Skip to content

Commit

Permalink
removing AFMT_ dependancy
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14246 b3059339-0415-0410-9bf9-f77b7e298cf2
  • Loading branch information
alex committed Dec 27, 2004
1 parent 00f99a8 commit 507121f
Show file tree
Hide file tree
Showing 65 changed files with 483 additions and 585 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done
endif

SRCS_COMMON = cpudetect.c codec-cfg.c spudec.c playtree.c playtreeparser.c asxparser.c vobsub.c subreader.c sub_cc.c find_sub.c m_config.c m_option.c parser-cfg.c m_struct.c edl.c
SRCS_MENCODER = mencoder.c mp_msg-mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/osd.c libvo/sub.c libvo/font_load.c libvo/font_load_ft.c xvid_vbr.c parser-mecmd.c
SRCS_MENCODER = mencoder.c mp_msg-mencoder.c $(SRCS_COMMON) divx4_vbr.c libvo/aclib.c libvo/osd.c libvo/sub.c libvo/font_load.c libvo/font_load_ft.c xvid_vbr.c parser-mecmd.c
SRCS_MPLAYER = mplayer.c mp_msg.c $(SRCS_COMMON) mixer.c parser-mpcmd.c

ifeq ($(UNRARLIB),yes)
Expand Down
2 changes: 1 addition & 1 deletion libaf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion libaf/af_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libaf/af_equalizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions libaf/af_export.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libaf/af_extrastereo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
47 changes: 35 additions & 12 deletions libaf/af_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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){
Expand All @@ -108,20 +126,25 @@ 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))
i+=snprintf(&str[i],size-i,"unsigned ");
else
i+=snprintf(&str[i],size-i,"signed ");

i+=snprintf(&str[i],size,"int ");
i+=snprintf(&str[i],size-i,"int ");
}
}
return str;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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){
Expand Down
70 changes: 61 additions & 9 deletions libaf/af_format.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,22 +16,72 @@
#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
#define AF_FORMAT_I (0<<2) // Int
#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__ */
2 changes: 1 addition & 1 deletion libaf/af_gate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libaf/af_hrtf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion libaf/af_lavcresample.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
98 changes: 0 additions & 98 deletions libaf/af_mp.c

This file was deleted.

Loading

0 comments on commit 507121f

Please sign in to comment.