Mercurial > audlegacy-plugins
annotate src/alac/alac.c @ 3191:a65f440cbed3
alsa-ng: Fix possible race conditions, sluggish pause and seek.
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Mon, 22 Jun 2009 16:05:57 -0400 |
parents | 99dd09396885 |
children |
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 actual decoder. |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
7 * |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
8 * http://crazney.net/programs/itunes/alac.html |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
9 * |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
10 * Permission is hereby granted, free of charge, to any person |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
11 * obtaining a copy of this software and associated documentation |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
12 * files (the "Software"), to deal in the Software without |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
13 * restriction, including without limitation the rights to use, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
14 * copy, modify, merge, publish, distribute, sublicense, and/or |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
15 * sell copies of the Software, and to permit persons to whom the |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
16 * Software is furnished to do so, subject to the following conditions: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
17 * |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
18 * The above copyright notice and this permission notice shall be |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
19 * included in all copies or substantial portions of the Software. |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
20 * |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
28 * OTHER DEALINGS IN THE SOFTWARE. |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
29 * |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
30 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
31 |
330 | 32 #include "config.h" |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
33 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
34 #include <stdio.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
35 #include <stdlib.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
36 #include <string.h> |
330 | 37 |
38 #if HAVE_STDINT_H | |
39 # include <stdint.h> | |
40 #else | |
41 # if HAVE_INTTYPES_H | |
42 # include <inttypes.h> | |
43 # endif | |
44 #endif | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
45 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
46 #include "decomp.h" |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
47 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
48 #define _Swap32(v) do { \ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
49 v = (((v) & 0x000000FF) << 0x18) | \ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
50 (((v) & 0x0000FF00) << 0x08) | \ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
51 (((v) & 0x00FF0000) >> 0x08) | \ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
52 (((v) & 0xFF000000) >> 0x18); } while(0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
53 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
54 #define _Swap16(v) do { \ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
55 v = (((v) & 0x00FF) << 0x08) | \ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
56 (((v) & 0xFF00) >> 0x08); } while (0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
57 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
58 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
59 int host_bigendian; |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
60 |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
61 void set_endian() |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
62 { |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
63 uint32_t integer = 0x000000aa; |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
64 unsigned char *p = (unsigned char*)&integer; |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
65 |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
66 if (p[0] == 0xaa) host_bigendian = 0; |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
67 else host_bigendian = 1; |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
68 } |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
69 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
70 struct alac_file |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
71 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
72 unsigned char *input_buffer; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
73 int input_buffer_bitaccumulator; /* used so we can do arbitary |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
74 bit reads */ |
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 int samplesize; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
77 int numchannels; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
78 int bytespersample; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
79 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
80 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
81 /* buffers */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
82 int32_t *predicterror_buffer_a; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
83 int32_t *predicterror_buffer_b; |
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 int32_t *outputsamples_buffer_a; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
86 int32_t *outputsamples_buffer_b; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
87 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
88 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
89 /* stuff from setinfo */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
90 uint32_t setinfo_max_samples_per_frame; /* 0x1000 = 4096 */ /* max samples per frame? */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
91 uint8_t setinfo_7a; /* 0x00 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
92 uint8_t setinfo_sample_size; /* 0x10 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
93 uint8_t setinfo_rice_historymult; /* 0x28 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
94 uint8_t setinfo_rice_initialhistory; /* 0x0a */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
95 uint8_t setinfo_rice_kmodifier; /* 0x0e */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
96 uint8_t setinfo_7f; /* 0x02 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
97 uint16_t setinfo_80; /* 0x00ff */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
98 uint32_t setinfo_82; /* 0x000020e7 */ /* max sample size?? */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
99 uint32_t setinfo_86; /* 0x00069fe4 */ /* bit rate (avarge)?? */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
100 uint32_t setinfo_8a_rate; /* 0x0000ac44 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
101 /* end setinfo stuff */ |
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 }; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
104 |
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 static void allocate_buffers(alac_file *alac) |
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 alac->predicterror_buffer_a = malloc(alac->setinfo_max_samples_per_frame * 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
109 alac->predicterror_buffer_b = malloc(alac->setinfo_max_samples_per_frame * 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
110 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
111 alac->outputsamples_buffer_a = malloc(alac->setinfo_max_samples_per_frame * 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
112 alac->outputsamples_buffer_b = malloc(alac->setinfo_max_samples_per_frame * 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
113 } |
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 void alac_set_info(alac_file *alac, char *inputbuffer) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
116 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
117 char *ptr = inputbuffer; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
118 ptr += 4; /* size */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
119 ptr += 4; /* frma */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
120 ptr += 4; /* alac */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
121 ptr += 4; /* size */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
122 ptr += 4; /* alac */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
123 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
124 ptr += 4; /* 0 ? */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
125 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
126 alac->setinfo_max_samples_per_frame = *(uint32_t*)ptr; /* buffer size / 2 ? */ |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
127 if (!host_bigendian) |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
128 _Swap32(alac->setinfo_max_samples_per_frame); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
129 ptr += 4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
130 alac->setinfo_7a = *(uint8_t*)ptr; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
131 ptr += 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
132 alac->setinfo_sample_size = *(uint8_t*)ptr; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
133 ptr += 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
134 alac->setinfo_rice_historymult = *(uint8_t*)ptr; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
135 ptr += 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
136 alac->setinfo_rice_initialhistory = *(uint8_t*)ptr; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
137 ptr += 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
138 alac->setinfo_rice_kmodifier = *(uint8_t*)ptr; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
139 ptr += 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
140 alac->setinfo_7f = *(uint8_t*)ptr; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
141 ptr += 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
142 alac->setinfo_80 = *(uint16_t*)ptr; |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
143 if (!host_bigendian) |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
144 _Swap16(alac->setinfo_80); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
145 ptr += 2; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
146 alac->setinfo_82 = *(uint32_t*)ptr; |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
147 if (!host_bigendian) |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
148 _Swap32(alac->setinfo_82); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
149 ptr += 4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
150 alac->setinfo_86 = *(uint32_t*)ptr; |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
151 if (!host_bigendian) |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
152 _Swap32(alac->setinfo_86); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
153 ptr += 4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
154 alac->setinfo_8a_rate = *(uint32_t*)ptr; |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
155 if (!host_bigendian) |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
156 _Swap32(alac->setinfo_8a_rate); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
157 ptr += 4; |
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 allocate_buffers(alac); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
160 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
161 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
162 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
163 /* stream reading */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
164 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
165 /* supports reading 1 to 16 bits, in big endian format */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
166 static uint32_t readbits_16(alac_file *alac, int bits) |
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 uint32_t result; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
169 int new_accumulator; |
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 result = (alac->input_buffer[0] << 16) | |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
172 (alac->input_buffer[1] << 8) | |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
173 (alac->input_buffer[2]); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
174 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
175 /* shift left by the number of bits we've already read, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
176 * so that the top 'n' bits of the 24 bits we read will |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
177 * be the return bits */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
178 result = result << alac->input_buffer_bitaccumulator; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
179 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
180 result = result & 0x00ffffff; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
181 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
182 /* and then only want the top 'n' bits from that, where |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
183 * n is 'bits' */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
184 result = result >> (24 - bits); |
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 new_accumulator = (alac->input_buffer_bitaccumulator + bits); |
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 /* increase the buffer pointer if we've read over n bytes. */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
189 alac->input_buffer += (new_accumulator >> 3); |
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 /* and the remainder goes back into the bit accumulator */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
192 alac->input_buffer_bitaccumulator = (new_accumulator & 7); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
193 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
194 return result; |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
197 /* supports reading 1 to 32 bits, in big endian format */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
198 static uint32_t readbits(alac_file *alac, int bits) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
199 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
200 int32_t result = 0; |
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 if (bits > 16) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
203 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
204 bits -= 16; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
205 result = readbits_16(alac, 16) << bits; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
206 } |
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 result |= readbits_16(alac, bits); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
209 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
210 return result; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
211 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
212 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
213 /* reads a single bit */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
214 static int readbit(alac_file *alac) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
215 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
216 int result; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
217 int new_accumulator; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
218 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
219 result = alac->input_buffer[0]; |
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 result = result << alac->input_buffer_bitaccumulator; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
222 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
223 result = result >> 7 & 1; |
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 new_accumulator = (alac->input_buffer_bitaccumulator + 1); |
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 alac->input_buffer += (new_accumulator / 8); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
228 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
229 alac->input_buffer_bitaccumulator = (new_accumulator % 8); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
230 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
231 return result; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
232 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
233 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
234 static void unreadbits(alac_file *alac, int bits) |
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 int new_accumulator = (alac->input_buffer_bitaccumulator - bits); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
237 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
238 alac->input_buffer += (new_accumulator >> 3); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
239 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
240 alac->input_buffer_bitaccumulator = (new_accumulator & 7); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
241 if (alac->input_buffer_bitaccumulator < 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
242 alac->input_buffer_bitaccumulator *= -1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
243 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
244 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
245 /* various implementations of count_leading_zero: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
246 * the first one is the original one, the simplest and most |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
247 * obvious for what it's doing. never use this. |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
248 * then there are the asm ones. fill in as necessary |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
249 * and finally an unrolled and optimised c version |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
250 * to fall back to |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
251 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
252 #if 0 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
253 /* hideously inefficient. could use a bitmask search, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
254 * alternatively bsr on x86, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
255 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
256 static int count_leading_zeros(int32_t input) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
257 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
258 int i = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
259 while (!(0x80000000 & input) && i < 32) |
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 i++; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
262 input = input << 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
263 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
264 return i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
265 } |
2700
99dd09396885
killed the alac warning on amd64 too
Cristi Magherusan <majeru@atheme.org>
parents:
557
diff
changeset
|
266 |
99dd09396885
killed the alac warning on amd64 too
Cristi Magherusan <majeru@atheme.org>
parents:
557
diff
changeset
|
267 #elif defined(__GNUC__) && (defined(_X86) || defined(__i386) || defined(i386) \ |
99dd09396885
killed the alac warning on amd64 too
Cristi Magherusan <majeru@atheme.org>
parents:
557
diff
changeset
|
268 || defined(_X86_64) || defined(__x86_64__) || defined(x86_64)) |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
269 /* for some reason the unrolled version (below) is |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
270 * actually faster than this. yay intel! |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
271 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
272 static int count_leading_zeros(int input) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
273 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
274 int output = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
275 if (!input) return 32; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
276 asm("bsr %1, %0\n" |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
277 : "=r" (output) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
278 : "r" (input)); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
279 return (0x1f - output); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
280 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
281 #elif defined(_MSC_VER) && defined(_M_IX86) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
282 static int count_leading_zeros(int input) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
283 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
284 int output = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
285 if (!input) return 32; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
286 __asm |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
287 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
288 mov eax, input; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
289 mov edx, 0x1f; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
290 bsr ecx, eax; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
291 sub edx, ecx; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
292 mov output, edx; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
293 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
294 return output; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
295 } |
557
732f07a601bc
[svn] Count leading zeroes as PPC assembler. Implemented by Joseph Jezak (JoseJX) from Gentoo.
chainsaw
parents:
330
diff
changeset
|
296 #elif defined (__powerpc__) || defined (__ppc__) || defined (__POWERPC__) || defined (__powerc) |
732f07a601bc
[svn] Count leading zeroes as PPC assembler. Implemented by Joseph Jezak (JoseJX) from Gentoo.
chainsaw
parents:
330
diff
changeset
|
297 static int count_leading_zeros(int input) |
732f07a601bc
[svn] Count leading zeroes as PPC assembler. Implemented by Joseph Jezak (JoseJX) from Gentoo.
chainsaw
parents:
330
diff
changeset
|
298 { |
732f07a601bc
[svn] Count leading zeroes as PPC assembler. Implemented by Joseph Jezak (JoseJX) from Gentoo.
chainsaw
parents:
330
diff
changeset
|
299 int output = 0; |
732f07a601bc
[svn] Count leading zeroes as PPC assembler. Implemented by Joseph Jezak (JoseJX) from Gentoo.
chainsaw
parents:
330
diff
changeset
|
300 if (!input) return 32; |
732f07a601bc
[svn] Count leading zeroes as PPC assembler. Implemented by Joseph Jezak (JoseJX) from Gentoo.
chainsaw
parents:
330
diff
changeset
|
301 asm("cntlzw %0, %1": "=r"(output):"r"(input)); |
732f07a601bc
[svn] Count leading zeroes as PPC assembler. Implemented by Joseph Jezak (JoseJX) from Gentoo.
chainsaw
parents:
330
diff
changeset
|
302 return output; |
732f07a601bc
[svn] Count leading zeroes as PPC assembler. Implemented by Joseph Jezak (JoseJX) from Gentoo.
chainsaw
parents:
330
diff
changeset
|
303 } |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
304 #else |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
305 #warning using generic count leading zeroes. You may wish to write one for your CPU / compiler |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
306 static int count_leading_zeros(int input) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
307 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
308 int output = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
309 int curbyte = 0; |
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 curbyte = input >> 24; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
312 if (curbyte) goto found; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
313 output += 8; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
314 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
315 curbyte = input >> 16; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
316 if (curbyte & 0xff) goto found; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
317 output += 8; |
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 curbyte = input >> 8; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
320 if (curbyte & 0xff) goto found; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
321 output += 8; |
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 curbyte = input; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
324 if (curbyte & 0xff) goto found; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
325 output += 8; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
326 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
327 return output; |
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 found: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
330 if (!(curbyte & 0xf0)) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
331 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
332 output += 4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
333 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
334 else |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
335 curbyte >>= 4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
336 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
337 if (curbyte & 0x8) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
338 return output; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
339 if (curbyte & 0x4) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
340 return output + 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
341 if (curbyte & 0x2) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
342 return output + 2; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
343 if (curbyte & 0x1) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
344 return output + 3; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
345 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
346 /* shouldn't get here: */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
347 return output + 4; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
348 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
349 #endif |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
350 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
351 void basterdised_rice_decompress(alac_file *alac, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
352 int32_t *output_buffer, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
353 int output_size, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
354 int readsamplesize, /* arg_10 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
355 int rice_initialhistory, /* arg424->b */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
356 int rice_kmodifier, /* arg424->d */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
357 int rice_historymult, /* arg424->c */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
358 int rice_kmodifier_mask /* arg424->e */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
359 ) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
360 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
361 int output_count; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
362 unsigned int history = rice_initialhistory; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
363 int sign_modifier = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
364 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
365 for (output_count = 0; output_count < output_size; output_count++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
366 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
367 int32_t x = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
368 int32_t x_modified; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
369 int32_t final_val; |
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 /* read x - number of 1s before 0 represent the rice */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
372 while (x <= 8 && readbit(alac)) |
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 x++; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
375 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
376 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
377 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
378 if (x > 8) /* RICE THRESHOLD */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
379 { /* use alternative encoding */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
380 int32_t value; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
381 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
382 value = readbits(alac, readsamplesize); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
383 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
384 /* mask value to readsamplesize size */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
385 if (readsamplesize != 32) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
386 value &= (0xffffffff >> (32 - readsamplesize)); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
387 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
388 x = value; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
389 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
390 else |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
391 { /* standard rice encoding */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
392 int extrabits; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
393 int k; /* size of extra bits */ |
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 /* read k, that is bits as is */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
396 k = 31 - rice_kmodifier - count_leading_zeros((history >> 9) + 3); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
397 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
398 if (k < 0) k += rice_kmodifier; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
399 else k = rice_kmodifier; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
400 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
401 if (k != 1) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
402 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
403 extrabits = readbits(alac, k); |
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 /* multiply x by 2^k - 1, as part of their strange algorithm */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
406 x = (x << k) - x; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
407 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
408 if (extrabits > 1) |
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 x += extrabits - 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
411 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
412 else unreadbits(alac, 1); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
413 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
414 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
415 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
416 x_modified = sign_modifier + x; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
417 final_val = (x_modified + 1) / 2; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
418 if (x_modified & 1) final_val *= -1; |
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 output_buffer[output_count] = final_val; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
421 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
422 sign_modifier = 0; |
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 /* now update the history */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
425 history += (x_modified * rice_historymult) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
426 - ((history * rice_historymult) >> 9); |
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 if (x_modified > 0xffff) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
429 history = 0xffff; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
430 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
431 /* special case: there may be compressed blocks of 0 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
432 if ((history < 128) && (output_count+1 < output_size)) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
433 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
434 int block_size; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
435 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
436 sign_modifier = 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
437 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
438 x = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
439 while (x <= 8 && readbit(alac)) |
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 x++; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
442 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
443 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
444 if (x > 8) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
445 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
446 block_size = readbits(alac, 16); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
447 block_size &= 0xffff; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
448 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
449 else |
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 int k; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
452 int extrabits; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
453 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
454 k = count_leading_zeros(history) + ((history + 16) >> 6 /* / 64 */) - 24; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
455 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
456 extrabits = readbits(alac, k); |
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 block_size = (((1 << k) - 1) & rice_kmodifier_mask) * x |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
459 + extrabits - 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
460 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
461 if (extrabits < 2) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
462 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
463 x = 1 - extrabits; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
464 block_size += x; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
465 unreadbits(alac, 1); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
466 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
467 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
468 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
469 if (block_size > 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
470 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
471 memset(&output_buffer[output_count+1], 0, block_size * 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
472 output_count += block_size; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
473 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
474 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
475 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
476 if (block_size > 0xffff) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
477 sign_modifier = 0; |
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 history = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
480 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
481 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
482 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
483 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
484 #define SIGN_EXTENDED32(val, bits) ((val << (32 - bits)) >> (32 - bits)) |
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 #define SIGN_ONLY(v) \ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
487 ((v < 0) ? (-1) : \ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
488 ((v > 0) ? (1) : \ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
489 (0))) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
490 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
491 static void predictor_decompress_fir_adapt(int32_t *error_buffer, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
492 int32_t *buffer_out, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
493 int output_size, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
494 int readsamplesize, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
495 int16_t *predictor_coef_table, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
496 int predictor_coef_num, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
497 int predictor_quantitization) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
498 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
499 int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
500 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
501 /* first sample always copies */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
502 *buffer_out = *error_buffer; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
503 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
504 if (!predictor_coef_num) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
505 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
506 if (output_size <= 1) return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
507 memcpy(buffer_out+1, error_buffer+1, (output_size-1) * 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
508 return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
509 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
510 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
511 if (predictor_coef_num == 0x1f) /* 11111 - max value of predictor_coef_num */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
512 { /* second-best case scenario for fir decompression, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
513 * error describes a small difference from the previous sample only |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
514 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
515 if (output_size <= 1) return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
516 for (i = 0; i < output_size - 1; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
517 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
518 int32_t prev_value; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
519 int32_t error_value; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
520 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
521 prev_value = buffer_out[i]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
522 error_value = error_buffer[i+1]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
523 buffer_out[i+1] = SIGN_EXTENDED32((prev_value + error_value), readsamplesize); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
524 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
525 return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
526 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
527 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
528 /* read warm-up samples */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
529 if (predictor_coef_num > 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
530 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
531 int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
532 for (i = 0; i < predictor_coef_num; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
533 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
534 int32_t val; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
535 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
536 val = buffer_out[i] + error_buffer[i+1]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
537 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
538 val = SIGN_EXTENDED32(val, readsamplesize); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
539 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
540 buffer_out[i+1] = val; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
541 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
542 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
543 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
544 #if 0 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
545 /* 4 and 8 are very common cases (the only ones i've seen). these |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
546 * should be unrolled and optimised |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
547 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
548 if (predictor_coef_num == 4) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
549 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
550 /* FIXME: optimised general case */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
551 return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
552 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
553 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
554 if (predictor_coef_table == 8) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
555 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
556 /* FIXME: optimised general case */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
557 return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
558 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
559 #endif |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
560 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
561 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
562 /* general case */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
563 if (predictor_coef_num > 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
564 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
565 for (i = predictor_coef_num + 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
566 i < output_size; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
567 i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
568 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
569 int j; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
570 int sum = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
571 int outval; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
572 int error_val = error_buffer[i]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
573 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
574 for (j = 0; j < predictor_coef_num; j++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
575 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
576 sum += (buffer_out[predictor_coef_num-j] - buffer_out[0]) * |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
577 predictor_coef_table[j]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
578 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
579 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
580 outval = (1 << (predictor_quantitization-1)) + sum; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
581 outval = outval >> predictor_quantitization; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
582 outval = outval + buffer_out[0] + error_val; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
583 outval = SIGN_EXTENDED32(outval, readsamplesize); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
584 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
585 buffer_out[predictor_coef_num+1] = outval; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
586 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
587 if (error_val > 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
588 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
589 int predictor_num = predictor_coef_num - 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
590 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
591 while (predictor_num >= 0 && error_val > 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
592 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
593 int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
594 int sign = SIGN_ONLY(val); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
595 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
596 predictor_coef_table[predictor_num] -= sign; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
597 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
598 val *= sign; /* absolute value */ |
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 error_val -= ((val >> predictor_quantitization) * |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
601 (predictor_coef_num - predictor_num)); |
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 predictor_num--; |
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 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
606 else if (error_val < 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
607 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
608 int predictor_num = predictor_coef_num - 1; |
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 while (predictor_num >= 0 && error_val < 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
611 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
612 int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
613 int sign = - SIGN_ONLY(val); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
614 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
615 predictor_coef_table[predictor_num] -= sign; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
616 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
617 val *= sign; /* neg value */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
618 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
619 error_val -= ((val >> predictor_quantitization) * |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
620 (predictor_coef_num - predictor_num)); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
621 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
622 predictor_num--; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
623 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
624 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
625 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
626 buffer_out++; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
627 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
628 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
629 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
630 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
631 void deinterlace_16(int32_t *buffer_a, int32_t *buffer_b, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
632 int16_t *buffer_out, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
633 int numchannels, int numsamples, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
634 uint8_t interlacing_shift, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
635 uint8_t interlacing_leftweight) |
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 int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
638 if (numsamples <= 0) return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
639 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
640 /* weighted interlacing */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
641 if (interlacing_leftweight) |
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 for (i = 0; i < numsamples; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
644 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
645 int32_t difference, midright; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
646 int16_t left; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
647 int16_t right; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
648 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
649 midright = buffer_a[i]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
650 difference = buffer_b[i]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
651 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
652 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
653 right = midright - ((difference * interlacing_leftweight) >> interlacing_shift); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
654 left = right + difference; |
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 /* output is always little endian */ |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
657 if (host_bigendian) |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
658 { |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
659 _Swap16(left); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
660 _Swap16(right); |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
661 } |
56
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 buffer_out[i*numchannels] = left; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
664 buffer_out[i*numchannels + 1] = right; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
665 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
666 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
667 return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
668 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
669 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
670 /* otherwise basic interlacing took place */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
671 for (i = 0; i < numsamples; i++) |
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 int16_t left, right; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
674 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
675 left = buffer_a[i]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
676 right = buffer_b[i]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
677 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
678 /* output is always little endian */ |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
679 if (host_bigendian) |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
680 { |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
681 _Swap16(left); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
682 _Swap16(right); |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
683 } |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
684 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
685 buffer_out[i*numchannels] = left; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
686 buffer_out[i*numchannels + 1] = right; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
687 } |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
690 void decode_frame(alac_file *alac, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
691 unsigned char *inbuffer, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
692 void *outbuffer, int *outputsize) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
693 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
694 int channels; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
695 int32_t outputsamples = alac->setinfo_max_samples_per_frame; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
696 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
697 /* setup the stream */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
698 alac->input_buffer = inbuffer; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
699 alac->input_buffer_bitaccumulator = 0; |
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 channels = readbits(alac, 3); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
702 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
703 *outputsize = outputsamples * alac->bytespersample; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
704 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
705 switch(channels) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
706 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
707 case 0: /* 1 channel */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
708 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
709 int hassize; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
710 int isnotcompressed; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
711 int readsamplesize; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
712 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
713 int wasted_bytes; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
714 int ricemodifier; |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
717 /* 2^result = something to do with output waiting. |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
718 * perhaps matters if we read > 1 frame in a pass? |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
719 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
720 readbits(alac, 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
721 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
722 readbits(alac, 12); /* unknown, skip 12 bits */ |
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 hassize = readbits(alac, 1); /* the output sample size is stored soon */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
725 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
726 wasted_bytes = readbits(alac, 2); /* unknown ? */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
727 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
728 isnotcompressed = readbits(alac, 1); /* whether the frame is compressed */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
729 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
730 if (hassize) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
731 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
732 /* now read the number of samples, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
733 * as a 32bit integer */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
734 outputsamples = readbits(alac, 32); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
735 *outputsize = outputsamples * alac->bytespersample; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
736 } |
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 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
739 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
740 if (!isnotcompressed) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
741 { /* so it is compressed */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
742 int16_t predictor_coef_table[32]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
743 int predictor_coef_num; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
744 int prediction_type; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
745 int prediction_quantitization; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
746 int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
747 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
748 /* skip 16 bits, not sure what they are. seem to be used in |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
749 * two channel case */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
750 readbits(alac, 8); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
751 readbits(alac, 8); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
752 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
753 prediction_type = readbits(alac, 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
754 prediction_quantitization = readbits(alac, 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
755 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
756 ricemodifier = readbits(alac, 3); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
757 predictor_coef_num = readbits(alac, 5); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
758 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
759 /* read the predictor table */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
760 for (i = 0; i < predictor_coef_num; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
761 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
762 predictor_coef_table[i] = (int16_t)readbits(alac, 16); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
763 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
764 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
765 if (wasted_bytes) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
766 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
767 /* these bytes seem to have something to do with |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
768 * > 2 channel files. |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
769 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
770 fprintf(stderr, "FIXME: unimplemented, unhandling of wasted_bytes\n"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
771 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
772 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
773 basterdised_rice_decompress(alac, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
774 alac->predicterror_buffer_a, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
775 outputsamples, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
776 readsamplesize, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
777 alac->setinfo_rice_initialhistory, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
778 alac->setinfo_rice_kmodifier, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
779 ricemodifier * alac->setinfo_rice_historymult / 4, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
780 (1 << alac->setinfo_rice_kmodifier) - 1); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
781 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
782 if (prediction_type == 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
783 { /* adaptive fir */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
784 predictor_decompress_fir_adapt(alac->predicterror_buffer_a, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
785 alac->outputsamples_buffer_a, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
786 outputsamples, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
787 readsamplesize, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
788 predictor_coef_table, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
789 predictor_coef_num, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
790 prediction_quantitization); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
791 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
792 else |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
793 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
794 fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
795 /* i think the only other prediction type (or perhaps this is just a |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
796 * boolean?) runs adaptive fir twice.. like: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
797 * predictor_decompress_fir_adapt(predictor_error, tempout, ...) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
798 * predictor_decompress_fir_adapt(predictor_error, outputsamples ...) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
799 * little strange.. |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
800 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
801 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
802 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
803 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
804 else |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
805 { /* not compressed, easy case */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
806 if (readsamplesize <= 16) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
807 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
808 int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
809 for (i = 0; i < outputsamples; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
810 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
811 int32_t audiobits = readbits(alac, readsamplesize); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
812 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
813 audiobits = SIGN_EXTENDED32(audiobits, readsamplesize); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
814 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
815 alac->outputsamples_buffer_a[i] = audiobits; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
816 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
817 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
818 else |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
819 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
820 int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
821 for (i = 0; i < outputsamples; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
822 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
823 int32_t audiobits; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
824 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
825 audiobits = readbits(alac, 16); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
826 /* special case of sign extension.. |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
827 * as we'll be ORing the low 16bits into this */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
828 audiobits = audiobits << 16; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
829 audiobits = audiobits >> (32 - readsamplesize); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
830 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
831 audiobits |= readbits(alac, readsamplesize - 16); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
832 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
833 alac->outputsamples_buffer_a[i] = audiobits; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
834 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
835 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
836 /* wasted_bytes = 0; // unused */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
837 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
838 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
839 switch(alac->setinfo_sample_size) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
840 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
841 case 16: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
842 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
843 int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
844 for (i = 0; i < outputsamples; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
845 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
846 int16_t sample = alac->outputsamples_buffer_a[i]; |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
847 if (host_bigendian) |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
848 _Swap16(sample); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
849 ((int16_t*)outbuffer)[i * alac->numchannels] = sample; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
850 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
851 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
852 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
853 case 20: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
854 case 24: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
855 case 32: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
856 fprintf(stderr, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
857 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
858 default: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
859 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
860 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
861 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
862 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
863 case 1: /* 2 channels */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
864 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
865 int hassize; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
866 int isnotcompressed; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
867 int readsamplesize; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
868 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
869 int wasted_bytes; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
870 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
871 uint8_t interlacing_shift; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
872 uint8_t interlacing_leftweight; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
873 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
874 /* 2^result = something to do with output waiting. |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
875 * perhaps matters if we read > 1 frame in a pass? |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
876 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
877 readbits(alac, 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
878 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
879 readbits(alac, 12); /* unknown, skip 12 bits */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
880 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
881 hassize = readbits(alac, 1); /* the output sample size is stored soon */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
882 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
883 wasted_bytes = readbits(alac, 2); /* unknown ? */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
884 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
885 isnotcompressed = readbits(alac, 1); /* whether the frame is compressed */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
886 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
887 if (hassize) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
888 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
889 /* now read the number of samples, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
890 * as a 32bit integer */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
891 outputsamples = readbits(alac, 32); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
892 *outputsize = outputsamples * alac->bytespersample; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
893 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
894 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
895 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
896 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
897 if (!isnotcompressed) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
898 { /* compressed */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
899 int16_t predictor_coef_table_a[32]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
900 int predictor_coef_num_a; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
901 int prediction_type_a; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
902 int prediction_quantitization_a; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
903 int ricemodifier_a; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
904 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
905 int16_t predictor_coef_table_b[32]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
906 int predictor_coef_num_b; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
907 int prediction_type_b; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
908 int prediction_quantitization_b; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
909 int ricemodifier_b; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
910 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
911 int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
912 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
913 interlacing_shift = readbits(alac, 8); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
914 interlacing_leftweight = readbits(alac, 8); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
915 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
916 /******** channel 1 ***********/ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
917 prediction_type_a = readbits(alac, 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
918 prediction_quantitization_a = readbits(alac, 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
919 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
920 ricemodifier_a = readbits(alac, 3); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
921 predictor_coef_num_a = readbits(alac, 5); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
922 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
923 /* read the predictor table */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
924 for (i = 0; i < predictor_coef_num_a; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
925 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
926 predictor_coef_table_a[i] = (int16_t)readbits(alac, 16); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
927 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
928 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
929 /******** channel 2 *********/ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
930 prediction_type_b = readbits(alac, 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
931 prediction_quantitization_b = readbits(alac, 4); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
932 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
933 ricemodifier_b = readbits(alac, 3); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
934 predictor_coef_num_b = readbits(alac, 5); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
935 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
936 /* read the predictor table */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
937 for (i = 0; i < predictor_coef_num_b; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
938 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
939 predictor_coef_table_b[i] = (int16_t)readbits(alac, 16); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
940 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
941 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
942 /*********************/ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
943 if (wasted_bytes) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
944 { /* see mono case */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
945 fprintf(stderr, "FIXME: unimplemented, unhandling of wasted_bytes\n"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
946 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
947 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
948 /* channel 1 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
949 basterdised_rice_decompress(alac, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
950 alac->predicterror_buffer_a, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
951 outputsamples, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
952 readsamplesize, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
953 alac->setinfo_rice_initialhistory, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
954 alac->setinfo_rice_kmodifier, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
955 ricemodifier_a * alac->setinfo_rice_historymult / 4, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
956 (1 << alac->setinfo_rice_kmodifier) - 1); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
957 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
958 if (prediction_type_a == 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
959 { /* adaptive fir */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
960 predictor_decompress_fir_adapt(alac->predicterror_buffer_a, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
961 alac->outputsamples_buffer_a, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
962 outputsamples, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
963 readsamplesize, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
964 predictor_coef_table_a, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
965 predictor_coef_num_a, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
966 prediction_quantitization_a); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
967 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
968 else |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
969 { /* see mono case */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
970 fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_a); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
971 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
972 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
973 /* channel 2 */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
974 basterdised_rice_decompress(alac, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
975 alac->predicterror_buffer_b, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
976 outputsamples, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
977 readsamplesize, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
978 alac->setinfo_rice_initialhistory, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
979 alac->setinfo_rice_kmodifier, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
980 ricemodifier_b * alac->setinfo_rice_historymult / 4, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
981 (1 << alac->setinfo_rice_kmodifier) - 1); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
982 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
983 if (prediction_type_b == 0) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
984 { /* adaptive fir */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
985 predictor_decompress_fir_adapt(alac->predicterror_buffer_b, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
986 alac->outputsamples_buffer_b, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
987 outputsamples, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
988 readsamplesize, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
989 predictor_coef_table_b, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
990 predictor_coef_num_b, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
991 prediction_quantitization_b); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
992 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
993 else |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
994 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
995 fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_b); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
996 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
997 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
998 else |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
999 { /* not compressed, easy case */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1000 if (alac->setinfo_sample_size <= 16) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1001 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1002 int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1003 for (i = 0; i < outputsamples; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1004 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1005 int32_t audiobits_a, audiobits_b; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1006 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1007 audiobits_a = readbits(alac, alac->setinfo_sample_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1008 audiobits_b = readbits(alac, alac->setinfo_sample_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1009 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1010 audiobits_a = SIGN_EXTENDED32(audiobits_a, alac->setinfo_sample_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1011 audiobits_b = SIGN_EXTENDED32(audiobits_b, alac->setinfo_sample_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1012 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1013 alac->outputsamples_buffer_a[i] = audiobits_a; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1014 alac->outputsamples_buffer_b[i] = audiobits_b; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1015 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1016 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1017 else |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1018 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1019 int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1020 for (i = 0; i < outputsamples; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1021 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1022 int32_t audiobits_a, audiobits_b; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1023 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1024 audiobits_a = readbits(alac, 16); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1025 audiobits_a = audiobits_a << 16; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1026 audiobits_a = audiobits_a >> (32 - alac->setinfo_sample_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1027 audiobits_a |= readbits(alac, alac->setinfo_sample_size - 16); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1028 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1029 audiobits_b = readbits(alac, 16); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1030 audiobits_b = audiobits_b << 16; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1031 audiobits_b = audiobits_b >> (32 - alac->setinfo_sample_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1032 audiobits_b |= readbits(alac, alac->setinfo_sample_size - 16); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1033 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1034 alac->outputsamples_buffer_a[i] = audiobits_a; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1035 alac->outputsamples_buffer_b[i] = audiobits_b; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1036 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1037 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1038 /* wasted_bytes = 0; */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1039 interlacing_shift = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1040 interlacing_leftweight = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1041 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1042 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1043 switch(alac->setinfo_sample_size) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1044 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1045 case 16: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1046 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1047 deinterlace_16(alac->outputsamples_buffer_a, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1048 alac->outputsamples_buffer_b, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1049 (int16_t*)outbuffer, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1050 alac->numchannels, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1051 outputsamples, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1052 interlacing_shift, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1053 interlacing_leftweight); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1054 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1055 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1056 case 20: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1057 case 24: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1058 case 32: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1059 fprintf(stderr, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1060 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1061 default: |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1062 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1063 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1064 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1065 break; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1066 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1067 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1068 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1069 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1070 alac_file *create_alac(int samplesize, int numchannels) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1071 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1072 alac_file *newfile = malloc(sizeof(alac_file)); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1073 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1074 newfile->samplesize = samplesize; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1075 newfile->numchannels = numchannels; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1076 newfile->bytespersample = (samplesize / 8) * numchannels; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1077 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1078 return newfile; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1079 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
1080 |