[FFmpeg-trac] #4681(avcodec:closed): Reference sample p0_03.j2k (ROI) shows artefacts
FFmpeg
trac at avcodec.org
Thu Apr 23 20:54:11 EEST 2020
#4681: Reference sample p0_03.j2k (ROI) shows artefacts
------------------------------------+-----------------------------------
Reporter: cehoyos | Owner:
Type: defect | Status: closed
Priority: normal | Component: avcodec
Version: git-master | Resolution: fixed
Keywords: j2k | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
------------------------------------+-----------------------------------
Changes (by cehoyos):
* status: new => closed
* resolution: => fixed
Comment:
Fixed by Gautam Ramakrishnan in e58766ba12bc86f54af1d8078cbe02f45b1686aa
The following change makes decoding bit-exact with kdu_render and
opj_decompress:
{{{
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;
\
}
\
@@ -1989,7 +1993,7 @@ static int jpeg2000_decode_tile(AVCodecContext
*avctx, void *td,
}
if (s->precision <= 8) {
- write_frame_8(s, tile, picture, 8);
+ write_frame_8(s, tile, picture, s->precision);
} else {
int precision = picture->format == AV_PIX_FMT_XYZ12 ||
picture->format == AV_PIX_FMT_RGB48 ||
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/4681#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list