[FFmpeg-devel] [PATCH] simplify ipmovie.c pts calculation
Michael Niedermayer
michaelni
Fri Feb 27 00:28:03 CET 2009
On Thu, Feb 26, 2009 at 11:01:26PM +0100, Reimar D?ffinger wrote:
> On Thu, Feb 26, 2009 at 09:37:53PM +0100, Michael Niedermayer wrote:
> > it should at least realize that 8341/125000 can represent them exactly
> > a patch that runs gcd over them is welcome
>
> Something like attached patch? It should work fine for all files that
> actually are constant-frame-rate and have an exact time-base.
> It works great for .mve files, but I haven't tested it well and I won't
> (I'm supposed to learn for exams :-) ).
>
> > also a patch that lets the user app configure its threshold of acceptance
> > a little would be welcome, for example
> > transcoding a file with 1/10000000 timebase to avi reqiures a smaller
> > timebase and it should select the best it can.
>
> Hm, I think it's actually large duration values, not large time bases
> that causes problems, isn't it?
of course
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 073e6da..9960fcd 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -2006,6 +2006,7 @@ int av_find_stream_info(AVFormatContext *ic)
> AVStream *st;
> AVPacket pkt1, *pkt;
> int64_t last_dts[MAX_STREAMS];
> + int64_t duration_gcd[MAX_STREAMS]={0};
> int duration_count[MAX_STREAMS]={0};
> double (*duration_error)[MAX_STD_TIMEBASES];
> int64_t old_offset = url_ftell(ic->pb);
> @@ -2127,6 +2128,7 @@ int av_find_stream_info(AVFormatContext *ic)
> double error= dur - ticks*1001*12/(double)framerate;
> duration_error[index][i] += error*error;
> }
> + duration_gcd[index] = av_gcd(duration_gcd[index], duration);
> duration_count[index]++;
> }
> if(last == AV_NOPTS_VALUE || duration_count[index]<=1)
> @@ -2181,6 +2183,8 @@ int av_find_stream_info(AVFormatContext *ic)
> if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_coded_sample)
> st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
>
> + if (duration_count[i] > 5 && duration_gcd[i] > 1)
> + av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * duration_gcd[i], INT_MAX);
maybe this should be under tb_unreliable() and the number should be higher
than 5 (patch ok with <- these)
also if you ignore the first 1-2 durations then this might fix the fps of
h264_acc_in_flv.flv i think
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Thouse who are best at talking, realize last or never when they are wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090227/f8a6a198/attachment.pgp>
More information about the ffmpeg-devel
mailing list