Mercurial > mplayer.hg
annotate libmpcodecs/ad_dvdpcm.c @ 13853:5a786c7e4df4
have each XviD's option flag have its (no)counterpart
author | gpoirier |
---|---|
date | Tue, 02 Nov 2004 17:22:24 +0000 |
parents | f67d20c01332 |
children | e0d400094e88 |
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" |
13236 | 9 #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
|
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 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
|
12 { |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
13 "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
|
14 "dvdpcm", |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
15 "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
|
16 "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
|
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 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
20 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
|
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 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
|
23 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
24 /* DVD PCM Audio:*/ |
13595
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
25 sh->i_bps = 0; |
7670 | 26 if(sh->codecdata_len==3){ |
27 // we have LPCM header: | |
28 unsigned char h=sh->codecdata[1]; | |
29 sh->channels=1+(h&7); | |
30 switch((h>>4)&3){ | |
31 case 0: sh->samplerate=48000;break; | |
32 case 1: sh->samplerate=96000;break; | |
33 case 2: sh->samplerate=44100;break; | |
34 case 3: sh->samplerate=32000;break; | |
35 } | |
13236 | 36 switch ((h >> 6) & 3) { |
37 case 0: | |
38 sh->sample_format = AFMT_S16_BE; | |
39 sh->samplesize = 2; | |
40 break; | |
13595
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
41 case 1: |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
42 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
|
43 sh->i_bps = sh->channels * sh->samplerate * 5 / 2; |
13236 | 44 case 2: |
45 sh->sample_format = AFMT_AF_FLAGS | AF_FORMAT_I | | |
46 AF_FORMAT_BE | AF_FORMAT_US; | |
47 sh->samplesize = 3; | |
48 break; | |
49 default: | |
50 sh->sample_format = AFMT_S16_BE; | |
51 sh->samplesize = 2; | |
52 } | |
7670 | 53 } else { |
54 // use defaults: | |
55 sh->channels=2; | |
56 sh->samplerate=48000; | |
13236 | 57 sh->sample_format = AFMT_S16_BE; |
58 sh->samplesize = 2; | |
7670 | 59 } |
13595
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
60 if (!sh->i_bps) |
13236 | 61 sh->i_bps = sh->samplesize * sh->channels * sh->samplerate; |
7670 | 62 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
|
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 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
91 int j,len; |
13595
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
92 if (sh_audio->samplesize == 3) { |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
93 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
|
94 // 20 bit |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
95 // 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
|
96 // can somebody clarify? |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
97 for (j = 0; j < minlen; j += 12) { |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
98 char tmp[10]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
99 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
|
100 if (len < 10) break; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
101 // first sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
102 buf[j + 0] = tmp[0]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
103 buf[j + 1] = tmp[1]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
104 buf[j + 2] = tmp[8] & 0xf0; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
105 // second sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
106 buf[j + 3] = tmp[2]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
107 buf[j + 4] = tmp[3]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
108 buf[j + 5] = tmp[8] << 4; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
109 // third sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
110 buf[j + 6] = tmp[4]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
111 buf[j + 7] = tmp[5]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
112 buf[j + 8] = tmp[9] & 0xf0; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
113 // fourth sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
114 buf[j + 9] = tmp[6]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
115 buf[j + 10] = tmp[7]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
116 buf[j + 11] = tmp[9] << 4; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
117 } |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
118 len = j; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
119 } else { |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
120 // 24 bit |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
121 for (j = 0; j < minlen; j += 12) { |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
122 char tmp[12]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
123 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
|
124 if (len < 12) break; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
125 // first sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
126 buf[j + 0] = tmp[0]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
127 buf[j + 1] = tmp[1]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
128 buf[j + 2] = tmp[8]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
129 // second sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
130 buf[j + 3] = tmp[2]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
131 buf[j + 4] = tmp[3]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
132 buf[j + 5] = tmp[9]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
133 // third sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
134 buf[j + 6] = tmp[4]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
135 buf[j + 7] = tmp[5]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
136 buf[j + 8] = tmp[10]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
137 // fourth sample |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
138 buf[j + 9] = tmp[6]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
139 buf[j + 10] = tmp[7]; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
140 buf[j + 11] = tmp[11]; |
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 len = j; |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
143 } |
f67d20c01332
Support for 24 bit and 20 bit LPCM (simple and slow :-( )
reimar
parents:
13236
diff
changeset
|
144 } 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
|
145 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
|
146 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
|
147 } |