mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 03:29:50 +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;
|
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:
|
/* gst_ffmpegdec_[video|audio]_frame:
|
||||||
* ffmpegdec:
|
* ffmpegdec:
|
||||||
* data: pointer to the data to decode
|
* data: pointer to the data to decode
|
||||||
|
@ -1655,6 +1667,7 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
|
||||||
GstClockTime out_timestamp, out_duration, out_pts;
|
GstClockTime out_timestamp, out_duration, out_pts;
|
||||||
gint64 out_offset;
|
gint64 out_offset;
|
||||||
const GstTSInfo *out_info;
|
const GstTSInfo *out_info;
|
||||||
|
AVPacket *packet;
|
||||||
|
|
||||||
*ret = GST_FLOW_OK;
|
*ret = GST_FLOW_OK;
|
||||||
*outbuf = NULL;
|
*outbuf = NULL;
|
||||||
|
@ -1700,8 +1713,9 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
|
||||||
GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx);
|
GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx);
|
||||||
|
|
||||||
/* now decode the frame */
|
/* now decode the frame */
|
||||||
len = avcodec_decode_video (ffmpegdec->context,
|
packet = gst_avpacket_new (data, size);
|
||||||
ffmpegdec->picture, &have_data, data, size);
|
len = avcodec_decode_video2 (ffmpegdec->context,
|
||||||
|
ffmpegdec->picture, &have_data, packet);
|
||||||
|
|
||||||
/* restore previous state */
|
/* restore previous state */
|
||||||
if (!decode)
|
if (!decode)
|
||||||
|
@ -2053,6 +2067,7 @@ gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
|
||||||
gint have_data = AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
gint have_data = AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
||||||
GstClockTime out_timestamp, out_duration;
|
GstClockTime out_timestamp, out_duration;
|
||||||
gint64 out_offset;
|
gint64 out_offset;
|
||||||
|
AVPacket *packet;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (ffmpegdec,
|
GST_DEBUG_OBJECT (ffmpegdec,
|
||||||
"size:%d, offset:%" G_GINT64_FORMAT ", ts:%" GST_TIME_FORMAT ", dur:%"
|
"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,
|
new_aligned_buffer (AVCODEC_MAX_AUDIO_FRAME_SIZE,
|
||||||
GST_PAD_CAPS (ffmpegdec->srcpad));
|
GST_PAD_CAPS (ffmpegdec->srcpad));
|
||||||
|
|
||||||
len = avcodec_decode_audio2 (ffmpegdec->context,
|
packet = gst_avpacket_new (data, size);
|
||||||
(int16_t *) GST_BUFFER_DATA (*outbuf), &have_data, data, size);
|
len = avcodec_decode_audio3 (ffmpegdec->context,
|
||||||
|
(int16_t *) GST_BUFFER_DATA (*outbuf), &have_data, packet);
|
||||||
GST_DEBUG_OBJECT (ffmpegdec,
|
GST_DEBUG_OBJECT (ffmpegdec,
|
||||||
"Decode audio: len=%d, have_data=%d", len, have_data);
|
"Decode audio: len=%d, have_data=%d", len, have_data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue