annotate libmpcodecs/ad_msgsm.c @ 9954:2615897d001d

also tdfxfb supports geometry
author attila
date Mon, 21 Apr 2003 07:53:55 +0000
parents 1578dc56a9ad
children 9d0b052c4f74
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
1 #include <stdio.h>
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
2 #include <stdlib.h>
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
3 #include <unistd.h>
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
4
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
5 #include "config.h"
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
6 #include "ad_internal.h"
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
7
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
8 static ad_info_t info =
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
9 {
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
10 "native GSM/MSGSM audio decoder",
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
11 "msgsm",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
12 "A'rpi",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
13 "XAnim",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
14 ""
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
15 };
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
16
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
17 LIBAD_EXTERN(msgsm)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
18
5603
5f4485862a72 native codecs files moved to libmpcodecs/native/
arpi
parents: 5345
diff changeset
19 #include "xa_gsm.h"
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
20
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
21 static int init(sh_audio_t *sh_audio)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
22 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
23 if(!sh_audio->wf) return 0;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
24 // MS-GSM audio codec:
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
25 GSM_Init();
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
26 sh_audio->channels=sh_audio->wf->nChannels;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
27 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
28 // decodes 65 byte -> 320 short
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
29 // 1 sec: sh_audio->channels*sh_audio->samplerate samples
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
30 // 1 frame: 320 samples
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
31 if(sh_audio->format==0x31 || sh_audio->format==0x32){
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
32 sh_audio->ds->ss_mul=65; sh_audio->ds->ss_div=320;
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
33 } else {
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
34 sh_audio->ds->ss_mul=33; sh_audio->ds->ss_div=160;
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
35 }
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
36 sh_audio->i_bps=sh_audio->ds->ss_mul*(sh_audio->channels*sh_audio->samplerate)/sh_audio->ds->ss_div; // 1:10
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
37 return 1;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
38 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
39
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
40 static int preinit(sh_audio_t *sh_audio)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
41 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
42 sh_audio->audio_out_minsize=4*320;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
43 return 1;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
44 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
45
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
46 static void uninit(sh_audio_t *sh)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
47 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
48 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
49
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
50 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
51 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
52 return CONTROL_UNKNOWN;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
53 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
54
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
55 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
56 {
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
57 if(sh_audio->format==0x31 || sh_audio->format==0x32){
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
58 unsigned char ibuf[65]; // 65 bytes / frame
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
59 if(demux_read_data(sh_audio->ds,ibuf,65)!=65) return -1; // EOF
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
60 XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
61 return 2*320;
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
62 } else {
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
63 unsigned char ibuf[33]; // 33 bytes / frame
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
64 if(demux_read_data(sh_audio->ds,ibuf,33)!=33) return -1; // EOF
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
65 XA_GSM_Decoder(ibuf,(unsigned short *) buf); // decodes 33 byte -> 160 short
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
66 return 2*160;
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
67 }
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
68 }