[FFmpeg-devel] [PATCH 2/3] avcodec/j2kenc: Add alpha support

Tomas Härdin git at haerdin.se
Wed Apr 5 15:50:46 EEST 2023


sön 2023-04-02 klockan 23:34 +0200 skrev Michael Niedermayer:
> On Fri, Mar 31, 2023 at 01:14:40AM +0200, Michael Niedermayer wrote:
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> >  libavcodec/j2kenc.c | 28 ++++++++++++++++++----------
> >  1 file changed, 18 insertions(+), 10 deletions(-)
> > 
> > diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
> > index 97b0da1c976..b23fb73770a 100644
> > --- a/libavcodec/j2kenc.c
> > +++ b/libavcodec/j2kenc.c
> > @@ -320,8 +320,8 @@ static int put_siz(Jpeg2000EncoderContext *s)
> >  
> >      for (i = 0; i < s->ncomponents; i++){ // Ssiz_i XRsiz_i,
> > YRsiz_i
> >          bytestream_put_byte(&s->buf, s->cbps[i] - 1);
> > -        bytestream_put_byte(&s->buf, i?1<<s->chroma_shift[0]:1);
> > -        bytestream_put_byte(&s->buf, i?1<<s->chroma_shift[1]:1);
> > +        bytestream_put_byte(&s->buf, (i%3)?1<<s-
> > >chroma_shift[0]:1);
> > +        bytestream_put_byte(&s->buf, (i%3)?1<<s-
> > >chroma_shift[1]:1);
> 
> i will replace the %3 by +1&2 to avoid slow modulo before applying

Is the compiler not smart enough to do that automagically? Not a biggie
though

/Tomas



More information about the ffmpeg-devel mailing list