[MPlayer-dev-eng] [PATCH] add support for big-endian PCM output

Giacomo Comes comes at naic.edu
Wed Mar 21 19:42:26 CET 2007


On Wed, Mar 21, 2007 at 05:11:29PM +0000, Grant Edwards wrote:
> [I posted this to the mencoder-user list a while back. Judging
> by the lack of any sort of rsopnse that was the wrong forum.]
> 
> I needed to be able to encode to 16-bit uncompressed big-endian
> PCM.  I couldn't get either "-format sb16be" or "-af format=s16be" 
> to encode to big-endian format, so I gave up and added a "pcms"
> audio encoder that swaps the byte-order of the data stream.  In
> order to get lavf containers to label the stream correctly, I
> had to invent a new "wav" audio tag for big-endian PCM.
> 
> Although it works I have a feeling that this wasn't really the
> "right" way to do it.  If anybody would care to comment or
> suggest a better way to get big-endian PCM output please feel
> free to do so.
> 
> Anyway, the patch is available at 
> 
> http://www.visi.com/~grante/sansa/mplayer-1.0rc1-encode-bigendian-pcm.patch

I did create some time ago a patch that allow to use the option -format 
togheter with -ao pcm:nowaveheader.

The thread start here:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-August/045084.html

There was some discussion about the patch, but then it was totally forgotten.

I'm sending it again with the hope that this time it will be considered
(it still apply against current svn).

Could you use my (simpler) patch for your purpose?

Ciao
Giacomo
-------------- next part --------------
diff -Nraub mplayer.ori/help/help_mp-en.h mplayer/help/help_mp-en.h
--- mplayer.ori/help/help_mp-en.h	2006-08-07 10:13:55.000000000 -0400
+++ mplayer/help/help_mp-en.h	2006-08-14 14:11:55.000000000 -0400
@@ -1092,7 +1092,8 @@
 // This one desn't even  have any mp_msg nor printf's?? [CHECK]
 
 // ao_pcm.c
-#define MSGTR_AO_PCM_FileInfo "[AO PCM] File: %s (%s)\nPCM: Samplerate: %iHz Channels: %s Format %s\n"
+#define MSGTR_AO_PCM_FileInfo "[AO PCM] File: %s (%s)\nPCM: Samplerate: %iHz Channels: %s Format: %s\n"
+#define MSGTR_AO_PCM_RawInfo "[AO PCM] Info: Use -format to set the format of RAW PCM files\n"
 #define MSGTR_AO_PCM_HintInfo "[AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast\n[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).\n"
 #define MSGTR_AO_PCM_CantOpenOutputFile "[AO PCM] Failed to open %s for writing!\n"
 
diff -Nraub mplayer.ori/libao2/ao_pcm.c mplayer/libao2/ao_pcm.c
--- mplayer.ori/libao2/ao_pcm.c	2006-06-05 15:46:03.000000000 -0400
+++ mplayer/libao2/ao_pcm.c	2006-08-14 15:14:13.000000000 -0400
@@ -102,6 +102,7 @@
 	   this means that the following "if" is a kludge and should
 	   really be a switch to be correct in all cases */
 
+	if(ao_pcm_waveheader) {
 	bits=8;
 	switch(format){
 	case AF_FORMAT_S8:
@@ -113,6 +114,9 @@
 	    bits=16;
 	    break;
 	}
+	} else {
+            bits=af_fmt2bits(format);
+	}
 
 	ao_data.outburst = 65536;
 	ao_data.buffersize= 2*65536;
@@ -133,6 +137,8 @@
 	mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_FileInfo, ao_outputfilename, 
 	       (ao_pcm_waveheader?"WAVE":"RAW PCM"), rate, 
 	       (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format));
+	if(!ao_pcm_waveheader)
+	    mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_RawInfo);
 	mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_PCM_HintInfo);
 
 	fp = fopen(ao_outputfilename, "wb");


More information about the MPlayer-dev-eng mailing list