From patchwork Fri Aug 4 14:21:35 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: 4623 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp2339163vsu; Fri, 4 Aug 2017 07:21:49 -0700 (PDT) X-Received: by 10.223.135.181 with SMTP id b50mr2156775wrb.261.1501856509589; Fri, 04 Aug 2017 07:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501856509; cv=none; d=google.com; s=arc-20160816; b=YvTMwA6xqUsUC8ozQxAOIfIFUBqwe42FF4i+MB8ezKOEBib9QWKAFJQdD/FS97fWSb RIqjiX7d8HiIOFtNl161izY+z+nIhcowBF/sFERVJ9noRylyuSvc1oi8G26GOBKoe3dV CrimtDhZiKaJpQ0Zi2RIoHCqdeWdCINym3+G2b/l8ao8WcFcG9M/l+Qsrel9AEzOyfNI fNGfY72ynRwkQzvDttvrgLyuj8acIw+EHFFz+6hqIMlbVWx3SA5tUt29kc7Eco3CGiyi KtwA1XGG/iLLj0VU5vXpzyEaF5XZUK0MO6buezncIDjevrBQ0J8UHrjEnuoUZL/e6Tl5 KFJQ== 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=WC3/L0QLMMF5OvJelV6nivm3hCEurGoGzmUFhuNOvE0=; b=A8fp08geD6Rb+jjH7VQ4qgUj2YqBJiXtUUVTMxIWuDvl04YQEw6FwdYTINhIY75PVE cgdEW7Aj+McB/5yh22qfrClZnkjKFCvLQEFknQpOYvX5Wh/cNbFXjf8ZJJtOa9JVrjTJ ab5cDMstyVr4ZbCtstnjPsQc2XbJ8cFapZIz5SXDDZVbJEg6IC+fwHX4IaPL/f1zrTm+ urWKGkNMYj0h6zZh7hwOZa7xokjTXSq2T9wYlh7YzM/QBnA+EfrgsbVdtH50vjt5LKJJ sbTuI1RlOu+LV2HAQlsT27UMwottiDbUMttXpfCz1/YkABeVopbaQqnracOZ2pize75U Hakg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@aruba.it header.b=XQDrE3Xs; 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 u20si3788204wrb.323.2017.08.04.07.21.48; Fri, 04 Aug 2017 07:21:49 -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=XQDrE3Xs; 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 9A27D6899F5; Fri, 4 Aug 2017 17:21:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpcmd0873.aruba.it (smtpcmd0873.aruba.it [62.149.156.73]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5758A6883C2 for ; Fri, 4 Aug 2017 17:21:38 +0300 (EEST) Received: from debiandevelop.rosselli.domain ([79.27.134.74]) by smtpcmd08.ad.aruba.it with bizsmtp id t2Mc1v01Q1cUSKz012MdNj; Fri, 04 Aug 2017 16:21:38 +0200 From: francesco@bltitalia.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 4 Aug 2017 16:21:35 +0200 Message-Id: <1501856495-13594-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=1501856498; bh=0juzmH6lNqvRUz/i4/rD57XZ8o5CSVp6NIgcFjhlvPE=; h=From:To:Subject:Date; b=XQDrE3XsdDhVMf3ltQNySNZ0dvIt4ydxE9n9hjO3o12wmFjFuKKZJuKd5fYMnKbJu YO8cfoD2sma6xPPWXmITCNLSWIRedUN7+e63MYjNzQ4QATpMwlnT/qdepMNcgrfIjp 6weRzNN/5iuIYv9wS2wFJhvpOoISGNrLu42VIHRqRfYfKFd46P72ODhKu+yjoGs3/c 9ndbe0u6BBvzhVhJh/HR2YlF+RcesOiP6UP9iTt85KbX/L6LjWuTSLSOUHNwXxsH44 wchOStyoK24gJ0GNfE2VbQffPpR52ONtSS9XNP/BihL6OUK/ANk5CbgQRFNlGosOGm vLPdZN0AdJ48Q== Subject: [FFmpeg-devel] [PATCH 2/2] Inserted check on codeblock size, added limits on codeblock size Modified according to Niedermayer suggestions 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 --- libavcodec/j2kenc.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 1bd4fbd..20dda87 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,13 @@ 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; @@ -1178,21 +1183,20 @@ 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" }, - { "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, }, + { "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.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 } };