annotate libmpcodecs/ad_msgsm.c @ 6588:12826366a806

more informal warning and also fixed a 10l bug. Patch by tibcu
author alex
date Fri, 28 Jun 2002 16:42:32 +0000
parents 5f4485862a72
children 28677d779205
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 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
10 "native MSGSM audio decoder",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
11 "msgsm",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
12 AFM_GSM,
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
13 "A'rpi",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
14 "XAnim",
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
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
18 LIBAD_EXTERN(msgsm)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
19
5603
5f4485862a72 native codecs files moved to libmpcodecs/native/
arpi
parents: 5345
diff changeset
20 #include "xa_gsm.h"
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
21
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
22 static int init(sh_audio_t *sh_audio)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
23 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
24 if(!sh_audio->wf) return 0;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
25 // MS-GSM audio codec:
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
26 GSM_Init();
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
27 sh_audio->channels=sh_audio->wf->nChannels;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
28 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
29 // decodes 65 byte -> 320 short
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
30 // 1 sec: sh_audio->channels*sh_audio->samplerate samples
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
31 // 1 frame: 320 samples
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
32 sh_audio->i_bps=65*(sh_audio->channels*sh_audio->samplerate)/320; // 1:10
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
33 return 1;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
34 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
35
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
36 static int preinit(sh_audio_t *sh_audio)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
37 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
38 sh_audio->audio_out_minsize=4*320;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
39 return 1;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
40 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
41
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
42 static void uninit(sh_audio_t *sh)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
43 {
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 int control(sh_audio_t *sh,int cmd,void* arg, ...)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
47 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
48 return CONTROL_UNKNOWN;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
49 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
50
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
51 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
52 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
53 unsigned char ibuf[65]; // 65 bytes / frame
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
54 if(demux_read_data(sh_audio->ds,ibuf,65)!=65) return -1; // EOF
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
55 XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
56 return 2*320;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
57 }