changeset 14245:815f03b7cee5

removing AFMT_ dependancy
author alex
date Mon, 27 Dec 2004 17:30:15 +0000
parents 9b03ad0254ae
children 474a40917f73
files Makefile libaf/Makefile libaf/af_comp.c libaf/af_equalizer.c libaf/af_export.c libaf/af_extrastereo.c libaf/af_format.c libaf/af_format.h libaf/af_gate.c libaf/af_hrtf.c libaf/af_lavcresample.c libaf/af_mp.c libaf/af_mp.h libaf/af_pan.c libaf/af_resample.c libaf/af_sub.c libaf/af_surround.c libaf/af_sweep.c libaf/af_volnorm.c libaf/af_volume.c libaf/config.h libao2/Makefile libao2/afmt.c libao2/afmt.h libao2/ao_alsa.c libao2/ao_alsa5.c libao2/ao_arts.c libao2/ao_dsound.c libao2/ao_dxr2.c libao2/ao_esd.c libao2/ao_jack.c libao2/ao_macosx.c libao2/ao_mpegpes.c libao2/ao_nas.c libao2/ao_null.c libao2/ao_oss.c libao2/ao_pcm.c libao2/ao_plugin.c libao2/ao_polyp.c libao2/ao_sdl.c libao2/ao_win32.c libao2/audio_out.c libao2/audio_plugin.h libao2/pl_delay.c libao2/pl_eq.c libao2/pl_extrastereo.c libao2/pl_format.c libao2/pl_resample.c libao2/pl_surround.c libao2/pl_volnorm.c libao2/pl_volume.c libmpcodecs/ad_dvdpcm.c libmpcodecs/ad_hwac3.c libmpcodecs/ad_internal.h libmpcodecs/ad_pcm.c libmpcodecs/ad_ra1428.c libmpcodecs/ad_sample.c libmpcodecs/dec_audio.c libmpdemux/demuxer.c libmpdemux/tv.c libmpdemux/tvi_bsdbt848.c libmpdemux/tvi_v4l.c libmpdemux/tvi_v4l2.c mencoder.c mplayer.c
diffstat 65 files changed, 483 insertions(+), 585 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Mon Dec 27 11:09:49 2004 +0000
+++ b/Makefile	Mon Dec 27 17:30:15 2004 +0000
@@ -20,7 +20,7 @@
 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)
--- a/libaf/Makefile	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/Makefile	Mon Dec 27 17:30:15 2004 +0000
@@ -2,7 +2,7 @@
 
 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)
--- a/libaf/af_comp.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_comp.c	Mon Dec 27 17:30:15 2004 +0000
@@ -44,7 +44,7 @@
     
     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
--- a/libaf/af_equalizer.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_equalizer.c	Mon Dec 27 17:30:15 2004 +0000
@@ -87,7 +87,7 @@
     
     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 @@
     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;
       
--- a/libaf/af_export.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_export.c	Mon Dec 27 17:30:15 2004 +0000
@@ -72,7 +72,7 @@
     // 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 void uninit( struct af_instance_s* af )
 {
-  int i;
   if (af->data){
     free(af->data);
     af->data = NULL;
--- a/libaf/af_extrastereo.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_extrastereo.c	Mon Dec 27 17:30:15 2004 +0000
@@ -37,7 +37,7 @@
     
     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);
--- a/libaf/af_format.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_format.c	Mon Dec 27 17:30:15 2004 +0000
@@ -43,7 +43,7 @@
 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 @@
   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 @@
       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 @@
       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 @@
   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 @@
        (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 @@
     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){
--- a/libaf/af_format.h	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_format.h	Mon Dec 27 17:30:15 2004 +0000
@@ -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)
 
-extern char* fmt2str(int format, char* str, size_t size);
+#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 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__ */
--- a/libaf/af_gate.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_gate.c	Mon Dec 27 17:30:15 2004 +0000
@@ -42,7 +42,7 @@
     
     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
--- a/libaf/af_hrtf.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_hrtf.c	Mon Dec 27 17:30:15 2004 +0000
@@ -119,7 +119,7 @@
 	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:
--- a/libaf/af_lavcresample.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_lavcresample.c	Mon Dec 27 17:30:15 2004 +0000
@@ -52,7 +52,7 @@
 
     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;
--- a/libaf/af_mp.c	Mon Dec 27 11:09:49 2004 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-}
-
--- a/libaf/af_mp.h	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_mp.h	Mon Dec 27 17:30:15 2004 +0000
@@ -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__ */
--- a/libaf/af_pan.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_pan.c	Mon Dec 27 17:30:15 2004 +0000
@@ -37,7 +37,7 @@
     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;
--- a/libaf/af_resample.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_resample.c	Mon Dec 27 17:30:15 2004 +0000
@@ -135,29 +135,28 @@
   // 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"
--- a/libaf/af_sub.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_sub.c	Mon Dec 27 17:30:15 2004 +0000
@@ -61,7 +61,7 @@
 
     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
--- a/libaf/af_surround.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_surround.c	Mon Dec 27 17:30:15 2004 +0000
@@ -93,7 +93,7 @@
     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){
--- a/libaf/af_sweep.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_sweep.c	Mon Dec 27 17:30:15 2004 +0000
@@ -25,7 +25,7 @@
   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;
 
--- a/libaf/af_volnorm.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_volnorm.c	Mon Dec 27 17:30:15 2004 +0000
@@ -79,11 +79,11 @@
     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 @@
 {
   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);
--- a/libaf/af_volume.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/af_volume.c	Mon Dec 27 17:30:15 2004 +0000
@@ -60,8 +60,8 @@
     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 @@
       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 @@
   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 @@
     }
   }
   // 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++){
--- a/libaf/config.h	Mon Dec 27 11:09:49 2004 +0000
+++ b/libaf/config.h	Mon Dec 27 17:30:15 2004 +0000
@@ -8,6 +8,8 @@
 //=============================================================================
 */
 
+#include "../config.h" // WORDS_BIGENDIAN
+
 // Number of channels
 #ifndef AF_NCH
 #define AF_NCH 6
--- a/libao2/Makefile	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/Makefile	Mon Dec 27 17:30:15 2004 +0000
@@ -2,7 +2,7 @@
 
 LIBNAME = libao2.a
 
-SRCS=afmt.c audio_out.c ao_mpegpes.c ao_null.c ao_pcm.c ao_plugin.c pl_delay.c pl_format.c pl_surround.c remez.c pl_resample.c pl_volume.c pl_extrastereo.c pl_volnorm.c pl_eq.c $(OPTIONAL_SRCS)
+SRCS=audio_out.c ao_mpegpes.c ao_null.c ao_pcm.c ao_plugin.c pl_delay.c pl_format.c pl_surround.c remez.c pl_resample.c pl_volume.c pl_extrastereo.c pl_volnorm.c pl_eq.c $(OPTIONAL_SRCS)
 
 OBJS=$(SRCS:.c=.o)
 
