annotate libmpcodecs/ad_dk4adpcm.c @ 5549:7bed3fb6a3be

query_format debug moved 1 verbose level down
author arpi
date Wed, 10 Apr 2002 23:23:19 +0000
parents 8ae2bf330ad5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
1 #include <stdio.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
2 #include <stdlib.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
3 #include <unistd.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
4
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
5 #include "config.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
6 #include "ad_internal.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
7
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
8 static ad_info_t info =
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
9 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
10 "Duck DK4 ADPCM (rogue format number) audio decoder",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
11 "dk4adpcm",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
12 AFM_DK4ADPCM,
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
13 "Nick Kurshev",
5353
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
14 "Mike Melanson",
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
15 "This format number was used by Duck Corp. but not officially registered with Microsoft"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
16 };
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
17
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
18 LIBAD_EXTERN(dk4adpcm)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
19
5353
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
20 #define DK4_ADPCM_PREAMBLE_SIZE 4
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
21
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
22 static int preinit(sh_audio_t *sh_audio)
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
23 {
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
24 sh_audio->audio_out_minsize =
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
25 (((sh_audio->wf->nBlockAlign - DK4_ADPCM_PREAMBLE_SIZE) * 2) + 1) * 4;
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
26 sh_audio->ds->ss_div =
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
27 ((sh_audio->wf->nBlockAlign - DK4_ADPCM_PREAMBLE_SIZE) * 2) + 1;
5458
b3d1348b251f audio input buffer allocation/free cleanup
arpi
parents: 5353
diff changeset
28 sh_audio->audio_in_minsize=
5353
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
29 sh_audio->ds->ss_mul=sh_audio->wf->nBlockAlign;
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
30 return 1;
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
31 }
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
32
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
33 static int init(sh_audio_t *sh_audio)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
34 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
35 sh_audio->channels=sh_audio->wf->nChannels;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
36 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
37 sh_audio->i_bps = sh_audio->wf->nBlockAlign *
5353
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
38 (sh_audio->channels*sh_audio->samplerate) /
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
39 (((sh_audio->wf->nBlockAlign - DK4_ADPCM_PREAMBLE_SIZE) * 2) + 1);
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
40 return 1;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
41 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
42
5353
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
43 static void uninit(sh_audio_t *sh_audio)
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
44 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
45 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
46
5481
8ae2bf330ad5 control() done
arpi
parents: 5458
diff changeset
47 static int control(sh_audio_t *sh_audio,int cmd,void* arg, ...)
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
48 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
49 // TODO!
5481
8ae2bf330ad5 control() done
arpi
parents: 5458
diff changeset
50 if(cmd==ADCTRL_SKIP_FRAME){
8ae2bf330ad5 control() done
arpi
parents: 5458
diff changeset
51 demux_read_data(sh_audio->ds, sh_audio->a_in_buffer,sh_audio->wf->nBlockAlign);
8ae2bf330ad5 control() done
arpi
parents: 5458
diff changeset
52 return CONTROL_TRUE;
8ae2bf330ad5 control() done
arpi
parents: 5458
diff changeset
53 }
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
54 return CONTROL_UNKNOWN;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
55 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
56
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
57 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
58 {
5353
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
59 if (demux_read_data(sh_audio->ds, sh_audio->a_in_buffer,
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
60 sh_audio->wf->nBlockAlign) !=
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
61 sh_audio->wf->nBlockAlign)
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
62 return -1; /* EOF */
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
63
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
64 return 2 * dk4_adpcm_decode_block((unsigned short*)buf,
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
65 sh_audio->a_in_buffer,
a9f3df4ee465 fixed up this audio decoder too
melanson
parents: 5340
diff changeset
66 sh_audio->wf->nChannels, sh_audio->wf->nBlockAlign);
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
67 }