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