[FFmpeg-devel] [PATCH] jpeg2000dec: Support non subsampled 9-16bit planar pixel formats
Paul B Mahol
onemda at gmail.com
Fri Jul 12 13:58:08 CEST 2013
On 7/7/13, Michael Niedermayer <michaelni at gmx.at> wrote:
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
> libavcodec/jpeg2000dec.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
If it fixes decoding of RGB48 produced with our libopenjpeg wrapper encoder
it should be fine.
>
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 18d2c85..98d3cb2 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -1297,14 +1297,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));
> @@ -1313,7 +1319,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]) {
> @@ -1323,10 +1329,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;
> }
> }
> }
> --
> 1.7.9.5
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list