Mercurial > libavcodec.hg
annotate alac.c @ 8680:83453ea78558 libavcodec
ARM: replace jump tables with conditional branches
author | mru |
---|---|
date | Tue, 27 Jan 2009 16:06:47 +0000 |
parents | fe449020b713 |
children | e9d9d946f213 |
rev | line source |
---|---|
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
1 /* |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
2 * ALAC (Apple Lossless Audio Codec) decoder |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
3 * Copyright (c) 2005 David Hammerton |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
4 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3347
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3347
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3347
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3347
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3347
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
16 * |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3347
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2967
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
20 */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
21 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
22 /** |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
23 * @file alac.c |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
24 * ALAC (Apple Lossless Audio Codec) decoder |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
25 * @author 2005 David Hammerton |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
26 * |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
27 * For more information on the ALAC format, visit: |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
28 * http://crazney.net/programs/itunes/alac.html |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
29 * |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
30 * Note: This decoder expects a 36- (0x24-)byte QuickTime atom to be |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
31 * passed through the extradata[_size] fields. This atom is tacked onto |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
32 * the end of an 'alac' stsd atom and has the following format: |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
33 * bytes 0-3 atom size (0x24), big-endian |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
34 * bytes 4-7 atom type ('alac', not the 'alac' tag from start of stsd) |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
35 * bytes 8-35 data bytes needed by decoder |
3135 | 36 * |
37 * Extradata: | |
38 * 32bit size | |
39 * 32bit tag (=alac) | |
40 * 32bit zero? | |
41 * 32bit max sample per frame | |
42 * 8bit ?? (zero?) | |
43 * 8bit sample size | |
44 * 8bit history mult | |
45 * 8bit initial history | |
46 * 8bit kmodifier | |
47 * 8bit channels? | |
48 * 16bit ?? | |
49 * 32bit max coded frame size | |
50 * 32bit bitrate? | |
51 * 32bit samplerate | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
52 */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
53 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
54 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
55 #include "avcodec.h" |
2559
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
56 #include "bitstream.h" |
5276 | 57 #include "bytestream.h" |
5628 | 58 #include "unary.h" |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
59 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
60 #define ALAC_EXTRADATA_SIZE 36 |
5272 | 61 #define MAX_CHANNELS 2 |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
62 |
2559
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
63 typedef struct { |
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
64 |
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
65 AVCodecContext *avctx; |
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
66 GetBitContext gb; |
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
67 /* init to 0; first frame decode should initialize from extradata and |
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
68 * set this to 1 */ |
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
69 int context_initialized; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
70 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
71 int numchannels; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
72 int bytespersample; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
73 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
74 /* buffers */ |
5272 | 75 int32_t *predicterror_buffer[MAX_CHANNELS]; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
76 |
5272 | 77 int32_t *outputsamples_buffer[MAX_CHANNELS]; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
78 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
79 /* stuff from setinfo */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
80 uint32_t setinfo_max_samples_per_frame; /* 0x1000 = 4096 */ /* max samples per frame? */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
81 uint8_t setinfo_sample_size; /* 0x10 */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
82 uint8_t setinfo_rice_historymult; /* 0x28 */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
83 uint8_t setinfo_rice_initialhistory; /* 0x0a */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
84 uint8_t setinfo_rice_kmodifier; /* 0x0e */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
85 /* end setinfo stuff */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
86 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
87 } ALACContext; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
88 |
2559
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
89 static void allocate_buffers(ALACContext *alac) |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
90 { |
5272 | 91 int chan; |
92 for (chan = 0; chan < MAX_CHANNELS; chan++) { | |
93 alac->predicterror_buffer[chan] = | |
94 av_malloc(alac->setinfo_max_samples_per_frame * 4); | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
95 |
5272 | 96 alac->outputsamples_buffer[chan] = |
97 av_malloc(alac->setinfo_max_samples_per_frame * 4); | |
98 } | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
99 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
100 |
3303
68721b62a528
sanity checks, some might have been exploitable ...
michael
parents:
3299
diff
changeset
|
101 static int alac_set_info(ALACContext *alac) |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
102 { |
6221 | 103 const unsigned char *ptr = alac->avctx->extradata; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
104 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
105 ptr += 4; /* size */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
106 ptr += 4; /* alac */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
107 ptr += 4; /* 0 ? */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
108 |
4364 | 109 if(AV_RB32(ptr) >= UINT_MAX/4){ |
3303
68721b62a528
sanity checks, some might have been exploitable ...
michael
parents:
3299
diff
changeset
|
110 av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n"); |
68721b62a528
sanity checks, some might have been exploitable ...
michael
parents:
3299
diff
changeset
|
111 return -1; |
68721b62a528
sanity checks, some might have been exploitable ...
michael
parents:
3299
diff
changeset
|
112 } |
5276 | 113 |
114 /* buffer size / 2 ? */ | |
115 alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr); | |
6634
981e2f43ea36
10l: my last commit broke compilation and introduced warnings
vitor
parents:
6633
diff
changeset
|
116 ptr++; /* ??? */ |
5360 | 117 alac->setinfo_sample_size = *ptr++; |
6778
1926f42527c7
simplify decoding of uncompressed samples. patch by matthieu castet <castet matthieu free fr>.
jbr
parents:
6773
diff
changeset
|
118 if (alac->setinfo_sample_size > 32) { |
1926f42527c7
simplify decoding of uncompressed samples. patch by matthieu castet <castet matthieu free fr>.
jbr
parents:
6773
diff
changeset
|
119 av_log(alac->avctx, AV_LOG_ERROR, "setinfo_sample_size too large\n"); |
1926f42527c7
simplify decoding of uncompressed samples. patch by matthieu castet <castet matthieu free fr>.
jbr
parents:
6773
diff
changeset
|
120 return -1; |
1926f42527c7
simplify decoding of uncompressed samples. patch by matthieu castet <castet matthieu free fr>.
jbr
parents:
6773
diff
changeset
|
121 } |
5360 | 122 alac->setinfo_rice_historymult = *ptr++; |
123 alac->setinfo_rice_initialhistory = *ptr++; | |
124 alac->setinfo_rice_kmodifier = *ptr++; | |
6634
981e2f43ea36
10l: my last commit broke compilation and introduced warnings
vitor
parents:
6633
diff
changeset
|
125 ptr++; /* channels? */ |
6633 | 126 bytestream_get_be16(&ptr); /* ??? */ |
127 bytestream_get_be32(&ptr); /* max coded frame size */ | |
128 bytestream_get_be32(&ptr); /* bitrate ? */ | |
6634
981e2f43ea36
10l: my last commit broke compilation and introduced warnings
vitor
parents:
6633
diff
changeset
|
129 bytestream_get_be32(&ptr); /* samplerate */ |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
130 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
131 allocate_buffers(alac); |
3303
68721b62a528
sanity checks, some might have been exploitable ...
michael
parents:
3299
diff
changeset
|
132 |
68721b62a528
sanity checks, some might have been exploitable ...
michael
parents:
3299
diff
changeset
|
133 return 0; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
134 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
135 |
6626 | 136 static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsamplesize){ |
137 /* read x - number of 1s before 0 represent the rice */ | |
138 int x = get_unary_0_9(gb); | |
139 | |
140 if (x > 8) { /* RICE THRESHOLD */ | |
141 /* use alternative encoding */ | |
142 x = get_bits(gb, readsamplesize); | |
143 } else { | |
6627 | 144 if (k >= limit) |
145 k = limit; | |
6625 | 146 |
6627 | 147 if (k != 1) { |
148 int extrabits = show_bits(gb, k); | |
6625 | 149 |
6627 | 150 /* multiply x by 2^k - 1, as part of their strange algorithm */ |
151 x = (x << k) - x; | |
6625 | 152 |
6627 | 153 if (extrabits > 1) { |
154 x += extrabits - 1; | |
155 skip_bits(gb, k); | |
156 } else | |
157 skip_bits(gb, k - 1); | |
158 } | |
6626 | 159 } |
6625 | 160 return x; |
161 } | |
162 | |
3071
cc0357a90e8f
make some functions static (patch by Dieter < freebsd at sopwith.solgatos.com >)
aurel
parents:
3036
diff
changeset
|
163 static void bastardized_rice_decompress(ALACContext *alac, |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
164 int32_t *output_buffer, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
165 int output_size, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
166 int readsamplesize, /* arg_10 */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
167 int rice_initialhistory, /* arg424->b */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
168 int rice_kmodifier, /* arg424->d */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
169 int rice_historymult, /* arg424->c */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
170 int rice_kmodifier_mask /* arg424->e */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
171 ) |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
172 { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
173 int output_count; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
174 unsigned int history = rice_initialhistory; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
175 int sign_modifier = 0; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
176 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
177 for (output_count = 0; output_count < output_size; output_count++) { |
5628 | 178 int32_t x; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
179 int32_t x_modified; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
180 int32_t final_val; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
181 |
6627 | 182 /* standard rice encoding */ |
183 int k; /* size of extra bits */ | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
184 |
6627 | 185 /* read k, that is bits as is */ |
6632 | 186 k = av_log2((history >> 9) + 3); |
6627 | 187 x= decode_scalar(&alac->gb, k, rice_kmodifier, readsamplesize); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
188 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
189 x_modified = sign_modifier + x; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
190 final_val = (x_modified + 1) / 2; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
191 if (x_modified & 1) final_val *= -1; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
192 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
193 output_buffer[output_count] = final_val; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
194 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
195 sign_modifier = 0; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
196 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
197 /* now update the history */ |
5365 | 198 history += x_modified * rice_historymult |
199 - ((history * rice_historymult) >> 9); | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
200 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
201 if (x_modified > 0xffff) |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
202 history = 0xffff; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
203 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
204 /* special case: there may be compressed blocks of 0 */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
205 if ((history < 128) && (output_count+1 < output_size)) { |
6742 | 206 int k; |
207 unsigned int block_size; | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
208 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
209 sign_modifier = 1; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
210 |
6632 | 211 k = 7 - av_log2(history) + ((history + 16) >> 6 /* / 64 */); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
212 |
6627 | 213 block_size= decode_scalar(&alac->gb, k, rice_kmodifier, 16); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
214 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
215 if (block_size > 0) { |
6742 | 216 if(block_size >= output_size - output_count){ |
217 av_log(alac->avctx, AV_LOG_ERROR, "invalid zero block size of %d %d %d\n", block_size, output_size, output_count); | |
218 block_size= output_size - output_count - 1; | |
219 } | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
220 memset(&output_buffer[output_count+1], 0, block_size * 4); |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
221 output_count += block_size; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
222 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
223 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
224 if (block_size > 0xffff) |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
225 sign_modifier = 0; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
226 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
227 history = 0; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
228 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
229 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
230 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
231 |
5617 | 232 static inline int32_t extend_sign32(int32_t val, int bits) |
5616 | 233 { |
234 return (val << (32 - bits)) >> (32 - bits); | |
235 } | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
236 |
5616 | 237 static inline int sign_only(int v) |
238 { | |
239 return v ? FFSIGN(v) : 0; | |
240 } | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
241 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
242 static void predictor_decompress_fir_adapt(int32_t *error_buffer, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
243 int32_t *buffer_out, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
244 int output_size, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
245 int readsamplesize, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
246 int16_t *predictor_coef_table, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
247 int predictor_coef_num, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
248 int predictor_quantitization) |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
249 { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
250 int i; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
251 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
252 /* first sample always copies */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
253 *buffer_out = *error_buffer; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
254 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
255 if (!predictor_coef_num) { |
5365 | 256 if (output_size <= 1) |
257 return; | |
258 | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
259 memcpy(buffer_out+1, error_buffer+1, (output_size-1) * 4); |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
260 return; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
261 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
262 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
263 if (predictor_coef_num == 0x1f) { /* 11111 - max value of predictor_coef_num */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
264 /* second-best case scenario for fir decompression, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
265 * error describes a small difference from the previous sample only |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
266 */ |
5365 | 267 if (output_size <= 1) |
268 return; | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
269 for (i = 0; i < output_size - 1; i++) { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
270 int32_t prev_value; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
271 int32_t error_value; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
272 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
273 prev_value = buffer_out[i]; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
274 error_value = error_buffer[i+1]; |
5365 | 275 buffer_out[i+1] = |
5617 | 276 extend_sign32((prev_value + error_value), readsamplesize); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
277 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
278 return; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
279 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
280 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
281 /* read warm-up samples */ |
5365 | 282 if (predictor_coef_num > 0) |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
283 for (i = 0; i < predictor_coef_num; i++) { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
284 int32_t val; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
285 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
286 val = buffer_out[i] + error_buffer[i+1]; |
5617 | 287 val = extend_sign32(val, readsamplesize); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
288 buffer_out[i+1] = val; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
289 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
290 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
291 #if 0 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
292 /* 4 and 8 are very common cases (the only ones i've seen). these |
5963 | 293 * should be unrolled and optimized |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
294 */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
295 if (predictor_coef_num == 4) { |
5963 | 296 /* FIXME: optimized general case */ |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
297 return; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
298 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
299 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
300 if (predictor_coef_table == 8) { |
5963 | 301 /* FIXME: optimized general case */ |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
302 return; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
303 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
304 #endif |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
305 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
306 /* general case */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
307 if (predictor_coef_num > 0) { |
5365 | 308 for (i = predictor_coef_num + 1; i < output_size; i++) { |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
309 int j; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
310 int sum = 0; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
311 int outval; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
312 int error_val = error_buffer[i]; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
313 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
314 for (j = 0; j < predictor_coef_num; j++) { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
315 sum += (buffer_out[predictor_coef_num-j] - buffer_out[0]) * |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
316 predictor_coef_table[j]; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
317 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
318 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
319 outval = (1 << (predictor_quantitization-1)) + sum; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
320 outval = outval >> predictor_quantitization; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
321 outval = outval + buffer_out[0] + error_val; |
5617 | 322 outval = extend_sign32(outval, readsamplesize); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
323 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
324 buffer_out[predictor_coef_num+1] = outval; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
325 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
326 if (error_val > 0) { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
327 int predictor_num = predictor_coef_num - 1; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
328 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
329 while (predictor_num >= 0 && error_val > 0) { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
330 int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; |
5616 | 331 int sign = sign_only(val); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
332 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
333 predictor_coef_table[predictor_num] -= sign; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
334 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
335 val *= sign; /* absolute value */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
336 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
337 error_val -= ((val >> predictor_quantitization) * |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
338 (predictor_coef_num - predictor_num)); |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
339 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
340 predictor_num--; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
341 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
342 } else if (error_val < 0) { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
343 int predictor_num = predictor_coef_num - 1; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
344 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
345 while (predictor_num >= 0 && error_val < 0) { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
346 int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; |
5616 | 347 int sign = - sign_only(val); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
348 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
349 predictor_coef_table[predictor_num] -= sign; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
350 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
351 val *= sign; /* neg value */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
352 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
353 error_val -= ((val >> predictor_quantitization) * |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
354 (predictor_coef_num - predictor_num)); |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
355 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
356 predictor_num--; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
357 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
358 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
359 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
360 buffer_out++; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
361 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
362 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
363 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
364 |
5504 | 365 static void reconstruct_stereo_16(int32_t *buffer[MAX_CHANNELS], |
5505 | 366 int16_t *buffer_out, |
367 int numchannels, int numsamples, | |
368 uint8_t interlacing_shift, | |
369 uint8_t interlacing_leftweight) | |
2543
e8f1f57215ad
do not use a variable before proper initialization
melanson
parents:
2542
diff
changeset
|
370 { |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
371 int i; |
5365 | 372 if (numsamples <= 0) |
373 return; | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
374 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
375 /* weighted interlacing */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
376 if (interlacing_leftweight) { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
377 for (i = 0; i < numsamples; i++) { |
5372 | 378 int32_t a, b; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
379 |
5372 | 380 a = buffer[0][i]; |
381 b = buffer[1][i]; | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
382 |
5372 | 383 a -= (b * interlacing_leftweight) >> interlacing_shift; |
384 b += a; | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
385 |
5372 | 386 buffer_out[i*numchannels] = b; |
387 buffer_out[i*numchannels + 1] = a; | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
388 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
389 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
390 return; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
391 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
392 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
393 /* otherwise basic interlacing took place */ |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
394 for (i = 0; i < numsamples; i++) { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
395 int16_t left, right; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
396 |
5368
a31f6ae7e83d
Make deinterlace_16 receive an array as a parameter and not two separated vars
vitor
parents:
5367
diff
changeset
|
397 left = buffer[0][i]; |
a31f6ae7e83d
Make deinterlace_16 receive an array as a parameter and not two separated vars
vitor
parents:
5367
diff
changeset
|
398 right = buffer[1][i]; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
399 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
400 buffer_out[i*numchannels] = left; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
401 buffer_out[i*numchannels + 1] = right; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
402 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
403 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
404 |
2544
8c426f5a09ae
decoder works fine now, when fed properly-sized chunks by the demuxer;
melanson
parents:
2543
diff
changeset
|
405 static int alac_decode_frame(AVCodecContext *avctx, |
8c426f5a09ae
decoder works fine now, when fed properly-sized chunks by the demuxer;
melanson
parents:
2543
diff
changeset
|
406 void *outbuffer, int *outputsize, |
6221 | 407 const uint8_t *inbuffer, int input_buffer_size) |
2543
e8f1f57215ad
do not use a variable before proper initialization
melanson
parents:
2542
diff
changeset
|
408 { |
2559
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
409 ALACContext *alac = avctx->priv_data; |
2544
8c426f5a09ae
decoder works fine now, when fed properly-sized chunks by the demuxer;
melanson
parents:
2543
diff
changeset
|
410 |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
411 int channels; |
6743 | 412 unsigned int outputsamples; |
5271 | 413 int hassize; |
7660
6fe7ff34a4db
alac : check readsamplesize to ensure get_bits() doesn't
jai_menon
parents:
7451
diff
changeset
|
414 unsigned int readsamplesize; |
5271 | 415 int wasted_bytes; |
416 int isnotcompressed; | |
5358 | 417 uint8_t interlacing_shift; |
418 uint8_t interlacing_leftweight; | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
419 |
2544
8c426f5a09ae
decoder works fine now, when fed properly-sized chunks by the demuxer;
melanson
parents:
2543
diff
changeset
|
420 /* short-circuit null buffers */ |
8c426f5a09ae
decoder works fine now, when fed properly-sized chunks by the demuxer;
melanson
parents:
2543
diff
changeset
|
421 if (!inbuffer || !input_buffer_size) |
8c426f5a09ae
decoder works fine now, when fed properly-sized chunks by the demuxer;
melanson
parents:
2543
diff
changeset
|
422 return input_buffer_size; |
8c426f5a09ae
decoder works fine now, when fed properly-sized chunks by the demuxer;
melanson
parents:
2543
diff
changeset
|
423 |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
424 /* initialize from the extradata */ |
2559
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
425 if (!alac->context_initialized) { |
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
426 if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) { |
3135 | 427 av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n", |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
428 ALAC_EXTRADATA_SIZE); |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
429 return input_buffer_size; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
430 } |
4226
43ebe9279fa0
fix some potential security issues, patch by Matthias Hopf, mat at mshopf dot de
bcoudurier
parents:
3947
diff
changeset
|
431 if (alac_set_info(alac)) { |
43ebe9279fa0
fix some potential security issues, patch by Matthias Hopf, mat at mshopf dot de
bcoudurier
parents:
3947
diff
changeset
|
432 av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n"); |
43ebe9279fa0
fix some potential security issues, patch by Matthias Hopf, mat at mshopf dot de
bcoudurier
parents:
3947
diff
changeset
|
433 return input_buffer_size; |
43ebe9279fa0
fix some potential security issues, patch by Matthias Hopf, mat at mshopf dot de
bcoudurier
parents:
3947
diff
changeset
|
434 } |
2559
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
435 alac->context_initialized = 1; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
436 } |
2543
e8f1f57215ad
do not use a variable before proper initialization
melanson
parents:
2542
diff
changeset
|
437 |
2559
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
438 init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
439 |
5298
e00f7048c50c
Make "channels" variable mean the number of channels, not the number of
vitor
parents:
5292
diff
changeset
|
440 channels = get_bits(&alac->gb, 3) + 1; |
5362 | 441 if (channels > MAX_CHANNELS) { |
442 av_log(avctx, AV_LOG_ERROR, "channels > %d not supported\n", | |
443 MAX_CHANNELS); | |
444 return input_buffer_size; | |
445 } | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
446 |
5361 | 447 /* 2^result = something to do with output waiting. |
448 * perhaps matters if we read > 1 frame in a pass? | |
449 */ | |
5518 | 450 skip_bits(&alac->gb, 4); |
5361 | 451 |
5518 | 452 skip_bits(&alac->gb, 12); /* unknown, skip 12 bits */ |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
453 |
5361 | 454 /* the output sample size is stored soon */ |
5513 | 455 hassize = get_bits1(&alac->gb); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
456 |
5361 | 457 wasted_bytes = get_bits(&alac->gb, 2); /* unknown ? */ |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
458 |
5361 | 459 /* whether the frame is compressed */ |
5513 | 460 isnotcompressed = get_bits1(&alac->gb); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
461 |
5361 | 462 if (hassize) { |
463 /* now read the number of samples as a 32bit integer */ | |
6773 | 464 outputsamples = get_bits_long(&alac->gb, 32); |
6743 | 465 if(outputsamples > alac->setinfo_max_samples_per_frame){ |
466 av_log(avctx, AV_LOG_ERROR, "outputsamples %d > %d\n", outputsamples, alac->setinfo_max_samples_per_frame); | |
467 return -1; | |
468 } | |
5361 | 469 } else |
470 outputsamples = alac->setinfo_max_samples_per_frame; | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
471 |
6744 | 472 if(outputsamples > *outputsize / alac->bytespersample){ |
473 av_log(avctx, AV_LOG_ERROR, "sample buffer too small\n"); | |
474 return -1; | |
475 } | |
476 | |
5361 | 477 *outputsize = outputsamples * alac->bytespersample; |
478 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + channels - 1; | |
7660
6fe7ff34a4db
alac : check readsamplesize to ensure get_bits() doesn't
jai_menon
parents:
7451
diff
changeset
|
479 if (readsamplesize > MIN_CACHE_BITS) { |
6fe7ff34a4db
alac : check readsamplesize to ensure get_bits() doesn't
jai_menon
parents:
7451
diff
changeset
|
480 av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize); |
6fe7ff34a4db
alac : check readsamplesize to ensure get_bits() doesn't
jai_menon
parents:
7451
diff
changeset
|
481 return -1; |
6fe7ff34a4db
alac : check readsamplesize to ensure get_bits() doesn't
jai_menon
parents:
7451
diff
changeset
|
482 } |
5271 | 483 |
5361 | 484 if (!isnotcompressed) { |
485 /* so it is compressed */ | |
486 int16_t predictor_coef_table[channels][32]; | |
487 int predictor_coef_num[channels]; | |
488 int prediction_type[channels]; | |
489 int prediction_quantitization[channels]; | |
490 int ricemodifier[channels]; | |
491 int i, chan; | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
492 |
5361 | 493 interlacing_shift = get_bits(&alac->gb, 8); |
494 interlacing_leftweight = get_bits(&alac->gb, 8); | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
495 |
5361 | 496 for (chan = 0; chan < channels; chan++) { |
5357
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
497 prediction_type[chan] = get_bits(&alac->gb, 4); |
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
498 prediction_quantitization[chan] = get_bits(&alac->gb, 4); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
499 |
5357
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
500 ricemodifier[chan] = get_bits(&alac->gb, 3); |
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
501 predictor_coef_num[chan] = get_bits(&alac->gb, 5); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
502 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
503 /* read the predictor table */ |
5365 | 504 for (i = 0; i < predictor_coef_num[chan]; i++) |
5357
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
505 predictor_coef_table[chan][i] = (int16_t)get_bits(&alac->gb, 16); |
5361 | 506 } |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
507 |
5400 | 508 if (wasted_bytes) |
5361 | 509 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n"); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
510 |
5361 | 511 for (chan = 0; chan < channels; chan++) { |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
512 bastardized_rice_decompress(alac, |
5357
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
513 alac->predicterror_buffer[chan], |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
514 outputsamples, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
515 readsamplesize, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
516 alac->setinfo_rice_initialhistory, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
517 alac->setinfo_rice_kmodifier, |
5357
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
518 ricemodifier[chan] * alac->setinfo_rice_historymult / 4, |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
519 (1 << alac->setinfo_rice_kmodifier) - 1); |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
520 |
5357
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
521 if (prediction_type[chan] == 0) { |
5361 | 522 /* adaptive fir */ |
5357
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
523 predictor_decompress_fir_adapt(alac->predicterror_buffer[chan], |
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
524 alac->outputsamples_buffer[chan], |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
525 outputsamples, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
526 readsamplesize, |
5357
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
527 predictor_coef_table[chan], |
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
528 predictor_coef_num[chan], |
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
529 prediction_quantitization[chan]); |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
530 } else { |
5357
07c6fa478918
Remove code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5298
diff
changeset
|
531 av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type[chan]); |
5366 | 532 /* I think the only other prediction type (or perhaps this is |
533 * just a boolean?) runs adaptive fir twice.. like: | |
5359
4743a1e95531
Remove more code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5358
diff
changeset
|
534 * predictor_decompress_fir_adapt(predictor_error, tempout, ...) |
4743a1e95531
Remove more code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5358
diff
changeset
|
535 * predictor_decompress_fir_adapt(predictor_error, outputsamples ...) |
4743a1e95531
Remove more code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5358
diff
changeset
|
536 * little strange.. |
4743a1e95531
Remove more code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5358
diff
changeset
|
537 */ |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
538 } |
5361 | 539 } |
540 } else { | |
541 /* not compressed, easy case */ | |
6779
a25842a4df43
cosmetics: indent after last commit. patch by matthieu castet <castet matthieu free fr>.
jbr
parents:
6778
diff
changeset
|
542 int i, chan; |
7043
e1ed057dc7c3
fix verbatim mode decoding. patch by Jai Menon (realityman gmx net).
jbr
parents:
7040
diff
changeset
|
543 for (i = 0; i < outputsamples; i++) |
e1ed057dc7c3
fix verbatim mode decoding. patch by Jai Menon (realityman gmx net).
jbr
parents:
7040
diff
changeset
|
544 for (chan = 0; chan < channels; chan++) { |
6779
a25842a4df43
cosmetics: indent after last commit. patch by matthieu castet <castet matthieu free fr>.
jbr
parents:
6778
diff
changeset
|
545 int32_t audiobits; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
546 |
6779
a25842a4df43
cosmetics: indent after last commit. patch by matthieu castet <castet matthieu free fr>.
jbr
parents:
6778
diff
changeset
|
547 audiobits = get_bits_long(&alac->gb, alac->setinfo_sample_size); |
a25842a4df43
cosmetics: indent after last commit. patch by matthieu castet <castet matthieu free fr>.
jbr
parents:
6778
diff
changeset
|
548 audiobits = extend_sign32(audiobits, alac->setinfo_sample_size); |
5359
4743a1e95531
Remove more code duplication. Based on a patch by Matthieu Castet.
vitor
parents:
5358
diff
changeset
|
549 |
6779
a25842a4df43
cosmetics: indent after last commit. patch by matthieu castet <castet matthieu free fr>.
jbr
parents:
6778
diff
changeset
|
550 alac->outputsamples_buffer[chan][i] = audiobits; |
a25842a4df43
cosmetics: indent after last commit. patch by matthieu castet <castet matthieu free fr>.
jbr
parents:
6778
diff
changeset
|
551 } |
5361 | 552 /* wasted_bytes = 0; */ |
553 interlacing_shift = 0; | |
554 interlacing_leftweight = 0; | |
555 } | |
6641 | 556 if (get_bits(&alac->gb, 3) != 7) |
557 av_log(avctx, AV_LOG_ERROR, "Error : Wrong End Of Frame\n"); | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
558 |
5361 | 559 switch(alac->setinfo_sample_size) { |
5400 | 560 case 16: |
5361 | 561 if (channels == 2) { |
5504 | 562 reconstruct_stereo_16(alac->outputsamples_buffer, |
5506 | 563 (int16_t*)outbuffer, |
564 alac->numchannels, | |
565 outputsamples, | |
566 interlacing_shift, | |
567 interlacing_leftweight); | |
5361 | 568 } else { |
569 int i; | |
570 for (i = 0; i < outputsamples; i++) { | |
571 int16_t sample = alac->outputsamples_buffer[0][i]; | |
572 ((int16_t*)outbuffer)[i * alac->numchannels] = sample; | |
573 } | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
574 } |
5361 | 575 break; |
576 case 20: | |
577 case 24: | |
5624 | 578 // It is not clear if there exist any encoder that creates 24 bit ALAC |
579 // files. iTunes convert 24 bit raw files to 16 bit before encoding. | |
5361 | 580 case 32: |
581 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size); | |
582 break; | |
583 default: | |
584 break; | |
585 } | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
586 |
6641 | 587 if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8) |
588 av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb)); | |
589 | |
2544
8c426f5a09ae
decoder works fine now, when fed properly-sized chunks by the demuxer;
melanson
parents:
2543
diff
changeset
|
590 return input_buffer_size; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
591 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
592 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6221
diff
changeset
|
593 static av_cold int alac_decode_init(AVCodecContext * avctx) |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
594 { |
2559
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
595 ALACContext *alac = avctx->priv_data; |
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
596 alac->avctx = avctx; |
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
597 alac->context_initialized = 0; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
598 |
2559
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
599 alac->numchannels = alac->avctx->channels; |
7836
fe449020b713
alac : fix case where bits_per_sample is not set.
jai_menon
parents:
7823
diff
changeset
|
600 alac->bytespersample = 2 * alac->numchannels; |
7451
85ab7655ad4d
Modify all codecs to report their supported input and output sample format(s).
pross
parents:
7043
diff
changeset
|
601 avctx->sample_fmt = SAMPLE_FMT_S16; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
602 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
603 return 0; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
604 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
605 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6221
diff
changeset
|
606 static av_cold int alac_decode_close(AVCodecContext *avctx) |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
607 { |
2559
7d8ba28e18d9
replace custom bit-reading functions with FFmpeg's internal function;
melanson
parents:
2546
diff
changeset
|
608 ALACContext *alac = avctx->priv_data; |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
609 |
5272 | 610 int chan; |
611 for (chan = 0; chan < MAX_CHANNELS; chan++) { | |
612 av_free(alac->predicterror_buffer[chan]); | |
613 av_free(alac->outputsamples_buffer[chan]); | |
614 } | |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
615 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
616 return 0; |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
617 } |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
618 |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
619 AVCodec alac_decoder = { |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
620 "alac", |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
621 CODEC_TYPE_AUDIO, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
622 CODEC_ID_ALAC, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
623 sizeof(ALACContext), |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
624 alac_decode_init, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
625 NULL, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
626 alac_decode_close, |
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
627 alac_decode_frame, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6779
diff
changeset
|
628 .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), |
2542
a27a580f292e
first pass at ALAC decoder from David Hammerton; while David's original
melanson
parents:
diff
changeset
|
629 }; |