diff mbox series

[FFmpeg-devel] lavf/subviewerdec: Support higher sub-second precision

Message ID CAB0OVGrz5S4MXcV=gC=Aj-f+L0JimE8EGcg0kxQG0VPzqEhJ3w@mail.gmail.com
State Accepted
Headers show
Series [FFmpeg-devel] lavf/subviewerdec: Support higher sub-second precision
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Carl Eugen Hoyos March 18, 2020, 1:16 a.m. UTC
Hi!

Attached patch fixes ticket #8575 for me, Google describes such files.

Please comment, Carl Eugen

Comments

Paul B Mahol March 18, 2020, 9:27 a.m. UTC | #1
On 3/18/20, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> Hi!
>
> Attached patch fixes ticket #8575 for me, Google describes such files.
>
> Please comment, Carl Eugen
>

Does it pass FATE?
Carl Eugen Hoyos March 18, 2020, 9:52 a.m. UTC | #2
Am Mi., 18. März 2020 um 10:27 Uhr schrieb Paul B Mahol <onemda@gmail.com>:
>
> On 3/18/20, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >
> > Attached patch fixes ticket #8575 for me, Google describes such files.

> Does it pass FATE?

Yes, it does.

Carl Eugen
Carl Eugen Hoyos March 18, 2020, 11:39 p.m. UTC | #3
Am Mi., 18. März 2020 um 02:16 Uhr schrieb Carl Eugen Hoyos
<ceffmpeg@gmail.com>:
>
> Hi!
>
> Attached patch fixes ticket #8575 for me, Google describes such files.

Ping.

Carl Eugen
Michael Niedermayer March 19, 2020, 6:32 p.m. UTC | #4
On Wed, Mar 18, 2020 at 02:16:30AM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #8575 for me, Google describes such files.
> 
> Please comment, Carl Eugen

