[FFmpeg-devel] Suggested Patch for timecode timebase calculation in mov.c

Michael Niedermayer michaelni at gmx.at
Wed Sep 10 00:10:27 CEST 2014


On Tue, Sep 09, 2014 at 12:01:23PM -0700, jon wrote:
> Hi ffmpeg developers.
> 
> I am still new to attempting contributing here, so please let me
> know if there is a better approach for this. I am attaching a patch
> I would like to incorporate for calculating the stream time_base of
> the timecode data track in mov's. Please advise.
> 
> Thanks!

>  mov.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 520754621cc38bff327ffd487d43d07c8f14925c  timecode_time_base.patch
> From 5ae0b5a9cf9c37e11d5a3fea05c80c66b7c00c3e Mon Sep 17 00:00:00 2001
> From: Jon Morley <jon at tweaksoftware.com>
> Date: Tue, 9 Sep 2014 11:48:02 -0700
> Subject: [PATCH] libavformat/mov.c: Set stream time_base from
>  frameduration/timescale
> 
> Use tmcd atom's timescale and frameduration to for stream time base
> instead of 1/framenum. For timecode streams that have an entry for each
> frame 1/framenum is less accurate than frameduration/timescale.
> ---
>  libavformat/mov.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index ae48c02..c300dd2 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1530,8 +1530,10 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
>              tmcd_ctx->tmcd_flags = val;
>              if (val & 1)
>                  st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE;
> -            st->codec->time_base.den = st->codec->extradata[16]; /* number of frame */
> -            st->codec->time_base.num = 1;
> +            int timescale = AV_RB32(st->codec->extradata + 8);
> +            int framedur  =  AV_RB32(st->codec->extradata + 12);
> +            st->codec->time_base.den = timescale;
> +            st->codec->time_base.num = framedur;            

the intermediate variables look unneeded.
But if you want to keep them, their declaration should be moved to the
block start as some compilers dont like mixed declarations and
statements.

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140910/5941ca31/attachment.asc>


More information about the ffmpeg-devel mailing list