[FFmpeg-devel] [PATCH 10/12] libavcodec: Minor macro polishing

Nedeljko Babic nedeljko.babic at imgtec.com
Thu Jun 11 16:08:55 CEST 2015


Use macros from aac_defines.h for adding suffixes
 instead of local macros.

Signed-off-by: Nedeljko Babic <nedeljko.babic at imgtec.com>
---
 libavcodec/cbrt_tablegen.h             |  5 ++---
 libavcodec/cbrt_tablegen_template.c    |  2 +-
 libavcodec/sinewin.h                   | 17 +++++------------
 libavcodec/sinewin_tablegen.h          | 21 +++++++++------------
 libavcodec/sinewin_tablegen_template.c | 14 ++++----------
 5 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h
index 07ef392..27a3e3a 100644
--- a/libavcodec/cbrt_tablegen.h
+++ b/libavcodec/cbrt_tablegen.h
@@ -26,12 +26,11 @@
 #include <stdint.h>
 #include <math.h>
 #include "libavutil/attributes.h"
+#include "libavcodec/aac_defines.h"
 
 #if USE_FIXED
-#define CBRT_RENAME(a) a ## _fixed
 #define CBRT(x) (int)floor((x).f * 8192 + 0.5)
 #else
-#define CBRT_RENAME(a) a
 #define CBRT(x) x.i
 #endif
 
@@ -46,7 +45,7 @@
 #else
 static uint32_t cbrt_tab[1 << 13];
 
