[FFmpeg-devel] avformat/lrcdec: fix losing opening bracket

Michael Niedermayer michael at niedermayer.cc
Wed Jul 18 23:52:41 EEST 2018


On Wed, Jul 18, 2018 at 06:04:29PM +0530, Umair Khan wrote:
> On Sat, Jul 14, 2018 at 8:37 PM Michael Niedermayer
> <michael at niedermayer.cc> wrote:
> >
> > On Fri, Jul 13, 2018 at 01:34:47PM +0530, Umair Khan wrote:
> > > On Wed, Jul 11, 2018 at 11:07 PM Michael Niedermayer
> > > <michael at niedermayer.cc> wrote:
> > > >
> > > > On Tue, Jul 10, 2018 at 08:10:00PM +0530, Umair Khan wrote:
> > > > > Hi,
> > > > >
> > > > > Patch attached.
> > > > >
> > > > > -Umair
> > > >
> > > > >  lrcdec.c |    3 +++
> > > > >  1 file changed, 3 insertions(+)
> > > > > 6782b07bfa45139361c15527ee5fb78e5893b9ba  0001-avformat-lrcdec-fix-losing-opening-bracket.patch
> > > > > From 95a5d2e5575c5f895e4251775a48f7deb4c86124 Mon Sep 17 00:00:00 2001
> > > > > From: Umair Khan <omerjerk at gmail.com>
> > > > > Date: Tue, 10 Jul 2018 19:51:41 +0530
> > > > > Subject: [PATCH 1/1] avformat/lrcdec: fix losing opening bracket
> > > > >
> > > > > Fixes #7255
> > > > >
> > > > > Signed-off-by: Umair Khan <omerjerk at gmail.com>
> > > > > ---
> > > > >  libavformat/lrcdec.c | 3 +++
> > > > >  1 file changed, 3 insertions(+)
> > > > >
> > > > > diff --git a/libavformat/lrcdec.c b/libavformat/lrcdec.c
> > > > > index f4e9a4efa9..d1e28aff87 100644
> > > > > --- a/libavformat/lrcdec.c
> > > > > +++ b/libavformat/lrcdec.c
> > > > > @@ -68,6 +68,9 @@ static int64_t count_ts(const char *p)
> > > > >                   (p[offset] >= '0' && p[offset] <= '9'))) {
> > > > >              offset++;
> > > > >          } else {
> > > > > +            if (in_brackets) {
> > > > > +                --offset;
> > > > > +            }
> > > > >              break;
> > > >
> > > > this is probably ok but it doesnt fix this completely
> > > >
> > > > consider 2 [[
> > > > or a [123
> > > >
> > > > The code should probably remember the last position after a correctly
> > > > parsed timestamp or maybe use sscanf() to parse these timestamps
> > >
> > > The new attached patch takes care of these cases.
> > >
> > > > Also it seems the code doesnt handle timestamps in the middle of lines
> > > > (not related to your patch though)
> > >
> > > I can handle this case if you can give me an example of what case you
> > > are talking about exactly.
> > >
> > > -Umair
> >
> > >  lrcdec.c |    7 ++++---
> > >  1 file changed, 4 insertions(+), 3 deletions(-)
> > > 72feffd56541236991001caaa92e533382b98b53  0001-avformat-lrcdec-fix-losing-opening-bracket.patch
> > > From 81c2e13aa0a7559886502cfb69f788bd0de7a64a Mon Sep 17 00:00:00 2001
> > > From: Umair Khan <omerjerk at gmail.com>
> > > Date: Fri, 13 Jul 2018 13:24:51 +0530
> > > Subject: [PATCH 1/1] avformat/lrcdec: fix losing opening bracket
> > >
> > > ---
> > >  libavformat/lrcdec.c | 7 ++++---
> > >  1 file changed, 4 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/libavformat/lrcdec.c b/libavformat/lrcdec.c
> > > index f4e9a4efa9..4093cbdf10 100644
> > > --- a/libavformat/lrcdec.c
> > > +++ b/libavformat/lrcdec.c
> > > @@ -60,14 +60,15 @@ static int64_t count_ts(const char *p)
> > >          } else if(p[offset] == '[') {
> > >              offset++;
> > >              in_brackets++;
> > > -        } else if (p[offset] == ']' && in_brackets) {
> > > -            offset++;
> > > -            in_brackets--;
> > >          } else if(in_brackets &&
> > >                   (p[offset] == ':' || p[offset] == '.' || p[offset] == '-' ||
> > >                   (p[offset] >= '0' && p[offset] <= '9'))) {
> > >              offset++;
> > >          } else {
> > > +            if (p[offset] == ']' && in_brackets) {
> > > +                offset++;
> > > +                in_brackets--;
> > > +            }
> > >              break;
> >
> > This breaks multiple times like:
> > [00:35.62][00:35.63][00:35.64][[[[123 is a number
> >
> > this should be interpreted as 3 occurances of "[[[[123 is a number" IIUC
> 
> Are you sure about this? As much as I read, there's no example of it
> being interpreted as 3 occurrences. It could be interpreted as empty
> words at the first two timestamps.

fate-suite/sub/test-lrc.lrc contains examples of this

The lyrics with repeats written out are here:
https://www.joshwoodward.com/song/Swansong

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180718/e94892d3/attachment.sig>


More information about the ffmpeg-devel mailing list