[Ffmpeg-devel] [PATCH] a fix in ffmpeg.c
Limin Wang
lance.lmwang
Tue Jan 30 02:53:47 CET 2007
Hi,
* Michael Niedermayer <michaelni at gmx.at> [2007-01-30 01:34:19 +0100]:
> Hi
>
> On Tue, Jan 23, 2007 at 11:06:53AM +0800, Limin Wang wrote:
> > Hi,
> >
> > > this looks better but it still has problems
> > > first it overrides the demuxer timebase blindly, which breaks some
> > > h264 in avi/mov, also it breaks user specified timebases
> > > (ffmpeg -r 12 myfile.h264 out.abc)
> > >
> > > so the check should not be for CODEC_ID_H264 but rather for the lack of
> > > a set timebase (this needs some change to libavformat/raw.c more specifically
> > > the hardcoded 1/25 timebase there should be changed to 0/0) then utils.c
> > > somewhere should check for this and set it to the codec timebase
> > > st->codec->time_base with av_set_pts_info or if that also is 0/0 then
> > > use some random default like 1/25
> >
> > I have fixed by your suggestion, please review the attached patch. One problem
> > is it'll cause av_rescale_q() in utils.c floating point exception, I don't know
> > what's the background. After comment it out, I can pass the test without
>
> av_rescale_q cant work with 0/0 timebase
> a if(timebase.den != 0) around that should fix it
OK, fix by this way instead of comment out. Please review regenerated patch
in attached file.
> also do the regresion tests pass with your patch (make test) ?
> and video grabing should also be tested (by someone) if all works fine then
> this patch (with the av_rescale_q if fix) should be ok
How to do the regresion tests? Any automatic test script? I have pass the test
with (h264->yuv, mov->yuv, > mp4->yuv). Who can do the video grabing testing?
I don't know how to test it.
Thanks,
Limin
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Democracy is the form of government in which you can choose your dictator
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
-------------- next part --------------
Index: ffmpeg.c
===================================================================
--- ffmpeg.c (revision 7763)
+++ ffmpeg.c (working copy)
@@ -107,8 +107,8 @@
static int frame_leftBand = 0;
static int frame_rightBand = 0;
static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX};
-static int frame_rate = 25;
-static int frame_rate_base = 1;
+static int frame_rate = 0;
+static int frame_rate_base = 0;
static float video_qscale = 0;
static int video_qdiff = 3;
static uint16_t *intra_matrix = NULL;
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c (revision 7763)
+++ libavformat/utils.c (working copy)
@@ -1939,8 +1939,8 @@
st->codec->codec_id == CODEC_ID_SHORTEN ||
(st->codec->codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/)
try_decode_frame(st, pkt->data, pkt->size);
-
- if (av_rescale_q(st->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
+ if (st->time_base.den != 0 &&
+ av_rescale_q(st->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
break;
}
count++;
@@ -1986,6 +1986,12 @@
st->r_frame_rate.den = st->time_base.num;
}
}
+
+ /* update with real frame rate if user didn't force it */
+ if( !st->time_base.num )
+ av_set_pts_info(st, 64, st->r_frame_rate.num, st->r_frame_rate.den);
+ else
+ av_set_pts_info(st, 64, 1, 25);
}
}
Index: libavformat/raw.c
===================================================================
--- libavformat/raw.c (revision 7763)
+++ libavformat/raw.c (working copy)
@@ -304,11 +304,13 @@
/* for mjpeg, specify frame rate */
/* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/
if (ap->time_base.num) {
+ /* user force fps */
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
} else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
st->codec->codec_id == CODEC_ID_MPEG4 ||
st->codec->codec_id == CODEC_ID_H264) {
- av_set_pts_info(st, 64, 1, 25);
+ /* default is 0/0 */
+ av_set_pts_info(st, 64, 0, 0);
}
return 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070130/9ff5064a/attachment.pgp>
More information about the ffmpeg-devel
mailing list