-static av_cold void CBRT_RENAME(cbrt_tableinit)(void)
+static av_cold void AAC_RENAME(cbrt_tableinit)(void)
 {
     if (!cbrt_tab[(1<<13) - 1]) {
         int i;
diff --git a/libavcodec/cbrt_tablegen_template.c b/libavcodec/cbrt_tablegen_template.c
index a8c0495..9dd2cf5 100644
--- a/libavcodec/cbrt_tablegen_template.c
+++ b/libavcodec/cbrt_tablegen_template.c
@@ -27,7 +27,7 @@
 
 int main(void)
 {
-    CBRT_RENAME(cbrt_tableinit)();
+    AAC_RENAME(cbrt_tableinit)();
 
     write_fileheader();
 
diff --git a/libavcodec/sinewin.h b/libavcodec/sinewin.h
index 5f0a74a..27c107c 100644
--- a/libavcodec/sinewin.h
+++ b/libavcodec/sinewin.h
@@ -23,6 +23,7 @@
 
 #include "config.h"
 #include "libavutil/mem.h"
+#include "libavcodec/aac_defines.h"
 
 #if CONFIG_HARDCODED_TABLES
 #   define SINETABLE_CONST const
@@ -34,28 +35,20 @@
 #define USE_FIXED 0
 #endif
 
-#if USE_FIXED
-#define SINEWIN_SUFFIX(a) a ## _fixed
-#define INTFLOAT int
-#else
-#define SINEWIN_SUFFIX(a) a
-#define INTFLOAT float
-#endif
-
 #define SINETABLE(size) \
-    SINETABLE_CONST DECLARE_ALIGNED(32, INTFLOAT, SINEWIN_SUFFIX(ff_sine_##size))[size]
+    SINETABLE_CONST DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size]
 
 /**
  * Generate a sine window.
  * @param   window  pointer to half window
  * @param   n       size of half window
  */
-void SINEWIN_SUFFIX(ff_sine_window_init)(INTFLOAT *window, int n);
+void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n);
 
 /**
  * initialize the specified entry of ff_sine_windows
  */
-void SINEWIN_SUFFIX(ff_init_ff_sine_windows)(int index);
+void AAC_RENAME(ff_init_ff_sine_windows)(int index);
 
 extern SINETABLE(  32);
 extern SINETABLE(  64);
@@ -67,6 +60,6 @@ extern SINETABLE(2048);
 extern SINETABLE(4096);
 extern SINETABLE(8192);
 
-extern SINETABLE_CONST INTFLOAT * const SINEWIN_SUFFIX(ff_sine_windows)[14];
+extern SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[14];
 
 #endif /* AVCODEC_SINEWIN_H */
diff --git a/libavcodec/sinewin_tablegen.h b/libavcodec/sinewin_tablegen.h
index e1623b4..4432135 100644
--- a/libavcodec/sinewin_tablegen.h
+++ b/libavcodec/sinewin_tablegen.h
@@ -27,6 +27,7 @@
 // do not use libavutil/libm.h since this is compiled both
 // for the host and the target and config.h is only valid for the target
 #include <math.h>
+#include "libavcodec/aac_defines.h"
 #include "libavutil/attributes.h"
 #include "libavutil/common.h"
 
@@ -49,33 +50,29 @@ SINETABLE(8192);
 #endif
 
 #if USE_FIXED
-#define SINEWIN_SUFFIX(a) a ## _fixed
-#define INTFLOAT int
 #define SIN_FIX(a) (int)floor((a) * 0x80000000 + 0.5)
 #else
-#define SINEWIN_SUFFIX(a) a
-#define INTFLOAT float
 #define SIN_FIX(a) a
 #endif
 
-SINETABLE_CONST INTFLOAT * const SINEWIN_SUFFIX(ff_sine_windows)[] = {
+SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = {
     NULL, NULL, NULL, NULL, NULL, // unused
-    SINEWIN_SUFFIX(ff_sine_32) , SINEWIN_SUFFIX(ff_sine_64), SINEWIN_SUFFIX(ff_sine_128),
-    SINEWIN_SUFFIX(ff_sine_256), SINEWIN_SUFFIX(ff_sine_512), SINEWIN_SUFFIX(ff_sine_1024),
-    SINEWIN_SUFFIX(ff_sine_2048), SINEWIN_SUFFIX(ff_sine_4096), SINEWIN_SUFFIX(ff_sine_8192)
+    AAC_RENAME(ff_sine_32) , AAC_RENAME(ff_sine_64), AAC_RENAME(ff_sine_128),
+    AAC_RENAME(ff_sine_256), AAC_RENAME(ff_sine_512), AAC_RENAME(ff_sine_1024),
+    AAC_RENAME(ff_sine_2048), AAC_RENAME(ff_sine_4096), AAC_RENAME(ff_sine_8192)
 };
 
 // Generate a sine window.
-av_cold void SINEWIN_SUFFIX(ff_sine_window_init)(INTFLOAT *window, int n) {
+av_cold void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n) {
     int i;
     for(i = 0; i < n; i++)
         window[i] = SIN_FIX(sinf((i + 0.5) * (M_PI / (2.0 * n))));
 }
 
-av_cold void SINEWIN_SUFFIX(ff_init_ff_sine_windows)(int index) {
-    assert(index >= 0 && index < FF_ARRAY_ELEMS(SINEWIN_SUFFIX(ff_sine_windows)));
+av_cold void AAC_RENAME(ff_init_ff_sine_windows)(int index) {
+    assert(index >= 0 && index < FF_ARRAY_ELEMS(AAC_RENAME(ff_sine_windows)));
 #if !CONFIG_HARDCODED_TABLES
-    SINEWIN_SUFFIX(ff_sine_window_init)(SINEWIN_SUFFIX(ff_sine_windows)[index], 1 << index);
+    AAC_RENAME(ff_sine_window_init)(AAC_RENAME(ff_sine_windows)[index], 1 << index);
 #endif
 }
 
diff --git a/libavcodec/sinewin_tablegen_template.c b/libavcodec/sinewin_tablegen_template.c
index 45547c4..43ce1ba 100644
--- a/libavcodec/sinewin_tablegen_template.c
+++ b/libavcodec/sinewin_tablegen_template.c
@@ -21,24 +21,18 @@
  */
 
 #include <stdlib.h>
+#include "libavcodec/aac_defines.h"
 #define CONFIG_HARDCODED_TABLES 0
 
 #if USE_FIXED
-#define ADD_SUFFIX(a) a ## _fixed
-#define INTFLOAT int
 #define WRITE_FUNC write_int32_t_array
-
 #else
-
-#define ADD_SUFFIX(a) a
-#define INTFLOAT float
 #define WRITE_FUNC write_float_array
-
 #endif
 
 #define SINETABLE_CONST
 #define SINETABLE(size) \
-    INTFLOAT ADD_SUFFIX(ff_sine_##size)[size]
+    INTFLOAT AAC_RENAME(ff_sine_##size)[size]
 #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
 #include "sinewin_tablegen.h"
 #include "tableprint.h"
@@ -50,9 +44,9 @@ int main(void)
     write_fileheader();
 
     for (i = 5; i <= 13; i++) {
-        ADD_SUFFIX(ff_init_ff_sine_windows)(i);
+        AAC_RENAME(ff_init_ff_sine_windows)(i);
         printf("SINETABLE(%4i) = {\n", 1 << i);
-        WRITE_FUNC(ADD_SUFFIX(ff_sine_windows)[i], 1 << i);
+        WRITE_FUNC(AAC_RENAME(ff_sine_windows)[i], 1 << i);
         printf("};\n");
     }
 
-- 
1.8.2.1



More information about the ffmpeg-devel mailing list