From patchwork Fri Nov 20 07:19:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23950 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:c00a:0:0:0:0:0 with SMTP id c10csp952891ybf; Thu, 19 Nov 2020 23:32:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtxZxyHUsQ44422p3DBNHm0bdVkgc6SkL7/HfqA2ym16O3FCIAo730pCY+1FUA7LuZAs0i X-Received: by 2002:a1c:7202:: with SMTP id n2mr8007384wmc.38.1605857553849; Thu, 19 Nov 2020 23:32:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605857553; cv=none; d=google.com; s=arc-20160816; b=rfmo03qxT9EIll3FNb7mGQI6Gd01N7sk67eavSXXWp0c0iByLKdLsL3RNSoZw0lITi V9dei23ZmvkrjpnqjDwBIhnwPrL8WcSO6UYFAbWMAKh6+RBDnIRO6wzvpmgDsBUAT2Cv ZRJrHo6iP3paSI94QAt7//c1sJg37Hdm/QY/z9zclv/63fLEtW+YW1p/1HECbJy191as /JTMUZoLqIKSMcsrQQhuKkHSjBG9m2XbWC0xUW8sNzRfZGKtZC30uQDqFwmQmlLnHAj1 L0NjHGXYtp8LiDGgRtkxY0UYItPQWhhAODUQlbvcUNPArUh8b6/zMzqMceeYdvI68pSK dxeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=88zL/PdOzv+bEi1XJ09MKNMyM1M54A2qBQ6nRJBQAhE=; b=Png3kbTVi4WSIWW2LHMYdEzGDNeSzpm1ZjLgZppcSH3VdBrv9rrntNOqGpP4wUZ1PB iPZPcLs8asxwshvTIXPLe1t56VbfQ9otCjriDiNTNQxITem0VCulUB9RI+KNYVekEKMI T6269AhRSDjsxuYmI+UtRUQY7YDgPnU7fuN+17vIMVd0cKS6JtfE5UDuN3ZQaatv9DmS Xn7CfY7eVEC55ny/jEg3rRgUPBenQzJinQ6egGXCTy3bFX6wIOwQR3ATWj1a0P8mFYpy HbgimjlfbiiNkFQurzaGvI3EUkTMnesv7lUgSn/orIrYBzOL2mXWQ3BlsuSoKzNxlfSd RvBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=YtW6h12H; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i3si1860669wri.144.2020.11.19.23.32.33; Thu, 19 Nov 2020 23:32:33 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=YtW6h12H; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D38CC68BB14; Fri, 20 Nov 2020 09:25:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 02CCB68BACF for ; Fri, 20 Nov 2020 09:24:59 +0200 (EET) Received: by mail-ej1-f67.google.com with SMTP id gj5so11499126ejb.8 for ; Thu, 19 Nov 2020 23:24:59 -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=dDF1pF3kIPIUhgN+IABdQc5A/fUTVFuorTg9cgIWRMM=; b=YtW6h12Hnv9gfI2vJuP11llPhZSHAzutUXWYewzTc7Ca8nO/3KNRaEDSK9CPYvXCxe 9ZLaebCIwWUS5JL1QX46atEEH9OugctnuRVt2REzfN5fl2wA92eg8HDiTio+kdI8p8DM ntGFJ1vdrkM7LCax7ZRr41vh+DVN2wH8psBxl957Wd8Ld2KFhxOS9ORmbeozPfvvlFI7 NokhgFqL/HUAbkvXFrd3YjD+iigLCruTqPPpGcY3CT/kiFq4cm3Tazn9NT/J9CigQyxs mfbQ2c7LUwdTpm7xNDljLhjktEWLrU4Hbg8BfNGw++M0andDuqBAMcIs280LiKCIZWPE 11hA== 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=dDF1pF3kIPIUhgN+IABdQc5A/fUTVFuorTg9cgIWRMM=; b=kTn4fdMr3gbcvDhB9uICfVU2yxETSuniHH6xAyY3dOQ1UIi6cDwGXPdey6Zl5SL0Uu uZaDc78V9RBkBVQHbtZK7O9WUAloiwyQaSPI/BUqwtU3YMF6xK5xxTWepxC/2eEizrw+ SGTS4SuIf+C8gcPpZVBuSjMOgQdRG6aE6No5rs4ysu1AbSaIDno3kYxOy1MbtK/GZqyy PeS1eQSTw1FFG8djQX+yFv6Rv44JzP7DFEO8J7hM0lqo5ZBTRD/qpuBrk+/fIDbSrOZt 2DZO+/ZYrG9ZIkL6TktdKv4td/bycco/aMjsb0eLW+fo4xeWV6d/UWXmkNFDn5tFdAbM mrFA== X-Gm-Message-State: AOAM530LuMWtOHumZPiahGffc/pEnH8n2X9JBsHH896z8MfNPp0ws0fq R9aysD5AHPuzwSRswzOpW0jrv1MQ4l0/sw== X-Received: by 2002:a17:906:2581:: with SMTP id m1mr30983667ejb.28.1605857099191; Thu, 19 Nov 2020 23:24:59 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id lz27sm779419ejb.39.2020.11.19.23.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:24:58 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:19:21 +0100 Message-Id: <20201120072116.818090-49-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 048/162] 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" X-TUID: pcEVHdTyhk71 Content-Length: 3490 Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc7.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index ad0fc6dbbc..0b9e6f0088 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,17 +95,17 @@ 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, NULL); + INIT_VLC_STATIC_OVERLONG, NULL); raw_quant_table += 2 * mpc7_quant_vlc_sizes[i]; + offset += quant_vlc[i][j].table_size; } } vlc_initialized = 1;