[FFmpeg-devel] avformat/mov: improve timecode calculation

Submitted by Michael Niedermayer on Aug. 25, 2019, 4:53 p.m.

Details

Message ID 20190825165319.GE3219@michaelspb
State New
Headers show

Commit Message

Michael Niedermayer Aug. 25, 2019, 4:53 p.m.
On Fri, Aug 23, 2019 at 06:01:32PM +0200, Paul B Mahol wrote:
> Here is patch.
> 
> On Thu, Aug 22, 2019 at 6:18 PM Paul B Mahol <onemda@gmail.com> wrote:
> 
> > Hi,
> >
> > patch attached.
> >

>  mov.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 1f2e91bc38bd8e3f96e61076d79dac73e7d30390  0001-avformat-mov-improve-timecode-calculation.patch
> From 881fcc40aad27d646a9b5866569ed8ca0e78777b Mon Sep 17 00:00:00 2001
> From: Paul B Mahol <onemda@gmail.com>
> Date: Thu, 22 Aug 2019 18:14:15 +0200
> Subject: [PATCH] avformat/mov: improve timecode calculation
> 
> Fixes timecode calculation for NTSC frame rates.
> Fixes ticket #5978.
> ---
>  libavformat/mov.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 24de5429d1..8fffc51fcb 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -2303,8 +2303,8 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
>              int val;
>              val = AV_RB32(st->codecpar->extradata + 4);
>              tmcd_ctx->tmcd_flags = val;
> -            st->avg_frame_rate.num = st->codecpar->extradata[16]; /* number of frame */
> -            st->avg_frame_rate.den = 1;
> +            st->avg_frame_rate.num = AV_RB32(st->codecpar->extradata + 8); /* timescale */
> +            st->avg_frame_rate.den = AV_RB32(st->codecpar->extradata + 12); /* frameDuration */
>  #if FF_API_LAVF_AVCTX
>  FF_DISABLE_DEPRECATION_WARNINGS
>              st->codec->time_base = av_inv_q(st->avg_frame_rate);

breaks fate

Test copy-trac236 failed. Look at tests/data/fate/copy-trac236.err for details.
make: *** [fate-copy-trac236] Error 1

[...]

Comments

