../../../ffmpeg/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
737 / 1043
70.7%
Branches:
550 / 942
58.4%
Functions:
21 / 30
70.0%

libavcodec/adpcm.c
Line Branch Exec Source
1 /*
2 * Copyright (c) 2001-2003 The FFmpeg project
3 *
4 * first version by Francois Revol (revol@free.fr)
5 * fringe ADPCM codecs (e.g., DK3, DK4, Westwood)
6 * by Mike Melanson (melanson@pcisys.net)
7 * CD-ROM XA ADPCM codec by BERO
8 * EA ADPCM decoder by Robin Kay (komadori@myrealbox.com)
9 * EA ADPCM R1/R2/R3 decoder by Peter Ross (pross@xvid.org)
10 * EA IMA EACS decoder by Peter Ross (pross@xvid.org)
11 * EA IMA SEAD decoder by Peter Ross (pross@xvid.org)
12 * EA ADPCM XAS decoder by Peter Ross (pross@xvid.org)
13 * MAXIS EA ADPCM decoder by Robert Marston (rmarston@gmail.com)
14 * THP ADPCM decoder by Marco Gerards (mgerards@xs4all.nl)
15 * Argonaut Games ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com)
16 * Simon & Schuster Interactive ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com)
17 * Ubisoft ADPCM decoder by Zane van Iperen (zane@zanevaniperen.com)
18 * High Voltage Software ALP decoder by Zane van Iperen (zane@zanevaniperen.com)
19 * Cunning Developments decoder by Zane van Iperen (zane@zanevaniperen.com)
20 * Sanyo LD-ADPCM decoder by Peter Ross (pross@xvid.org)
21 *
22 * This file is part of FFmpeg.
23 *
24 * FFmpeg is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU Lesser General Public
26 * License as published by the Free Software Foundation; either
27 * version 2.1 of the License, or (at your option) any later version.
28 *
29 * FFmpeg is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 * Lesser General Public License for more details.
33 *
34 * You should have received a copy of the GNU Lesser General Public
35 * License along with FFmpeg; if not, write to the Free Software
36 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
37 */
38
39 #include "config_components.h"
40
41 #include "avcodec.h"
42 #include "get_bits.h"
43 #include "bytestream.h"
44 #include "adpcm.h"
45 #include "adpcm_data.h"
46 #include "codec_internal.h"
47 #include "decode.h"
48
49 #include "libavutil/attributes.h"
50
51 /**
52 * @file
53 * ADPCM decoders
54 * Features and limitations:
55 *
56 * Reference documents:
57 * http://wiki.multimedia.cx/index.php?title=Category:ADPCM_Audio_Codecs
58 * http://www.pcisys.net/~melanson/codecs/simpleaudio.html [dead]
59 * http://www.geocities.com/SiliconValley/8682/aud3.txt [dead]
60 * http://openquicktime.sourceforge.net/
61 * XAnim sources (xa_codec.c) http://xanim.polter.net/
62 * http://www.cs.ucla.edu/~leec/mediabench/applications.html [dead]
63 * SoX source code http://sox.sourceforge.net/
64 *
65 * CD-ROM XA:
66 * http://ku-www.ss.titech.ac.jp/~yatsushi/xaadpcm.html [dead]
67 * vagpack & depack http://homepages.compuserve.de/bITmASTER32/psx-index.html [dead]
68 * readstr http://www.geocities.co.jp/Playtown/2004/
69 */
70
71 #define CASE_0(codec_id, ...)
72 #define CASE_1(codec_id, ...) \
73 case codec_id: \
74 { __VA_ARGS__ } \
75 break;
76 #define CASE_2(enabled, codec_id, ...) \
77 CASE_ ## enabled(codec_id, __VA_ARGS__)
78 #define CASE_3(config, codec_id, ...) \
79 CASE_2(config, codec_id, __VA_ARGS__)
80 #define CASE(codec, ...) \
81 CASE_3(CONFIG_ ## codec ## _DECODER, AV_CODEC_ID_ ## codec, __VA_ARGS__)
82
83 /* These are for CD-ROM XA ADPCM */
84 static const int8_t xa_adpcm_table[5][2] = {
85 { 0, 0 },
86 { 60, 0 },
87 { 115, -52 },
88 { 98, -55 },
89 { 122, -60 }
90 };
91
92 static const int16_t afc_coeffs[2][16] = {
93 { 0, 2048, 0, 1024, 4096, 3584, 3072, 4608, 4200, 4800, 5120, 2048, 1024, -1024, -1024, -2048 },
94 { 0, 0, 2048, 1024, -2048, -1536, -1024, -2560, -2248, -2300, -3072, -2048, -1024, 1024, 0, 0 }
95 };
96
97 static const int16_t ea_adpcm_table[] = {
98 0, 240, 460, 392,
99 0, 0, -208, -220,
100 0, 1, 3, 4,
101 7, 8, 10, 11,
102 0, -1, -3, -4
103 };
104
105 /*
106 * Dumped from the binaries:
107 * - FantasticJourney.exe - 0x794D2, DGROUP:0x47A4D2
108 * - BigRaceUSA.exe - 0x9B8AA, DGROUP:0x49C4AA
109 * - Timeshock!.exe - 0x8506A, DGROUP:0x485C6A
110 */
111 static const int8_t ima_cunning_index_table[9] = {
112 -1, -1, -1, -1, 1, 2, 3, 4, -1
113 };
114
115 /*
116 * Dumped from the binaries:
117 * - FantasticJourney.exe - 0x79458, DGROUP:0x47A458
118 * - BigRaceUSA.exe - 0x9B830, DGROUP:0x49C430
119 * - Timeshock!.exe - 0x84FF0, DGROUP:0x485BF0
120 */
121 static const int16_t ima_cunning_step_table[61] = {
122 1, 1, 1, 1, 2, 2, 3, 3, 4, 5,
123 6, 7, 8, 10, 12, 14, 16, 20, 24, 28,
124 32, 40, 48, 56, 64, 80, 96, 112, 128, 160,
125 192, 224, 256, 320, 384, 448, 512, 640, 768, 896,
126 1024, 1280, 1536, 1792, 2048, 2560, 3072, 3584, 4096, 5120,
127 6144, 7168, 8192, 10240, 12288, 14336, 16384, 20480, 24576, 28672, 0
128 };
129
130 static const int8_t adpcm_index_table2[4] = {
131 -1, 2,
132 -1, 2,
133 };
134
135 static const int8_t adpcm_index_table3[8] = {
136 -1, -1, 1, 2,
137 -1, -1, 1, 2,
138 };
139
140 static const int8_t adpcm_index_table5[32] = {
141 -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16,
142 -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16,
143 };
144
145 static const int8_t * const adpcm_index_tables[4] = {
146 &adpcm_index_table2[0],
147 &adpcm_index_table3[0],
148 &ff_adpcm_index_table[0],
149 &adpcm_index_table5[0],
150 };
151
152 static const int16_t mtaf_stepsize[32][16] = {
153 { 1, 5, 9, 13, 16, 20, 24, 28,
154 -1, -5, -9, -13, -16, -20, -24, -28, },
155 { 2, 6, 11, 15, 20, 24, 29, 33,
156 -2, -6, -11, -15, -20, -24, -29, -33, },
157 { 2, 7, 13, 18, 23, 28, 34, 39,
158 -2, -7, -13, -18, -23, -28, -34, -39, },
159 { 3, 9, 15, 21, 28, 34, 40, 46,
160 -3, -9, -15, -21, -28, -34, -40, -46, },
161 { 3, 11, 18, 26, 33, 41, 48, 56,
162 -3, -11, -18, -26, -33, -41, -48, -56, },
163 { 4, 13, 22, 31, 40, 49, 58, 67,
164 -4, -13, -22, -31, -40, -49, -58, -67, },
165 { 5, 16, 26, 37, 48, 59, 69, 80,
166 -5, -16, -26, -37, -48, -59, -69, -80, },
167 { 6, 19, 31, 44, 57, 70, 82, 95,
168 -6, -19, -31, -44, -57, -70, -82, -95, },
169 { 7, 22, 38, 53, 68, 83, 99, 114,
170 -7, -22, -38, -53, -68, -83, -99, -114, },
171 { 9, 27, 45, 63, 81, 99, 117, 135,
172 -9, -27, -45, -63, -81, -99, -117, -135, },
173 { 10, 32, 53, 75, 96, 118, 139, 161,
174 -10, -32, -53, -75, -96, -118, -139, -161, },
175 { 12, 38, 64, 90, 115, 141, 167, 193,
176 -12, -38, -64, -90, -115, -141, -167, -193, },
177 { 15, 45, 76, 106, 137, 167, 198, 228,
178 -15, -45, -76, -106, -137, -167, -198, -228, },
179 { 18, 54, 91, 127, 164, 200, 237, 273,
180 -18, -54, -91, -127, -164, -200, -237, -273, },
181 { 21, 65, 108, 152, 195, 239, 282, 326,
182 -21, -65, -108, -152, -195, -239, -282, -326, },
183 { 25, 77, 129, 181, 232, 284, 336, 388,
184 -25, -77, -129, -181, -232, -284, -336, -388, },
185 { 30, 92, 153, 215, 276, 338, 399, 461,
186 -30, -92, -153, -215, -276, -338, -399, -461, },
187 { 36, 109, 183, 256, 329, 402, 476, 549,
188 -36, -109, -183, -256, -329, -402, -476, -549, },
189 { 43, 130, 218, 305, 392, 479, 567, 654,
190 -43, -130, -218, -305, -392, -479, -567, -654, },
191 { 52, 156, 260, 364, 468, 572, 676, 780,
192 -52, -156, -260, -364, -468, -572, -676, -780, },
193 { 62, 186, 310, 434, 558, 682, 806, 930,
194 -62, -186, -310, -434, -558, -682, -806, -930, },
195 { 73, 221, 368, 516, 663, 811, 958, 1106,
196 -73, -221, -368, -516, -663, -811, -958, -1106, },
197 { 87, 263, 439, 615, 790, 966, 1142, 1318,
198 -87, -263, -439, -615, -790, -966, -1142, -1318, },
199 { 104, 314, 523, 733, 942, 1152, 1361, 1571,
200 -104, -314, -523, -733, -942, -1152, -1361, -1571, },
201 { 124, 374, 623, 873, 1122, 1372, 1621, 1871,
202 -124, -374, -623, -873, -1122, -1372, -1621, -1871, },
203 { 148, 445, 743, 1040, 1337, 1634, 1932, 2229,
204 -148, -445, -743, -1040, -1337, -1634, -1932, -2229, },
205 { 177, 531, 885, 1239, 1593, 1947, 2301, 2655,
206 -177, -531, -885, -1239, -1593, -1947, -2301, -2655, },
207 { 210, 632, 1053, 1475, 1896, 2318, 2739, 3161,
208 -210, -632, -1053, -1475, -1896, -2318, -2739, -3161, },
209 { 251, 753, 1255, 1757, 2260, 2762, 3264, 3766,
210 -251, -753, -1255, -1757, -2260, -2762, -3264, -3766, },
211 { 299, 897, 1495, 2093, 2692, 3290, 3888, 4486,
212 -299, -897, -1495, -2093, -2692, -3290, -3888, -4486, },
213 { 356, 1068, 1781, 2493, 3206, 3918, 4631, 5343,
214 -356, -1068, -1781, -2493, -3206, -3918, -4631, -5343, },
215 { 424, 1273, 2121, 2970, 3819, 4668, 5516, 6365,
216 -424, -1273, -2121, -2970, -3819, -4668, -5516, -6365, },
217 };
218
219 static const int16_t oki_step_table[49] = {
220 16, 17, 19, 21, 23, 25, 28, 31, 34, 37,
221 41, 45, 50, 55, 60, 66, 73, 80, 88, 97,
222 107, 118, 130, 143, 157, 173, 190, 209, 230, 253,
223 279, 307, 337, 371, 408, 449, 494, 544, 598, 658,
224 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552
225 };
226
227 // padded to zero where table size is less then 16
228 static const int8_t swf_index_tables[4][16] = {
229 /*2*/ { -1, 2 },
230 /*3*/ { -1, -1, 2, 4 },
231 /*4*/ { -1, -1, -1, -1, 2, 4, 6, 8 },
232 /*5*/ { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
233 };
234
235 static const int8_t zork_index_table[8] = {
236 -1, -1, -1, 1, 4, 7, 10, 12,
237 };
238
239 static const int8_t mtf_index_table[16] = {
240 8, 6, 4, 2, -1, -1, -1, -1,
241 -1, -1, -1, -1, 2, 4, 6, 8,
242 };
243
244 static const int16_t rhetorex_step[128] = {
245 40, 130, 232, 350, 493, 673, 927, 1382,
246 60, 195, 348, 526, 740, 1010, 1391, 2074,
247 85, 277, 494, 745, 1048, 1431, 1971, 2938,
248 121, 391, 697, 1052, 1480, 2021, 2782, 4148,
249 176, 570, 1017, 1535, 2158, 2947, 4058, 6050,
250 257, 831, 1482, 2236, 3145, 4295, 5913, 8815,
251 373, 1206, 2151, 3245, 4564, 6232, 8579, 12791,
252 534, 1728, 3082, 4649, 6538, 8928, 12290, 18323,
253 782, 2527, 4507, 6798, 9560, 13055, 17971, 26793,
254 1115, 3603, 6426, 9692, 13631, 18614, 25623, 32767,
255 1620, 5233, 9334, 14078, 19799, 27036, 32767, 32767,
256 2361, 7630, 13608, 20526, 28866, 32767, 32767, 32767,
257 3447, 11136, 19860, 29955, 32767, 32767, 32767, 32767,
258 4865, 15717, 28031, 32767, 32767, 32767, 32767, 32767,
259 6888, 22255, 32767, 32767, 32767, 32767, 32767, 32767,
260 -10336, 32144, 5984,-24288, 4752, 24112, 24688,-26336,
261 };
262
263 static const int16_t rhetorex_index[8] = {
264 -83, -55, -27, 163, 374, 677, 1864, 3408,
265 };
266
267 static const int8_t citrix_index_table[4] = {
268 -1, 1, -1, 1,
269 };
270
271 /* end of tables */
272
273 typedef struct ADPCMDecodeContext {
274 ADPCMChannelStatus status[14];
275 int vqa_version; /**< VQA version. Used for ADPCM_IMA_WS */
276 int has_status; /**< Status flag. Reset to 0 after a flush. */
277 } ADPCMDecodeContext;
278
279 static void adpcm_flush(AVCodecContext *avctx);
280
281 208 static av_cold int adpcm_decode_init(AVCodecContext * avctx)
282 {
283 208 ADPCMDecodeContext *c = avctx->priv_data;
284 208 unsigned int min_channels = 1;
285 208 unsigned int max_channels = 2;
286
287 208 adpcm_flush(avctx);
288
289
7/9
✓ Branch 3 → 4 taken 5 times.
✓ Branch 3 → 5 taken 6 times.
✓ Branch 3 → 6 taken 25 times.
✗ Branch 3 → 7 not taken.
✓ Branch 3 → 11 taken 2 times.
✓ Branch 3 → 12 taken 1 time.
✗ Branch 3 → 16 not taken.
✓ Branch 3 → 21 taken 8 times.
✓ Branch 3 → 22 taken 161 times.
208 switch(avctx->codec->id) {
290 5 case AV_CODEC_ID_ADPCM_IMA_AMV:
291 case AV_CODEC_ID_ADPCM_N64:
292 case AV_CODEC_ID_ADPCM_RHETOREX:
293 5 max_channels = 1;
294 5 break;
295 6 case AV_CODEC_ID_ADPCM_SANYO:
296 6 max_channels = 2;
297 6 break;
298 25 case AV_CODEC_ID_ADPCM_AFC:
299 case AV_CODEC_ID_ADPCM_EA_R1:
300 case AV_CODEC_ID_ADPCM_EA_R2:
301 case AV_CODEC_ID_ADPCM_EA_R3:
302 case AV_CODEC_ID_ADPCM_EA_XAS:
303 case AV_CODEC_ID_ADPCM_MS:
304 25 max_channels = 6;
305 25 break;
306 ✗ case AV_CODEC_ID_ADPCM_MTAF:
307 ✗ min_channels = 2;
308 ✗ max_channels = 8;
309
0/2
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 10 not taken.
✗ if (avctx->ch_layout.nb_channels & 1) {
310 ✗ avpriv_request_sample(avctx, "channel count %d", avctx->ch_layout.nb_channels);
311 ✗ return AVERROR_PATCHWELCOME;
312 }
313 ✗ break;
314 2 case AV_CODEC_ID_ADPCM_DTK:
315 2 min_channels = 2;
316 2 break;
317 1 case AV_CODEC_ID_ADPCM_PSX:
318 1 max_channels = 8;
319
1/2
✓ Branch 12 → 13 taken 1 time.
✗ Branch 12 → 14 not taken.
1 if (avctx->ch_layout.nb_channels <= 0 ||
320
1/2
✓ Branch 13 → 14 taken 1 time.
✗ Branch 13 → 15 not taken.
1 avctx->block_align % (16 * avctx->ch_layout.nb_channels))
321 1 return AVERROR_INVALIDDATA;
322 ✗ break;
323 ✗ case AV_CODEC_ID_ADPCM_PSXC:
324 ✗ max_channels = 8;
325
0/4
✗ Branch 16 → 17 not taken.
✗ Branch 16 → 19 not taken.
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 19 not taken.
✗ if (avctx->ch_layout.nb_channels <= 0 || avctx->block_align <= 0 ||
326
0/2
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 20 not taken.
✗ avctx->block_align % avctx->ch_layout.nb_channels)
327 ✗ return AVERROR_INVALIDDATA;
328 ✗ break;
329 8 case AV_CODEC_ID_ADPCM_IMA_DAT4:
330 case AV_CODEC_ID_ADPCM_THP:
331 case AV_CODEC_ID_ADPCM_THP_LE:
332 8 max_channels = 14;
333 8 break;
334 }
335
1/2
✓ Branch 22 → 23 taken 207 times.
✗ Branch 22 → 24 not taken.
207 if (avctx->ch_layout.nb_channels < min_channels ||
336
1/2
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 26 taken 207 times.
207 avctx->ch_layout.nb_channels > max_channels) {
337 ✗ av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
338 ✗ return AVERROR(EINVAL);
339 }
340
341
6/7
✓ Branch 26 → 27 taken 11 times.
✓ Branch 26 → 31 taken 6 times.
✓ Branch 26 → 35 taken 6 times.
✓ Branch 26 → 39 taken 1 time.
✗ Branch 26 → 42 not taken.
✓ Branch 26 → 45 taken 4 times.
✓ Branch 26 → 51 taken 179 times.
207 switch(avctx->codec->id) {
342 11 case AV_CODEC_ID_ADPCM_IMA_WAV:
343
2/4
✓ Branch 27 → 28 taken 11 times.
✗ Branch 27 → 29 not taken.
✗ Branch 28 → 29 not taken.
✓ Branch 28 → 30 taken 11 times.
11 if (avctx->bits_per_coded_sample < 2 || avctx->bits_per_coded_sample > 5)
344 ✗ return AVERROR_INVALIDDATA;
345 11 break;
346 6 case AV_CODEC_ID_ADPCM_ARGO:
347
1/2
✓ Branch 31 → 32 taken 6 times.
✗ Branch 31 → 33 not taken.
6 if (avctx->bits_per_coded_sample != 4 ||
348
1/2
✗ Branch 32 → 33 not taken.
✓ Branch 32 → 34 taken 6 times.
6 avctx->block_align != 17 * avctx->ch_layout.nb_channels)
349 ✗ return AVERROR_INVALIDDATA;
350 6 break;
351 6 case AV_CODEC_ID_ADPCM_SANYO:
352
2/4
✓ Branch 35 → 36 taken 6 times.
✗ Branch 35 → 37 not taken.
✗ Branch 36 → 37 not taken.
✓ Branch 36 → 38 taken 6 times.
6 if (avctx->bits_per_coded_sample < 3 || avctx->bits_per_coded_sample > 5)
353 ✗ return AVERROR_INVALIDDATA;
354 6 break;
355 1 case AV_CODEC_ID_ADPCM_IMA_XBOX:
356
1/2
✗ Branch 39 → 40 not taken.
✓ Branch 39 → 41 taken 1 time.
1 if (avctx->bits_per_coded_sample != 4)
357 ✗ return AVERROR_INVALIDDATA;
358 1 break;
359 ✗ case AV_CODEC_ID_ADPCM_ZORK:
360
0/2
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 44 not taken.
✗ if (avctx->bits_per_coded_sample != 8)
361 ✗ return AVERROR_INVALIDDATA;
362 ✗ break;
363 4 case AV_CODEC_ID_ADPCM_IMA_CITRIX:
364
1/2
✓ Branch 45 → 46 taken 4 times.
✗ Branch 45 → 49 not taken.
4 if (avctx->bits_per_coded_sample != 2 ||
365
1/2
✓ Branch 46 → 47 taken 4 times.
✗ Branch 46 → 49 not taken.
4 avctx->block_align < 4 * avctx->ch_layout.nb_channels ||
366
3/4
✓ Branch 47 → 48 taken 2 times.
✓ Branch 47 → 50 taken 2 times.
✗ Branch 48 → 49 not taken.
✓ Branch 48 → 50 taken 2 times.
4 (avctx->ch_layout.nb_channels == 2 && avctx->block_align % 8))
367 ✗ return AVERROR_INVALIDDATA;
368 4 break;
369 179 default:
370 179 break;
371 }
372
373
4/4
✓ Branch 52 → 53 taken 95 times.
✓ Branch 52 → 54 taken 8 times.
✓ Branch 52 → 58 taken 13 times.
✓ Branch 52 → 62 taken 91 times.
207 switch (avctx->codec->id) {
374 95 case AV_CODEC_ID_ADPCM_AICA:
375 case AV_CODEC_ID_ADPCM_IMA_CUNNING:
376 case AV_CODEC_ID_ADPCM_IMA_DAT4:
377 case AV_CODEC_ID_ADPCM_IMA_QT:
378 case AV_CODEC_ID_ADPCM_IMA_WAV:
379 case AV_CODEC_ID_ADPCM_IMA_XBOX:
380 case AV_CODEC_ID_ADPCM_4XM:
381 case AV_CODEC_ID_ADPCM_XA:
382 case AV_CODEC_ID_ADPCM_XMD:
383 case AV_CODEC_ID_ADPCM_EA_R1:
384 case AV_CODEC_ID_ADPCM_EA_R2:
385 case AV_CODEC_ID_ADPCM_EA_R3:
386 case AV_CODEC_ID_ADPCM_EA_XAS:
387 case AV_CODEC_ID_ADPCM_THP:
388 case AV_CODEC_ID_ADPCM_THP_LE:
389 case AV_CODEC_ID_ADPCM_AFC:
390 case AV_CODEC_ID_ADPCM_DTK:
391 case AV_CODEC_ID_ADPCM_PSX:
392 case AV_CODEC_ID_ADPCM_PSXC:
393 case AV_CODEC_ID_ADPCM_SANYO:
394 case AV_CODEC_ID_ADPCM_MTAF:
395 case AV_CODEC_ID_ADPCM_ARGO:
396 case AV_CODEC_ID_ADPCM_IMA_MOFLEX:
397 case AV_CODEC_ID_ADPCM_N64:
398 95 avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
399 95 break;
400 8 case AV_CODEC_ID_ADPCM_IMA_WS:
401
2/2
✓ Branch 54 → 55 taken 2 times.
✓ Branch 54 → 56 taken 6 times.
8 avctx->sample_fmt = c->vqa_version == 3 ? AV_SAMPLE_FMT_S16P :
402 AV_SAMPLE_FMT_S16;
403 8 break;
404 13 case AV_CODEC_ID_ADPCM_MS:
405
1/2
✗ Branch 58 → 59 not taken.
✓ Branch 58 → 60 taken 13 times.
13 avctx->sample_fmt = avctx->ch_layout.nb_channels > 2 ? AV_SAMPLE_FMT_S16P :
406 AV_SAMPLE_FMT_S16;
407 13 break;
408 91 default:
409 91 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
410 }
411 207 return 0;
412 }
413
414 ✗ static inline int16_t adpcm_agm_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
415 {
416 int delta, pred, step, add;
417
418 ✗ pred = c->predictor;
419 ✗ delta = nibble & 7;
420 ✗ step = c->step;
421 ✗ add = (delta * 2 + 1) * step;
422
0/2
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
✗ if (add < 0)
423 ✗ add = add + 7;
424
425
0/2
✗ Branch 4 → 5 not taken.
✗ Branch 4 → 6 not taken.
✗ if ((nibble & 8) == 0)
426 ✗ pred = av_clip(pred + (add >> 3), -32767, 32767);
427 else
428 ✗ pred = av_clip(pred - (add >> 3), -32767, 32767);
429
430
0/5
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 9 not taken.
✗ Branch 7 → 10 not taken.
✗ Branch 7 → 11 not taken.
✗ Branch 7 → 12 not taken.
✗ switch (delta) {
431 ✗ case 7:
432 ✗ step *= 0x99;
433 ✗ break;
434 ✗ case 6:
435 ✗ c->step = av_clip(c->step * 2, 127, 24576);
436 ✗ c->predictor = pred;
437 ✗ return pred;
438 ✗ case 5:
439 ✗ step *= 0x66;
440 ✗ break;
441 ✗ case 4:
442 ✗ step *= 0x4d;
443 ✗ break;
444 ✗ default:
445 ✗ step *= 0x39;
446 ✗ break;
447 }
448
449
0/2
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 15 not taken.
✗ if (step < 0)
450 ✗ step += 0x3f;
451
452 ✗ c->step = step >> 6;
453 ✗ c->step = av_clip(c->step, 127, 24576);
454 ✗ c->predictor = pred;
455 ✗ return pred;
456 }
457
458 #if CONFIG_ADPCM_IMA_ESCAPE_DECODER
459 ✗ static inline int16_t adpcm_ima_escape_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
460 {
461 int step_index;
462 int predictor;
463 int sign, delta, diff, step;
464
465 ✗ step = ff_adpcm_step_table[c->step_index];
466 ✗ step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
467 ✗ step_index = av_clip(step_index, 0, 88);
468
469 ✗ sign = nibble & 8;
470 ✗ delta = nibble & 7;
471 ✗ diff = (delta * step) >> 2;
472 ✗ predictor = c->predictor;
473
0/2
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
✗ if (sign) predictor -= diff;
474 ✗ else predictor += diff;
475
476 ✗ c->predictor = av_clip_int16(predictor);
477 ✗ c->step_index = step_index;
478
479 ✗ return (int16_t)c->predictor;
480 }
481 #endif
482
483 8100424 static inline int16_t adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift)
484 {
485 int step_index;
486 int predictor;
487 int sign, delta, diff, step;
488
489 8100424 step = ff_adpcm_step_table[c->step_index];
490 8100424 step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
491 8100424 step_index = av_clip(step_index, 0, 88);
492
493 8100424 sign = nibble & 8;
494 8100424 delta = nibble & 7;
495 /* perform direct multiplication instead of series of jumps proposed by
496 * the reference ADPCM implementation since modern CPUs can do the mults
497 * quickly enough */
498 8100424 diff = ((2 * delta + 1) * step) >> shift;
499 8100424 predictor = c->predictor;
500
2/2
✓ Branch 2 → 3 taken 4004685 times.
✓ Branch 2 → 4 taken 4095739 times.
8100424 if (sign) predictor -= diff;
501 4095739 else predictor += diff;
502
503 8100424 c->predictor = av_clip_int16(predictor);
504 8100424 c->step_index = step_index;
505
506 8100424 return (int16_t)c->predictor;
507 }
508
509 679344 static inline int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift)
510 {
511 int step_index;
512 int predictor;
513 int sign, delta, diff, step;
514
515 679344 step = ff_adpcm_step_table[c->step_index];
516 679344 step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
517 679344 step_index = av_clip(step_index, 0, 88);
518
519 679344 sign = nibble & 8;
520 679344 delta = nibble & 7;
521 679344 diff = (delta * step) >> shift;
522 679344 predictor = c->predictor;
523
2/2
✓ Branch 2 → 3 taken 339842 times.
✓ Branch 2 → 4 taken 339502 times.
679344 if (sign) predictor -= diff;
524 339502 else predictor += diff;
525
526 679344 c->predictor = av_clip_int16(predictor);
527 679344 c->step_index = step_index;
528
529 679344 return (int16_t)c->predictor;
530 }
531
532 ✗ static inline int16_t adpcm_ima_mtf_expand_nibble(ADPCMChannelStatus *c, int nibble)
533 {
534 int step_index, step, delta, predictor;
535
536 ✗ step = ff_adpcm_step_table[c->step_index];
537
538 ✗ delta = step * (2 * nibble - 15);
539 ✗ predictor = c->predictor + delta;
540
541 ✗ step_index = c->step_index + mtf_index_table[(unsigned)nibble];
542 ✗ c->predictor = av_clip_int16(predictor >> 4);
543 ✗ c->step_index = av_clip(step_index, 0, 88);
544
545 ✗ return (int16_t)c->predictor;
546 }
547
548 386028 static inline int16_t adpcm_ima_cunning_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
549 {
550 int step_index;
551 int predictor;
552 int step;
553
554 386028 nibble = sign_extend(nibble & 0xF, 4);
555
556 386028 step = ima_cunning_step_table[c->step_index];
557 386028 step_index = c->step_index + ima_cunning_index_table[abs(nibble)];
558 386028 step_index = av_clip(step_index, 0, 60);
559
560 386028 predictor = c->predictor + step * nibble;
561
562 386028 c->predictor = av_clip_int16(predictor);
563 386028 c->step_index = step_index;
564
565 386028 return c->predictor;
566 }
567
568 ✗ static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps)
569 {
570 int nibble, step_index, predictor, sign, delta, diff, step, shift;
571
572 ✗ shift = bps - 1;
573 ✗ nibble = get_bits_le(gb, bps),
574 ✗ step = ff_adpcm_step_table[c->step_index];
575 ✗ step_index = c->step_index + adpcm_index_tables[bps - 2][nibble];
576 ✗ step_index = av_clip(step_index, 0, 88);
577
578 ✗ sign = nibble & (1 << shift);
579 ✗ delta = av_zero_extend(nibble, shift);
580 ✗ diff = step >> shift;
581
0/2
✗ Branch 5 → 4 not taken.
✗ Branch 5 → 6 not taken.
✗ for (int i = 0; i < shift; i++)
582 ✗ diff += (step >> (shift-1-i)) * !!(delta & (1 << i));
583 ✗ predictor = c->predictor;
584
0/2
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 8 not taken.
✗ if (sign) predictor -= diff;
585 ✗ else predictor += diff;
586
587 ✗ c->predictor = av_clip_int16(predictor);
588 ✗ c->step_index = step_index;
589
590 ✗ return (int16_t)c->predictor;
591 }
592
593 6911962 int16_t ff_adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble)
594 {
595 int step_index;
596 int predictor;
597 int diff, step;
598
599 6911962 step = ff_adpcm_step_table[c->step_index];
600 6911962 step_index = c->step_index + ff_adpcm_index_table[nibble];
601 6911962 step_index = av_clip(step_index, 0, 88);
602
603 6911962 diff = step >> 3;
604
2/2
✓ Branch 2 → 3 taken 1590213 times.
✓ Branch 2 → 4 taken 5321749 times.
6911962 if (nibble & 4) diff += step;
605
2/2
✓ Branch 4 → 5 taken 2944916 times.
✓ Branch 4 → 6 taken 3967046 times.
6911962 if (nibble & 2) diff += step >> 1;
606
2/2
✓ Branch 6 → 7 taken 3194806 times.
✓ Branch 6 → 8 taken 3717156 times.
6911962 if (nibble & 1) diff += step >> 2;
607
608
2/2
✓ Branch 8 → 9 taken 3443931 times.
✓ Branch 8 → 10 taken 3468031 times.
6911962 if (nibble & 8)
609 3443931 predictor = c->predictor - diff;
610 else
611 3468031 predictor = c->predictor + diff;
612
613 6911962 c->predictor = av_clip_int16(predictor);
614 6911962 c->step_index = step_index;
615
616 6911962 return c->predictor;
617 }
618
619 #if CONFIG_ADPCM_IMA_HVQM2_DECODER
620 ✗ static void decode_adpcm_ima_hvqm2(AVCodecContext *avctx, int16_t *outbuf,
621 int samples_to_do, int frame_format,
622 GetByteContext *gb)
623 {
624 ✗ ADPCMDecodeContext *c = avctx->priv_data;
625 ✗ int st = avctx->ch_layout.nb_channels == 2;
626 uint8_t nibble;
627
628
0/2
✗ Branch 8 → 3 not taken.
✗ Branch 8 → 9 not taken.
✗ for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
629 unsigned tmp;
630
631
0/2
✗ Branch 3 → 4 not taken.
✗ Branch 3 → 6 not taken.
✗ switch (frame_format) {
632 ✗ case 0: /* combined hist+index */
633 ✗ tmp = bytestream2_get_be16(gb);
634 ✗ c->status[ch].predictor = sign_extend(tmp & 0xFF80, 16);
635 ✗ c->status[ch].step_index = tmp & 0x7f;
636 ✗ *outbuf++ = c->status[ch].predictor;
637 ✗ samples_to_do--;
638 ✗ break;
639 ✗ default:
640 ✗ break;
641 }
642
643 ✗ c->status[ch].step_index = av_clip(c->status[ch].step_index, 0, 88);
644 }
645
646
0/2
✗ Branch 17 → 10 not taken.
✗ Branch 17 → 18 not taken.
✗ for (int i = 0; i < samples_to_do; i++) {
647
0/2
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 14 not taken.
✗ if (!(i&1)) {
648 ✗ nibble = bytestream2_get_byte(gb);
649 ✗ *outbuf++ = ff_adpcm_ima_qt_expand_nibble(&c->status[st], nibble >> 4);
650 } else {
651 ✗ *outbuf++ = ff_adpcm_ima_qt_expand_nibble(&c->status[ 0], nibble & 0xF);
652 }
653 }
654
655 ✗ bytestream2_seek(gb, 0, SEEK_END);
656 ✗ }
657 #endif
658
659 #if CONFIG_ADPCM_IMA_HVQM4_DECODER
660 ✗ static void decode_adpcm_ima_hvqm4(AVCodecContext *avctx, int16_t *outbuf,
661 int samples_to_do, int frame_format,
662 GetByteContext *gb)
663 {
664 ✗ ADPCMDecodeContext *c = avctx->priv_data;
665 ✗ int st = avctx->ch_layout.nb_channels == 2;
666 unsigned tmp;
667
668
0/2
✗ Branch 11 → 3 not taken.
✗ Branch 11 → 12 not taken.
✗ for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
669
0/3
✗ Branch 3 → 4 not taken.
✗ Branch 3 → 6 not taken.
✗ Branch 3 → 7 not taken.
✗ switch (frame_format) {
670 ✗ case 1: /* combined hist+index */
671 ✗ tmp = bytestream2_get_be16(gb);
672 ✗ c->status[ch].predictor = sign_extend(tmp & 0xFF80, 16);
673 ✗ c->status[ch].step_index = tmp & 0x7f;
674 ✗ break;
675 ✗ case 2: /* no hist/index (continues from previous frame) */
676 default:
677 ✗ break;
678 ✗ case 3: /* separate hist+index */
679 ✗ tmp = bytestream2_get_be16(gb);
680 ✗ c->status[ch].predictor = sign_extend(tmp, 16);
681 ✗ c->status[ch].step_index = bytestream2_get_byte(gb);
682 ✗ break;
683 }
684
685 ✗ c->status[ch].step_index = av_clip(c->status[ch].step_index, 0, 88);
686 }
687
688
0/4
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 14 not taken.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 18 not taken.
✗ if (frame_format == 1 || frame_format == 3) {
689
0/2
✗ Branch 16 → 15 not taken.
✗ Branch 16 → 17 not taken.
✗ for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++)
690 ✗ *outbuf++ = (int16_t)c->status[st - ch].predictor;
691 ✗ samples_to_do--;
692 }
693
694
0/2
✗ Branch 26 → 19 not taken.
✗ Branch 26 → 27 not taken.
✗ for (int i = 0; i < samples_to_do; i += 1+(!st)) {
695 ✗ uint8_t nibble = bytestream2_get_byte(gb);
696
697 ✗ *outbuf++ = ff_adpcm_ima_qt_expand_nibble(&c->status[st], nibble & 0xF);
698
0/2
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 24 not taken.
✗ *outbuf++ = ff_adpcm_ima_qt_expand_nibble(&c->status[ 0], nibble >> 4);
699 }
700
701 ✗ bytestream2_seek(gb, 0, SEEK_END);
702 ✗ }
703 #endif
704
705 2229948 static inline int16_t adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble)
706 {
707 int predictor;
708
709 2229948 predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 64;
710
2/2
✓ Branch 2 → 3 taken 972056 times.
✓ Branch 2 → 4 taken 1257892 times.
2229948 predictor += ((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
711
712 2229948 c->sample2 = c->sample1;
713 2229948 c->sample1 = av_clip_int16(predictor);
714 2229948 c->idelta = (ff_adpcm_AdaptationTable[(int)nibble] * c->idelta) >> 8;
715
2/2
✓ Branch 5 → 6 taken 92703 times.
✓ Branch 5 → 7 taken 2137245 times.
2229948 if (c->idelta < 16) c->idelta = 16;
716
1/2
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 10 taken 2229948 times.
2229948 if (c->idelta > INT_MAX/768) {
717 ✗ av_log(NULL, AV_LOG_WARNING, "idelta overflow\n");
718 ✗ c->idelta = INT_MAX/768;
719 }
720
721 2229948 return c->sample1;
722 }
723
724 55124 static inline int16_t adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nibble)
725 {
726 int step_index, predictor, sign, delta, diff, step;
727
728 55124 step = oki_step_table[c->step_index];
729 55124 step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
730 55124 step_index = av_clip(step_index, 0, 48);
731
732 55124 sign = nibble & 8;
733 55124 delta = nibble & 7;
734 55124 diff = ((2 * delta + 1) * step) >> 3;
735 55124 predictor = c->predictor;
736
2/2
✓ Branch 2 → 3 taken 25352 times.
✓ Branch 2 → 4 taken 29772 times.
55124 if (sign) predictor -= diff;
737 29772 else predictor += diff;
738
739 55124 c->predictor = av_clip_intp2(predictor, 11);
740 55124 c->step_index = step_index;
741
742 55124 return c->predictor * 16;
743 }
744
745 524192 static inline int16_t adpcm_ct_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
746 {
747 int sign, delta, diff;
748 int new_step;
749
750 524192 sign = nibble & 8;
751 524192 delta = nibble & 7;
752 /* perform direct multiplication instead of series of jumps proposed by
753 * the reference ADPCM implementation since modern CPUs can do the mults
754 * quickly enough */
755 524192 diff = ((2 * delta + 1) * c->step) >> 3;
756 /* predictor update is not so trivial: predictor is multiplied on 254/256 before updating */
757
2/2
✓ Branch 2 → 3 taken 263253 times.
✓ Branch 2 → 4 taken 260939 times.
524192 c->predictor = ((c->predictor * 254) >> 8) + (sign ? -diff : diff);
758 524192 c->predictor = av_clip_int16(c->predictor);
759 /* calculate new step and clamp it to range 511..32767 */
760 524192 new_step = (ff_adpcm_AdaptationTable[nibble & 7] * c->step) >> 8;
761 524192 c->step = av_clip(new_step, 511, 32767);
762
763 524192 return (int16_t)c->predictor;
764 }
765
766 20480 static inline int16_t adpcm_rhetorex_expand_nibble(ADPCMChannelStatus *c, uint16_t nibble)
767 {
768 int delta, add, a, b;
769 int16_t sample;
770
771 20480 delta = nibble & 7;
772 20480 add = rhetorex_step[((c->step_index >> 8) & 0xF8) + delta];
773
2/2
✓ Branch 2 → 3 taken 10650 times.
✓ Branch 2 → 4 taken 9830 times.
20480 if (nibble & 0x8)
774 10650 add = -add;
775
776 20480 sample = av_clip_int16(c->predictor + add);
777
778 20480 a = 32768 * c->coeff1 + (add >> 1) * c->sample2;
779 20480 c->coeff1 = av_clip_int16((a - ((a >> 7) & ~0xFF)) >> 15);
780
781 20480 b = 32768 * c->coeff2 + (add >> 1) * c->sample1;
782 20480 c->coeff2 = av_clip_int16((b - ((b >> 7) & ~0xFF) + 0x800000) >> 15);
783
784 20480 c->predictor = av_clip_int16((c->coeff1 * c->sample1 + c->coeff2 * sample) >> 15);
785
786 20480 c->sample2 = c->sample1;
787 20480 c->sample1 = sample;
788
789 20480 c->step_index = FFABS((int)(64512U * c->step_index + 65536U * rhetorex_index[delta])) >> 16;
790
791 20480 return sample;
792 }
793
794 313380 static inline int16_t adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int size, int shift)
795 {
796 int sign, delta, diff;
797
798 313380 sign = nibble & (1<<(size-1));
799 313380 delta = nibble & ((1<<(size-1))-1);
800 313380 diff = delta << (7 + c->step + shift);
801
802 /* clamp result */
803
2/2
✓ Branch 2 → 3 taken 129904 times.
✓ Branch 2 → 4 taken 183476 times.
313380 c->predictor = av_clip(c->predictor + (sign ? -diff : diff), -16384,16256);
804
805 /* calculate new step */
806
4/4
✓ Branch 5 → 6 taken 97171 times.
✓ Branch 5 → 8 taken 216209 times.
✓ Branch 6 → 7 taken 75080 times.
✓ Branch 6 → 8 taken 22091 times.
313380 if (delta >= (2*size - 3) && c->step < 3)
807 75080 c->step++;
808
4/4
✓ Branch 8 → 9 taken 129907 times.
✓ Branch 8 → 11 taken 108393 times.
✓ Branch 9 → 10 taken 75080 times.
✓ Branch 9 → 11 taken 54827 times.
238300 else if (delta == 0 && c->step > 0)
809 75080 c->step--;
810
811 313380 return (int16_t) c->predictor;
812 }
813
814 1105920 static inline int16_t adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
815 {
816
2/2
✓ Branch 2 → 3 taken 5 times.
✓ Branch 2 → 4 taken 1105915 times.
1105920 if(!c->step) {
817 5 c->predictor = 0;
818 5 c->step = 127;
819 }
820
821 1105920 c->predictor += (c->step * ff_adpcm_yamaha_difflookup[nibble]) / 8;
822 1105920 c->predictor = av_clip_int16(c->predictor);
823 1105920 c->step = (c->step * ff_adpcm_yamaha_indexscale[nibble]) >> 8;
824 1105920 c->step = av_clip(c->step, 127, 24576);
825 1105920 return c->predictor;
826 }
827
828 ✗ static inline int16_t adpcm_mtaf_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
829 {
830 ✗ c->predictor += mtaf_stepsize[c->step][nibble];
831 ✗ c->predictor = av_clip_int16(c->predictor);
832 ✗ c->step += ff_adpcm_index_table[nibble];
833 ✗ c->step = av_clip_uintp2(c->step, 5);
834 ✗ return c->predictor;
835 }
836
837 #if CONFIG_ADPCM_CIRCUS_DECODER
838 ✗ static inline int16_t adpcm_circus_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
839 {
840 ✗ int32_t sample = c->predictor;
841 ✗ int32_t scale = c->step;
842 ✗ int32_t code = sign_extend(nibble, 8);
843
844 ✗ sample += code * (1 << scale);
845
0/2
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
✗ if (code == 0) {
846 ✗ scale--;
847
0/4
✗ Branch 4 → 5 not taken.
✗ Branch 4 → 6 not taken.
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 7 not taken.
✗ } else if (code == 127 || code == -128) {
848 ✗ scale++;
849 }
850 ✗ scale = av_clip(scale, 0, 8);
851 ✗ sample = av_clip_int16(sample);
852
853 ✗ c->predictor = sample;
854 ✗ c->step = scale;
855
856 ✗ return sample;
857 }
858 #endif
859
860 ✗ static inline int16_t adpcm_zork_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
861 {
862 ✗ int16_t index = c->step_index;
863 ✗ uint32_t lookup_sample = ff_adpcm_step_table[index];
864 ✗ int32_t sample = 0;
865
866
0/2
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
✗ if (nibble & 0x40)
867 ✗ sample += lookup_sample;
868
0/2
✗ Branch 4 → 5 not taken.
✗ Branch 4 → 6 not taken.
✗ if (nibble & 0x20)
869 ✗ sample += lookup_sample >> 1;
870
0/2
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 8 not taken.
✗ if (nibble & 0x10)
871 ✗ sample += lookup_sample >> 2;
872
0/2
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
✗ if (nibble & 0x08)
873 ✗ sample += lookup_sample >> 3;
874
0/2
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 12 not taken.
✗ if (nibble & 0x04)
875 ✗ sample += lookup_sample >> 4;
876
0/2
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 14 not taken.
✗ if (nibble & 0x02)
877 ✗ sample += lookup_sample >> 5;
878
0/2
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 16 not taken.
✗ if (nibble & 0x01)
879 ✗ sample += lookup_sample >> 6;
880
0/2
✗ Branch 16 → 17 not taken.
✗ Branch 16 → 18 not taken.
✗ if (nibble & 0x80)
881 ✗ sample = -sample;
882
883 ✗ sample += c->predictor;
884 ✗ sample = av_clip_int16(sample);
885
886 ✗ index += zork_index_table[(nibble >> 4) & 7];
887 ✗ index = av_clip(index, 0, 88);
888
889 ✗ c->predictor = sample;
890 ✗ c->step_index = index;
891
892 ✗ return sample;
893 }
894
895 #if CONFIG_ADPCM_XA_DECODER
896 666 static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1,
897 const uint8_t *in, ADPCMChannelStatus *left,
898 ADPCMChannelStatus *right, int channels, int sample_offset)
899 {
900 int i, j;
901 int shift,filter,f0,f1;
902 int s_1,s_2;
903 int d,s,t;
904
905 666 out0 += sample_offset;
906
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 666 times.
666 if (channels == 1)
907 ✗ out1 = out0 + 28;
908 else
909 666 out1 += sample_offset;
910
911
2/2
✓ Branch 31 → 6 taken 2664 times.
✓ Branch 31 → 32 taken 666 times.
3330 for(i=0;i<4;i++) {
912 2664 shift = 12 - (in[4+i*2] & 15);
913 2664 filter = in[4+i*2] >> 4;
914
1/2
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 9 taken 2664 times.
2664 if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table)) {
915 ✗ avpriv_request_sample(avctx, "unknown XA-ADPCM filter %d", filter);
916 ✗ filter=0;
917 }
918
1/2
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 12 taken 2664 times.
2664 if (shift < 0) {
919 ✗ avpriv_request_sample(avctx, "unknown XA-ADPCM shift %d", shift);
920 ✗ shift = 0;
921 }
922 2664 f0 = xa_adpcm_table[filter][0];
923 2664 f1 = xa_adpcm_table[filter][1];
924
925 2664 s_1 = left->sample1;
926 2664 s_2 = left->sample2;
927
928
2/2
✓ Branch 14 → 13 taken 74592 times.
✓ Branch 14 → 15 taken 2664 times.
77256 for(j=0;j<28;j++) {
929 74592 d = in[16+i+j*4];
930
931 74592 t = sign_extend(d, 4);
932 74592 s = t*(1<<shift) + ((s_1*f0 + s_2*f1+32)>>6);
933 74592 s_2 = s_1;
934 74592 s_1 = av_clip_int16(s);
935 74592 out0[j] = s_1;
936 }
937
938
1/2
✓ Branch 15 → 16 taken 2664 times.
✗ Branch 15 → 17 not taken.
2664 if (channels == 2) {
939 2664 left->sample1 = s_1;
940 2664 left->sample2 = s_2;
941 2664 s_1 = right->sample1;
942 2664 s_2 = right->sample2;
943 }
944
945 2664 shift = 12 - (in[5+i*2] & 15);
946 2664 filter = in[5+i*2] >> 4;
947
2/4
✓ Branch 17 → 18 taken 2664 times.
✗ Branch 17 → 19 not taken.
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 21 taken 2664 times.
2664 if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table) || shift < 0) {
948 ✗ avpriv_request_sample(avctx, "unknown XA-ADPCM filter %d", filter);
949 ✗ filter=0;
950 }
951
1/2
✗ Branch 21 → 22 not taken.
✓ Branch 21 → 24 taken 2664 times.
2664 if (shift < 0) {
952 ✗ avpriv_request_sample(avctx, "unknown XA-ADPCM shift %d", shift);
953 ✗ shift = 0;
954 }
955
956 2664 f0 = xa_adpcm_table[filter][0];
957 2664 f1 = xa_adpcm_table[filter][1];
958
959
2/2
✓ Branch 26 → 25 taken 74592 times.
✓ Branch 26 → 27 taken 2664 times.
77256 for(j=0;j<28;j++) {
960 74592 d = in[16+i+j*4];
961
962 74592 t = sign_extend(d >> 4, 4);
963 74592 s = t*(1<<shift) + ((s_1*f0 + s_2*f1+32)>>6);
964 74592 s_2 = s_1;
965 74592 s_1 = av_clip_int16(s);
966 74592 out1[j] = s_1;
967 }
968
969
1/2
✓ Branch 27 → 28 taken 2664 times.
✗ Branch 27 → 29 not taken.
2664 if (channels == 2) {
970 2664 right->sample1 = s_1;
971 2664 right->sample2 = s_2;
972 } else {
973 ✗ left->sample1 = s_1;
974 ✗ left->sample2 = s_2;
975 }
976
977 2664 out0 += 28 * (3 - channels);
978 2664 out1 += 28 * (3 - channels);
979 }
980
981 666 return 0;
982 }
983 #endif
984
985 #if CONFIG_ADPCM_SWF_DECODER
986 195 static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int16_t *samples)
987 {
988 195 ADPCMDecodeContext *c = avctx->priv_data;
989 GetBitContext gb;
990 const int8_t *table;
991 195 int channels = avctx->ch_layout.nb_channels;
992 int k0, signmask, nb_bits, count;
993 195 int size = buf_size*8;
994 int i;
995
996 195 init_get_bits(&gb, buf, size);
997
998 //read bits & initial values
999 195 nb_bits = get_bits(&gb, 2)+2;
1000 195 table = swf_index_tables[nb_bits-2];
1001 195 k0 = 1 << (nb_bits-2);
1002 195 signmask = 1 << (nb_bits-1);
1003
1004
2/2
✓ Branch 28 → 5 taken 195 times.
✓ Branch 28 → 29 taken 195 times.
390 while (get_bits_count(&gb) <= size - 22 * channels) {
1005
2/2
✓ Branch 9 → 6 taken 390 times.
✓ Branch 9 → 10 taken 195 times.
585 for (i = 0; i < channels; i++) {
1006 390 *samples++ = c->status[i].predictor = get_sbits(&gb, 16);
1007 390 c->status[i].step_index = get_bits(&gb, 6);
1008 }
1009
1010
3/4
✓ Branch 24 → 25 taken 798525 times.
✓ Branch 24 → 26 taken 195 times.
✓ Branch 25 → 11 taken 798525 times.
✗ Branch 25 → 26 not taken.
798720 for (count = 0; get_bits_count(&gb) <= size - nb_bits * channels && count < 4095; count++) {
1011 int i;
1012
1013
2/2
✓ Branch 21 → 12 taken 1597050 times.
✓ Branch 21 → 22 taken 798525 times.
2395575 for (i = 0; i < channels; i++) {
1014 // similar to IMA adpcm
1015 1597050 int delta = get_bits(&gb, nb_bits);
1016 1597050 int step = ff_adpcm_step_table[c->status[i].step_index];
1017 1597050 int vpdiff = 0; // vpdiff = (delta+0.5)*step/4
1018 1597050 int k = k0;
1019
1020 do {
1021
2/2
✓ Branch 14 → 15 taken 1979561 times.
✓ Branch 14 → 16 taken 2811589 times.
4791150 if (delta & k)
1022 1979561 vpdiff += step;
1023 4791150 step >>= 1;
1024 4791150 k >>= 1;
1025
2/2
✓ Branch 16 → 14 taken 3194100 times.
✓ Branch 16 → 17 taken 1597050 times.
4791150 } while(k);
1026 1597050 vpdiff += step;
1027
1028
2/2
✓ Branch 17 → 18 taken 803527 times.
✓ Branch 17 → 19 taken 793523 times.
1597050 if (delta & signmask)
1029 803527 c->status[i].predictor -= vpdiff;
1030 else
1031 793523 c->status[i].predictor += vpdiff;
1032
1033 1597050 c->status[i].step_index += table[delta & (~signmask)];
1034
1035 1597050 c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
1036 1597050 c->status[i].predictor = av_clip_int16(c->status[i].predictor);
1037
1038 1597050 *samples++ = c->status[i].predictor;
1039 }
1040 }
1041 }
1042 195 }
1043 #endif
1044
1045 18335520 int16_t ff_adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int shift, int flag)
1046 {
1047 18335520 int sample = sign_extend(nibble, 4) * (1 << shift);
1048
1049
2/2
✓ Branch 2 → 3 taken 9806208 times.
✓ Branch 2 → 4 taken 8529312 times.
18335520 if (flag)
1050 9806208 sample += (8 * cs->sample1) - (4 * cs->sample2);
1051 else
1052 8529312 sample += 4 * cs->sample1;
1053
1054 18335520 sample = av_clip_int16(sample >> 2);
1055
1056 18335520 cs->sample2 = cs->sample1;
1057 18335520 cs->sample1 = sample;
1058
1059 18335520 return sample;
1060 }
1061
1062 #if CONFIG_ADPCM_SANYO_DECODER
1063 20832 static int adpcm_sanyo_expand3(ADPCMChannelStatus *c, int bits)
1064 {
1065 int sign, delta, add;
1066
1067 20832 sign = bits & 4;
1068
2/2
✓ Branch 2 → 3 taken 7806 times.
✓ Branch 2 → 4 taken 13026 times.
20832 if (sign)
1069 7806 delta = 4 - (bits & 3);
1070 else
1071 13026 delta = bits;
1072
1073
5/6
✓ Branch 5 → 6 taken 5975 times.
✓ Branch 5 → 7 taken 8612 times.
✓ Branch 5 → 8 taken 3893 times.
✓ Branch 5 → 9 taken 2199 times.
✓ Branch 5 → 10 taken 153 times.
✗ Branch 5 → 11 not taken.
20832 switch (delta) {
1074 5975 case 0:
1075 5975 add = 0;
1076 5975 c->step = (3 * c->step) >> 2;
1077 5975 break;
1078 8612 case 1:
1079 8612 add = c->step;
1080 8612 c->step = (4 * c->step - (c->step >> 1)) >> 2;
1081 8612 break;
1082 3893 case 2:
1083 3893 add = 2 * c->step;
1084 3893 c->step = ((c->step >> 1) + add) >> 1;
1085 3893 break;
1086 2199 case 3:
1087 2199 add = 4 * c->step - (c->step >> 1);
1088 2199 c->step = 2 * c->step;
1089 2199 break;
1090 153 case 4:
1091 153 add = (11 * c->step) >> 1;
1092 153 c->step = 3 * c->step;
1093 153 break;
1094 ✗ default:
1095 ✗ av_unreachable("There are cases for all control paths when bits is 3-bit");
1096 }
1097
1098
2/2
✓ Branch 12 → 13 taken 7806 times.
✓ Branch 12 → 14 taken 13026 times.
20832 if (sign)
1099 7806 add = -add;
1100
1101 20832 c->predictor = av_clip_int16(c->predictor + add);
1102 20832 c->step = av_clip(c->step, 1, 7281);
1103 20832 return c->predictor;
1104 }
1105
1106 20664 static int adpcm_sanyo_expand4(ADPCMChannelStatus *c, int bits)
1107 {
1108 int sign, delta, add;
1109
1110 20664 sign = bits & 8;
1111
2/2
✓ Branch 2 → 3 taken 9081 times.
✓ Branch 2 → 4 taken 11583 times.
20664 if (sign)
1112 9081 delta = 8 - (bits & 7);
1113 else
1114 11583 delta = bits;
1115
1116
9/10
✓ Branch 5 → 6 taken 3407 times.
✓ Branch 5 → 7 taken 4750 times.
✓ Branch 5 → 8 taken 3536 times.
✓ Branch 5 → 9 taken 2837 times.
✓ Branch 5 → 10 taken 2269 times.
✓ Branch 5 → 11 taken 2264 times.
✓ Branch 5 → 12 taken 879 times.
✓ Branch 5 → 13 taken 605 times.
✓ Branch 5 → 17 taken 117 times.
✗ Branch 5 → 18 not taken.
20664 switch (delta) {
1117 3407 case 0:
1118 3407 add = 0;
1119 3407 c->step = (3 * c->step) >> 2;
1120 3407 break;
1121 4750 case 1:
1122 4750 add = c->step;
1123 4750 c->step = (3 * c->step) >> 2;
1124 4750 break;
1125 3536 case 2:
1126 3536 add = 2 * c->step;
1127 3536 break;
1128 2837 case 3:
1129 2837 add = 3 * c->step;
1130 2837 break;
1131 2269 case 4:
1132 2269 add = 4 * c->step;
1133 2269 break;
1134 2264 case 5:
1135 2264 add = (11 * c->step) >> 1;
1136 2264 c->step += c->step >> 2;
1137 2264 break;
1138 879 case 6:
1139 879 add = (15 * c->step) >> 1;
1140 879 c->step = 2 * c->step;
1141 879 break;
1142 605 case 7:
1143
2/2
✓ Branch 13 → 14 taken 169 times.
✓ Branch 13 → 15 taken 436 times.
605 if (sign)
1144 169 add = (19 * c->step) >> 1;
1145 else
1146 436 add = (21 * c->step) >> 1;
1147 605 c->step = (c->step >> 1) + 2 * c->step;
1148 605 break;
1149 117 case 8:
1150 117 add = (25 * c->step) >> 1;
1151 117 c->step = 5 * c->step;
1152 117 break;
1153 ✗ default:
1154 ✗ av_unreachable("There are cases for all control paths when bits is 4-bit");
1155 }
1156
1157
2/2
✓ Branch 19 → 20 taken 9081 times.
✓ Branch 19 → 21 taken 11583 times.
20664 if (sign)
1158 9081 add = -add;
1159
1160 20664 c->predictor = av_clip_int16(c->predictor + add);
1161 20664 c->step = av_clip(c->step, 1, 2621);
1162 20664 return c->predictor;
1163 }
1164
1165 20956 static int adpcm_sanyo_expand5(ADPCMChannelStatus *c, int bits)
1166 {
1167 int sign, delta, add;
1168
1169 20956 sign = bits & 0x10;
1170
2/2
✓ Branch 2 → 3 taken 9481 times.
✓ Branch 2 → 4 taken 11475 times.
20956 if (sign)
1171 9481 delta = 16 - (bits & 0xF);
1172 else
1173 11475 delta = bits;
1174
1175 20956 add = delta * c->step;
1176
13/14
✓ Branch 5 → 6 taken 2894 times.
✓ Branch 5 → 7 taken 8615 times.
✓ Branch 5 → 8 taken 3930 times.
✓ Branch 5 → 9 taken 1463 times.
✓ Branch 5 → 10 taken 1105 times.
✓ Branch 5 → 11 taken 747 times.
✓ Branch 5 → 12 taken 516 times.
✓ Branch 5 → 13 taken 397 times.
✓ Branch 5 → 14 taken 309 times.
✓ Branch 5 → 15 taken 215 times.
✓ Branch 5 → 16 taken 175 times.
✓ Branch 5 → 17 taken 125 times.
✓ Branch 5 → 18 taken 465 times.
✗ Branch 5 → 19 not taken.
20956 switch (delta) {
1177 2894 case 0:
1178 2894 c->step += (c->step >> 2) - (c->step >> 1);
1179 2894 break;
1180 8615 case 1:
1181 case 2:
1182 case 3:
1183 8615 c->step += (c->step >> 3) - (c->step >> 2);
1184 8615 break;
1185 3930 case 4:
1186 case 5:
1187 3930 c->step += (c->step >> 4) - (c->step >> 3);
1188 3930 break;
1189 1463 case 6:
1190 1463 break;
1191 1105 case 7:
1192 1105 c->step += c->step >> 3;
1193 1105 break;
1194 747 case 8:
1195 747 c->step += c->step >> 2;
1196 747 break;
1197 516 case 9:
1198 516 c->step += c->step >> 1;
1199 516 break;
1200 397 case 10:
1201 397 c->step = 2 * c->step - (c->step >> 3);
1202 397 break;
1203 309 case 11:
1204 309 c->step = 2 * c->step + (c->step >> 3);
1205 309 break;
1206 215 case 12:
1207 215 c->step = 2 * c->step + (c->step >> 1) - (c->step >> 3);
1208 215 break;
1209 175 case 13:
1210 175 c->step = 3 * c->step - (c->step >> 2);
1211 175 break;
1212 125 case 14:
1213 125 c->step *= 3;
1214 125 break;
1215 465 case 15:
1216 case 16:
1217 465 c->step = (7 * c->step) >> 1;
1218 465 break;
1219 }
1220
1221
2/2
✓ Branch 19 → 20 taken 9481 times.
✓ Branch 19 → 21 taken 11475 times.
20956 if (sign)
1222 9481 add = -add;
1223
1224 20956 c->predictor = av_clip_int16(c->predictor + add);
1225 20956 c->step = av_clip(c->step, 1, 1024);
1226 20956 return c->predictor;
1227 }
1228 #endif
1229
1230 #if CONFIG_ADPCM_IMA_CITRIX_DECODER
1231 424576 static int adpcm_citrix_expand(ADPCMChannelStatus *c, int bits)
1232 {
1233 424576 int step = ff_adpcm_step_table[c->step_index];
1234 424576 int add = step >> 1;
1235
2/2
✓ Branch 2 → 3 taken 124950 times.
✓ Branch 2 → 4 taken 299626 times.
424576 if ((bits & 1))
1236 124950 add += step;
1237
2/2
✓ Branch 4 → 5 taken 212006 times.
✓ Branch 4 → 6 taken 212570 times.
424576 if ((bits & 2))
1238 212006 add = -add;
1239 424576 c->step_index = av_clip(c->step_index + citrix_index_table[bits], 0, 88);
1240 424576 c->predictor = av_clip_int16(c->predictor + add);
1241 424576 return c->predictor;
1242 }
1243 #endif
1244
1245 /**
1246 * Get the number of samples (per channel) that will be decoded from the packet.
1247 * In one case, this is actually the maximum number of samples possible to
1248 * decode with the given buf_size.
1249 *
1250 * @param[out] coded_samples set to the number of samples as coded in the
1251 * packet, or 0 if the codec does not encode the
1252 * number of samples in each frame.
1253 * @param[out] approx_nb_samples set to non-zero if the number of samples
1254 * returned is an approximation.
1255 */
1256 38297 static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
1257 int buf_size, int *coded_samples, int *approx_nb_samples)
1258 {
1259 38297 ADPCMDecodeContext *s = avctx->priv_data;
1260 38297 int nb_samples = 0;
1261 38297 int ch = avctx->ch_layout.nb_channels;
1262 38297 int has_coded_samples = 0;
1263 int header_size;
1264
1265 38297 *coded_samples = 0;
1266 38297 *approx_nb_samples = 0;
1267
1268
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 38297 times.
38297 if(ch <= 0)
1269 ✗ return 0;
1270
1/2
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 38297 times.
38297 if (buf_size > INT_MAX / 14)
1271 ✗ return 0;
1272
1273
4/5
✓ Branch 6 → 7 taken 600 times.
✓ Branch 6 → 10 taken 26342 times.
✗ Branch 6 → 13 not taken.
✓ Branch 6 → 14 taken 1195 times.
✓ Branch 6 → 15 taken 10160 times.
38297 switch (avctx->codec->id) {
1274 /* constant, only check buf_size */
1275 600 case AV_CODEC_ID_ADPCM_EA_XAS:
1276
1/2
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 600 times.
600 if (buf_size < 76 * ch)
1277 ✗ return 0;
1278 600 nb_samples = 128;
1279 600 break;
1280 26342 case AV_CODEC_ID_ADPCM_IMA_QT:
1281
1/2
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 12 taken 26342 times.
26342 if (buf_size < 34 * ch)
1282 ✗ return 0;
1283 26342 nb_samples = 64;
1284 26342 break;
1285 ✗ case AV_CODEC_ID_ADPCM_N64:
1286 ✗ nb_samples = (buf_size / 9) * 16;
1287 ✗ break;
1288 /* simple 4-bit adpcm */
1289 1195 case AV_CODEC_ID_ADPCM_CT:
1290 case AV_CODEC_ID_ADPCM_IMA_APC:
1291 case AV_CODEC_ID_ADPCM_IMA_CUNNING:
1292 case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
1293 case AV_CODEC_ID_ADPCM_IMA_ESCAPE:
1294 case AV_CODEC_ID_ADPCM_IMA_OKI:
1295 case AV_CODEC_ID_ADPCM_IMA_WS:
1296 case AV_CODEC_ID_ADPCM_YAMAHA:
1297 case AV_CODEC_ID_ADPCM_AICA:
1298 case AV_CODEC_ID_ADPCM_IMA_SSI:
1299 case AV_CODEC_ID_ADPCM_IMA_APM:
1300 case AV_CODEC_ID_ADPCM_IMA_ALP:
1301 case AV_CODEC_ID_ADPCM_IMA_MTF:
1302 1195 nb_samples = buf_size * 2 / ch;
1303 1195 break;
1304 }
1305
2/2
✓ Branch 15 → 16 taken 28137 times.
✓ Branch 15 → 17 taken 10160 times.
38297 if (nb_samples)
1306 28137 return nb_samples;
1307
1308 /* simple 4-bit adpcm, with header */
1309 10160 header_size = 0;
1310
3/3
✓ Branch 17 → 18 taken 145 times.
✓ Branch 17 → 19 taken 350 times.
✓ Branch 17 → 20 taken 9665 times.
10160 switch (avctx->codec->id) {
1311 145 case AV_CODEC_ID_ADPCM_4XM:
1312 case AV_CODEC_ID_ADPCM_AGM:
1313 case AV_CODEC_ID_ADPCM_IMA_ACORN:
1314 case AV_CODEC_ID_ADPCM_IMA_DAT4:
1315 case AV_CODEC_ID_ADPCM_IMA_MOFLEX:
1316 145 case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break;
1317 350 case AV_CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4 * ch; break;
1318 }
1319
2/2
✓ Branch 20 → 21 taken 495 times.
✓ Branch 20 → 22 taken 9665 times.
10160 if (header_size > 0)
1320 495 return (buf_size - header_size) * 2 / ch;
1321
1322 /* more complex formats */
1323
20/30
✓ Branch 22 → 23 taken 162 times.
✓ Branch 22 → 27 taken 158 times.
✗ Branch 22 → 32 not taken.
✗ Branch 22 → 34 not taken.
✓ Branch 22 → 41 taken 47 times.
✓ Branch 22 → 43 taken 33 times.
✓ Branch 22 → 44 taken 400 times.
✓ Branch 22 → 52 taken 642 times.
✓ Branch 22 → 55 taken 649 times.
✓ Branch 22 → 60 taken 1000 times.
✗ Branch 22 → 63 not taken.
✗ Branch 22 → 66 not taken.
✓ Branch 22 → 72 taken 1668 times.
✗ Branch 22 → 77 not taken.
✓ Branch 22 → 82 taken 2943 times.
✗ Branch 22 → 85 not taken.
✓ Branch 22 → 88 taken 57 times.
✓ Branch 22 → 97 taken 195 times.
✓ Branch 22 → 101 taken 71 times.
✓ Branch 22 → 112 taken 12 times.
✓ Branch 22 → 113 taken 37 times.
✗ Branch 22 → 114 not taken.
✓ Branch 22 → 115 taken 32 times.
✗ Branch 22 → 116 not taken.
✓ Branch 22 → 117 taken 40 times.
✓ Branch 22 → 118 taken 946 times.
✗ Branch 22 → 119 not taken.
✓ Branch 22 → 120 taken 124 times.
✓ Branch 22 → 124 taken 449 times.
✗ Branch 22 → 127 not taken.
9665 switch (avctx->codec->id) {
1324 162 case AV_CODEC_ID_ADPCM_IMA_AMV:
1325 162 bytestream2_skip(gb, 4);
1326 162 has_coded_samples = 1;
1327 162 *coded_samples = bytestream2_get_le32u(gb);
1328 162 nb_samples = FFMIN((buf_size - 8) * 2, *coded_samples);
1329 162 bytestream2_seek(gb, -8, SEEK_CUR);
1330 162 break;
1331 158 case AV_CODEC_ID_ADPCM_EA:
1332 /* Stereo is 30 bytes per block */
1333 /* Mono is 15 bytes per block */
1334 158 has_coded_samples = 1;
1335 158 *coded_samples = bytestream2_get_le32(gb);
1336 158 *coded_samples -= *coded_samples % 28;
1337
1/2
✓ Branch 28 → 29 taken 158 times.
✗ Branch 28 → 30 not taken.
158 nb_samples = (buf_size - 12) / (ch == 2 ? 30 : 15) * 28;
1338 158 break;
1339 ✗ case AV_CODEC_ID_ADPCM_IMA_HVQM2:
1340 ✗ nb_samples = ((bytestream2_peek_be64(gb) >> 16) & 0xFFFF);
1341 ✗ break;
1342 ✗ case AV_CODEC_ID_ADPCM_IMA_HVQM4:
1343 {
1344 ✗ int frame_format = bytestream2_get_be16(gb);
1345 ✗ int skip = 6;
1346
1347
0/2
✗ Branch 35 → 36 not taken.
✗ Branch 35 → 37 not taken.
✗ if (frame_format == 1)
1348 ✗ skip += 2 * ch;
1349
0/2
✗ Branch 37 → 38 not taken.
✗ Branch 37 → 39 not taken.
✗ if (frame_format == 3)
1350 ✗ skip += 3 * ch;
1351
1352 ✗ nb_samples = (buf_size - skip) * 2 / ch;
1353 ✗ bytestream2_seek(gb, 0, SEEK_SET);
1354 }
1355 ✗ break;
1356 47 case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
1357 47 has_coded_samples = 1;
1358 47 *coded_samples = bytestream2_get_le32(gb);
1359 47 nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
1360 47 break;
1361 33 case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:
1362 33 nb_samples = (buf_size - ch) / ch * 2;
1363 33 break;
1364 400 case AV_CODEC_ID_ADPCM_EA_R1:
1365 case AV_CODEC_ID_ADPCM_EA_R2:
1366 case AV_CODEC_ID_ADPCM_EA_R3:
1367 /* maximum number of samples */
1368 /* has internal offsets and a per-frame switch to signal raw 16-bit */
1369 400 has_coded_samples = 1;
1370
3/4
✓ Branch 44 → 45 taken 95 times.
✓ Branch 44 → 47 taken 180 times.
✓ Branch 44 → 49 taken 125 times.
✗ Branch 44 → 51 not taken.
400 switch (avctx->codec->id) {
1371 95 case AV_CODEC_ID_ADPCM_EA_R1:
1372 95 header_size = 4 + 9 * ch;
1373 95 *coded_samples = bytestream2_get_le32(gb);
1374 95 break;
1375 180 case AV_CODEC_ID_ADPCM_EA_R2:
1376 180 header_size = 4 + 5 * ch;
1377 180 *coded_samples = bytestream2_get_le32(gb);
1378 180 break;
1379 125 case AV_CODEC_ID_ADPCM_EA_R3:
1380 125 header_size = 4 + 5 * ch;
1381 125 *coded_samples = bytestream2_get_be32(gb);
1382 125 break;
1383 }
1384 400 *coded_samples -= *coded_samples % 28;
1385 400 nb_samples = (buf_size - header_size) * 2 / ch;
1386 400 nb_samples -= nb_samples % 28;
1387 400 *approx_nb_samples = 1;
1388 400 break;
1389 642 case AV_CODEC_ID_ADPCM_IMA_DK3:
1390
1/2
✓ Branch 52 → 53 taken 642 times.
✗ Branch 52 → 54 not taken.
642 if (avctx->block_align > 0)
1391 642 buf_size = FFMIN(buf_size, avctx->block_align);
1392 642 nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
1393 642 break;
1394 649 case AV_CODEC_ID_ADPCM_IMA_DK4:
1395
1/2
✓ Branch 55 → 56 taken 649 times.
✗ Branch 55 → 57 not taken.
649 if (avctx->block_align > 0)
1396 649 buf_size = FFMIN(buf_size, avctx->block_align);
1397
1/2
✗ Branch 57 → 58 not taken.
✓ Branch 57 → 59 taken 649 times.
649 if (buf_size < 4 * ch)
1398 ✗ return AVERROR_INVALIDDATA;
1399 649 nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
1400 649 break;
1401 1000 case AV_CODEC_ID_ADPCM_IMA_RAD:
1402
1/2
✓ Branch 60 → 61 taken 1000 times.
✗ Branch 60 → 62 not taken.
1000 if (avctx->block_align > 0)
1403 1000 buf_size = FFMIN(buf_size, avctx->block_align);
1404 1000 nb_samples = (buf_size - 4 * ch) * 2 / ch;
1405 1000 break;
1406 ✗ case AV_CODEC_ID_ADPCM_IMA_PDA:
1407
0/2
✗ Branch 63 → 64 not taken.
✗ Branch 63 → 65 not taken.
✗ if (avctx->block_align > 0)
1408 ✗ buf_size = FFMIN(buf_size, avctx->block_align);
1409 ✗ nb_samples = (buf_size - 4 * ch) * 2 / ch;
1410 ✗ break;
1411 ✗ case AV_CODEC_ID_ADPCM_IMA_MAGIX:
1412
0/2
✗ Branch 66 → 67 not taken.
✗ Branch 66 → 68 not taken.
✗ if (avctx->block_align > 0)
1413 ✗ buf_size = FFMIN(buf_size, avctx->block_align);
1414 ✗ nb_samples = (buf_size - 4 * ch) * 2 / ch;
1415
0/2
✗ Branch 68 → 69 not taken.
✗ Branch 68 → 71 not taken.
✗ if (ch == 1) {
1416 ✗ avpriv_request_sample(avctx, "mono ADPCM Magix");
1417 ✗ return AVERROR_PATCHWELCOME;
1418 }
1419 ✗ break;
1420
2/4
✓ Branch 72 → 73 taken 1668 times.
✗ Branch 72 → 74 not taken.
✗ Branch 74 → 75 not taken.
✓ Branch 74 → 76 taken 1668 times.
1668 CASE(ADPCM_IMA_WAV,
1421 int bsize = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];
1422 int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
1423 if (avctx->block_align > 0)
1424 buf_size = FFMIN(buf_size, avctx->block_align);
1425 if (buf_size < 4 * ch)
1426 return AVERROR_INVALIDDATA;
1427 nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;
1428 ) /* End of CASE */
1429
0/4
✗ Branch 77 → 78 not taken.
✗ Branch 77 → 79 not taken.
✗ Branch 79 → 80 not taken.
✗ Branch 79 → 81 not taken.
✗ CASE(ADPCM_IMA_XBOX,
1430 int bsize = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];
1431 int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
1432 if (avctx->block_align > 0)
1433 buf_size = FFMIN(buf_size, avctx->block_align);
1434 if (buf_size < 4 * ch)
1435 return AVERROR_INVALIDDATA;
1436 nb_samples = (buf_size - 4 * ch) / (bsize * ch) * bsamples + 1;
1437 ) /* End of CASE */
1438 2943 case AV_CODEC_ID_ADPCM_MS:
1439
1/2
✓ Branch 82 → 83 taken 2943 times.
✗ Branch 82 → 84 not taken.
2943 if (avctx->block_align > 0)
1440 2943 buf_size = FFMIN(buf_size, avctx->block_align);
1441 2943 nb_samples = (buf_size - 6 * ch) * 2 / ch;
1442 2943 break;
1443 ✗ case AV_CODEC_ID_ADPCM_MTAF:
1444
0/2
✗ Branch 85 → 86 not taken.
✗ Branch 85 → 87 not taken.
✗ if (avctx->block_align > 0)
1445 ✗ buf_size = FFMIN(buf_size, avctx->block_align);
1446 ✗ nb_samples = (buf_size - 16 * (ch / 2)) * 2 / ch;
1447 ✗ break;
1448 57 case AV_CODEC_ID_ADPCM_SBPRO_2:
1449 case AV_CODEC_ID_ADPCM_SBPRO_3:
1450 case AV_CODEC_ID_ADPCM_SBPRO_4:
1451 {
1452 int samples_per_byte;
1453
3/4
✓ Branch 88 → 89 taken 13 times.
✓ Branch 88 → 90 taken 18 times.
✓ Branch 88 → 91 taken 26 times.
✗ Branch 88 → 92 not taken.
57 switch (avctx->codec->id) {
1454 13 case AV_CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break;
1455 18 case AV_CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break;
1456 26 case AV_CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;
1457 }
1458
2/2
✓ Branch 92 → 93 taken 3 times.
✓ Branch 92 → 96 taken 54 times.
57 if (!s->status[0].step_index) {
1459
1/2
✗ Branch 93 → 94 not taken.
✓ Branch 93 → 95 taken 3 times.
3 if (buf_size < ch)
1460 ✗ return AVERROR_INVALIDDATA;
1461 3 nb_samples++;
1462 3 buf_size -= ch;
1463 }
1464 57 nb_samples += buf_size * samples_per_byte / ch;
1465 57 break;
1466 }
1467 195 case AV_CODEC_ID_ADPCM_SWF:
1468 {
1469 195 int buf_bits = buf_size * 8 - 2;
1470 195 int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
1471 195 int block_hdr_size = 22 * ch;
1472 195 int block_size = block_hdr_size + nbits * ch * 4095;
1473 195 int nblocks = buf_bits / block_size;
1474 195 int bits_left = buf_bits - nblocks * block_size;
1475 195 nb_samples = nblocks * 4096;
1476
1/2
✗ Branch 98 → 99 not taken.
✓ Branch 98 → 100 taken 195 times.
195 if (bits_left >= block_hdr_size)
1477 ✗ nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
1478 195 break;
1479 }
1480 71 case AV_CODEC_ID_ADPCM_THP:
1481 case AV_CODEC_ID_ADPCM_THP_LE:
1482
1/2
✗ Branch 101 → 102 not taken.
✓ Branch 101 → 103 taken 71 times.
71 if (avctx->extradata) {
1483 ✗ nb_samples = buf_size * 14 / (8 * ch);
1484 ✗ break;
1485 }
1486 71 has_coded_samples = 1;
1487 71 bytestream2_skip(gb, 4); // channel size
1488 142 *coded_samples = (avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE) ?
1489
1/2
✗ Branch 104 → 105 not taken.
✓ Branch 104 → 107 taken 71 times.
142 bytestream2_get_le32(gb) :
1490 71 bytestream2_get_be32(gb);
1491 71 buf_size -= 8 + 36 * ch;
1492 71 buf_size /= ch;
1493 71 nb_samples = buf_size / 8 * 14;
1494
1/2
✗ Branch 109 → 110 not taken.
✓ Branch 109 → 111 taken 71 times.
71 if (buf_size % 8 > 1)
1495 ✗ nb_samples += (buf_size % 8 - 1) * 2;
1496 71 *approx_nb_samples = 1;
1497 71 break;
1498 12 case AV_CODEC_ID_ADPCM_AFC:
1499 12 nb_samples = buf_size / (9 * ch) * 16;
1500 12 break;
1501 37 case AV_CODEC_ID_ADPCM_XA:
1502 37 nb_samples = (buf_size / 128) * 224 / ch;
1503 37 break;
1504 ✗ case AV_CODEC_ID_ADPCM_XMD:
1505 ✗ nb_samples = buf_size / (21 * ch) * 32;
1506 ✗ break;
1507 32 case AV_CODEC_ID_ADPCM_DTK:
1508 case AV_CODEC_ID_ADPCM_PSX:
1509 32 nb_samples = buf_size / (16 * ch) * 28;
1510 32 break;
1511 ✗ case AV_CODEC_ID_ADPCM_PSXC:
1512 ✗ nb_samples = ((buf_size - 1) / ch) * 2;
1513 ✗ break;
1514 40 case AV_CODEC_ID_ADPCM_RHETOREX:
1515 40 nb_samples = buf_size * 2;
1516 40 break;
1517 946 case AV_CODEC_ID_ADPCM_ARGO:
1518 946 nb_samples = buf_size / avctx->block_align * 32;
1519 946 break;
1520 ✗ case AV_CODEC_ID_ADPCM_CIRCUS:
1521 case AV_CODEC_ID_ADPCM_ZORK:
1522 ✗ nb_samples = buf_size / ch;
1523 ✗ break;
1524 124 case AV_CODEC_ID_ADPCM_SANYO:
1525
2/4
✓ Branch 120 → 121 taken 124 times.
✗ Branch 120 → 122 not taken.
✗ Branch 121 → 122 not taken.
✓ Branch 121 → 123 taken 124 times.
124 if (!avctx->extradata || avctx->extradata_size != 2)
1526 ✗ return AVERROR_INVALIDDATA;
1527 124 nb_samples = AV_RL16(avctx->extradata);
1528 124 break;
1529 449 case AV_CODEC_ID_ADPCM_IMA_CITRIX:
1530
1/2
✗ Branch 124 → 125 not taken.
✓ Branch 124 → 126 taken 449 times.
449 if (buf_size < avctx->block_align)
1531 ✗ return 0;
1532 449 nb_samples = (buf_size / avctx->block_align) * (1 + ((avctx->block_align / ch) - 4) * 4);
1533 449 break;
1534 }
1535
1536 /* validate coded sample count */
1537
4/6
✓ Branch 127 → 128 taken 838 times.
✓ Branch 127 → 131 taken 8827 times.
✓ Branch 128 → 129 taken 838 times.
✗ Branch 128 → 130 not taken.
✗ Branch 129 → 130 not taken.
✓ Branch 129 → 131 taken 838 times.
9665 if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
1538 ✗ return AVERROR_INVALIDDATA;
1539
1540 9665 return nb_samples;
1541 }
1542
1543 38297 static int adpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
1544 int *got_frame_ptr, AVPacket *avpkt)
1545 {
1546 38297 const uint8_t *buf = avpkt->data;
1547 38297 int buf_size = avpkt->size;
1548 38297 av_unused ADPCMDecodeContext *c = avctx->priv_data;
1549 38297 int channels = avctx->ch_layout.nb_channels;
1550 av_unused int16_t *samples;
1551 av_unused int16_t **samples_p;
1552 av_unused int st; /* stereo */
1553 int nb_samples, coded_samples, approx_nb_samples, ret;
1554 GetByteContext gb;
1555
1556 38297 bytestream2_init(&gb, buf, buf_size);
1557 38297 nb_samples = get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
1558
1/2
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 7 taken 38297 times.
38297 if (nb_samples <= 0) {
1559 ✗ av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
1560 ✗ return AVERROR_INVALIDDATA;
1561 }
1562
1563 /* get output buffer */
1564 38297 frame->nb_samples = nb_samples;
1565
1/2
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 38297 times.
38297 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
1566 ✗ return ret;
1567 38297 samples = (int16_t *)frame->data[0];
1568 38297 samples_p = (int16_t **)frame->extended_data;
1569
1570 /* use coded_samples when applicable */
1571 /* it is always <= nb_samples, so the output buffer will be large enough */
1572
2/2
✓ Branch 10 → 11 taken 838 times.
✓ Branch 10 → 15 taken 37459 times.
38297 if (coded_samples) {
1573
3/4
✓ Branch 11 → 12 taken 367 times.
✓ Branch 11 → 14 taken 471 times.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 367 times.
838 if (!approx_nb_samples && coded_samples != nb_samples)
1574 ✗ av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
1575 838 frame->nb_samples = nb_samples = coded_samples;
1576 }
1577
1578 38297 st = channels == 2 ? 1 : 0;
1579
1580
35/55
✓ Branch 15 → 16 taken 26342 times.
✓ Branch 15 → 36 taken 1668 times.
✗ Branch 15 → 77 not taken.
✓ Branch 15 → 98 taken 26 times.
✗ Branch 15 → 119 not taken.
✓ Branch 15 → 134 taken 2943 times.
✗ Branch 15 → 184 not taken.
✓ Branch 15 → 207 taken 649 times.
✓ Branch 15 → 222 taken 642 times.
✗ Branch 15 → 253 not taken.
✓ Branch 15 → 272 taken 119 times.
✗ Branch 15 → 290 not taken.
✗ Branch 15 → 311 not taken.
✓ Branch 15 → 322 taken 179 times.
✗ Branch 15 → 329 not taken.
✗ Branch 15 → 332 not taken.
✓ Branch 15 → 335 taken 127 times.
✓ Branch 15 → 342 taken 87 times.
✓ Branch 15 → 352 taken 85 times.
✓ Branch 15 → 362 taken 39 times.
✓ Branch 15 → 372 taken 54 times.
✓ Branch 15 → 379 taken 1000 times.
✓ Branch 15 → 403 taken 311 times.
✗ Branch 15 → 423 not taken.
✓ Branch 15 → 441 taken 37 times.
✗ Branch 15 → 454 not taken.
✓ Branch 15 → 461 taken 47 times.
✓ Branch 15 → 481 taken 49 times.
✓ Branch 15 → 488 taken 158 times.
✓ Branch 15 → 517 taken 33 times.
✓ Branch 15 → 539 taken 400 times.
✓ Branch 15 → 582 taken 600 times.
✗ Branch 15 → 601 not taken.
✓ Branch 15 → 616 taken 162 times.
✗ Branch 15 → 638 not taken.
✓ Branch 15 → 654 taken 350 times.
✓ Branch 15 → 670 taken 128 times.
✓ Branch 15 → 677 taken 57 times.
✓ Branch 15 → 707 taken 195 times.
✓ Branch 15 → 709 taken 136 times.
✗ Branch 15 → 716 not taken.
✓ Branch 15 → 726 taken 12 times.
✓ Branch 15 → 749 taken 71 times.
✓ Branch 15 → 810 taken 32 times.
✗ Branch 15 → 835 not taken.
✗ Branch 15 → 879 not taken.
✗ Branch 15 → 905 not taken.
✓ Branch 15 → 925 taken 124 times.
✓ Branch 15 → 948 taken 40 times.
✓ Branch 15 → 955 taken 946 times.
✗ Branch 15 → 969 not taken.
✗ Branch 15 → 978 not taken.
✗ Branch 15 → 984 not taken.
✓ Branch 15 → 994 taken 449 times.
✗ Branch 15 → 1027 not taken.
38297 switch(avctx->codec->id) {
1581
10/12
✓ Branch 18 → 19 taken 43648 times.
✗ Branch 18 → 23 not taken.
✓ Branch 19 → 20 taken 39464 times.
✓ Branch 19 → 21 taken 4184 times.
✓ Branch 21 → 22 taken 30 times.
✓ Branch 21 → 24 taken 43618 times.
✗ Branch 24 → 25 not taken.
✓ Branch 24 → 27 taken 43648 times.
✓ Branch 32 → 28 taken 1396736 times.
✓ Branch 32 → 33 taken 43648 times.
✓ Branch 34 → 17 taken 43648 times.
✓ Branch 34 → 35 taken 26342 times.
1466726 CASE(ADPCM_IMA_QT,
1582 /* In QuickTime, IMA is encoded by chunks of 34 bytes (=64 samples).
1583 Channel data is interleaved per-chunk. */
1584 for (int channel = 0; channel < channels; channel++) {
1585 ADPCMChannelStatus *cs = &c->status[channel];
1586 int predictor;
1587 int step_index;
1588 /* (pppppp) (piiiiiii) */
1589
1590 /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */
1591 predictor = sign_extend(bytestream2_get_be16u(&gb), 16);
1592 step_index = predictor & 0x7F;
1593 predictor &= ~0x7F;
1594
1595 if (cs->step_index == step_index) {
1596 int diff = predictor - cs->predictor;
1597 if (diff < 0)
1598 diff = - diff;
1599 if (diff > 0x7f)
1600 goto update;
1601 } else {
1602 update:
1603 cs->step_index = step_index;
1604 cs->predictor = predictor;
1605 }
1606
1607 if (cs->step_index > 88u){
1608 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
1609 channel, cs->step_index);
1610 return AVERROR_INVALIDDATA;
1611 }
1612
1613 samples = samples_p[channel];
1614
1615 for (int m = 0; m < 64; m += 2) {
1616 int byte = bytestream2_get_byteu(&gb);
1617 samples[m ] = ff_adpcm_ima_qt_expand_nibble(cs, byte & 0x0F);
1618 samples[m + 1] = ff_adpcm_ima_qt_expand_nibble(cs, byte >> 4 );
1619 }
1620 }
1621 ) /* End of CASE */
1622
10/22
✗ Branch 40 → 41 not taken.
✓ Branch 40 → 43 taken 3336 times.
✓ Branch 44 → 37 taken 3336 times.
✓ Branch 44 → 45 taken 1668 times.
✗ Branch 45 → 46 not taken.
✓ Branch 45 → 64 taken 1668 times.
✗ Branch 50 → 49 not taken.
✗ Branch 50 → 51 not taken.
✗ Branch 52 → 53 not taken.
✗ Branch 52 → 54 not taken.
✗ Branch 57 → 55 not taken.
✗ Branch 57 → 58 not taken.
✗ Branch 59 → 48 not taken.
✗ Branch 59 → 60 not taken.
✗ Branch 61 → 47 not taken.
✗ Branch 61 → 62 not taken.
✓ Branch 71 → 67 taken 1107936 times.
✓ Branch 71 → 72 taken 276984 times.
✓ Branch 73 → 66 taken 276984 times.
✓ Branch 73 → 74 taken 138492 times.
✓ Branch 75 → 65 taken 138492 times.
✓ Branch 75 → 76 taken 1668 times.
1528416 CASE(ADPCM_IMA_WAV,
1623 for (int i = 0; i < channels; i++) {
1624 ADPCMChannelStatus *cs = &c->status[i];
1625 cs->predictor = samples_p[i][0] = sign_extend(bytestream2_get_le16u(&gb), 16);
1626
1627 cs->step_index = bytestream2_get_byteu(&gb);
1628 bytestream2_skipu(&gb, 1);
1629 if (cs->step_index > 88u){
1630 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
1631 i, cs->step_index);
1632 return AVERROR_INVALIDDATA;
1633 }
1634 }
1635
1636 if (avctx->bits_per_coded_sample != 4) {
1637 int samples_per_block = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
1638 int block_size = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];
1639 uint8_t temp[20 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
1640 GetBitContext g;
1641
1642 for (int n = 0; n < (nb_samples - 1) / samples_per_block; n++) {
1643 for (int i = 0; i < channels; i++) {
1644 ADPCMChannelStatus *cs = &c->status[i];
1645 samples = &samples_p[i][1 + n * samples_per_block];
1646 for (int j = 0; j < block_size; j++) {
1647 temp[j] = buf[4 * channels + block_size * n * channels +
1648 (j % 4) + (j / 4) * (channels * 4) + i * 4];
1649 }
1650 ret = init_get_bits8(&g, (const uint8_t *)&temp, block_size);
1651 if (ret < 0)
1652 return ret;
1653 for (int m = 0; m < samples_per_block; m++) {
1654 samples[m] = adpcm_ima_wav_expand_nibble(cs, &g,
1655 avctx->bits_per_coded_sample);
1656 }
1657 }
1658 }
1659 bytestream2_skip(&gb, avctx->block_align - channels * 4);
1660 } else {
1661 for (int n = 0; n < (nb_samples - 1) / 8; n++) {
1662 for (int i = 0; i < channels; i++) {
1663 ADPCMChannelStatus *cs = &c->status[i];
1664 samples = &samples_p[i][1 + n * 8];
1665 for (int m = 0; m < 8; m += 2) {
1666 int v = bytestream2_get_byteu(&gb);
1667 samples[m ] = ff_adpcm_ima_qt_expand_nibble(cs, v & 0x0F);
1668 samples[m + 1] = ff_adpcm_ima_qt_expand_nibble(cs, v >> 4);
1669 }
1670 }
1671 }
1672 }
1673 ) /* End of CASE */
1674
0/10
✗ Branch 80 → 81 not taken.
✗ Branch 80 → 83 not taken.
✗ Branch 84 → 78 not taken.
✗ Branch 84 → 85 not taken.
✗ Branch 92 → 88 not taken.
✗ Branch 92 → 93 not taken.
✗ Branch 94 → 87 not taken.
✗ Branch 94 → 95 not taken.
✗ Branch 96 → 86 not taken.
✗ Branch 96 → 97 not taken.
✗ CASE(ADPCM_IMA_XBOX,
1675 for (int i = 0; i < channels; i++) {
1676 ADPCMChannelStatus *cs = &c->status[i];
1677 cs->predictor = samples_p[i][0] = sign_extend(bytestream2_get_le16u(&gb), 16);
1678
1679 cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
1680 if (cs->step_index > 88u) {
1681 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
1682 i, cs->step_index);
1683 return AVERROR_INVALIDDATA;
1684 }
1685 }
1686
1687 for (int n = 0; n < (nb_samples-1) / 8; n++) {
1688 for (int i = 0; i < channels; i++) {
1689 ADPCMChannelStatus *cs = &c->status[i];
1690 samples = &samples_p[i][1 + n * 8];
1691 for (int m = 0; m < 8; m += 2) {
1692 int v = bytestream2_get_byteu(&gb);
1693 samples[m ] = adpcm_ima_expand_nibble(cs, v & 0x0F, 3);
1694 samples[m + 1] = adpcm_ima_expand_nibble(cs, v >> 4 , 3);
1695 }
1696 }
1697 }
1698 frame->nb_samples--;
1699 ) /* End of CASE */
1700
9/10
✓ Branch 101 → 99 taken 52 times.
✓ Branch 101 → 102 taken 26 times.
✗ Branch 104 → 105 not taken.
✓ Branch 104 → 107 taken 52 times.
✓ Branch 108 → 103 taken 52 times.
✓ Branch 108 → 109 taken 26 times.
✓ Branch 115 → 111 taken 38224 times.
✓ Branch 115 → 116 taken 52 times.
✓ Branch 117 → 110 taken 52 times.
✓ Branch 117 → 118 taken 26 times.
38406 CASE(ADPCM_4XM,
1701 for (int i = 0; i < channels; i++)
1702 c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
1703
1704 for (int i = 0; i < channels; i++) {
1705 c->status[i].step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
1706 if (c->status[i].step_index > 88u) {
1707 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
1708 i, c->status[i].step_index);
1709 return AVERROR_INVALIDDATA;
1710 }
1711 }
1712
1713 for (int i = 0; i < channels; i++) {
1714 ADPCMChannelStatus *cs = &c->status[i];
1715 samples = (int16_t *)frame->data[i];
1716 for (int n = nb_samples >> 1; n > 0; n--) {
1717 int v = bytestream2_get_byteu(&gb);
1718 *samples++ = adpcm_ima_expand_nibble(cs, v & 0x0F, 4);
1719 *samples++ = adpcm_ima_expand_nibble(cs, v >> 4 , 4);
1720 }
1721 }
1722 ) /* End of CASE */
1723
0/6
✗ Branch 122 → 120 not taken.
✗ Branch 122 → 123 not taken.
✗ Branch 126 → 124 not taken.
✗ Branch 126 → 127 not taken.
✗ Branch 132 → 128 not taken.
✗ Branch 132 → 133 not taken.
✗ CASE(ADPCM_AGM,
1724 for (int i = 0; i < channels; i++)
1725 c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
1726 for (int i = 0; i < channels; i++)
1727 c->status[i].step = sign_extend(bytestream2_get_le16u(&gb), 16);
1728
1729 for (int n = 0; n < nb_samples >> (1 - st); n++) {
1730 int v = bytestream2_get_byteu(&gb);
1731 *samples++ = adpcm_agm_expand_nibble(&c->status[0], v & 0xF);
1732 *samples++ = adpcm_agm_expand_nibble(&c->status[st], v >> 4 );
1733 }
1734 ) /* End of CASE */
1735
17/26
✗ Branch 134 → 135 not taken.
✓ Branch 134 → 151 taken 2943 times.
✗ Branch 137 → 138 not taken.
✗ Branch 137 → 140 not taken.
✗ Branch 148 → 144 not taken.
✗ Branch 148 → 149 not taken.
✗ Branch 150 → 136 not taken.
✗ Branch 150 → 183 not taken.
✗ Branch 152 → 153 not taken.
✓ Branch 152 → 155 taken 2943 times.
✓ Branch 155 → 156 taken 2895 times.
✓ Branch 155 → 161 taken 48 times.
✗ Branch 157 → 158 not taken.
✓ Branch 157 → 160 taken 2895 times.
✓ Branch 162 → 163 taken 2895 times.
✓ Branch 162 → 165 taken 48 times.
✓ Branch 166 → 167 taken 2895 times.
✓ Branch 166 → 169 taken 48 times.
✓ Branch 170 → 171 taken 2895 times.
✓ Branch 170 → 173 taken 48 times.
✓ Branch 173 → 174 taken 2895 times.
✓ Branch 173 → 175 taken 48 times.
✓ Branch 175 → 176 taken 2895 times.
✓ Branch 175 → 177 taken 48 times.
✓ Branch 182 → 178 taken 1114974 times.
✓ Branch 182 → 183 taken 2943 times.
1117917 CASE(ADPCM_MS,
1736 int block_predictor;
1737
1738 if (avctx->ch_layout.nb_channels > 2) {
1739 for (int channel = 0; channel < avctx->ch_layout.nb_channels; channel++) {
1740 samples = samples_p[channel];
1741 block_predictor = bytestream2_get_byteu(&gb);
1742 if (block_predictor > 6) {
1743 av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[%d] = %d\n",
1744 channel, block_predictor);
1745 return AVERROR_INVALIDDATA;
1746 }
1747 c->status[channel].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
1748 c->status[channel].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
1749 c->status[channel].idelta = sign_extend(bytestream2_get_le16u(&gb), 16);
1750 c->status[channel].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16);
1751 c->status[channel].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16);
1752 *samples++ = c->status[channel].sample2;
1753 *samples++ = c->status[channel].sample1;
1754 for (int n = (nb_samples - 2) >> 1; n > 0; n--) {
1755 int byte = bytestream2_get_byteu(&gb);
1756 *samples++ = adpcm_ms_expand_nibble(&c->status[channel], byte >> 4 );
1757 *samples++ = adpcm_ms_expand_nibble(&c->status[channel], byte & 0x0F);
1758 }
1759 }
1760 } else {
1761 block_predictor = bytestream2_get_byteu(&gb);
1762 if (block_predictor > 6) {
1763 av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[0] = %d\n",
1764 block_predictor);
1765 return AVERROR_INVALIDDATA;
1766 }
1767 c->status[0].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
1768 c->status[0].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
1769 if (st) {
1770 block_predictor = bytestream2_get_byteu(&gb);
1771 if (block_predictor > 6) {
1772 av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[1] = %d\n",
1773 block_predictor);
1774 return AVERROR_INVALIDDATA;
1775 }
1776 c->status[1].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
1777 c->status[1].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
1778 }
1779 c->status[0].idelta = sign_extend(bytestream2_get_le16u(&gb), 16);
1780 if (st){
1781 c->status[1].idelta = sign_extend(bytestream2_get_le16u(&gb), 16);
1782 }
1783
1784 c->status[0].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16);
1785 if (st) c->status[1].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16);
1786 c->status[0].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16);
1787 if (st) c->status[1].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16);
1788
1789 *samples++ = c->status[0].sample2;
1790 if (st) *samples++ = c->status[1].sample2;
1791 *samples++ = c->status[0].sample1;
1792 if (st) *samples++ = c->status[1].sample1;
1793 for (int n = (nb_samples - 2) >> (1 - st); n > 0; n--) {
1794 int byte = bytestream2_get_byteu(&gb);
1795 *samples++ = adpcm_ms_expand_nibble(&c->status[0 ], byte >> 4 );
1796 *samples++ = adpcm_ms_expand_nibble(&c->status[st], byte & 0x0F);
1797 }
1798 }
1799 ) /* End of CASE */
1800
0/6
✗ Branch 197 → 193 not taken.
✗ Branch 197 → 198 not taken.
✗ Branch 203 → 199 not taken.
✗ Branch 203 → 204 not taken.
✗ Branch 205 → 185 not taken.
✗ Branch 205 → 206 not taken.
✗ CASE(ADPCM_MTAF,
1801 for (int channel = 0; channel < channels; channel += 2) {
1802 bytestream2_skipu(&gb, 4);
1803 c->status[channel ].step = bytestream2_get_le16u(&gb) & 0x1f;
1804 c->status[channel + 1].step = bytestream2_get_le16u(&gb) & 0x1f;
1805 c->status[channel ].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
1806 bytestream2_skipu(&gb, 2);
1807 c->status[channel + 1].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
1808 bytestream2_skipu(&gb, 2);
1809 for (int n = 0; n < nb_samples; n += 2) {
1810 int v = bytestream2_get_byteu(&gb);
1811 samples_p[channel][n ] = adpcm_mtaf_expand_nibble(&c->status[channel], v & 0x0F);
1812 samples_p[channel][n + 1] = adpcm_mtaf_expand_nibble(&c->status[channel], v >> 4 );
1813 }
1814 for (int n = 0; n < nb_samples; n += 2) {
1815 int v = bytestream2_get_byteu(&gb);
1816 samples_p[channel + 1][n ] = adpcm_mtaf_expand_nibble(&c->status[channel + 1], v & 0x0F);
1817 samples_p[channel + 1][n + 1] = adpcm_mtaf_expand_nibble(&c->status[channel + 1], v >> 4 );
1818 }
1819 }
1820 ) /* End of CASE */
1821
5/6
✗ Branch 210 → 211 not taken.
✓ Branch 210 → 213 taken 1298 times.
✓ Branch 214 → 208 taken 1298 times.
✓ Branch 214 → 215 taken 649 times.
✓ Branch 220 → 216 taken 1323960 times.
✓ Branch 220 → 221 taken 649 times.
1325907 CASE(ADPCM_IMA_DK4,
1822 for (int channel = 0; channel < channels; channel++) {
1823 ADPCMChannelStatus *cs = &c->status[channel];
1824 cs->predictor = *samples++ = sign_extend(bytestream2_get_le16u(&gb), 16);
1825 cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
1826 if (cs->step_index > 88u){
1827 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
1828 channel, cs->step_index);
1829 return AVERROR_INVALIDDATA;
1830 }
1831 }
1832 for (int n = (nb_samples - 1) >> (1 - st); n > 0; n--) {
1833 int v = bytestream2_get_byteu(&gb);
1834 *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v >> 4 , 3);
1835 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
1836 }
1837 ) /* End of CASE */
1838
1839 /* DK3 ADPCM support macro */
1840 #define DK3_GET_NEXT_NIBBLE() \
1841 if (decode_top_nibble_next) { \
1842 nibble = last_byte >> 4; \
1843 decode_top_nibble_next = 0; \
1844 } else { \
1845 last_byte = bytestream2_get_byteu(&gb); \
1846 nibble = last_byte & 0x0F; \
1847 decode_top_nibble_next = 1; \
1848 }
1849
11/14
✓ Branch 227 → 228 taken 642 times.
✗ Branch 227 → 229 not taken.
✗ Branch 228 → 229 not taken.
✓ Branch 228 → 231 taken 642 times.
✓ Branch 232 → 233 taken 434634 times.
✓ Branch 232 → 234 taken 434634 times.
✓ Branch 237 → 238 taken 434634 times.
✓ Branch 237 → 239 taken 434634 times.
✓ Branch 242 → 243 taken 434634 times.
✓ Branch 242 → 244 taken 434634 times.
✓ Branch 248 → 232 taken 869268 times.
✓ Branch 248 → 249 taken 642 times.
✓ Branch 250 → 251 taken 642 times.
✗ Branch 250 → 252 not taken.
869910 CASE(ADPCM_IMA_DK3,
1850 int last_byte = 0;
1851 int nibble;
1852 int decode_top_nibble_next = 0;
1853 int diff_channel;
1854 const int16_t *samples_end = samples + channels * nb_samples;
1855
1856 bytestream2_skipu(&gb, 10);
1857 c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
1858 c->status[1].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
1859 c->status[0].step_index = bytestream2_get_byteu(&gb);
1860 c->status[1].step_index = bytestream2_get_byteu(&gb);
1861 if (c->status[0].step_index > 88u || c->status[1].step_index > 88u){
1862 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i/%i\n",
1863 c->status[0].step_index, c->status[1].step_index);
1864 return AVERROR_INVALIDDATA;
1865 }
1866 /* sign extend the predictors */
1867 diff_channel = c->status[1].predictor;
1868
1869 while (samples < samples_end) {
1870
1871 /* for this algorithm, c->status[0] is the sum channel and
1872 * c->status[1] is the diff channel */
1873
1874 /* process the first predictor of the sum channel */
1875 DK3_GET_NEXT_NIBBLE();
1876 adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
1877
1878 /* process the diff channel predictor */
1879 DK3_GET_NEXT_NIBBLE();
1880 adpcm_ima_expand_nibble(&c->status[1], nibble, 3);
1881
1882 /* process the first pair of stereo PCM samples */
1883 diff_channel = (diff_channel + c->status[1].predictor) / 2;
1884 *samples++ = c->status[0].predictor + c->status[1].predictor;
1885 *samples++ = c->status[0].predictor - c->status[1].predictor;
1886
1887 /* process the second predictor of the sum channel */
1888 DK3_GET_NEXT_NIBBLE();
1889 adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
1890
1891 /* process the second pair of stereo PCM samples */
1892 diff_channel = (diff_channel + c->status[1].predictor) / 2;
1893 *samples++ = c->status[0].predictor + c->status[1].predictor;
1894 *samples++ = c->status[0].predictor - c->status[1].predictor;
1895 }
1896
1897 if ((bytestream2_tell(&gb) & 1))
1898 bytestream2_skip(&gb, 1);
1899 ) /* End of CASE */
1900
0/8
✗ Branch 256 → 257 not taken.
✗ Branch 256 → 259 not taken.
✗ Branch 260 → 254 not taken.
✗ Branch 260 → 261 not taken.
✗ Branch 268 → 265 not taken.
✗ Branch 268 → 269 not taken.
✗ Branch 270 → 262 not taken.
✗ Branch 270 → 271 not taken.
✗ CASE(ADPCM_IMA_MAGIX,
1901 for (int channel = 0; channel < channels; channel++) {
1902 ADPCMChannelStatus *cs = &c->status[channel];
1903 cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
1904 cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
1905 if (cs->step_index > 88u){
1906 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
1907 channel, cs->step_index);
1908 return AVERROR_INVALIDDATA;
1909 }
1910 }
1911
1912 for (int m = 0; m < channels*nb_samples/16; m ++) {
1913 uint32_t v0 = bytestream2_get_le32u(&gb);
1914 uint32_t v1 = bytestream2_get_le32u(&gb);
1915
1916 for (int n = 8; n > 0; n--, v0 >>= 4, v1 >>= 4, samples += 2) {
1917 samples[0] = adpcm_ima_expand_nibble(&c->status[0], v0 & 15, 3);
1918 samples[1] = adpcm_ima_expand_nibble(&c->status[1], v1 & 15, 3);
1919 }
1920 }
1921 ) /* End of CASE */
1922
6/8
✗ Branch 275 → 276 not taken.
✓ Branch 275 → 278 taken 119 times.
✓ Branch 279 → 273 taken 119 times.
✓ Branch 279 → 280 taken 119 times.
✗ Branch 282 → 283 not taken.
✓ Branch 282 → 284 taken 60452 times.
✓ Branch 288 → 281 taken 60452 times.
✓ Branch 288 → 289 taken 119 times.
60690 CASE(ADPCM_IMA_ISS,
1923 for (int channel = 0; channel < channels; channel++) {
1924 ADPCMChannelStatus *cs = &c->status[channel];
1925 cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
1926 cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
1927 if (cs->step_index > 88u){
1928 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
1929 channel, cs->step_index);
1930 return AVERROR_INVALIDDATA;
1931 }
1932 }
1933
1934 for (int n = nb_samples >> (1 - st); n > 0; n--) {
1935 int v1, v2;
1936 int v = bytestream2_get_byteu(&gb);
1937 /* nibbles are swapped for mono */
1938 if (st) {
1939 v1 = v >> 4;
1940 v2 = v & 0x0F;
1941 } else {
1942 v2 = v >> 4;
1943 v1 = v & 0x0F;
1944 }
1945 *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v1, 3);
1946 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3);
1947 }
1948 ) /* End of CASE */
1949
0/10
✗ Branch 293 → 294 not taken.
✗ Branch 293 → 296 not taken.
✗ Branch 297 → 291 not taken.
✗ Branch 297 → 298 not taken.
✗ Branch 305 → 301 not taken.
✗ Branch 305 → 306 not taken.
✗ Branch 307 → 300 not taken.
✗ Branch 307 → 308 not taken.
✗ Branch 309 → 299 not taken.
✗ Branch 309 → 310 not taken.
✗ CASE(ADPCM_IMA_MOFLEX,
1950 for (int channel = 0; channel < channels; channel++) {
1951 ADPCMChannelStatus *cs = &c->status[channel];
1952 cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
1953 cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
1954 if (cs->step_index > 88u){
1955 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
1956 channel, cs->step_index);
1957 return AVERROR_INVALIDDATA;
1958 }
1959 }
1960
1961 for (int subframe = 0; subframe < nb_samples / 256; subframe++) {
1962 for (int channel = 0; channel < channels; channel++) {
1963 samples = samples_p[channel] + 256 * subframe;
1964 for (int n = 0; n < 256; n += 2) {
1965 int v = bytestream2_get_byteu(&gb);
1966 *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3);
1967 *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3);
1968 }
1969 }
1970 }
1971 ) /* End of CASE */
1972
0/4
✗ Branch 318 → 314 not taken.
✗ Branch 318 → 319 not taken.
✗ Branch 320 → 312 not taken.
✗ Branch 320 → 321 not taken.
✗ CASE(ADPCM_IMA_DAT4,
1973 for (int channel = 0; channel < channels; channel++) {
1974 ADPCMChannelStatus *cs = &c->status[channel];
1975 samples = samples_p[channel];
1976 bytestream2_skip(&gb, 4);
1977 for (int n = 0; n < nb_samples; n += 2) {
1978 int v = bytestream2_get_byteu(&gb);
1979 *samples++ = adpcm_ima_expand_nibble(cs, v >> 4 , 3);
1980 *samples++ = adpcm_ima_expand_nibble(cs, v & 0x0F, 3);
1981 }
1982 }
1983 ) /* End of CASE */
1984
2/2
✓ Branch 327 → 323 taken 732060 times.
✓ Branch 327 → 328 taken 179 times.
732239 CASE(ADPCM_IMA_APC,
1985 for (int n = nb_samples >> (1 - st); n > 0; n--) {
1986 int v = bytestream2_get_byteu(&gb);
1987 *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4 , 3);
1988 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
1989 }
1990 ) /* End of CASE */
1991 ✗ CASE(ADPCM_IMA_HVQM2,
1992 int format = bytestream2_get_be16(&gb);
1993
1994 bytestream2_skip(&gb, 4);
1995 decode_adpcm_ima_hvqm2(avctx, samples, nb_samples, format, &gb);
1996 ) /* End of CASE */
1997 ✗ CASE(ADPCM_IMA_HVQM4,
1998 int format = bytestream2_get_be16(&gb);
1999
2000 bytestream2_skip(&gb, 4);
2001 decode_adpcm_ima_hvqm4(avctx, samples, nb_samples, format, &gb);
2002 ) /* End of CASE */
2003
2/2
✓ Branch 340 → 336 taken 514600 times.
✓ Branch 340 → 341 taken 127 times.
514727 CASE(ADPCM_IMA_SSI,
2004 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2005 int v = bytestream2_get_byteu(&gb);
2006 *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[0], v >> 4 );
2007 *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[st], v & 0x0F);
2008 }
2009 ) /* End of CASE */
2010
4/4
✓ Branch 348 → 344 taken 347109 times.
✓ Branch 348 → 349 taken 181830 times.
✓ Branch 350 → 343 taken 181830 times.
✓ Branch 350 → 351 taken 87 times.
529026 CASE(ADPCM_IMA_APM,
2011 for (int n = nb_samples / 2; n > 0; n--) {
2012 for (int channel = 0; channel < channels; channel++) {
2013 int v = bytestream2_get_byteu(&gb);
2014 *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[channel], v >> 4 );
2015 samples[st] = ff_adpcm_ima_qt_expand_nibble(&c->status[channel], v & 0x0F);
2016 }
2017 samples += channels;
2018 }
2019 ) /* End of CASE */
2020
4/4
✓ Branch 358 → 354 taken 339672 times.
✓ Branch 358 → 359 taken 172372 times.
✓ Branch 360 → 353 taken 172372 times.
✓ Branch 360 → 361 taken 85 times.
512129 CASE(ADPCM_IMA_ALP,
2021 for (int n = nb_samples / 2; n > 0; n--) {
2022 for (int channel = 0; channel < channels; channel++) {
2023 int v = bytestream2_get_byteu(&gb);
2024 *samples++ = adpcm_ima_alp_expand_nibble(&c->status[channel], v >> 4 , 2);
2025 samples[st] = adpcm_ima_alp_expand_nibble(&c->status[channel], v & 0x0F, 2);
2026 }
2027 samples += channels;
2028 }
2029 ) /* End of CASE */
2030
4/4
✓ Branch 368 → 364 taken 193014 times.
✓ Branch 368 → 369 taken 51 times.
✓ Branch 370 → 363 taken 51 times.
✓ Branch 370 → 371 taken 39 times.
193104 CASE(ADPCM_IMA_CUNNING,
2031 for (int channel = 0; channel < channels; channel++) {
2032 int16_t *smp = samples_p[channel];
2033 for (int n = 0; n < nb_samples / 2; n++) {
2034 int v = bytestream2_get_byteu(&gb);
2035 *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v & 0x0F);
2036 *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v >> 4);
2037 }
2038 }
2039 ) /* End of CASE */
2040
2/2
✓ Branch 377 → 373 taken 27562 times.
✓ Branch 377 → 378 taken 54 times.
27616 CASE(ADPCM_IMA_OKI,
2041 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2042 int v = bytestream2_get_byteu(&gb);
2043 *samples++ = adpcm_ima_oki_expand_nibble(&c->status[0], v >> 4 );
2044 *samples++ = adpcm_ima_oki_expand_nibble(&c->status[st], v & 0x0F);
2045 }
2046 ) /* End of CASE */
2047
10/12
✗ Branch 382 → 383 not taken.
✓ Branch 382 → 385 taken 2000 times.
✓ Branch 386 → 380 taken 2000 times.
✓ Branch 386 → 387 taken 1000 times.
✓ Branch 389 → 390 taken 16000 times.
✗ Branch 389 → 392 not taken.
✓ Branch 395 → 393 taken 32000 times.
✓ Branch 395 → 396 taken 16000 times.
✓ Branch 399 → 397 taken 32000 times.
✓ Branch 399 → 400 taken 16000 times.
✓ Branch 401 → 388 taken 16000 times.
✓ Branch 401 → 402 taken 1000 times.
83000 CASE(ADPCM_IMA_RAD,
2048 for (int channel = 0; channel < channels; channel++) {
2049 ADPCMChannelStatus *cs = &c->status[channel];
2050 cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
2051 cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
2052 if (cs->step_index > 88u){
2053 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
2054 channel, cs->step_index);
2055 return AVERROR_INVALIDDATA;
2056 }
2057 }
2058 for (int n = 0; n < nb_samples / 2; n++) {
2059 int byte[2];
2060
2061 byte[0] = bytestream2_get_byteu(&gb);
2062 if (st)
2063 byte[1] = bytestream2_get_byteu(&gb);
2064 for (int channel = 0; channel < channels; channel++) {
2065 *samples++ = adpcm_ima_expand_nibble(&c->status[channel], byte[channel] & 0x0F, 3);
2066 }
2067 for (int channel = 0; channel < channels; channel++) {
2068 *samples++ = adpcm_ima_expand_nibble(&c->status[channel], byte[channel] >> 4 , 3);
2069 }
2070 }
2071 ) /* End of CASE */
2072
10/10
✓ Branch 403 → 404 taken 12 times.
✓ Branch 403 → 413 taken 299 times.
✓ Branch 410 → 406 taken 8820 times.
✓ Branch 410 → 411 taken 12 times.
✓ Branch 412 → 405 taken 12 times.
✓ Branch 412 → 422 taken 12 times.
✓ Branch 419 → 415 taken 298777 times.
✓ Branch 419 → 420 taken 166477 times.
✓ Branch 421 → 414 taken 166477 times.
✓ Branch 421 → 422 taken 299 times.
474397 CASE(ADPCM_IMA_WS,
2073 if (c->vqa_version == 3) {
2074 for (int channel = 0; channel < channels; channel++) {
2075 int16_t *smp = samples_p[channel];
2076
2077 for (int n = nb_samples / 2; n > 0; n--) {
2078 int v = bytestream2_get_byteu(&gb);
2079 *smp++ = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3);
2080 *smp++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3);
2081 }
2082 }
2083 } else {
2084 for (int n = nb_samples / 2; n > 0; n--) {
2085 for (int channel = 0; channel < channels; channel++) {
2086 int v = bytestream2_get_byteu(&gb);
2087 *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3);
2088 samples[st] = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3);
2089 }
2090 samples += channels;
2091 }
2092 }
2093 bytestream2_seek(&gb, 0, SEEK_END);
2094 ) /* End of CASE */
2095
0/8
✗ Branch 431 → 429 not taken.
✗ Branch 431 → 432 not taken.
✗ Branch 433 → 425 not taken.
✗ Branch 433 → 434 not taken.
✗ Branch 436 → 424 not taken.
✗ Branch 436 → 437 not taken.
✗ Branch 438 → 439 not taken.
✗ Branch 438 → 440 not taken.
✗ CASE(ADPCM_XMD,
2096 int bytes_remaining, block = 0;
2097 while (bytestream2_get_bytes_left(&gb) >= 21 * channels) {
2098 for (int channel = 0; channel < channels; channel++) {
2099 int16_t *out = samples_p[channel] + block * 32;
2100 int16_t history[2];
2101 uint16_t scale;
2102
2103 history[1] = sign_extend(bytestream2_get_le16(&gb), 16);
2104 history[0] = sign_extend(bytestream2_get_le16(&gb), 16);
2105 scale = bytestream2_get_le16(&gb);
2106
2107 out[0] = history[1];
2108 out[1] = history[0];
2109
2110 for (int n = 0; n < 15; n++) {
2111 unsigned byte = bytestream2_get_byte(&gb);
2112 int32_t nibble[2];
2113
2114 nibble[0] = sign_extend(byte & 15, 4);
2115 nibble[1] = sign_extend(byte >> 4, 4);
2116
2117 out[2+n*2] = nibble[0]*scale + ((history[0]*3667 - history[1]*1642) >> 11);
2118 history[1] = history[0];
2119 history[0] = out[2+n*2];
2120
2121 out[2+n*2+1] = nibble[1]*scale + ((history[0]*3667 - history[1]*1642) >> 11);
2122 history[1] = history[0];
2123 history[0] = out[2+n*2+1];
2124 }
2125 }
2126
2127 block++;
2128 }
2129 bytes_remaining = bytestream2_get_bytes_left(&gb);
2130 if (bytes_remaining > 0) {
2131 bytestream2_skip(&gb, bytes_remaining);
2132 }
2133 ) /* End of CASE */
2134
4/6
✗ Branch 444 → 445 not taken.
✓ Branch 444 → 446 taken 666 times.
✓ Branch 449 → 442 taken 666 times.
✓ Branch 449 → 450 taken 37 times.
✗ Branch 451 → 452 not taken.
✓ Branch 451 → 453 taken 37 times.
703 CASE(ADPCM_XA,
2135 int16_t *out0 = samples_p[0];
2136 int16_t *out1 = samples_p[1];
2137 int samples_per_block = 28 * (3 - channels) * 4;
2138 int sample_offset = 0;
2139 int bytes_remaining;
2140 while (bytestream2_get_bytes_left(&gb) >= 128) {
2141 if ((ret = xa_decode(avctx, out0, out1, buf + bytestream2_tell(&gb),
2142 &c->status[0], &c->status[1],
2143 channels, sample_offset)) < 0)
2144 return ret;
2145 bytestream2_skipu(&gb, 128);
2146 sample_offset += samples_per_block;
2147 }
2148 /* Less than a full block of data left, e.g. when reading from
2149 * 2324 byte per sector XA; the remainder is padding */
2150 bytes_remaining = bytestream2_get_bytes_left(&gb);
2151 if (bytes_remaining > 0) {
2152 bytestream2_skip(&gb, bytes_remaining);
2153 }
2154 ) /* End of CASE */
2155
0/2
✗ Branch 459 → 455 not taken.
✗ Branch 459 → 460 not taken.
✗ CASE(ADPCM_IMA_ESCAPE,
2156 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2157 int byte = bytestream2_get_byteu(&gb);
2158 *samples++ = adpcm_ima_escape_expand_nibble(&c->status[0], byte >> 4);
2159 *samples++ = adpcm_ima_escape_expand_nibble(&c->status[st], byte & 0xF);
2160 }
2161 ) /* End of CASE */
2162
8/10
✗ Branch 463 → 464 not taken.
✓ Branch 463 → 466 taken 94 times.
✓ Branch 467 → 462 taken 94 times.
✓ Branch 467 → 468 taken 47 times.
✗ Branch 470 → 471 not taken.
✓ Branch 470 → 472 taken 94 times.
✓ Branch 473 → 469 taken 94 times.
✓ Branch 473 → 474 taken 47 times.
✓ Branch 479 → 475 taken 68996 times.
✓ Branch 479 → 480 taken 47 times.
69231 CASE(ADPCM_IMA_EA_EACS,
2163 for (int i = 0; i <= st; i++) {
2164 c->status[i].step_index = bytestream2_get_le32u(&gb);
2165 if (c->status[i].step_index > 88u) {
2166 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
2167 i, c->status[i].step_index);
2168 return AVERROR_INVALIDDATA;
2169 }
2170 }
2171 for (int i = 0; i <= st; i++) {
2172 c->status[i].predictor = bytestream2_get_le32u(&gb);
2173 if (FFABS((int64_t)c->status[i].predictor) > (1<<16))
2174 return AVERROR_INVALIDDATA;
2175 }
2176
2177 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2178 int byte = bytestream2_get_byteu(&gb);
2179 *samples++ = adpcm_ima_expand_nibble(&c->status[0], byte >> 4, 3);
2180 *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte & 0x0F, 3);
2181 }
2182 ) /* End of CASE */
2183
2/2
✓ Branch 486 → 482 taken 71392 times.
✓ Branch 486 → 487 taken 49 times.
71441 CASE(ADPCM_IMA_EA_SEAD,
2184 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2185 int byte = bytestream2_get_byteu(&gb);
2186 *samples++ = adpcm_ima_expand_nibble(&c->status[0], byte >> 4, 6);
2187 *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte & 0x0F, 6);
2188 }
2189 ) /* End of CASE */
2190
9/16
✗ Branch 488 → 489 not taken.
✓ Branch 488 → 491 taken 158 times.
✗ Branch 489 → 490 not taken.
✗ Branch 489 → 491 not taken.
✓ Branch 497 → 498 taken 8296 times.
✗ Branch 497 → 500 not taken.
✓ Branch 503 → 504 taken 232288 times.
✗ Branch 503 → 505 not taken.
✓ Branch 507 → 508 taken 240584 times.
✗ Branch 507 → 509 not taken.
✓ Branch 510 → 502 taken 232288 times.
✓ Branch 510 → 511 taken 8296 times.
✓ Branch 512 → 496 taken 8296 times.
✓ Branch 512 → 513 taken 158 times.
✓ Branch 513 → 514 taken 158 times.
✗ Branch 513 → 515 not taken.
240742 CASE(ADPCM_EA,
2191 int previous_left_sample, previous_right_sample;
2192 int current_left_sample, current_right_sample;
2193 int next_left_sample, next_right_sample;
2194 int coeff1l, coeff2l, coeff1r, coeff2r;
2195 int shift_left, shift_right;
2196
2197 /* Each EA ADPCM frame has a 12-byte header followed by 30-byte (stereo) or 15-byte (mono) pieces,
2198 each coding 28 stereo/mono samples. */
2199
2200 if (channels != 2 && channels != 1)
2201 return AVERROR_INVALIDDATA;
2202
2203 current_left_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
2204 previous_left_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
2205 current_right_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
2206 previous_right_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
2207
2208 for (int count1 = 0; count1 < nb_samples / 28; count1++) {
2209 int byte = bytestream2_get_byteu(&gb);
2210 coeff1l = ea_adpcm_table[ byte >> 4 ];
2211 coeff2l = ea_adpcm_table[(byte >> 4 ) + 4];
2212 coeff1r = ea_adpcm_table[ byte & 0x0F];
2213 coeff2r = ea_adpcm_table[(byte & 0x0F) + 4];
2214
2215 if (channels == 2){
2216 byte = bytestream2_get_byteu(&gb);
2217 shift_left = 20 - (byte >> 4);
2218 shift_right = 20 - (byte & 0x0F);
2219 } else{
2220 /* Mono packs the shift into the coefficient byte's lower nibble instead */
2221 shift_left = 20 - (byte & 0x0F);
2222 }
2223
2224 for (int count2 = 0; count2 < (channels == 2 ? 28 : 14); count2++) {
2225 byte = bytestream2_get_byteu(&gb);
2226 next_left_sample = sign_extend(byte >> 4, 4) * (1 << shift_left);
2227
2228 next_left_sample = (next_left_sample +
2229 (current_left_sample * coeff1l) +
2230 (previous_left_sample * coeff2l) + 0x80) >> 8;
2231
2232 previous_left_sample = current_left_sample;
2233 current_left_sample = av_clip_int16(next_left_sample);
2234 *samples++ = current_left_sample;
2235
2236 if (channels == 2){
2237 next_right_sample = sign_extend(byte, 4) * (1 << shift_right);
2238
2239 next_right_sample = (next_right_sample +
2240 (current_right_sample * coeff1r) +
2241 (previous_right_sample * coeff2r) + 0x80) >> 8;
2242
2243 previous_right_sample = current_right_sample;
2244 current_right_sample = av_clip_int16(next_right_sample);
2245 *samples++ = current_right_sample;
2246 } else {
2247 next_left_sample = sign_extend(byte, 4) * (1 << shift_left);
2248
2249 next_left_sample = (next_left_sample +
2250 (current_left_sample * coeff1l) +
2251 (previous_left_sample * coeff2l) + 0x80) >> 8;
2252
2253 previous_left_sample = current_left_sample;
2254 current_left_sample = av_clip_int16(next_left_sample);
2255
2256 *samples++ = current_left_sample;
2257 }
2258 }
2259 }
2260 bytestream2_skip(&gb, channels == 2 ? 2 : 3); // Skip terminating NULs
2261 ) /* End of CASE */
2262
11/12
✓ Branch 521 → 520 taken 132 times.
✓ Branch 521 → 522 taken 66 times.
✓ Branch 523 → 518 taken 66 times.
✓ Branch 523 → 524 taken 33 times.
✓ Branch 526 → 527 taken 462 times.
✗ Branch 526 → 529 not taken.
✓ Branch 532 → 531 taken 1848 times.
✓ Branch 532 → 533 taken 924 times.
✓ Branch 534 → 530 taken 924 times.
✓ Branch 534 → 535 taken 462 times.
✓ Branch 536 → 525 taken 462 times.
✓ Branch 536 → 537 taken 33 times.
3465 CASE(ADPCM_EA_MAXIS_XA,
2263 int coeff[2][2], shift[2];
2264
2265 for (int channel = 0; channel < channels; channel++) {
2266 int byte = bytestream2_get_byteu(&gb);
2267 for (int i = 0; i < 2; i++)
2268 coeff[channel][i] = ea_adpcm_table[(byte >> 4) + 4*i];
2269 shift[channel] = 20 - (byte & 0x0F);
2270 }
2271 for (int count1 = 0; count1 < nb_samples / 2; count1++) {
2272 int byte[2];
2273
2274 byte[0] = bytestream2_get_byteu(&gb);
2275 if (st) byte[1] = bytestream2_get_byteu(&gb);
2276 for (int i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */
2277 for (int channel = 0; channel < channels; channel++) {
2278 int sample = sign_extend(byte[channel] >> i, 4) * (1 << shift[channel]);
2279 sample = (sample +
2280 c->status[channel].sample1 * coeff[channel][0] +
2281 c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8;
2282 c->status[channel].sample2 = c->status[channel].sample1;
2283 c->status[channel].sample1 = av_clip_int16(sample);
2284 *samples++ = c->status[channel].sample1;
2285 }
2286 }
2287 }
2288 bytestream2_seek(&gb, 0, SEEK_END);
2289 ) /* End of CASE */
2290 #if CONFIG_ADPCM_EA_R1_DECODER || CONFIG_ADPCM_EA_R2_DECODER || CONFIG_ADPCM_EA_R3_DECODER
2291 400 case AV_CODEC_ID_ADPCM_EA_R1:
2292 case AV_CODEC_ID_ADPCM_EA_R2:
2293 case AV_CODEC_ID_ADPCM_EA_R3: {
2294 /* channel numbering
2295 2chan: 0=fl, 1=fr
2296 4chan: 0=fl, 1=rl, 2=fr, 3=rr
2297 6chan: 0=fl, 1=c, 2=fr, 3=rl, 4=rr, 5=sub */
2298 400 const int big_endian = avctx->codec->id == AV_CODEC_ID_ADPCM_EA_R3;
2299 int previous_sample, current_sample, next_sample;
2300 int coeff1, coeff2;
2301 int shift;
2302 uint16_t *samplesC;
2303 400 int count = 0;
2304 int offsets[6];
2305
2306
2/2
✓ Branch 544 → 540 taken 800 times.
✓ Branch 544 → 545 taken 400 times.
1200 for (unsigned channel = 0; channel < channels; channel++)
2307
2/2
✓ Branch 540 → 541 taken 250 times.
✓ Branch 540 → 542 taken 550 times.
800 offsets[channel] = (big_endian ? bytestream2_get_be32(&gb) :
2308 550 bytestream2_get_le32(&gb)) +
2309 800 (channels + 1) * 4;
2310
2311
2/2
✓ Branch 578 → 546 taken 800 times.
✓ Branch 578 → 579 taken 400 times.
1200 for (unsigned channel = 0; channel < channels; channel++) {
2312 int count1;
2313
2314 800 bytestream2_seek(&gb, offsets[channel], SEEK_SET);
2315 800 samplesC = samples_p[channel];
2316
2317
2/2
✓ Branch 547 → 548 taken 190 times.
✓ Branch 547 → 551 taken 610 times.
800 if (avctx->codec->id == AV_CODEC_ID_ADPCM_EA_R1) {
2318 190 current_sample = sign_extend(bytestream2_get_le16(&gb), 16);
2319 190 previous_sample = sign_extend(bytestream2_get_le16(&gb), 16);
2320 } else {
2321 610 current_sample = c->status[channel].predictor;
2322 610 previous_sample = c->status[channel].prev_sample;
2323 }
2324
2325
2/2
✓ Branch 569 → 553 taken 41192 times.
✓ Branch 569 → 570 taken 800 times.
41992 for (count1 = 0; count1 < nb_samples / 28; count1++) {
2326 41192 int byte = bytestream2_get_byte(&gb);
2327
2/2
✓ Branch 554 → 555 taken 12 times.
✓ Branch 554 → 561 taken 41180 times.
41192 if (byte == 0xEE) { /* only seen in R2 and R3 */
2328 12 current_sample = sign_extend(bytestream2_get_be16(&gb), 16);
2329 12 previous_sample = sign_extend(bytestream2_get_be16(&gb), 16);
2330
2331
2/2
✓ Branch 560 → 558 taken 336 times.
✓ Branch 560 → 568 taken 12 times.
348 for (int count2 = 0; count2 < 28; count2++)
2332 336 *samplesC++ = sign_extend(bytestream2_get_be16(&gb), 16);
2333 } else {
2334 41180 coeff1 = ea_adpcm_table[ byte >> 4 ];
2335 41180 coeff2 = ea_adpcm_table[(byte >> 4) + 4];
2336 41180 shift = 20 - (byte & 0x0F);
2337
2338
2/2
✓ Branch 567 → 562 taken 1153040 times.
✓ Branch 567 → 568 taken 41180 times.
1194220 for (int count2 = 0; count2 < 28; count2++) {
2339
2/2
✓ Branch 562 → 563 taken 576520 times.
✓ Branch 562 → 564 taken 576520 times.
1153040 if (count2 & 1)
2340 576520 next_sample = (unsigned)sign_extend(byte, 4) << shift;
2341 else {
2342 576520 byte = bytestream2_get_byte(&gb);
2343 576520 next_sample = (unsigned)sign_extend(byte >> 4, 4) << shift;
2344 }
2345
2346 1153040 next_sample += (current_sample * coeff1) +
2347 1153040 (previous_sample * coeff2);
2348 1153040 next_sample = av_clip_int16(next_sample >> 8);
2349
2350 1153040 previous_sample = current_sample;
2351 1153040 current_sample = next_sample;
2352 1153040 *samplesC++ = current_sample;
2353 }
2354 }
2355 }
2356
2/2
✓ Branch 570 → 571 taken 400 times.
✓ Branch 570 → 572 taken 400 times.
800 if (!count) {
2357 400 count = count1;
2358
1/2
✗ Branch 572 → 573 not taken.
✓ Branch 572 → 575 taken 400 times.
400 } else if (count != count1) {
2359 ✗ av_log(avctx, AV_LOG_WARNING, "per-channel sample count mismatch\n");
2360 ✗ count = FFMAX(count, count1);
2361 }
2362
2363
2/2
✓ Branch 575 → 576 taken 610 times.
✓ Branch 575 → 577 taken 190 times.
800 if (avctx->codec->id != AV_CODEC_ID_ADPCM_EA_R1) {
2364 610 c->status[channel].predictor = current_sample;
2365 610 c->status[channel].prev_sample = previous_sample;
2366 }
2367 }
2368
2369 400 frame->nb_samples = count * 28;
2370 400 bytestream2_seek(&gb, 0, SEEK_END);
2371 400 break;
2372 }
2373 #endif /* CONFIG_ADPCM_EA_Rx_DECODER */
2374
10/10
✓ Branch 587 → 586 taken 4800 times.
✓ Branch 587 → 588 taken 2400 times.
✓ Branch 590 → 584 taken 2400 times.
✓ Branch 590 → 591 taken 600 times.
✓ Branch 595 → 593 taken 36000 times.
✓ Branch 595 → 596 taken 9000 times.
✓ Branch 597 → 592 taken 9000 times.
✓ Branch 597 → 598 taken 600 times.
✓ Branch 599 → 583 taken 600 times.
✓ Branch 599 → 600 taken 600 times.
53400 CASE(ADPCM_EA_XAS,
2375 for (int channel=0; channel < channels; channel++) {
2376 int coeff[2][4], shift[4];
2377 int16_t *s = samples_p[channel];
2378 for (int n = 0; n < 4; n++, s += 32) {
2379 int val = sign_extend(bytestream2_get_le16u(&gb), 16);
2380 for (int i = 0; i < 2; i++)
2381 coeff[i][n] = ea_adpcm_table[(val&0x0F)+4*i];
2382 s[0] = val & ~0x0F;
2383
2384 val = sign_extend(bytestream2_get_le16u(&gb), 16);
2385 shift[n] = 20 - (val & 0x0F);
2386 s[1] = val & ~0x0F;
2387 }
2388
2389 for (int m = 2; m < 32; m += 2) {
2390 s = &samples_p[channel][m];
2391 for (int n = 0; n < 4; n++, s += 32) {
2392 int level, pred;
2393 int byte = bytestream2_get_byteu(&gb);
2394
2395 level = sign_extend(byte >> 4, 4) * (1 << shift[n]);
2396 pred = s[-1] * coeff[0][n] + s[-2] * coeff[1][n];
2397 s[0] = av_clip_int16((level + pred + 0x80) >> 8);
2398
2399 level = sign_extend(byte, 4) * (1 << shift[n]);
2400 pred = s[0] * coeff[0][n] + s[-1] * coeff[1][n];
2401 s[1] = av_clip_int16((level + pred + 0x80) >> 8);
2402 }
2403 }
2404 }
2405 ) /* End of CASE */
2406
0/6
✗ Branch 604 → 605 not taken.
✗ Branch 604 → 607 not taken.
✗ Branch 608 → 602 not taken.
✗ Branch 608 → 609 not taken.
✗ Branch 614 → 610 not taken.
✗ Branch 614 → 615 not taken.
✗ CASE(ADPCM_IMA_ACORN,
2407 for (int channel = 0; channel < channels; channel++) {
2408 ADPCMChannelStatus *cs = &c->status[channel];
2409 cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
2410 cs->step_index = bytestream2_get_le16u(&gb) & 0xFF;
2411 if (cs->step_index > 88u){
2412 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
2413 channel, cs->step_index);
2414 return AVERROR_INVALIDDATA;
2415 }
2416 }
2417 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2418 int byte = bytestream2_get_byteu(&gb);
2419 *samples++ = adpcm_ima_expand_nibble(&c->status[0], byte & 0x0F, 3);
2420 *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte >> 4, 3);
2421 }
2422 ) /* End of CASE */
2423
7/10
✗ Branch 616 → 617 not taken.
✓ Branch 616 → 619 taken 162 times.
✗ Branch 622 → 623 not taken.
✓ Branch 622 → 625 taken 162 times.
✓ Branch 630 → 626 taken 111618 times.
✓ Branch 630 → 631 taken 162 times.
✓ Branch 631 → 632 taken 22 times.
✓ Branch 631 → 637 taken 140 times.
✗ Branch 634 → 635 not taken.
✓ Branch 634 → 637 taken 22 times.
111780 CASE(ADPCM_IMA_AMV,
2424 av_assert0(channels == 1);
2425
2426 /*
2427 * Header format:
2428 * int16_t predictor;
2429 * uint8_t step_index;
2430 * uint8_t reserved;
2431 * uint32_t frame_size;
2432 *
2433 * Some implementations have step_index as 16-bits, but others
2434 * only use the lower 8 and store garbage in the upper 8.
2435 */
2436 c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
2437 c->status[0].step_index = bytestream2_get_byteu(&gb);
2438 bytestream2_skipu(&gb, 5);
2439 if (c->status[0].step_index > 88u) {
2440 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n",
2441 c->status[0].step_index);
2442 return AVERROR_INVALIDDATA;
2443 }
2444
2445 for (int n = nb_samples >> 1; n > 0; n--) {
2446 int v = bytestream2_get_byteu(&gb);
2447
2448 *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4, 3);
2449 *samples++ = adpcm_ima_expand_nibble(&c->status[0], v & 0xf, 3);
2450 }
2451
2452 if (nb_samples & 1) {
2453 int v = bytestream2_get_byteu(&gb);
2454 *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4, 3);
2455
2456 if (v & 0x0F) {
2457 /* Holds true on all the http://samples.mplayerhq.hu/amv samples. */
2458 av_log(avctx, AV_LOG_WARNING, "Last nibble set on packet with odd sample count.\n");
2459 av_log(avctx, AV_LOG_WARNING, "Sample will be skipped.\n");
2460 }
2461 }
2462 ) /* End of CASE */
2463
0/6
✗ Branch 642 → 643 not taken.
✗ Branch 642 → 645 not taken.
✗ Branch 646 → 639 not taken.
✗ Branch 646 → 647 not taken.
✗ Branch 652 → 648 not taken.
✗ Branch 652 → 653 not taken.
✗ CASE(ADPCM_IMA_PDA,
2464 for (int i = 0; i < channels; i++) {
2465 c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
2466 c->status[i].step_index = bytestream2_get_byteu(&gb);
2467 bytestream2_skipu(&gb, 1);
2468 if (c->status[i].step_index > 88u) {
2469 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n",
2470 c->status[i].step_index);
2471 return AVERROR_INVALIDDATA;
2472 }
2473 }
2474
2475 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2476 int v = bytestream2_get_byteu(&gb);
2477
2478 *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[0 ], v >> 4 );
2479 *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[st], v & 0xf);
2480 }
2481 ) /* End of CASE */
2482
5/6
✗ Branch 658 → 659 not taken.
✓ Branch 658 → 661 taken 350 times.
✓ Branch 662 → 655 taken 350 times.
✓ Branch 662 → 663 taken 350 times.
✓ Branch 668 → 664 taken 89600 times.
✓ Branch 668 → 669 taken 350 times.
90300 CASE(ADPCM_IMA_SMJPEG,
2483 for (int i = 0; i < channels; i++) {
2484 c->status[i].predictor = sign_extend(bytestream2_get_be16u(&gb), 16);
2485 c->status[i].step_index = bytestream2_get_byteu(&gb);
2486 bytestream2_skipu(&gb, 1);
2487 if (c->status[i].step_index > 88u) {
2488 av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n",
2489 c->status[i].step_index);
2490 return AVERROR_INVALIDDATA;
2491 }
2492 }
2493
2494 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2495 int v = bytestream2_get_byteu(&gb);
2496
2497 *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[0 ], v >> 4 );
2498 *samples++ = ff_adpcm_ima_qt_expand_nibble(&c->status[st], v & 0xf);
2499 }
2500 ) /* End of CASE */
2501
2/2
✓ Branch 675 → 671 taken 262096 times.
✓ Branch 675 → 676 taken 128 times.
262224 CASE(ADPCM_CT,
2502 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2503 int v = bytestream2_get_byteu(&gb);
2504 *samples++ = adpcm_ct_expand_nibble(&c->status[0 ], v >> 4 );
2505 *samples++ = adpcm_ct_expand_nibble(&c->status[st], v & 0x0F);
2506 }
2507 ) /* End of CASE */
2508 #if CONFIG_ADPCM_SBPRO_2_DECODER || CONFIG_ADPCM_SBPRO_3_DECODER || \
2509 CONFIG_ADPCM_SBPRO_4_DECODER
2510 57 case AV_CODEC_ID_ADPCM_SBPRO_4:
2511 case AV_CODEC_ID_ADPCM_SBPRO_3:
2512 case AV_CODEC_ID_ADPCM_SBPRO_2:
2513
2/2
✓ Branch 677 → 678 taken 3 times.
✓ Branch 677 → 683 taken 54 times.
57 if (!c->status[0].step_index) {
2514 /* the first byte is a raw sample */
2515 3 *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
2516
1/2
✗ Branch 679 → 680 not taken.
✓ Branch 679 → 682 taken 3 times.
3 if (st)
2517 ✗ *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
2518 3 c->status[0].step_index = 1;
2519 3 nb_samples--;
2520 }
2521
2/2
✓ Branch 683 → 684 taken 26 times.
✓ Branch 683 → 690 taken 31 times.
57 if (avctx->codec->id == AV_CODEC_ID_ADPCM_SBPRO_4) {
2522
2/2
✓ Branch 689 → 685 taken 52230 times.
✓ Branch 689 → 706 taken 26 times.
52256 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2523 52230 int byte = bytestream2_get_byteu(&gb);
2524 104460 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
2525 52230 byte >> 4, 4, 0);
2526 52230 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
2527 byte & 0x0F, 4, 0);
2528 }
2529
2/2
✓ Branch 690 → 691 taken 18 times.
✓ Branch 690 → 698 taken 13 times.
31 } else if (avctx->codec->id == AV_CODEC_ID_ADPCM_SBPRO_3) {
2530
2/2
✓ Branch 697 → 692 taken 34820 times.
✓ Branch 697 → 706 taken 18 times.
34838 for (int n = (nb_samples<<st) / 3; n > 0; n--) {
2531 34820 int byte = bytestream2_get_byteu(&gb);
2532 69640 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
2533 34820 byte >> 5 , 3, 0);
2534 69640 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
2535 34820 (byte >> 2) & 0x07, 3, 0);
2536 34820 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
2537 byte & 0x03, 2, 0);
2538 }
2539 } else {
2540
2/2
✓ Branch 705 → 699 taken 26115 times.
✓ Branch 705 → 706 taken 13 times.
26128 for (int n = nb_samples >> (2 - st); n > 0; n--) {
2541 26115 int byte = bytestream2_get_byteu(&gb);
2542 52230 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
2543 26115 byte >> 6 , 2, 2);
2544 52230 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
2545 26115 (byte >> 4) & 0x03, 2, 2);
2546 52230 *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
2547 26115 (byte >> 2) & 0x03, 2, 2);
2548 26115 *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
2549 byte & 0x03, 2, 2);
2550 }
2551 }
2552 57 break;
2553 #endif /* CONFIG_ADPCM_SBPRO_x_DECODER */
2554 195 CASE(ADPCM_SWF,
2555 adpcm_swf_decode(avctx, buf, buf_size, samples);
2556 bytestream2_seek(&gb, 0, SEEK_END);
2557 ) /* End of CASE */
2558
2/2
✓ Branch 714 → 710 taken 552960 times.
✓ Branch 714 → 715 taken 136 times.
553096 CASE(ADPCM_YAMAHA,
2559 for (int n = nb_samples >> (1 - st); n > 0; n--) {
2560 int v = bytestream2_get_byteu(&gb);
2561 *samples++ = adpcm_yamaha_expand_nibble(&c->status[0 ], v & 0x0F);
2562 *samples++ = adpcm_yamaha_expand_nibble(&c->status[st], v >> 4 );
2563 }
2564 ) /* End of CASE */
2565
0/4
✗ Branch 722 → 718 not taken.
✗ Branch 722 → 723 not taken.
✗ Branch 724 → 717 not taken.
✗ Branch 724 → 725 not taken.
✗ CASE(ADPCM_AICA,
2566 for (int channel = 0; channel < channels; channel++) {
2567 samples = samples_p[channel];
2568 for (int n = nb_samples >> 1; n > 0; n--) {
2569 int v = bytestream2_get_byteu(&gb);
2570 *samples++ = adpcm_yamaha_expand_nibble(&c->status[channel], v & 0x0F);
2571 *samples++ = adpcm_yamaha_expand_nibble(&c->status[channel], v >> 4 );
2572 }
2573 }
2574 ) /* End of CASE */
2575
11/16
✗ Branch 726 → 727 not taken.
✓ Branch 726 → 730 taken 12 times.
✗ Branch 727 → 728 not taken.
✗ Branch 727 → 730 not taken.
✗ Branch 728 → 729 not taken.
✗ Branch 728 → 730 not taken.
✓ Branch 736 → 737 taken 215040 times.
✓ Branch 736 → 738 taken 215040 times.
✓ Branch 741 → 736 taken 430080 times.
✓ Branch 741 → 742 taken 26880 times.
✓ Branch 743 → 734 taken 26880 times.
✓ Branch 743 → 744 taken 24 times.
✓ Branch 745 → 733 taken 24 times.
✓ Branch 745 → 746 taken 12 times.
✓ Branch 747 → 732 taken 12 times.
✓ Branch 747 → 748 taken 12 times.
457008 CASE(ADPCM_AFC,
2576 int samples_per_block;
2577 int blocks;
2578
2579 if (avctx->extradata && avctx->extradata_size == 1 && avctx->extradata[0]) {
2580 samples_per_block = avctx->extradata[0] / 16;
2581 blocks = nb_samples / avctx->extradata[0];
2582 } else {
2583 samples_per_block = nb_samples / 16;
2584 blocks = 1;
2585 }
2586
2587 for (int m = 0; m < blocks; m++) {
2588 for (int channel = 0; channel < channels; channel++) {
2589 int prev1 = c->status[channel].sample1;
2590 int prev2 = c->status[channel].sample2;
2591
2592 samples = samples_p[channel] + m * 16;
2593 /* Read in every sample for this channel. */
2594 for (int i = 0; i < samples_per_block; i++) {
2595 int byte = bytestream2_get_byteu(&gb);
2596 int scale = 1 << (byte >> 4);
2597 int index = byte & 0xf;
2598 int factor1 = afc_coeffs[0][index];
2599 int factor2 = afc_coeffs[1][index];
2600
2601 /* Decode 16 samples. */
2602 for (int n = 0; n < 16; n++) {
2603 int32_t sampledat;
2604
2605 if (n & 1) {
2606 sampledat = sign_extend(byte, 4);
2607 } else {
2608 byte = bytestream2_get_byteu(&gb);
2609 sampledat = sign_extend(byte >> 4, 4);
2610 }
2611
2612 sampledat = ((prev1 * factor1 + prev2 * factor2) >> 11) +
2613 sampledat * scale;
2614 *samples = av_clip_int16(sampledat);
2615 prev2 = prev1;
2616 prev1 = *samples++;
2617 }
2618 }
2619
2620 c->status[channel].sample1 = prev1;
2621 c->status[channel].sample2 = prev2;
2622 }
2623 }
2624 bytestream2_seek(&gb, 0, SEEK_END);
2625 ) /* End of CASE */
2626 #if CONFIG_ADPCM_THP_DECODER || CONFIG_ADPCM_THP_LE_DECODER
2627 71 case AV_CODEC_ID_ADPCM_THP:
2628 case AV_CODEC_ID_ADPCM_THP_LE:
2629 {
2630 int table[14][16];
2631
2632 #define THP_GET16(g) \
2633 sign_extend( \
2634 avctx->codec->id == AV_CODEC_ID_ADPCM_THP_LE ? \
2635 bytestream2_get_le16u(&(g)) : \
2636 bytestream2_get_be16u(&(g)), 16)
2637
2638
1/2
✗ Branch 749 → 750 not taken.
✓ Branch 749 → 766 taken 71 times.
71 if (avctx->extradata) {
2639 GetByteContext tb;
2640
0/2
✗ Branch 750 → 751 not taken.
✗ Branch 750 → 753 not taken.
✗ if (avctx->extradata_size < 32 * channels) {
2641 ✗ av_log(avctx, AV_LOG_ERROR, "Missing coeff table\n");
2642 ✗ return AVERROR_INVALIDDATA;
2643 }
2644
2645 ✗ bytestream2_init(&tb, avctx->extradata, avctx->extradata_size);
2646
0/2
✗ Branch 764 → 755 not taken.
✗ Branch 764 → 765 not taken.
✗ for (int i = 0; i < channels; i++)
2647
0/2
✗ Branch 762 → 756 not taken.
✗ Branch 762 → 763 not taken.
✗ for (int n = 0; n < 16; n++)
2648
0/2
✗ Branch 756 → 757 not taken.
✗ Branch 756 → 759 not taken.
✗ table[i][n] = THP_GET16(tb);
2649 } else {
2650
2/2
✓ Branch 776 → 767 taken 142 times.
✓ Branch 776 → 777 taken 71 times.
213 for (int i = 0; i < channels; i++)
2651
2/2
✓ Branch 774 → 768 taken 2272 times.
✓ Branch 774 → 775 taken 142 times.
2414 for (int n = 0; n < 16; n++)
2652
1/2
✗ Branch 768 → 769 not taken.
✓ Branch 768 → 771 taken 2272 times.
2272 table[i][n] = THP_GET16(gb);
2653
2654
2/2
✓ Branch 777 → 778 taken 1 time.
✓ Branch 777 → 792 taken 70 times.
71 if (!c->has_status) {
2655 /* Initialize the previous sample. */
2656
2/2
✓ Branch 790 → 779 taken 2 times.
✓ Branch 790 → 791 taken 1 time.
3 for (int i = 0; i < channels; i++) {
2657
1/2
✗ Branch 779 → 780 not taken.
✓ Branch 779 → 782 taken 2 times.
2 c->status[i].sample1 = THP_GET16(gb);
2658
1/2
✗ Branch 784 → 785 not taken.
✓ Branch 784 → 787 taken 2 times.
2 c->status[i].sample2 = THP_GET16(gb);
2659 }
2660 1 c->has_status = 1;
2661 } else {
2662 70 bytestream2_skip(&gb, channels * 4);
2663 }
2664 }
2665
2666
2/2
✓ Branch 807 → 794 taken 142 times.
✓ Branch 807 → 808 taken 71 times.
213 for (int ch = 0; ch < channels; ch++) {
2667 142 samples = samples_p[ch];
2668
2669 /* Read in every sample for this channel. */
2670
2/2
✓ Branch 805 → 795 taken 10840 times.
✓ Branch 805 → 806 taken 142 times.
10982 for (int i = 0; i < (nb_samples + 13) / 14; i++) {
2671 10840 int byte = bytestream2_get_byteu(&gb);
2672 10840 int index = (byte >> 4) & 7;
2673 10840 unsigned int exp = byte & 0x0F;
2674 10840 int64_t factor1 = table[ch][index * 2];
2675 10840 int64_t factor2 = table[ch][index * 2 + 1];
2676
2677 /* Decode 14 samples. */
2678
3/4
✓ Branch 802 → 803 taken 151760 times.
✓ Branch 802 → 804 taken 10840 times.
✓ Branch 803 → 797 taken 151760 times.
✗ Branch 803 → 804 not taken.
162600 for (int n = 0; n < 14 && (i * 14 + n < nb_samples); n++) {
2679 int32_t sampledat;
2680
2681
2/2
✓ Branch 797 → 798 taken 75880 times.
✓ Branch 797 → 799 taken 75880 times.
151760 if (n & 1) {
2682 75880 sampledat = sign_extend(byte, 4);
2683 } else {
2684 75880 byte = bytestream2_get_byteu(&gb);
2685 75880 sampledat = sign_extend(byte >> 4, 4);
2686 }
2687
2688 151760 sampledat = ((c->status[ch].sample1 * factor1
2689 151760 + c->status[ch].sample2 * factor2) >> 11) + sampledat * (1 << exp);
2690 151760 *samples = av_clip_int16(sampledat);
2691 151760 c->status[ch].sample2 = c->status[ch].sample1;
2692 151760 c->status[ch].sample1 = *samples++;
2693 }
2694 }
2695 }
2696 71 break;
2697 }
2698 #endif /* CONFIG_ADPCM_THP(_LE)_DECODER */
2699
16/16
✓ Branch 812 → 813 taken 1024 times.
✓ Branch 812 → 814 taken 1024 times.
✓ Branch 817 → 818 taken 3388 times.
✓ Branch 817 → 819 taken 50876 times.
✓ Branch 817 → 820 taken 2744 times.
✓ Branch 817 → 821 taken 336 times.
✓ Branch 823 → 824 taken 28672 times.
✓ Branch 823 → 825 taken 28672 times.
✓ Branch 827 → 817 taken 57344 times.
✓ Branch 827 → 828 taken 2048 times.
✓ Branch 829 → 812 taken 2048 times.
✓ Branch 829 → 830 taken 64 times.
✓ Branch 830 → 831 taken 32 times.
✓ Branch 830 → 832 taken 32 times.
✓ Branch 833 → 811 taken 64 times.
✓ Branch 833 → 834 taken 32 times.
59488 CASE(ADPCM_DTK,
2700 for (int channel = 0; channel < channels; channel++) {
2701 samples = samples_p[channel];
2702
2703 /* Read in every sample for this channel. */
2704 for (int i = 0; i < nb_samples / 28; i++) {
2705 int byte, header;
2706 if (channel)
2707 bytestream2_skipu(&gb, 1);
2708 header = bytestream2_get_byteu(&gb);
2709 bytestream2_skipu(&gb, 3 - channel);
2710
2711 /* Decode 28 samples. */
2712 for (int n = 0; n < 28; n++) {
2713 int32_t sampledat, prev;
2714
2715 switch (header >> 4) {
2716 case 1:
2717 prev = (c->status[channel].sample1 * 0x3c);
2718 break;
2719 case 2:
2720 prev = (c->status[channel].sample1 * 0x73) - (c->status[channel].sample2 * 0x34);
2721 break;
2722 case 3:
2723 prev = (c->status[channel].sample1 * 0x62) - (c->status[channel].sample2 * 0x37);
2724 break;
2725 default:
2726 prev = 0;
2727 }
2728
2729 prev = av_clip_intp2((prev + 0x20) >> 6, 21);
2730
2731 byte = bytestream2_get_byteu(&gb);
2732 if (!channel)
2733 sampledat = sign_extend(byte, 4);
2734 else
2735 sampledat = sign_extend(byte >> 4, 4);
2736
2737 sampledat = ((sampledat * (1 << 12)) >> (header & 0xf)) * (1 << 6) + prev;
2738 *samples++ = av_clip_int16(sampledat >> 6);
2739 c->status[channel].sample2 = c->status[channel].sample1;
2740 c->status[channel].sample1 = sampledat;
2741 }
2742 }
2743 if (!channel)
2744 bytestream2_seek(&gb, 0, SEEK_SET);
2745 }
2746 ) /* End of CASE */
2747
0/30
✗ Branch 835 → 836 not taken.
✗ Branch 835 → 849 not taken.
✗ Branch 840 → 841 not taken.
✗ Branch 840 → 843 not taken.
✗ Branch 841 → 842 not taken.
✗ Branch 841 → 843 not taken.
✗ Branch 842 → 843 not taken.
✗ Branch 842 → 844 not taken.
✗ Branch 847 → 845 not taken.
✗ Branch 847 → 848 not taken.
✗ Branch 851 → 852 not taken.
✗ Branch 851 → 853 not taken.
✗ Branch 853 → 854 not taken.
✗ Branch 853 → 855 not taken.
✗ Branch 856 → 851 not taken.
✗ Branch 856 → 857 not taken.
✗ Branch 861 → 860 not taken.
✗ Branch 861 → 862 not taken.
✗ Branch 865 → 864 not taken.
✗ Branch 865 → 866 not taken.
✗ Branch 867 → 863 not taken.
✗ Branch 867 → 868 not taken.
✗ Branch 869 → 859 not taken.
✗ Branch 869 → 870 not taken.
✗ Branch 872 → 871 not taken.
✗ Branch 872 → 873 not taken.
✗ Branch 874 → 858 not taken.
✗ Branch 874 → 875 not taken.
✗ Branch 876 → 850 not taken.
✗ Branch 876 → 877 not taken.
✗ CASE(ADPCM_N64,
2748 ADPCMChannelStatus *cs = &c->status[0];
2749 int coefs[8*2*8] = { 0 };
2750
2751 if (avctx->extradata) {
2752 int version, order, entries;
2753 GetByteContext cb;
2754
2755 bytestream2_init(&cb, avctx->extradata, avctx->extradata_size);
2756
2757 version = bytestream2_get_be16(&cb);
2758 order = bytestream2_get_be16(&cb);
2759 entries = bytestream2_get_be16(&cb);
2760 if (version != 1 || order != 2 || entries > 8)
2761 return AVERROR_INVALIDDATA;
2762
2763 for (int n = 0; n < order * entries * 8; n++)
2764 coefs[n] = sign_extend(bytestream2_get_be16(&cb), 16);
2765 }
2766
2767 for (int block = 0; block < avpkt->size / 9; block++) {
2768 int scale, index, codes[16];
2769 int16_t hist[8] = { 0 };
2770 const int order = 2;
2771 int16_t out[16];
2772
2773 hist[6] = cs->sample2;
2774 hist[7] = cs->sample1;
2775
2776 samples = samples_p[0] + block * 16;
2777
2778 scale = (buf[0] >> 4) & 0xF;
2779 index = (buf[0] >> 0) & 0xF;
2780 scale = 1 << scale;
2781 index = FFMIN(index, 8);
2782
2783 for (int i = 0, j = 0; i < 16; i += 2, j++) {
2784 int n0 = (buf[j+1] >> 4) & 0xF;
2785 int n1 = (buf[j+1] >> 0) & 0xF;
2786
2787 if (n0 & 8)
2788 n0 = n0 - 16;
2789 if (n1 & 8)
2790 n1 = n1 - 16;
2791
2792 codes[i+0] = n0 * scale;
2793 codes[i+1] = n1 * scale;
2794 }
2795
2796 for (int j = 0; j < 2; j++) {
2797 int *sf_codes = &codes[j*8];
2798 int16_t *sf_out = &out[j*8];
2799
2800 for (int i = 0; i < 8; i++) {
2801 int sample;
2802 unsigned delta = 0;
2803
2804 for (int o = 0; o < order; o++)
2805 delta += coefs[o*8 + i] * hist[(8 - order) + o];
2806
2807 for (int k = i-1; k > -1; k--) {
2808 for (int o = 1; o < order; o++)
2809 delta += sf_codes[(i-1) - k] * (unsigned)coefs[(o*8) + k];
2810 }
2811
2812 sample = sf_codes[i] * 2048;
2813 sample = (int)(sample + delta) / 2048;
2814 sample = av_clip_int16(sample);
2815 sf_out[i] = sample;
2816 }
2817
2818 for (int i = 8 - order; i < 8; i++)
2819 hist[i] = sf_out[i];
2820 }
2821
2822 memcpy(samples, out, sizeof(out));
2823
2824 cs->sample2 = hist[6];
2825 cs->sample1 = hist[7];
2826
2827 buf += 9;
2828 }
2829 bytestream2_seek(&gb, 0, SEEK_END);
2830 ) /* End of CASE */
2831
0/16
✗ Branch 881 → 882 not taken.
✗ Branch 881 → 884 not taken.
✗ Branch 886 → 887 not taken.
✗ Branch 886 → 888 not taken.
✗ Branch 890 → 891 not taken.
✗ Branch 890 → 892 not taken.
✗ Branch 894 → 895 not taken.
✗ Branch 894 → 896 not taken.
✗ Branch 897 → 890 not taken.
✗ Branch 897 → 898 not taken.
✗ Branch 899 → 885 not taken.
✗ Branch 899 → 900 not taken.
✗ Branch 901 → 881 not taken.
✗ Branch 901 → 902 not taken.
✗ Branch 903 → 880 not taken.
✗ Branch 903 → 904 not taken.
✗ CASE(ADPCM_PSX,
2832 for (int block = 0; block < avpkt->size / FFMAX(avctx->block_align, 16 * channels); block++) {
2833 int nb_samples_per_block = 28 * FFMAX(avctx->block_align, 16 * channels) / (16 * channels);
2834 for (int channel = 0; channel < channels; channel++) {
2835 samples = samples_p[channel] + block * nb_samples_per_block;
2836 av_assert0((block + 1) * nb_samples_per_block <= nb_samples);
2837
2838 /* Read in every sample for this channel. */
2839 for (int i = 0; i < nb_samples_per_block / 28; i++) {
2840 int filter, shift, flag, byte;
2841
2842 filter = bytestream2_get_byteu(&gb);
2843 shift = filter & 0xf;
2844 filter = filter >> 4;
2845 if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table))
2846 return AVERROR_INVALIDDATA;
2847 flag = bytestream2_get_byteu(&gb) & 0x7;
2848
2849 /* Decode 28 samples. */
2850 for (int n = 0; n < 28; n++) {
2851 int sample = 0, scale;
2852
2853 if (n & 1) {
2854 scale = sign_extend(byte >> 4, 4);
2855 } else {
2856 byte = bytestream2_get_byteu(&gb);
2857 scale = sign_extend(byte, 4);
2858 }
2859
2860 if (flag < 0x07) {
2861 scale = scale * (1 << 12);
2862 sample = (int)((scale >> shift) + (c->status[channel].sample1 * xa_adpcm_table[filter][0] + c->status[channel].sample2 * xa_adpcm_table[filter][1]) / 64);
2863 }
2864 *samples++ = av_clip_int16(sample);
2865 c->status[channel].sample2 = c->status[channel].sample1;
2866 c->status[channel].sample1 = sample;
2867 }
2868 }
2869 }
2870 }
2871 ) /* End of CASE */
2872
0/12
✗ Branch 907 → 908 not taken.
✗ Branch 907 → 910 not taken.
✗ Branch 911 → 912 not taken.
✗ Branch 911 → 913 not taken.
✗ Branch 914 → 915 not taken.
✗ Branch 914 → 916 not taken.
✗ Branch 919 → 914 not taken.
✗ Branch 919 → 920 not taken.
✗ Branch 921 → 907 not taken.
✗ Branch 921 → 922 not taken.
✗ Branch 923 → 906 not taken.
✗ Branch 923 → 924 not taken.
✗ CASE(ADPCM_PSXC,
2873 for (int block = 0; block < avpkt->size / avctx->block_align; block++) {
2874 int nb_samples_per_block = ((avctx->block_align - 1) / channels) * 2;
2875 for (int channel = 0; channel < channels; channel++) {
2876 int filter, shift, byte;
2877
2878 samples = samples_p[channel] + block * nb_samples_per_block;
2879 av_assert0((block + 1) * nb_samples_per_block <= nb_samples);
2880
2881 filter = bytestream2_get_byteu(&gb);
2882 shift = filter & 0xf;
2883 filter = filter >> 4;
2884 if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table))
2885 return AVERROR_INVALIDDATA;
2886
2887 for (int n = 0; n < nb_samples_per_block; n++) {
2888 int sample = 0, scale;
2889
2890 if (n & 1) {
2891 scale = sign_extend(byte >> 4, 4);
2892 } else {
2893 byte = bytestream2_get_byteu(&gb);
2894 scale = sign_extend(byte & 0xF, 4);
2895 }
2896
2897 scale = scale * (1 << 12);
2898 sample = (int)((scale >> shift) + (c->status[channel].sample1 * xa_adpcm_table[filter][0] + c->status[channel].sample2 * xa_adpcm_table[filter][1]) / 64);
2899 *samples++ = av_clip_int16(sample);
2900 c->status[channel].sample2 = c->status[channel].sample1;
2901 c->status[channel].sample1 = sample;
2902 }
2903 }
2904 }
2905 ) /* End of CASE */
2906
9/10
✓ Branch 925 → 926 taken 31 times.
✓ Branch 925 → 927 taken 41 times.
✓ Branch 925 → 928 taken 52 times.
✗ Branch 925 → 929 not taken.
✓ Branch 933 → 930 taken 124 times.
✓ Branch 933 → 934 taken 124 times.
✓ Branch 941 → 938 taken 62452 times.
✓ Branch 941 → 942 taken 62452 times.
✓ Branch 943 → 937 taken 62452 times.
✓ Branch 943 → 944 taken 124 times.
125152 CASE(ADPCM_SANYO,
2907 int (*expand)(ADPCMChannelStatus *c, int bits);
2908 GetBitContext g;
2909
2910 switch(avctx->bits_per_coded_sample) {
2911 case 3: expand = adpcm_sanyo_expand3; break;
2912 case 4: expand = adpcm_sanyo_expand4; break;
2913 case 5: expand = adpcm_sanyo_expand5; break;
2914 }
2915
2916 for (int ch = 0; ch < channels; ch++) {
2917 c->status[ch].predictor = sign_extend(bytestream2_get_le16(&gb), 16);
2918 c->status[ch].step = sign_extend(bytestream2_get_le16(&gb), 16);
2919 }
2920
2921 init_get_bits8(&g, gb.buffer, bytestream2_get_bytes_left(&gb));
2922 for (int i = 0; i < nb_samples; i++)
2923 for (int ch = 0; ch < channels; ch++)
2924 samples_p[ch][i] = expand(&c->status[ch], get_bits_le(&g, avctx->bits_per_coded_sample));
2925
2926 align_get_bits(&g);
2927 bytestream2_skip(&gb, get_bits_count(&g) / 8);
2928 ) /* End of CASE */
2929
2/2
✓ Branch 953 → 949 taken 10240 times.
✓ Branch 953 → 954 taken 40 times.
10280 CASE(ADPCM_RHETOREX,
2930 for (int i = 0; i < nb_samples / 2; i++) {
2931 uint8_t byte = bytestream2_get_byteu(&gb);
2932 *samples++ = adpcm_rhetorex_expand_nibble(c->status, byte >> 4);
2933 *samples++ = adpcm_rhetorex_expand_nibble(c->status, byte);
2934 }
2935 ) /* End of CASE */
2936
6/6
✓ Branch 963 → 959 taken 747296 times.
✓ Branch 963 → 964 taken 46706 times.
✓ Branch 965 → 957 taken 46706 times.
✓ Branch 965 → 966 taken 30245 times.
✓ Branch 967 → 956 taken 30245 times.
✓ Branch 967 → 968 taken 946 times.
825193 CASE(ADPCM_ARGO,
2937 /*
2938 * The format of each block:
2939 * uint8_t left_control;
2940 * uint4_t left_samples[nb_samples];
2941 * ---- and if stereo ----
2942 * uint8_t right_control;
2943 * uint4_t right_samples[nb_samples];
2944 *
2945 * Format of the control byte:
2946 * MSB [SSSSRDRR] LSB
2947 * S = (Shift Amount - 2)
2948 * D = Decoder flag.
2949 * R = Reserved
2950 *
2951 * Each block relies on the previous two samples of each channel.
2952 * They should be 0 initially.
2953 */
2954 for (int block = 0; block < avpkt->size / avctx->block_align; block++) {
2955 for (int channel = 0; channel < avctx->ch_layout.nb_channels; channel++) {
2956 ADPCMChannelStatus *cs = c->status + channel;
2957 int control, shift;
2958
2959 samples = samples_p[channel] + block * 32;
2960
2961 /* Get the control byte and decode the samples, 2 at a time. */
2962 control = bytestream2_get_byteu(&gb);
2963 shift = (control >> 4) + 2;
2964
2965 for (int n = 0; n < 16; n++) {
2966 int sample = bytestream2_get_byteu(&gb);
2967 *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 4, shift, control & 0x04);
2968 *samples++ = ff_adpcm_argo_expand_nibble(cs, sample >> 0, shift, control & 0x04);
2969 }
2970 }
2971 }
2972 ) /* End of CASE */
2973
0/4
✗ Branch 974 → 971 not taken.
✗ Branch 974 → 975 not taken.
✗ Branch 976 → 970 not taken.
✗ Branch 976 → 977 not taken.
✗ CASE(ADPCM_CIRCUS,
2974 for (int n = 0; n < nb_samples; n++) {
2975 for (int ch = 0; ch < channels; ch++) {
2976 int v = bytestream2_get_byteu(&gb);
2977 *samples++ = adpcm_circus_expand_nibble(&c->status[ch], v);
2978 }
2979 }
2980 ) /* End of CASE */
2981
0/2
✗ Branch 982 → 979 not taken.
✗ Branch 982 → 983 not taken.
✗ CASE(ADPCM_ZORK,
2982 for (int n = 0; n < nb_samples * channels; n++) {
2983 int v = bytestream2_get_byteu(&gb);
2984 *samples++ = adpcm_zork_expand_nibble(&c->status[n % channels], v);
2985 }
2986 ) /* End of CASE */
2987
0/4
✗ Branch 990 → 986 not taken.
✗ Branch 990 → 991 not taken.
✗ Branch 992 → 985 not taken.
✗ Branch 992 → 993 not taken.
✗ CASE(ADPCM_IMA_MTF,
2988 for (int n = nb_samples / 2; n > 0; n--) {
2989 for (int channel = 0; channel < channels; channel++) {
2990 int v = bytestream2_get_byteu(&gb);
2991 *samples++ = adpcm_ima_mtf_expand_nibble(&c->status[channel], v >> 4);
2992 samples[st] = adpcm_ima_mtf_expand_nibble(&c->status[channel], v & 0x0F);
2993 }
2994 samples += channels;
2995 }
2996 ) /* End of CASE */
2997
15/16
✗ Branch 998 → 999 not taken.
✓ Branch 998 → 1000 taken 856 times.
✓ Branch 1002 → 996 taken 856 times.
✓ Branch 1002 → 1003 taken 449 times.
✓ Branch 1003 → 1004 taken 42 times.
✓ Branch 1003 → 1012 taken 407 times.
✓ Branch 1011 → 1005 taken 5208 times.
✓ Branch 1011 → 1023 taken 42 times.
✓ Branch 1018 → 1016 taken 403744 times.
✓ Branch 1018 → 1019 taken 25234 times.
✓ Branch 1020 → 1014 taken 25234 times.
✓ Branch 1020 → 1021 taken 12617 times.
✓ Branch 1022 → 1013 taken 12617 times.
✓ Branch 1022 → 1023 taken 407 times.
✓ Branch 1025 → 995 taken 449 times.
✓ Branch 1025 → 1026 taken 449 times.
448557 CASE(ADPCM_IMA_CITRIX,
2998 while (bytestream2_get_bytes_left(&gb) >= avctx->block_align) {
2999 for (int ch = 0; ch < channels; ch++) {
3000 *samples++ = c->status[ch].predictor = sign_extend(bytestream2_get_le16(&gb), 16);
3001 c->status[ch].step_index = bytestream2_get_byte(&gb);
3002 if (c->status[ch].step_index > 88)
3003 return AVERROR_INVALIDDATA;
3004 bytestream2_skip(&gb, 1);
3005 }
3006 if (channels == 1) {
3007 for (int block = 0; block < avctx->block_align - 4; block++) {
3008 uint8_t bits = bytestream2_get_byteu(&gb);
3009 samples[0] = adpcm_citrix_expand(&c->status[0], bits & 3);
3010 samples[1] = adpcm_citrix_expand(&c->status[0], (bits >> 2) & 3);
3011 samples[2] = adpcm_citrix_expand(&c->status[0], (bits >> 4) & 3);
3012 samples[3] = adpcm_citrix_expand(&c->status[0], (bits >> 6) & 3);
3013 samples += 4;
3014 }
3015 } else { // channels == 2
3016 for (int block = 0; block < (avctx->block_align - 4*channels) / (4*channels); block++) {
3017 for (int ch = 0; ch < channels; ch++) {
3018 uint32_t bits = bytestream2_get_le32(&gb);
3019 for (int j = 0; j < 16; j++)
3020 samples[j*channels + ch] = adpcm_citrix_expand(&c->status[ch], (bits >> (2*j)) & 3);
3021 }
3022 samples += 16*channels;
3023 }
3024 }
3025 }
3026 ) /* End of CASE */
3027 ✗ default:
3028 ✗ av_unreachable("There are cases for all codec ids using adpcm_decode_frame");
3029 }
3030
3031
2/4
✓ Branch 1028 → 1029 taken 38297 times.
✗ Branch 1028 → 1033 not taken.
✗ Branch 1030 → 1031 not taken.
✓ Branch 1030 → 1033 taken 38297 times.
38297 if (avpkt->size && bytestream2_tell(&gb) == 0) {
3032 ✗ av_log(avctx, AV_LOG_ERROR, "Nothing consumed\n");
3033 ✗ return AVERROR_INVALIDDATA;
3034 }
3035
3036 38297 *got_frame_ptr = 1;
3037
3038
1/2
✗ Branch 1034 → 1035 not taken.
✓ Branch 1034 → 1038 taken 38297 times.
38297 if (avpkt->size < bytestream2_tell(&gb)) {
3039 ✗ av_log(avctx, AV_LOG_ERROR, "Overread of %d < %d\n", avpkt->size, bytestream2_tell(&gb));
3040 ✗ return avpkt->size;
3041 }
3042
3043 38297 return bytestream2_tell(&gb);
3044 }
3045
3046 208 static av_cold void adpcm_flush(AVCodecContext *avctx)
3047 {
3048 208 ADPCMDecodeContext *c = avctx->priv_data;
3049
3050 /* Just nuke the entire state and re-init. */
3051 208 memset(c, 0, sizeof(ADPCMDecodeContext));
3052
3053
5/5
✓ Branch 2 → 3 taken 2 times.
✓ Branch 2 → 4 taken 3 times.
✓ Branch 2 → 8 taken 6 times.
✓ Branch 2 → 12 taken 8 times.
✓ Branch 2 → 16 taken 189 times.
208 switch(avctx->codec_id) {
3054 2 case AV_CODEC_ID_ADPCM_CT:
3055 2 c->status[0].step = c->status[1].step = 511;
3056 2 break;
3057
3058 3 case AV_CODEC_ID_ADPCM_IMA_APC:
3059
3/4
✓ Branch 4 → 5 taken 2 times.
✓ Branch 4 → 7 taken 1 time.
✓ Branch 5 → 6 taken 2 times.
✗ Branch 5 → 7 not taken.
3 if (avctx->extradata && avctx->extradata_size >= 8) {
3060 2 c->status[0].predictor = av_clip_intp2(AV_RL32(avctx->extradata ), 18);
3061 2 c->status[1].predictor = av_clip_intp2(AV_RL32(avctx->extradata + 4), 18);
3062 }
3063 3 break;
3064
3065 6 case AV_CODEC_ID_ADPCM_IMA_APM:
3066
2/4
✓ Branch 8 → 9 taken 6 times.
✗ Branch 8 → 11 not taken.
✓ Branch 9 → 10 taken 6 times.
✗ Branch 9 → 11 not taken.
6 if (avctx->extradata && avctx->extradata_size >= 28) {
3067 6 c->status[0].predictor = av_clip_intp2(AV_RL32(avctx->extradata + 16), 18);
3068 6 c->status[0].step_index = av_clip(AV_RL32(avctx->extradata + 20), 0, 88);
3069 6 c->status[1].predictor = av_clip_intp2(AV_RL32(avctx->extradata + 4), 18);
3070 6 c->status[1].step_index = av_clip(AV_RL32(avctx->extradata + 8), 0, 88);
3071 }
3072 6 break;
3073
3074 8 case AV_CODEC_ID_ADPCM_IMA_WS:
3075
3/4
✓ Branch 12 → 13 taken 5 times.
✓ Branch 12 → 15 taken 3 times.
✓ Branch 13 → 14 taken 5 times.
✗ Branch 13 → 15 not taken.
8 if (avctx->extradata && avctx->extradata_size >= 2)
3076 5 c->vqa_version = AV_RL16(avctx->extradata);
3077 8 break;
3078 189 default:
3079 /* Other codecs may want to handle this during decoding. */
3080 189 c->has_status = 0;
3081 189 return;
3082 }
3083
3084 19 c->has_status = 1;
3085 }
3086
3087
3088 #define ADPCM_DECODER_0(id_, name_, long_name_)
3089 #define ADPCM_DECODER_1(id_, name_, long_name_) \
3090 const FFCodec ff_ ## name_ ## _decoder = { \
3091 .p.name = #name_, \
3092 CODEC_LONG_NAME(long_name_), \
3093 .p.type = AVMEDIA_TYPE_AUDIO, \
3094 .p.id = id_, \
3095 .p.capabilities = AV_CODEC_CAP_DR1, \
3096 .priv_data_size = sizeof(ADPCMDecodeContext), \
3097 .init = adpcm_decode_init, \
3098 FF_CODEC_DECODE_CB(adpcm_decode_frame), \
3099 .flush = adpcm_flush, \
3100 };
3101 #define ADPCM_DECODER_2(enabled, codec_id, name, long_name) \
3102 ADPCM_DECODER_ ## enabled(codec_id, name, long_name)
3103 #define ADPCM_DECODER_3(config, codec_id, name, long_name) \
3104 ADPCM_DECODER_2(config, codec_id, name, long_name)
3105 #define ADPCM_DECODER(codec, name, long_name) \
3106 ADPCM_DECODER_3(CONFIG_ ## codec ## _DECODER, AV_CODEC_ID_ ## codec, \
3107 name, long_name)
3108
3109 /* Note: Do not forget to add new entries to the Makefile as well. */
3110 ADPCM_DECODER(ADPCM_4XM, adpcm_4xm, "ADPCM 4X Movie")
3111 ADPCM_DECODER(ADPCM_AFC, adpcm_afc, "ADPCM Nintendo Gamecube AFC")
3112 ADPCM_DECODER(ADPCM_AGM, adpcm_agm, "ADPCM AmuseGraphics Movie")
3113 ADPCM_DECODER(ADPCM_AICA, adpcm_aica, "ADPCM Yamaha AICA")
3114 ADPCM_DECODER(ADPCM_ARGO, adpcm_argo, "ADPCM Argonaut Games")
3115 ADPCM_DECODER(ADPCM_CIRCUS, adpcm_circus, "ADPCM Circus")
3116 ADPCM_DECODER(ADPCM_CT, adpcm_ct, "ADPCM Creative Technology")
3117 ADPCM_DECODER(ADPCM_DTK, adpcm_dtk, "ADPCM Nintendo Gamecube DTK")
3118 ADPCM_DECODER(ADPCM_EA, adpcm_ea, "ADPCM Electronic Arts")
3119 ADPCM_DECODER(ADPCM_EA_MAXIS_XA, adpcm_ea_maxis_xa, "ADPCM Electronic Arts Maxis CDROM XA")
3120 ADPCM_DECODER(ADPCM_EA_R1, adpcm_ea_r1, "ADPCM Electronic Arts R1")
3121 ADPCM_DECODER(ADPCM_EA_R2, adpcm_ea_r2, "ADPCM Electronic Arts R2")
3122 ADPCM_DECODER(ADPCM_EA_R3, adpcm_ea_r3, "ADPCM Electronic Arts R3")
3123 ADPCM_DECODER(ADPCM_EA_XAS, adpcm_ea_xas, "ADPCM Electronic Arts XAS")
3124 ADPCM_DECODER(ADPCM_IMA_ACORN, adpcm_ima_acorn, "ADPCM IMA Acorn Replay")
3125 ADPCM_DECODER(ADPCM_IMA_AMV, adpcm_ima_amv, "ADPCM IMA AMV")
3126 ADPCM_DECODER(ADPCM_IMA_APC, adpcm_ima_apc, "ADPCM IMA CRYO APC")
3127 ADPCM_DECODER(ADPCM_IMA_APM, adpcm_ima_apm, "ADPCM IMA Ubisoft APM")
3128 ADPCM_DECODER(ADPCM_IMA_CITRIX, adpcm_ima_citrix, "ADPCM IMA Citrix")
3129 ADPCM_DECODER(ADPCM_IMA_CUNNING, adpcm_ima_cunning, "ADPCM IMA Cunning Developments")
3130 ADPCM_DECODER(ADPCM_IMA_DAT4, adpcm_ima_dat4, "ADPCM IMA Eurocom DAT4")
3131 ADPCM_DECODER(ADPCM_IMA_DK3, adpcm_ima_dk3, "ADPCM IMA Duck DK3")
3132 ADPCM_DECODER(ADPCM_IMA_DK4, adpcm_ima_dk4, "ADPCM IMA Duck DK4")
3133 ADPCM_DECODER(ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS")
3134 ADPCM_DECODER(ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD")
3135 ADPCM_DECODER(ADPCM_IMA_ESCAPE, adpcm_ima_escape, "ADPCM IMA Acorn Escape")
3136 ADPCM_DECODER(ADPCM_IMA_HVQM2, adpcm_ima_hvqm2, "ADPCM IMA HVQM2")
3137 ADPCM_DECODER(ADPCM_IMA_HVQM4, adpcm_ima_hvqm4, "ADPCM IMA HVQM4")
3138 ADPCM_DECODER(ADPCM_IMA_ISS, adpcm_ima_iss, "ADPCM IMA Funcom ISS")
3139 ADPCM_DECODER(ADPCM_IMA_MAGIX, adpcm_ima_magix, "ADPCM IMA Magix")
3140 ADPCM_DECODER(ADPCM_IMA_MOFLEX, adpcm_ima_moflex, "ADPCM IMA MobiClip MOFLEX")
3141 ADPCM_DECODER(ADPCM_IMA_MTF, adpcm_ima_mtf, "ADPCM IMA Capcom's MT Framework")
3142 ADPCM_DECODER(ADPCM_IMA_OKI, adpcm_ima_oki, "ADPCM IMA Dialogic OKI")
3143 ADPCM_DECODER(ADPCM_IMA_PDA, adpcm_ima_pda, "ADPCM IMA PlayDate")
3144 ADPCM_DECODER(ADPCM_IMA_QT, adpcm_ima_qt, "ADPCM IMA QuickTime")
3145 ADPCM_DECODER(ADPCM_IMA_RAD, adpcm_ima_rad, "ADPCM IMA Radical")
3146 ADPCM_DECODER(ADPCM_IMA_SSI, adpcm_ima_ssi, "ADPCM IMA Simon & Schuster Interactive")
3147 ADPCM_DECODER(ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG")
3148 ADPCM_DECODER(ADPCM_IMA_ALP, adpcm_ima_alp, "ADPCM IMA High Voltage Software ALP")
3149 ADPCM_DECODER(ADPCM_IMA_WAV, adpcm_ima_wav, "ADPCM IMA WAV")
3150 ADPCM_DECODER(ADPCM_IMA_WS, adpcm_ima_ws, "ADPCM IMA Westwood")
3151 ADPCM_DECODER(ADPCM_IMA_XBOX, adpcm_ima_xbox, "ADPCM IMA Xbox")
3152 ADPCM_DECODER(ADPCM_MS, adpcm_ms, "ADPCM Microsoft")
3153 ADPCM_DECODER(ADPCM_MTAF, adpcm_mtaf, "ADPCM MTAF")
3154 ADPCM_DECODER(ADPCM_N64, adpcm_n64, "ADPCM Silicon Graphics N64")
3155 ADPCM_DECODER(ADPCM_PSX, adpcm_psx, "ADPCM Playstation")
3156 ADPCM_DECODER(ADPCM_PSXC, adpcm_psxc, "ADPCM Playstation C")
3157 ADPCM_DECODER(ADPCM_RHETOREX, adpcm_rhetorex, "ADPCM Rhetorex")
3158 ADPCM_DECODER(ADPCM_SANYO, adpcm_sanyo, "ADPCM Sanyo")
3159 ADPCM_DECODER(ADPCM_SBPRO_2, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit")
3160 ADPCM_DECODER(ADPCM_SBPRO_3, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit")
3161 ADPCM_DECODER(ADPCM_SBPRO_4, adpcm_sbpro_4, "ADPCM Sound Blaster Pro 4-bit")
3162 ADPCM_DECODER(ADPCM_SWF, adpcm_swf, "ADPCM Shockwave Flash")
3163 ADPCM_DECODER(ADPCM_THP_LE, adpcm_thp_le, "ADPCM Nintendo THP (little-endian)")
3164 ADPCM_DECODER(ADPCM_THP, adpcm_thp, "ADPCM Nintendo THP")
3165 ADPCM_DECODER(ADPCM_XA, adpcm_xa, "ADPCM CDROM XA")
3166 ADPCM_DECODER(ADPCM_XMD, adpcm_xmd, "ADPCM Konami XMD")
3167 ADPCM_DECODER(ADPCM_YAMAHA, adpcm_yamaha, "ADPCM Yamaha")
3168 ADPCM_DECODER(ADPCM_ZORK, adpcm_zork, "ADPCM Zork")
3169