diff options
author | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-12-27 17:30:15 +0000 |
---|---|---|
committer | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-12-27 17:30:15 +0000 |
commit | 507121f7fe2d170dd8db99d3112602036ddef718 (patch) | |
tree | 38b26e115cfadde356b005496286f78307839440 /libaf | |
parent | 00f99a82a8f57573e3e6982cf9d014c9b9d8a68b (diff) | |
download | mpv-507121f7fe2d170dd8db99d3112602036ddef718.tar.bz2 mpv-507121f7fe2d170dd8db99d3112602036ddef718.tar.xz |
removing AFMT_ dependancy
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14246 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libaf')
-rw-r--r-- | libaf/Makefile | 2 | ||||
-rw-r--r-- | libaf/af_comp.c | 2 | ||||
-rw-r--r-- | libaf/af_equalizer.c | 4 | ||||
-rw-r--r-- | libaf/af_export.c | 3 | ||||
-rw-r--r-- | libaf/af_extrastereo.c | 2 | ||||
-rw-r--r-- | libaf/af_format.c | 47 | ||||
-rw-r--r-- | libaf/af_format.h | 70 | ||||
-rw-r--r-- | libaf/af_gate.c | 2 | ||||
-rw-r--r-- | libaf/af_hrtf.c | 2 | ||||
-rw-r--r-- | libaf/af_lavcresample.c | 2 | ||||
-rw-r--r-- | libaf/af_mp.c | 98 | ||||
-rw-r--r-- | libaf/af_mp.h | 5 | ||||
-rw-r--r-- | libaf/af_pan.c | 2 | ||||
-rw-r--r-- | libaf/af_resample.c | 11 | ||||
-rw-r--r-- | libaf/af_sub.c | 2 | ||||
-rw-r--r-- | libaf/af_surround.c | 2 | ||||
-rw-r--r-- | libaf/af_sweep.c | 2 | ||||
-rw-r--r-- | libaf/af_volnorm.c | 10 | ||||
-rw-r--r-- | libaf/af_volume.c | 10 | ||||
-rw-r--r-- | libaf/config.h | 2 |
20 files changed, 126 insertions, 154 deletions
diff --git a/libaf/Makefile b/libaf/Makefile index 317547bf56..47780231a6 100644 --- a/libaf/Makefile +++ b/libaf/Makefile @@ -2,7 +2,7 @@ include config.mak LIBNAME = libaf.a -SRCS=af.c af_mp.c af_dummy.c af_delay.c af_channels.c af_format.c af_resample.c \ +SRCS=af.c af_dummy.c af_delay.c af_channels.c af_format.c af_resample.c \ window.c filter.c af_volume.c af_equalizer.c af_tools.c af_comp.c af_gate.c \ af_pan.c af_surround.c af_sub.c af_export.c af_volnorm.c af_extrastereo.c \ af_lavcresample.c af_sweep.c af_hrtf.c $(OPTIONAL_SRCS) diff --git a/libaf/af_comp.c b/libaf/af_comp.c index be03957bff..0ae83fe93b 100644 --- a/libaf/af_comp.c +++ b/libaf/af_comp.c @@ -44,7 +44,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; // Time constant set to 0.1s diff --git a/libaf/af_equalizer.c b/libaf/af_equalizer.c index 7613ba087a..0f9533d6d0 100644 --- a/libaf/af_equalizer.c +++ b/libaf/af_equalizer.c @@ -87,7 +87,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - af->data->format = AF_FORMAT_NE | AF_FORMAT_F; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; // Calculate number of active filters @@ -173,7 +173,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) float* end = in + c->len/4; // Block loop end while(in < end){ - register uint32_t k = 0; // Frequency band index + register int k = 0; // Frequency band index register float yt = *in; // Current input sample in+=nch; diff --git a/libaf/af_export.c b/libaf/af_export.c index f64299ba21..c685cb10b4 100644 --- a/libaf/af_export.c +++ b/libaf/af_export.c @@ -72,7 +72,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) // Accept only int16_t as input format (which sucks) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; // If buffer length isn't set, set it to the default value @@ -163,7 +163,6 @@ static int control(struct af_instance_s* af, int cmd, void* arg) */ static void uninit( struct af_instance_s* af ) { - int i; if (af->data){ free(af->data); af->data = NULL; diff --git a/libaf/af_extrastereo.c b/libaf/af_extrastereo.c index 36674e9ffa..f04ef080f7 100644 --- a/libaf/af_extrastereo.c +++ b/libaf/af_extrastereo.c @@ -37,7 +37,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = 2; - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; return af_test_output(af,(af_data_t*)arg); diff --git a/libaf/af_format.c b/libaf/af_format.c index 8ad80046f9..68c0a647f3 100644 --- a/libaf/af_format.c +++ b/libaf/af_format.c @@ -43,7 +43,7 @@ static void float2int(void* in, void* out, int len, int bps); static void int2float(void* in, void* out, int len, int bps); // Convert from string to format -static int str2fmt(char* str) +int af_str2fmt(char* str) { int format=0; // Scan for endianess @@ -87,16 +87,34 @@ static int str2fmt(char* str) return format; } +inline int af_fmt2bits(int format) +{ + return (format & AF_FORMAT_BITS_MASK)+8; +// return (((format & AF_FORMAT_BITS_MASK)>>3)+1) * 8; +#if 0 + switch(format & AF_FORMAT_BITS_MASK) + { + case AF_FORMAT_8BIT: return 8; + case AF_FORMAT_16BIT: return 16; + case AF_FORMAT_24BIT: return 24; + case AF_FORMAT_32BIT: return 32; + case AF_FORMAT_48BIT: return 48; + } +#endif + return -1; +} + /* Convert format to str input str is a buffer for the converted string, size is the size of the buffer */ -char* fmt2str(int format, char* str, size_t size) +char* af_fmt2str(int format, char* str, int size) { int i=0; - // Print endinaness + + // Endianess if(AF_FORMAT_LE == (format & AF_FORMAT_END_MASK)) - i+=snprintf(str,size,"little endian "); + i+=snprintf(str,size-i,"little endian "); else - i+=snprintf(str,size,"big endian "); + i+=snprintf(str,size-i,"big endian "); if(format & AF_FORMAT_SPECIAL_MASK){ switch(format & AF_FORMAT_SPECIAL_MASK){ @@ -108,12 +126,17 @@ char* fmt2str(int format, char* str, size_t size) i+=snprintf(&str[i],size-i,"MPEG 2 "); break; case(AF_FORMAT_AC3): i+=snprintf(&str[i],size-i,"AC3 "); break; + default: + printf("Unknown special\n"); } } else{ + // Bits + i+=snprintf(&str[i],size-i,"%d-bit ", af_fmt2bits(format)); + // Point if(AF_FORMAT_F == (format & AF_FORMAT_POINT_MASK)) - i+=snprintf(&str[i],size,"float "); + i+=snprintf(&str[i],size-i,"float "); else{ // Sign if(AF_FORMAT_US == (format & AF_FORMAT_SIGN_MASK)) @@ -121,7 +144,7 @@ char* fmt2str(int format, char* str, size_t size) else i+=snprintf(&str[i],size-i,"signed "); - i+=snprintf(&str[i],size,"int "); + i+=snprintf(&str[i],size-i,"int "); } } return str; @@ -148,7 +171,7 @@ static int check_format(int format) case(AF_FORMAT_MPEG2): case(AF_FORMAT_AC3): af_msg(AF_MSG_ERROR,"[format] Sample format %s not yet supported \n", - fmt2str(format,buf,255)); + af_fmt2str(format,buf,255)); return AF_ERROR; } return AF_OK; @@ -173,9 +196,9 @@ static int control(struct af_instance_s* af, int cmd, void* arg) (AF_OK != check_format(af->data->format))) return AF_ERROR; - af_msg(AF_MSG_VERBOSE,"[format] Changing sample format from %ibit %sto %ibit %s \n", - ((af_data_t*)arg)->bps*8,fmt2str(((af_data_t*)arg)->format,buf1,255), - af->data->bps*8,fmt2str(af->data->format,buf2,255)); + af_msg(AF_MSG_VERBOSE,"[format] Changing sample format from %sto %s \n", + af_fmt2str(((af_data_t*)arg)->format,buf1,255), + af_fmt2str(af->data->format,buf2,255)); af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; @@ -190,7 +213,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) str[0] = '\0'; sscanf((char*)arg,"%i:%s",&bps,str); // Convert string to format - format = str2fmt(str); + format = af_str2fmt(str); // Automatic correction of errors switch(format & AF_FORMAT_SPECIAL_MASK){ diff --git a/libaf/af_format.h b/libaf/af_format.h index f7b2a15b16..82eac84817 100644 --- a/libaf/af_format.h +++ b/libaf/af_format.h @@ -1,6 +1,8 @@ /* The sample format system used lin libaf is based on bitmasks. The format definition only refers to the storage format not the resolution. */ +#ifndef __af_format_h__ +#define __af_format_h__ // Endianess #define AF_FORMAT_BE (0<<0) // Big Endian @@ -14,8 +16,8 @@ #endif // Signed/unsigned -#define AF_FORMAT_SI (0<<1) // SIgned -#define AF_FORMAT_US (1<<1) // Un Signed +#define AF_FORMAT_SI (0<<1) // Signed +#define AF_FORMAT_US (1<<1) // Unsigned #define AF_FORMAT_SIGN_MASK (1<<1) // Fixed or floating point @@ -23,13 +25,63 @@ #define AF_FORMAT_F (1<<2) // Foating point #define AF_FORMAT_POINT_MASK (1<<2) +// Bits used +#define AF_FORMAT_8BIT (0<<3) +#define AF_FORMAT_16BIT (1<<3) +#define AF_FORMAT_24BIT (2<<3) +#define AF_FORMAT_32BIT (3<<3) +#define AF_FORMAT_40BIT (4<<3) +#define AF_FORMAT_48BIT (5<<3) +#define AF_FORMAT_BITS_MASK (7<<3) + // Special flags refering to non pcm data -#define AF_FORMAT_MU_LAW (1<<3) // -#define AF_FORMAT_A_LAW (2<<3) // -#define AF_FORMAT_MPEG2 (3<<3) // MPEG(2) audio -#define AF_FORMAT_AC3 (4<<3) // Dolby Digital AC3 -#define AF_FORMAT_IMA_ADPCM AF_FORMAT_LE|AF_FORMAT_SI // Same as 16 bit signed int -#define AF_FORMAT_SPECIAL_MASK (7<<3) +#define AF_FORMAT_MU_LAW (1<<6) +#define AF_FORMAT_A_LAW (2<<6) +#define AF_FORMAT_MPEG2 (3<<6) // MPEG(2) audio +#define AF_FORMAT_AC3 (4<<6) // Dolby Digital AC3 +#define AF_FORMAT_IMA_ADPCM (5<<6) +#define AF_FORMAT_SPECIAL_MASK (7<<6) + +// PREDEFINED formats + +#define AF_FORMAT_U8 (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_8BIT|AF_FORMAT_NE) +#define AF_FORMAT_S8 (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_8BIT|AF_FORMAT_NE) +#define AF_FORMAT_U16_LE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_16BIT|AF_FORMAT_LE) +#define AF_FORMAT_U16_BE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_16BIT|AF_FORMAT_BE) +#define AF_FORMAT_S16_LE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_16BIT|AF_FORMAT_LE) +#define AF_FORMAT_S16_BE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_16BIT|AF_FORMAT_BE) +#define AF_FORMAT_U24_LE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_24BIT|AF_FORMAT_LE) +#define AF_FORMAT_U24_BE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_24BIT|AF_FORMAT_BE) +#define AF_FORMAT_S24_LE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_24BIT|AF_FORMAT_LE) +#define AF_FORMAT_S24_BE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_24BIT|AF_FORMAT_BE) +#define AF_FORMAT_U32_LE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_32BIT|AF_FORMAT_LE) +#define AF_FORMAT_U32_BE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_32BIT|AF_FORMAT_BE) +#define AF_FORMAT_S32_LE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_32BIT|AF_FORMAT_LE) +#define AF_FORMAT_S32_BE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_32BIT|AF_FORMAT_BE) + +#define AF_FORMAT_FLOAT_LE (AF_FORMAT_F|AF_FORMAT_32BIT|AF_FORMAT_LE) +#define AF_FORMAT_FLOAT_BE (AF_FORMAT_F|AF_FORMAT_32BIT|AF_FORMAT_BE) + +#ifdef WORDS_BIGENDIAN +#define AF_FORMAT_U16_NE AF_FORMAT_U16_BE +#define AF_FORMAT_S16_NE AF_FORMAT_S16_BE +#define AF_FORMAT_U24_NE AF_FORMAT_U24_BE +#define AF_FORMAT_S24_NE AF_FORMAT_S24_BE +#define AF_FORMAT_U32_NE AF_FORMAT_U32_BE +#define AF_FORMAT_S32_NE AF_FORMAT_S32_BE +#define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT_BE +#else +#define AF_FORMAT_U16_NE AF_FORMAT_U16_LE +#define AF_FORMAT_S16_NE AF_FORMAT_S16_LE +#define AF_FORMAT_U24_NE AF_FORMAT_U24_LE +#define AF_FORMAT_S24_NE AF_FORMAT_S24_LE +#define AF_FORMAT_U32_NE AF_FORMAT_U32_LE +#define AF_FORMAT_S32_NE AF_FORMAT_S32_LE +#define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT_LE +#endif -extern char* fmt2str(int format, char* str, size_t size); +extern int af_str2fmt(char *str); +extern int af_fmt2bits(int format); +extern char* af_fmt2str(int format, char* str, int size); +#endif /* __af_format_h__ */ diff --git a/libaf/af_gate.c b/libaf/af_gate.c index 55acc2970a..f0e7a3df9f 100644 --- a/libaf/af_gate.c +++ b/libaf/af_gate.c @@ -42,7 +42,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; // Time constant set to 0.1s diff --git a/libaf/af_hrtf.c b/libaf/af_hrtf.c index 8f302e8448..d516494943 100644 --- a/libaf/af_hrtf.c +++ b/libaf/af_hrtf.c @@ -119,7 +119,7 @@ static int control(struct af_instance_s *af, int cmd, void* arg) if(af->data->nch < 5) { af->data->nch = 5; } - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; return af_test_output(af, (af_data_t*)arg); case AF_CONTROL_COMMAND_LINE: diff --git a/libaf/af_lavcresample.c b/libaf/af_lavcresample.c index c37807865b..20d9ffc878 100644 --- a/libaf/af_lavcresample.c +++ b/libaf/af_lavcresample.c @@ -52,7 +52,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->nch = data->nch; if (af->data->nch > CHANS) af->data->nch = CHANS; - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; g= ff_gcd(af->data->rate, data->rate); af->mul.n = af->data->rate/g; diff --git a/libaf/af_mp.c b/libaf/af_mp.c deleted file mode 100644 index 50bbc90e2e..0000000000 --- a/libaf/af_mp.c +++ /dev/null @@ -1,98 +0,0 @@ -#include "af.h" - -/* Decodes the format from mplayer format to libaf format */ -int af_format_decode(int ifmt) -{ - int ofmt = ~0; - // Check input ifmt - switch(ifmt){ - case(AFMT_U8): - ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; - case(AFMT_S8): - ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; - case(AFMT_S16_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; - case(AFMT_S16_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_SI; break; - case(AFMT_U16_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; - case(AFMT_U16_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_US; break; - case(AFMT_S24_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; - case(AFMT_S24_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_SI; break; - case(AFMT_U24_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; - case(AFMT_U24_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_US; break; - case(AFMT_S32_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; - case(AFMT_S32_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_SI; break; - case(AFMT_U32_LE): - ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; - case(AFMT_U32_BE): - ofmt = AF_FORMAT_BE|AF_FORMAT_US; break; - case(AFMT_IMA_ADPCM): - ofmt = AF_FORMAT_IMA_ADPCM; break; - case(AFMT_MU_LAW): - ofmt = AF_FORMAT_MU_LAW; break; - case(AFMT_A_LAW): - ofmt = AF_FORMAT_A_LAW; break; - case(AFMT_MPEG): - ofmt = AF_FORMAT_MPEG2; break; - case(AFMT_AC3): - ofmt = AF_FORMAT_AC3; break; - case(AFMT_FLOAT): - ofmt = AF_FORMAT_F | AF_FORMAT_NE; break; - default: - if ((ifmt & AFMT_AF_FLAGS) == AFMT_AF_FLAGS) { - ofmt = ifmt & ~AFMT_AF_FLAGS; - break; - } - //This can not happen .... - af_msg(AF_MSG_FATAL,"Unrecognized input audio format %i\n",ifmt); - break; - } - return ofmt; -} - -/* Encodes the format from libaf format to mplayer (OSS) format */ -int af_format_encode(void* fmtp) -{ - af_data_t* fmt=(af_data_t*) fmtp; - switch(fmt->format&AF_FORMAT_SPECIAL_MASK){ - case 0: // PCM: - if((fmt->format&AF_FORMAT_POINT_MASK)==AF_FORMAT_I){ - if((fmt->format&AF_FORMAT_SIGN_MASK)==AF_FORMAT_SI){ - // signed int PCM: - switch(fmt->bps){ - case 1: return AFMT_S8; - case 2: return (fmt->format&AF_FORMAT_LE) ? AFMT_S16_LE : AFMT_S16_BE; - case 3: return (fmt->format&AF_FORMAT_LE) ? AFMT_S24_LE : AFMT_S24_BE; - case 4: return (fmt->format&AF_FORMAT_LE) ? AFMT_S32_LE : AFMT_S32_BE; - } - } else { - // unsigned int PCM: - switch(fmt->bps){ - case 1: return AFMT_U8; - case 2: return (fmt->format&AF_FORMAT_LE) ? AFMT_U16_LE : AFMT_U16_BE; - case 3: return (fmt->format&AF_FORMAT_LE) ? AFMT_U24_LE : AFMT_U24_BE; - case 4: return (fmt->format&AF_FORMAT_LE) ? AFMT_U32_LE : AFMT_U32_BE; - } - } - } else { - // float PCM: - return AFMT_FLOAT; // FIXME? - } - break; - case AF_FORMAT_MU_LAW: return AFMT_MU_LAW; - case AF_FORMAT_A_LAW: return AFMT_A_LAW; - case AF_FORMAT_MPEG2: return AFMT_MPEG; - case AF_FORMAT_AC3: return AFMT_AC3; - case AF_FORMAT_IMA_ADPCM: return AFMT_IMA_ADPCM; - } - return (fmt->format | AFMT_AF_FLAGS); -} - diff --git a/libaf/af_mp.h b/libaf/af_mp.h index 7d3918a55a..cd6ec92806 100644 --- a/libaf/af_mp.h +++ b/libaf/af_mp.h @@ -5,7 +5,6 @@ #include "../config.h" #include "../mp_msg.h" #include "../cpudetect.h" -#include "../libao2/afmt.h" /* Set the initialization type from mplayers cpudetect */ #ifdef AF_INIT_TYPE @@ -20,8 +19,4 @@ #define af_msg(lev, args... ) \ mp_msg(MSGT_AFILTER,(((lev)<0)?((lev)+3):(((lev)==0)?MSGL_INFO:((lev)+5))), ##args ) -/* Decodes the format from mplayer format to libaf format */ -extern int af_format_decode(int format); -extern int af_format_encode(void* fmt); - #endif /* __af_mp_h__ */ diff --git a/libaf/af_pan.c b/libaf/af_pan.c index 78ffd36a28..268ffd6e4b 100644 --- a/libaf/af_pan.c +++ b/libaf/af_pan.c @@ -37,7 +37,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) if(!arg) return AF_ERROR; af->data->rate = ((af_data_t*)arg)->rate; - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; af->mul.n = af->data->nch; af->mul.d = ((af_data_t*)arg)->nch; diff --git a/libaf/af_resample.c b/libaf/af_resample.c index 0cd5402620..00d06fa8ec 100644 --- a/libaf/af_resample.c +++ b/libaf/af_resample.c @@ -135,29 +135,28 @@ static int set_types(struct af_instance_s* af, af_data_t* data) // Make sure this filter isn't redundant if((af->data->rate == data->rate) || (af->data->rate == 0)) return AF_DETACH; - /* If sloppy and small resampling difference (2%) */ rd = abs((float)af->data->rate - (float)data->rate)/(float)data->rate; if((((s->setup & FREQ_MASK) == FREQ_SLOPPY) && (rd < 0.02) && - (data->format != (AF_FORMAT_NE | AF_FORMAT_F))) || + (data->format != (AF_FORMAT_FLOAT_NE))) || ((s->setup & RSMP_MASK) == RSMP_LIN)){ s->setup = (s->setup & ~RSMP_MASK) | RSMP_LIN; - af->data->format = AF_FORMAT_NE | AF_FORMAT_SI; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; af_msg(AF_MSG_VERBOSE,"[resample] Using linear interpolation. \n"); } else{ /* If the input format is float or if float is explicitly selected use float, otherwise use int */ - if((data->format == (AF_FORMAT_NE | AF_FORMAT_F)) || + if((data->format == (AF_FORMAT_FLOAT_NE)) || ((s->setup & RSMP_MASK) == RSMP_FLOAT)){ s->setup = (s->setup & ~RSMP_MASK) | RSMP_FLOAT; - af->data->format = AF_FORMAT_NE | AF_FORMAT_F; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; } else{ s->setup = (s->setup & ~RSMP_MASK) | RSMP_INT; - af->data->format = AF_FORMAT_NE | AF_FORMAT_SI; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; } af_msg(AF_MSG_VERBOSE,"[resample] Using %s processing and %s frequecy" diff --git a/libaf/af_sub.c b/libaf/af_sub.c index 4845018d1a..e57c99dca1 100644 --- a/libaf/af_sub.c +++ b/libaf/af_sub.c @@ -61,7 +61,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = max(s->ch+1,((af_data_t*)arg)->nch); - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; // Design low-pass filter diff --git a/libaf/af_surround.c b/libaf/af_surround.c index 590eaf74eb..e00c23f727 100644 --- a/libaf/af_surround.c +++ b/libaf/af_surround.c @@ -93,7 +93,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) float fc; af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch*2; - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; if (af->data->nch != 4){ diff --git a/libaf/af_sweep.c b/libaf/af_sweep.c index 8ed84266e1..619ebf7868 100644 --- a/libaf/af_sweep.c +++ b/libaf/af_sweep.c @@ -25,7 +25,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) switch(cmd){ case AF_CONTROL_REINIT: af->data->nch = data->nch; - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; af->data->rate = data->rate; diff --git a/libaf/af_volnorm.c b/libaf/af_volnorm.c index c1fed6a9d3..60485118b0 100644 --- a/libaf/af_volnorm.c +++ b/libaf/af_volnorm.c @@ -79,11 +79,11 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - if(((af_data_t*)arg)->format == (AF_FORMAT_SI | AF_FORMAT_NE)){ - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + if(((af_data_t*)arg)->format == (AF_FORMAT_S16_NE)){ + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; }else{ - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; } return af_test_output(af,(af_data_t*)arg); @@ -288,14 +288,14 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) { af_volnorm_t *s = af->setup; - if(af->data->format == (AF_FORMAT_SI | AF_FORMAT_NE)) + if(af->data->format == (AF_FORMAT_S16_NE)) { if (s->method) method2_int16(s, data); else method1_int16(s, data); } - else if(af->data->format == (AF_FORMAT_F | AF_FORMAT_NE)) + else if(af->data->format == (AF_FORMAT_FLOAT_NE)) { if (s->method) method2_float(s, data); diff --git a/libaf/af_volume.c b/libaf/af_volume.c index 6c3d73be65..e6221fe51a 100644 --- a/libaf/af_volume.c +++ b/libaf/af_volume.c @@ -60,8 +60,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->rate = ((af_data_t*)arg)->rate; af->data->nch = ((af_data_t*)arg)->nch; - if(s->fast && (((af_data_t*)arg)->format != (AF_FORMAT_F | AF_FORMAT_NE))){ - af->data->format = AF_FORMAT_SI | AF_FORMAT_NE; + if(s->fast && (((af_data_t*)arg)->format != (AF_FORMAT_FLOAT_NE))){ + af->data->format = AF_FORMAT_S16_NE; af->data->bps = 2; } else{ @@ -70,7 +70,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) float t = 2.0-cos(x); s->time = 1.0 - (t - sqrt(t*t - 1)); af_msg(AF_MSG_DEBUG0,"[volume] Forgetting factor = %0.5f\n",s->time); - af->data->format = AF_FORMAT_F | AF_FORMAT_NE; + af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; } return af_test_output(af,(af_data_t*)arg); @@ -140,7 +140,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) register int i = 0; // Basic operation volume control only (used on slow machines) - if(af->data->format == (AF_FORMAT_SI | AF_FORMAT_NE)){ + if(af->data->format == (AF_FORMAT_S16_NE)){ int16_t* a = (int16_t*)c->audio; // Audio data int len = c->len/2; // Number of samples for(ch = 0; ch < nch ; ch++){ @@ -154,7 +154,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) } } // Machine is fast and data is floating point - else if(af->data->format == (AF_FORMAT_F | AF_FORMAT_NE)){ + else if(af->data->format == (AF_FORMAT_FLOAT_NE)){ float* a = (float*)c->audio; // Audio data int len = c->len/4; // Number of samples for(ch = 0; ch < nch ; ch++){ diff --git a/libaf/config.h b/libaf/config.h index 676979ef6b..22a20ae4fa 100644 --- a/libaf/config.h +++ b/libaf/config.h @@ -8,6 +8,8 @@ //============================================================================= */ +#include "../config.h" // WORDS_BIGENDIAN + // Number of channels #ifndef AF_NCH #define AF_NCH 6 |