[FFmpeg-devel] [PATCH 2/6] libopenjpegenc: Simplify initialization of sub_dx/y.

Michael Niedermayer michaelni at gmx.at
Fri Nov 18 02:32:52 CET 2011


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavcodec/libopenjpegenc.c |   23 +++++------------------
 1 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 1a92d60..31d87e7 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -59,59 +59,46 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
     int numcomps = 0;
     OPJ_COLOR_SPACE color_space = CLRSPC_UNKNOWN;
 
+    sub_dx[0] = sub_dx[3] = 1;
+    sub_dy[0] = sub_dy[3] = 1;
+    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;
+
     switch (avctx->pix_fmt) {
     case PIX_FMT_GRAY8:
         color_space = CLRSPC_GRAY;
         numcomps = 1;
         bpp = 8;
-        sub_dx[0] = 1;
-        sub_dy[0] = 1;
         break;
     case PIX_FMT_RGB24:
         color_space = CLRSPC_SRGB;
         numcomps = 3;
         bpp = 24;
-        sub_dx[0] = sub_dx[1] = sub_dx[2] = 1;
-        sub_dy[0] = sub_dy[1] = sub_dy[2] = 1;
         break;
     case PIX_FMT_RGBA:
         color_space = CLRSPC_SRGB;
         numcomps = 4;
         bpp = 32;
-        sub_dx[0] = sub_dx[1] = sub_dx[2] = sub_dx[3] = 1;
-        sub_dy[0] = sub_dy[1] = sub_dy[2] = sub_dy[3] = 1;
         break;
     case PIX_FMT_YUV420P:
         color_space = CLRSPC_SYCC;
         numcomps = 3;
         bpp = 12;
-        sub_dx[0] = 1;
-        sub_dx[1] = sub_dx[2] = 2;
-        sub_dy[0] = 1;
-        sub_dy[1] = sub_dy[2] = 2;
         break;
     case PIX_FMT_YUV422P:
         color_space = CLRSPC_SYCC;
         numcomps = 3;
         bpp = 16;
-        sub_dx[0] = 1;
-        sub_dx[1] = sub_dx[2] = 2;
-        sub_dy[0] = sub_dy[1] = sub_dy[2] = 1;
         break;
     case PIX_FMT_YUV440P:
         color_space = CLRSPC_SYCC;
         numcomps = 3;
         bpp = 16;
-        sub_dx[0] = sub_dx[1] = sub_dx[2] = 1;
-        sub_dy[0] = 1;
-        sub_dy[1] = sub_dy[2] = 2;
             break;
     case PIX_FMT_YUV444P:
         color_space = CLRSPC_SYCC;
         numcomps = 3;
         bpp = 24;
-        sub_dx[0] = sub_dx[1] = sub_dx[2] = 1;
-        sub_dy[0] = sub_dy[1] = sub_dy[2] = 1;
         break;
     default:
         av_log(avctx, AV_LOG_ERROR, "The requested pixel format '%s' is not supported\n", av_get_pix_fmt_name(avctx->pix_fmt));
-- 
1.7.4.1



More information about the ffmpeg-devel mailing list