From patchwork Tue Nov 10 10:58:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23516 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 78BB644A3F2 for ; Tue, 10 Nov 2020 12:59:23 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 64F9368BFC8; Tue, 10 Nov 2020 12:59:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8A7BD68BFC6 for ; Tue, 10 Nov 2020 12:59:17 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id j7so4921172wrp.3 for ; Tue, 10 Nov 2020 02:59:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=8peZw8sPL4v3VOz7K0+VBd5PAzkTA73KI0lrqzLHFEU=; b=CqqJIpFzfmbTbEMrNuFgO1kO2T1vVUJb49CFbpAsbHFfM5650cEKlwX24V0k31jF2M BOz0FEkfq519hRRDo+n1R4IXqF70jU/kTty2qHh2DzQzCmiaqiA+HiCr4y8K7bsqusE/ rDqKpqLdub8aBqRpm4s9t92rfixA5F5taW18Q8yzq6hLKc2aoDvKvOpZPAP5PwlACrl9 spa3FOAwA2dn6NZPp36ji4wgTKbkcahcPp9bOs13wcp9mT808PJ32wutInUMxnnvgJdm u7odEKfRXou5rShZzKtg71LvmKziKASpfEq2dd0UU6mVU6Om3U8o/wkp2DWFmSEZIxak IbNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=8peZw8sPL4v3VOz7K0+VBd5PAzkTA73KI0lrqzLHFEU=; b=nvjZjC5oQKVlMYeqRxWIXW4bGGdGUNtoHj8I7j3PnBZSYIgIizHIZAytUTKqtl1HI9 dQxQ8CRZ4K5q6DLF5XxrY6Eb+IOs4dQdLj0S66HIxy/IEi3VCR9NvgWH3raCJR+1CqNW 3vxCudVlAs5NfOQ2IiCN3fAkT7u0S9iGVQnzewxMAdlGPSTLQ7Mc+h5y9/qGAnxLo6yR gcrVvH6kmQjc0orRxBYwhkLLN2gHZymYcgY/Pj6y3sovCorH9m5WXrYuAbBypthL2Vgd qvGZG7u5SvokENCZKZc2Y5I9o1OKivUAhxhOnUnqUazOLf40z4e688L3Fh5hs09Ci/Kb 9T2g== X-Gm-Message-State: AOAM533bzmrp5ZlcvaSebAVivsP+m6KfeCDV+idyecszW6SuS8MK4xXu 3FLuZQ7prlDa6TBZQfIUP1/vETxIz4U= X-Google-Smtp-Source: ABdhPJxnZi0zd4C9rwuYY5tREJJN0xxIrvlj+7aUJNfyIQ/NT+wIs+byBl6QpjJwF2rXqyOSTB9oPA== X-Received: by 2002:adf:fd49:: with SMTP id h9mr24347399wrs.115.1605005956798; Tue, 10 Nov 2020 02:59:16 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id o197sm2561308wme.17.2020.11.10.02.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 02:59:16 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Nov 2020 11:58:16 +0100 Message-Id: <20201110105836.321916-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> References: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 094/114] avcodec/atrac9dec: Don't create VLCs that are never used 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The ATRAC9 decoder creates VLCs with parameters contained in HuffmanCodebooks; some of these HuffmanCodebooks are empty and yet VLCs (that were completely unused*) were created from them. Said VLC contained a single table with 512 VLC_TYPE[2] entries, each of which indicated that this is an invalid code. This commit stops creating said VLCs. *: read_coeffs_coarse() uses the HuffmanCodebook at9_huffman_coeffs[cb][prec][cbi]. prec is c->precision_coarse[i] + 1 and every precision_coarse entry is in the 1..15 range after calc_precision(), so prec is >= 2 (all codebooks with prec < 2 are empty). The remaining empty codebooks are those with cb == 1 and cbi == 0, yet this is impossible, too: cb is given by c->codebookset[i] and this is always 0 if i < 8 (because those are never set to anything else in calc_codebook_idx()) and cbi is given by at9_q_unit_to_codebookidx[i] which is never zero if i >= 8. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac9dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c index ddfa02a393..4715ce42d7 100644 --- a/libavcodec/atrac9dec.c +++ b/libavcodec/atrac9dec.c @@ -964,8 +964,8 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx) /* Coefficient VLCs */ tab = at9_coeffs_tab; for (int i = 0; i < 2; i++) { - for (int j = 0; j < 8; j++) { - for (int k = 0; k < 4; k++) { + for (int j = 2; j < 8; j++) { + for (int k = i; k < 4; k++) { const HuffmanCodebook *hf = &at9_huffman_coeffs[i][j][k]; ret = ff_init_vlc_from_lengths(&s->coeff_vlc[i][j][k], 9, hf->size, &tab[0][1], 2,