Commit 06b0c6a6 authored by Paul B Mahol's avatar Paul B Mahol Committed by Michael Niedermayer

libopenjpegenc: use pix_fmt descriptor to get numcomps

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
Reviewed-by: 's avatarMichael Bradshaw <mbradshaw@sorensonmedia.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 140c54ea
...@@ -57,7 +57,7 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p ...@@ -57,7 +57,7 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
int bpp = 8; int bpp = 8;
int sub_dx[4]; int sub_dx[4];
int sub_dy[4]; int sub_dy[4];
int numcomps = 0; int numcomps;
OPJ_COLOR_SPACE color_space = CLRSPC_UNKNOWN; OPJ_COLOR_SPACE color_space = CLRSPC_UNKNOWN;
sub_dx[0] = sub_dx[3] = 1; sub_dx[0] = sub_dx[3] = 1;
...@@ -65,77 +65,64 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p ...@@ -65,77 +65,64 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
sub_dx[1] = sub_dx[2] = 1<<av_pix_fmt_descriptors[avctx->pix_fmt].log2_chroma_w; sub_dx[1] = sub_dx[2] = 1<<av_pix_fmt_descriptors[avctx->pix_fmt].log2_chroma_w;
sub_dy[1] = sub_dy[2] = 1<<av_pix_fmt_descriptors[avctx->pix_fmt].log2_chroma_h; sub_dy[1] = sub_dy[2] = 1<<av_pix_fmt_descriptors[avctx->pix_fmt].log2_chroma_h;
numcomps = av_pix_fmt_descriptors[avctx->pix_fmt].nb_components;
switch (avctx->pix_fmt) { switch (avctx->pix_fmt) {
case PIX_FMT_GRAY8: case PIX_FMT_GRAY8:
color_space = CLRSPC_GRAY; color_space = CLRSPC_GRAY;
numcomps = 1;
break; break;
case PIX_FMT_GRAY8A: case PIX_FMT_GRAY8A:
color_space = CLRSPC_GRAY; color_space = CLRSPC_GRAY;
numcomps = 2;
break; break;
case PIX_FMT_GRAY16: case PIX_FMT_GRAY16:
color_space = CLRSPC_GRAY; color_space = CLRSPC_GRAY;
numcomps = 1;
bpp = 16; bpp = 16;
break; break;
case PIX_FMT_RGB24: case PIX_FMT_RGB24:
color_space = CLRSPC_SRGB; color_space = CLRSPC_SRGB;
numcomps = 3;
break; break;
case PIX_FMT_RGBA: case PIX_FMT_RGBA:
color_space = CLRSPC_SRGB; color_space = CLRSPC_SRGB;
numcomps = 4;
break; break;
case PIX_FMT_RGB48: case PIX_FMT_RGB48:
color_space = CLRSPC_SRGB; color_space = CLRSPC_SRGB;
numcomps = 3;
bpp = 16; bpp = 16;
break; break;
case PIX_FMT_RGBA64: case PIX_FMT_RGBA64:
color_space = CLRSPC_SRGB; color_space = CLRSPC_SRGB;
numcomps = 4;
bpp = 16; bpp = 16;
break; break;
case PIX_FMT_YUV420P: case PIX_FMT_YUV420P:
color_space = CLRSPC_SYCC; color_space = CLRSPC_SYCC;
numcomps = 3;
break; break;
case PIX_FMT_YUV422P: case PIX_FMT_YUV422P:
color_space = CLRSPC_SYCC; color_space = CLRSPC_SYCC;
numcomps = 3;
break; break;
case PIX_FMT_YUV440P: case PIX_FMT_YUV440P:
color_space = CLRSPC_SYCC; color_space = CLRSPC_SYCC;
numcomps = 3;
break; break;
case PIX_FMT_YUV444P: case PIX_FMT_YUV444P:
color_space = CLRSPC_SYCC; color_space = CLRSPC_SYCC;
numcomps = 3;
break; break;
case PIX_FMT_YUVA420P: case PIX_FMT_YUVA420P:
color_space = CLRSPC_SYCC; color_space = CLRSPC_SYCC;
numcomps = 4;
break; break;
case PIX_FMT_YUV420P9: case PIX_FMT_YUV420P9:
case PIX_FMT_YUV422P9: case PIX_FMT_YUV422P9:
case PIX_FMT_YUV444P9: case PIX_FMT_YUV444P9:
color_space = CLRSPC_SYCC; color_space = CLRSPC_SYCC;
numcomps = 3;
bpp = 9; bpp = 9;
break; break;
case PIX_FMT_YUV420P10: case PIX_FMT_YUV420P10:
case PIX_FMT_YUV422P10: case PIX_FMT_YUV422P10:
case PIX_FMT_YUV444P10: case PIX_FMT_YUV444P10:
color_space = CLRSPC_SYCC; color_space = CLRSPC_SYCC;
numcomps = 3;
bpp = 10; bpp = 10;
break; break;
case PIX_FMT_YUV420P16: case PIX_FMT_YUV420P16:
case PIX_FMT_YUV422P16: case PIX_FMT_YUV422P16:
case PIX_FMT_YUV444P16: case PIX_FMT_YUV444P16:
color_space = CLRSPC_SYCC; color_space = CLRSPC_SYCC;
numcomps = 3;
bpp = 16; bpp = 16;
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment