From patchwork Wed Sep 28 10:08:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Tomas_H=C3=A4rdin?= X-Patchwork-Id: 38427 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp99648pzh; Wed, 28 Sep 2022 03:08:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM61GJOVeyoV6gbbo12TMfX6GgeKu4EH7C9DjrtUaFmE28CDzE/8YVfhZdFYPbBMir4/Enel X-Received: by 2002:a17:907:72d4:b0:783:22e1:43a1 with SMTP id du20-20020a17090772d400b0078322e143a1mr16172878ejc.47.1664359702094; Wed, 28 Sep 2022 03:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359702; cv=none; d=google.com; s=arc-20160816; b=PjJ6ZOWqHhc3z8WGfGDIsNvOKqKaR1xWhZW3gl9OAY+10MIrlWuhqYlX38ANLd2r/i asBJqj7fQHOGSrfHt6vm6EtfXDjLubB1YPZB69cClw6wgJTzlO5cEUe7+r7R8fC/dB3c Xvx0qrHlrxzwB5SoegnLXcLpXlXOgpdg32HNxfp8eky0CCm33mDOcgt8kPJSP+nhnQPY ZzS9rvuUBbNmwoOk63cAv5ygxbftKFyHpsqcD6sNUdjnWLPNdXzvZiqlKAbCpPPHTXhX XHZyxGiG8BMC4ubW1SlL5G1zwt1AxEdB8iFQpoffmqOJf4zdtA2uLl5Fr5y1u0yCxj4w 0oQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:user-agent:references:in-reply-to:date:to:from :message-id:delivered-to; bh=hxHOu55mXxmePseXyutpbS1R9hujUiSz5FzSdNvdlaY=; b=eRo6zbBwR9bKW+J7nCFCwu0r162jfAAa+hREtYJ1sAHTsGZP9Zn4S592RwqxyOe7Zp oKPQ5FeAnTlyDZdjvALjmcZqZ9TnlbXcqfx8hdlNsLN3j9tC2WgpYzazKSBmjyNbXwWu NmBdIW+CvsNuPHcyJmPp2DOwaiQvQcGd7Y8XnR8l+UvPe+EOxnSeTttOjT647JiR0eJ8 kghqARTCTJwIlCyKbk4ePbrJcKwAUr2pu8f/ZW4L3e8P6hQJF6E/DwhR7w030Q+ozMHg DjinonLpGUFeTTkK4ICFwt/HCYyx5Q1U9FsRrdwa9/6NkNHuXwFqUw9f1eqh5BNkoEzr nWzA== ARC-Authentication-Results: i=1; mx.google.com; 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 ji14-20020a170907980e00b007806a130086si4440849ejc.302.2022.09.28.03.08.21; Wed, 28 Sep 2022 03:08:22 -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; 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 B61CE68BC56; Wed, 28 Sep 2022 13:08:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.frobbit.se (mail.frobbit.se [85.30.129.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ED03D68BC50 for ; Wed, 28 Sep 2022 13:08:13 +0300 (EEST) Received: from debian.lan (unknown [IPv6:2a00:66c0:a::72c]) by mail.frobbit.se (Postfix) with ESMTPSA id 774E2213E0 for ; Wed, 28 Sep 2022 12:08:13 +0200 (CEST) Message-ID: <975acd73022f0784d26f3799605104e344d9f958.camel@haerdin.se> From: Tomas =?iso-8859-1?q?H=E4rdin?= To: FFmpeg development discussions and patches Date: Wed, 28 Sep 2022 12:08:12 +0200 In-Reply-To: <65e79fe701374868bb2f4b70ce8fd220938e2e86.camel@haerdin.se> References: <65e79fe701374868bb2f4b70ce8fd220938e2e86.camel@haerdin.se> User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/11] lavc/jpeg2000: Minimize calls to av_codec_is_encoder() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: sRawUFOgsgMv From ecb1d9ff671b83bddb0d1c7d31d60ade4b5cdead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Tue, 14 Jun 2022 10:57:45 +0200 Subject: [PATCH 09/11] lavc/jpeg2000: Minimize calls to av_codec_is_encoder() --- libavcodec/jpeg2000.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 2574c2b97e..bb6efab72e 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -248,7 +248,7 @@ static void init_band_stepsize(AVCodecContext *avctx, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int bandno, int gbandno, int reslevelno, - int cbps) + int cbps, int is_enc) { /* TODO: Implementation of quantization step not finished, * see ISO/IEC 15444-1:2002 E.1 and A.6.4. */ @@ -306,7 +306,7 @@ static void init_band_stepsize(AVCodecContext *avctx, /* FIXME: In OpenJPEG code stepsize = stepsize * 0.5. Why? * If not set output of entropic decoder is not correct. */ - if (!av_codec_is_encoder(avctx->codec)) + if (!is_enc) band->f_stepsize *= 0.5; } @@ -317,7 +317,8 @@ static int init_prec(AVCodecContext *avctx, Jpeg2000CodingStyle *codsty, int precno, int bandno, int reslevelno, int log2_band_prec_width, - int log2_band_prec_height) + int log2_band_prec_height, + int is_enc) { Jpeg2000Prec *prec = band->prec + precno; int nb_codeblocks, cblkno, ret; @@ -414,7 +415,7 @@ static int init_prec(AVCodecContext *avctx, cblk->lblock = 3; cblk->length = 0; cblk->npasses = 0; - if (av_codec_is_encoder(avctx->codec)) { + if (is_enc) { av_freep(&cblk->layers); cblk->layers = av_calloc(codsty->nlayers, sizeof(*cblk->layers)); if (!cblk->layers) @@ -431,7 +432,7 @@ static int init_band(AVCodecContext *avctx, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int bandno, int gbandno, int reslevelno, - int cbps, int dx, int dy) + int cbps, int dx, int dy, int is_enc) { Jpeg2000Band *band = reslevel->band + bandno; uint8_t log2_band_prec_width, log2_band_prec_height; @@ -440,7 +441,7 @@ static int init_band(AVCodecContext *avctx, int nb_precincts; int i, j, ret; - init_band_stepsize(avctx, band, codsty, qntsty, bandno, gbandno, reslevelno, cbps); + init_band_stepsize(avctx, band, codsty, qntsty, bandno, gbandno, reslevelno, cbps, is_enc); /* computation of tbx_0, tbx_1, tby_0, tby_1 * see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1 @@ -494,7 +495,8 @@ static int init_band(AVCodecContext *avctx, for (precno = 0; precno < nb_precincts; precno++) { ret = init_prec(avctx, band, reslevel, comp, codsty, precno, bandno, reslevelno, - log2_band_prec_width, log2_band_prec_height); + log2_band_prec_width, log2_band_prec_height, + is_enc); if (ret < 0) return ret; } @@ -511,6 +513,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, int reslevelno, bandno, gbandno = 0, ret, i, j; uint32_t csize; size_t prod; + int is_enc = av_codec_is_encoder(avctx->codec); if (codsty->nreslevels2decode <= 0) { av_log(avctx, AV_LOG_ERROR, "nreslevels2decode %d invalid or uninitialized\n", codsty->nreslevels2decode); @@ -608,7 +611,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, ret = init_band(avctx, reslevel, comp, codsty, qntsty, bandno, gbandno, reslevelno, - cbps, dx, dy); + cbps, dx, dy, is_enc); if (ret < 0) return ret; } -- 2.30.2