annotate libmpcodecs/ad_msgsm.c @ 7282:b21e38a4fbec

links (found on xvid-dev list)
author michael
date Thu, 05 Sep 2002 09:38:06 +0000
parents 28677d779205
children 1578dc56a9ad
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 "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
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
31 sh_audio->i_bps=65*(sh_audio->channels*sh_audio->samplerate)/320; // 1:10
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
32 return 1;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
33 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
34
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
35 static int preinit(sh_audio_t *sh_audio)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
36 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
37 sh_audio->audio_out_minsize=4*320;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
38 return 1;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
39 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
40
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
41 static void uninit(sh_audio_t *sh)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
42 {
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 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
46 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
47 return CONTROL_UNKNOWN;
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 decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
51 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
52 unsigned char ibuf[65]; // 65 bytes / frame
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
53 if(demux_read_data(sh_audio->ds,ibuf,65)!=65) return -1; // EOF
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
54 XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
55 return 2*320;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
56 }