decoder/ffmpeg: copy the AVPacket in ffmpeg_send_packet()

Revert commit 70495aad by rewriting it.  Turns out, in old FFmpeg
versions, copying the AVPacket is necessary.
This commit is contained in:
Max Kellermann 2016-07-28 19:41:05 +02:00
parent c25b464f37
commit eb192137d6
2 changed files with 20 additions and 1 deletions

1
NEWS
View File

@ -1,5 +1,6 @@
ver 0.19.18 (not yet released)
* decoder
- ffmpeg: fix crash with older FFmpeg versions (< 3.0)
- ffmpeg: log detailed error message
ver 0.19.17 (2016/07/09)

View File

@ -419,6 +419,24 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
return cmd;
}
static DecoderCommand
ffmpeg_send_packet(Decoder &decoder, InputStream &is,
const AVPacket &packet,
AVCodecContext &codec_context,
const AVStream &stream,
AVFrame *frame,
uint64_t min_frame, size_t pcm_frame_size,
FfmpegBuffer &buffer)
{
return ffmpeg_send_packet(decoder, is,
/* copy the AVPacket, because FFmpeg
< 3.0 requires this */
AVPacket(packet),
codec_context, stream,
frame, min_frame, pcm_frame_size,
buffer);
}
gcc_const
static SampleFormat
ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
@ -627,7 +645,7 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
if (packet.stream_index == audio_stream) {
cmd = ffmpeg_send_packet(decoder, input,
std::move(packet),
packet,
*codec_context,
*av_stream,
frame,