From patchwork Tue Nov 10 10:47:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23510 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 2AFB0449CD8 for ; Tue, 10 Nov 2020 12:58:31 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 93D1868BE6A; Tue, 10 Nov 2020 12:50:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D59AE68BE58 for ; Tue, 10 Nov 2020 12:50:00 +0200 (EET) Received: by mail-wm1-f67.google.com with SMTP id 10so2534225wml.2 for ; Tue, 10 Nov 2020 02:50:00 -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=SA8dO2A2Cpe5oqjcXWIm3TLrm0U5wIFjgWl3DGD+HOU=; b=dNePgXIR1BJ6jPJCUH+csEuShXZepEp84FrI7+alZbc5qrlB6pcN57CMLrfQZVP9DC HaH3XCzb+94sgIHRveE1ccmT2EANIiZ6iuuaOimEYQ6vY0Ll7XgNTTHeoWuf8OhRNHjN MpUkcnU7LvadCN7nI8ksqzbO5l+kOGTiV8hz56dBeRm2CQvjrcL8j57d5tfgtxliqJ6P U6cx74LoEq7BHfuCRLC5Oz7esj2Imu67yO5vepiGmatqT2KvbVcK/YCfe9Y92Cr80dOA 8msDgUJtaEubdfXErWFD/ygJQ7WjpaxyYyh5n9AWt5pStVoRPxkNHVq9AkuWOeQYzMV4 y6+w== 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=SA8dO2A2Cpe5oqjcXWIm3TLrm0U5wIFjgWl3DGD+HOU=; b=Rido2pp/FrXhDbFNuSxVuome2mrWVC9AVuxczA06wFuBwpuqgSyNsC2EDJ8vqeKsw8 8FsXmkw7HqxzQF3r6KLWEmFDhIIMzw6ZEMj9V6ko1FkF+0fXducw+ckw6Ieq0GVGOjLo y6sR49a/oB9dNkjX1bxYZ/vMCD8Uih/5PYFD25ofKhyNgbGVFXKSmQ2vejizJamQjYuo Ajr6idxfcKyS7tKiFhD0+Ze2QYBQVt9hECcpGoT5ri4FVxbw538znjlo7EpRTCVaZqdk YpOMa5tOeRSI2Xj92tJY9ZRhPmGTpG9puXnQJoZ4sMu84yrD8uPmCXkd4rou3gXzOnP9 dfWQ== X-Gm-Message-State: AOAM533ix+3+YoqFDUxARBEDOnJLl+A6gbRDr0XaqGVilbIGGRBBIHZI iAT00c2h5cze2xqGJGDE/3LAmbJ3T80= X-Google-Smtp-Source: ABdhPJzjoAebbgEwDYvAjNE3ABSU0hWX9tty+G9/alYlEEgRd1/TZ15kZVbUTu0K8qjiJ08g9d15RQ== X-Received: by 2002:a05:600c:21cc:: with SMTP id x12mr821478wmj.8.1605005400062; Tue, 10 Nov 2020 02:50:00 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id l24sm2572543wmi.7.2020.11.10.02.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 02:49:59 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Nov 2020 11:47:37 +0100 Message-Id: <20201110104851.321029-41-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 040/114] avcodec/mpc7: Avoid offsets table when creating VLCs 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" Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc7.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index 3c1a8578dd..7f6a01d444 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -38,22 +38,15 @@ static VLC scfi_vlc, dscf_vlc, hdr_vlc, quant_vlc[MPC7_QUANT_VLC_TABLES][2]; -static const uint16_t quant_sizes[MPC7_QUANT_VLC_TABLES*2] = -{ - 512, 512, 512, 516, 512, 512, 512, 512, 512, 512, 512, 528, 512, 548 -}; - - static av_cold int mpc7_decode_init(AVCodecContext * avctx) { - int i, j; + int j; MPCContext *c = avctx->priv_data; GetBitContext gb; LOCAL_ALIGNED_16(uint8_t, buf, [16]); static int vlc_initialized = 0; static VLC_TYPE quant_tables[7224][2]; - VLC_TYPE (*quant_table)[2] = quant_tables; const uint8_t *raw_quant_table = mpc7_quant_vlcs; /* Musepack SV7 is always stereo */ @@ -102,16 +95,16 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) INIT_VLC_STATIC_FROM_LENGTHS(&hdr_vlc, MPC7_HDR_BITS, MPC7_HDR_SIZE, &mpc7_hdr[1], 2, &mpc7_hdr[0], 2, 1, -5, 0, 1 << MPC7_HDR_BITS); - for(i = 0; i < MPC7_QUANT_VLC_TABLES; i++){ + for (unsigned i = 0, offset = 0; i < MPC7_QUANT_VLC_TABLES; i++){ for(j = 0; j < 2; j++){ - quant_vlc[i][j].table = quant_table; - quant_vlc[i][j].table_allocated = quant_sizes[i * 2 + j]; - quant_table += quant_sizes[i * 2 + j]; + quant_vlc[i][j].table = &quant_tables[offset]; + quant_vlc[i][j].table_allocated = FF_ARRAY_ELEMS(quant_tables) - offset; ff_init_vlc_from_lengths(&quant_vlc[i][j], 9, mpc7_quant_vlc_sizes[i], &raw_quant_table[1], 2, &raw_quant_table[0], 2, 1, mpc7_quant_vlc_off[i], INIT_VLC_USE_NEW_STATIC); raw_quant_table += 2 * mpc7_quant_vlc_sizes[i]; + offset += quant_vlc[i][j].table_size; } } vlc_initialized = 1;