[FFmpeg-devel] [PATCH] JPEG2000 encoding with variable codeblock size

francesco at bltitalia.com francesco at bltitalia.com
Thu Aug 3 16:58:22 EEST 2017


From: Francesco Cuzzocrea <francesco at bltitalia.com>

Hi to all
I've made some simple changes tha allow encoding with variable codeblock
size.  Default value are the same as previous (16X16) but now setting them
to 64x128 make generated codestream compatible with Analog Devices ADV212
video codec.


---
 libavcodec/j2kenc.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index c8d3861..1bd4fbd 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1178,17 +1178,21 @@ static int j2kenc_destroy(AVCodecContext *avctx)
 // taken from the libopenjpeg wraper so it matches
 
 #define OFFSET(x) offsetof(Jpeg2000EncoderContext, x)
+#define OFFSET1(x) offsetof(Jpeg2000CodingStyle, x)
+
+
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
-    { "format",        "Codec Format",      OFFSET(format),        AV_OPT_TYPE_INT,   { .i64 = CODEC_JP2   }, CODEC_J2K, CODEC_JP2,   VE, "format"      },
-    { "j2k",           NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = CODEC_J2K   }, 0,         0,           VE, "format"      },
-    { "jp2",           NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = CODEC_JP2   }, 0,         0,           VE, "format"      },
-    { "tile_width",    "Tile Width",        OFFSET(tile_width),    AV_OPT_TYPE_INT,   { .i64 = 256         }, 1,     1<<30,           VE, },
-    { "tile_height",   "Tile Height",       OFFSET(tile_height),   AV_OPT_TYPE_INT,   { .i64 = 256         }, 1,     1<<30,           VE, },
-    { "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"        },
-
+    { "format",           "Codec Format",       OFFSET(format),                               AV_OPT_TYPE_INT,   { .i64 = CODEC_JP2   }, CODEC_J2K, CODEC_JP2,   VE, "format"      },
+    { "j2k",               NULL,                0,                                            AV_OPT_TYPE_CONST, { .i64 = CODEC_J2K   }, 0,         0,           VE, "format"      },
+    { "jp2",               NULL,                0,                                            AV_OPT_TYPE_CONST, { .i64 = CODEC_JP2   }, 0,         0,           VE, "format"      },
+    { "tile_width",        "Tile Width",        OFFSET(tile_width),                           AV_OPT_TYPE_INT,   { .i64 = 256         }, 1,     1<<30,           VE, },
+    { "tile_height",       "Tile Height",       OFFSET(tile_height),                          AV_OPT_TYPE_INT,   { .i64 = 256         }, 1,     1<<30,           VE, },
+    { "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)+OFFSET1(log2_cblk_width)),    AV_OPT_TYPE_INT,   { .i64 = 4           }, 1,     1<<30,           VE, },
+    { "log2_cblk_height",  "Codeblock Height",  (OFFSET(codsty)+OFFSET1(log2_cblk_height)),   AV_OPT_TYPE_INT,   { .i64 = 4           }, 1,     1<<30,           VE, },
     { NULL }
 };
 
-- 
2.1.4



More information about the ffmpeg-devel mailing list