[Mplayer-cvslog] CVS: main/libaf af_mp.c,1.3,1.4 af_mp.h,1.3,1.4

Arpi of Ize arpi at mplayerhq.hu
Sat Jan 18 18:31:37 CET 2003


Update of /cvsroot/mplayer/main/libaf
In directory mail:/var/tmp.root/cvs-serv7815

Modified Files:
	af_mp.c af_mp.h 
Log Message:
added af_format_encode() to convert sample format from libaf to mplayer (OSS)


Index: af_mp.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_mp.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- af_mp.c	14 Jan 2003 02:52:10 -0000	1.3
+++ af_mp.c	18 Jan 2003 17:31:22 -0000	1.4
@@ -41,3 +41,40 @@
   }
   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 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 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 AFMT_S16_LE; // shouldn't happen
+}
+

Index: af_mp.h
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_mp.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- af_mp.h	15 Jan 2003 11:16:29 -0000	1.3
+++ af_mp.h	18 Jan 2003 17:31:22 -0000	1.4
@@ -22,5 +22,6 @@
 
 /* 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__ */



More information about the MPlayer-cvslog mailing list