[FFmpeg-devel] [PATCH] JPEG200 encoding : added option for changing default codeblock size

francesco at bltitalia.com francesco at bltitalia.com
Mon Aug 7 11:26:21 EEST 2017


From: Francesco Cuzzocrea <francesco at bltitalia.com>

HI
I think this time I've made correctly a patch. As in previous mail, I added
option for changing codeblock size. I've inserted check on exponent sum as for
ISO/IEC FCD 15444-1



---
 libavcodec/j2kenc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index c8d3861..63096ca 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1121,8 +1121,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
     memset(codsty->log2_prec_heights, 15, sizeof(codsty->log2_prec_heights));
     codsty->nreslevels2decode=
     codsty->nreslevels       = 7;
-    codsty->log2_cblk_width  = 4;
-    codsty->log2_cblk_height = 4;
     codsty->transform        = s->pred ? FF_DWT53 : FF_DWT97_INT;
 
     qntsty->nguardbits       = 1;
@@ -1131,6 +1129,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
         (s->tile_height & (s->tile_height-1))) {
         av_log(avctx, AV_LOG_WARNING, "Tile dimension not a power of 2\n");
     }
+    i = codsty->log2_cblk_width + codsty->log2_cblk_height -4;
+    if ( i > 12 )
+    {
+      av_log(avctx, AV_LOG_ERROR, "Invalid values for codeblocks size\n");
+      return -1;
+    }
 
     if (codsty->transform == FF_DWT53)
         qntsty->quantsty = JPEG2000_QSTY_NONE;
@@ -1188,6 +1192,8 @@ static const AVOption options[] = {
     { "pred",          "DWT Type",          OFFSET(pred),          AV_OPT_TYPE_INT,   { .i64 = 0           }, 0,         1,           VE, "pred"        },
     { "dwt97int",      NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = 0           }, INT_MIN, INT_MAX,       VE, "pred"        },
     { "dwt53",         NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = 0           }, INT_MIN, INT_MAX,       VE, "pred"        },
+    { "log2_cblk_width",   "Codeblock Width",   OFFSET(codsty.log2_cblk_width),    AV_OPT_TYPE_INT,   { .i64 = 4           }, 0,     1<<10,           VE, },
+    { "log2_cblk_height",  "Codeblock Height",  OFFSET(codsty.log2_cblk_height),   AV_OPT_TYPE_INT,   { .i64 = 4           }, 0,     1<<10,           VE, },
 
     { NULL }
 };
-- 
2.1.4



More information about the ffmpeg-devel mailing list