[FFmpeg-devel] [PATCH] avcodec/aacsbr_tablegen: always initialize tables at runtime

Ganesh Ajjanagadde gajjanagadde at gmail.com
Mon Nov 30 04:58:03 CET 2015


This gets rid of virtually useless hardcoded tables hackery. The reason
it is useless is that a 320 element lut is anyway placed regardless of
--enable-hardcoded-tables, from which all necessary tables are trivially
derived at runtime at very low cost:

sample benchmark (x86-64, Haswell, GNU/Linux, single run is really
what is relevant here since looping drastically changes the bench). Fluctuations
are on the order of 10% for the single run test:
39400 decicycles in aacsbr_tableinit,       1 runs,      0 skips
25325 decicycles in aacsbr_tableinit,       2 runs,      0 skips
18475 decicycles in aacsbr_tableinit,       4 runs,      0 skips
15008 decicycles in aacsbr_tableinit,       8 runs,      0 skips
13016 decicycles in aacsbr_tableinit,      16 runs,      0 skips
12005 decicycles in aacsbr_tableinit,      32 runs,      0 skips
11546 decicycles in aacsbr_tableinit,      64 runs,      0 skips
11506 decicycles in aacsbr_tableinit,     128 runs,      0 skips
11500 decicycles in aacsbr_tableinit,     256 runs,      0 skips
11183 decicycles in aacsbr_tableinit,     509 runs,      3 skips

Tested with FATE with/without --enable-hardcoded-tables.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 libavcodec/Makefile                 |  8 ++-----
 libavcodec/aacsbr_fixed_tablegen.c  | 42 -------------------------------------
 libavcodec/aacsbr_fixed_tablegen.h  |  4 ----
 libavcodec/aacsbr_tablegen.c        | 42 -------------------------------------
 libavcodec/aacsbr_tablegen.h        |  4 ----
 libavcodec/aacsbr_tablegen_common.h |  4 ----
 6 files changed, 2 insertions(+), 102 deletions(-)
 delete mode 100644 libavcodec/aacsbr_fixed_tablegen.c
 delete mode 100644 libavcodec/aacsbr_tablegen.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d85215d..a4c35b9 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -965,8 +965,6 @@ TOOLS = fourcc2pixfmt
 
 HOSTPROGS = aacps_tablegen                                              \
             aacps_fixed_tablegen                                        \
-            aacsbr_tablegen                                             \
-            aacsbr_fixed_tablegen                                       \
             cbrt_tablegen                                               \
             cbrt_fixed_tablegen                                         \
             cos_tablegen                                                \
@@ -996,8 +994,8 @@ else
 $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0
 endif
 
-GEN_HEADERS = cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aacps_fixed_tables.h aacsbr_tables.h \
-              aacsbr_fixed_tables.h dsd_tables.h dv_tables.h     \
+GEN_HEADERS = cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aacps_fixed_tables.h \
+              dsd_tables.h dv_tables.h     \
               sinewin_tables.h sinewin_fixed_tables.h mpegaudio_tables.h motionpixels_tables.h \
               pcm_tables.h qdm2_tables.h
 GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS))
