Browse code

avcodec/libopenjpegenc: Set numresolutions by default to a value that is not too large

Fixes issues with libopenjpeg 2.1

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2016/06/27 00:34:37
Showing 1 changed files
... ...
@@ -352,6 +352,12 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
352 352
     ctx->enc_params.cp_cinema = ctx->cinema_mode;
353 353
 #endif
354 354
 
355
+    if (!ctx->numresolution) {
356
+        ctx->numresolution = 6;
357
+        while (FFMIN(avctx->width, avctx->height) >> ctx->numresolution < 1)
358
+            ctx->numresolution --;
359
+    }
360
+
355 361
     ctx->enc_params.mode = !!avctx->global_quality;
356 362
     ctx->enc_params.prog_order = ctx->prog_order;
357 363
     ctx->enc_params.numresolution = ctx->numresolution;
... ...
@@ -815,7 +821,7 @@ static const AVOption options[] = {
815 815
     { "rpcl",          NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = OPJ(RPCL)    }, 0,         0,           VE, "prog_order"  },
816 816
     { "pcrl",          NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = OPJ(PCRL)    }, 0,         0,           VE, "prog_order"  },
817 817
     { "cprl",          NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = OPJ(CPRL)    }, 0,         0,           VE, "prog_order"  },
818
-    { "numresolution", NULL,                OFFSET(numresolution), AV_OPT_TYPE_INT,   { .i64 = 6           }, 1,         INT_MAX,     VE                },
818
+    { "numresolution", NULL,                OFFSET(numresolution), AV_OPT_TYPE_INT,   { .i64 = 0           }, 0,         INT_MAX,     VE                },
819 819
     { "numlayers",     NULL,                OFFSET(numlayers),     AV_OPT_TYPE_INT,   { .i64 = 1           }, 1,         10,          VE                },
820 820
     { "disto_alloc",   NULL,                OFFSET(disto_alloc),   AV_OPT_TYPE_INT,   { .i64 = 1           }, 0,         1,           VE                },
821 821
     { "fixed_alloc",   NULL,                OFFSET(fixed_alloc),   AV_OPT_TYPE_INT,   { .i64 = 0           }, 0,         1,           VE                },