On Sat, Apr 25, 2020 at 07:26:08PM +0200, Carl Eugen Hoyos wrote: > Hi! > > Attached patch makes the output of the reference sample p0_03.j2k > bit-exact with opj_decompress and kdu_render and more similar to > jasper's output. > > Please comment, Carl Eugen
> jpeg2000dec.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > 895351be2965009049944f0ceeb42bc5f8cee733 > 0001-lavc-jpeg2000dec-Scale-4-7-bit-output-to-8-bits.patch > From de80453a8decd95b4a71cea71b20ba0bd74485cb Mon Sep 17 00:00:00 2001 > From: Carl Eugen Hoyos <ceffm...@gmail.com> > Date: Sat, 25 Apr 2020 18:31:22 +0200 > Subject: [PATCH] lavc/jpeg2000dec: Scale 4-7 bit output to 8 bits. > > Makes p0_03.j2k output bitexact with opj_decompress and kdu_render > and more similar with the output of jasper. > --- > libavcodec/jpeg2000dec.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c > index 460a4ad95c..8d7c729530 100644 > --- a/libavcodec/jpeg2000dec.c > +++ b/libavcodec/jpeg2000dec.c > @@ -1938,7 +1938,9 @@ static inline void > tile_codeblocks(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile > int val = lrintf(*datap) + (1 << (cbps - 1)); > \ > /* DC level shift and clip see ISO 15444-1:2002 > G.1.2 */ \ > val = av_clip(val, 0, (1 << cbps) - 1); > \ > - *dst = val << (precision - cbps); > \ > + *dst = val << ((precision < 8 ? 8 : precision) - > cbps); \ > + if (precision < 8) > \ > + *dst |= *dst >> (8 - precision); > \ > datap++; > \ > dst += pixelsize; > \ > } > \ > @@ -1947,7 +1949,9 @@ static inline void > tile_codeblocks(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile > int val = *i_datap + (1 << (cbps - 1)); > \ > /* DC level shift and clip see ISO 15444-1:2002 > G.1.2 */ \ > val = av_clip(val, 0, (1 << cbps) - 1); > \ > - *dst = val << (precision - cbps); > \ > + *dst = val << ((precision < 8 ? 8 : precision) - > cbps); \ > + if (precision < 8) > \ > + *dst |= *dst >> (8 - precision); > \ > i_datap++; > \ > dst += pixelsize; > \ > } > \ the check should be outside the pixel loop, as precission does not change between pixels, this is already a macro to avoid a 8/16 check. And it would probably be hard for the compiler to figure out when it can remove which side thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".