--- a/libao2/afmt.c	Mon Dec 27 11:09:49 2004 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "config.h"
-#include "afmt.h"
-
-char *audio_out_format_name(int format)
-{
-    switch (format)
-    {
-	case AFMT_MU_LAW:
-	    return("Mu-Law");
-	case AFMT_A_LAW:
-	    return("A-Law");
-	case AFMT_IMA_ADPCM:
-	    return("Ima-ADPCM");
-	case AFMT_S8:
-	    return("Signed 8-bit");
-	case AFMT_U8:
-	    return("Unsigned 8-bit");
-	case AFMT_U16_LE:
-	    return("Unsigned 16-bit (Little-Endian)");
-	case AFMT_U16_BE: 
-	    return("Unsigned 16-bit (Big-Endian)");
-	case AFMT_S16_LE:
-	    return("Signed 16-bit (Little-Endian)");
-	case AFMT_S16_BE:
-	    return("Signed 16-bit (Big-Endian)");
-	case AFMT_MPEG:
-	    return("MPEG (2) audio");
-	case AFMT_AC3:
-	    return("AC3");
-	case AFMT_U32_LE:
-	    return("Unsigned 32-bit (Little-Endian)");
-	case AFMT_U32_BE:
-	    return("Unsigned 32-bit (Big-Endian)");
-	case AFMT_S32_LE:
-	    return("Signed 32-bit (Little-Endian)");
-	case AFMT_S32_BE:
-	    return("Signed 32-bit (Big-Endian)");
-	case AFMT_U24_LE:
-	    return("Unsigned 24-bit (Little-Endian)");
-	case AFMT_U24_BE:
-	    return("Unsigned 24-bit (Big-Endian)");
-	case AFMT_S24_LE:
-	    return("Signed 24-bit (Little-Endian)");
-	case AFMT_S24_BE:
-	    return("Signed 24-bit (Big-Endian)");
-	case AFMT_FLOAT:
-	    return("Floating Point");
-    }
-    return("Unknown");
-}
-
-// return number of bits for 1 sample in one channel, or 8 bits for compressed
-int audio_out_format_bits(int format){
-    switch (format)
-    {
-	case AFMT_S16_LE:
-	case AFMT_S16_BE:
-	case AFMT_U16_LE:
-	case AFMT_U16_BE: 
-	return 16;//16 bits
-
-	case AFMT_S32_LE:
-	case AFMT_S32_BE:
-	case AFMT_U32_LE:
-	case AFMT_U32_BE:
-	case AFMT_FLOAT:
-	return 32;
-
-	case AFMT_S24_LE:
-	case AFMT_S24_BE:
-	case AFMT_U24_LE:
-	case AFMT_U24_BE:
-	return 24;
-	
-	case AFMT_MU_LAW:
-	case AFMT_A_LAW:
-	case AFMT_IMA_ADPCM:
-	case AFMT_S8:
-	case AFMT_U8:
-	case AFMT_MPEG:
-	case AFMT_AC3:
-	default:
-	    return 8;//default 1 byte
-	
-    }
-    return 8;
-}
--- a/libao2/afmt.h	Mon Dec 27 11:09:49 2004 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-
-/* Defines that AFMT_ stuff */
-
-#ifdef	HAVE_SYS_SOUNDCARD_H
-#include <sys/soundcard.h>	/* For AFMT_* on linux */
-#else 
-#ifdef HAVE_SOUNDCARD_H
-#include <soundcard.h> /* OpenBSD have this instead of <sys/soundcard> */
-#endif
-#endif
-
-#include "config.h" /* for native endianness */
-
-/* standard, old OSS audio formats */
-#ifndef AFMT_MU_LAW
-#	define AFMT_MU_LAW		0x00000001
-#	define AFMT_A_LAW		0x00000002
-#	define AFMT_IMA_ADPCM		0x00000004
-#	define AFMT_U8			0x00000008
-#	define AFMT_S16_LE		0x00000010	/* Little endian signed 16*/
-#	define AFMT_S16_BE		0x00000020	/* Big endian signed 16 */
-#	define AFMT_S8			0x00000040
-#	define AFMT_U16_LE		0x00000080	/* Little endian U16 */
-#	define AFMT_U16_BE		0x00000100	/* Big endian U16 */
-#endif
-
-#ifndef AFMT_MPEG
-#	define AFMT_MPEG		0x00000200	/* MPEG (2) audio */
-#endif
-
-#ifndef AFMT_AC3
-#	define AFMT_AC3			0x00000400	/* Dolby Digital AC3 */
-#endif
-
-/* 24 bit formats from the linux kernel */
-#ifndef AFMT_S24_LE
-
-// FreeBSD fix...
-#if AFMT_S32_LE == 0x1000
-
-#define AFMT_S24_LE		0x00010000
-#define AFMT_S24_BE		0x00020000
-#define AFMT_U24_LE		0x00040000
-#define AFMT_U24_BE		0x00080000
-
-#else
-
-#define AFMT_S24_LE		0x00000800
-#define AFMT_S24_BE		0x00001000
-#define AFMT_U24_LE		0x00002000
-#define AFMT_U24_BE		0x00004000
-
-#endif
-
-#endif
-
-/* 32 bit formats from the linux kernel */
-#ifndef AFMT_S32_LE
-#define AFMT_S32_LE		0x00008000
-#define AFMT_S32_BE		0x00010000
-#define AFMT_U32_LE		0x00020000
-#define AFMT_U32_BE		0x00040000
-#endif
-
-/* native endian formats */
-#ifndef	AFMT_S16_NE
-# if WORDS_BIGENDIAN
-#  define AFMT_S16_NE	AFMT_S16_BE
-#  define AFMT_S24_NE	AFMT_S24_BE
-#  define AFMT_S32_NE	AFMT_S32_BE
-# else
-#  define AFMT_S16_NE	AFMT_S16_LE
-#  define AFMT_S24_NE	AFMT_S24_LE
-#  define AFMT_S32_NE	AFMT_S32_LE
-# endif
-#endif
-
-#ifndef AFMT_FLOAT
-# define AFMT_FLOAT               0x00100000
-#endif
-
-/* for formats that don't have a corresponding AFMT_* type,
- * use the flags from libaf/af_format.h or'ed with this */
-#define AFMT_AF_FLAGS             0x70000000
--- a/libao2/ao_alsa.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_alsa.c	Mon Dec 27 17:30:15 2004 +0000
@@ -37,7 +37,7 @@
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 static ao_info_t info = 
 {
@@ -125,7 +125,7 @@
       }
       if(mixer_device) card = mixer_device;
 
-      if(ao_data.format == AFMT_AC3)
+      if(ao_data.format == AF_FORMAT_AC3)
 	return CONTROL_TRUE;
 
       //allocate simple id
@@ -275,42 +275,42 @@
 
     switch (format)
       {
-      case AFMT_S8:
+      case AF_FORMAT_S8:
 	alsa_format = SND_PCM_FORMAT_S8;
 	break;
-      case AFMT_U8:
+      case AF_FORMAT_U8:
 	alsa_format = SND_PCM_FORMAT_U8;
 	break;
-      case AFMT_U16_LE:
+      case AF_FORMAT_U16_LE:
 	alsa_format = SND_PCM_FORMAT_U16_LE;
 	break;
-      case AFMT_U16_BE:
+      case AF_FORMAT_U16_BE:
 	alsa_format = SND_PCM_FORMAT_U16_BE;
 	break;
 #ifndef WORDS_BIGENDIAN
-      case AFMT_AC3:
+      case AF_FORMAT_AC3:
 #endif
-      case AFMT_S16_LE:
+      case AF_FORMAT_S16_LE:
 	alsa_format = SND_PCM_FORMAT_S16_LE;
 	break;
 #ifdef WORDS_BIGENDIAN
-      case AFMT_AC3:
+      case AF_FORMAT_AC3:
 #endif
-      case AFMT_S16_BE:
+      case AF_FORMAT_S16_BE:
 	alsa_format = SND_PCM_FORMAT_S16_BE;
 	break;
-      case AFMT_S32_LE:
+      case AF_FORMAT_S32_LE:
 	alsa_format = SND_PCM_FORMAT_S32_LE;
 	break;
-      case AFMT_S32_BE:
+      case AF_FORMAT_S32_BE:
 	alsa_format = SND_PCM_FORMAT_S32_BE;
 	break;
-      case AFMT_FLOAT:
+      case AF_FORMAT_FLOAT_LE:
 	alsa_format = SND_PCM_FORMAT_FLOAT_LE;
 	break;
 
       default:
-	alsa_format = SND_PCM_FORMAT_MPEG; //? default should be -1
+	alsa_format = SND_PCM_FORMAT_MPEG2; //? default should be -1
 	break;
       }
     
@@ -412,7 +412,7 @@
      * while opening the abstract alias for the spdif subdevice
      * 'iec958'
      */