>  subviewerdec.c |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 1a6133ed3dbb66945d6bf16e212c0e77e3fd0579  0001-lavf-subviewerdec-Support-higher-sub-second-precisio.patch
> From 39d0748782bb3e37fb2f92c679ffa58b239374c7 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> Date: Wed, 18 Mar 2020 02:11:33 +0100
> Subject: [PATCH] lavf/subviewerdec: Support higher sub-second precision.
> 
> Fixes ticket #8575.
> ---
>  libavformat/subviewerdec.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
> index 06b827b70f..ed48b3388d 100644
> --- a/libavformat/subviewerdec.c
> +++ b/libavformat/subviewerdec.c
> @@ -56,11 +56,15 @@ static int read_ts(const char *s, int64_t *start, int *duration)
>      int64_t end;
>      int hh1, mm1, ss1, ms1;
>      int hh2, mm2, ss2, ms2;
> +    int multiplier = 1;
>  
> +    if (sscanf(s, "%u:%u:%u.%2u,%u:%u:%u.%2u",
> +               &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8)
> +        multiplier = 10;
>      if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
>                 &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {

which lengths can the ms1 / ms2 part have ?
do all of the following work ?
x.1
x.19
x.199
x.1999

or are some of these guranteed not to occur ?


thx

[...]
Carl Eugen Hoyos March 19, 2020, 9:18 p.m. UTC | #5
Am Do., 19. März 2020 um 19:32 Uhr schrieb Michael Niedermayer
<michael@niedermayer.cc>:
>
> On Wed, Mar 18, 2020 at 02:16:30AM +0100, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > Attached patch fixes ticket #8575 for me, Google describes such files.
> >
> > Please comment, Carl Eugen
>
> >  subviewerdec.c |   10 +++++++---
> >  1 file changed, 7 insertions(+), 3 deletions(-)
> > 1a6133ed3dbb66945d6bf16e212c0e77e3fd0579  0001-lavf-subviewerdec-Support-higher-sub-second-precisio.patch
> > From 39d0748782bb3e37fb2f92c679ffa58b239374c7 Mon Sep 17 00:00:00 2001
> > From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> > Date: Wed, 18 Mar 2020 02:11:33 +0100
> > Subject: [PATCH] lavf/subviewerdec: Support higher sub-second precision.
> >
> > Fixes ticket #8575.
> > ---
> >  libavformat/subviewerdec.c | 10 +++++++---
> >  1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
> > index 06b827b70f..ed48b3388d 100644
> > --- a/libavformat/subviewerdec.c
> > +++ b/libavformat/subviewerdec.c
> > @@ -56,11 +56,15 @@ static int read_ts(const char *s, int64_t *start, int *duration)
> >      int64_t end;
> >      int hh1, mm1, ss1, ms1;
> >      int hh2, mm2, ss2, ms2;
> > +    int multiplier = 1;
> >
> > +    if (sscanf(s, "%u:%u:%u.%2u,%u:%u:%u.%2u",
> > +               &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8)
> > +        multiplier = 10;
> >      if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
> >                 &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
>
> which lengths can the ms1 / ms2 part have ?
> do all of the following work ?
> x.1
> x.19
> x.199
> x.1999
>
> or are some of these guranteed not to occur ?

I have no idea but my suspicion is that whoever created the files
in question misunderstood the original format.

Carl Eugen
Michael Niedermayer March 20, 2020, 12:48 a.m. UTC | #6
On Thu, Mar 19, 2020 at 10:18:33PM +0100, Carl Eugen Hoyos wrote:
> Am Do., 19. März 2020 um 19:32 Uhr schrieb Michael Niedermayer
> <michael@niedermayer.cc>:
> >
> > On Wed, Mar 18, 2020 at 02:16:30AM +0100, Carl Eugen Hoyos wrote:
> > > Hi!
> > >
> > > Attached patch fixes ticket #8575 for me, Google describes such files.
> > >
> > > Please comment, Carl Eugen
> >
> > >  subviewerdec.c |   10 +++++++---
> > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > > 1a6133ed3dbb66945d6bf16e212c0e77e3fd0579  0001-lavf-subviewerdec-Support-higher-sub-second-precisio.patch
> > > From 39d0748782bb3e37fb2f92c679ffa58b239374c7 Mon Sep 17 00:00:00 2001
> > > From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> > > Date: Wed, 18 Mar 2020 02:11:33 +0100
> > > Subject: [PATCH] lavf/subviewerdec: Support higher sub-second precision.
> > >
> > > Fixes ticket #8575.
> > > ---
> > >  libavformat/subviewerdec.c | 10 +++++++---
> > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
> > > index 06b827b70f..ed48b3388d 100644
> > > --- a/libavformat/subviewerdec.c
> > > +++ b/libavformat/subviewerdec.c
> > > @@ -56,11 +56,15 @@ static int read_ts(const char *s, int64_t *start, int *duration)
> > >      int64_t end;
> > >      int hh1, mm1, ss1, ms1;
> > >      int hh2, mm2, ss2, ms2;
> > > +    int multiplier = 1;
> > >
> > > +    if (sscanf(s, "%u:%u:%u.%2u,%u:%u:%u.%2u",
> > > +               &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8)
> > > +        multiplier = 10;
> > >      if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
> > >                 &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
> >
> > which lengths can the ms1 / ms2 part have ?
> > do all of the following work ?
> > x.1
> > x.19
> > x.199
> > x.1999
> >
> > or are some of these guranteed not to occur ?
> 
> I have no idea but my suspicion is that whoever created the files
> in question misunderstood the original format.

then i would suggest that the code either supports all variants of this
or checks if the input is one of the supported ones.
basically checking how long the ms1/ms2 fields are IIUC

thx

[...]
Carl Eugen Hoyos March 20, 2020, 8:05 a.m. UTC | #7
Am Fr., 20. März 2020 um 01:49 Uhr schrieb Michael Niedermayer
<michael@niedermayer.cc>:
>
> On Thu, Mar 19, 2020 at 10:18:33PM +0100, Carl Eugen Hoyos wrote:
> > Am Do., 19. März 2020 um 19:32 Uhr schrieb Michael Niedermayer
> > <michael@niedermayer.cc>:
> > >
> > > On Wed, Mar 18, 2020 at 02:16:30AM +0100, Carl Eugen Hoyos wrote:
> > > > Hi!
> > > >
> > > > Attached patch fixes ticket #8575 for me, Google describes such files.
> > > >
> > > > Please comment, Carl Eugen
> > >
> > > >  subviewerdec.c |   10 +++++++---
> > > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > > > 1a6133ed3dbb66945d6bf16e212c0e77e3fd0579  0001-lavf-subviewerdec-Support-higher-sub-second-precisio.patch
> > > > From 39d0748782bb3e37fb2f92c679ffa58b239374c7 Mon Sep 17 00:00:00 2001
> > > > From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> > > > Date: Wed, 18 Mar 2020 02:11:33 +0100
> > > > Subject: [PATCH] lavf/subviewerdec: Support higher sub-second precision.
> > > >
> > > > Fixes ticket #8575.
> > > > ---
> > > >  libavformat/subviewerdec.c | 10 +++++++---
> > > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
> > > > index 06b827b70f..ed48b3388d 100644
> > > > --- a/libavformat/subviewerdec.c
> > > > +++ b/libavformat/subviewerdec.c
> > > > @@ -56,11 +56,15 @@ static int read_ts(const char *s, int64_t *start, int *duration)
> > > >      int64_t end;
> > > >      int hh1, mm1, ss1, ms1;
> > > >      int hh2, mm2, ss2, ms2;
> > > > +    int multiplier = 1;
> > > >
> > > > +    if (sscanf(s, "%u:%u:%u.%2u,%u:%u:%u.%2u",
> > > > +               &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8)
> > > > +        multiplier = 10;
> > > >      if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
> > > >                 &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
> > >
> > > which lengths can the ms1 / ms2 part have ?
> > > do all of the following work ?
> > > x.1
> > > x.19
> > > x.199
> > > x.1999
> > >
> > > or are some of these guranteed not to occur ?
> >
> > I have no idea but my suspicion is that whoever created the files
> > in question misunderstood the original format.
>
> then i would suggest that the code either supports all variants of this
> or checks if the input is one of the supported ones.
> basically checking how long the ms1/ms2 fields are IIUC

New patch attached.

Thank you, Carl Eugen
Michael Niedermayer March 21, 2020, 5:35 p.m. UTC | #8
On Fri, Mar 20, 2020 at 09:05:12AM +0100, Carl Eugen Hoyos wrote:
> Am Fr., 20. März 2020 um 01:49 Uhr schrieb Michael Niedermayer
> <michael@niedermayer.cc>:
> >
> > On Thu, Mar 19, 2020 at 10:18:33PM +0100, Carl Eugen Hoyos wrote:
> > > Am Do., 19. März 2020 um 19:32 Uhr schrieb Michael Niedermayer
> > > <michael@niedermayer.cc>:
> > > >
> > > > On Wed, Mar 18, 2020 at 02:16:30AM +0100, Carl Eugen Hoyos wrote:
> > > > > Hi!
> > > > >
> > > > > Attached patch fixes ticket #8575 for me, Google describes such files.
> > > > >
> > > > > Please comment, Carl Eugen
> > > >
> > > > >  subviewerdec.c |   10 +++++++---
> > > > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > > > > 1a6133ed3dbb66945d6bf16e212c0e77e3fd0579  0001-lavf-subviewerdec-Support-higher-sub-second-precisio.patch
> > > > > From 39d0748782bb3e37fb2f92c679ffa58b239374c7 Mon Sep 17 00:00:00 2001
> > > > > From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> > > > > Date: Wed, 18 Mar 2020 02:11:33 +0100
> > > > > Subject: [PATCH] lavf/subviewerdec: Support higher sub-second precision.
> > > > >
> > > > > Fixes ticket #8575.
> > > > > ---
> > > > >  libavformat/subviewerdec.c | 10 +++++++---
> > > > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > > > >
> > > > > diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
> > > > > index 06b827b70f..ed48b3388d 100644
> > > > > --- a/libavformat/subviewerdec.c
> > > > > +++ b/libavformat/subviewerdec.c
> > > > > @@ -56,11 +56,15 @@ static int read_ts(const char *s, int64_t *start, int *duration)
> > > > >      int64_t end;
> > > > >      int hh1, mm1, ss1, ms1;
> > > > >      int hh2, mm2, ss2, ms2;
> > > > > +    int multiplier = 1;
> > > > >
> > > > > +    if (sscanf(s, "%u:%u:%u.%2u,%u:%u:%u.%2u",
> > > > > +               &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8)
> > > > > +        multiplier = 10;
> > > > >      if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
> > > > >                 &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
> > > >
> > > > which lengths can the ms1 / ms2 part have ?
> > > > do all of the following work ?
> > > > x.1
> > > > x.19
> > > > x.199
> > > > x.1999
> > > >
> > > > or are some of these guranteed not to occur ?
> > >
> > > I have no idea but my suspicion is that whoever created the files
> > > in question misunderstood the original format.
> >
> > then i would suggest that the code either supports all variants of this
> > or checks if the input is one of the supported ones.
> > basically checking how long the ms1/ms2 fields are IIUC
> 
> New patch attached.
> 
> Thank you, Carl Eugen

>  subviewerdec.c |   16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 09ba97edd94b332e899d1669626229cacab4fbbe  0001-lavf-subviewerdec-Support-higher-sub-second-precisio.patch
> From 17574e5cb44dead6990051540ada103610ee1e5b Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> Date: Fri, 20 Mar 2020 09:02:59 +0100
> Subject: [PATCH] lavf/subviewerdec: Support higher sub-second precision.
> 
> Fixes ticket #8575.
> ---
>  libavformat/subviewerdec.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
> index 06b827b70f..83378eab5f 100644
> --- a/libavformat/subviewerdec.c
> +++ b/libavformat/subviewerdec.c
> @@ -56,11 +56,21 @@ static int read_ts(const char *s, int64_t *start, int *duration)
>      int64_t end;
>      int hh1, mm1, ss1, ms1;
>      int hh2, mm2, ss2, ms2;
> +    int multiplier = 1;
>  
> +    if (sscanf(s, "%u:%u:%u.%2u,%u:%u:%u.%2u",
> +               &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
> +        multiplier = 10;
> +    } else if (sscanf(s, "%u:%u:%u.%1u,%u:%u:%u.%1u",
> +                      &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
> +        multiplier = 100;
> +    }
>      if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
>                 &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
> -        end    = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
> -        *start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;

> +        ms1 = FFMIN(ms1, 999);
> +        ms2 = FFMIN(ms2, 999);

iam not sure this is the best solutiuon, no warning, no error just cliping 

except that, the patch is probably ok

thx

[...]
Carl Eugen Hoyos March 21, 2020, 5:50 p.m. UTC | #9
Am Sa., 21. März 2020 um 18:35 Uhr schrieb Michael Niedermayer
<michael@niedermayer.cc>:
>
> On Fri, Mar 20, 2020 at 09:05:12AM +0100, Carl Eugen Hoyos wrote:
> > Am Fr., 20. März 2020 um 01:49 Uhr schrieb Michael Niedermayer
> > <michael@niedermayer.cc>:
> > >
> > > On Thu, Mar 19, 2020 at 10:18:33PM +0100, Carl Eugen Hoyos wrote:
> > > > Am Do., 19. März 2020 um 19:32 Uhr schrieb Michael Niedermayer
> > > > <michael@niedermayer.cc>:
> > > > >
> > > > > On Wed, Mar 18, 2020 at 02:16:30AM +0100, Carl Eugen Hoyos wrote:
> > > > > > Hi!
> > > > > >
> > > > > > Attached patch fixes ticket #8575 for me, Google describes such files.
> > > > > >
> > > > > > Please comment, Carl Eugen
> > > > >
> > > > > >  subviewerdec.c |   10 +++++++---
> > > > > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > > > > > 1a6133ed3dbb66945d6bf16e212c0e77e3fd0579  0001-lavf-subviewerdec-Support-higher-sub-second-precisio.patch
> > > > > > From 39d0748782bb3e37fb2f92c679ffa58b239374c7 Mon Sep 17 00:00:00 2001
> > > > > > From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> > > > > > Date: Wed, 18 Mar 2020 02:11:33 +0100
> > > > > > Subject: [PATCH] lavf/subviewerdec: Support higher sub-second precision.
> > > > > >
> > > > > > Fixes ticket #8575.
> > > > > > ---
> > > > > >  libavformat/subviewerdec.c | 10 +++++++---
> > > > > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > > > > >
> > > > > > diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
> > > > > > index 06b827b70f..ed48b3388d 100644
> > > > > > --- a/libavformat/subviewerdec.c
> > > > > > +++ b/libavformat/subviewerdec.c
> > > > > > @@ -56,11 +56,15 @@ static int read_ts(const char *s, int64_t *start, int *duration)
> > > > > >      int64_t end;
> > > > > >      int hh1, mm1, ss1, ms1;
> > > > > >      int hh2, mm2, ss2, ms2;
> > > > > > +    int multiplier = 1;
> > > > > >
> > > > > > +    if (sscanf(s, "%u:%u:%u.%2u,%u:%u:%u.%2u",
> > > > > > +               &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8)
> > > > > > +        multiplier = 10;
> > > > > >      if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
> > > > > >                 &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
> > > > >
> > > > > which lengths can the ms1 / ms2 part have ?
> > > > > do all of the following work ?
> > > > > x.1
> > > > > x.19
> > > > > x.199
> > > > > x.1999
> > > > >
> > > > > or are some of these guranteed not to occur ?
> > > >
> > > > I have no idea but my suspicion is that whoever created the files
> > > > in question misunderstood the original format.
> > >
> > > then i would suggest that the code either supports all variants of this
> > > or checks if the input is one of the supported ones.
> > > basically checking how long the ms1/ms2 fields are IIUC
> >
> > New patch attached.
> >
> > Thank you, Carl Eugen
>
> >  subviewerdec.c |   16 +++++++++++++---
> >  1 file changed, 13 insertions(+), 3 deletions(-)
> > 09ba97edd94b332e899d1669626229cacab4fbbe  0001-lavf-subviewerdec-Support-higher-sub-second-precisio.patch
> > From 17574e5cb44dead6990051540ada103610ee1e5b Mon Sep 17 00:00:00 2001
> > From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> > Date: Fri, 20 Mar 2020 09:02:59 +0100
> > Subject: [PATCH] lavf/subviewerdec: Support higher sub-second precision.
> >
> > Fixes ticket #8575.
> > ---
> >  libavformat/subviewerdec.c | 16 +++++++++++++---
> >  1 file changed, 13 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
> > index 06b827b70f..83378eab5f 100644
> > --- a/libavformat/subviewerdec.c
> > +++ b/libavformat/subviewerdec.c
> > @@ -56,11 +56,21 @@ static int read_ts(const char *s, int64_t *start, int *duration)
> >      int64_t end;
> >      int hh1, mm1, ss1, ms1;
> >      int hh2, mm2, ss2, ms2;
> > +    int multiplier = 1;
> >
> > +    if (sscanf(s, "%u:%u:%u.%2u,%u:%u:%u.%2u",
> > +               &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
> > +        multiplier = 10;
> > +    } else if (sscanf(s, "%u:%u:%u.%1u,%u:%u:%u.%1u",
> > +                      &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
> > +        multiplier = 100;
> > +    }
> >      if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
> >                 &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
> > -        end    = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
> > -        *start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;
>
> > +        ms1 = FFMIN(ms1, 999);
> > +        ms2 = FFMIN(ms2, 999);
>
> iam not sure this is the best solutiuon, no warning, no error just cliping

I believe this is a useful solution for subtitles, especially if no such samples
are known.

> except that, the patch is probably ok

Patch applied.

Thank you, Carl Eugen
diff mbox series

Patch

From 39d0748782bb3e37fb2f92c679ffa58b239374c7 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Wed, 18 Mar 2020 02:11:33 +0100
Subject: [PATCH] lavf/subviewerdec: Support higher sub-second precision.

Fixes ticket #8575.
---
 libavformat/subviewerdec.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
index 06b827b70f..ed48b3388d 100644
--- a/libavformat/subviewerdec.c
+++ b/libavformat/subviewerdec.c
@@ -56,11 +56,15 @@  static int read_ts(const char *s, int64_t *start, int *duration)
     int64_t end;
     int hh1, mm1, ss1, ms1;
     int hh2, mm2, ss2, ms2;
+    int multiplier = 1;
 
+    if (sscanf(s, "%u:%u:%u.%2u,%u:%u:%u.%2u",
+               &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8)
+        multiplier = 10;
     if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
                &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
-        end    = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
-        *start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;
+        end    = (hh2*3600LL + mm2*60LL + ss2) * 1000LL + ms2 * multiplier;
+        *start = (hh1*3600LL + mm1*60LL + ss1) * 1000LL + ms1 * multiplier;
         *duration = end - *start;
         return 0;
     }
@@ -84,7 +88,7 @@  static int subviewer_read_header(AVFormatContext *s)
         return res;
     if (avio_rb24(s->pb) != 0xefbbbf)
         avio_seek(s->pb, -3, SEEK_CUR);
-    avpriv_set_pts_info(st, 64, 1, 100);
+    avpriv_set_pts_info(st, 64, 1, 1000);
     st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
     st->codecpar->codec_id   = AV_CODEC_ID_SUBVIEWER;
 
-- 
2.24.1