Mercurial > mplayer.hg
annotate libmpcodecs/ad_dvdpcm.c @ 21353:a965ca17debc
reordering of #include to avoid clash with math.h and quicktime/*.h, patch by Crhis Roccati<roccati@pobox.com>
author | nplourde |
---|---|
date | Tue, 28 Nov 2006 23:13:08 +0000 |
parents | 815f03b7cee5 |
children | 0f1b5b68af32 |
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" |
13595
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
6 #include "mp_msg.h" |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
7 #include "help_mp.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 #include "ad_internal.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
9 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
10 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
|
11 { |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
12 "Uncompressed DVD/VOB LPCM audio decoder", |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
13 "dvdpcm", |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
14 "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
|
15 "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
|
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 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
19 LIBAD_EXTERN(dvdpcm) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
20 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
21 static int init(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
|
22 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
23 /* DVD PCM Audio:*/ |
13595
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
24 sh->i_bps = 0; |
7670 | 25 if(sh->codecdata_len==3){ |
26 // we have LPCM header: | |
27 unsigned char h=sh->codecdata[1]; | |
28 sh->channels=1+(h&7); | |
29 switch((h>>4)&3){ | |
30 case 0: sh->samplerate=48000;break; | |
31 case 1: sh->samplerate=96000;break; | |
32 case 2: sh->samplerate=44100;break; | |
33 case 3: sh->samplerate=32000;break; | |
34 } | |
13236 | 35 switch ((h >> 6) & 3) { |
36 case 0: | |
14245 | 37 sh->sample_format = AF_FORMAT_S16_BE; |
13236 | 38 sh->samplesize = 2; |
39 break; | |
13595
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
40 case 1: |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
41 mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_SamplesWanted); |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
42 sh->i_bps = sh->channels * sh->samplerate * 5 / 2; |
13236 | 43 case 2: |
14245 | 44 sh->sample_format = AF_FORMAT_S24_BE; |
13236 | 45 sh->samplesize = 3; |
46 break; | |
47 default: | |
14245 | 48 sh->sample_format = AF_FORMAT_S16_BE; |
13236 | 49 sh->samplesize = 2; |
50 } | |
7670 | 51 } else { |
52 // use defaults: | |
53 sh->channels=2; | |
54 sh->samplerate=48000; | |
14245 | 55 sh->sample_format = AF_FORMAT_S16_BE; |
13236 | 56 sh->samplesize = 2; |
7670 | 57 } |
13595
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
58 if (!sh->i_bps) |
13236 | 59 sh->i_bps = sh->samplesize * sh->channels * sh->samplerate; |
7670 | 60 return 1; |
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 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
63 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
|
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 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
|
66 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
|
67 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
68 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
69 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
|
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 } |
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 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
|
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 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
|
76 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
|
77 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 } |
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_UNKNOWN; |
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 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
87 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
|
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 int j,len; |
13595
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
90 if (sh_audio->samplesize == 3) { |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
91 if (((sh_audio->codecdata[1] >> 6) & 3) == 1) { |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
92 // 20 bit |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
93 // not sure if the "& 0xf0" and "<< 4" are the right way around |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
94 // can somebody clarify? |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
95 for (j = 0; j < minlen; j += 12) { |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
96 char tmp[10]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
97 len = demux_read_data(sh_audio->ds, tmp, 10); |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
98 if (len < 10) break; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
99 // first sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
100 buf[j + 0] = tmp[0]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
101 buf[j + 1] = tmp[1]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
102 buf[j + 2] = tmp[8] & 0xf0; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
103 // second sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
104 buf[j + 3] = tmp[2]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
105 buf[j + 4] = tmp[3]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
106 buf[j + 5] = tmp[8] << 4; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
107 // third sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
108 buf[j + 6] = tmp[4]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
109 buf[j + 7] = tmp[5]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
110 buf[j + 8] = tmp[9] & 0xf0; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
111 // fourth sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
112 buf[j + 9] = tmp[6]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
113 buf[j + 10] = tmp[7]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
114 buf[j + 11] = tmp[9] << 4; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
115 } |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
116 len = j; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
117 } else { |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
118 // 24 bit |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
119 for (j = 0; j < minlen; j += 12) { |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
120 char tmp[12]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
121 len = demux_read_data(sh_audio->ds, tmp, 12); |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
122 if (len < 12) break; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
123 // first sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
124 buf[j + 0] = tmp[0]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
125 buf[j + 1] = tmp[1]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
126 buf[j + 2] = tmp[8]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
127 // second sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
128 buf[j + 3] = tmp[2]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
129 buf[j + 4] = tmp[3]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
130 buf[j + 5] = tmp[9]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
131 // third sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
132 buf[j + 6] = tmp[4]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
133 buf[j + 7] = tmp[5]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
134 buf[j + 8] = tmp[10]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
135 // fourth sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
136 buf[j + 9] = tmp[6]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
137 buf[j + 10] = tmp[7]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
138 buf[j + 11] = tmp[11]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
139 } |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
140 len = j; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
141 } |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
142 } else |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
143 len=demux_read_data(sh_audio->ds,buf,(minlen+3)&(~3)); |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
144 return len; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
145 } |