Paul B Mahol Aug. 25, 2019, 4:59 p.m.
On Sun, Aug 25, 2019 at 6:53 PM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> On Fri, Aug 23, 2019 at 06:01:32PM +0200, Paul B Mahol wrote:
> > Here is patch.
> >
> > On Thu, Aug 22, 2019 at 6:18 PM Paul B Mahol <onemda@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > patch attached.
> > >
>
> >  mov.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 1f2e91bc38bd8e3f96e61076d79dac73e7d30390
> 0001-avformat-mov-improve-timecode-calculation.patch
> > From 881fcc40aad27d646a9b5866569ed8ca0e78777b Mon Sep 17 00:00:00 2001
> > From: Paul B Mahol <onemda@gmail.com>
> > Date: Thu, 22 Aug 2019 18:14:15 +0200
> > Subject: [PATCH] avformat/mov: improve timecode calculation
> >
> > Fixes timecode calculation for NTSC frame rates.
> > Fixes ticket #5978.
> > ---
> >  libavformat/mov.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index 24de5429d1..8fffc51fcb 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -2303,8 +2303,8 @@ static int mov_parse_stsd_data(MOVContext *c,
> AVIOContext *pb,
> >              int val;
> >              val = AV_RB32(st->codecpar->extradata + 4);
> >              tmcd_ctx->tmcd_flags = val;
> > -            st->avg_frame_rate.num = st->codecpar->extradata[16]; /*
> number of frame */
> > -            st->avg_frame_rate.den = 1;
> > +            st->avg_frame_rate.num = AV_RB32(st->codecpar->extradata +
> 8); /* timescale */
> > +            st->avg_frame_rate.den = AV_RB32(st->codecpar->extradata +
> 12); /* frameDuration */
> >  #if FF_API_LAVF_AVCTX
> >  FF_DISABLE_DEPRECATION_WARNINGS
> >              st->codec->time_base = av_inv_q(st->avg_frame_rate);
>
> breaks fate
>

Obviously that test is broken.


>
> --- ./tests/ref/fate/copy-trac236       2019-08-23 23:30:40.819525130 +0200
> +++ tests/data/fate/copy-trac236        2019-08-25 18:50:46.578857135 +0200
> @@ -1,4 +1,4 @@
> -959a4d78c6c11936e361fc3101a013eb *tests/data/fate/copy-trac236.mov
> +984a33c6292e3d35e2cfdfbf66d8e82b *tests/data/fate/copy-trac236.mov
>  630860 tests/data/fate/copy-trac236.mov
>  #tb 0: 100/2997
>  #media_type 0: video
> Test copy-trac236 failed. Look at tests/data/fate/copy-trac236.err for
> details.
> make: *** [fate-copy-trac236] Error 1
>
> [...]
>
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The real ebay dictionary, page 2
> "100% positive feedback" - "All either got their money back or didnt
> complain"
> "Best seller ever, very honest" - "Seller refunded buyer after failed scam"
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
James Almer Aug. 25, 2019, 5:02 p.m.
On 8/25/2019 1:59 PM, Paul B Mahol wrote:
> On Sun, Aug 25, 2019 at 6:53 PM Michael Niedermayer <michael@niedermayer.cc>
> wrote:
> 
>> On Fri, Aug 23, 2019 at 06:01:32PM +0200, Paul B Mahol wrote:
>>> Here is patch.
>>>
>>> On Thu, Aug 22, 2019 at 6:18 PM Paul B Mahol <onemda@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> patch attached.
>>>>
>>
>>>  mov.c |    4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>> 1f2e91bc38bd8e3f96e61076d79dac73e7d30390
>> 0001-avformat-mov-improve-timecode-calculation.patch
>>> From 881fcc40aad27d646a9b5866569ed8ca0e78777b Mon Sep 17 00:00:00 2001
>>> From: Paul B Mahol <onemda@gmail.com>
>>> Date: Thu, 22 Aug 2019 18:14:15 +0200
>>> Subject: [PATCH] avformat/mov: improve timecode calculation
>>>
>>> Fixes timecode calculation for NTSC frame rates.
>>> Fixes ticket #5978.
>>> ---
>>>  libavformat/mov.c | 4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>>> index 24de5429d1..8fffc51fcb 100644
>>> --- a/libavformat/mov.c
>>> +++ b/libavformat/mov.c
>>> @@ -2303,8 +2303,8 @@ static int mov_parse_stsd_data(MOVContext *c,
>> AVIOContext *pb,
>>>              int val;
>>>              val = AV_RB32(st->codecpar->extradata + 4);
>>>              tmcd_ctx->tmcd_flags = val;
>>> -            st->avg_frame_rate.num = st->codecpar->extradata[16]; /*
>> number of frame */
>>> -            st->avg_frame_rate.den = 1;
>>> +            st->avg_frame_rate.num = AV_RB32(st->codecpar->extradata +
>> 8); /* timescale */
>>> +            st->avg_frame_rate.den = AV_RB32(st->codecpar->extradata +
>> 12); /* frameDuration */
>>>  #if FF_API_LAVF_AVCTX
>>>  FF_DISABLE_DEPRECATION_WARNINGS
>>>              st->codec->time_base = av_inv_q(st->avg_frame_rate);
>>
>> breaks fate
>>
> 
> Obviously that test is broken.

Then make sure to update the test ref file in this same patch before
pushing.

Patch hide | download patch | download mbox

--- ./tests/ref/fate/copy-trac236	2019-08-23 23:30:40.819525130 +0200
+++ tests/data/fate/copy-trac236	2019-08-25 18:50:46.578857135 +0200
@@ -1,4 +1,4 @@ 
-959a4d78c6c11936e361fc3101a013eb *tests/data/fate/copy-trac236.mov
+984a33c6292e3d35e2cfdfbf66d8e82b *tests/data/fate/copy-trac236.mov
 630860 tests/data/fate/copy-trac236.mov
 #tb 0: 100/2997
 #media_type 0: video