comparison libmpcodecs/ad_imaadpcm.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 f9cd6381e327
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 #include "../adpcm.h"
9
10 static ad_info_t info =
11 {
12 "IMA ADPCM audio decoder",
13 "imaadpcm",
14 AFM_IMAADPCM,
15 "Nick Kurshev",
16 "Mike Melanson",
17 "ima4 (MOV files)"
18 };
19
20 LIBAD_EXTERN(imaadpcm)
21
22 static int init(sh_audio_t *sh_audio)
23 {
24 /* IMA-ADPCM 4:1 audio codec:*/
25 sh_audio->channels=sh_audio->wf->nChannels;
26 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
27 /* decodes 34 byte -> 64 short*/
28 sh_audio->i_bps=IMA_ADPCM_BLOCK_SIZE*(sh_audio->channels*sh_audio->samplerate)/
29 IMA_ADPCM_SAMPLES_PER_BLOCK; /* 1:4 */
30 return 1;
31 }
32
33 static int preinit(sh_audio_t *sh_audio)
34 {
35 sh_audio->audio_out_minsize=4096;
36 sh_audio->ds->ss_div=IMA_ADPCM_SAMPLES_PER_BLOCK;
37 sh_audio->ds->ss_mul=IMA_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels;
38 return 1;
39 }
40
41 static void uninit(sh_audio_t *sh)
42 {
43 }
44
45 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
46 {
47 // TODO!!!
48 return CONTROL_UNKNOWN;
49 }
50
51 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
52 {
53 unsigned char ibuf[IMA_ADPCM_BLOCK_SIZE * 2]; /* bytes / stereo frame */
54 if (demux_read_data(sh_audio->ds, ibuf,
55 IMA_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) !=
56 IMA_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels)
57 return -1;
58 return 2*ima_adpcm_decode_block((unsigned short*)buf,ibuf, sh_audio->wf->nChannels);
59 }