annotate src/alac/demux.c @ 848:2452835bbfcf trunk

[svn] - make "stop after current song" work. - now cuesheet plugin handles the end of file nicely. - improve reliability.
author yaz
date Tue, 13 Mar 2007 09:37:27 -0700
parents 74df3bd6f472
children 799b321bd9bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
1 /*
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
2 * ALAC (Apple Lossless Audio Codec) decoder
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
3 * Copyright (c) 2005 David Hammerton
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
4 * All rights reserved.
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
5 *
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
6 * This is the quicktime container demuxer.
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
7 *
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
8 * http://crazney.net/programs/itunes/alac.html
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
9 *
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
10 * Permission is hereby granted, free of charge, to any person
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
11 * obtaining a copy of this software and associated documentation
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
12 * files (the "Software"), to deal in the Software without
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
13 * restriction, including without limitation the rights to use,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
14 * copy, modify, merge, publish, distribute, sublicense, and/or
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
15 * sell copies of the Software, and to permit persons to whom the
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
16 * Software is furnished to do so, subject to the following conditions:
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
17 *
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
18 * The above copyright notice and this permission notice shall be
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
19 * included in all copies or substantial portions of the Software.
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
20 *
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
28 * OTHER DEALINGS IN THE SOFTWARE.
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
29 *
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
30 */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
31
330
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 85
diff changeset
32 #include "config.h"
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
33
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
34 #include <string.h>
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
35 #include <stdio.h>
330
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 85
diff changeset
36
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 85
diff changeset
37 #if HAVE_STDINT_H
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 85
diff changeset
38 # include <stdint.h>
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 85
diff changeset
39 #else
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 85
diff changeset
40 # if HAVE_INTTYPES_H
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 85
diff changeset
41 # include <inttypes.h>
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 85
diff changeset
42 # endif
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 85
diff changeset
43 #endif
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 85
diff changeset
44
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
45 #include <stdlib.h>
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
46
78
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
47 #include <glib.h>
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
48
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
49 #include "stream.h"
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
50 #include "demux.h"
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
51
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
52 typedef struct
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
53 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
54 stream_t *stream;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
55 demux_res_t *res;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
56 long saved_mdat_pos;
84
fa9e4ed85309 [svn] - try this
nenolod
parents: 80
diff changeset
57 int isfilenotalac;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
58 } qtmovie_t;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
59
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
60
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
61 /* chunk handlers */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
62 static void read_chunk_ftyp(qtmovie_t *qtmovie, size_t chunk_len)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
63 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
64 fourcc_t type;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
65 uint32_t minor_ver;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
66 size_t size_remaining = chunk_len - 8; /* FIXME: can't hardcode 8, size may be 64bit */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
67
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
68 type = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
69 size_remaining-=4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
70 if (type != MAKEFOURCC('M','4','A',' '))
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
71 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
72 return;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
73 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
74 minor_ver = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
75 size_remaining-=4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
76
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
77 /* compatible brands */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
78 while (size_remaining)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
79 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
80 /* unused */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
81 /*fourcc_t cbrand =*/ stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
82 size_remaining-=4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
83 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
84 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
85
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
86 static void read_chunk_tkhd(qtmovie_t *qtmovie, size_t chunk_len)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
87 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
88 /* don't need anything from here atm, skip */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
89 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
90
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
91 stream_skip(qtmovie->stream, size_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
92 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
93
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
94 static void read_chunk_mdhd(qtmovie_t *qtmovie, size_t chunk_len)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
95 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
96 /* don't need anything from here atm, skip */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
97 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
98
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
99 stream_skip(qtmovie->stream, size_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
100 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
101
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
102 static void read_chunk_edts(qtmovie_t *qtmovie, size_t chunk_len)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
103 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
104 /* don't need anything from here atm, skip */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
105 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
106
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
107 stream_skip(qtmovie->stream, size_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
108 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
109
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
110 static void read_chunk_elst(qtmovie_t *qtmovie, size_t chunk_len)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
111 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
112 /* don't need anything from here atm, skip */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
113 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
114
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
115 stream_skip(qtmovie->stream, size_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
116 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
117
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
118 /* media handler inside mdia */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
119 static void read_chunk_hdlr(qtmovie_t *qtmovie, size_t chunk_len)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
120 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
121 fourcc_t comptype, compsubtype;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
122 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
123
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
124 int strlen;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
125 char str[256] = {0};
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
126
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
127 /* version */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
128 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
129 size_remaining -= 1;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
130 /* flags */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
131 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
132 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
133 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
134 size_remaining -= 3;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
135
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
136 /* component type */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
137 comptype = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
138 compsubtype = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
139 size_remaining -= 8;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
140
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
141 /* component manufacturer */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
142 stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
143 size_remaining -= 4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
144
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
145 /* flags */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
146 stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
147 stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
148 size_remaining -= 8;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
149
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
150 /* name */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
151 strlen = stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
152 stream_read(qtmovie->stream, strlen, str);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
153 size_remaining -= 1 + strlen;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
154
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
155 if (size_remaining)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
156 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
157 stream_skip(qtmovie->stream, size_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
158 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
159
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
160 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
161
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
162 static int read_chunk_stsd(qtmovie_t *qtmovie, size_t chunk_len)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
163 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
164 unsigned int i;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
165 uint32_t numentries;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
166 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
167
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
168 /* version */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
169 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
170 size_remaining -= 1;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
171 /* flags */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
172 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
173 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
174 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
175 size_remaining -= 3;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
176
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
177 numentries = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
178 size_remaining -= 4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
179
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
180 if (numentries != 1)
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
181 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
182
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
183 for (i = 0; i < numentries; i++)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
184 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
185 uint32_t entry_size;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
186 uint16_t version;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
187
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
188 uint32_t entry_remaining;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
189
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
190 entry_size = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
191 qtmovie->res->format = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
192 entry_remaining = entry_size;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
193 entry_remaining -= 8;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
194
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
195 /* sound info: */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
196
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
197 stream_skip(qtmovie->stream, 6); /* reserved */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
198 entry_remaining -= 6;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
199
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
200 version = stream_read_uint16(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
201 if (version != 1)
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
202 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
203 entry_remaining -= 2;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
204
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
205 /* revision level */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
206 stream_read_uint16(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
207 /* vendor */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
208 stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
209 entry_remaining -= 6;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
210
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
211 /* EH?? spec doesn't say theres an extra 16 bits here.. but there is! */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
212 stream_read_uint16(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
213 entry_remaining -= 2;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
214
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
215 qtmovie->res->num_channels = stream_read_uint16(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
216
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
217 qtmovie->res->sample_size = stream_read_uint16(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
218 entry_remaining -= 4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
219
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
220 /* compression id */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
221 stream_read_uint16(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
222 /* packet size */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
223 stream_read_uint16(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
224 entry_remaining -= 4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
225
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
226 /* sample rate - 32bit fixed point = 16bit?? */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
227 qtmovie->res->sample_rate = stream_read_uint16(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
228 entry_remaining -= 2;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
229
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
230 /* skip 2 */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
231 stream_skip(qtmovie->stream, 2);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
232 entry_remaining -= 2;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
233
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
234 /* remaining is codec data */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
235
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
236 /* 12 = audio format atom, 8 = padding */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
237 qtmovie->res->codecdata_len = entry_remaining + 12 + 8;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
238 qtmovie->res->codecdata = malloc(qtmovie->res->codecdata_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
239 memset(qtmovie->res->codecdata, 0, qtmovie->res->codecdata_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
240 /* audio format atom */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
241 ((unsigned int*)qtmovie->res->codecdata)[0] = 0x0c000000;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
242 ((unsigned int*)qtmovie->res->codecdata)[1] = MAKEFOURCC('a','m','r','f');
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
243 ((unsigned int*)qtmovie->res->codecdata)[2] = MAKEFOURCC('c','a','l','a');
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
244
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
245 stream_read(qtmovie->stream,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
246 entry_remaining,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
247 ((char*)qtmovie->res->codecdata) + 12);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
248 entry_remaining -= entry_remaining;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
249
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
250 if (entry_remaining)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
251 stream_skip(qtmovie->stream, entry_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
252
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
253 qtmovie->res->format_read = 1;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
254 if (qtmovie->res->format != MAKEFOURCC('a','l','a','c'))
84
fa9e4ed85309 [svn] - try this
nenolod
parents: 80
diff changeset
255 {
fa9e4ed85309 [svn] - try this
nenolod
parents: 80
diff changeset
256 qtmovie->isfilenotalac = 1;
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
257 return 0;
84
fa9e4ed85309 [svn] - try this
nenolod
parents: 80
diff changeset
258 }
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
259 }
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
260
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
261 return 1;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
262 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
263
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
264 static void read_chunk_stts(qtmovie_t *qtmovie, size_t chunk_len)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
265 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
266 unsigned int i;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
267 uint32_t numentries;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
268 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
269
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
270 /* version */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
271 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
272 size_remaining -= 1;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
273 /* flags */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
274 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
275 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
276 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
277 size_remaining -= 3;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
278
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
279 numentries = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
280 size_remaining -= 4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
281
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
282 qtmovie->res->num_time_to_samples = numentries;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
283 qtmovie->res->time_to_sample = malloc(numentries * sizeof(*qtmovie->res->time_to_sample));
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
284
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
285 for (i = 0; i < numentries; i++)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
286 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
287 qtmovie->res->time_to_sample[i].sample_count = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
288 qtmovie->res->time_to_sample[i].sample_duration = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
289 size_remaining -= 8;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
290 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
291
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
292 if (size_remaining)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
293 stream_skip(qtmovie->stream, size_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
294 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
295
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
296 static void read_chunk_stsz(qtmovie_t *qtmovie, size_t chunk_len)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
297 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
298 unsigned int i;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
299 uint32_t numentries;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
300 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
301
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
302 /* version */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
303 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
304 size_remaining -= 1;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
305 /* flags */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
306 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
307 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
308 stream_read_uint8(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
309 size_remaining -= 3;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
310
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
311 /* default sample size */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
312 if (stream_read_uint32(qtmovie->stream) != 0)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
313 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
314 stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
315 size_remaining -= 4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
316 return;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
317 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
318 size_remaining -= 4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
319
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
320 numentries = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
321 size_remaining -= 4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
322
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
323 qtmovie->res->num_sample_byte_sizes = numentries;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
324 qtmovie->res->sample_byte_size = malloc(numentries * sizeof(*qtmovie->res->sample_byte_size));
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
325
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
326 for (i = 0; i < numentries; i++)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
327 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
328 qtmovie->res->sample_byte_size[i] = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
329 size_remaining -= 4;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
330 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
331
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
332 if (size_remaining)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
333 stream_skip(qtmovie->stream, size_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
334 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
335
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
336 static int read_chunk_stbl(qtmovie_t *qtmovie, size_t chunk_len)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
337 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
338 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
339
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
340 while (size_remaining)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
341 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
342 size_t sub_chunk_len;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
343 fourcc_t sub_chunk_id;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
344
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
345 sub_chunk_len = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
346 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
347 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
348
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
349 sub_chunk_id = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
350
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
351 switch (sub_chunk_id)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
352 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
353 case MAKEFOURCC('s','t','s','d'):
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
354 if (read_chunk_stsd(qtmovie, sub_chunk_len) == 0)
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
355 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
356 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
357 case MAKEFOURCC('s','t','t','s'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
358 read_chunk_stts(qtmovie, sub_chunk_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
359 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
360 case MAKEFOURCC('s','t','s','z'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
361 read_chunk_stsz(qtmovie, sub_chunk_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
362 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
363 case MAKEFOURCC('s','t','s','c'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
364 case MAKEFOURCC('s','t','c','o'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
365 /* skip these, no indexing for us! */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
366 stream_skip(qtmovie->stream, sub_chunk_len - 8);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
367 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
368 default:
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
369 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
370 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
371
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
372 size_remaining -= sub_chunk_len;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
373 }
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
374
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
375 return 1;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
376 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
377
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
378 static int read_chunk_minf(qtmovie_t *qtmovie, size_t chunk_len)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
379 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
380 size_t dinf_size, stbl_size;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
381 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
382
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
383 if (stream_read_uint32(qtmovie->stream) != 16)
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
384 return 0;
67
41e2dc106f4e [svn] - remove spurious debugging notices
nenolod
parents: 56
diff changeset
385
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
386 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','m','h','d'))
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
387 return 0;
67
41e2dc106f4e [svn] - remove spurious debugging notices
nenolod
parents: 56
diff changeset
388
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
389 /* now skip the rest */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
390 stream_skip(qtmovie->stream, 16 - 8);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
391 size_remaining -= 16;
67
41e2dc106f4e [svn] - remove spurious debugging notices
nenolod
parents: 56
diff changeset
392
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
393
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
394 /**** DINF CHUNK ****/
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
395 dinf_size = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
396 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('d','i','n','f'))
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
397 return 0;
67
41e2dc106f4e [svn] - remove spurious debugging notices
nenolod
parents: 56
diff changeset
398
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
399 /* skip it */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
400 stream_skip(qtmovie->stream, dinf_size - 8);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
401 size_remaining -= dinf_size;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
402 /****/
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
403
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
404
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
405 /**** SAMPLE TABLE ****/
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
406 stbl_size = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
407 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','t','b','l'))
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
408 return 0;
67
41e2dc106f4e [svn] - remove spurious debugging notices
nenolod
parents: 56
diff changeset
409
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
410 if (read_chunk_stbl(qtmovie, stbl_size) == 0)
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
411 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
412 size_remaining -= stbl_size;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
413
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
414 if (size_remaining)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
415 stream_skip(qtmovie->stream, size_remaining);
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
416
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
417 return 1;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
418 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
419
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
420 static int read_chunk_mdia(qtmovie_t *qtmovie, size_t chunk_len)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
421 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
422 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
423
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
424 while (size_remaining)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
425 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
426 size_t sub_chunk_len;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
427 fourcc_t sub_chunk_id;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
428
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
429 sub_chunk_len = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
430 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
431 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
432
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
433 sub_chunk_id = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
434
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
435 switch (sub_chunk_id)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
436 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
437 case MAKEFOURCC('m','d','h','d'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
438 read_chunk_mdhd(qtmovie, sub_chunk_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
439 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
440 case MAKEFOURCC('h','d','l','r'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
441 read_chunk_hdlr(qtmovie, sub_chunk_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
442 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
443 case MAKEFOURCC('m','i','n','f'):
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
444 if (read_chunk_minf(qtmovie, sub_chunk_len) == 0)
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
445 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
446 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
447 default:
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
448 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
449 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
450
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
451 size_remaining -= sub_chunk_len;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
452 }
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
453
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
454 return 1;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
455 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
456
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
457 /* 'trak' - a movie track - contains other atoms */
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
458 static int read_chunk_trak(qtmovie_t *qtmovie, size_t chunk_len)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
459 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
460 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
461
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
462 while (size_remaining)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
463 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
464 size_t sub_chunk_len;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
465 fourcc_t sub_chunk_id;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
466
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
467 sub_chunk_len = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
468 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
469 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
470
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
471 sub_chunk_id = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
472
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
473 switch (sub_chunk_id)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
474 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
475 case MAKEFOURCC('t','k','h','d'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
476 read_chunk_tkhd(qtmovie, sub_chunk_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
477 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
478 case MAKEFOURCC('m','d','i','a'):
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
479 if (read_chunk_mdia(qtmovie, sub_chunk_len) == 0)
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
480 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
481 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
482 case MAKEFOURCC('e','d','t','s'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
483 read_chunk_edts(qtmovie, sub_chunk_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
484 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
485 default:
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
486 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
487 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
488
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
489 size_remaining -= sub_chunk_len;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
490 }
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
491
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
492 return 1;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
493 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
494
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
495 /* 'mvhd' movie header atom */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
496 static void read_chunk_mvhd(qtmovie_t *qtmovie, size_t chunk_len)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
497 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
498 /* don't need anything from here atm, skip */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
499 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
500
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
501 stream_skip(qtmovie->stream, size_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
502 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
503
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
504 /* 'iods' */
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
505 static void read_chunk_iods(qtmovie_t *qtmovie, size_t chunk_len)
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
506 {
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
507 /* don't need anything from here atm, skip */
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
508 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
509
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
510 stream_skip(qtmovie->stream, size_remaining);
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
511 }
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
512
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
513 enum
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
514 {
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
515 UDTA_NIL = 0,
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
516 UDTA_NAM,
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
517 UDTA_ART,
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
518 UDTA_ALB,
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
519 UDTA_GEN,
80
c312e5c852ac [svn] - parse comments
nenolod
parents: 79
diff changeset
520 UDTA_DAY,
c312e5c852ac [svn] - parse comments
nenolod
parents: 79
diff changeset
521 UDTA_CMT,
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
522 };
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
523
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
524 /* 'udta' user data.. contains tag info. this routine is utterly fucked because Apple's
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
525 * lovely container format is utterly fucked itself...
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
526 */
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
527 void read_chunk_udta(qtmovie_t *qtmovie, size_t chunk_len)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
528 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
529 /* don't need anything from here atm, skip */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
530 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
531 char *buf = g_malloc0(chunk_len);
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
532 char *bptr;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
533 fourcc_t sub_chunk_id; /* bptr[4] << 24 | bptr[3] << 16 | bptr[2] << 8 | bptr[1] */
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
534 int udta_tgt = UDTA_NIL;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
535
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
536 /* read the stream in for scanning -nenolod */
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
537 stream_read(qtmovie->stream, size_remaining, buf);
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
538
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
539 /* this is (bptr + 3) to account for the MAKEFOURCC() macro. -nenolod */
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
540 for (bptr = buf; (bptr + 3) - buf < size_remaining; bptr++)
78
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
541 {
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
542 sub_chunk_id = MAKEFOURCC(*bptr, *(bptr + 1), *(bptr + 2), *(bptr + 3));
78
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
543
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
544 switch (sub_chunk_id)
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
545 {
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
546 case MAKEFOURCC('m','e','t','a'):
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
547 bptr += 4; /* skip meta */
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
548 break;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
549 case MAKEFOURCC(0xA9,'n','a','m'):
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
550 udta_tgt = UDTA_NAM;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
551 bptr += 4;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
552 break;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
553 case MAKEFOURCC(0xA9,'A','R','T'):
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
554 udta_tgt = UDTA_ART;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
555 bptr += 4;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
556 break;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
557 case MAKEFOURCC(0xA9,'a','l','b'):
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
558 udta_tgt = UDTA_ALB;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
559 bptr += 4;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
560 break;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
561 case MAKEFOURCC(0xA9,'g','e','n'):
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
562 udta_tgt = UDTA_GEN;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
563 bptr += 4;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
564 break;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
565 case MAKEFOURCC(0xA9,'d','a','y'):
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
566 udta_tgt = UDTA_DAY;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
567 bptr += 4;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
568 break;
80
c312e5c852ac [svn] - parse comments
nenolod
parents: 79
diff changeset
569 case MAKEFOURCC(0xA9,'c','m','t'):
c312e5c852ac [svn] - parse comments
nenolod
parents: 79
diff changeset
570 udta_tgt = UDTA_CMT;
c312e5c852ac [svn] - parse comments
nenolod
parents: 79
diff changeset
571 bptr += 4;
c312e5c852ac [svn] - parse comments
nenolod
parents: 79
diff changeset
572 break;
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
573 case MAKEFOURCC('d','a','t','a'):
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
574 switch(udta_tgt)
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
575 {
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
576 case UDTA_NAM:
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
577 qtmovie->res->tuple.nam = g_strdup(bptr + 12);
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
578 break;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
579 case UDTA_ART:
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
580 qtmovie->res->tuple.art = g_strdup(bptr + 12);
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
581 break;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
582 case UDTA_ALB:
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
583 qtmovie->res->tuple.alb = g_strdup(bptr + 12);
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
584 break;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
585 case UDTA_DAY:
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
586 qtmovie->res->tuple.day = g_strdup(bptr + 12);
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
587 break;
80
c312e5c852ac [svn] - parse comments
nenolod
parents: 79
diff changeset
588 case UDTA_CMT:
c312e5c852ac [svn] - parse comments
nenolod
parents: 79
diff changeset
589 qtmovie->res->tuple.cmt = g_strdup(bptr + 12);
c312e5c852ac [svn] - parse comments
nenolod
parents: 79
diff changeset
590 break;
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
591 case UDTA_GEN:
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
592 qtmovie->res->tuple.gen = g_strdup(bptr + 12);
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
593 break;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
594 default:
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
595 break;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
596 }
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
597
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
598 bptr += 12;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
599 bptr += strlen(bptr);
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
600 break;
78
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
601 default:
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
602 break;
78
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
603 }
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
604 }
78
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
605
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
606 g_free(buf);
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
607 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
608
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
609 /* 'moov' movie atom - contains other atoms */
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
610 static int read_chunk_moov(qtmovie_t *qtmovie, size_t chunk_len)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
611 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
612 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
613
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
614 while (size_remaining)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
615 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
616 size_t sub_chunk_len;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
617 fourcc_t sub_chunk_id;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
618
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
619 sub_chunk_len = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
620 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
621 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
622
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
623 sub_chunk_id = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
624
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
625 switch (sub_chunk_id)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
626 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
627 case MAKEFOURCC('m','v','h','d'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
628 read_chunk_mvhd(qtmovie, sub_chunk_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
629 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
630 case MAKEFOURCC('t','r','a','k'):
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
631 if (read_chunk_trak(qtmovie, sub_chunk_len) == 0)
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
632 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
633 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
634 case MAKEFOURCC('u','d','t','a'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
635 read_chunk_udta(qtmovie, sub_chunk_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
636 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
637 case MAKEFOURCC('e','l','s','t'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
638 read_chunk_elst(qtmovie, sub_chunk_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
639 break;
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
640 case MAKEFOURCC('i','o','d','s'):
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
641 read_chunk_iods(qtmovie, sub_chunk_len);
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
642 break;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
643 default:
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
644 return 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
645 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
646
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
647 size_remaining -= sub_chunk_len;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
648 }
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
649
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
650 return 1;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
651 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
652
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
653 static void read_chunk_mdat(qtmovie_t *qtmovie, size_t chunk_len, int skip_mdat)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
654 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
655 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
656
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
657 if (size_remaining == 0) return;
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
658
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
659 qtmovie->res->mdat_len = (uint32_t)size_remaining;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
660 if (skip_mdat)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
661 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
662 qtmovie->saved_mdat_pos = stream_tell(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
663 stream_skip(qtmovie->stream, size_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
664 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
665 #if 0
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
666 qtmovie->res->mdat = malloc(size_remaining);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
667
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
668 stream_read(qtmovie->stream, size_remaining, qtmovie->res->mdat);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
669 #endif
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
670 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
671
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
672 static int set_saved_mdat(qtmovie_t *qtmovie)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
673 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
674 if (qtmovie->saved_mdat_pos == -1)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
675 return 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
676
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
677 if (stream_setpos(qtmovie->stream, qtmovie->saved_mdat_pos))
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
678 return 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
679
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
680 return 1;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
681 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
682
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
683 int qtmovie_read(stream_t *file, demux_res_t *demux_res)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
684 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
685 int found_moov = 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
686 int found_mdat = 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
687 qtmovie_t *qtmovie;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
688
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
689 qtmovie = (qtmovie_t*)malloc(sizeof(qtmovie_t));
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
690
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
691 /* construct the stream */
78
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
692 qtmovie->stream = file;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
693 qtmovie->res = demux_res;
84
fa9e4ed85309 [svn] - try this
nenolod
parents: 80
diff changeset
694 qtmovie->isfilenotalac = 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
695
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
696 memset(demux_res, 0, sizeof(demux_res_t));
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
697
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
698 /* read the chunks */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
699 while (1)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
700 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
701 size_t chunk_len;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
702 fourcc_t chunk_id;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
703
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
704 chunk_len = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
705 if (stream_eof(qtmovie->stream))
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
706 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
707 return 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
708 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
709
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
710 if (chunk_len == 1)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
711 return 0;
67
41e2dc106f4e [svn] - remove spurious debugging notices
nenolod
parents: 56
diff changeset
712
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
713 chunk_id = stream_read_uint32(qtmovie->stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
714
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
715 switch (chunk_id)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
716 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
717 case MAKEFOURCC('f','t','y','p'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
718 read_chunk_ftyp(qtmovie, chunk_len);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
719 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
720 case MAKEFOURCC('m','o','o','v'):
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
721 if (read_chunk_moov(qtmovie, chunk_len) == 0)
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 84
diff changeset
722 return 0; /* failed to read moov, can't do anything */
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
723 if (found_mdat)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
724 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
725 return set_saved_mdat(qtmovie);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
726 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
727 found_moov = 1;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
728 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
729 /* if we hit mdat before we've found moov, record the position
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
730 * and move on. We can then come back to mdat later.
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
731 * This presumes the stream supports seeking backwards.
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
732 */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
733 case MAKEFOURCC('m','d','a','t'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
734 read_chunk_mdat(qtmovie, chunk_len, !found_moov);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
735 if (found_moov)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
736 return 1;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
737 found_mdat = 1;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
738 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
739
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
740 /* these following atoms can be skipped !!!! */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
741 case MAKEFOURCC('f','r','e','e'):
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
742 stream_skip(qtmovie->stream, chunk_len - 8); /* FIXME not 8 */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
743 break;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
744 default:
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
745 return 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
746 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
747
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
748 }
84
fa9e4ed85309 [svn] - try this
nenolod
parents: 80
diff changeset
749
fa9e4ed85309 [svn] - try this
nenolod
parents: 80
diff changeset
750 return qtmovie->isfilenotalac;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
751 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
752
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
753