2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "ad_internal.h"
28 static const ad_info_t info
=
30 "Uncompressed DVD/VOB LPCM audio decoder",
39 static int init(sh_audio_t
*sh
)
43 if(sh
->codecdata_len
==3){
44 // we have LPCM header:
45 unsigned char h
=sh
->codecdata
[1];
48 case 0: sh
->samplerate
=48000;break;
49 case 1: sh
->samplerate
=96000;break;
50 case 2: sh
->samplerate
=44100;break;
51 case 3: sh
->samplerate
=32000;break;
53 switch ((h
>> 6) & 3) {
55 sh
->sample_format
= AF_FORMAT_S16_BE
;
59 mp_msg(MSGT_DECAUDIO
, MSGL_INFO
, MSGTR_SamplesWanted
);
60 sh
->i_bps
= sh
->channels
* sh
->samplerate
* 5 / 2;
62 sh
->sample_format
= AF_FORMAT_S24_BE
;
66 sh
->sample_format
= AF_FORMAT_S16_BE
;
73 sh
->sample_format
= AF_FORMAT_S16_BE
;
77 sh
->i_bps
= sh
->samplesize
* sh
->channels
* sh
->samplerate
;
81 static int preinit(sh_audio_t
*sh
)
83 sh
->audio_out_minsize
=2048;
87 static void uninit(sh_audio_t
*sh
)
91 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
96 case ADCTRL_SKIP_FRAME
:
99 demux_read_data(sh
->ds
,NULL
,skip
);
102 return CONTROL_UNKNOWN
;
105 static int decode_audio(sh_audio_t
*sh_audio
,unsigned char *buf
,int minlen
,int maxlen
)
108 if (sh_audio
->samplesize
== 3) {
109 if (((sh_audio
->codecdata
[1] >> 6) & 3) == 1) {
111 // not sure if the "& 0xf0" and "<< 4" are the right way around
112 // can somebody clarify?
113 for (j
= 0; j
< minlen
; j
+= 12) {
115 len
= demux_read_data(sh_audio
->ds
, tmp
, 10);
120 buf
[j
+ 2] = tmp
[8] & 0xf0;
124 buf
[j
+ 5] = tmp
[8] << 4;
128 buf
[j
+ 8] = tmp
[9] & 0xf0;
131 buf
[j
+ 10] = tmp
[7];
132 buf
[j
+ 11] = tmp
[9] << 4;
137 for (j
= 0; j
< minlen
; j
+= 12) {
139 len
= demux_read_data(sh_audio
->ds
, tmp
, 12);
152 buf
[j
+ 8] = tmp
[10];
155 buf
[j
+ 10] = tmp
[7];
156 buf
[j
+ 11] = tmp
[11];
161 len
=demux_read_data(sh_audio
->ds
,buf
,(minlen
+3)&(~3));