annotate libmpcodecs/ad_roqaudio.c @ 10141:7d6a854a5fe5

cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
author rfelker
date Tue, 20 May 2003 18:36:55 +0000
parents a117511790c0
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 "Id RoQ File 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 "roqaudio",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
12 "Nick Kurshev",
7191
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
13 "Mike Melanson",
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
14 "" //"RoQA is an internal MPlayer FOURCC"
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 };
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 LIBAD_EXTERN(roqaudio)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
18
7470
a117511790c0 declarations moved to *.c files
arpi
parents: 7191
diff changeset
19 // in native/roqav.c:
a117511790c0 declarations moved to *.c files
arpi
parents: 7191
diff changeset
20 void *roq_decode_audio_init(void);
a117511790c0 declarations moved to *.c files
arpi
parents: 7191
diff changeset
21 int roq_decode_audio(unsigned short *output, unsigned char *input,
a117511790c0 declarations moved to *.c files
arpi
parents: 7191
diff changeset
22 int encoded_size, int channels, void *context);
a117511790c0 declarations moved to *.c files
arpi
parents: 7191
diff changeset
23
5349
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
24 static int preinit(sh_audio_t *sh_audio)
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
25 {
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
26 // minsize was stored in wf->nBlockAlign by the RoQ demuxer
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
27 sh_audio->audio_out_minsize=sh_audio->wf->nBlockAlign;
5458
b3d1348b251f audio input buffer allocation/free cleanup
arpi
parents: 5422
diff changeset
28 sh_audio->audio_in_minsize=sh_audio->audio_out_minsize / 2; // FIXME?
5349
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
29 sh_audio->context = roq_decode_audio_init();
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
30 return 1;
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
31 }
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
32
5340
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;
5422
978991a26bb0 fixed ibps
melanson
parents: 5349
diff changeset
37 sh_audio->i_bps = 44100;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
38 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
39 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
40
5349
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
41 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
42 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
43 }
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 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
46 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
47 // TODO!!!
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
48 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
49 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
50
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
51 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
52 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
53 unsigned char header_data[6];
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
54 int read_len;
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 /* figure out how much data to read */
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
57 if (demux_read_data(sh_audio->ds, header_data, 6) != 6) return -1; /* EOF */
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
58 read_len = (header_data[5] << 24) | (header_data[4] << 16) |
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
59 (header_data[3] << 8) | header_data[2];
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
60 read_len += 2; /* 16-bit arguments */
5349
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
61 if (demux_read_data(sh_audio->ds, sh_audio->a_in_buffer, read_len) !=
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
62 read_len) return -1;
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
63 return 2 * roq_decode_audio((unsigned short *)buf, sh_audio->a_in_buffer,
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
64 read_len, sh_audio->channels, sh_audio->context);
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
65 }