From patchwork Fri Nov 20 07:32:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23863 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 8184744B2D5 for ; Fri, 20 Nov 2020 09:46:38 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CE39368BCD5; Fri, 20 Nov 2020 09:34:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D4A168BC9C for ; Fri, 20 Nov 2020 09:34:21 +0200 (EET) Received: by mail-ej1-f66.google.com with SMTP id bo9so5775594ejb.13 for ; Thu, 19 Nov 2020 23:34:21 -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=iDl1FqIR5Yp3Nw2h2JU2JVPuehSzxF19mTwoOHxV5Pc=; b=AswM9uPwYd0lFCkpG6kyLpGGiQd9+/k+69ocZALCuES69J6uHvHmH26aloTMCFyHX2 iBdW3SAFWewLfr4m3a0Dt9XZLpDYKR8wle4sgNeORVHAPeYYWYo7sF6ipti+85yiNED4 eFX05bMLaEUqtdnj2qLoq6Dc7FHJnMpD/FAGVKdnNz3ft3D0uXpNBY5Lru0TXwzyxkZ5 bT+5fT2hwZem2WH+cN+EMWPSrNXvJxsNBcATOBtAOUTqek7EIttPdWqxU7Tnz0gINyyb 9pYHw721hX7U9FDFGA84rZSB2k7ABMI1dX1i7KYyuGl2QlgKx413bktdLkeB+EjHtDA+ PvdA== 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=iDl1FqIR5Yp3Nw2h2JU2JVPuehSzxF19mTwoOHxV5Pc=; b=HxFbQjFmOKFuiBIY8hMPukO6gp1pTw0goy0KzQfFGr6hDJBis5Q6kKdAyp2fEn6Jyq S2wpfVLbVEAgH4kvU1wrYJ+YX++FcrSl1ZMyekRVCpw7kmv9k+cDN6j5wiqczG0+Pv+s pjJV4AssYBktc6X+1QLrPoXehCil3dM5QnwDvAZz5NR/o0+YUgDkmujANluvwGSRm4/B W+/UP0XRZCZfnX+7ab/UOWcSIUaWCbl/YnUgvnjJrsq2xFHY93a/Kp+VvCPfWQ8i8WtR LUwYcrz/ika/1L56/SPqUFU05H9wGa1bk/CCJi3IMy8ixB9QlkdblvhfCdcrmgc0GSCQ XVJQ== X-Gm-Message-State: AOAM530EZmDxyETc0U52v3uSMp6EKy4/4vfdHREgKAMBS27WySo/Dhur oJlxg0I1j3aUv+m0mkvoUsROovR00iJs9g== X-Google-Smtp-Source: ABdhPJzk/I5wKY5JbqdctoaT9anBdK7oB3p+UPYJbSsf4k8ZXPS5B6M3bcCWDhW01m8OpzpypIprvA== X-Received: by 2002:a17:906:3153:: with SMTP id e19mr5460320eje.17.1605857660525; Thu, 19 Nov 2020 23:34:20 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id i13sm769110ejv.84.2020.11.19.23.34.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:34:20 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:32:43 +0100 Message-Id: <20201120073327.820745-19-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201120072116.818090-1-andreas.rheinhardt@gmail.com> References: <20201120072116.818090-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 118/162] 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 4814beb112..b5f819985a 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,