| @@ -271,14 +271,15 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) · 270 unmodified lines |
| 271 | case AV_CODEC_ID_ADPCM_MTAF: | 271 | case AV_CODEC_ID_ADPCM_MTAF: |
| 272 | min_channels = 2; | 272 | min_channels = 2; |
| 273 | max_channels = 8; | 273 | max_channels = 8; |
| 274 | if (avctx->channels & 1) { | 274 | if (avctx->ch_layout.nb_channels & 1) { |
| 275 | avpriv_request_sample(avctx, "channel count %d", avctx->channels); | 275 | avpriv_request_sample(avctx, "channel count %d", avctx->ch_layout.nb_channels); |
| 276 | return AVERROR_PATCHWELCOME; | 276 | return AVERROR_PATCHWELCOME; |
| 277 | } | 277 | } |
| 278 | break; | 278 | break; |
| 279 | case AV_CODEC_ID_ADPCM_PSX: | 279 | case AV_CODEC_ID_ADPCM_PSX: |
| 280 | max_channels = 8; | 280 | max_channels = 8; |
| 281 | if (avctx->channels <= 0 || avctx->block_align % (16 * avctx->channels)) | 281 | if (avctx->ch_layout.nb_channels <= 0 || |
| | 282 | avctx->block_align % (16 * avctx->ch_layout.nb_channels)) |
| 282 | return AVERROR_INVALIDDATA; | 283 | return AVERROR_INVALIDDATA; |
| 283 | break; | 284 | break; |
| 284 | case AV_CODEC_ID_ADPCM_IMA_DAT4: | 285 | case AV_CODEC_ID_ADPCM_IMA_DAT4: |
| @@ -287,7 +288,8 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) · 2 unmodified lines |
| 287 | max_channels = 14; | 288 | max_channels = 14; |
| 288 | break; | 289 | break; |
| 289 | } | 290 | } |
| 290 | if (avctx->channels < min_channels || avctx->channels > max_channels) { | 291 | if (avctx->ch_layout.nb_channels < min_channels || |
| | 292 | avctx->ch_layout.nb_channels > max_channels) { |
| 291 | av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n"); | 293 | av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n"); |
| 292 | return AVERROR(EINVAL); | 294 | return AVERROR(EINVAL); |
| 293 | } | 295 | } |
| @@ -298,7 +300,8 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) · 4 unmodified lines |
| 298 | return AVERROR_INVALIDDATA; | 300 | return AVERROR_INVALIDDATA; |
| 299 | break; | 301 | break; |
| 300 | case AV_CODEC_ID_ADPCM_ARGO: | 302 | case AV_CODEC_ID_ADPCM_ARGO: |
| 301 | if (avctx->bits_per_coded_sample != 4 || avctx->block_align != 17 * avctx->channels) | 303 | if (avctx->bits_per_coded_sample != 4 || |
| | 304 | avctx->block_align != 17 * avctx->ch_layout.nb_channels) |
| 302 | return AVERROR_INVALIDDATA; | 305 | return AVERROR_INVALIDDATA; |
| 303 | break; | 306 | break; |
| 304 | case AV_CODEC_ID_ADPCM_ZORK: | 307 | case AV_CODEC_ID_ADPCM_ZORK: |
| @@ -336,7 +339,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) · 31 unmodified lines |
| 336 | AV_SAMPLE_FMT_S16; | 339 | AV_SAMPLE_FMT_S16; |
| 337 | break; | 340 | break; |
| 338 | case AV_CODEC_ID_ADPCM_MS: | 341 | case AV_CODEC_ID_ADPCM_MS: |
| 339 | avctx->sample_fmt = avctx->channels > 2 ? AV_SAMPLE_FMT_S16P : | 342 | avctx->sample_fmt = avctx->ch_layout.nb_channels > 2 ? AV_SAMPLE_FMT_S16P : |
| 340 | AV_SAMPLE_FMT_S16; | 343 | AV_SAMPLE_FMT_S16; |
| 341 | break; | 344 | break; |
| 342 | default: | 345 | default: |
| @@ -755,6 +758,7 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_ · 412 unmodified lines |
| 755 | ADPCMDecodeContext *c = avctx->priv_data; | 758 | ADPCMDecodeContext *c = avctx->priv_data; |
| 756 | GetBitContext gb; | 759 | GetBitContext gb; |
| 757 | const int8_t *table; | 760 | const int8_t *table; |
| | 761 | int channels = avctx->ch_layout.nb_channels; |
| 758 | int k0, signmask, nb_bits, count; | 762 | int k0, signmask, nb_bits, count; |
| 759 | int size = buf_size*8; | 763 | int size = buf_size*8; |
| 760 | int i; | 764 | int i; |
| @@ -767,16 +771,16 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_ · 6 unmodified lines |
| 767 | k0 = 1 << (nb_bits-2); | 771 | k0 = 1 << (nb_bits-2); |
| 768 | signmask = 1 << (nb_bits-1); | 772 | signmask = 1 << (nb_bits-1); |
| 769 | | 773 | |
| 770 | while (get_bits_count(&gb) <= size - 22*avctx->channels) { | 774 | while (get_bits_count(&gb) <= size - 22 * channels) { |
| 771 | for (i = 0; i < avctx->channels; i++) { | 775 | for (i = 0; i < channels; i++) { |
| 772 | *samples++ = c->status[i].predictor = get_sbits(&gb, 16); | 776 | *samples++ = c->status[i].predictor = get_sbits(&gb, 16); |
| 773 | c->status[i].step_index = get_bits(&gb, 6); | 777 | c->status[i].step_index = get_bits(&gb, 6); |
| 774 | } | 778 | } |
| 775 | | 779 | |
| 776 | for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) { | 780 | for (count = 0; get_bits_count(&gb) <= size - nb_bits * channels && count < 4095; count++) { |
| 777 | int i; | 781 | int i; |
| 778 | | 782 | |
| 779 | for (i = 0; i < avctx->channels; i++) { | 783 | for (i = 0; i < channels; i++) { |
| 780 | // similar to IMA adpcm | 784 | // similar to IMA adpcm |
| 781 | int delta = get_bits(&gb, nb_bits); | 785 | int delta = get_bits(&gb, nb_bits); |
| 782 | int step = ff_adpcm_step_table[c->status[i].step_index]; | 786 | int step = ff_adpcm_step_table[c->status[i].step_index]; |
| @@ -840,7 +844,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, · 57 unmodified lines |
| 840 | { | 844 | { |
| 841 | ADPCMDecodeContext *s = avctx->priv_data; | 845 | ADPCMDecodeContext *s = avctx->priv_data; |
| 842 | int nb_samples = 0; | 846 | int nb_samples = 0; |
| 843 | int ch = avctx->channels; | 847 | int ch = avctx->ch_layout.nb_channels; |
| 844 | int has_coded_samples = 0; | 848 | int has_coded_samples = 0; |
| 845 | int header_size; | 849 | int header_size; |
| 846 | | 850 | |
| @@ -1061,6 +1065,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 214 unmodified lines |
| 1061 | const uint8_t *buf = avpkt->data; | 1065 | const uint8_t *buf = avpkt->data; |
| 1062 | int buf_size = avpkt->size; | 1066 | int buf_size = avpkt->size; |
| 1063 | ADPCMDecodeContext *c = avctx->priv_data; | 1067 | ADPCMDecodeContext *c = avctx->priv_data; |
| | 1068 | int channels = avctx->ch_layout.nb_channels; |
| 1064 | int16_t *samples; | 1069 | int16_t *samples; |
| 1065 | int16_t **samples_p; | 1070 | int16_t **samples_p; |
| 1066 | int st; /* stereo */ | 1071 | int st; /* stereo */ |
| @@ -1089,13 +1094,13 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 22 unmodified lines |
| 1089 | frame->nb_samples = nb_samples = coded_samples; | 1094 | frame->nb_samples = nb_samples = coded_samples; |
| 1090 | } | 1095 | } |
| 1091 | | 1096 | |
| 1092 | st = avctx->channels == 2 ? 1 : 0; | 1097 | st = channels == 2 ? 1 : 0; |
| 1093 | | 1098 | |
| 1094 | switch(avctx->codec->id) { | 1099 | switch(avctx->codec->id) { |
| 1095 | CASE(ADPCM_IMA_QT, | 1100 | CASE(ADPCM_IMA_QT, |
| 1096 | /* In QuickTime, IMA is encoded by chunks of 34 bytes (=64 samples). | 1101 | /* In QuickTime, IMA is encoded by chunks of 34 bytes (=64 samples). |
| 1097 | Channel data is interleaved per-chunk. */ | 1102 | Channel data is interleaved per-chunk. */ |
| 1098 | for (int channel = 0; channel < avctx->channels; channel++) { | 1103 | for (int channel = 0; channel < channels; channel++) { |
| 1099 | ADPCMChannelStatus *cs = &c->status[channel]; | 1104 | ADPCMChannelStatus *cs = &c->status[channel]; |
| 1100 | int predictor; | 1105 | int predictor; |
| 1101 | int step_index; | 1106 | int step_index; |
| @@ -1134,7 +1139,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 32 unmodified lines |
| 1134 | } | 1139 | } |
| 1135 | ) /* End of CASE */ | 1140 | ) /* End of CASE */ |
| 1136 | CASE(ADPCM_IMA_WAV, | 1141 | CASE(ADPCM_IMA_WAV, |
| 1137 | for (int i = 0; i < avctx->channels; i++) { | 1142 | for (int i = 0; i < channels; i++) { |
| 1138 | ADPCMChannelStatus *cs = &c->status[i]; | 1143 | ADPCMChannelStatus *cs = &c->status[i]; |
| 1139 | cs->predictor = samples_p[i][0] = sign_extend(bytestream2_get_le16u(&gb), 16); | 1144 | cs->predictor = samples_p[i][0] = sign_extend(bytestream2_get_le16u(&gb), 16); |
| 1140 | | 1145 | |
| @@ -1153,12 +1158,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 12 unmodified lines |
| 1153 | GetBitContext g; | 1158 | GetBitContext g; |
| 1154 | | 1159 | |
| 1155 | for (int n = 0; n < (nb_samples - 1) / samples_per_block; n++) { | 1160 | for (int n = 0; n < (nb_samples - 1) / samples_per_block; n++) { |
| 1156 | for (int i = 0; i < avctx->channels; i++) { | 1161 | for (int i = 0; i < channels; i++) { |
| 1157 | ADPCMChannelStatus *cs = &c->status[i]; | 1162 | ADPCMChannelStatus *cs = &c->status[i]; |
| 1158 | samples = &samples_p[i][1 + n * samples_per_block]; | 1163 | samples = &samples_p[i][1 + n * samples_per_block]; |
| 1159 | for (int j = 0; j < block_size; j++) { | 1164 | for (int j = 0; j < block_size; j++) { |
| 1160 | temp[j] = buf[4 * avctx->channels + block_size * n * avctx->channels + | 1165 | temp[j] = buf[4 * channels + block_size * n * channels + |
| 1161 | (j % 4) + (j / 4) * (avctx->channels * 4) + i * 4]; | 1166 | (j % 4) + (j / 4) * (channels * 4) + i * 4]; |
| 1162 | } | 1167 | } |
| 1163 | ret = init_get_bits8(&g, (const uint8_t *)&temp, block_size); | 1168 | ret = init_get_bits8(&g, (const uint8_t *)&temp, block_size); |
| 1164 | if (ret < 0) | 1169 | if (ret < 0) |
| @@ -1169,10 +1174,10 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines |
| 1169 | } | 1174 | } |
| 1170 | } | 1175 | } |
| 1171 | } | 1176 | } |
| 1172 | bytestream2_skip(&gb, avctx->block_align - avctx->channels * 4); | 1177 | bytestream2_skip(&gb, avctx->block_align - channels * 4); |
| 1173 | } else { | 1178 | } else { |
| 1174 | for (int n = 0; n < (nb_samples - 1) / 8; n++) { | 1179 | for (int n = 0; n < (nb_samples - 1) / 8; n++) { |
| 1175 | for (int i = 0; i < avctx->channels; i++) { | 1180 | for (int i = 0; i < channels; i++) { |
| 1176 | ADPCMChannelStatus *cs = &c->status[i]; | 1181 | ADPCMChannelStatus *cs = &c->status[i]; |
| 1177 | samples = &samples_p[i][1 + n * 8]; | 1182 | samples = &samples_p[i][1 + n * 8]; |
| 1178 | for (int m = 0; m < 8; m += 2) { | 1183 | for (int m = 0; m < 8; m += 2) { |
| @@ -1185,10 +1190,10 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 6 unmodified lines |
| 1185 | } | 1190 | } |
| 1186 | ) /* End of CASE */ | 1191 | ) /* End of CASE */ |
| 1187 | CASE(ADPCM_4XM, | 1192 | CASE(ADPCM_4XM, |
| 1188 | for (int i = 0; i < avctx->channels; i++) | 1193 | for (int i = 0; i < channels; i++) |
| 1189 | c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); | 1194 | c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); |
| 1190 | | 1195 | |
| 1191 | for (int i = 0; i < avctx->channels; i++) { | 1196 | for (int i = 0; i < channels; i++) { |
| 1192 | c->status[i].step_index = sign_extend(bytestream2_get_le16u(&gb), 16); | 1197 | c->status[i].step_index = sign_extend(bytestream2_get_le16u(&gb), 16); |
| 1193 | if (c->status[i].step_index > 88u) { | 1198 | if (c->status[i].step_index > 88u) { |
| 1194 | av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n", | 1199 | av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n", |
| @@ -1197,7 +1202,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 2 unmodified lines |
| 1197 | } | 1202 | } |
| 1198 | } | 1203 | } |
| 1199 | | 1204 | |
| 1200 | for (int i = 0; i < avctx->channels; i++) { | 1205 | for (int i = 0; i < channels; i++) { |
| 1201 | ADPCMChannelStatus *cs = &c->status[i]; | 1206 | ADPCMChannelStatus *cs = &c->status[i]; |
| 1202 | samples = (int16_t *)frame->data[i]; | 1207 | samples = (int16_t *)frame->data[i]; |
| 1203 | for (int n = nb_samples >> 1; n > 0; n--) { | 1208 | for (int n = nb_samples >> 1; n > 0; n--) { |
| @@ -1208,9 +1213,9 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines |
| 1208 | } | 1213 | } |
| 1209 | ) /* End of CASE */ | 1214 | ) /* End of CASE */ |
| 1210 | CASE(ADPCM_AGM, | 1215 | CASE(ADPCM_AGM, |
| 1211 | for (int i = 0; i < avctx->channels; i++) | 1216 | for (int i = 0; i < channels; i++) |
| 1212 | c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); | 1217 | c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); |
| 1213 | for (int i = 0; i < avctx->channels; i++) | 1218 | for (int i = 0; i < channels; i++) |
| 1214 | c->status[i].step = sign_extend(bytestream2_get_le16u(&gb), 16); | 1219 | c->status[i].step = sign_extend(bytestream2_get_le16u(&gb), 16); |
| 1215 | | 1220 | |
| 1216 | for (int n = 0; n < nb_samples >> (1 - st); n++) { | 1221 | for (int n = 0; n < nb_samples >> (1 - st); n++) { |
| @@ -1222,8 +1227,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 5 unmodified lines |
| 1222 | CASE(ADPCM_MS, | 1227 | CASE(ADPCM_MS, |
| 1223 | int block_predictor; | 1228 | int block_predictor; |
| 1224 | | 1229 | |
| 1225 | if (avctx->channels > 2) { | 1230 | if (avctx->ch_layout.nb_channels > 2) { |
| 1226 | for (int channel = 0; channel < avctx->channels; channel++) { | 1231 | for (int channel = 0; channel < avctx->ch_layout.nb_channels; channel++) { |
| 1227 | samples = samples_p[channel]; | 1232 | samples = samples_p[channel]; |
| 1228 | block_predictor = bytestream2_get_byteu(&gb); | 1233 | block_predictor = bytestream2_get_byteu(&gb); |
| 1229 | if (block_predictor > 6) { | 1234 | if (block_predictor > 6) { |
| @@ -1285,7 +1290,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 55 unmodified lines |
| 1285 | } | 1290 | } |
| 1286 | ) /* End of CASE */ | 1291 | ) /* End of CASE */ |
| 1287 | CASE(ADPCM_MTAF, | 1292 | CASE(ADPCM_MTAF, |
| 1288 | for (int channel = 0; channel < avctx->channels; channel += 2) { | 1293 | for (int channel = 0; channel < channels; channel += 2) { |
| 1289 | bytestream2_skipu(&gb, 4); | 1294 | bytestream2_skipu(&gb, 4); |
| 1290 | c->status[channel ].step = bytestream2_get_le16u(&gb) & 0x1f; | 1295 | c->status[channel ].step = bytestream2_get_le16u(&gb) & 0x1f; |
| 1291 | c->status[channel + 1].step = bytestream2_get_le16u(&gb) & 0x1f; | 1296 | c->status[channel + 1].step = bytestream2_get_le16u(&gb) & 0x1f; |
| @@ -1306,7 +1311,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 14 unmodified lines |
| 1306 | } | 1311 | } |
| 1307 | ) /* End of CASE */ | 1312 | ) /* End of CASE */ |
| 1308 | CASE(ADPCM_IMA_DK4, | 1313 | CASE(ADPCM_IMA_DK4, |
| 1309 | for (int channel = 0; channel < avctx->channels; channel++) { | 1314 | for (int channel = 0; channel < channels; channel++) { |
| 1310 | ADPCMChannelStatus *cs = &c->status[channel]; | 1315 | ADPCMChannelStatus *cs = &c->status[channel]; |
| 1311 | cs->predictor = *samples++ = sign_extend(bytestream2_get_le16u(&gb), 16); | 1316 | cs->predictor = *samples++ = sign_extend(bytestream2_get_le16u(&gb), 16); |
| 1312 | cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); | 1317 | cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); |
| @@ -1338,7 +1343,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 25 unmodified lines |
| 1338 | int nibble; | 1343 | int nibble; |
| 1339 | int decode_top_nibble_next = 0; | 1344 | int decode_top_nibble_next = 0; |
| 1340 | int diff_channel; | 1345 | int diff_channel; |
| 1341 | const int16_t *samples_end = samples + avctx->channels * nb_samples; | 1346 | const int16_t *samples_end = samples + channels * nb_samples; |
| 1342 | | 1347 | |
| 1343 | bytestream2_skipu(&gb, 10); | 1348 | bytestream2_skipu(&gb, 10); |
| 1344 | c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); | 1349 | c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16); |
| @@ -1385,7 +1390,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 40 unmodified lines |
| 1385 | bytestream2_skip(&gb, 1); | 1390 | bytestream2_skip(&gb, 1); |
| 1386 | ) /* End of CASE */ | 1391 | ) /* End of CASE */ |
| 1387 | CASE(ADPCM_IMA_ISS, | 1392 | CASE(ADPCM_IMA_ISS, |
| 1388 | for (int channel = 0; channel < avctx->channels; channel++) { | 1393 | for (int channel = 0; channel < channels; channel++) { |
| 1389 | ADPCMChannelStatus *cs = &c->status[channel]; | 1394 | ADPCMChannelStatus *cs = &c->status[channel]; |
| 1390 | cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); | 1395 | cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); |
| 1391 | cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); | 1396 | cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); |
| @@ -1412,7 +1417,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 20 unmodified lines |
| 1412 | } | 1417 | } |
| 1413 | ) /* End of CASE */ | 1418 | ) /* End of CASE */ |
| 1414 | CASE(ADPCM_IMA_MOFLEX, | 1419 | CASE(ADPCM_IMA_MOFLEX, |
| 1415 | for (int channel = 0; channel < avctx->channels; channel++) { | 1420 | for (int channel = 0; channel < channels; channel++) { |
| 1416 | ADPCMChannelStatus *cs = &c->status[channel]; | 1421 | ADPCMChannelStatus *cs = &c->status[channel]; |
| 1417 | cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); | 1422 | cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); |
| 1418 | cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); | 1423 | cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); |
| @@ -1424,7 +1429,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 5 unmodified lines |
| 1424 | } | 1429 | } |
| 1425 | | 1430 | |
| 1426 | for (int subframe = 0; subframe < nb_samples / 256; subframe++) { | 1431 | for (int subframe = 0; subframe < nb_samples / 256; subframe++) { |
| 1427 | for (int channel = 0; channel < avctx->channels; channel++) { | 1432 | for (int channel = 0; channel < channels; channel++) { |
| 1428 | samples = samples_p[channel] + 256 * subframe; | 1433 | samples = samples_p[channel] + 256 * subframe; |
| 1429 | for (int n = 0; n < 256; n += 2) { | 1434 | for (int n = 0; n < 256; n += 2) { |
| 1430 | int v = bytestream2_get_byteu(&gb); | 1435 | int v = bytestream2_get_byteu(&gb); |
| @@ -1435,7 +1440,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines |
| 1435 | } | 1440 | } |
| 1436 | ) /* End of CASE */ | 1441 | ) /* End of CASE */ |
| 1437 | CASE(ADPCM_IMA_DAT4, | 1442 | CASE(ADPCM_IMA_DAT4, |
| 1438 | for (int channel = 0; channel < avctx->channels; channel++) { | 1443 | for (int channel = 0; channel < channels; channel++) { |
| 1439 | ADPCMChannelStatus *cs = &c->status[channel]; | 1444 | ADPCMChannelStatus *cs = &c->status[channel]; |
| 1440 | samples = samples_p[channel]; | 1445 | samples = samples_p[channel]; |
| 1441 | bytestream2_skip(&gb, 4); | 1446 | bytestream2_skip(&gb, 4); |
| @@ -1462,26 +1467,26 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 20 unmodified lines |
| 1462 | ) /* End of CASE */ | 1467 | ) /* End of CASE */ |
| 1463 | CASE(ADPCM_IMA_APM, | 1468 | CASE(ADPCM_IMA_APM, |
| 1464 | for (int n = nb_samples / 2; n > 0; n--) { | 1469 | for (int n = nb_samples / 2; n > 0; n--) { |
| 1465 | for (int channel = 0; channel < avctx->channels; channel++) { | 1470 | for (int channel = 0; channel < channels; channel++) { |
| 1466 | int v = bytestream2_get_byteu(&gb); | 1471 | int v = bytestream2_get_byteu(&gb); |
| 1467 | *samples++ = adpcm_ima_qt_expand_nibble(&c->status[channel], v >> 4 ); | 1472 | *samples++ = adpcm_ima_qt_expand_nibble(&c->status[channel], v >> 4 ); |
| 1468 | samples[st] = adpcm_ima_qt_expand_nibble(&c->status[channel], v & 0x0F); | 1473 | samples[st] = adpcm_ima_qt_expand_nibble(&c->status[channel], v & 0x0F); |
| 1469 | } | 1474 | } |
| 1470 | samples += avctx->channels; | 1475 | samples += channels; |
| 1471 | } | 1476 | } |
| 1472 | ) /* End of CASE */ | 1477 | ) /* End of CASE */ |
| 1473 | CASE(ADPCM_IMA_ALP, | 1478 | CASE(ADPCM_IMA_ALP, |
| 1474 | for (int n = nb_samples / 2; n > 0; n--) { | 1479 | for (int n = nb_samples / 2; n > 0; n--) { |
| 1475 | for (int channel = 0; channel < avctx->channels; channel++) { | 1480 | for (int channel = 0; channel < channels; channel++) { |
| 1476 | int v = bytestream2_get_byteu(&gb); | 1481 | int v = bytestream2_get_byteu(&gb); |
| 1477 | *samples++ = adpcm_ima_alp_expand_nibble(&c->status[channel], v >> 4 , 2); | 1482 | *samples++ = adpcm_ima_alp_expand_nibble(&c->status[channel], v >> 4 , 2); |
| 1478 | samples[st] = adpcm_ima_alp_expand_nibble(&c->status[channel], v & 0x0F, 2); | 1483 | samples[st] = adpcm_ima_alp_expand_nibble(&c->status[channel], v & 0x0F, 2); |
| 1479 | } | 1484 | } |
| 1480 | samples += avctx->channels; | 1485 | samples += channels; |
| 1481 | } | 1486 | } |
| 1482 | ) /* End of CASE */ | 1487 | ) /* End of CASE */ |
| 1483 | CASE(ADPCM_IMA_CUNNING, | 1488 | CASE(ADPCM_IMA_CUNNING, |
| 1484 | for (int channel = 0; channel < avctx->channels; channel++) { | 1489 | for (int channel = 0; channel < channels; channel++) { |
| 1485 | int16_t *smp = samples_p[channel]; | 1490 | int16_t *smp = samples_p[channel]; |
| 1486 | for (int n = 0; n < nb_samples / 2; n++) { | 1491 | for (int n = 0; n < nb_samples / 2; n++) { |
| 1487 | int v = bytestream2_get_byteu(&gb); | 1492 | int v = bytestream2_get_byteu(&gb); |
| @@ -1498,7 +1503,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 10 unmodified lines |
| 1498 | } | 1503 | } |
| 1499 | ) /* End of CASE */ | 1504 | ) /* End of CASE */ |
| 1500 | CASE(ADPCM_IMA_RAD, | 1505 | CASE(ADPCM_IMA_RAD, |
| 1501 | for (int channel = 0; channel < avctx->channels; channel++) { | 1506 | for (int channel = 0; channel < channels; channel++) { |
| 1502 | ADPCMChannelStatus *cs = &c->status[channel]; | 1507 | ADPCMChannelStatus *cs = &c->status[channel]; |
| 1503 | cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); | 1508 | cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16); |
| 1504 | cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); | 1509 | cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); |
| @@ -1514,17 +1519,17 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 9 unmodified lines |
| 1514 | byte[0] = bytestream2_get_byteu(&gb); | 1519 | byte[0] = bytestream2_get_byteu(&gb); |
| 1515 | if (st) | 1520 | if (st) |
| 1516 | byte[1] = bytestream2_get_byteu(&gb); | 1521 | byte[1] = bytestream2_get_byteu(&gb); |
| 1517 | for (int channel = 0; channel < avctx->channels; channel++) { | 1522 | for (int channel = 0; channel < channels; channel++) { |
| 1518 | *samples++ = adpcm_ima_expand_nibble(&c->status[channel], byte[channel] & 0x0F, 3); | 1523 | *samples++ = adpcm_ima_expand_nibble(&c->status[channel], byte[channel] & 0x0F, 3); |
| 1519 | } | 1524 | } |
| 1520 | for (int channel = 0; channel < avctx->channels; channel++) { | 1525 | for (int channel = 0; channel < channels; channel++) { |
| 1521 | *samples++ = adpcm_ima_expand_nibble(&c->status[channel], byte[channel] >> 4 , 3); | 1526 | *samples++ = adpcm_ima_expand_nibble(&c->status[channel], byte[channel] >> 4 , 3); |
| 1522 | } | 1527 | } |
| 1523 | } | 1528 | } |
| 1524 | ) /* End of CASE */ | 1529 | ) /* End of CASE */ |
| 1525 | CASE(ADPCM_IMA_WS, | 1530 | CASE(ADPCM_IMA_WS, |
| 1526 | if (c->vqa_version == 3) { | 1531 | if (c->vqa_version == 3) { |
| 1527 | for (int channel = 0; channel < avctx->channels; channel++) { | 1532 | for (int channel = 0; channel < channels; channel++) { |
| 1528 | int16_t *smp = samples_p[channel]; | 1533 | int16_t *smp = samples_p[channel]; |
| 1529 | | 1534 | |
| 1530 | for (int n = nb_samples / 2; n > 0; n--) { | 1535 | for (int n = nb_samples / 2; n > 0; n--) { |
| @@ -1535,12 +1540,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines |
| 1535 | } | 1540 | } |
| 1536 | } else { | 1541 | } else { |
| 1537 | for (int n = nb_samples / 2; n > 0; n--) { | 1542 | for (int n = nb_samples / 2; n > 0; n--) { |
| 1538 | for (int channel = 0; channel < avctx->channels; channel++) { | 1543 | for (int channel = 0; channel < channels; channel++) { |
| 1539 | int v = bytestream2_get_byteu(&gb); | 1544 | int v = bytestream2_get_byteu(&gb); |
| 1540 | *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3); | 1545 | *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3); |
| 1541 | samples[st] = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3); | 1546 | samples[st] = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3); |
| 1542 | } | 1547 | } |
| 1543 | samples += avctx->channels; | 1548 | samples += channels; |
| 1544 | } | 1549 | } |
| 1545 | } | 1550 | } |
| 1546 | bytestream2_seek(&gb, 0, SEEK_END); | 1551 | bytestream2_seek(&gb, 0, SEEK_END); |
| @@ -1548,13 +1553,13 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 1 unmodified line |
| 1548 | CASE(ADPCM_XA, | 1553 | CASE(ADPCM_XA, |
| 1549 | int16_t *out0 = samples_p[0]; | 1554 | int16_t *out0 = samples_p[0]; |
| 1550 | int16_t *out1 = samples_p[1]; | 1555 | int16_t *out1 = samples_p[1]; |
| 1551 | int samples_per_block = 28 * (3 - avctx->channels) * 4; | 1556 | int samples_per_block = 28 * (3 - channels) * 4; |
| 1552 | int sample_offset = 0; | 1557 | int sample_offset = 0; |
| 1553 | int bytes_remaining; | 1558 | int bytes_remaining; |
| 1554 | while (bytestream2_get_bytes_left(&gb) >= 128) { | 1559 | while (bytestream2_get_bytes_left(&gb) >= 128) { |
| 1555 | if ((ret = xa_decode(avctx, out0, out1, buf + bytestream2_tell(&gb), | 1560 | if ((ret = xa_decode(avctx, out0, out1, buf + bytestream2_tell(&gb), |
| 1556 | &c->status[0], &c->status[1], | 1561 | &c->status[0], &c->status[1], |
| 1557 | avctx->channels, sample_offset)) < 0) | 1562 | channels, sample_offset)) < 0) |
| 1558 | return ret; | 1563 | return ret; |
| 1559 | bytestream2_skipu(&gb, 128); | 1564 | bytestream2_skipu(&gb, 128); |
| 1560 | sample_offset += samples_per_block; | 1565 | sample_offset += samples_per_block; |
| @@ -1604,7 +1609,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 43 unmodified lines |
| 1604 | /* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces, | 1609 | /* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces, |
| 1605 | each coding 28 stereo samples. */ | 1610 | each coding 28 stereo samples. */ |
| 1606 | | 1611 | |
| 1607 | if(avctx->channels != 2) | 1612 | if (channels != 2) |
| 1608 | return AVERROR_INVALIDDATA; | 1613 | return AVERROR_INVALIDDATA; |
| 1609 | | 1614 | |
| 1610 | current_left_sample = sign_extend(bytestream2_get_le16u(&gb), 16); | 1615 | current_left_sample = sign_extend(bytestream2_get_le16u(&gb), 16); |
| @@ -1649,7 +1654,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 38 unmodified lines |
| 1649 | CASE(ADPCM_EA_MAXIS_XA, | 1654 | CASE(ADPCM_EA_MAXIS_XA, |
| 1650 | int coeff[2][2], shift[2]; | 1655 | int coeff[2][2], shift[2]; |
| 1651 | | 1656 | |
| 1652 | for (int channel = 0; channel < avctx->channels; channel++) { | 1657 | for (int channel = 0; channel < channels; channel++) { |
| 1653 | int byte = bytestream2_get_byteu(&gb); | 1658 | int byte = bytestream2_get_byteu(&gb); |
| 1654 | for (int i = 0; i < 2; i++) | 1659 | for (int i = 0; i < 2; i++) |
| 1655 | coeff[channel][i] = ea_adpcm_table[(byte >> 4) + 4*i]; | 1660 | coeff[channel][i] = ea_adpcm_table[(byte >> 4) + 4*i]; |
| @@ -1661,7 +1666,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 5 unmodified lines |
| 1661 | byte[0] = bytestream2_get_byteu(&gb); | 1666 | byte[0] = bytestream2_get_byteu(&gb); |
| 1662 | if (st) byte[1] = bytestream2_get_byteu(&gb); | 1667 | if (st) byte[1] = bytestream2_get_byteu(&gb); |
| 1663 | for (int i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */ | 1668 | for (int i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */ |
| 1664 | for (int channel = 0; channel < avctx->channels; channel++) { | 1669 | for (int channel = 0; channel < channels; channel++) { |
| 1665 | int sample = sign_extend(byte[channel] >> i, 4) * (1 << shift[channel]); | 1670 | int sample = sign_extend(byte[channel] >> i, 4) * (1 << shift[channel]); |
| 1666 | sample = (sample + | 1671 | sample = (sample + |
| 1667 | c->status[channel].sample1 * coeff[channel][0] + | 1672 | c->status[channel].sample1 * coeff[channel][0] + |
| @@ -1690,12 +1695,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 22 unmodified lines |
| 1690 | int count = 0; | 1695 | int count = 0; |
| 1691 | int offsets[6]; | 1696 | int offsets[6]; |
| 1692 | | 1697 | |
| 1693 | for (unsigned channel = 0; channel < avctx->channels; channel++) | 1698 | for (unsigned channel = 0; channel < channels; channel++) |
| 1694 | offsets[channel] = (big_endian ? bytestream2_get_be32(&gb) : | 1699 | offsets[channel] = (big_endian ? bytestream2_get_be32(&gb) : |
| 1695 | bytestream2_get_le32(&gb)) + | 1700 | bytestream2_get_le32(&gb)) + |
| 1696 | (avctx->channels + 1) * 4; | 1701 | (channels + 1) * 4; |
| 1697 | | 1702 | |
| 1698 | for (unsigned channel = 0; channel < avctx->channels; channel++) { | 1703 | for (unsigned channel = 0; channel < channels; channel++) { |
| 1699 | int count1; | 1704 | int count1; |
| 1700 | | 1705 | |
| 1701 | bytestream2_seek(&gb, offsets[channel], SEEK_SET); | 1706 | bytestream2_seek(&gb, offsets[channel], SEEK_SET); |
| @@ -1759,7 +1764,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 57 unmodified lines |
| 1759 | } | 1764 | } |
| 1760 | #endif /* CONFIG_ADPCM_EA_Rx_DECODER */ | 1765 | #endif /* CONFIG_ADPCM_EA_Rx_DECODER */ |
| 1761 | CASE(ADPCM_EA_XAS, | 1766 | CASE(ADPCM_EA_XAS, |
| 1762 | for (int channel=0; channel < avctx->channels; channel++) { | 1767 | for (int channel=0; channel < channels; channel++) { |
| 1763 | int coeff[2][4], shift[4]; | 1768 | int coeff[2][4], shift[4]; |
| 1764 | int16_t *s = samples_p[channel]; | 1769 | int16_t *s = samples_p[channel]; |
| 1765 | for (int n = 0; n < 4; n++, s += 32) { | 1770 | for (int n = 0; n < 4; n++, s += 32) { |
| @@ -1791,7 +1796,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 25 unmodified lines |
| 1791 | } | 1796 | } |
| 1792 | ) /* End of CASE */ | 1797 | ) /* End of CASE */ |
| 1793 | CASE(ADPCM_IMA_ACORN, | 1798 | CASE(ADPCM_IMA_ACORN, |
| 1794 | for (int channel = 0; channel < avctx->channels; channel++) { | 1799 | for (int channel = 0; channel < channels; channel++) { |
| 1795 | ADPCMChannelStatus *cs = &c->status[channel]; | 1800 | ADPCMChannelStatus *cs = &c->status[channel]; |
| 1796 | cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); | 1801 | cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16); |
| 1797 | cs->step_index = bytestream2_get_le16u(&gb) & 0xFF; | 1802 | cs->step_index = bytestream2_get_le16u(&gb) & 0xFF; |
| @@ -1808,7 +1813,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 10 unmodified lines |
| 1808 | } | 1813 | } |
| 1809 | ) /* End of CASE */ | 1814 | ) /* End of CASE */ |
| 1810 | CASE(ADPCM_IMA_AMV, | 1815 | CASE(ADPCM_IMA_AMV, |
| 1811 | av_assert0(avctx->channels == 1); | 1816 | av_assert0(channels == 1); |
| 1812 | | 1817 | |
| 1813 | /* | 1818 | /* |
| 1814 | * Header format: | 1819 | * Header format: |
| @@ -1848,7 +1853,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 33 unmodified lines |
| 1848 | } | 1853 | } |
| 1849 | ) /* End of CASE */ | 1854 | ) /* End of CASE */ |
| 1850 | CASE(ADPCM_IMA_SMJPEG, | 1855 | CASE(ADPCM_IMA_SMJPEG, |
| 1851 | for (int i = 0; i < avctx->channels; i++) { | 1856 | for (int i = 0; i < channels; i++) { |
| 1852 | c->status[i].predictor = sign_extend(bytestream2_get_be16u(&gb), 16); | 1857 | c->status[i].predictor = sign_extend(bytestream2_get_be16u(&gb), 16); |
| 1853 | c->status[i].step_index = bytestream2_get_byteu(&gb); | 1858 | c->status[i].step_index = bytestream2_get_byteu(&gb); |
| 1854 | bytestream2_skipu(&gb, 1); | 1859 | bytestream2_skipu(&gb, 1); |
| @@ -1931,7 +1936,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 76 unmodified lines |
| 1931 | } | 1936 | } |
| 1932 | ) /* End of CASE */ | 1937 | ) /* End of CASE */ |
| 1933 | CASE(ADPCM_AICA, | 1938 | CASE(ADPCM_AICA, |
| 1934 | for (int channel = 0; channel < avctx->channels; channel++) { | 1939 | for (int channel = 0; channel < channels; channel++) { |
| 1935 | samples = samples_p[channel]; | 1940 | samples = samples_p[channel]; |
| 1936 | for (int n = nb_samples >> 1; n > 0; n--) { | 1941 | for (int n = nb_samples >> 1; n > 0; n--) { |
| 1937 | int v = bytestream2_get_byteu(&gb); | 1942 | int v = bytestream2_get_byteu(&gb); |
| @@ -1953,7 +1958,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 15 unmodified lines |
| 1953 | } | 1958 | } |
| 1954 | | 1959 | |
| 1955 | for (int m = 0; m < blocks; m++) { | 1960 | for (int m = 0; m < blocks; m++) { |
| 1956 | for (int channel = 0; channel < avctx->channels; channel++) { | 1961 | for (int channel = 0; channel < channels; channel++) { |
| 1957 | int prev1 = c->status[channel].sample1; | 1962 | int prev1 = c->status[channel].sample1; |
| 1958 | int prev2 = c->status[channel].sample2; | 1963 | int prev2 = c->status[channel].sample2; |
| 1959 | | 1964 | |
| @@ -2005,33 +2010,33 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 45 unmodified lines |
| 2005 | | 2010 | |
| 2006 | if (avctx->extradata) { | 2011 | if (avctx->extradata) { |
| 2007 | GetByteContext tb; | 2012 | GetByteContext tb; |
| 2008 | if (avctx->extradata_size < 32 * avctx->channels) { | 2013 | if (avctx->extradata_size < 32 * channels) { |
| 2009 | av_log(avctx, AV_LOG_ERROR, "Missing coeff table\n"); | 2014 | av_log(avctx, AV_LOG_ERROR, "Missing coeff table\n"); |
| 2010 | return AVERROR_INVALIDDATA; | 2015 | return AVERROR_INVALIDDATA; |
| 2011 | } | 2016 | } |
| 2012 | | 2017 | |
| 2013 | bytestream2_init(&tb, avctx->extradata, avctx->extradata_size); | 2018 | bytestream2_init(&tb, avctx->extradata, avctx->extradata_size); |
| 2014 | for (int i = 0; i < avctx->channels; i++) | 2019 | for (int i = 0; i < channels; i++) |
| 2015 | for (int n = 0; n < 16; n++) | 2020 | for (int n = 0; n < 16; n++) |
| 2016 | table[i][n] = THP_GET16(tb); | 2021 | table[i][n] = THP_GET16(tb); |
| 2017 | } else { | 2022 | } else { |
| 2018 | for (int i = 0; i < avctx->channels; i++) | 2023 | for (int i = 0; i < channels; i++) |
| 2019 | for (int n = 0; n < 16; n++) | 2024 | for (int n = 0; n < 16; n++) |
| 2020 | table[i][n] = THP_GET16(gb); | 2025 | table[i][n] = THP_GET16(gb); |
| 2021 | | 2026 | |
| 2022 | if (!c->has_status) { | 2027 | if (!c->has_status) { |
| 2023 | /* Initialize the previous sample. */ | 2028 | /* Initialize the previous sample. */ |
| 2024 | for (int i = 0; i < avctx->channels; i++) { | 2029 | for (int i = 0; i < channels; i++) { |
| 2025 | c->status[i].sample1 = THP_GET16(gb); | 2030 | c->status[i].sample1 = THP_GET16(gb); |
| 2026 | c->status[i].sample2 = THP_GET16(gb); | 2031 | c->status[i].sample2 = THP_GET16(gb); |
| 2027 | } | 2032 | } |
| 2028 | c->has_status = 1; | 2033 | c->has_status = 1; |
| 2029 | } else { | 2034 | } else { |
| 2030 | bytestream2_skip(&gb, avctx->channels * 4); | 2035 | bytestream2_skip(&gb, channels * 4); |
| 2031 | } | 2036 | } |
| 2032 | } | 2037 | } |
| 2033 | | 2038 | |
| 2034 | for (int ch = 0; ch < avctx->channels; ch++) { | 2039 | for (int ch = 0; ch < channels; ch++) { |
| 2035 | samples = samples_p[ch]; | 2040 | samples = samples_p[ch]; |
| 2036 | | 2041 | |
| 2037 | /* Read in every sample for this channel. */ | 2042 | /* Read in every sample for this channel. */ |
| @@ -2065,7 +2070,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 27 unmodified lines |
| 2065 | } | 2070 | } |
| 2066 | #endif /* CONFIG_ADPCM_THP(_LE)_DECODER */ | 2071 | #endif /* CONFIG_ADPCM_THP(_LE)_DECODER */ |
| 2067 | CASE(ADPCM_DTK, | 2072 | CASE(ADPCM_DTK, |
| 2068 | for (int channel = 0; channel < avctx->channels; channel++) { | 2073 | for (int channel = 0; channel < channels; channel++) { |
| 2069 | samples = samples_p[channel]; | 2074 | samples = samples_p[channel]; |
| 2070 | | 2075 | |
| 2071 | /* Read in every sample for this channel. */ | 2076 | /* Read in every sample for this channel. */ |
| @@ -2113,9 +2118,9 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 41 unmodified lines |
| 2113 | } | 2118 | } |
| 2114 | ) /* End of CASE */ | 2119 | ) /* End of CASE */ |
| 2115 | CASE(ADPCM_PSX, | 2120 | CASE(ADPCM_PSX, |
| 2116 | for (int block = 0; block < avpkt->size / FFMAX(avctx->block_align, 16 * avctx->channels); block++) { | 2121 | for (int block = 0; block < avpkt->size / FFMAX(avctx->block_align, 16 * channels); block++) { |
| 2117 | int nb_samples_per_block = 28 * FFMAX(avctx->block_align, 16 * avctx->channels) / (16 * avctx->channels); | 2122 | int nb_samples_per_block = 28 * FFMAX(avctx->block_align, 16 * channels) / (16 * channels); |
| 2118 | for (int channel = 0; channel < avctx->channels; channel++) { | 2123 | for (int channel = 0; channel < channels; channel++) { |
| 2119 | samples = samples_p[channel] + block * nb_samples_per_block; | 2124 | samples = samples_p[channel] + block * nb_samples_per_block; |
| 2120 | av_assert0((block + 1) * nb_samples_per_block <= nb_samples); | 2125 | av_assert0((block + 1) * nb_samples_per_block <= nb_samples); |
| 2121 | | 2126 | |
| @@ -2172,7 +2177,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 50 unmodified lines |
| 2172 | * They should be 0 initially. | 2177 | * They should be 0 initially. |
| 2173 | */ | 2178 | */ |
| 2174 | for (int block = 0; block < avpkt->size / avctx->block_align; block++) { | 2179 | for (int block = 0; block < avpkt->size / avctx->block_align; block++) { |
| 2175 | for (int channel = 0; channel < avctx->channels; channel++) { | 2180 | for (int channel = 0; channel < avctx->ch_layout.nb_channels; channel++) { |
| 2176 | ADPCMChannelStatus *cs = c->status + channel; | 2181 | ADPCMChannelStatus *cs = c->status + channel; |
| 2177 | int control, shift; | 2182 | int control, shift; |
| 2178 | | 2183 | |
| @@ -2191,19 +2196,19 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 12 unmodified lines |
| 2191 | } | 2196 | } |
| 2192 | ) /* End of CASE */ | 2197 | ) /* End of CASE */ |
| 2193 | CASE(ADPCM_ZORK, | 2198 | CASE(ADPCM_ZORK, |
| 2194 | for (int n = 0; n < nb_samples * avctx->channels; n++) { | 2199 | for (int n = 0; n < nb_samples * channels; n++) { |
| 2195 | int v = bytestream2_get_byteu(&gb); | 2200 | int v = bytestream2_get_byteu(&gb); |
| 2196 | *samples++ = adpcm_zork_expand_nibble(&c->status[n % avctx->channels], v); | 2201 | *samples++ = adpcm_zork_expand_nibble(&c->status[n % channels], v); |
| 2197 | } | 2202 | } |
| 2198 | ) /* End of CASE */ | 2203 | ) /* End of CASE */ |
| 2199 | CASE(ADPCM_IMA_MTF, | 2204 | CASE(ADPCM_IMA_MTF, |
| 2200 | for (int n = nb_samples / 2; n > 0; n--) { | 2205 | for (int n = nb_samples / 2; n > 0; n--) { |
| 2201 | for (int channel = 0; channel < avctx->channels; channel++) { | 2206 | for (int channel = 0; channel < channels; channel++) { |
| 2202 | int v = bytestream2_get_byteu(&gb); | 2207 | int v = bytestream2_get_byteu(&gb); |
| 2203 | *samples++ = adpcm_ima_mtf_expand_nibble(&c->status[channel], v >> 4); | 2208 | *samples++ = adpcm_ima_mtf_expand_nibble(&c->status[channel], v >> 4); |
| 2204 | samples[st] = adpcm_ima_mtf_expand_nibble(&c->status[channel], v & 0x0F); | 2209 | samples[st] = adpcm_ima_mtf_expand_nibble(&c->status[channel], v & 0x0F); |
| 2205 | } | 2210 | } |
| 2206 | samples += avctx->channels; | 2211 | samples += channels; |
| 2207 | } | 2212 | } |
| 2208 | ) /* End of CASE */ | 2213 | ) /* End of CASE */ |
| 2209 | default: | 2214 | default: |