From patchwork Mon Aug 7 08:26:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: francesco@bltitalia.com X-Patchwork-Id: 4648 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp2588163vsu; Mon, 7 Aug 2017 01:26:34 -0700 (PDT) X-Received: by 10.28.91.140 with SMTP id p134mr93510wmb.79.1502094394578; Mon, 07 Aug 2017 01:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502094394; cv=none; d=google.com; s=arc-20160816; b=aNO25U75xdVODAbpf3XujRNQyj22XNVevYolAf42KXtqfMh4LLa8++GRm/vbI1KggO pmyIbkLfxRsbIHm+u9DpwYTq1p6t7YZPUYXMowr+oisi32T1TGMAm2HlKXT53p2kRHY3 9B7r2V7PUBUvGSzHZcQtJG+mPKY7P3QsemLlGbVu33tAQ5EJMGHMww/UoEWJXAHF1av0 5vUZorCx/4pO5H+kTMVaAe55znMClJdkQYdKJdGgWeNt2sdIp19y15h8qKALVpxB+DtA 9xm6us9SNUGyUyO17HdfLYltrmCXTgjgLuTd6HsVu6PMzn1IdE/SjHLWp5H+/fcnMlFr 0KCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:dkim-signature:message-id:date:to:from :delivered-to:arc-authentication-results; bh=csix+oD8JzhIDmj8R9kOt/IYYjbvNFIJbRI/7xmlY1o=; b=phZlY03voHnAFR8XcGPdNlj+ec9g4KodiiG2doH8tCRjDppjjcdS96zbqb34dmjjBi hCdnpU71Vts0WFjMWP5qx8VqkP7vXspLjPyHsK14nc1I6Ubk2LwISai8qUVcp8XVMUVY 5TAyHyiFUQg8pco4rze/DyyQ/V4CNJU2xtBzw80UyRU32bhJ6keEz8kTGyYZ6L3c+nQP iV1T4tMcPoyaDyMMbbpAmzZy9Td8z3cAD4bN/tqEz0h+UnAl5VqhheRvP9Wu8ijFg9ZJ /udnxNDYo08gust177u108xA6E+QkMUaZg+fuOX51lrKftrL2aQAUHpgtbRxCRK4C7KG BtyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@aruba.it header.b=Z7DPGIWi; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q21si8133958wra.478.2017.08.07.01.26.33; Mon, 07 Aug 2017 01:26:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@aruba.it header.b=Z7DPGIWi; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 28052680934; Mon, 7 Aug 2017 11:26:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpcmd0643.aruba.it (smtpcmd0643.aruba.it [62.149.156.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BD14668056A for ; Mon, 7 Aug 2017 11:26:22 +0300 (EEST) Received: from debiandevelop.rosselli.domain ([95.245.215.185]) by smtpcmd06.ad.aruba.it with bizsmtp id u8SM1v01W40attb018SMCY; Mon, 07 Aug 2017 10:26:23 +0200 From: francesco@bltitalia.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Aug 2017 10:26:21 +0200 Message-Id: <1502094381-16589-1-git-send-email-francesco@bltitalia.com> X-Mailer: git-send-email 2.1.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aruba.it; s=a1; t=1502094383; bh=TpTOTkK5qridfPSFaWmoRXrpk5VoJpHryU90ynq3Axg=; h=From:To:Subject:Date; b=Z7DPGIWi7p/Amcu9WWYD5qSj3+heasXmiDFb4oPq+L7cUe23s+5EPiZzfaYjKS1M4 gE4RKYvkONGpVVtib0D/wMdOl7xi4CByKWOMy1lh9H10KYq/bxtaxyPnmX83qgwa+X k12UaBg26w+2ZCzh5x08r38DSRwc8EVkCwqxDKJtmnrw0Wd3jgdrpu/6ykb+SUeiHe lyHzcrmrQvw8bAbG3UzbEhz8xVkZTkfVVVB0TSKNIIow5cA7RO2NG5SIHPSiP0pTeb xIkl45CqjSu6ctoU0LSS0mRYQ87oLRIPhS3Ucm56Sl+RQtr0RnBlxt0Id+/f4gjJ1d ycf409Ci403Ow== Subject: [FFmpeg-devel] [PATCH] JPEG200 encoding : added option for changing default codeblock size X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Francesco Cuzzocrea MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Francesco Cuzzocrea 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 } };