summaryrefslogtreecommitdiff
path: root/libavcodec/jpeg2000dec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-07-08 00:58:40 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-07-21 04:16:53 +0200
commit1434df3b93fde086be729d174ffbbee1e25792b3 (patch)
treed2b19912de89432776d3f6531354553b3bbc9a69 /libavcodec/jpeg2000dec.c
parent0c480bcfd932ea977db934322b07cf03a39c308d (diff)
jpeg2000dec: Support non subsampled 9-16bit planar pixel formats
This applies changes similar to fc6de70c44be05eb0368ab519bfb790431d8dee5 to the >8bit codepath Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/jpeg2000dec.c')
-rw-r--r--libavcodec/jpeg2000dec.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index f94d9a32df..c6f6f6c9cb 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1292,14 +1292,20 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
uint16_t *linel;
int cbps = s->cbps[compno];
int w = tile->comp[compno].coord[0][1] - s->image_offset_x;
+ int planar = !!picture->data[2];
+ int pixelsize = planar ? 1 : s->ncomponents;
+ int plane = 0;
+
+ if (planar)
+ plane = s->cdef[compno] ? s->cdef[compno]-1 : (s->ncomponents-1);
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
- linel = (uint16_t *)picture->data[0] + y * (picture->linesize[0] >> 1);
+ linel = (uint16_t *)picture->data[plane] + y * (picture->linesize[plane] >> 1);
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint16_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
- dst = linel + (x * s->ncomponents + compno);
+ dst = linel + (x * pixelsize + compno*!planar);
if (codsty->transform == FF_DWT97) {
for (; x < w; x += s-> cdx[compno]) {
int val = lrintf(*datap) + (1 << (cbps - 1));
@@ -1308,7 +1314,7 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
/* align 12 bit values in little-endian mode */
*dst = val << (16 - cbps);
datap++;
- dst += s->ncomponents;
+ dst += pixelsize;
}
} else {
for (; x < w; x += s-> cdx[compno]) {
@@ -1318,10 +1324,10 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
/* align 12 bit values in little-endian mode */
*dst = val << (16 - cbps);
i_datap++;
- dst += s->ncomponents;
+ dst += pixelsize;
}
}
- linel += picture->linesize[0] >> 1;
+ linel += picture->linesize[plane] >> 1;
}
}
}