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.
24 #include "ad_internal.h"
26 static const ad_info_t info
=
28 "aLaw/uLaw audio decoder",
37 #include "native/alaw.h"
39 static int init(sh_audio_t
*sh_audio
)
41 /* aLaw audio codec:*/
42 if(!sh_audio
->wf
) return 0;
43 sh_audio
->channels
=sh_audio
->wf
->nChannels
;
44 sh_audio
->samplerate
=sh_audio
->wf
->nSamplesPerSec
;
45 sh_audio
->i_bps
=sh_audio
->channels
*sh_audio
->samplerate
;
46 sh_audio
->samplesize
=2;
50 static int preinit(sh_audio_t
*sh
)
52 sh
->audio_out_minsize
=2048;
53 sh
->ds
->ss_div
= 1; // 1 samples/packet
54 sh
->ds
->ss_mul
= sh
->wf
->nChannels
; // bytes/packet
58 static void uninit(sh_audio_t
*sh
)
62 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
67 case ADCTRL_SKIP_FRAME
:
70 demux_read_data(sh
->ds
,NULL
,skip
);
73 return CONTROL_UNKNOWN
;
75 return CONTROL_UNKNOWN
;
78 static int decode_audio(sh_audio_t
*sh_audio
,unsigned char *buf
,int minlen
,int maxlen
)
81 int l
=demux_read_data(sh_audio
->ds
,buf
,minlen
/2);
82 unsigned short *d
=(unsigned short *) buf
;
85 if(sh_audio
->format
==6 || sh_audio
->format
==0x77616C61){
87 while(l
>0){ --l
; d
[l
]=alaw2short
[s
[l
]]; }
90 while(l
>0){ --l
; d
[l
]=ulaw2short
[s
[l
]]; }