annotate libmpcodecs/ad_roqaudio.c @ 5438:607d437c1d9d

fixed new_chunk calculation at seeking (seeking not work yet) and added -nosound support
author arpi
date Sun, 31 Mar 2002 22:44:03 +0000
parents 978991a26bb0
children b3d1348b251f
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 #include "../roqav.h"
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;
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
25 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
26 return 1;
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
27 }
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
28
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
29 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
30 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
31 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
32 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
5422
978991a26bb0 fixed ibps
melanson
parents: 5349
diff changeset
33 sh_audio->i_bps = 44100;
5349
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
34
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
35 if ((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
36 (unsigned char *)malloc(sh_audio->audio_out_minsize / 2)) == NULL)
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
37 return 0;
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
38
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 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
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
5349
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
42 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
43 {
5349
80d11d6a5fca fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents: 5340
diff changeset
44 free(sh_audio->a_in_buffer);
5340
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
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
47 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
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!!!
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
50 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
51 }
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 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
54 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
55 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
56 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
57
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
58 /* 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
59 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
60 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
61 (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
62 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
63 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
64 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
65 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
66 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
67 }