Mercurial > mplayer.hg
annotate libmpcodecs/ad_pcm.c @ 13970:948e8164f1d0
synced to 1.50
author | gabrov |
---|---|
date | Thu, 18 Nov 2004 16:29:33 +0000 |
parents | 0febef62023e |
children | efe58d68689e |
rev | line source |
---|---|
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
1 #include <stdio.h> |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
2 #include <stdlib.h> |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
3 #include <unistd.h> |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
4 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
5 #include "config.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
6 #include "ad_internal.h" |
12478 | 7 #include "../libaf/af_format.h" |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
8 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
9 static ad_info_t info = |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
10 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
11 "Uncompressed PCM audio decoder", |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
12 "pcm", |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
13 "Nick Kurshev", |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
14 "A'rpi", |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
15 "" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
16 }; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
17 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
18 LIBAD_EXTERN(pcm) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
19 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
20 static int init(sh_audio_t *sh_audio) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
21 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
22 WAVEFORMATEX *h=sh_audio->wf; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
23 sh_audio->i_bps=h->nAvgBytesPerSec; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
24 sh_audio->channels=h->nChannels; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
25 sh_audio->samplerate=h->nSamplesPerSec; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
26 sh_audio->samplesize=(h->wBitsPerSample+7)/8; |
12447
fde132f084ce
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
reimar
parents:
12080
diff
changeset
|
27 sh_audio->sample_format=AFMT_S16_LE; // default |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
28 switch(sh_audio->format){ /* hardware formats: */ |
12539 | 29 case 0x0: |
12447
fde132f084ce
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
reimar
parents:
12080
diff
changeset
|
30 case 0x1: // Microsoft PCM |
fde132f084ce
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
reimar
parents:
12080
diff
changeset
|
31 switch (sh_audio->samplesize) { |
fde132f084ce
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
reimar
parents:
12080
diff
changeset
|
32 case 1: sh_audio->sample_format=AFMT_U8; break; |
fde132f084ce
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
reimar
parents:
12080
diff
changeset
|
33 case 2: sh_audio->sample_format=AFMT_S16_LE; break; |
13553 | 34 case 3: sh_audio->sample_format=AFMT_S24_LE; break; |
12447
fde132f084ce
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
reimar
parents:
12080
diff
changeset
|
35 case 4: sh_audio->sample_format=AFMT_S32_LE; break; |
fde132f084ce
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
reimar
parents:
12080
diff
changeset
|
36 } |
fde132f084ce
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
reimar
parents:
12080
diff
changeset
|
37 break; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
38 case 0x6: sh_audio->sample_format=AFMT_A_LAW;break; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
39 case 0x7: sh_audio->sample_format=AFMT_MU_LAW;break; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
40 case 0x11: sh_audio->sample_format=AFMT_IMA_ADPCM;break; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
41 case 0x50: sh_audio->sample_format=AFMT_MPEG;break; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
42 /* case 0x2000: sh_audio->sample_format=AFMT_AC3; */ |
12498 | 43 case 0x20776172: // 'raw ' |
44 sh_audio->sample_format=AFMT_S16_BE; | |
45 if(sh_audio->samplesize==1) sh_audio->sample_format=AFMT_U8; | |
46 break; | |
8102 | 47 case 0x736F7774: // 'twos' |
12447
fde132f084ce
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
reimar
parents:
12080
diff
changeset
|
48 sh_audio->sample_format=AFMT_S16_BE; |
fde132f084ce
fix bigendian problems (left-right swapped 8bit pcms), add 32bit support
reimar
parents:
12080
diff
changeset
|
49 // intended fall-through |
8102 | 50 case 0x74776F73: // 'swot' |
51 if(sh_audio->samplesize==1) sh_audio->sample_format=AFMT_S8; | |
12080
1abbfe730adc
Revert my old twos fix, it seems to break more files than it fixed.
rtognimp
parents:
11548
diff
changeset
|
52 // Uncomment this if twos audio is broken for you |
1abbfe730adc
Revert my old twos fix, it seems to break more files than it fixed.
rtognimp
parents:
11548
diff
changeset
|
53 // (typically with movies made on sgi machines) |
1abbfe730adc
Revert my old twos fix, it seems to break more files than it fixed.
rtognimp
parents:
11548
diff
changeset
|
54 // This is just a workaround, the real bug is elsewhere |
1abbfe730adc
Revert my old twos fix, it seems to break more files than it fixed.
rtognimp
parents:
11548
diff
changeset
|
55 #if 0 |
11548 | 56 sh_audio->ds->ss_div= sh_audio->samplesize; |
57 sh_audio->ds->ss_mul= sh_audio->samplesize * sh_audio->channels; | |
12080
1abbfe730adc
Revert my old twos fix, it seems to break more files than it fixed.
rtognimp
parents:
11548
diff
changeset
|
58 #endif |
6233 | 59 break; |
5827
9907037223fb
bigendian fix - thx to Rogrio Brito <linuxconsult@yahoo.com.br>
arpi
parents:
5455
diff
changeset
|
60 default: if(sh_audio->samplesize!=2) sh_audio->sample_format=AFMT_U8; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
61 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
62 return 1; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
63 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
64 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
65 static int preinit(sh_audio_t *sh) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
66 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
67 sh->audio_out_minsize=2048; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
68 return 1; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
69 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
70 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
71 static void uninit(sh_audio_t *sh) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
72 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
73 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
74 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
75 static int control(sh_audio_t *sh,int cmd,void* arg, ...) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
76 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
77 int skip; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
78 switch(cmd) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
79 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
80 case ADCTRL_SKIP_FRAME: |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
81 skip=sh->i_bps/16; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
82 skip=skip&(~3); |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
83 demux_read_data(sh->ds,NULL,skip); |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
84 return CONTROL_TRUE; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
85 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
86 return CONTROL_UNKNOWN; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
87 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
88 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
89 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
90 { |
5455 | 91 int len=sh_audio->channels*sh_audio->samplesize-1; |
92 len=(minlen+len)&(~len); // sample align | |
93 len=demux_read_data(sh_audio->ds,buf,len); | |
94 return len; | |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
95 } |