annotate libmpcodecs/ad_roqaudio.c @ 7016:44ce5a673be2

added gettimeofday-based profiling/timing little speedup of outline()
author arpi
date Thu, 15 Aug 2002 20:50:13 +0000
parents 5f4485862a72
children 28677d779205
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"
5603
5f4485862a72 native codecs files moved to libmpcodecs/native/
arpi
parents: 5458
diff changeset
7 #include "roqav.h"
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
8
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
9 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
10 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
11 "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
12 "roqaudio",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
13 AFM_ROQAUDIO,
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
14 "Nick Kurshev",
5349
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
15 "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
16 "RoQA is an internal MPlayer FOURCC"
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
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
19 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
20
5349
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
21 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
22 {
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
23 // 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
24 sh_audio->audio_out_minsize=sh_audio->wf->nBlockAlign;
5458
b3d1348b251f audio input buffer allocation/free cleanup
arpi
parents: 5422
diff changeset
25 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
26 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
27 return 1;
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
28 }
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
29
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
30 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
31 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
32 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
33 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
5422
978991a26bb0 fixed ibps
melanson
parents: 5349
diff changeset
34 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
35 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
36 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
37
5349
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
38 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
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 }
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 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
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 // TODO!!!
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
45 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
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
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
48 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
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 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
51 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
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 /* 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
54 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
55 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
56 (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
57 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
58 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
59 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
60 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
61 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
62 }