-    if (format == AFMT_AC3) {
+    if (format == AF_FORMAT_AC3) {
       unsigned char s[4];
 
       switch (channels) {
@@ -590,7 +590,7 @@
 		"alsa-init: format %s are not supported by hardware, trying default\n", 
 		audio_out_format_name(format));
          alsa_format = SND_PCM_FORMAT_S16_LE;
-         ao_data.format = AFMT_S16_LE;
+         ao_data.format = AF_FORMAT_S16_LE;
          ao_data.bps = channels * rate_hz * 2;
       }
 
--- a/libao2/ao_alsa5.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_alsa5.c	Mon Dec 27 17:30:15 2004 +0000
@@ -13,7 +13,7 @@
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 #include "mp_msg.h"
 #include "help_mp.h"
@@ -75,28 +75,28 @@
     memset(&alsa_format, 0, sizeof(alsa_format));
     switch (format)
     {
-	case AFMT_S8:
+	case AF_FORMAT_S8:
 	    alsa_format.format = SND_PCM_SFMT_S8;
 	    break;
-	case AFMT_U8:
+	case AF_FORMAT_U8:
 	    alsa_format.format = SND_PCM_SFMT_U8;
 	    break;
-	case AFMT_U16_LE:
+	case AF_FORMAT_U16_LE:
 	    alsa_format.format = SND_PCM_SFMT_U16_LE;
 	    break;
-	case AFMT_U16_BE:
+	case AF_FORMAT_U16_BE:
 	    alsa_format.format = SND_PCM_SFMT_U16_BE;
 	    break;
 #ifndef WORDS_BIGENDIAN
-	case AFMT_AC3:
+	case AF_FORMAT_AC3:
 #endif
-	case AFMT_S16_LE:
+	case AF_FORMAT_S16_LE:
 	    alsa_format.format = SND_PCM_SFMT_S16_LE;
 	    break;
 #ifdef WORDS_BIGENDIAN
-	case AFMT_AC3:
+	case AF_FORMAT_AC3:
 #endif
-	case AFMT_S16_BE:
+	case AF_FORMAT_S16_BE:
 	    alsa_format.format = SND_PCM_SFMT_S16_BE;
 	    break;
 	default:
--- a/libao2/ao_arts.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_arts.c	Mon Dec 27 17:30:15 2004 +0000
@@ -12,12 +12,12 @@
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include "config.h"
 #include "mp_msg.h"
 #include "help_mp.h"
 
-#define OBTAIN_BITRATE(a) (((a != AFMT_U8) && (a != AFMT_S8)) ? 16 : 8)
+#define OBTAIN_BITRATE(a) (((a != AF_FORMAT_U8) && (a != AF_FORMAT_S8)) ? 16 : 8)
 
 /* Feel free to experiment with the following values: */
 #define ARTS_PACKETS 10 /* Number of audio packets */
@@ -60,12 +60,12 @@
 	 * using mplayer's audio filters.
 	 */
 	switch (format) {
-	case AFMT_U8:
-	case AFMT_S8:
-	    format = AFMT_U8;
+	case AF_FORMAT_U8:
+	case AF_FORMAT_S8:
+	    format = AF_FORMAT_U8;
 	    break;
 	default:
-	    format = AFMT_S16_LE;    /* artsd always expects little endian?*/
+	    format = AF_FORMAT_S16_LE;    /* artsd always expects little endian?*/
 	    break;
 	}
 
@@ -74,7 +74,7 @@
 	ao_data.samplerate = rate_hz;
 	ao_data.bps = (rate_hz*channels);
 
-	if(format != AFMT_U8 && format != AFMT_S8)
+	if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8)
 		ao_data.bps*=2;
 
 	stream=arts_play_stream(rate_hz, OBTAIN_BITRATE(format), channels, "MPlayer");
--- a/libao2/ao_dsound.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_dsound.c	Mon Dec 27 17:30:15 2004 +0000
@@ -28,7 +28,7 @@
 #define DIRECTSOUND_VERSION 0x0600
 #include <dsound.h>
 
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include "audio_out.h"
 #include "audio_out_internal.h"
 #include "mp_msg.h"
@@ -265,7 +265,7 @@
   
   if (SUCCEEDED(res)) 
   {
-  	if( (ao_data.channels == 6) && (ao_data.format!=AFMT_AC3) ) {
+  	if( (ao_data.channels == 6) && (ao_data.format!=AF_FORMAT_AC3) ) {
   	    // reorder channels while writing to pointers.
   	    // it's this easy because buffer size and len are always
   	    // aligned to multiples of channels*bytespersample
@@ -366,14 +366,14 @@
 
 	//check if the format is supported in general
 	switch(format){
-		case AFMT_AC3:
-		case AFMT_S24_LE:
-		case AFMT_S16_LE:
-		case AFMT_S8:
+		case AF_FORMAT_AC3:
+		case AF_FORMAT_S24_LE:
+		case AF_FORMAT_S16_LE:
+		case AF_FORMAT_S8:
 			break;
 		default:
 			mp_msg(MSGT_AO, MSGL_V,"ao_dsound: format %s not supported defaulting to Signed 16-bit Little-Endian\n",audio_out_format_name(format));
-			format=AFMT_S16_LE;
+			format=AF_FORMAT_S16_LE;
 	}   	
 	//fill global ao_data
 	ao_data.channels = channels;
@@ -389,7 +389,7 @@
 	wformat.Format.cbSize          = (channels > 2) ? sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX) : 0;
 	wformat.Format.nChannels       = channels;
 	wformat.Format.nSamplesPerSec  = rate;
-	if (format == AFMT_AC3) {
+	if (format == AF_FORMAT_AC3) {
 		wformat.Format.wFormatTag      = WAVE_FORMAT_DOLBY_AC3_SPDIF;
 		wformat.Format.wBitsPerSample  = 16;
 		wformat.Format.nBlockAlign     = 4;
--- a/libao2/ao_dxr2.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_dxr2.c	Mon Dec 27 17:30:15 2004 +0000
@@ -11,8 +11,7 @@
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
-
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 
 static ao_info_t info =
@@ -158,9 +157,9 @@
 // return: number of bytes played
 static int play(void* data,int len,int flags){
   // MPEG and AC3 don't work :-(
-    if(ao_data.format==AFMT_MPEG)
+    if(ao_data.format==AF_FORMAT_MPEG2)
 	dxr2_send_packet(data,len,0xC0,ao_data.pts);
-    else if(ao_data.format==AFMT_AC3)
+    else if(ao_data.format==AF_FORMAT_AC3)
       	dxr2_send_packet(data,len,0x80,ao_data.pts);
     else {
 	int i;
--- a/libao2/ao_esd.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_esd.c	Mon Dec 27 17:30:15 2004 +0000
@@ -32,7 +32,7 @@
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include "config.h"
 #include "mp_msg.h"
 #include "help_mp.h"
@@ -200,14 +200,14 @@
 
     /* EsounD can play 8bit unsigned and 16bit signed native */
     switch (format) {
-    case AFMT_S8:
-    case AFMT_U8:
+    case AF_FORMAT_S8:
+    case AF_FORMAT_U8:
 	esd_fmt |= ESD_BITS8;
-	ao_data.format = AFMT_U8;
+	ao_data.format = AF_FORMAT_U8;
 	break;
     default:
 	esd_fmt |= ESD_BITS16;
-	ao_data.format = AFMT_S16_NE;
+	ao_data.format = AF_FORMAT_S16_NE;
 	bytes_per_sample *= 2;
 	break;
     }
--- a/libao2/ao_jack.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_jack.c	Mon Dec 27 17:30:15 2004 +0000
@@ -14,7 +14,7 @@
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include "config.h"
 #include "mp_msg.h"
 
@@ -146,14 +146,14 @@
 	}
 
 	switch (format) {
-		case AFMT_U8:
-		case AFMT_S8:
-			format = AFMT_U8;
+		case AF_FORMAT_U8:
+		case AF_FORMAT_S8:
+			format = AF_FORMAT_U8;
 			bits_per_sample = 8;
 			m = 1;
 			break;
 		default:
-			format = AFMT_S16_LE;
+			format = AF_FORMAT_S16_LE;
 			bits_per_sample = 16;
 			m = 2;
 			break;
--- a/libao2/ao_macosx.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_macosx.c	Mon Dec 27 17:30:15 2004 +0000
@@ -47,7 +47,7 @@
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 static ao_info_t info =
   {
@@ -252,7 +252,7 @@
     if (ao->outputStreamBasicDescription.mFormatID == kAudioFormatLinearPCM) {
       uint32_t flags = ao->outputStreamBasicDescription.mFormatFlags;
       if (flags & kAudioFormatFlagIsFloat) {
-	ao_data.format = AFMT_FLOAT;
+	ao_data.format = AF_FORMAT_FLOAT_NE;
       } else {
 	ao_msg(MSGT_AO,MSGL_WARN, "Unsupported audio output "
 	       "format %d. Please report this to the developer\n",
--- a/libao2/ao_mpegpes.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_mpegpes.c	Mon Dec 27 17:30:15 2004 +0000
@@ -15,7 +15,7 @@
 #include "audio_out.h"
 #include "audio_out_internal.h"
 
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 #include "mp_msg.h"
 #include "help_mp.h"
@@ -96,14 +96,14 @@
     ao_data.channels=2;
     ao_data.outburst=2000;
     switch(format){
-	case AFMT_S16_LE:
-	case AFMT_S16_BE:
-	case AFMT_MPEG:
-	case AFMT_AC3:
+	case AF_FORMAT_S16_LE:
+	case AF_FORMAT_S16_BE:
+	case AF_FORMAT_MPEG2:
+	case AF_FORMAT_AC3:
 	    ao_data.format=format;
 	    break;
 	default:
-	    ao_data.format=AFMT_S16_BE;
+	    ao_data.format=AF_FORMAT_S16_BE;
     }
     
 retry:
@@ -174,14 +174,14 @@
 // return: number of bytes played
 static int play(void* data,int len,int flags){
 //    printf("\nao_mpegpes: play(%d) freq=%d\n",len,freq_id);
-    if(ao_data.format==AFMT_MPEG)
+    if(ao_data.format==AF_FORMAT_MPEG2)
 	send_pes_packet(data,len,0x1C0,ao_data.pts);
     else {
 	int i;
 	unsigned short *s=data;
 //	if(len>2000) len=2000;
 //	printf("ao_mpegpes: len=%d  \n",len);
-	if(ao_data.format==AFMT_S16_LE || ao_data.format==AFMT_AC3)
+	if(ao_data.format==AF_FORMAT_S16_LE || ao_data.format==AF_FORMAT_AC3)
 	    for(i=0;i<len/2;i++) s[i]=(s[i]>>8)|(s[i]<<8); // le<->be
 	send_lpcm_packet(data,len,0xA0,ao_data.pts,freq_id);
     }
--- a/libao2/ao_nas.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_nas.c	Mon Dec 27 17:30:15 2004 +0000
@@ -37,7 +37,7 @@
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 #define NAS_FRAG_SIZE 4096
 
@@ -312,22 +312,22 @@
 static unsigned int nas_aformat_to_auformat(unsigned int *format)
 {
 	switch (*format) {
-	case	AFMT_U8:
+	case	AF_FORMAT_U8:
 		return AuFormatLinearUnsigned8;
-	case	AFMT_S8:
+	case	AF_FORMAT_S8:
 		return AuFormatLinearSigned8;
-	case	AFMT_U16_LE:
+	case	AF_FORMAT_U16_LE:
 		return AuFormatLinearUnsigned16LSB;
-	case	AFMT_U16_BE:
+	case	AF_FORMAT_U16_BE:
 		return AuFormatLinearUnsigned16MSB;
-	case	AFMT_S16_LE:
+	case	AF_FORMAT_S16_LE:
 		return AuFormatLinearSigned16LSB;
-	case	AFMT_S16_BE:
+	case	AF_FORMAT_S16_BE:
 		return AuFormatLinearSigned16MSB;
-	case	AFMT_MU_LAW:
+	case	AF_FORMAT_MU_LAW:
 		return AuFormatULAW8;
 	default:
-		*format=AFMT_S16_NE;
+		*format=AF_FORMAT_S16_NE;
 		return nas_aformat_to_auformat(format);
 	}
 }
--- a/libao2/ao_null.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_null.c	Mon Dec 27 17:30:15 2004 +0000
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <sys/time.h>
 
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include "audio_out.h"
 #include "audio_out_internal.h"
 
@@ -55,7 +55,7 @@
     ao_data.samplerate=rate;
     ao_data.format=format;
     ao_data.bps=channels*rate;
-    if (format != AFMT_U8 && format != AFMT_S8)
+    if (format != AF_FORMAT_U8 && format != AF_FORMAT_S8)
 	ao_data.bps*=2; 
     buffer=0;
     gettimeofday(&last_tv, 0);
--- a/libao2/ao_oss.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_oss.c	Mon Dec 27 17:30:15 2004 +0000
@@ -9,14 +9,21 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
-//#include <sys/soundcard.h>
 
 #include "config.h"
 #include "mp_msg.h"
 #include "mixer.h"
 #include "help_mp.h"
 
-#include "afmt.h"
+#ifdef HAVE_SYS_SOUNDCARD_H
+#include <sys/soundcard.h>
+#else
+#ifdef HAVE_SOUNDCARD_H
+#include <soundcard.h>
+#endif
+#endif
+
+#include "../libaf/af_format.h"
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
@@ -33,6 +40,86 @@
 
 LIBAO_EXTERN(oss)
 
+static int format2oss(int format)
+{
+    switch(format)
+    {
+    case AF_FORMAT_U8: return AFMT_U8;
+    case AF_FORMAT_S8: return AFMT_S8;
+    case AF_FORMAT_U16_LE: return AFMT_U16_LE;
+    case AF_FORMAT_U16_BE: return AFMT_U16_BE;
+    case AF_FORMAT_S16_LE: return AFMT_S16_LE;
+    case AF_FORMAT_S16_BE: return AFMT_S16_BE;
+#ifdef AFMT_S24_LE
+    case AF_FORMAT_U24_LE: return AFMT_U24_LE;
+    case AF_FORMAT_U24_BE: return AFMT_U24_BE;
+    case AF_FORMAT_S24_LE: return AFMT_S24_LE;
+    case AF_FORMAT_S24_BE: return AFMT_S24_BE;
+#endif
+#ifdef AFMT_S32_LE
+    case AF_FORMAT_U32_LE: return AFMT_U32_LE;
+    case AF_FORMAT_U32_BE: return AFMT_U32_BE;
+    case AF_FORMAT_S32_LE: return AFMT_S32_LE;
+    case AF_FORMAT_S32_BE: return AFMT_S32_BE;
+#endif
+#ifdef AFMT_FLOAT
+    case AF_FORMAT_FLOAT_NE: return AFMT_FLOAT;
+#endif
+    // SPECIALS
+    case AF_FORMAT_MU_LAW: return AFMT_MU_LAW;
+    case AF_FORMAT_A_LAW: return AFMT_A_LAW;
+    case AF_FORMAT_IMA_ADPCM: return AFMT_IMA_ADPCM;
+#ifdef AFMT_MPEG
+    case AF_FORMAT_MPEG2: return AFMT_MPEG;
+#endif
+#ifdef AFMT_AC3
+    case AF_FORMAT_AC3: return AFMT_AC3;
+#endif
+    }
+    printf("Unknown format: %x\n", format);
+    return -1;
+}
+
+static int oss2format(int format)
+{
+    switch(format)
+    {
+    case AFMT_U8: return AF_FORMAT_U8;
+    case AFMT_S8: return AF_FORMAT_S8;
+    case AFMT_U16_LE: return AF_FORMAT_U16_LE;
+    case AFMT_U16_BE: return AF_FORMAT_U16_BE;
+    case AFMT_S16_LE: return AF_FORMAT_S16_LE;
+    case AFMT_S16_BE: return AF_FORMAT_S16_BE;
+#ifdef AFMT_S24_LE
+    case AFMT_U24_LE: return AF_FORMAT_U24_LE;
+    case AFMT_U24_BE: return AF_FORMAT_U24_BE;
+    case AFMT_S24_LE: return AF_FORMAT_S24_LE;
+    case AFMT_S24_BE: return AF_FORMAT_S24_BE;
+#endif
+#ifdef AFMT_S32_LE
+    case AFMT_U32_LE: return AF_FORMAT_U32_LE;
+    case AFMT_U32_BE: return AF_FORMAT_U32_BE;
+    case AFMT_S32_LE: return AF_FORMAT_S32_LE;
+    case AFMT_S32_BE: return AF_FORMAT_S32_BE;
+#endif
+#ifdef AFMT_FLOAT
+    case AFMT_FLOAT: return AF_FORMAT_FLOAT_NE;
+#endif
+    // SPECIALS
+    case AFMT_MU_LAW: return AF_FORMAT_MU_LAW;
+    case AFMT_A_LAW: return AF_FORMAT_A_LAW;
+    case AFMT_IMA_ADPCM: return AF_FORMAT_IMA_ADPCM;
+#ifdef AFMT_MPEG
+    case AFMT_MPEG: return AF_FORMAT_MPEG2;
+#endif
+#ifdef AFMT_AC3
+    case AFMT_AC3: return AF_FORMAT_AC3;
+#endif
+    }
+    printf("Unknown format: %x\n", format);
+    return -1;
+}
+
 static char *dsp=PATH_DEV_DSP;
 static audio_buf_info zz;
 static int audio_fd=-1;
@@ -57,7 +144,7 @@
 	    ao_control_vol_t *vol = (ao_control_vol_t *)arg;
 	    int fd, v, devs;
 
-	    if(ao_data.format == AFMT_AC3)
+	    if(ao_data.format == AF_FORMAT_AC3)
 		return CONTROL_TRUE;
     
 	    if ((fd = open(oss_mixer_device, O_RDONLY)) > 0)
@@ -95,9 +182,10 @@
 // return: 1=success 0=fail
 static int init(int rate,int channels,int format,int flags){
   char *mixer_channels [SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
+  int oss_format;
 
-  mp_msg(MSGT_AO,MSGL_V,"ao2: %d Hz  %d chans  %s\n",rate,channels,
-    audio_out_format_name(format));
+//  mp_msg(MSGT_AO,MSGL_V,"ao2: %d Hz  %d chans  %s\n",rate,channels,
+//    audio_out_format_name(format));
 
   if (ao_subdevice)
     dsp = ao_subdevice;
@@ -160,32 +248,39 @@
   fcntl(audio_fd, F_SETFD, FD_CLOEXEC);
 #endif
   
-  if(format == AFMT_AC3) {
+  if(format == AF_FORMAT_AC3) {
     ao_data.samplerate=rate;
     ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate);
   }
 
 ac3_retry:  
   ao_data.format=format;
-  if( ioctl(audio_fd, SNDCTL_DSP_SETFMT, &ao_data.format)<0 ||
-      ao_data.format != format) if(format == AFMT_AC3){
+  oss_format=format2oss(format);
+  if (oss_format == -1) return 0;
+  if( ioctl(audio_fd, SNDCTL_DSP_SETFMT, &oss_format)<0 ||
+      oss_format != format2oss(format)) if(format == AF_FORMAT_AC3){
     mp_msg(MSGT_AO,MSGL_WARN, MSGTR_AO_OSS_CantSetAC3, dsp);
 #ifdef WORDS_BIGENDIAN
-    format=AFMT_S16_BE;
+    oss_format=AFMT_S16_BE;
+    format=AF_FORMAT_S16_BE;
 #else
-    format=AFMT_S16_LE;
+    oss_format=AFMT_S16_LE;
+    format=AF_FORMAT_S16_LE;
 #endif
     goto ac3_retry;
   }
-  mp_msg(MSGT_AO,MSGL_V,"audio_setup: sample format: %s (requested: %s)\n",
-    audio_out_format_name(ao_data.format), audio_out_format_name(format));
+//  mp_msg(MSGT_AO,MSGL_V,"audio_setup: sample format: %s (requested: %s)\n",
+//    audio_out_format_name(ao_data.format), audio_out_format_name(format));
 #if 0
-  if(ao_data.format!=format)
+  if(oss_format!=format2oss(format))
 	mp_msg(MSGT_AO,MSGL_WARN,"WARNING! Your soundcard does NOT support %s sample format! Broken audio or bad playback speed are possible! Try with '-aop list=format'\n",audio_out_format_name(format));
 #endif
+
+  ao_data.format = oss2format(oss_format);
+  if (ao_data.format == -1) return 0;
   
   ao_data.channels = channels;
-  if(format != AFMT_AC3) {
+  if(format != AF_FORMAT_AC3) {
     // We only use SNDCTL_DSP_CHANNELS for >2 channels, in case some drivers don't have it
     if (ao_data.channels > 2) {
       if ( ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels) == -1 ||
@@ -253,7 +348,7 @@
   }
 
   ao_data.bps=ao_data.channels;
-  if(ao_data.format != AFMT_U8 && ao_data.format != AFMT_S8)
+  if(ao_data.format != AF_FORMAT_U8 && ao_data.format != AF_FORMAT_S8)
     ao_data.bps*=2;
 
   ao_data.outburst-=ao_data.outburst % ao_data.bps; // round down
@@ -280,6 +375,7 @@
 
 // stop playing and empty buffers (for seeking/pause)
 static void reset(){
+  int oss_format;
     uninit(1);
     audio_fd=open(dsp, O_WRONLY);
     if(audio_fd < 0){
@@ -291,8 +387,9 @@
   fcntl(audio_fd, F_SETFD, FD_CLOEXEC);
 #endif
 
-  ioctl (audio_fd, SNDCTL_DSP_SETFMT, &ao_data.format);
-  if(ao_data.format != AFMT_AC3) {
+  oss_format = format2oss(ao_data.format);
+  ioctl (audio_fd, SNDCTL_DSP_SETFMT, &oss_format);
+  if(ao_data.format != AF_FORMAT_AC3) {
     if (ao_data.channels > 2)
       ioctl (audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels);
     else {
--- a/libao2/ao_pcm.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_pcm.c	Mon Dec 27 17:30:15 2004 +0000
@@ -5,7 +5,7 @@
 #include <string.h>
 
 #include "bswap.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include "audio_out.h"
 #include "audio_out_internal.h"
 #include "mp_msg.h"
@@ -89,12 +89,12 @@
 
 	bits=8;
 	switch(format){
-	case AFMT_S8:
-	    format=AFMT_U8;
-	case AFMT_U8:
+	case AF_FORMAT_S8:
+	    format=AF_FORMAT_U8;
+	case AF_FORMAT_U8:
 	    break;
 	default:
-	    format=AFMT_S16_LE;
+	    format=AF_FORMAT_S16_LE;
 	    bits=16;
 	    break;
 	}
@@ -114,9 +114,9 @@
 	wavhdr.data_length=le2me_32(0x7ffff000);
 	wavhdr.file_length = wavhdr.data_length + sizeof(wavhdr) - 8;
 
-	mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_FileInfo, ao_outputfilename, 
-	       (ao_pcm_waveheader?"WAVE":"RAW PCM"), rate, 
-	       (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format));
+//	mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_FileInfo, ao_outputfilename, 
+//	       (ao_pcm_waveheader?"WAVE":"RAW PCM"), rate, 
+//	       (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format));
 	mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_HintInfo);
 
 	fp = fopen(ao_outputfilename, "wb");
--- a/libao2/ao_plugin.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_plugin.c	Mon Dec 27 17:30:15 2004 +0000
@@ -6,7 +6,7 @@
 
 #include "mp_msg.h"
 #include "help_mp.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include "audio_out.h"
 #include "audio_out_internal.h"
 
@@ -140,7 +140,7 @@
 
   ao_plugin_local_data.format=format;
   ao_plugin_local_data.channels=channels;
-  ao_plugin_local_data.bpm=audio_out_format_bits(format);
+  ao_plugin_local_data.bpm=af_fmt2bits(format);
 
   ao_plugin_data.rate=rate;
   ao_plugin_data.channels=channels;
@@ -168,7 +168,7 @@
   // Calculate bps
   ao_plugin_local_data.bps=(float)(ao_plugin_data.rate * 
 				   ao_plugin_data.channels);
-  ao_plugin_local_data.bps*=audio_out_format_bits(ao_plugin_data.format)/8;
+  ao_plugin_local_data.bps*=af_fmt2bits(ao_plugin_data.format)/8;
 
   // This should never happen but check anyway 
   if(NULL==ao_plugin_local_data.driver)
--- a/libao2/ao_polyp.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_polyp.c	Mon Dec 27 17:30:15 2004 +0000
@@ -6,7 +6,7 @@
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include "config.h"
 #include "mp_msg.h"
 
@@ -91,16 +91,16 @@
     ss.rate = rate_hz;
 
     switch (format) {
-        case AFMT_U8:
+        case AF_FORMAT_U8:
             ss.format = PA_SAMPLE_U8;
             break;
-        case AFMT_S16_LE:
+        case AF_FORMAT_S16_LE:
             ss.format = PA_SAMPLE_S16LE;
             break;
-        case AFMT_S16_BE:
+        case AF_FORMAT_S16_BE:
             ss.format = PA_SAMPLE_S16BE;
             break;
-        case AFMT_FLOAT:
+        case AF_FORMAT_FLOAT_NE:
             ss.format = PA_SAMPLE_FLOAT32;
             break;
         default:
--- a/libao2/ao_sdl.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_sdl.c	Mon Dec 27 17:30:15 2004 +0000
@@ -20,7 +20,7 @@
 
 #include "audio_out.h"
 #include "audio_out_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include <SDL.h>
 #include "osdep/timer.h"
 
@@ -181,7 +181,7 @@
 	/* Allocate ring-buffer memory */
 	buffer = (unsigned char *) malloc(BUFFSIZE);
 
-	mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_INFO, rate, (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format));
+//	mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_INFO, rate, (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format));
 
 	if(ao_subdevice) {
 		setenv("SDL_AUDIODRIVER", ao_subdevice, 1);
@@ -193,32 +193,32 @@
 	ao_data.format=format;
 
 	ao_data.bps=channels*rate;
-	if(format != AFMT_U8 && format != AFMT_S8)
+	if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8)
 	  ao_data.bps*=2;
 	
 	/* The desired audio format (see SDL_AudioSpec) */
 	switch(format) {
-	    case AFMT_U8:
+	    case AF_FORMAT_U8:
 		aspec.format = AUDIO_U8;
 	    break;
-	    case AFMT_S16_LE:
+	    case AF_FORMAT_S16_LE:
 		aspec.format = AUDIO_S16LSB;
 	    break;
-	    case AFMT_S16_BE:
+	    case AF_FORMAT_S16_BE:
 		aspec.format = AUDIO_S16MSB;
 	    break;
-	    case AFMT_S8:
+	    case AF_FORMAT_S8:
 		aspec.format = AUDIO_S8;
 	    break;
-	    case AFMT_U16_LE:
+	    case AF_FORMAT_U16_LE:
 		aspec.format = AUDIO_U16LSB;
 	    break;
-	    case AFMT_U16_BE:
+	    case AF_FORMAT_U16_BE:
 		aspec.format = AUDIO_U16MSB;
 	    break;
 	    default:
                 aspec.format = AUDIO_S16LSB;
-                ao_data.format = AFMT_S16_LE;
+                ao_data.format = AF_FORMAT_S16_LE;
                 mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_SDL_UnsupportedAudioFmt, format);
 	}
 
@@ -256,22 +256,22 @@
 
 	switch(obtained.format) {
 	    case AUDIO_U8 :
-		ao_data.format = AFMT_U8;
+		ao_data.format = AF_FORMAT_U8;
 	    break;
 	    case AUDIO_S16LSB :
-		ao_data.format = AFMT_S16_LE;
+		ao_data.format = AF_FORMAT_S16_LE;
 	    break;
 	    case AUDIO_S16MSB :
-		ao_data.format = AFMT_S16_BE;
+		ao_data.format = AF_FORMAT_S16_BE;
 	    break;
 	    case AUDIO_S8 :
-		ao_data.format = AFMT_S8;
+		ao_data.format = AF_FORMAT_S8;
 	    break;
 	    case AUDIO_U16LSB :
-		ao_data.format = AFMT_U16_LE;
+		ao_data.format = AF_FORMAT_U16_LE;
 	    break;
 	    case AUDIO_U16MSB :
-		ao_data.format = AFMT_U16_BE;
+		ao_data.format = AF_FORMAT_U16_BE;
 	    break;
 	    default:
                 mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_SDL_UnsupportedAudioFmt, obtained.format);
--- a/libao2/ao_win32.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/ao_win32.c	Mon Dec 27 17:30:15 2004 +0000
@@ -23,7 +23,7 @@
 #include <windows.h>
 #include <mmsystem.h>
 
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include "audio_out.h"
 #include "audio_out_internal.h"
 #include "mp_msg.h"
@@ -149,21 +149,21 @@
 	int i;
    
 	switch(format){
-		case AFMT_AC3:
-		case AFMT_S24_LE:
-		case AFMT_S16_LE:
-		case AFMT_S8:
+		case AF_FORMAT_AC3:
+		case AF_FORMAT_S24_LE:
+		case AF_FORMAT_S16_LE:
+		case AF_FORMAT_S8:
 			break;
 		default:
 			mp_msg(MSGT_AO, MSGL_V,"ao_win32: format %s not supported defaulting to Signed 16-bit Little-Endian\n",audio_out_format_name(format));
-			format=AFMT_S16_LE;
+			format=AF_FORMAT_S16_LE;
 	}   
 	//fill global ao_data 
 	ao_data.channels=channels;
 	ao_data.samplerate=rate;
 	ao_data.format=format;
 	ao_data.bps=channels*rate;
-	if(format != AFMT_U8 && format != AFMT_S8)
+	if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8)
 	  ao_data.bps*=2;
 	if(ao_data.buffersize==-1)
 	{
@@ -179,7 +179,7 @@
     wformat.Format.cbSize          = (channels>2)?sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX):0;
     wformat.Format.nChannels       = channels;                
     wformat.Format.nSamplesPerSec  = rate;            
-    if(format == AFMT_AC3)
+    if(format == AF_FORMAT_AC3)
     {
         wformat.Format.wFormatTag      = WAVE_FORMAT_DOLBY_AC3_SPDIF;
         wformat.Format.wBitsPerSample  = 16;
@@ -208,7 +208,7 @@
 		mp_msg(MSGT_AO, MSGL_ERR,"ao_win32: format not supported switching to default\n");
         ao_data.channels = wformat.Format.nChannels = 2;
 	    ao_data.samplerate = wformat.Format.nSamplesPerSec = 44100;
-	    ao_data.format = AFMT_S16_LE;
+	    ao_data.format = AF_FORMAT_S16_LE;
 		ao_data.bps=ao_data.channels * ao_data.samplerate*2;
 	    wformat.Format.wBitsPerSample=16;
         wformat.Format.wFormatTag=WAVE_FORMAT_PCM;
--- a/libao2/audio_out.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/audio_out.c	Mon Dec 27 17:30:15 2004 +0000
@@ -4,7 +4,6 @@
 
 #include "config.h"
 #include "audio_out.h"
-#include "afmt.h"
 
 #include "mp_msg.h"
 #include "help_mp.h"
@@ -187,6 +186,7 @@
 	    audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,audio_out);
 	    audio_out=&audio_out_plugin;
 	}
+//	if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE)
 	if(audio_out->init(rate,channels,format,flags))
 	    return audio_out; // success!
     }
--- a/libao2/audio_plugin.h	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/audio_plugin.h	Mon Dec 27 17:30:15 2004 +0000
@@ -45,7 +45,7 @@
 // Configuration defaults
 #define CFG_DEFAULTS { \
  NULL, \
- AFMT_S16_LE, \
+ AF_FORMAT_S16_LE, \
  0, \
  48000, \
  101, \
--- a/libao2/pl_delay.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/pl_delay.c	Mon Dec 27 17:30:15 2004 +0000
@@ -12,7 +12,7 @@
 #include "audio_out.h"
 #include "audio_plugin.h"
 #include "audio_plugin_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 static ao_info_t info =
 {
@@ -65,7 +65,7 @@
 
   // Tell ao_plugin how much this plugin adds to the overall time delay
   time_delay=-1*(float)ao_plugin_cfg.pl_delay_len/((float)pl_delay.channels*(float)pl_delay.rate);
-  if(pl_delay.format != AFMT_U8 && pl_delay.format != AFMT_S8)
+  if(pl_delay.format != AF_FORMAT_U8 && pl_delay.format != AF_FORMAT_S8)
     time_delay/=2;
   ao_plugin_data.delay_fix+=time_delay;
 
--- a/libao2/pl_eq.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/pl_eq.c	Mon Dec 27 17:30:15 2004 +0000
@@ -24,7 +24,7 @@
 #include "audio_out.h"
 #include "audio_plugin.h"
 #include "audio_plugin_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 #include "eq.h"
 
 static ao_info_t info =
@@ -122,7 +122,7 @@
   float F[KM] = CF;
   
   // Check input format
-  if(ao_plugin_data.format != AFMT_S16_NE){
+  if(ao_plugin_data.format != AF_FORMAT_S16_NE){
     fprintf(stderr,"[pl_eq] Input audio format not yet supported. \n");
     return 0;
   }
--- a/libao2/pl_extrastereo.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/pl_extrastereo.c	Mon Dec 27 17:30:15 2004 +0000
@@ -19,7 +19,7 @@
 #include "audio_out.h"
 #include "audio_plugin.h"
 #include "audio_plugin_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 static ao_info_t info = {
         "Extra stereo plugin",
@@ -57,7 +57,7 @@
 // return: 1=success 0=fail
 static int init(){
   switch(ao_plugin_data.format){
-  case(AFMT_S16_NE):
+  case(AF_FORMAT_S16_NE):
     break;
   default:
     fprintf(stderr,"[pl_extrastereo] Audio format not yet suported \n");
@@ -87,7 +87,7 @@
 static int play(){
 
   switch(pl_extrastereo.format){
-  case(AFMT_S16_NE): {
+  case(AF_FORMAT_S16_NE): {
 
     int16_t* data=(int16_t*)ao_plugin_data.data;
     int len=ao_plugin_data.len / 2; // 16 bits samples
--- a/libao2/pl_format.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/pl_format.c	Mon Dec 27 17:30:15 2004 +0000
@@ -16,7 +16,7 @@
 #include "audio_out.h"
 #include "audio_plugin.h"
 #include "audio_plugin_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 static ao_info_t info =
 {
@@ -75,29 +75,30 @@
 // open & setup audio device
 // return: 1=success 0=fail
 static int init(){
+  char buf1[128], buf2[128];
   // Sheck input format
   switch(ao_plugin_data.format){
-  case(AFMT_U8):
+  case(AF_FORMAT_U8):
     pl_format.in=LE|B08|US; break;
-  case(AFMT_S8):
+  case(AF_FORMAT_S8):
     pl_format.in=LE|B08|SI; break;
-  case(AFMT_S16_LE):
+  case(AF_FORMAT_S16_LE):
     pl_format.in=LE|B16|SI; break;
-  case(AFMT_S16_BE):
+  case(AF_FORMAT_S16_BE):
     pl_format.in=BE|B16|SI; break;
-  case(AFMT_U16_LE):	
+  case(AF_FORMAT_U16_LE):	
     pl_format.in=LE|B16|US; break;
-  case(AFMT_U16_BE):	
+  case(AF_FORMAT_U16_BE):	
     pl_format.in=BE|B16|US; break;
-  case(AFMT_S32_LE):
+  case(AF_FORMAT_S32_LE):
     pl_format.in=LE|B32|SI; break;
-  case(AFMT_S32_BE):	
+  case(AF_FORMAT_S32_BE):	
     pl_format.in=BE|B32|SI; break;
-  case(AFMT_IMA_ADPCM):		
-  case(AFMT_MU_LAW):
-  case(AFMT_A_LAW):
-  case(AFMT_MPEG):
-  case(AFMT_AC3):
+  case(AF_FORMAT_IMA_ADPCM):		
+  case(AF_FORMAT_MU_LAW):
+  case(AF_FORMAT_A_LAW):
+  case(AF_FORMAT_MPEG2):
+  case(AF_FORMAT_AC3):
     printf("[pl_format] Input audio format not yet suported \n");
     return 0;
   default: 
@@ -106,27 +107,27 @@
   }
   // Sheck output format
   switch(ao_plugin_cfg.pl_format_type){
-  case(AFMT_U8):
+  case(AF_FORMAT_U8):
     pl_format.out=LE|B08|US; break;
-  case(AFMT_S8):
+  case(AF_FORMAT_S8):
     pl_format.out=LE|B08|SI; break;
-  case(AFMT_S16_LE):
+  case(AF_FORMAT_S16_LE):
     pl_format.out=LE|B16|SI; break;
-  case(AFMT_S16_BE):
+  case(AF_FORMAT_S16_BE):
     pl_format.out=BE|B16|SI; break;
-  case(AFMT_U16_LE):	
+  case(AF_FORMAT_U16_LE):	
     pl_format.out=LE|B16|US; break;
-  case(AFMT_U16_BE):	
+  case(AF_FORMAT_U16_BE):	
     pl_format.out=BE|B16|US; break;
-  case(AFMT_S32_LE):
+  case(AF_FORMAT_S32_LE):
     pl_format.out=LE|B32|SI; break;
-  case(AFMT_S32_BE):	
+  case(AF_FORMAT_S32_BE):	
     pl_format.out=BE|B32|SI; break;
-  case(AFMT_IMA_ADPCM):		
-  case(AFMT_MU_LAW):
-  case(AFMT_A_LAW):
-  case(AFMT_MPEG):
-  case(AFMT_AC3):
+  case(AF_FORMAT_IMA_ADPCM):		
+  case(AF_FORMAT_MU_LAW):
+  case(AF_FORMAT_A_LAW):
+  case(AF_FORMAT_MPEG2):
+  case(AF_FORMAT_AC3):
     printf("[pl_format] Output audio format not yet suported \n");
     return 0;
   default:
@@ -136,8 +137,8 @@
 
   // Tell the world what we are up to
   printf("[pl_format] Input format: %s, output format: %s \n",
-	 audio_out_format_name(ao_plugin_data.format),
-	 audio_out_format_name(ao_plugin_cfg.pl_format_type));
+	 af_fmt2str(ao_plugin_data.format, &buf1, 128),
+	 af_fmt2str(ao_plugin_cfg.pl_format_type, &buf2, 128));
 
   // We are changing the format
   ao_plugin_data.format=ao_plugin_cfg.pl_format_type;
--- a/libao2/pl_resample.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/pl_resample.c	Mon Dec 27 17:30:15 2004 +0000
@@ -23,7 +23,7 @@
 #include "audio_out.h"
 #include "audio_plugin.h"
 #include "audio_plugin_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 static ao_info_t info =
 {
@@ -119,7 +119,7 @@
   pl_resample.up=UP;
 
   // Sheck input format
-  if(ao_plugin_data.format != AFMT_S16_NE){
+  if(ao_plugin_data.format != AF_FORMAT_S16_NE){
     fprintf(stderr,"[pl_resample] Input audio format not yet suported. \n");
     return 0;
   }
--- a/libao2/pl_surround.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/pl_surround.c	Mon Dec 27 17:30:15 2004 +0000
@@ -44,7 +44,7 @@
 #include "audio_out.h"
 #include "audio_plugin.h"
 #include "audio_plugin_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 #include "remez.h"
 #include "firfilter.c"
@@ -108,8 +108,8 @@
     pl_surround.passthrough = 1;
     return 1;
   }
-  if (ao_plugin_data.format != AFMT_S16_NE) {
-    fprintf(stderr, "pl_surround: I'm dumb and can only handle AFMT_S16_NE audio format, using passthrough mode\n");
+  if (ao_plugin_data.format != AF_FORMAT_S16_NE) {
+    fprintf(stderr, "pl_surround: I'm dumb and can only handle AF_FORMAT_S16_NE audio format, using passthrough mode\n");
     pl_surround.passthrough = 1;
     return 1;
   }
--- a/libao2/pl_volnorm.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/pl_volnorm.c	Mon Dec 27 17:30:15 2004 +0000
@@ -30,7 +30,7 @@
 #include "audio_out.h"
 #include "audio_plugin.h"
 #include "audio_plugin_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 static ao_info_t info = {
         "Volume normalizer",
@@ -116,7 +116,7 @@
 // return: 1=success 0=fail
 static int init(){
   switch(ao_plugin_data.format){
-    case(AFMT_S16_NE):
+    case(AF_FORMAT_S16_NE):
       break;
     default:
       fprintf(stderr,"[pl_volnorm] Audio format not yet supported.\n");
@@ -142,7 +142,7 @@
   int i;
   mul = MUL_INIT;
   switch(ao_plugin_data.format) {
-    case(AFMT_S16_NE):
+    case(AF_FORMAT_S16_NE):
 #if AVG==1
       lastavg = MID_S16;
 #elif AVG==2
@@ -165,7 +165,7 @@
 static int play(){
 
   switch(pl_volnorm.format){
-  case(AFMT_S16_NE): {
+  case(AF_FORMAT_S16_NE): {
 #define CLAMP(x,m,M) do { if ((x)<(m)) (x) = (m); else if ((x)>(M)) (x) = (M); } while(0)
 
     int16_t* data=(int16_t*)ao_plugin_data.data;
--- a/libao2/pl_volume.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libao2/pl_volume.c	Mon Dec 27 17:30:15 2004 +0000
@@ -20,7 +20,7 @@
 #include "audio_out.h"
 #include "audio_plugin.h"
 #include "audio_plugin_internal.h"
-#include "afmt.h"
+#include "libaf/af_format.h"
 
 static ao_info_t info =
 {
@@ -80,8 +80,8 @@
 static int init(){
   // Sanity sheck this plugin supports AFMT_U8 and AFMT_S16_LE
   switch(ao_plugin_data.format){
-  case(AFMT_U8):
-  case(AFMT_S16_NE):
+  case(AF_FORMAT_U8):
+  case(AF_FORMAT_S16_NE):
     break;
   default: 
     fprintf(stderr,"[pl_volume] Audio format not yet suported \n");
@@ -117,7 +117,7 @@
   vol=(vol*vol*vol)>>12;
   // Change the volume.
   switch(pl_volume.format){
-  case(AFMT_U8):{
+  case(AF_FORMAT_U8):{
     register uint8_t* data=(uint8_t*)ao_plugin_data.data;
     register int x;
       for(i=0;i<ao_plugin_data.len;i++){
@@ -135,7 +135,7 @@
       }
       break;
   }
-  case(AFMT_S16_NE):{
+  case(AF_FORMAT_S16_NE):{
     register int len=ao_plugin_data.len>>1;
     register int16_t* data=(int16_t*)ao_plugin_data.data;
     register int x;
--- a/libmpcodecs/ad_dvdpcm.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpcodecs/ad_dvdpcm.c	Mon Dec 27 17:30:15 2004 +0000
@@ -6,7 +6,6 @@
 #include "mp_msg.h"
 #include "help_mp.h"
 #include "ad_internal.h"
-#include "../libaf/af_format.h"
 
 static ad_info_t info = 
 {
@@ -35,26 +34,25 @@
 	}
 	switch ((h >> 6) & 3) {
 	  case 0:
-	    sh->sample_format = AFMT_S16_BE;
+	    sh->sample_format = AF_FORMAT_S16_BE;
 	    sh->samplesize = 2;
 	    break;
 	  case 1:
 	    mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_SamplesWanted);
 	    sh->i_bps = sh->channels * sh->samplerate * 5 / 2;
 	  case 2: 
-	    sh->sample_format = AFMT_AF_FLAGS | AF_FORMAT_I |
-	                         AF_FORMAT_BE | AF_FORMAT_SI;
+	    sh->sample_format = AF_FORMAT_S24_BE;
 	    sh->samplesize = 3;
 	    break;
 	  default:
-	    sh->sample_format = AFMT_S16_BE;
+	    sh->sample_format = AF_FORMAT_S16_BE;
 	    sh->samplesize = 2;
 	}
     } else {
 	// use defaults:
 	sh->channels=2;
 	sh->samplerate=48000;
-	sh->sample_format = AFMT_S16_BE;
+	sh->sample_format = AF_FORMAT_S16_BE;
 	sh->samplesize = 2;
     }
     if (!sh->i_bps)
--- a/libmpcodecs/ad_hwac3.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpcodecs/ad_hwac3.c	Mon Dec 27 17:30:15 2004 +0000
@@ -105,7 +105,7 @@
   sh->audio_in_minsize = 8192;
   sh->channels = 2;
   sh->samplesize = 2;
-  sh->sample_format = AFMT_AC3;
+  sh->sample_format = AF_FORMAT_AC3;
   return 1;
 }
 
--- a/libmpcodecs/ad_internal.h	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpcodecs/ad_internal.h	Mon Dec 27 17:30:15 2004 +0000
@@ -1,6 +1,6 @@
 
 #include "codec-cfg.h"
-#include "../libao2/afmt.h"
+#include "../libaf/af_format.h"
 
 #include "stream.h"
 #include "demuxer.h"
--- a/libmpcodecs/ad_pcm.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpcodecs/ad_pcm.c	Mon Dec 27 17:30:15 2004 +0000
@@ -24,31 +24,31 @@
   sh_audio->channels=h->nChannels;
   sh_audio->samplerate=h->nSamplesPerSec;
   sh_audio->samplesize=(h->wBitsPerSample+7)/8;
-  sh_audio->sample_format=AFMT_S16_LE; // default
+  sh_audio->sample_format=AF_FORMAT_S16_LE; // default
   switch(sh_audio->format){ /* hardware formats: */
     case 0x0:
     case 0x1: // Microsoft PCM
        switch (sh_audio->samplesize) {
-         case 1: sh_audio->sample_format=AFMT_U8; break;
-         case 2: sh_audio->sample_format=AFMT_S16_LE; break;
-         case 3: sh_audio->sample_format=AFMT_S24_LE; break;
-         case 4: sh_audio->sample_format=AFMT_S32_LE; break;
+         case 1: sh_audio->sample_format=AF_FORMAT_U8; break;
+         case 2: sh_audio->sample_format=AF_FORMAT_S16_LE; break;
+         case 3: sh_audio->sample_format=AF_FORMAT_S24_LE; break;
+         case 4: sh_audio->sample_format=AF_FORMAT_S32_LE; break;
        }
        break;
-    case 0x6:  sh_audio->sample_format=AFMT_A_LAW;break;
-    case 0x7:  sh_audio->sample_format=AFMT_MU_LAW;break;
-    case 0x11: sh_audio->sample_format=AFMT_IMA_ADPCM;break;
-    case 0x50: sh_audio->sample_format=AFMT_MPEG;break;
+    case 0x6:  sh_audio->sample_format=AF_FORMAT_A_LAW;break;
+    case 0x7:  sh_audio->sample_format=AF_FORMAT_MU_LAW;break;
+    case 0x11: sh_audio->sample_format=AF_FORMAT_IMA_ADPCM;break;
+    case 0x50: sh_audio->sample_format=AF_FORMAT_MPEG2;break;
 /*    case 0x2000: sh_audio->sample_format=AFMT_AC3; */
     case 0x20776172: // 'raw '
-       sh_audio->sample_format=AFMT_S16_BE;
-       if(sh_audio->samplesize==1) sh_audio->sample_format=AFMT_U8;
+       sh_audio->sample_format=AF_FORMAT_S16_BE;
+       if(sh_audio->samplesize==1) sh_audio->sample_format=AF_FORMAT_U8;
        break;
     case 0x736F7774: // 'twos'
-       sh_audio->sample_format=AFMT_S16_BE;
+       sh_audio->sample_format=AF_FORMAT_S16_BE;
        // intended fall-through
     case 0x74776F73: // 'swot'
-       if(sh_audio->samplesize==1) sh_audio->sample_format=AFMT_S8;
+       if(sh_audio->samplesize==1) sh_audio->sample_format=AF_FORMAT_S8;
 // Uncomment this if twos audio is broken for you
 // (typically with movies made on sgi machines)
 // This is just a workaround, the real bug is elsewhere
@@ -58,10 +58,10 @@
 #endif
        break;
     case 0x32336c66: // 'fl32', bigendian float32
-       sh_audio->sample_format=AFMT_AF_FLAGS | AF_FORMAT_BE | AF_FORMAT_F;
+       sh_audio->sample_format=AF_FORMAT_FLOAT_BE;
        sh_audio->samplesize=4;
        break;
-    default: if(sh_audio->samplesize!=2) sh_audio->sample_format=AFMT_U8;
+    default: if(sh_audio->samplesize!=2) sh_audio->sample_format=AF_FORMAT_U8;
   }
   return 1;
 }
--- a/libmpcodecs/ad_ra1428.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpcodecs/ad_ra1428.c	Mon Dec 27 17:30:15 2004 +0000
@@ -25,7 +25,7 @@
   sh->samplerate=sh->wf->nSamplesPerSec;
   sh->samplesize=sh->wf->wBitsPerSample/8;
   sh->channels=sh->wf->nChannels;
-  sh->sample_format=AFMT_S16_LE;
+  sh->sample_format=AF_FORMAT_S16_LE;
 
 	switch (sh->format) {
 		case mmioFOURCC('1','4','_','4'):
--- a/libmpcodecs/ad_sample.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpcodecs/ad_sample.c	Mon Dec 27 17:30:15 2004 +0000
@@ -47,7 +47,7 @@
   sh->samplesize=2;              // bytes (not bits!) per sample per channel
   sh->channels=2;                // number of channels
   sh->samplerate=44100;          // samplerate
-  sh->sample_format=AFMT_S16_LE; // sample format, see libao2/afmt.h
+  sh->sample_format=AF_FORMAT_S16_LE; // sample format, see libao2/afmt.h
   
   sh->i_bps=64000/8; // input data rate (compressed bytes per second)
   // Note: if you have VBR or unknown input rate, set it to some common or
--- a/libmpcodecs/dec_audio.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpcodecs/dec_audio.c	Mon Dec 27 17:30:15 2004 +0000
@@ -14,7 +14,7 @@
 
 #include "dec_audio.h"
 #include "ad.h"
-#include "../libao2/afmt.h"
+#include "../libaf/af_format.h"
 
 #include "../libaf/af.h"
 
@@ -267,13 +267,15 @@
   // input format: same as codec's output format:
   afs->input.rate   = in_samplerate;
   afs->input.nch    = in_channels;
-  afs->input.format = af_format_decode(in_format);
+//  afs->input.format = af_format_decode(in_format);
+  afs->input.format = in_format;
   afs->input.bps    = in_bps;
 
   // output format: same as ao driver's input format (if missing, fallback to input)
   afs->output.rate   = *out_samplerate ? *out_samplerate : afs->input.rate;
   afs->output.nch    = *out_channels ? *out_channels : afs->input.nch;
-  afs->output.format = *out_format ? af_format_decode(*out_format) : afs->input.format;
+//  afs->output.format = *out_format ? af_format_decode(*out_format) : afs->input.format;
+  afs->output.format = *out_format ? *out_format : afs->input.format;
   afs->output.bps    = out_bps ? out_bps : afs->input.bps;
 
   // filter config:  
@@ -291,11 +293,12 @@
   
   *out_samplerate=afs->output.rate;
   *out_channels=afs->output.nch;
-  *out_format=af_format_encode((void*)(&afs->output));
+//  *out_format=af_format_encode((void*)(&afs->output));
+  *out_format=afs->output.format;
   
   mp_msg(MSGT_DECAUDIO, MSGL_INFO, "AF_pre: af format: %d bps, %d ch, %d hz, %s\n",
       afs->output.bps, afs->output.nch, afs->output.rate,
-      fmt2str(afs->output.format,strbuf,200));
+      af_fmt2str(afs->output.format,strbuf,200));
   
   sh_audio->afilter=(void*)afs;
   return 1;
@@ -315,13 +318,15 @@
   // input format: same as codec's output format:
   afs->input.rate   = in_samplerate;
   afs->input.nch    = in_channels;
-  afs->input.format = af_format_decode(in_format);
+//  afs->input.format = af_format_decode(in_format);
+  afs->input.format = in_format;
   afs->input.bps    = in_bps;
 
   // output format: same as ao driver's input format (if missing, fallback to input)
   afs->output.rate   = out_samplerate ? out_samplerate : afs->input.rate;
   afs->output.nch    = out_channels ? out_channels : afs->input.nch;
-  afs->output.format = af_format_decode(out_format ? out_format : afs->input.format);
+//  afs->output.format = af_format_decode(out_format ? out_format : afs->input.format);
+  afs->output.format = out_format ? out_format : afs->input.format;
   afs->output.bps    = out_bps ? out_bps : afs->input.bps;
 
   // filter config:  
@@ -404,7 +409,8 @@
   afd.len=declen;
   afd.rate=sh_audio->samplerate;
   afd.nch=sh_audio->channels;
-  afd.format=af_format_decode(sh_audio->sample_format);
+//  afd.format=af_format_decode(sh_audio->sample_format);
+  afd.format=sh_audio->sample_format;
   afd.bps=sh_audio->samplesize;
   //pafd=&afd;
 //  printf("\nAF: %d --> ",declen);
--- a/libmpdemux/demuxer.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpdemux/demuxer.c	Mon Dec 27 17:30:15 2004 +0000
@@ -18,7 +18,7 @@
 #include "stheader.h"
 #include "mf.h"
 
-#include "../libao2/afmt.h"
+#include "../libaf/af_format.h"
 #include "../libvo/fastmemcpy.h"
 
 // Should be set to 1 by demux module if ids it passes to new_sh_audio and
@@ -91,7 +91,7 @@
         sh = demuxer->a_streams[id];
         // set some defaults
         sh->samplesize=2;
-        sh->sample_format=AFMT_S16_NE;
+        sh->sample_format=AF_FORMAT_S16_NE;
         sh->audio_out_minsize=8192;/* default size, maybe not enough for Win32/ACM*/
         if (identify && !demux_aid_vid_mismatch)
           mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", id);
--- a/libmpdemux/tv.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpdemux/tv.c	Mon Dec 27 17:30:15 2004 +0000
@@ -29,8 +29,7 @@
 #include "demuxer.h"
 #include "stheader.h"
 
-#include "../libao2/afmt.h"
-#include "../libao2/audio_out.h"
+#include "../libaf/af_format.h"
 #include "../libvo/img_format.h"
 #include "../libvo/fastmemcpy.h"
 
@@ -516,6 +515,7 @@
     {
 	int audio_format;
 	int sh_audio_format;
+	char buf[128];
 
 	/* yeah, audio is present */
 
@@ -527,24 +527,24 @@
 
 	switch(audio_format)
 	{
-	    case AFMT_U8:
-	    case AFMT_S8:
-	    case AFMT_U16_LE:
-	    case AFMT_U16_BE:
-	    case AFMT_S16_LE:
-	    case AFMT_S16_BE:
-	    case AFMT_S32_LE:
-	    case AFMT_S32_BE:
+	    case AF_FORMAT_U8:
+	    case AF_FORMAT_S8:
+	    case AF_FORMAT_U16_LE:
+	    case AF_FORMAT_U16_BE:
+	    case AF_FORMAT_S16_LE:
+	    case AF_FORMAT_S16_BE:
+	    case AF_FORMAT_S32_LE:
+	    case AF_FORMAT_S32_BE:
 		sh_audio_format = 0x1; /* PCM */
 		break;
-	    case AFMT_IMA_ADPCM:
-	    case AFMT_MU_LAW:
-	    case AFMT_A_LAW:
-	    case AFMT_MPEG:
-	    case AFMT_AC3:
+	    case AF_FORMAT_IMA_ADPCM:
+	    case AF_FORMAT_MU_LAW:
+	    case AF_FORMAT_A_LAW:
+	    case AF_FORMAT_MPEG2:
+	    case AF_FORMAT_AC3:
 	    default:
 		mp_msg(MSGT_TV, MSGL_ERR, "Audio type '%s (%x)' unsupported!\n",
-		    audio_out_format_name(audio_format), audio_format);
+		    af_fmt2str(audio_format, &buf, 128), audio_format);
 		goto no_audio;
 	}
 	
--- a/libmpdemux/tvi_bsdbt848.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpdemux/tvi_bsdbt848.c	Mon Dec 27 17:30:15 2004 +0000
@@ -61,6 +61,7 @@
 #endif
 #endif
 
+#include "../libaf/af_format.h"
 #include "../libvo/img_format.h"
 #include "tv.h"
 
@@ -246,7 +247,7 @@
 
     case TVI_CONTROL_AUD_GET_FORMAT:
         {
-        (int)*(void **)arg = AFMT_S16_LE;
+        (int)*(void **)arg = AF_FORMAT_S16_LE;
         return(TVI_CONTROL_TRUE);
         }
     case TVI_CONTROL_AUD_GET_CHANNELS:
--- a/libmpdemux/tvi_v4l.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpdemux/tvi_v4l.c	Mon Dec 27 17:30:15 2004 +0000
@@ -41,7 +41,7 @@
 #endif
 
 #include "mp_msg.h"
-#include "../libao2/afmt.h"
+#include "../libaf/af_format.h"
 #include "../libvo/img_format.h"
 #include "../libvo/fastmemcpy.h"
 #include "../libvo/videodev_mjpeg.h"
@@ -1285,7 +1285,7 @@
 	/* ========== AUDIO controls =========== */
 	case TVI_CONTROL_AUD_GET_FORMAT:
 	{
-	    *(int *)arg = AFMT_S16_LE;
+	    *(int *)arg = AF_FORMAT_S16_LE;
 	    return(TVI_CONTROL_TRUE);
 	}
 	case TVI_CONTROL_AUD_GET_CHANNELS:
--- a/libmpdemux/tvi_v4l2.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/libmpdemux/tvi_v4l2.c	Mon Dec 27 17:30:15 2004 +0000
@@ -43,7 +43,7 @@
 #include "videodev2.h"
 #include "../mp_msg.h"
 #include "../libvo/img_format.h"
-#include "../libao2/afmt.h"
+#include "../libaf/af_format.h"
 #include "tv.h"
 #include "audio_in.h"
 
@@ -731,7 +731,7 @@
 	}
 	return TVI_CONTROL_TRUE;
     case TVI_CONTROL_AUD_GET_FORMAT:
-	*(int *)arg = AFMT_S16_LE;
+	*(int *)arg = AF_FORMAT_S16_LE;
 	mp_msg(MSGT_TV, MSGL_V, "%s: get audio format: %d\n",
 	       info.short_name, *(int *)arg);
 	return TVI_CONTROL_TRUE;
--- a/mencoder.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/mencoder.c	Mon Dec 27 17:30:15 2004 +0000
@@ -54,7 +54,7 @@
 
 #include "libvo/video_out.h"
 
-#include "libao2/afmt.h"
+#include "libaf/af_format.h"
 
 #include "libmpcodecs/mp_image.h"
 #include "libmpcodecs/dec_audio.h"
@@ -809,7 +809,7 @@
         sh_audio->samplerate,
 	sh_audio->channels, sh_audio->sample_format, sh_audio->samplesize,
 	mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels,
-	(mux_a->wf->wBitsPerSample==8)?	AFMT_U8:AFMT_S16_LE,
+	(mux_a->wf->wBitsPerSample==8)?	AF_FORMAT_U8:AF_FORMAT_S16_LE,
 	mux_a->wf->wBitsPerSample/8,
 	16384, mux_a->wf->nAvgBytesPerSec)){
       mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_NoMatchingFilter);
@@ -842,11 +842,7 @@
         sh_audio->samplerate,
 	sh_audio->channels, sh_audio->sample_format, sh_audio->samplesize,
 	mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels,
-#ifdef WORDS_BIGENDIAN
-	AFMT_S16_BE, 2,
-#else
-	AFMT_S16_LE, 2,
-#endif
+	AF_FORMAT_S16_NE, 2,
 	4608, mux_a->h.dwRate*mux_a->wf->nChannels*2)){
       mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_NoMatchingFilter);
     }
@@ -983,7 +979,7 @@
 	sh_audio->samplerate, sh_audio->channels,
 	sh_audio->sample_format, sh_audio->samplesize,
 	mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels,
-	AFMT_S16_NE, 2,
+	AF_FORMAT_S16_NE, 2,
 	mux_a->h.dwSuggestedBufferSize,
 	mux_a->h.dwSuggestedBufferSize*2)) {
 	mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_NoMatchingFilter);
@@ -1048,7 +1044,7 @@
 	sh_audio->samplerate, sh_audio->channels,
 	sh_audio->sample_format, sh_audio->samplesize,
 	mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels,
-	AFMT_S16_NE, 2,
+	AF_FORMAT_S16_NE, 2,
 	mux_a->h.dwSuggestedBufferSize,
 	mux_a->h.dwSuggestedBufferSize*2)) {
 	mp_msg(MSGT_CPLAYER, MSGL_ERR, "Couldn't find matching filter / ao format!\n");
--- a/mplayer.c	Mon Dec 27 11:09:49 2004 +0000
+++ b/mplayer.c	Mon Dec 27 17:30:15 2004 +0000
@@ -942,7 +942,7 @@
   result =  init_audio_filters(sh_audio, new_srate,
            sh_audio->channels, sh_audio->sample_format, sh_audio->samplesize,
            ao_data->samplerate, ao_data->channels, ao_data->format,
-           audio_out_format_bits(ao_data->format) / 8, /* ao_data.bps, */
+           af_fmt2bits(ao_data->format) / 8, /* ao_data.bps, */
            ao_data->outburst * 4, ao_data->buffersize);
   mixer.afilter = sh_audio->afilter;
   return result;
@@ -2094,12 +2094,13 @@
 	sh_audio->channels, sh_audio->sample_format, sh_audio->samplesize,
 	// output:
 	&ao_data.samplerate, &ao_data.channels, &ao_data.format,
-	audio_out_format_bits(ao_data.format)/8)){
+	af_fmt2bits(ao_data.format)/8)){
       mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_AudioFilterChainPreinitError);
   } else {
+    char buf[128];
     mp_msg(MSGT_CPLAYER,MSGL_INFO,"AF_pre: %dHz %dch %s\n",
       ao_data.samplerate, ao_data.channels,
-      audio_out_format_name(ao_data.format));
+      af_fmt2str(ao_data.format,&buf,128));
   }
 #endif  
   current_module="ao2_init";
@@ -2114,12 +2115,13 @@
     sh_audio=d_audio->sh=NULL; // -> nosound
   } else {
     // SUCCESS:
+    char buf[128];
     inited_flags|=INITED_AO;
     mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %dHz %dch %s (%d bps)\n",
       audio_out->info->short_name,
       ao_data.samplerate, ao_data.channels,
-      audio_out_format_name(ao_data.format),
-      audio_out_format_bits(ao_data.format)/8 );
+      af_fmt2str(ao_data.format, &buf, 128),
+      af_fmt2bits(ao_data.format)/8 );
     mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Description: %s\nAO: Author: %s\n",
       audio_out->info->name, audio_out->info->author);
     if(strlen(audio_out->info->comment) > 0)