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 "native GSM/MSGSM audio decoder",
37 #include "native/xa_gsm.h"
39 static int init(sh_audio_t
*sh_audio
)
41 if(!sh_audio
->wf
) return 0;
42 // MS-GSM audio codec:
44 sh_audio
->channels
=sh_audio
->wf
->nChannels
;
45 sh_audio
->samplerate
=sh_audio
->wf
->nSamplesPerSec
;
46 sh_audio
->samplesize
=2;
47 // decodes 65 byte -> 320 short
48 // 1 sec: sh_audio->channels*sh_audio->samplerate samples
49 // 1 frame: 320 samples
50 if(sh_audio
->format
==0x31 || sh_audio
->format
==0x32){
51 sh_audio
->ds
->ss_mul
=65; sh_audio
->ds
->ss_div
=320;
53 sh_audio
->ds
->ss_mul
=33; sh_audio
->ds
->ss_div
=160;
55 sh_audio
->i_bps
=sh_audio
->ds
->ss_mul
*(sh_audio
->channels
*sh_audio
->samplerate
)/sh_audio
->ds
->ss_div
; // 1:10
59 static int preinit(sh_audio_t
*sh_audio
)
61 sh_audio
->audio_out_minsize
=4*320;
65 static void uninit(sh_audio_t
*sh
)
69 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
71 return CONTROL_UNKNOWN
;
74 static int decode_audio(sh_audio_t
*sh_audio
,unsigned char *buf
,int minlen
,int maxlen
)
76 if(sh_audio
->format
==0x31 || sh_audio
->format
==0x32){
77 unsigned char ibuf
[65]; // 65 bytes / frame
78 if(demux_read_data(sh_audio
->ds
,ibuf
,65)!=65) return -1; // EOF
79 XA_MSGSM_Decoder(ibuf
,(unsigned short *) buf
); // decodes 65 byte -> 320 short
82 unsigned char ibuf
[33]; // 33 bytes / frame
83 if(demux_read_data(sh_audio
->ds
,ibuf
,33)!=33) return -1; // EOF
84 XA_GSM_Decoder(ibuf
,(unsigned short *) buf
); // decodes 33 byte -> 160 short