@@ -1010,8 +1008,6 @@ $(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h
 $(SUBDIR)aacdec_fixed.o: $(SUBDIR)cbrt_fixed_tables.h
 $(SUBDIR)aacps_float.o: $(SUBDIR)aacps_tables.h
 $(SUBDIR)aacps_fixed.o: $(SUBDIR)aacps_fixed_tables.h
-$(SUBDIR)aacsbr.o: $(SUBDIR)aacsbr_tables.h
-$(SUBDIR)aacsbr_fixed.o: $(SUBDIR)aacsbr_fixed_tables.h
 $(SUBDIR)aactab_fixed.o: $(SUBDIR)aac_fixed_tables.h
 $(SUBDIR)dsddec.o: $(SUBDIR)dsd_tables.h
 $(SUBDIR)dvenc.o: $(SUBDIR)dv_tables.h
diff --git a/libavcodec/aacsbr_fixed_tablegen.c b/libavcodec/aacsbr_fixed_tablegen.c
deleted file mode 100644
index b896d75..0000000
--- a/libavcodec/aacsbr_fixed_tablegen.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Header file for hardcoded AAC SBR windows
- *
- * Copyright (c) 2014 Reimar Döffinger <Reimar.Doeffinger at gmx.de>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdlib.h>
-#include "libavutil/internal.h"
-#include "libavutil/common.h"
-#undef CONFIG_HARDCODED_TABLES
-#define CONFIG_HARDCODED_TABLES 0
-#define USE_FIXED 1
-#include "aacsbr_fixed_tablegen.h"
-#include "tableprint.h"
-
-int main(void)
-{
-    aacsbr_tableinit();
-
-    write_fileheader();
-
-    WRITE_ARRAY_ALIGNED("static const", 32, int32_t, sbr_qmf_window_ds);
-    WRITE_ARRAY_ALIGNED("static const", 32, int32_t, sbr_qmf_window_us);
-
-    return 0;
-}
diff --git a/libavcodec/aacsbr_fixed_tablegen.h b/libavcodec/aacsbr_fixed_tablegen.h
index 1439ebe..3fcf020 100644
--- a/libavcodec/aacsbr_fixed_tablegen.h
+++ b/libavcodec/aacsbr_fixed_tablegen.h
@@ -25,8 +25,4 @@
 
 #include "aacsbr_tablegen_common.h"
 
-#if CONFIG_HARDCODED_TABLES
-#include "libavcodec/aacsbr_fixed_tables.h"
-#endif /* CONFIG_HARDCODED_TABLES */
-
 #endif /* AVCODEC_AACSBR_FIXED_TABLEGEN_H */
diff --git a/libavcodec/aacsbr_tablegen.c b/libavcodec/aacsbr_tablegen.c
deleted file mode 100644
index ee0d818..0000000
--- a/libavcodec/aacsbr_tablegen.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Header file for hardcoded AAC SBR windows
- *
- * Copyright (c) 2014 Reimar Döffinger <Reimar.Doeffinger at gmx.de>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdlib.h>
-#include "libavutil/internal.h"
-#include "libavutil/common.h"
-#undef CONFIG_HARDCODED_TABLES
-#define CONFIG_HARDCODED_TABLES 0
-#define USE_FIXED 0
-#include "aacsbr_tablegen.h"
-#include "tableprint.h"
-
-int main(void)
-{
-    aacsbr_tableinit();
-
-    write_fileheader();
-
-    WRITE_ARRAY_ALIGNED("static const", 32, float, sbr_qmf_window_ds);
-    WRITE_ARRAY_ALIGNED("static const", 32, float, sbr_qmf_window_us);
-
-    return 0;
-}
diff --git a/libavcodec/aacsbr_tablegen.h b/libavcodec/aacsbr_tablegen.h
index d86eba7..242a963 100644
--- a/libavcodec/aacsbr_tablegen.h
+++ b/libavcodec/aacsbr_tablegen.h
@@ -25,8 +25,4 @@
 
 #include "aacsbr_tablegen_common.h"
 
-#if CONFIG_HARDCODED_TABLES
-#include "libavcodec/aacsbr_tables.h"
-#endif /* CONFIG_HARDCODED_TABLES */
-
 #endif /* AVCODEC_AACSBR_TABLEGEN_H */
diff --git a/libavcodec/aacsbr_tablegen_common.h b/libavcodec/aacsbr_tablegen_common.h
index 0a64552..e60231e 100644
--- a/libavcodec/aacsbr_tablegen_common.h
+++ b/libavcodec/aacsbr_tablegen_common.h
@@ -24,9 +24,6 @@
 #define AVCODEC_AACSBR_TABLEGEN_COMMON_H
 #include "aac.h"
 
-#if CONFIG_HARDCODED_TABLES
-#define aacsbr_tableinit()
-#else
 ///< window coefficients for analysis/synthesis QMF banks
 static DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_ds)[320];
 static DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_us)[640] = {
@@ -124,6 +121,5 @@ static av_cold void aacsbr_tableinit(void)
     for (n = 0; n < 320; n++)
         sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n];
 }
-#endif /* CONFIG_HARDCODED_TABLES */
 
 #endif /* AVCODEC_AACSBR_TABLEGEN_COMMON_H */
-- 
2.6.2



More information about the ffmpeg-devel mailing list