mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +00:00
ext/ffmpeg/gstffmpegdec.c: Add some more timestamp debugging.
Original commit message from CVS: * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open), (check_keyframe), (gst_ffmpegdec_video_frame), (gst_ffmpegdec_chain): Add some more timestamp debugging. Fixed wrong duration whn not using a parser.
This commit is contained in:
parent
9e06696cca
commit
16fec520b3
2 changed files with 51 additions and 22 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2006-09-13 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
|
||||||
|
(check_keyframe), (gst_ffmpegdec_video_frame),
|
||||||
|
(gst_ffmpegdec_chain):
|
||||||
|
Add some more timestamp debugging.
|
||||||
|
Fixed wrong duration whn not using a parser.
|
||||||
|
|
||||||
2006-09-08 Edward Hervey <edward@fluendo.com>
|
2006-09-08 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
|
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
|
||||||
|
|
|
@ -482,14 +482,19 @@ gst_ffmpegdec_open (GstFFMpegDec * ffmpegdec)
|
||||||
GST_LOG_OBJECT (ffmpegdec, "Opened ffmpeg codec %s, id %d",
|
GST_LOG_OBJECT (ffmpegdec, "Opened ffmpeg codec %s, id %d",
|
||||||
oclass->in_plugin->name, oclass->in_plugin->id);
|
oclass->in_plugin->name, oclass->in_plugin->id);
|
||||||
|
|
||||||
/* open a parser if we can - exclude mp3 because it doesn't work (?),
|
/* open a parser if we can */
|
||||||
* and mjpeg because ... */
|
switch (oclass->in_plugin->id) {
|
||||||
if (oclass->in_plugin->id != CODEC_ID_MPEG4 &&
|
case CODEC_ID_MPEG4:
|
||||||
oclass->in_plugin->id != CODEC_ID_MJPEG &&
|
case CODEC_ID_MJPEG:
|
||||||
oclass->in_plugin->id != CODEC_ID_MP3 &&
|
case CODEC_ID_MP3:
|
||||||
oclass->in_plugin->id != CODEC_ID_H264) {
|
case CODEC_ID_H264:
|
||||||
|
GST_LOG_OBJECT (ffmpegdec, "not using parser, blacklisted codec");
|
||||||
|
ffmpegdec->pctx = NULL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
GST_LOG_OBJECT (ffmpegdec, "Using parser");
|
GST_LOG_OBJECT (ffmpegdec, "Using parser");
|
||||||
ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
|
ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (oclass->in_plugin->type) {
|
switch (oclass->in_plugin->type) {
|
||||||
|
@ -1068,8 +1073,8 @@ check_keyframe (GstFFMpegDec * ffmpegdec)
|
||||||
|| (oclass->in_plugin->id == CODEC_ID_HUFFYUV);
|
|| (oclass->in_plugin->id == CODEC_ID_HUFFYUV);
|
||||||
|
|
||||||
GST_LOG_OBJECT (ffmpegdec,
|
GST_LOG_OBJECT (ffmpegdec,
|
||||||
"current picture: is_keyframe:%d, is_itype:%d, is_reference:%d",
|
"current picture: type: %d, is_keyframe:%d, is_itype:%d, is_reference:%d",
|
||||||
iskeyframe, is_itype, is_reference);
|
ffmpegdec->picture->pict_type, iskeyframe, is_itype, is_reference);
|
||||||
|
|
||||||
return iskeyframe;
|
return iskeyframe;
|
||||||
}
|
}
|
||||||
|
@ -1203,6 +1208,10 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
|
||||||
if (len < 0 || have_data <= 0)
|
if (len < 0 || have_data <= 0)
|
||||||
goto beach;
|
goto beach;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %"G_GUINT64_FORMAT, ffmpegdec->picture->pts);
|
||||||
|
GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d", ffmpegdec->picture->coded_picture_number);
|
||||||
|
GST_DEBUG_OBJECT (ffmpegdec, "picture: display %d", ffmpegdec->picture->display_picture_number);
|
||||||
|
|
||||||
/* check if we are dealing with a keyframe here */
|
/* check if we are dealing with a keyframe here */
|
||||||
iskeyframe = check_keyframe (ffmpegdec);
|
iskeyframe = check_keyframe (ffmpegdec);
|
||||||
|
|
||||||
|
@ -1224,10 +1233,22 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
|
||||||
/*
|
/*
|
||||||
* Timestamps:
|
* Timestamps:
|
||||||
*
|
*
|
||||||
* 1) Copy input timestamp if valid
|
* 1) Copy parse context timestamp if present and valid (FIXME)
|
||||||
* 2) else interpolate from previous input timestamp
|
* 2) Copy input timestamp if valid
|
||||||
|
* 3) else interpolate from previous input timestamp
|
||||||
*/
|
*/
|
||||||
/* always take timestamps from the input buffer if any */
|
#if 0
|
||||||
|
/* this does not work reliably, for some files this works fine, for other
|
||||||
|
* files it returns the same timestamp twice. Leaving the code here for when
|
||||||
|
* the parsers are improved in ffmpeg. */
|
||||||
|
if (ffmpegdec->pctx) {
|
||||||
|
GST_DEBUG_OBJECT (ffmpegdec, "picture: ffpts %"G_GUINT64_FORMAT, ffmpegdec->pctx->pts);
|
||||||
|
if (ffmpegdec->pctx->pts != AV_NOPTS_VALUE) {
|
||||||
|
in_timestamp = gst_ffmpeg_time_ff_to_gst (ffmpegdec->pctx->pts,
|
||||||
|
ffmpegdec->context->time_base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (!GST_CLOCK_TIME_IS_VALID (in_timestamp)) {
|
if (!GST_CLOCK_TIME_IS_VALID (in_timestamp)) {
|
||||||
GST_LOG_OBJECT (ffmpegdec, "using timestamp returned by ffmpeg");
|
GST_LOG_OBJECT (ffmpegdec, "using timestamp returned by ffmpeg");
|
||||||
/* Get (interpolated) timestamp from FFMPEG */
|
/* Get (interpolated) timestamp from FFMPEG */
|
||||||
|
@ -1814,7 +1835,7 @@ gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
|
||||||
/* no cache, input timestamp matches the buffer we try to decode */
|
/* no cache, input timestamp matches the buffer we try to decode */
|
||||||
left = 0;
|
left = 0;
|
||||||
in_timestamp = pending_timestamp;
|
in_timestamp = pending_timestamp;
|
||||||
in_duration = pending_timestamp;
|
in_duration = pending_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* workarounds, functions write to buffers:
|
/* workarounds, functions write to buffers:
|
||||||
|
@ -1835,13 +1856,13 @@ gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
|
||||||
gint res;
|
gint res;
|
||||||
gint64 ffpts;
|
gint64 ffpts;
|
||||||
|
|
||||||
GST_LOG_OBJECT (ffmpegdec,
|
|
||||||
"Calling av_parser_parse with ts:%" GST_TIME_FORMAT,
|
|
||||||
GST_TIME_ARGS (in_timestamp));
|
|
||||||
|
|
||||||
/* convert timestamp to ffmpeg timestamp */
|
/* convert timestamp to ffmpeg timestamp */
|
||||||
ffpts = gst_ffmpeg_time_gst_to_ff (in_timestamp, ffmpegdec->context->time_base);
|
ffpts = gst_ffmpeg_time_gst_to_ff (in_timestamp, ffmpegdec->context->time_base);
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (ffmpegdec,
|
||||||
|
"Calling av_parser_parse with ts:%" GST_TIME_FORMAT", ffpts:%"G_GINT64_FORMAT,
|
||||||
|
GST_TIME_ARGS (in_timestamp), ffpts);
|
||||||
|
|
||||||
/* feed the parser */
|
/* feed the parser */
|
||||||
res = av_parser_parse (ffmpegdec->pctx, ffmpegdec->context,
|
res = av_parser_parse (ffmpegdec->pctx, ffmpegdec->context,
|
||||||
&data, &size, bdata, bsize, ffpts, ffpts);
|
&data, &size, bdata, bsize, ffpts, ffpts);
|
||||||
|
@ -1854,8 +1875,8 @@ gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GST_LOG_OBJECT (ffmpegdec, "consuming %d bytes. Next ts at %d",
|
GST_LOG_OBJECT (ffmpegdec, "consuming %d bytes. Next ts at %d, ffpts:%"G_GINT64_FORMAT,
|
||||||
size, left);
|
size, left, ffmpegdec->pctx->pts);
|
||||||
|
|
||||||
/* there is output, set pointers for next round. */
|
/* there is output, set pointers for next round. */
|
||||||
bsize -= size;
|
bsize -= size;
|
||||||
|
@ -1879,8 +1900,8 @@ gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
|
||||||
next_timestamp = gst_ffmpeg_time_ff_to_gst (ffmpegdec->pctx->pts,
|
next_timestamp = gst_ffmpeg_time_ff_to_gst (ffmpegdec->pctx->pts,
|
||||||
ffmpegdec->context->time_base);
|
ffmpegdec->context->time_base);
|
||||||
next_duration = GST_CLOCK_TIME_NONE;
|
next_duration = GST_CLOCK_TIME_NONE;
|
||||||
GST_LOG_OBJECT (ffmpegdec, "parse context next ts:%" GST_TIME_FORMAT,
|
GST_LOG_OBJECT (ffmpegdec, "parse context next ts:%" GST_TIME_FORMAT", ffpts:%"G_GINT64_FORMAT,
|
||||||
GST_TIME_ARGS (next_timestamp));
|
GST_TIME_ARGS (next_timestamp), ffpts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue