[MPlayer-dev-eng] [PATCH] make -format to work with -ao pcm:nowaveheader

Giacomo Comes comes at naic.edu
Wed Aug 9 16:48:04 CEST 2006


Currently if you use the option -ao pcm, the only format that can be selected for 
the saved pcm stream is u8 and s16le (default).
Tha attached patch make possible to extend the use of the option -format if you
use the option -ao pcm:nowaveheader
I'm not sure but it seems that the wav header do not provide a field to specify
the endianess of the pcm samples, so it is pointless to allow -format to work
with -ao pcm:waveheader (am I right?).

With the patch applied you can select for the raw pcm file: le/be, 16/24/32 bit
(this is what I have tested and seems to work).

Apart for making -format to work with -ao pcm:nowaveheader, the only other 
difference between the patched and unpatched mplayer is that if you use the option
-ao pcm:nowaveheader, without the patch the defaul format is s16le and with the 
patch it is s16be.
For this reason I output also the following info string:
[AO PCM] Info: Use -format to set the format of RAW PCM files (default: s16be)

Please apply if nobody complains.

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-09 10:06:46.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 (default: s16be)\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-09 10:05:31.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=(((format >> 3) & 7) + 1) * 8;
+	}
 
 	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