diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c index 646045b007..d364e8da81 100644 --- a/ext/ffmpeg/gstffmpegdec.c +++ b/ext/ffmpeg/gstffmpegdec.c @@ -1628,6 +1628,18 @@ flush_queued (GstFFMpegDec * ffmpegdec) return res; } +static AVPacket * +gst_avpacket_new (guint8 * data, guint size) +{ + AVPacket *res; + + res = g_malloc0 (sizeof (AVPacket)); + res->data = data; + res->size = size; + + return res; +} + /* gst_ffmpegdec_[video|audio]_frame: * ffmpegdec: * data: pointer to the data to decode @@ -1655,6 +1667,7 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec, GstClockTime out_timestamp, out_duration, out_pts; gint64 out_offset; const GstTSInfo *out_info; + AVPacket *packet; *ret = GST_FLOW_OK; *outbuf = NULL; @@ -1700,8 +1713,9 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec, GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx); /* now decode the frame */ - len = avcodec_decode_video (ffmpegdec->context, - ffmpegdec->picture, &have_data, data, size); + packet = gst_avpacket_new (data, size); + len = avcodec_decode_video2 (ffmpegdec->context, + ffmpegdec->picture, &have_data, packet); /* restore previous state */ if (!decode) @@ -2053,6 +2067,7 @@ gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec, gint have_data = AVCODEC_MAX_AUDIO_FRAME_SIZE; GstClockTime out_timestamp, out_duration; gint64 out_offset; + AVPacket *packet; GST_DEBUG_OBJECT (ffmpegdec, "size:%d, offset:%" G_GINT64_FORMAT ", ts:%" GST_TIME_FORMAT ", dur:%" @@ -2064,8 +2079,9 @@ gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec, new_aligned_buffer (AVCODEC_MAX_AUDIO_FRAME_SIZE, GST_PAD_CAPS (ffmpegdec->srcpad)); - len = avcodec_decode_audio2 (ffmpegdec->context, - (int16_t *) GST_BUFFER_DATA (*outbuf), &have_data, data, size); + packet = gst_avpacket_new (data, size); + len = avcodec_decode_audio3 (ffmpegdec->context, + (int16_t *) GST_BUFFER_DATA (*outbuf), &have_data, packet); GST_DEBUG_OBJECT (ffmpegdec, "Decode audio: len=%d, have_data=%d", len, have_data);