Mercurial > audlegacy-plugins
annotate src/alac/demux.c @ 157:34b6f9d5633a trunk
[svn] - use xmms_show_message() here.
author | nenolod |
---|---|
date | Tue, 31 Oct 2006 12:45:32 -0800 |
parents | 86ce11c6b8c3 |
children | 74df3bd6f472 |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
32 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
33 #include <string.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
34 #include <stdio.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
35 #include <stdint.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
36 #include <stdlib.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
37 |
78 | 38 #include <glib.h> |
39 | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
40 #include "stream.h" |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
41 #include "demux.h" |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
42 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
43 typedef struct |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
44 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
45 stream_t *stream; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
46 demux_res_t *res; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
47 long saved_mdat_pos; |
84 | 48 int isfilenotalac; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
49 } qtmovie_t; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
50 |
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 /* chunk handlers */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
53 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
|
54 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
55 fourcc_t type; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
56 uint32_t minor_ver; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
57 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
|
58 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
59 type = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
60 size_remaining-=4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
61 if (type != MAKEFOURCC('M','4','A',' ')) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
62 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
63 return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
64 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
65 minor_ver = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
66 size_remaining-=4; |
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 /* compatible brands */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
69 while (size_remaining) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
70 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
71 /* unused */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
72 /*fourcc_t cbrand =*/ stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
73 size_remaining-=4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
74 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
75 } |
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 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
|
78 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
79 /* don't need anything from here atm, skip */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
80 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
81 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
82 stream_skip(qtmovie->stream, size_remaining); |
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 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
|
86 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
87 /* don't need anything from here atm, skip */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
88 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
89 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
90 stream_skip(qtmovie->stream, size_remaining); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
91 } |
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 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
|
94 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
95 /* don't need anything from here atm, skip */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
96 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
97 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
98 stream_skip(qtmovie->stream, size_remaining); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
99 } |
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 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
|
102 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
103 /* don't need anything from here atm, skip */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
104 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
105 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
106 stream_skip(qtmovie->stream, size_remaining); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
107 } |
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 /* media handler inside mdia */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
110 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
|
111 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
112 fourcc_t comptype, compsubtype; |
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 int strlen; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
116 char str[256] = {0}; |
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 /* version */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
119 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
120 size_remaining -= 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
121 /* flags */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
122 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
123 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
124 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
125 size_remaining -= 3; |
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 /* component type */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
128 comptype = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
129 compsubtype = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
130 size_remaining -= 8; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
131 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
132 /* component manufacturer */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
133 stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
134 size_remaining -= 4; |
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 /* flags */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
137 stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
138 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 /* name */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
142 strlen = stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
143 stream_read(qtmovie->stream, strlen, str); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
144 size_remaining -= 1 + strlen; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
145 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
146 if (size_remaining) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
147 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
148 stream_skip(qtmovie->stream, size_remaining); |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
151 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
152 |
85 | 153 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
|
154 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
155 unsigned int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
156 uint32_t numentries; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
157 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
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 /* version */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
160 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
161 size_remaining -= 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
162 /* flags */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
163 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
164 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
165 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
166 size_remaining -= 3; |
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 numentries = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
169 size_remaining -= 4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
170 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
171 if (numentries != 1) |
85 | 172 return 0; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
173 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
174 for (i = 0; i < numentries; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
175 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
176 uint32_t entry_size; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
177 uint16_t version; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
178 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
179 uint32_t entry_remaining; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
180 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
181 entry_size = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
182 qtmovie->res->format = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
183 entry_remaining = entry_size; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
184 entry_remaining -= 8; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
185 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
186 /* sound info: */ |
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 stream_skip(qtmovie->stream, 6); /* reserved */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
189 entry_remaining -= 6; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
190 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
191 version = stream_read_uint16(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
192 if (version != 1) |
85 | 193 return 0; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
194 entry_remaining -= 2; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
195 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
196 /* revision level */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
197 stream_read_uint16(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
198 /* vendor */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
199 stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
200 entry_remaining -= 6; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
201 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
202 /* 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
|
203 stream_read_uint16(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
204 entry_remaining -= 2; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
205 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
206 qtmovie->res->num_channels = stream_read_uint16(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
207 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
208 qtmovie->res->sample_size = stream_read_uint16(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
209 entry_remaining -= 4; |
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 /* compression id */ |
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 /* packet size */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
214 stream_read_uint16(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
215 entry_remaining -= 4; |
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 /* sample rate - 32bit fixed point = 16bit?? */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
218 qtmovie->res->sample_rate = stream_read_uint16(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
219 entry_remaining -= 2; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
220 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
221 /* skip 2 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
222 stream_skip(qtmovie->stream, 2); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
223 entry_remaining -= 2; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
224 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
225 /* remaining is codec data */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
226 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
227 /* 12 = audio format atom, 8 = padding */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
228 qtmovie->res->codecdata_len = entry_remaining + 12 + 8; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
229 qtmovie->res->codecdata = malloc(qtmovie->res->codecdata_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
230 memset(qtmovie->res->codecdata, 0, qtmovie->res->codecdata_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
231 /* audio format atom */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
232 ((unsigned int*)qtmovie->res->codecdata)[0] = 0x0c000000; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
233 ((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
|
234 ((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
|
235 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
236 stream_read(qtmovie->stream, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
237 entry_remaining, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
238 ((char*)qtmovie->res->codecdata) + 12); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
239 entry_remaining -= entry_remaining; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
240 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
241 if (entry_remaining) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
242 stream_skip(qtmovie->stream, entry_remaining); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
243 |
85 | 244 qtmovie->res->format_read = 1; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
245 if (qtmovie->res->format != MAKEFOURCC('a','l','a','c')) |
84 | 246 { |
247 qtmovie->isfilenotalac = 1; | |
85 | 248 return 0; |
84 | 249 } |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
250 } |
85 | 251 |
252 return 1; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
253 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
254 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
255 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
|
256 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
257 unsigned int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
258 uint32_t numentries; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
259 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
260 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
261 /* version */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
262 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
263 size_remaining -= 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
264 /* flags */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
265 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
266 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
267 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
268 size_remaining -= 3; |
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 numentries = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
271 size_remaining -= 4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
272 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
273 qtmovie->res->num_time_to_samples = numentries; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
274 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
|
275 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
276 for (i = 0; i < numentries; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
277 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
278 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
|
279 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
|
280 size_remaining -= 8; |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
283 if (size_remaining) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
284 stream_skip(qtmovie->stream, size_remaining); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
285 } |
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 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
|
288 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
289 unsigned int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
290 uint32_t numentries; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
291 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
292 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
293 /* version */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
294 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
295 size_remaining -= 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
296 /* flags */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
297 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
298 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
299 stream_read_uint8(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
300 size_remaining -= 3; |
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 /* default sample size */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
303 if (stream_read_uint32(qtmovie->stream) != 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
304 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
305 stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
306 size_remaining -= 4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
307 return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
308 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
309 size_remaining -= 4; |
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 numentries = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
312 size_remaining -= 4; |
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 qtmovie->res->num_sample_byte_sizes = numentries; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
315 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
|
316 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
317 for (i = 0; i < numentries; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
318 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
319 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
|
320 size_remaining -= 4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
321 } |
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 if (size_remaining) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
324 stream_skip(qtmovie->stream, size_remaining); |
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 |
85 | 327 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
|
328 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
329 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
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 while (size_remaining) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
332 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
333 size_t sub_chunk_len; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
334 fourcc_t sub_chunk_id; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
335 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
336 sub_chunk_len = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
337 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) |
85 | 338 return 0; |
56
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 sub_chunk_id = stream_read_uint32(qtmovie->stream); |
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 switch (sub_chunk_id) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
343 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
344 case MAKEFOURCC('s','t','s','d'): |
85 | 345 if (read_chunk_stsd(qtmovie, sub_chunk_len) == 0) |
346 return 0; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
347 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
348 case MAKEFOURCC('s','t','t','s'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
349 read_chunk_stts(qtmovie, sub_chunk_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
350 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
351 case MAKEFOURCC('s','t','s','z'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
352 read_chunk_stsz(qtmovie, sub_chunk_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
353 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
354 case MAKEFOURCC('s','t','s','c'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
355 case MAKEFOURCC('s','t','c','o'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
356 /* skip these, no indexing for us! */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
357 stream_skip(qtmovie->stream, sub_chunk_len - 8); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
358 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
359 default: |
85 | 360 return 0; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
361 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
362 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
363 size_remaining -= sub_chunk_len; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
364 } |
85 | 365 |
366 return 1; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
367 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
368 |
85 | 369 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
|
370 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
371 size_t dinf_size, stbl_size; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
372 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
373 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
374 if (stream_read_uint32(qtmovie->stream) != 16) |
85 | 375 return 0; |
67 | 376 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
377 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','m','h','d')) |
85 | 378 return 0; |
67 | 379 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
380 /* now skip the rest */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
381 stream_skip(qtmovie->stream, 16 - 8); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
382 size_remaining -= 16; |
67 | 383 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
384 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
385 /**** DINF CHUNK ****/ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
386 dinf_size = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
387 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('d','i','n','f')) |
85 | 388 return 0; |
67 | 389 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
390 /* skip it */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
391 stream_skip(qtmovie->stream, dinf_size - 8); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
392 size_remaining -= dinf_size; |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
395 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
396 /**** SAMPLE TABLE ****/ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
397 stbl_size = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
398 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','t','b','l')) |
85 | 399 return 0; |
67 | 400 |
85 | 401 if (read_chunk_stbl(qtmovie, stbl_size) == 0) |
402 return 0; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
403 size_remaining -= stbl_size; |
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 if (size_remaining) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
406 stream_skip(qtmovie->stream, size_remaining); |
85 | 407 |
408 return 1; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
409 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
410 |
85 | 411 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
|
412 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
413 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
414 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
415 while (size_remaining) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
416 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
417 size_t sub_chunk_len; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
418 fourcc_t sub_chunk_id; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
419 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
420 sub_chunk_len = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
421 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) |
85 | 422 return 0; |
56
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 sub_chunk_id = stream_read_uint32(qtmovie->stream); |
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 switch (sub_chunk_id) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
427 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
428 case MAKEFOURCC('m','d','h','d'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
429 read_chunk_mdhd(qtmovie, sub_chunk_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
430 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
431 case MAKEFOURCC('h','d','l','r'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
432 read_chunk_hdlr(qtmovie, sub_chunk_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
433 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
434 case MAKEFOURCC('m','i','n','f'): |
85 | 435 if (read_chunk_minf(qtmovie, sub_chunk_len) == 0) |
436 return 0; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
437 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
438 default: |
85 | 439 return 0; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
440 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
441 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
442 size_remaining -= sub_chunk_len; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
443 } |
85 | 444 |
445 return 1; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
446 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
447 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
448 /* 'trak' - a movie track - contains other atoms */ |
85 | 449 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
|
450 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
451 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
452 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
453 while (size_remaining) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
454 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
455 size_t sub_chunk_len; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
456 fourcc_t sub_chunk_id; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
457 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
458 sub_chunk_len = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
459 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) |
85 | 460 return 0; |
56
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 sub_chunk_id = stream_read_uint32(qtmovie->stream); |
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 switch (sub_chunk_id) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
465 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
466 case MAKEFOURCC('t','k','h','d'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
467 read_chunk_tkhd(qtmovie, sub_chunk_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
468 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
469 case MAKEFOURCC('m','d','i','a'): |
85 | 470 if (read_chunk_mdia(qtmovie, sub_chunk_len) == 0) |
471 return 0; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
472 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
473 case MAKEFOURCC('e','d','t','s'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
474 read_chunk_edts(qtmovie, sub_chunk_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
475 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
476 default: |
85 | 477 return 0; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
478 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
479 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
480 size_remaining -= sub_chunk_len; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
481 } |
85 | 482 |
483 return 1; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
484 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
485 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
486 /* 'mvhd' movie header atom */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
487 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
|
488 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
489 /* don't need anything from here atm, skip */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
490 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
491 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
492 stream_skip(qtmovie->stream, size_remaining); |
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 |
85 | 495 /* 'iods' */ |
496 static void read_chunk_iods(qtmovie_t *qtmovie, size_t chunk_len) | |
497 { | |
498 /* don't need anything from here atm, skip */ | |
499 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ | |
500 | |
501 stream_skip(qtmovie->stream, size_remaining); | |
502 } | |
503 | |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
504 enum |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
505 { |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
506 UDTA_NIL = 0, |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
507 UDTA_NAM, |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
508 UDTA_ART, |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
509 UDTA_ALB, |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
510 UDTA_GEN, |
80 | 511 UDTA_DAY, |
512 UDTA_CMT, | |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
513 }; |
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' 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
|
516 * 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
|
517 */ |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
518 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
|
519 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
520 /* don't need anything from here atm, skip */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
521 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
|
522 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
|
523 char *bptr; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
524 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
|
525 int udta_tgt = UDTA_NIL; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
526 |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
527 /* 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
|
528 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
|
529 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
530 /* 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
|
531 for (bptr = buf; (bptr + 3) - buf < size_remaining; bptr++) |
78 | 532 { |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
533 sub_chunk_id = MAKEFOURCC(*bptr, *(bptr + 1), *(bptr + 2), *(bptr + 3)); |
78 | 534 |
535 switch (sub_chunk_id) | |
536 { | |
537 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
|
538 bptr += 4; /* skip meta */ |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
539 break; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
540 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
|
541 udta_tgt = UDTA_NAM; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
542 bptr += 4; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
543 break; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
544 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
|
545 udta_tgt = UDTA_ART; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
546 bptr += 4; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
547 break; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
548 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
|
549 udta_tgt = UDTA_ALB; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
550 bptr += 4; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
551 break; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
552 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
|
553 udta_tgt = UDTA_GEN; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
554 bptr += 4; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
555 break; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
556 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
|
557 udta_tgt = UDTA_DAY; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
558 bptr += 4; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
559 break; |
80 | 560 case MAKEFOURCC(0xA9,'c','m','t'): |
561 udta_tgt = UDTA_CMT; | |
562 bptr += 4; | |
563 break; | |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
564 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
|
565 switch(udta_tgt) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
566 { |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
567 case UDTA_NAM: |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
568 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
|
569 break; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
570 case UDTA_ART: |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
571 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
|
572 break; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
573 case UDTA_ALB: |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
574 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
|
575 break; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
576 case UDTA_DAY: |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
577 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
|
578 break; |
80 | 579 case UDTA_CMT: |
580 qtmovie->res->tuple.cmt = g_strdup(bptr + 12); | |
581 break; | |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
582 case UDTA_GEN: |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
583 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
|
584 break; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
585 default: |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
586 break; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
587 } |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
588 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
589 bptr += 12; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
590 bptr += strlen(bptr); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
591 break; |
78 | 592 default: |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
593 break; |
78 | 594 } |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
595 } |
78 | 596 |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
597 g_free(buf); |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
598 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
599 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
600 /* 'moov' movie atom - contains other atoms */ |
85 | 601 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
|
602 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
603 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
604 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
605 while (size_remaining) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
606 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
607 size_t sub_chunk_len; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
608 fourcc_t sub_chunk_id; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
609 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
610 sub_chunk_len = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
611 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) |
85 | 612 return 0; |
56
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 sub_chunk_id = stream_read_uint32(qtmovie->stream); |
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 switch (sub_chunk_id) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
617 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
618 case MAKEFOURCC('m','v','h','d'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
619 read_chunk_mvhd(qtmovie, sub_chunk_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
620 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
621 case MAKEFOURCC('t','r','a','k'): |
85 | 622 if (read_chunk_trak(qtmovie, sub_chunk_len) == 0) |
623 return 0; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
624 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
625 case MAKEFOURCC('u','d','t','a'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
626 read_chunk_udta(qtmovie, sub_chunk_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
627 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
628 case MAKEFOURCC('e','l','s','t'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
629 read_chunk_elst(qtmovie, sub_chunk_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
630 break; |
85 | 631 case MAKEFOURCC('i','o','d','s'): |
632 read_chunk_iods(qtmovie, sub_chunk_len); | |
633 break; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
634 default: |
85 | 635 return 0; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
636 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
637 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
638 size_remaining -= sub_chunk_len; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
639 } |
85 | 640 |
641 return 1; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
642 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
643 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
644 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
|
645 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
646 size_t size_remaining = chunk_len - 8; /* FIXME WRONG */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
647 |
85 | 648 if (size_remaining == 0) return; |
649 | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
650 qtmovie->res->mdat_len = (uint32_t)size_remaining; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
651 if (skip_mdat) |
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 qtmovie->saved_mdat_pos = stream_tell(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
654 stream_skip(qtmovie->stream, size_remaining); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
655 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
656 #if 0 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
657 qtmovie->res->mdat = malloc(size_remaining); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
658 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
659 stream_read(qtmovie->stream, size_remaining, qtmovie->res->mdat); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
660 #endif |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
663 static int set_saved_mdat(qtmovie_t *qtmovie) |
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 (qtmovie->saved_mdat_pos == -1) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
666 return 0; |
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 if (stream_setpos(qtmovie->stream, qtmovie->saved_mdat_pos)) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
669 return 0; |
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 return 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
672 } |
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 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
|
675 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
676 int found_moov = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
677 int found_mdat = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
678 qtmovie_t *qtmovie; |
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 qtmovie = (qtmovie_t*)malloc(sizeof(qtmovie_t)); |
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 /* construct the stream */ |
78 | 683 qtmovie->stream = file; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
684 qtmovie->res = demux_res; |
84 | 685 qtmovie->isfilenotalac = 0; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
686 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
687 memset(demux_res, 0, sizeof(demux_res_t)); |
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 /* read the chunks */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
690 while (1) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
691 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
692 size_t chunk_len; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
693 fourcc_t chunk_id; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
694 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
695 chunk_len = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
696 if (stream_eof(qtmovie->stream)) |
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 return 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
699 } |
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 if (chunk_len == 1) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
702 return 0; |
67 | 703 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
704 chunk_id = stream_read_uint32(qtmovie->stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
705 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
706 switch (chunk_id) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
707 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
708 case MAKEFOURCC('f','t','y','p'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
709 read_chunk_ftyp(qtmovie, chunk_len); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
710 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
711 case MAKEFOURCC('m','o','o','v'): |
85 | 712 if (read_chunk_moov(qtmovie, chunk_len) == 0) |
713 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
|
714 if (found_mdat) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
715 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
716 return set_saved_mdat(qtmovie); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
717 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
718 found_moov = 1; |
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 /* 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
|
721 * 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
|
722 * This presumes the stream supports seeking backwards. |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
723 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
724 case MAKEFOURCC('m','d','a','t'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
725 read_chunk_mdat(qtmovie, chunk_len, !found_moov); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
726 if (found_moov) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
727 return 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
728 found_mdat = 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
729 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
730 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
731 /* these following atoms can be skipped !!!! */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
732 case MAKEFOURCC('f','r','e','e'): |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
733 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
|
734 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
735 default: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
736 return 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
737 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
738 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
739 } |
84 | 740 |
741 return qtmovie->isfilenotalac; | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
742 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
743 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
744 |