From patchwork Fri Nov 20 07:33:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23913 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 9F6DD44AD6B for ; Fri, 20 Nov 2020 09:55:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 08C1368BDDE; Fri, 20 Nov 2020 09:35:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0CE2068BD13 for ; Fri, 20 Nov 2020 09:35:05 +0200 (EET) Received: by mail-ej1-f65.google.com with SMTP id o21so11523999ejb.3 for ; Thu, 19 Nov 2020 23:35:04 -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=IjKlLUpa23iYyosm3Ri0FV6NTE4kA8Fr+9nQmLUt9B4=; b=nhvfRIBX7Nq3C8Y5H4TU/xFVDTTfAyD00+n83HYy3gvgRXowde2e2VtT8xxk9KUCgY h4GjU65dniNeOO9J7NUgMs6/zx7dHSlM2KrIL6M8tdE1oyO2a3K91uw8H1p1/4XAgLWT N9E02ObMcvlK3gZ4mOtUofCNtdshj6HQBr31ZWUDG0m9Wiz3rfTwKK8vrZcuGR2qhNJF to3g4z4l3Apps4TztM3TbEAqTigNGe0Uh9c8QOUug85gq3kjt4/nDsV0CoX7Qcu3clrR aByvuiLHTIBMknTgg+ds2W07aXvBtoloRf0WYQFt1V5qKnN7tA2Agacz2Fpw1OjL3XTR 7HGQ== 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=IjKlLUpa23iYyosm3Ri0FV6NTE4kA8Fr+9nQmLUt9B4=; b=DFyd8kvdcUptLed0AZJQlgGB5Tb8vKM37NHW5nsHtIQ94eu+ipo0FRczEE3hRGDYmD +mklXnnWnPeBao+Pb/goPmLHsYx0S28bvcnt4VeO7iSCWeSlfM4uiJOwqjuV7arFE4Vy 6NqB7mRdxHw6442hiXHa/oezWZ+hPnGEeIl427vt7IQBsN3/QROzJ5eel04Zf/vzA/Yl PQtqYp0VnkC0B6tPGLrERBZxtJtiH79OJMiSLnZRxPCIRhiiHPOkfbpPDabMYsMLXCIT 7N/I+Jsrb4ryIMD5jy2oUn+juOdJxZ8fBfrSuvFPj54WuHbZAI29iHBF9+VwPkOiLKAw mghQ== X-Gm-Message-State: AOAM531EQ4hxwehnDJHmpTgjfcEYm6pepHH14ewQYw/0hxXlmCScCdcn NtMVrwlMMPShmo0/wh+e5NMKPui1/dyQew== X-Google-Smtp-Source: ABdhPJzqOfl94BWzMgijnYEQpsbNmSG5Ns95IYbgafXnjf3nZvwRYuLavNeuGJ7piZXc9uZWNcZEmw== X-Received: by 2002:a17:906:4a02:: with SMTP id w2mr13911952eju.267.1605857704259; Thu, 19 Nov 2020 23:35:04 -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.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:35:03 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:33:24 +0100 Message-Id: <20201120073327.820745-60-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 159/162] avcodec/mpegaudio_tablegen: Avoid write-only buffers 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 mpegaudio_tablegen header contains code to initialize several tables; it is included in both the fixed as well as the floating point mpegaudio decoders and some of these tables are only used by the fixed resp. floating point decoders; yet both types are always initialized, leaving the compiler to figure out that one of them is unused. GCC 9.3 fails at this (even with -O3): $ readelf -s mpegaudiodec_fixed.o|grep _float 28: 0000000000001660 32768 OBJECT LOCAL DEFAULT 4 expval_table_float An actually unused table (expval_table_fixed/float) of size 32KiB is kept and initialized (the reason for this is probably that this table is read from, namely to initialize another table: exp_table_fixed/float; of course the float resp. fixed tables are not used in the fixed resp. floating point decoder). Therefore #ifdef the unneeded tables away. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudio_tablegen.c | 1 + libavcodec/mpegaudio_tablegen.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libavcodec/mpegaudio_tablegen.c b/libavcodec/mpegaudio_tablegen.c index ede7c8e221..bff0f031a1 100644 --- a/libavcodec/mpegaudio_tablegen.c +++ b/libavcodec/mpegaudio_tablegen.c @@ -22,6 +22,7 @@ #include #define CONFIG_HARDCODED_TABLES 0 +#define BOTH_TABLES #include "libavutil/tablegen.h" #include "mpegaudio_tablegen.h" #include "tableprint.h" diff --git a/libavcodec/mpegaudio_tablegen.h b/libavcodec/mpegaudio_tablegen.h index 0b0ea40682..c78d5b5d7c 100644 --- a/libavcodec/mpegaudio_tablegen.h +++ b/libavcodec/mpegaudio_tablegen.h @@ -34,10 +34,18 @@ #else static int8_t table_4_3_exp[TABLE_4_3_SIZE]; static uint32_t table_4_3_value[TABLE_4_3_SIZE]; + +#if defined(BOTH_TABLES) || !USE_FLOATS +#define FIXED_TABLE static uint32_t exp_table_fixed[512]; static uint32_t expval_table_fixed[512][16]; +#endif + +#if defined(BOTH_TABLES) || USE_FLOATS +#define FLOAT_TABLE static float exp_table_float[512]; static float expval_table_float[512][16]; +#endif #define FRAC_BITS 23 #define IMDCT_SCALAR 1.759 @@ -79,13 +87,23 @@ static av_cold void mpegaudio_tableinit(void) exp2_val = exp2_base * exp2_lut[exponent & 3] / IMDCT_SCALAR; for (value = 0; value < 16; value++) { double f = pow43_lut[value] * exp2_val; +#ifdef FIXED_TABLE expval_table_fixed[exponent][value] = (f < 0xFFFFFFFF ? llrint(f) : 0xFFFFFFFF); +#endif +#ifdef FLOAT_TABLE expval_table_float[exponent][value] = f; +#endif } +#ifdef FIXED_TABLE exp_table_fixed[exponent] = expval_table_fixed[exponent][1]; +#endif +#ifdef FLOAT_TABLE exp_table_float[exponent] = expval_table_float[exponent][1]; +#endif } } +#undef FLOAT_TABLE +#undef FIXED_TABLE #endif /* CONFIG_HARDCODED_TABLES */ #endif /* AVCODEC_MPEGAUDIO_TABLEGEN_H */