aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-05-08 23:41:13 +0000
committerGravatar reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-05-08 23:41:13 +0000
commit12744612d971f508fe99d51df2c2f09c12cd52a3 (patch)
tree3de32c4ee634b3d7f55fa599f765716f89a6a6c5
parent2a78342333311afe2d7d46080c0b1febee357aa4 (diff)
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12448 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libmpcodecs/ad_pcm.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/libmpcodecs/ad_pcm.c b/libmpcodecs/ad_pcm.c
index c249c5f0b4..aedcedf2fb 100644
--- a/libmpcodecs/ad_pcm.c
+++ b/libmpcodecs/ad_pcm.c
@@ -23,13 +23,23 @@ static int init(sh_audio_t *sh_audio)
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
switch(sh_audio->format){ /* hardware formats: */
+ 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 4: sh_audio->sample_format=AFMT_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 0x2000: sh_audio->sample_format=AFMT_AC3; */
case 0x736F7774: // 'twos'
+ sh_audio->sample_format=AFMT_S16_BE;
+ // intended fall-through
case 0x74776F73: // 'swot'
if(sh_audio->samplesize==1) sh_audio->sample_format=AFMT_S8;
// Uncomment this if twos audio is broken for you
@@ -74,17 +84,5 @@ static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int m
int len=sh_audio->channels*sh_audio->samplesize-1;
len=(minlen+len)&(~len); // sample align
len=demux_read_data(sh_audio->ds,buf,len);
-#ifdef WORDS_BIGENDIAN
- if(sh_audio->format!=0x736F7774){
-#else
- if(sh_audio->format==0x736F7774){ // "twos" is swapped byteorder
-#endif
- int j;
- for(j=0;j<len;j+=2){
- char x=buf[j];
- buf[j]=buf[j+1];
- buf[j+1]=x;
- }
- }
return len;
}