8 #include "ad_internal.h"
10 static ad_info_t info
=
12 "Uncompressed DVD/VOB LPCM audio decoder",
21 static int init(sh_audio_t
*sh
)
25 if(sh
->codecdata_len
==3){
26 // we have LPCM header:
27 unsigned char h
=sh
->codecdata
[1];
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;
35 switch ((h
>> 6) & 3) {
37 sh
->sample_format
= AF_FORMAT_S16_BE
;
41 mp_msg(MSGT_DECAUDIO
, MSGL_INFO
, MSGTR_SamplesWanted
);
42 sh
->i_bps
= sh
->channels
* sh
->samplerate
* 5 / 2;
44 sh
->sample_format
= AF_FORMAT_S24_BE
;
48 sh
->sample_format
= AF_FORMAT_S16_BE
;
55 sh
->sample_format
= AF_FORMAT_S16_BE
;
59 sh
->i_bps
= sh
->samplesize
* sh
->channels
* sh
->samplerate
;
63 static int preinit(sh_audio_t
*sh
)
65 sh
->audio_out_minsize
=2048;
69 static void uninit(sh_audio_t
*sh
)
73 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
78 case ADCTRL_SKIP_FRAME
:
81 demux_read_data(sh
->ds
,NULL
,skip
);
84 return CONTROL_UNKNOWN
;
87 static int decode_audio(sh_audio_t
*sh_audio
,unsigned char *buf
,int minlen
,int maxlen
)
90 if (sh_audio
->samplesize
== 3) {
91 if (((sh_audio
->codecdata
[1] >> 6) & 3) == 1) {
93 // not sure if the "& 0xf0" and "<< 4" are the right way around
94 // can somebody clarify?
95 for (j
= 0; j
< minlen
; j
+= 12) {
97 len
= demux_read_data(sh_audio
->ds
, tmp
, 10);
102 buf
[j
+ 2] = tmp
[8] & 0xf0;
106 buf
[j
+ 5] = tmp
[8] << 4;
110 buf
[j
+ 8] = tmp
[9] & 0xf0;
113 buf
[j
+ 10] = tmp
[7];
114 buf
[j
+ 11] = tmp
[9] << 4;
119 for (j
= 0; j
< minlen
; j
+= 12) {
121 len
= demux_read_data(sh_audio
->ds
, tmp
, 12);
134 buf
[j
+ 8] = tmp
[10];
137 buf
[j
+ 10] = tmp
[7];
138 buf
[j
+ 11] = tmp
[11];
143 len
=demux_read_data(sh_audio
->ds
,buf
,(minlen
+3)&(~3));