Commit a9d986c2 authored by Nedeljko Babic's avatar Nedeljko Babic Committed by Michael Niedermayer

avcodec: Minor macro polishing

Use macros from aac_defines.h for adding suffixes
 instead of local macros.
Signed-off-by: 's avatarNedeljko Babic <nedeljko.babic@imgtec.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 4845f668
......@@ -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;
......
......@@ -27,7 +27,7 @@
int main(void)
{
CBRT_RENAME(cbrt_tableinit)();
AAC_RENAME(cbrt_tableinit)();
write_fileheader();
......
......@@ -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 */
......@@ -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
}
......
......@@ -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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment