j2k/jpeg2000: merge pix_fmt setting code

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-05-30 16:45:30 +02:00
parent 6f7de3d5c8
commit 310f9dd698
2 changed files with 38 additions and 29 deletions

View File

@ -215,22 +215,33 @@ static int get_siz(Jpeg2000DecoderContext *s)
s->reduction_factor); s->reduction_factor);
switch(s->ncomponents) { switch(s->ncomponents) {
case 1: case 1:
if (s->precision > 8) { if (s->precision > 8)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16; s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
} else { else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8; s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
}
break; break;
case 3: case 3:
if (s->precision > 8) { switch (s->avctx->profile) {
s->avctx->pix_fmt = AV_PIX_FMT_RGB48; case FF_PROFILE_JPEG2000_DCINEMA_2K:
} else { case FF_PROFILE_JPEG2000_DCINEMA_4K:
s->avctx->pix_fmt = AV_PIX_FMT_RGB24; /* XYZ color-space for digital cinema profiles */
s->avctx->pix_fmt = AV_PIX_FMT_XYZ12;
break;
default:
if (s->precision > 8)
s->avctx->pix_fmt = AV_PIX_FMT_RGB48;
else
s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
break;
} }
break; break;
case 4: case 4:
s->avctx->pix_fmt = AV_PIX_FMT_RGBA; s->avctx->pix_fmt = AV_PIX_FMT_RGBA;
break; break;
default:
/* pixel format can not be identified */
s->avctx->pix_fmt = AV_PIX_FMT_NONE;
break;
} }

View File

@ -213,37 +213,35 @@ static int get_siz(Jpeg2000DecoderContext *s)
s->avctx->height = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y, s->avctx->height = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
s->reduction_factor); s->reduction_factor);
switch (s->avctx->profile) { switch(s->ncomponents) {
case FF_PROFILE_JPEG2000_DCINEMA_2K: case 1:
case FF_PROFILE_JPEG2000_DCINEMA_4K: if (s->precision > 8)
/* XYZ color-space for digital cinema profiles */ s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
s->avctx->pix_fmt = AV_PIX_FMT_XYZ12; else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
break; break;
default: case 3:
/* For other profiles selects color-space according number of switch (s->avctx->profile) {
* components and bit depth precision. */ case FF_PROFILE_JPEG2000_DCINEMA_2K:
switch (s->ncomponents) { case FF_PROFILE_JPEG2000_DCINEMA_4K:
case 1: /* XYZ color-space for digital cinema profiles */
if (s->precision > 8) s->avctx->pix_fmt = AV_PIX_FMT_XYZ12;
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
break; break;
case 3: default:
if (s->precision > 8) if (s->precision > 8)
s->avctx->pix_fmt = AV_PIX_FMT_RGB48; s->avctx->pix_fmt = AV_PIX_FMT_RGB48;
else else
s->avctx->pix_fmt = AV_PIX_FMT_RGB24; s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
break; break;
case 4:
s->avctx->pix_fmt = AV_PIX_FMT_BGRA;
break;
default:
/* pixel format can not be identified */
s->avctx->pix_fmt = AV_PIX_FMT_NONE;
break;
} }
break; break;
case 4:
s->avctx->pix_fmt = AV_PIX_FMT_RGBA;
break;
default:
/* pixel format can not be identified */
s->avctx->pix_fmt = AV_PIX_FMT_NONE;
break;
} }
return 0; return 0;
} }