1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec: Minor macro polishing

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

Signed-off-by: Nedeljko Babic <nedeljko.babic@imgtec.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Nedeljko Babic 2015-07-20 13:36:20 +02:00 committed by Michael Niedermayer
parent 4845f6687d
commit a9d986c2ce
5 changed files with 21 additions and 38 deletions

View File

@ -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;

View File

@ -27,7 +27,7 @@
int main(void)
{
CBRT_RENAME(cbrt_tableinit)();
AAC_RENAME(cbrt_tableinit)();
write_fileheader();

View File

@ -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 */

View File

@ -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
}

View File

@ -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");
}