annotate mace.c @ 7814:3cdedd7f0017 libavcodec

Convert tables to signed and decimal.
author vitor
date Sun, 07 Sep 2008 14:30:54 +0000
parents 0bd07f3d3556
children 275e43fa3dcb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
1 /*
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
2 * MACE decoder
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
3 * Copyright (c) 2002 Laszlo Torok <torokl@alpha.dfmk.hu>
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3682
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3682
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3682
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3682
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3682
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
15 * Lesser General Public License for more details.
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
16 *
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3682
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2967
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
20 */
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
21
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
22 /**
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
23 * @file mace.c
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
24 * MACE decoder.
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
25 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2487
diff changeset
26
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
27 #include "avcodec.h"
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
28
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
29 /*
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
30 * Adapted to ffmpeg by Francois Revol <revol@free.fr>
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
31 * (removed 68k REG stuff, changed types, added some statics and consts,
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
32 * libavcodec api, context stuff, interlaced stereo out).
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
33 */
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
34
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 893
diff changeset
35 static const uint16_t MACEtab1[] = { 0xfff3, 0x0008, 0x004c, 0x00de, 0x00de, 0x004c, 0x0008, 0xfff3 };
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
36
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 893
diff changeset
37 static const uint16_t MACEtab3[] = { 0xffee, 0x008c, 0x008c, 0xffee };
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
38
7814
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
39 static const int16_t MACEtab2[][8] = {
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
40 { 37, 116, 206, 330, -331, -207, -117, -38},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
41 { 39, 121, 216, 346, -347, -217, -122, -40},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
42 { 41, 127, 225, 361, -362, -226, -128, -42},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
43 { 42, 132, 235, 377, -378, -236, -133, -43},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
44 { 44, 137, 245, 392, -393, -246, -138, -45},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
45 { 46, 144, 256, 410, -411, -257, -145, -47},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
46 { 48, 150, 267, 428, -429, -268, -151, -49},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
47 { 51, 157, 280, 449, -450, -281, -158, -52},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
48 { 53, 165, 293, 470, -471, -294, -166, -54},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
49 { 55, 172, 306, 490, -491, -307, -173, -56},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
50 { 58, 179, 319, 511, -512, -320, -180, -59},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
51 { 60, 187, 333, 534, -535, -334, -188, -61},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
52 { 63, 195, 348, 557, -558, -349, -196, -64},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
53 { 66, 205, 364, 583, -584, -365, -206, -67},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
54 { 69, 214, 380, 609, -610, -381, -215, -70},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
55 { 72, 223, 396, 635, -636, -397, -224, -73},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
56 { 75, 233, 414, 663, -664, -415, -234, -76},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
57 { 79, 244, 433, 694, -695, -434, -245, -80},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
58 { 82, 254, 453, 725, -726, -454, -255, -83},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
59 { 86, 265, 472, 756, -757, -473, -266, -87},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
60 { 90, 278, 495, 792, -793, -496, -279, -91},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
61 { 94, 290, 516, 826, -827, -517, -291, -95},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
62 { 98, 303, 538, 862, -863, -539, -304, -99},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
63 { 102, 316, 562, 901, -902, -563, -317, -103},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
64 { 107, 331, 588, 942, -943, -589, -332, -108},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
65 { 112, 345, 614, 983, -984, -615, -346, -113},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
66 { 117, 361, 641, 1027, -1028, -642, -362, -118},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
67 { 122, 377, 670, 1074, -1075, -671, -378, -123},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
68 { 127, 394, 701, 1123, -1124, -702, -395, -128},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
69 { 133, 411, 732, 1172, -1173, -733, -412, -134},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
70 { 139, 430, 764, 1224, -1225, -765, -431, -140},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
71 { 145, 449, 799, 1280, -1281, -800, -450, -146},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
72 { 152, 469, 835, 1337, -1338, -836, -470, -153},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
73 { 159, 490, 872, 1397, -1398, -873, -491, -160},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
74 { 166, 512, 911, 1459, -1460, -912, -513, -167},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
75 { 173, 535, 951, 1523, -1524, -952, -536, -174},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
76 { 181, 558, 993, 1590, -1591, -994, -559, -182},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
77 { 189, 584, 1038, 1663, -1664, -1039, -585, -190},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
78 { 197, 610, 1085, 1738, -1739, -1086, -611, -198},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
79 { 206, 637, 1133, 1815, -1816, -1134, -638, -207},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
80 { 215, 665, 1183, 1895, -1896, -1184, -666, -216},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
81 { 225, 695, 1237, 1980, -1981, -1238, -696, -226},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
82 { 235, 726, 1291, 2068, -2069, -1292, -727, -236},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
83 { 246, 759, 1349, 2161, -2162, -1350, -760, -247},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
84 { 257, 792, 1409, 2257, -2258, -1410, -793, -258},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
85 { 268, 828, 1472, 2357, -2358, -1473, -829, -269},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
86 { 280, 865, 1538, 2463, -2464, -1539, -866, -281},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
87 { 293, 903, 1606, 2572, -2573, -1607, -904, -294},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
88 { 306, 944, 1678, 2688, -2689, -1679, -945, -307},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
89 { 319, 986, 1753, 2807, -2808, -1754, -987, -320},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
90 { 334, 1030, 1832, 2933, -2934, -1833, -1031, -335},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
91 { 349, 1076, 1914, 3065, -3066, -1915, -1077, -350},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
92 { 364, 1124, 1999, 3202, -3203, -2000, -1125, -365},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
93 { 380, 1174, 2088, 3344, -3345, -2089, -1175, -381},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
94 { 398, 1227, 2182, 3494, -3495, -2183, -1228, -399},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
95 { 415, 1281, 2278, 3649, -3650, -2279, -1282, -416},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
96 { 434, 1339, 2380, 3811, -3812, -2381, -1340, -435},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
97 { 453, 1398, 2486, 3982, -3983, -2487, -1399, -454},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
98 { 473, 1461, 2598, 4160, -4161, -2599, -1462, -474},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
99 { 495, 1526, 2714, 4346, -4347, -2715, -1527, -496},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
100 { 517, 1594, 2835, 4540, -4541, -2836, -1595, -518},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
101 { 540, 1665, 2961, 4741, -4742, -2962, -1666, -541},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
102 { 564, 1740, 3093, 4953, -4954, -3094, -1741, -565},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
103 { 589, 1818, 3232, 5175, -5176, -3233, -1819, -590},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
104 { 615, 1898, 3375, 5405, -5406, -3376, -1899, -616},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
105 { 643, 1984, 3527, 5647, -5648, -3528, -1985, -644},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
106 { 671, 2072, 3683, 5898, -5899, -3684, -2073, -672},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
107 { 701, 2164, 3848, 6161, -6162, -3849, -2165, -702},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
108 { 733, 2261, 4020, 6438, -6439, -4021, -2262, -734},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
109 { 766, 2362, 4199, 6724, -6725, -4200, -2363, -767},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
110 { 800, 2467, 4386, 7024, -7025, -4387, -2468, -801},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
111 { 836, 2578, 4583, 7339, -7340, -4584, -2579, -837},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
112 { 873, 2692, 4786, 7664, -7665, -4787, -2693, -874},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
113 { 912, 2813, 5001, 8008, -8009, -5002, -2814, -913},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
114 { 952, 2938, 5223, 8364, -8365, -5224, -2939, -953},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
115 { 995, 3070, 5457, 8739, -8740, -5458, -3071, -996},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
116 { 1039, 3207, 5701, 9129, -9130, -5702, -3208, -1040},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
117 { 1086, 3350, 5956, 9537, -9538, -5957, -3351, -1087},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
118 { 1134, 3499, 6220, 9960, -9961, -6221, -3500, -1135},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
119 { 1185, 3655, 6497, 10404, -10405, -6498, -3656, -1186},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
120 { 1238, 3818, 6788, 10869, -10870, -6789, -3819, -1239},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
121 { 1293, 3989, 7091, 11355, -11356, -7092, -3990, -1294},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
122 { 1351, 4166, 7407, 11861, -11862, -7408, -4167, -1352},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
123 { 1411, 4352, 7738, 12390, -12391, -7739, -4353, -1412},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
124 { 1474, 4547, 8084, 12946, -12947, -8085, -4548, -1475},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
125 { 1540, 4750, 8444, 13522, -13523, -8445, -4751, -1541},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
126 { 1609, 4962, 8821, 14126, -14127, -8822, -4963, -1610},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
127 { 1680, 5183, 9215, 14756, -14757, -9216, -5184, -1681},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
128 { 1756, 5415, 9626, 15415, -15416, -9627, -5416, -1757},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
129 { 1834, 5657, 10057, 16104, -16105, -10058, -5658, -1835},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
130 { 1916, 5909, 10505, 16822, -16823, -10506, -5910, -1917},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
131 { 2001, 6173, 10975, 17574, -17575, -10976, -6174, -2002},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
132 { 2091, 6448, 11463, 18356, -18357, -11464, -6449, -2092},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
133 { 2184, 6736, 11974, 19175, -19176, -11975, -6737, -2185},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
134 { 2282, 7037, 12510, 20032, -20033, -12511, -7038, -2283},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
135 { 2383, 7351, 13068, 20926, -20927, -13069, -7352, -2384},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
136 { 2490, 7679, 13652, 21861, -21862, -13653, -7680, -2491},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
137 { 2601, 8021, 14260, 22834, -22835, -14261, -8022, -2602},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
138 { 2717, 8380, 14897, 23854, -23855, -14898, -8381, -2718},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
139 { 2838, 8753, 15561, 24918, -24919, -15562, -8754, -2839},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
140 { 2965, 9144, 16256, 26031, -26032, -16257, -9145, -2966},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
141 { 3097, 9553, 16982, 27193, -27194, -16983, -9554, -3098},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
142 { 3236, 9979, 17740, 28407, -28408, -17741, -9980, -3237},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
143 { 3380, 10424, 18532, 29675, -29676, -18533, -10425, -3381},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
144 { 3531, 10890, 19359, 31000, -31001, -19360, -10891, -3532},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
145 { 3688, 11375, 20222, 32382, -32383, -20223, -11376, -3689},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
146 { 3853, 11883, 21125, 32767, -32768, -21126, -11884, -3854},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
147 { 4025, 12414, 22069, 32767, -32768, -22070, -12415, -4026},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
148 { 4205, 12967, 23053, 32767, -32768, -23054, -12968, -4206},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
149 { 4392, 13546, 24082, 32767, -32768, -24083, -13547, -4393},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
150 { 4589, 14151, 25157, 32767, -32768, -25158, -14152, -4590},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
151 { 4793, 14783, 26280, 32767, -32768, -26281, -14784, -4794},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
152 { 5007, 15442, 27452, 32767, -32768, -27453, -15443, -5008},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
153 { 5231, 16132, 28678, 32767, -32768, -28679, -16133, -5232},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
154 { 5464, 16851, 29957, 32767, -32768, -29958, -16852, -5465},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
155 { 5708, 17603, 31294, 32767, -32768, -31295, -17604, -5709},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
156 { 5963, 18389, 32691, 32767, -32768, -32692, -18390, -5964},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
157 { 6229, 19210, 32767, 32767, -32768, -32768, -19211, -6230},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
158 { 6507, 20067, 32767, 32767, -32768, -32768, -20068, -6508},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
159 { 6797, 20963, 32767, 32767, -32768, -32768, -20964, -6798},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
160 { 7101, 21899, 32767, 32767, -32768, -32768, -21900, -7102},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
161 { 7418, 22876, 32767, 32767, -32768, -32768, -22877, -7419},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
162 { 7749, 23897, 32767, 32767, -32768, -32768, -23898, -7750},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
163 { 8095, 24964, 32767, 32767, -32768, -32768, -24965, -8096},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
164 { 8456, 26078, 32767, 32767, -32768, -32768, -26079, -8457},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
165 { 8833, 27242, 32767, 32767, -32768, -32768, -27243, -8834},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
166 { 9228, 28457, 32767, 32767, -32768, -32768, -28458, -9229},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
167 { 9639, 29727, 32767, 32767, -32768, -32768, -29728, -9640}
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
168 };
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
169
7814
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
170 static const int16_t MACEtab4[][4] = {
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
171 { 64, 216, -217, -65}, { 67, 226, -227, -68},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
172 { 70, 236, -237, -71}, { 74, 246, -247, -75},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
173 { 77, 257, -258, -78}, { 80, 268, -269, -81},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
174 { 84, 280, -281, -85}, { 88, 294, -295, -89},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
175 { 92, 307, -308, -93}, { 96, 321, -322, -97},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
176 { 100, 334, -335, -101}, { 104, 350, -351, -105},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
177 { 109, 365, -366, -110}, { 114, 382, -383, -115},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
178 { 119, 399, -400, -120}, { 124, 416, -417, -125},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
179 { 130, 434, -435, -131}, { 136, 454, -455, -137},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
180 { 142, 475, -476, -143}, { 148, 495, -496, -149},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
181 { 155, 519, -520, -156}, { 162, 541, -542, -163},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
182 { 169, 564, -565, -170}, { 176, 590, -591, -177},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
183 { 185, 617, -618, -186}, { 193, 644, -645, -194},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
184 { 201, 673, -674, -202}, { 210, 703, -704, -211},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
185 { 220, 735, -736, -221}, { 230, 767, -768, -231},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
186 { 240, 801, -802, -241}, { 251, 838, -839, -252},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
187 { 262, 876, -877, -263}, { 274, 914, -915, -275},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
188 { 286, 955, -956, -287}, { 299, 997, -998, -300},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
189 { 312, 1041, -1042, -313}, { 326, 1089, -1090, -327},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
190 { 341, 1138, -1139, -342}, { 356, 1188, -1189, -357},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
191 { 372, 1241, -1242, -373}, { 388, 1297, -1298, -389},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
192 { 406, 1354, -1355, -407}, { 424, 1415, -1416, -425},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
193 { 443, 1478, -1479, -444}, { 462, 1544, -1545, -463},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
194 { 483, 1613, -1614, -484}, { 505, 1684, -1685, -506},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
195 { 527, 1760, -1761, -528}, { 551, 1838, -1839, -552},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
196 { 576, 1921, -1922, -577}, { 601, 2007, -2008, -602},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
197 { 628, 2097, -2098, -629}, { 656, 2190, -2191, -657},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
198 { 686, 2288, -2289, -687}, { 716, 2389, -2390, -717},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
199 { 748, 2496, -2497, -749}, { 781, 2607, -2608, -782},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
200 { 816, 2724, -2725, -817}, { 853, 2846, -2847, -854},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
201 { 891, 2973, -2974, -892}, { 930, 3104, -3105, -931},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
202 { 972, 3243, -3244, -973}, { 1016, 3389, -3390, -1017},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
203 { 1061, 3539, -3540, -1062}, { 1108, 3698, -3699, -1109},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
204 { 1158, 3862, -3863, -1159}, { 1209, 4035, -4036, -1210},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
205 { 1264, 4216, -4217, -1265}, { 1320, 4403, -4404, -1321},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
206 { 1379, 4599, -4600, -1380}, { 1441, 4806, -4807, -1442},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
207 { 1505, 5019, -5020, -1506}, { 1572, 5244, -5245, -1573},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
208 { 1642, 5477, -5478, -1643}, { 1715, 5722, -5723, -1716},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
209 { 1792, 5978, -5979, -1793}, { 1872, 6245, -6246, -1873},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
210 { 1955, 6522, -6523, -1956}, { 2043, 6813, -6814, -2044},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
211 { 2134, 7118, -7119, -2135}, { 2229, 7436, -7437, -2230},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
212 { 2329, 7767, -7768, -2330}, { 2432, 8114, -8115, -2433},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
213 { 2541, 8477, -8478, -2542}, { 2655, 8854, -8855, -2656},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
214 { 2773, 9250, -9251, -2774}, { 2897, 9663, -9664, -2898},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
215 { 3026, 10094, -10095, -3027}, { 3162, 10546, -10547, -3163},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
216 { 3303, 11016, -11017, -3304}, { 3450, 11508, -11509, -3451},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
217 { 3604, 12020, -12021, -3605}, { 3765, 12556, -12557, -3766},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
218 { 3933, 13118, -13119, -3934}, { 4108, 13703, -13704, -4109},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
219 { 4292, 14315, -14316, -4293}, { 4483, 14953, -14954, -4484},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
220 { 4683, 15621, -15622, -4684}, { 4892, 16318, -16319, -4893},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
221 { 5111, 17046, -17047, -5112}, { 5339, 17807, -17808, -5340},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
222 { 5577, 18602, -18603, -5578}, { 5826, 19433, -19434, -5827},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
223 { 6086, 20300, -20301, -6087}, { 6358, 21205, -21206, -6359},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
224 { 6642, 22152, -22153, -6643}, { 6938, 23141, -23142, -6939},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
225 { 7248, 24173, -24174, -7249}, { 7571, 25252, -25253, -7572},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
226 { 7909, 26380, -26381, -7910}, { 8262, 27557, -27558, -8263},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
227 { 8631, 28786, -28787, -8632}, { 9016, 30072, -30073, -9017},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
228 { 9419, 31413, -31414, -9420}, { 9839, 32767, -32768, -9840},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
229 { 10278, 32767, -32768, -10279}, { 10737, 32767, -32768, -10738},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
230 { 11216, 32767, -32768, -11217}, { 11717, 32767, -32768, -11718},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
231 { 12240, 32767, -32768, -12241}, { 12786, 32767, -32768, -12787},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
232 { 13356, 32767, -32768, -13357}, { 13953, 32767, -32768, -13954},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
233 { 14576, 32767, -32768, -14577}, { 15226, 32767, -32768, -15227},
3cdedd7f0017 Convert tables to signed and decimal.
vitor
parents: 7813
diff changeset
234 { 15906, 32767, -32768, -15907}, { 16615, 32767, -32768, -16616}
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
235 };
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
236
7808
0acafe424d54 Use the same 8 bit -> 16 bit conversion as QuickTime.
vitor
parents: 7807
diff changeset
237 #define QT_8S_2_16S(x) (((x) & 0xFF00) | (((x) >> 8) & 0xFF))
0acafe424d54 Use the same 8 bit -> 16 bit conversion as QuickTime.
vitor
parents: 7807
diff changeset
238
7807
8c32b5606f83 Do not share context variables between channels and do not zero them at
vitor
parents: 7806
diff changeset
239 typedef struct ChannelData {
8c32b5606f83 Do not share context variables between channels and do not zero them at
vitor
parents: 7806
diff changeset
240 short index, lev, factor, prev2, previous, level;
8c32b5606f83 Do not share context variables between channels and do not zero them at
vitor
parents: 7806
diff changeset
241 } ChannelData;
8c32b5606f83 Do not share context variables between channels and do not zero them at
vitor
parents: 7806
diff changeset
242
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
243 typedef struct MACEContext {
7807
8c32b5606f83 Do not share context variables between channels and do not zero them at
vitor
parents: 7806
diff changeset
244 ChannelData chd[2];
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
245 } MACEContext;
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
246
7810
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
247 /**
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
248 * MACE version of av_clip_int16(). We have to do this to keep binary
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
249 * identical output to the binary decoder.
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
250 */
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
251 static inline int16_t mace_broken_clip_int16(int n)
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
252 {
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
253 if (n > 32767)
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
254 return 32767;
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
255 else if (n < -32768)
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
256 return -32767;
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
257 else
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
258 return n;
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
259 }
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
260
7807
8c32b5606f83 Do not share context variables between channels and do not zero them at
vitor
parents: 7806
diff changeset
261 static void chomp3(ChannelData *ctx, int16_t *output, uint8_t val,
7806
b90764c4f31a Remove output pointer from context
vitor
parents: 7798
diff changeset
262 const uint16_t tab1[],
7813
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
263 const uint16_t *tab2, int tab2_stride,
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
264 uint32_t numChannels)
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
265 {
7792
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
266 short current;
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
267
7813
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
268 current = (short)tab2[((ctx->index & 0x7f0) >> 4)*tab2_stride + val];
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
269
7810
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
270 current = mace_broken_clip_int16(current + ctx->lev);
7792
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
271
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
272 ctx->lev = current - (current >> 3);
7808
0acafe424d54 Use the same 8 bit -> 16 bit conversion as QuickTime.
vitor
parents: 7807
diff changeset
273 *output = QT_8S_2_16S(current);
7792
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
274 if (( ctx->index += tab1[val]-(ctx->index >> 5) ) < 0)
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
275 ctx->index = 0;
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
276 }
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
277
7807
8c32b5606f83 Do not share context variables between channels and do not zero them at
vitor
parents: 7806
diff changeset
278 static void chomp6(ChannelData *ctx, int16_t *output, uint8_t val,
7806
b90764c4f31a Remove output pointer from context
vitor
parents: 7798
diff changeset
279 const uint16_t tab1[],
7813
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
280 const uint16_t *tab2, int tab2_stride,
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
281 uint32_t numChannels)
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
282 {
7792
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
283 short current;
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
284
7813
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
285 current = (short)tab2[((ctx->index & 0x7f0) >> 4)*tab2_stride + val];
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
286
7792
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
287 if ((ctx->previous ^ current) >= 0) {
7811
ed61b4ffdd7e Use FFMIN() instead of rewriting it.
vitor
parents: 7810
diff changeset
288 ctx->factor = FFMIN(ctx->factor + 506, 32767);
7792
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
289 } else {
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
290 if (ctx->factor - 314 < -32768)
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
291 ctx->factor = -32767;
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
292 else
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
293 ctx->factor -= 314;
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
294 }
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
295
7810
06d3f6968b90 Factorize broken clipping in its own function and document it.
vitor
parents: 7809
diff changeset
296 current = mace_broken_clip_int16(current + ctx->level);
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
297
7792
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
298 ctx->level = ((current*ctx->factor) >> 15);
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
299 current >>= 1;
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
300
7808
0acafe424d54 Use the same 8 bit -> 16 bit conversion as QuickTime.
vitor
parents: 7807
diff changeset
301 output[0] = QT_8S_2_16S(ctx->previous + ctx->prev2 -
0acafe424d54 Use the same 8 bit -> 16 bit conversion as QuickTime.
vitor
parents: 7807
diff changeset
302 ((ctx->prev2-current) >> 2));
0acafe424d54 Use the same 8 bit -> 16 bit conversion as QuickTime.
vitor
parents: 7807
diff changeset
303 output[numChannels] = QT_8S_2_16S(ctx->previous + current +
0acafe424d54 Use the same 8 bit -> 16 bit conversion as QuickTime.
vitor
parents: 7807
diff changeset
304 ((ctx->prev2-current) >> 2));
7792
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
305 ctx->prev2 = ctx->previous;
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
306 ctx->previous = current;
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
307
7792
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
308 if ((ctx->index += tab1[val] - (ctx->index >> 5)) < 0)
c372b8d5abfb Reindent mace.c, its indentation was completly inconsistent with the coding rules.
vitor
parents: 7451
diff changeset
309 ctx->index = 0;
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
310 }
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
311
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6217
diff changeset
312 static av_cold int mace_decode_init(AVCodecContext * avctx)
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
313 {
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
314 if (avctx->channels > 2)
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
315 return -1;
7451
85ab7655ad4d Modify all codecs to report their supported input and output sample format(s).
pross
parents: 7040
diff changeset
316 avctx->sample_fmt = SAMPLE_FMT_S16;
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
317 return 0;
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
318 }
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
319
7795
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
320 static int mace3_decode_frame(AVCodecContext *avctx,
7809
74a7ac273231 Cosmetics: whitespace/linebreaks
vitor
parents: 7808
diff changeset
321 void *data, int *data_size,
74a7ac273231 Cosmetics: whitespace/linebreaks
vitor
parents: 7808
diff changeset
322 const uint8_t *buf, int buf_size)
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
323 {
7794
315d2a6c6a1e Simplify mace_decode_frame()
vitor
parents: 7793
diff changeset
324 short *samples = data;
7796
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
325 MACEContext *ctx = avctx->priv_data;
7797
09b73aceebaf Simplify: use a for instead of unrolling by hand
vitor
parents: 7796
diff changeset
326 int i, j, k;
7796
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
327
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
328 for(i = 0; i < avctx->channels; i++) {
7806
b90764c4f31a Remove output pointer from context
vitor
parents: 7798
diff changeset
329 int16_t *output = samples + i;
7796
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
330
7798
e7ec66d55d9e Cosmetics: indent after last commit and remove useless braces
vitor
parents: 7797
diff changeset
331 for (j=0; j < buf_size / 2 / avctx->channels; j++)
7797
09b73aceebaf Simplify: use a for instead of unrolling by hand
vitor
parents: 7796
diff changeset
332 for (k=0; k < 2; k++) {
7798
e7ec66d55d9e Cosmetics: indent after last commit and remove useless braces
vitor
parents: 7797
diff changeset
333 uint8_t pkt = buf[i*2 + j*2*avctx->channels + k];
7809
74a7ac273231 Cosmetics: whitespace/linebreaks
vitor
parents: 7808
diff changeset
334 chomp3(&ctx->chd[i], output, pkt &7, MACEtab1, MACEtab2,
7813
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
335 8, avctx->channels);
7806
b90764c4f31a Remove output pointer from context
vitor
parents: 7798
diff changeset
336 output += avctx->channels;
7809
74a7ac273231 Cosmetics: whitespace/linebreaks
vitor
parents: 7808
diff changeset
337 chomp3(&ctx->chd[i], output,(pkt >> 3) &3, MACEtab3, MACEtab4,
7813
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
338 4, avctx->channels);
7806
b90764c4f31a Remove output pointer from context
vitor
parents: 7798
diff changeset
339 output += avctx->channels;
7809
74a7ac273231 Cosmetics: whitespace/linebreaks
vitor
parents: 7808
diff changeset
340 chomp3(&ctx->chd[i], output, pkt >> 5 , MACEtab1, MACEtab2,
7813
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
341 8, avctx->channels);
7806
b90764c4f31a Remove output pointer from context
vitor
parents: 7798
diff changeset
342 output += avctx->channels;
7797
09b73aceebaf Simplify: use a for instead of unrolling by hand
vitor
parents: 7796
diff changeset
343 }
7796
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
344 }
7795
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
345
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
346 *data_size = 2 * 3 * buf_size;
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
347
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
348 return buf_size;
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
349 }
7794
315d2a6c6a1e Simplify mace_decode_frame()
vitor
parents: 7793
diff changeset
350
7795
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
351 static int mace6_decode_frame(AVCodecContext *avctx,
7809
74a7ac273231 Cosmetics: whitespace/linebreaks
vitor
parents: 7808
diff changeset
352 void *data, int *data_size,
74a7ac273231 Cosmetics: whitespace/linebreaks
vitor
parents: 7808
diff changeset
353 const uint8_t *buf, int buf_size)
7795
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
354 {
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
355 short *samples = data;
7796
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
356 MACEContext *ctx = avctx->priv_data;
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
357 int i, j;
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
358
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
359 for(i = 0; i < avctx->channels; i++) {
7806
b90764c4f31a Remove output pointer from context
vitor
parents: 7798
diff changeset
360 int16_t *output = samples + i;
7796
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
361
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
362 for (j = 0; j < buf_size / avctx->channels; j++) {
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
363 uint8_t pkt = buf[i + j*avctx->channels];
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
364
7809
74a7ac273231 Cosmetics: whitespace/linebreaks
vitor
parents: 7808
diff changeset
365 chomp6(&ctx->chd[i], output, pkt >> 5 , MACEtab1, MACEtab2,
7813
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
366 8, avctx->channels);
7806
b90764c4f31a Remove output pointer from context
vitor
parents: 7798
diff changeset
367 output += avctx->channels << 1;
7809
74a7ac273231 Cosmetics: whitespace/linebreaks
vitor
parents: 7808
diff changeset
368 chomp6(&ctx->chd[i], output,(pkt >> 3) & 3, MACEtab3, MACEtab4,
7813
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
369 4, avctx->channels);
7806
b90764c4f31a Remove output pointer from context
vitor
parents: 7798
diff changeset
370 output += avctx->channels << 1;
7809
74a7ac273231 Cosmetics: whitespace/linebreaks
vitor
parents: 7808
diff changeset
371 chomp6(&ctx->chd[i], output, pkt & 7, MACEtab1, MACEtab2,
7813
0bd07f3d3556 Remove unused table entries.
vitor
parents: 7812
diff changeset
372 8, avctx->channels);
7806
b90764c4f31a Remove output pointer from context
vitor
parents: 7798
diff changeset
373 output += avctx->channels << 1;
7796
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
374 }
a7caaa2b56e9 Functions mace{3,6}_decode_frame() are just wrappers to Exp1to{3,6}(). This commit
vitor
parents: 7795
diff changeset
375 }
7794
315d2a6c6a1e Simplify mace_decode_frame()
vitor
parents: 7793
diff changeset
376
7795
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
377 *data_size = 2 * 6 * buf_size;
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
378
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
379 return buf_size;
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
380 }
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
381
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
382 AVCodec mace3_decoder = {
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
383 "mace3",
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
384 CODEC_TYPE_AUDIO,
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
385 CODEC_ID_MACE3,
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
386 sizeof(MACEContext),
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
387 mace_decode_init,
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
388 NULL,
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
389 NULL,
7795
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
390 mace3_decode_frame,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6710
diff changeset
391 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"),
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
392 };
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
393
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
394 AVCodec mace6_decoder = {
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
395 "mace6",
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
396 CODEC_TYPE_AUDIO,
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
397 CODEC_ID_MACE6,
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
398 sizeof(MACEContext),
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
399 mace_decode_init,
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
400 NULL,
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
401 NULL,
7795
7f81fb0dd829 Simplify: use two distinct functions to decode MACE3 and MACE6, since the
vitor
parents: 7794
diff changeset
402 mace6_decode_frame,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6710
diff changeset
403 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"),
827
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
404 };
770578c6c300 added MACE (Macintosh Audio Compression/Expansion) 3:1 & 6:1 support
michaelni
parents:
diff changeset
405