[FFmpeg-devel] [PATCH 1/8] libavcodec/jpeg2000_parser: Speed up long skips

Anton Khirnov anton at khirnov.net
Wed Jun 1 16:29:48 EEST 2022


Quoting Tomas Härdin (2022-06-01 14:34:57)
> ons 2022-06-01 klockan 11:59 +0200 skrev Anton Khirnov:
> > Quoting Tomas Härdin (2022-05-31 11:58:39)
> > > 
> > > 
> > > From fedd7f9ae2c691a25c37be935d7547be61d46017 Mon Sep 17 00:00:00
> > > 2001
> > > From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git at haerdin.se>
> > > Date: Fri, 20 May 2022 11:38:25 +0200
> > > Subject: [PATCH 1/8] libavcodec/jpeg2000_parser: Speed up long
> > > skips
> > > 
> > > ---
> > >  libavcodec/jpeg2000_parser.c | 11 +++++++++++
> > >  1 file changed, 11 insertions(+)
> > > 
> > > diff --git a/libavcodec/jpeg2000_parser.c
> > > b/libavcodec/jpeg2000_parser.c
> > > index 2975e71482..9fac958dfa 100644
> > > --- a/libavcodec/jpeg2000_parser.c
> > > +++ b/libavcodec/jpeg2000_parser.c
> > > @@ -95,6 +95,17 @@ static int find_frame_end(JPEG2000ParserContext
> > > *m, const uint8_t *buf, int buf_
> > >          state64 = state64 << 8 | buf[i];
> > >          m->bytes_read++;
> > >          if (m->skip_bytes) {
> > > +            // handle long skips
> > > +            if (m->skip_bytes > 8) {
> > > +                // need -9 else buf_size - i == 8 ==> i ==
> > > buf_size after this,
> > > +                // and thus i == buf_size + 1 after the loop
> > > +                int64_t skip = FFMIN(m->skip_bytes - 8, buf_size -
> > > i - 9);
> > > +                if (skip > 0) {
> > > +                    m->skip_bytes -= skip;
> > > +                    i += skip;
> > > +                    m->bytes_read += skip;
> > 
> > Shouldn't you also update state(64)?
> > 
> 
> It gets updated after 8 more skips. Keep in mind the buffer may end
> before the skip is fully done, so I can't just AV_RB64().

Ah right, nevermind then. Set looks good to me.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list