mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-18 13:25:56 +00:00
ffmpegdec: Use new AVPacket-based API
Right now it doesn't use any of the extra fields AVPacket provides. It might be wise to investigate the pts/dts ones to see if we can finally get rid of the timing-related cruft we have.
This commit is contained in:
parent
436a211aff
commit
fe1a971b31
1 changed files with 20 additions and 4 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue