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.
25 #include "ad_internal.h"
27 static const ad_info_t info
=
29 "Uncompressed DVD/VOB LPCM audio decoder",
38 static int init(sh_audio_t
*sh
)
42 if(sh
->codecdata_len
==3){
43 // we have LPCM header:
44 unsigned char h
=sh
->codecdata
[1];
47 case 0: sh
->samplerate
=48000;break;
48 case 1: sh
->samplerate
=96000;break;
49 case 2: sh
->samplerate
=44100;break;
50 case 3: sh
->samplerate
=32000;break;
52 switch ((h
>> 6) & 3) {
54 sh
->sample_format
= AF_FORMAT_S16_BE
;
58 mp_tmsg(MSGT_DECAUDIO
, MSGL_INFO
, "Samples of this format are needed to improve support. Please contact the developers.\n");
59 sh
->i_bps
= sh
->channels
* sh
->samplerate
* 5 / 2;
61 sh
->sample_format
= AF_FORMAT_S24_BE
;
65 sh
->sample_format
= AF_FORMAT_S16_BE
;
72 sh
->sample_format
= AF_FORMAT_S16_BE
;
76 sh
->i_bps
= sh
->samplesize
* sh
->channels
* sh
->samplerate
;
80 static int preinit(sh_audio_t
*sh
)
82 sh
->audio_out_minsize
=2048;
86 static void uninit(sh_audio_t
*sh
)
90 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
95 case ADCTRL_SKIP_FRAME
:
98 demux_read_data(sh
->ds
,NULL
,skip
);
101 return CONTROL_UNKNOWN
;
104 static int decode_audio(sh_audio_t
*sh_audio
,unsigned char *buf
,int minlen
,int maxlen
)
107 if (sh_audio
->samplesize
== 3) {
108 if (((sh_audio
->codecdata
[1] >> 6) & 3) == 1) {
110 // not sure if the "& 0xf0" and "<< 4" are the right way around
111 // can somebody clarify?
112 for (j
= 0; j
< minlen
; j
+= 12) {
114 len
= demux_read_data(sh_audio
->ds
, tmp
, 10);
119 buf
[j
+ 2] = tmp
[8] & 0xf0;
123 buf
[j
+ 5] = tmp
[8] << 4;
127 buf
[j
+ 8] = tmp
[9] & 0xf0;
130 buf
[j
+ 10] = tmp
[7];
131 buf
[j
+ 11] = tmp
[9] << 4;
136 for (j
= 0; j
< minlen
; j
+= 12) {
138 len
= demux_read_data(sh_audio
->ds
, tmp
, 12);
151 buf
[j
+ 8] = tmp
[10];
154 buf
[j
+ 10] = tmp
[7];
155 buf
[j
+ 11] = tmp
[11];
160 len
=demux_read_data(sh_audio
->ds
,buf
,(minlen
+3)&(~3));