[FFmpeg-devel] [PATCH 2/3] avcodec/j2kenc: Add alpha support
Michael Niedermayer
michael at niedermayer.cc
Thu Apr 6 22:18:28 EEST 2023
On Thu, Apr 06, 2023 at 10:15:48AM -0400, Leo Izen wrote:
>
>
> On 4/2/23 17:34, Michael Niedermayer wrote:
> > 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
> >
> >
>
> (i % 3) and (i + 1) & 2 aren't the same tho, and won't be nonzero at the
> same time. `(i + 1) & 2` is equivalent to `(i + 1) % 4`.
they are non zero in the same cases for the first 4 planes and we support
just 4. So its the same for us. Its a good argument though why gcc may
have difficulty doing this substitution on its own
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20230406/83459103/attachment.sig>
More information about the ffmpeg-devel
mailing list