MAX_PCI_DEVICES 64 is not enough on my system (even though lspci only shows 25 device...
[mplayer/greg.git] / libmpcodecs / ad_msgsm.c
blobc558595656fb7b5457f19145cb7019a435f21a6a
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
5 #include "config.h"
6 #include "ad_internal.h"
8 static ad_info_t info =
10 "native GSM/MSGSM audio decoder",
11 "msgsm",
12 "A'rpi",
13 "XAnim",
17 LIBAD_EXTERN(msgsm)
19 #include "native/xa_gsm.h"
21 static int init(sh_audio_t *sh_audio)
23 if(!sh_audio->wf) return 0;
24 // MS-GSM audio codec:
25 GSM_Init();
26 sh_audio->channels=sh_audio->wf->nChannels;
27 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
28 sh_audio->samplesize=2;
29 // decodes 65 byte -> 320 short
30 // 1 sec: sh_audio->channels*sh_audio->samplerate samples
31 // 1 frame: 320 samples
32 if(sh_audio->format==0x31 || sh_audio->format==0x32){
33 sh_audio->ds->ss_mul=65; sh_audio->ds->ss_div=320;
34 } else {
35 sh_audio->ds->ss_mul=33; sh_audio->ds->ss_div=160;
37 sh_audio->i_bps=sh_audio->ds->ss_mul*(sh_audio->channels*sh_audio->samplerate)/sh_audio->ds->ss_div; // 1:10
38 return 1;
41 static int preinit(sh_audio_t *sh_audio)
43 sh_audio->audio_out_minsize=4*320;
44 return 1;
47 static void uninit(sh_audio_t *sh)
51 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
53 return CONTROL_UNKNOWN;
56 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
58 if(sh_audio->format==0x31 || sh_audio->format==0x32){
59 unsigned char ibuf[65]; // 65 bytes / frame
60 if(demux_read_data(sh_audio->ds,ibuf,65)!=65) return -1; // EOF
61 XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short
62 return 2*320;
63 } else {
64 unsigned char ibuf[33]; // 33 bytes / frame
65 if(demux_read_data(sh_audio->ds,ibuf,33)!=33) return -1; // EOF
66 XA_GSM_Decoder(ibuf,(unsigned short *) buf); // decodes 33 byte -> 160 short
67 return 2*160;