Mercurial > mplayer.hg
comparison libmpcodecs/ad_msadpcm.c @ 5340:0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
author | arpi |
---|---|
date | Mon, 25 Mar 2002 21:06:01 +0000 |
parents | |
children | d59e27f2f5be |
comparison
equal
deleted
inserted
replaced
5339:e72d8e3955ea | 5340:0f12fb7c1c5d |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <unistd.h> | |
4 | |
5 #include "config.h" | |
6 #include "ad_internal.h" | |
7 | |
8 static ad_info_t info = | |
9 { | |
10 "MS ADPCM audio decoder", | |
11 "msadpcm", | |
12 AFM_MSADPCM, | |
13 "Nick Kurshev", | |
14 "Mike Melanson", | |
15 "" | |
16 }; | |
17 | |
18 LIBAD_EXTERN(msadpcm) | |
19 | |
20 #include "../adpcm.h" | |
21 | |
22 static int init(sh_audio_t *sh_audio) | |
23 { | |
24 sh_audio->channels=sh_audio->wf->nChannels; | |
25 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
26 sh_audio->i_bps = sh_audio->wf->nBlockAlign * | |
27 (sh_audio->channels*sh_audio->samplerate) / MS_ADPCM_SAMPLES_PER_BLOCK; | |
28 return 1; | |
29 } | |
30 | |
31 static int preinit(sh_audio_t *sh_audio) | |
32 { | |
33 sh_audio->audio_out_minsize=sh_audio->wf->nBlockAlign * 8; | |
34 sh_audio->ds->ss_div = MS_ADPCM_SAMPLES_PER_BLOCK; | |
35 sh_audio->ds->ss_mul = sh_audio->wf->nBlockAlign; | |
36 return 1; | |
37 } | |
38 | |
39 static void uninit(sh_audio_t *sh) | |
40 { | |
41 } | |
42 | |
43 static int control(sh_audio_t *sh,int cmd,void* arg, ...) | |
44 { | |
45 // TODO!!! | |
46 return CONTROL_UNKNOWN; | |
47 } | |
48 | |
49 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) | |
50 { | |
51 static unsigned char *ibuf = NULL; // FIXME!!! TODO!!! use sh->a_in_buffer! | |
52 if (!ibuf) | |
53 ibuf = (unsigned char *)malloc | |
54 (sh_audio->wf->nBlockAlign * sh_audio->wf->nChannels); | |
55 if (demux_read_data(sh_audio->ds, ibuf, | |
56 sh_audio->wf->nBlockAlign) != | |
57 sh_audio->wf->nBlockAlign) | |
58 return -1; /* EOF */ | |
59 return 2 * ms_adpcm_decode_block( | |
60 (unsigned short*)buf,ibuf, sh_audio->wf->nChannels, | |
61 sh_audio->wf->nBlockAlign); | |
62 } |