[FFmpeg-cvslog] j2kdec: Try to fix 8bps output case

Michael Niedermayer git at videolan.org
Tue May 28 19:09:45 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue May 28 17:11:12 2013 +0200| [f0a2c8285a4e14b977b7d949cc7323f9be876b1f] | committer: Michael Niedermayer

j2kdec: Try to fix 8bps output case

Ive no test samples for which this makes a difference but it
matches the 16bit implementation.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f0a2c8285a4e14b977b7d949cc7323f9be876b1f
---

 libavcodec/j2kdec.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c
index a1fd555..d2e003c 100644
--- a/libavcodec/j2kdec.c
+++ b/libavcodec/j2kdec.c
@@ -933,12 +933,10 @@ static int decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
                 dst = line + x * s->ncomponents + compno;
 
                 for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) {
-                    *src[compno] += 1 << (s->cbps[compno]-1);
-                    if (*src[compno] < 0)
-                        *src[compno] = 0;
-                    else if (*src[compno] >= (1 << s->cbps[compno]))
-                        *src[compno] = (1 << s->cbps[compno]) - 1;
-                    *dst = *src[compno]++;
+                    int val = *src[compno]++ << (8 - s->cbps[compno]);
+                    val += 1 << 7;
+                    val = av_clip(val, 0, (1 << 8) - 1);
+                    *dst = val;
                     dst += s->ncomponents;
                 }
                 line += s->picture->linesize[0];



More information about the ffmpeg-cvslog mailing list