History

adpcm: convert to new channel layout API

Anton Khirnov committed 13 years ago

Commit 984612a1 parent 111ed1b2 files · +141 −132Browse files

Unified · Split

2 files
  1. libavcodec/adpcm.c +78 −73
  2. libavcodec/adpcmenc.c +63 −59
libavcodec/adpcm.c+78−73
@@ -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 adpcm784 // 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:
libavcodec/adpcmenc.c+63−59
@@ -79,11 +79,7 @@ typedef struct ADPCMEncodeContext { · 78 unmodified lines
79static av_cold int adpcm_encode_init(AVCodecContext *avctx)79static av_cold int adpcm_encode_init(AVCodecContext *avctx)
80{80{
81 ADPCMEncodeContext *s = avctx->priv_data;81 ADPCMEncodeContext *s = avctx->priv_data;
82 82 int channels = avctx->ch_layout.nb_channels;
83 if (avctx->channels > 2) {
84 av_log(avctx, AV_LOG_ERROR, "only stereo or mono is supported\n");
85 return AVERROR(EINVAL);
86 }
87 83
88 /*84 /*
89 * AMV's block size has to match that of the corresponding video85 * AMV's block size has to match that of the corresponding video
@@ -130,8 +126,8 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) · 40 unmodified lines
130 CASE(ADPCM_IMA_WAV,126 CASE(ADPCM_IMA_WAV,
131 /* each 16 bits sample gives one nibble127 /* each 16 bits sample gives one nibble
132 and we have 4 bytes per channel overhead */128 and we have 4 bytes per channel overhead */
133 avctx->frame_size = (s->block_size - 4 * avctx->channels) * 8 /129 avctx->frame_size = (s->block_size - 4 * channels) * 8 /
134 (4 * avctx->channels) + 1;130 (4 * channels) + 1;
135 /* seems frame_size isn't taken into account...131 /* seems frame_size isn't taken into account...
136 have to buffer the samples :-( */132 have to buffer the samples :-( */
137 avctx->block_align = s->block_size;133 avctx->block_align = s->block_size;
@@ -139,13 +135,13 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) · 1 unmodified line
139 ) /* End of CASE */135 ) /* End of CASE */
140 CASE(ADPCM_IMA_QT,136 CASE(ADPCM_IMA_QT,
141 avctx->frame_size = 64;137 avctx->frame_size = 64;
142 avctx->block_align = 34 * avctx->channels;138 avctx->block_align = 34 * channels;
143 ) /* End of CASE */139 ) /* End of CASE */
144 CASE(ADPCM_MS,140 CASE(ADPCM_MS,
145 uint8_t *extradata;141 uint8_t *extradata;
146 /* each 16 bits sample gives one nibble142 /* each 16 bits sample gives one nibble
147 and we have 7 bytes per channel overhead */143 and we have 7 bytes per channel overhead */
148 avctx->frame_size = (s->block_size - 7 * avctx->channels) * 2 / avctx->channels + 2;144 avctx->frame_size = (s->block_size - 7 * channels) * 2 / channels + 2;
149 avctx->bits_per_coded_sample = 4;145 avctx->bits_per_coded_sample = 4;
150 avctx->block_align = s->block_size;146 avctx->block_align = s->block_size;
151 if (!(avctx->extradata = av_malloc(32 + AV_INPUT_BUFFER_PADDING_SIZE)))147 if (!(avctx->extradata = av_malloc(32 + AV_INPUT_BUFFER_PADDING_SIZE)))
@@ -160,7 +156,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) · 8 unmodified lines
160 }156 }
161 ) /* End of CASE */157 ) /* End of CASE */
162 CASE(ADPCM_YAMAHA,158 CASE(ADPCM_YAMAHA,
163 avctx->frame_size = s->block_size * 2 / avctx->channels;159 avctx->frame_size = s->block_size * 2 / channels;
164 avctx->block_align = s->block_size;160 avctx->block_align = s->block_size;
165 ) /* End of CASE */161 ) /* End of CASE */
166 CASE(ADPCM_SWF,162 CASE(ADPCM_SWF,
@@ -172,11 +168,11 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) · 5 unmodified lines
172 return AVERROR(EINVAL);168 return AVERROR(EINVAL);
173 }169 }
174 avctx->frame_size = 4096; /* Hardcoded according to the SWF spec. */170 avctx->frame_size = 4096; /* Hardcoded according to the SWF spec. */
175 avctx->block_align = (2 + avctx->channels * (22 + 4 * (avctx->frame_size - 1)) + 7) / 8;171 avctx->block_align = (2 + channels * (22 + 4 * (avctx->frame_size - 1)) + 7) / 8;
176 ) /* End of CASE */172 ) /* End of CASE */
177 case AV_CODEC_ID_ADPCM_IMA_SSI:173 case AV_CODEC_ID_ADPCM_IMA_SSI:
178 case AV_CODEC_ID_ADPCM_IMA_ALP:174 case AV_CODEC_ID_ADPCM_IMA_ALP:
179 avctx->frame_size = s->block_size * 2 / avctx->channels;175 avctx->frame_size = s->block_size * 2 / channels;
180 avctx->block_align = s->block_size;176 avctx->block_align = s->block_size;
181 break;177 break;
182 CASE(ADPCM_IMA_AMV,178 CASE(ADPCM_IMA_AMV,
@@ -185,7 +181,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) · 2 unmodified lines
185 return AVERROR(EINVAL);181 return AVERROR(EINVAL);
186 }182 }
187 183
188 if (avctx->channels != 1) {184 if (channels != 1) {
189 av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");185 av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");
190 return AVERROR(EINVAL);186 return AVERROR(EINVAL);
191 }187 }
@@ -194,7 +190,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) · 2 unmodified lines
194 avctx->block_align = 8 + (FFALIGN(avctx->frame_size, 2) / 2);190 avctx->block_align = 8 + (FFALIGN(avctx->frame_size, 2) / 2);
195 ) /* End of CASE */191 ) /* End of CASE */
196 CASE(ADPCM_IMA_APM,192 CASE(ADPCM_IMA_APM,
197 avctx->frame_size = s->block_size * 2 / avctx->channels;193 avctx->frame_size = s->block_size * 2 / channels;
198 avctx->block_align = s->block_size;194 avctx->block_align = s->block_size;
199 195
200 if (!(avctx->extradata = av_mallocz(28 + AV_INPUT_BUFFER_PADDING_SIZE)))196 if (!(avctx->extradata = av_mallocz(28 + AV_INPUT_BUFFER_PADDING_SIZE)))
@@ -203,11 +199,11 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) · 2 unmodified lines
203 ) /* End of CASE */199 ) /* End of CASE */
204 CASE(ADPCM_ARGO,200 CASE(ADPCM_ARGO,
205 avctx->frame_size = 32;201 avctx->frame_size = 32;
206 avctx->block_align = 17 * avctx->channels;202 avctx->block_align = 17 * channels;
207 ) /* End of CASE */203 ) /* End of CASE */
208 CASE(ADPCM_IMA_WS,204 CASE(ADPCM_IMA_WS,
209 /* each 16 bits sample gives one nibble */205 /* each 16 bits sample gives one nibble */
210 avctx->frame_size = s->block_size * 2 / avctx->channels;206 avctx->frame_size = s->block_size * 2 / channels;
211 avctx->block_align = s->block_size;207 avctx->block_align = s->block_size;
212 ) /* End of CASE */208 ) /* End of CASE */
213 default:209 default:
@@ -606,16 +602,17 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 392 unmodified lines
606 int16_t **samples_p;602 int16_t **samples_p;
607 uint8_t *dst;603 uint8_t *dst;
608 ADPCMEncodeContext *c = avctx->priv_data;604 ADPCMEncodeContext *c = avctx->priv_data;
605 int channels = avctx->ch_layout.nb_channels;
609 606
610 samples = (const int16_t *)frame->data[0];607 samples = (const int16_t *)frame->data[0];
611 samples_p = (int16_t **)frame->extended_data;608 samples_p = (int16_t **)frame->extended_data;
612 st = avctx->channels == 2;609 st = channels == 2;
613 610
614 if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||611 if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||
615 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_ALP ||612 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_ALP ||
616 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM ||613 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM ||
617 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_WS)614 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_WS)
618 pkt_size = (frame->nb_samples * avctx->channels) / 2;615 pkt_size = (frame->nb_samples * channels) / 2;
619 else616 else
620 pkt_size = avctx->block_align;617 pkt_size = avctx->block_align;
621 if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0)618 if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0)
@@ -626,7 +623,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 4 unmodified lines
626 CASE(ADPCM_IMA_WAV,623 CASE(ADPCM_IMA_WAV,
627 int blocks = (frame->nb_samples - 1) / 8;624 int blocks = (frame->nb_samples - 1) / 8;
628 625
629 for (int ch = 0; ch < avctx->channels; ch++) {626 for (int ch = 0; ch < channels; ch++) {
630 ADPCMChannelStatus *status = &c->status[ch];627 ADPCMChannelStatus *status = &c->status[ch];
631 status->prev_sample = samples_p[ch][0];628 status->prev_sample = samples_p[ch][0];
632 /* status->step_index = 0;629 /* status->step_index = 0;
@@ -639,15 +636,15 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 6 unmodified lines
639 /* stereo: 4 bytes (8 samples) for left, 4 bytes for right */636 /* stereo: 4 bytes (8 samples) for left, 4 bytes for right */
640 if (avctx->trellis > 0) {637 if (avctx->trellis > 0) {
641 uint8_t *buf;638 uint8_t *buf;
642 if (!FF_ALLOC_TYPED_ARRAY(buf, avctx->channels * blocks * 8))639 if (!FF_ALLOC_TYPED_ARRAY(buf, channels * blocks * 8))
643 return AVERROR(ENOMEM);640 return AVERROR(ENOMEM);
644 for (int ch = 0; ch < avctx->channels; ch++) {641 for (int ch = 0; ch < channels; ch++) {
645 adpcm_compress_trellis(avctx, &samples_p[ch][1],642 adpcm_compress_trellis(avctx, &samples_p[ch][1],
646 buf + ch * blocks * 8, &c->status[ch],643 buf + ch * blocks * 8, &c->status[ch],
647 blocks * 8, 1);644 blocks * 8, 1);
648 }645 }
649 for (int i = 0; i < blocks; i++) {646 for (int i = 0; i < blocks; i++) {
650 for (int ch = 0; ch < avctx->channels; ch++) {647 for (int ch = 0; ch < channels; ch++) {
651 uint8_t *buf1 = buf + ch * blocks * 8 + i * 8;648 uint8_t *buf1 = buf + ch * blocks * 8 + i * 8;
652 for (int j = 0; j < 8; j += 2)649 for (int j = 0; j < 8; j += 2)
653 *dst++ = buf1[j] | (buf1[j + 1] << 4);650 *dst++ = buf1[j] | (buf1[j + 1] << 4);
@@ -656,7 +653,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 2 unmodified lines
656 av_free(buf);653 av_free(buf);
657 } else {654 } else {
658 for (int i = 0; i < blocks; i++) {655 for (int i = 0; i < blocks; i++) {
659 for (int ch = 0; ch < avctx->channels; ch++) {656 for (int ch = 0; ch < channels; ch++) {
660 ADPCMChannelStatus *status = &c->status[ch];657 ADPCMChannelStatus *status = &c->status[ch];
661 const int16_t *smp = &samples_p[ch][1 + i * 8];658 const int16_t *smp = &samples_p[ch][1 + i * 8];
662 for (int j = 0; j < 8; j += 2) {659 for (int j = 0; j < 8; j += 2) {
@@ -672,7 +669,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 9 unmodified lines
672 PutBitContext pb;669 PutBitContext pb;
673 init_put_bits(&pb, dst, pkt_size);670 init_put_bits(&pb, dst, pkt_size);
674 671
675 for (int ch = 0; ch < avctx->channels; ch++) {672 for (int ch = 0; ch < channels; ch++) {
676 ADPCMChannelStatus *status = &c->status[ch];673 ADPCMChannelStatus *status = &c->status[ch];
677 put_bits(&pb, 9, (status->prev_sample & 0xFFFF) >> 7);674 put_bits(&pb, 9, (status->prev_sample & 0xFFFF) >> 7);
678 put_bits(&pb, 7, status->step_index);675 put_bits(&pb, 7, status->step_index);
@@ -703,7 +700,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 24 unmodified lines
703 av_assert0(avctx->trellis == 0);700 av_assert0(avctx->trellis == 0);
704 701
705 for (int i = 0; i < frame->nb_samples; i++) {702 for (int i = 0; i < frame->nb_samples; i++) {
706 for (int ch = 0; ch < avctx->channels; ch++) {703 for (int ch = 0; ch < channels; ch++) {
707 put_bits(&pb, 4, adpcm_ima_qt_compress_sample(c->status + ch, *samples++));704 put_bits(&pb, 4, adpcm_ima_qt_compress_sample(c->status + ch, *samples++));
708 }705 }
709 }706 }
@@ -717,11 +714,11 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 7 unmodified lines
717 av_assert0(avctx->trellis == 0);714 av_assert0(avctx->trellis == 0);
718 715
719 for (int n = frame->nb_samples / 2; n > 0; n--) {716 for (int n = frame->nb_samples / 2; n > 0; n--) {
720 for (int ch = 0; ch < avctx->channels; ch++) {717 for (int ch = 0; ch < channels; ch++) {
721 put_bits(&pb, 4, adpcm_ima_alp_compress_sample(c->status + ch, *samples++));718 put_bits(&pb, 4, adpcm_ima_alp_compress_sample(c->status + ch, *samples++));
722 put_bits(&pb, 4, adpcm_ima_alp_compress_sample(c->status + ch, samples[st]));719 put_bits(&pb, 4, adpcm_ima_alp_compress_sample(c->status + ch, samples[st]));
723 }720 }
724 samples += avctx->channels;721 samples += channels;
725 }722 }
726 723
727 flush_put_bits(&pb);724 flush_put_bits(&pb);
@@ -738,7 +735,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 10 unmodified lines
738 put_bits(&pb, 2, 2); // set 4-bit flash adpcm format735 put_bits(&pb, 2, 2); // set 4-bit flash adpcm format
739 736
740 // init the encoder state737 // init the encoder state
741 for (int i = 0; i < avctx->channels; i++) {738 for (int i = 0; i < channels; i++) {
742 // clip step so it fits 6 bits739 // clip step so it fits 6 bits
743 c->status[i].step_index = av_clip_uintp2(c->status[i].step_index, 6);740 c->status[i].step_index = av_clip_uintp2(c->status[i].step_index, 6);
744 put_sbits(&pb, 16, samples[i]);741 put_sbits(&pb, 16, samples[i]);
@@ -748,22 +745,22 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 3 unmodified lines
748 745
749 if (avctx->trellis > 0) {746 if (avctx->trellis > 0) {
750 uint8_t buf[8190 /* = 2 * n */];747 uint8_t buf[8190 /* = 2 * n */];
751 adpcm_compress_trellis(avctx, samples + avctx->channels, buf,748 adpcm_compress_trellis(avctx, samples + channels, buf,
752 &c->status[0], n, avctx->channels);749 &c->status[0], n, channels);
753 if (avctx->channels == 2)750 if (channels == 2)
754 adpcm_compress_trellis(avctx, samples + avctx->channels + 1,751 adpcm_compress_trellis(avctx, samples + channels + 1,
755 buf + n, &c->status[1], n,752 buf + n, &c->status[1], n,
756 avctx->channels);753 channels);
757 for (int i = 0; i < n; i++) {754 for (int i = 0; i < n; i++) {
758 put_bits(&pb, 4, buf[i]);755 put_bits(&pb, 4, buf[i]);
759 if (avctx->channels == 2)756 if (channels == 2)
760 put_bits(&pb, 4, buf[n + i]);757 put_bits(&pb, 4, buf[n + i]);
761 }758 }
762 } else {759 } else {
763 for (int i = 1; i < frame->nb_samples; i++) {760 for (int i = 1; i < frame->nb_samples; i++) {
764 put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0],761 put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0],
765 samples[avctx->channels * i]));762 samples[channels * i]));
766 if (avctx->channels == 2)763 if (channels == 2)
767 put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1],764 put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1],
768 samples[2 * i + 1]));765 samples[2 * i + 1]));
769 }766 }
@@ -771,47 +768,47 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 1 unmodified line
771 flush_put_bits(&pb);768 flush_put_bits(&pb);
772 ) /* End of CASE */769 ) /* End of CASE */
773 CASE(ADPCM_MS,770 CASE(ADPCM_MS,
774 for (int i = 0; i < avctx->channels; i++) {771 for (int i = 0; i < channels; i++) {
775 int predictor = 0;772 int predictor = 0;
776 *dst++ = predictor;773 *dst++ = predictor;
777 c->status[i].coeff1 = ff_adpcm_AdaptCoeff1[predictor];774 c->status[i].coeff1 = ff_adpcm_AdaptCoeff1[predictor];
778 c->status[i].coeff2 = ff_adpcm_AdaptCoeff2[predictor];775 c->status[i].coeff2 = ff_adpcm_AdaptCoeff2[predictor];
779 }776 }
780 for (int i = 0; i < avctx->channels; i++) {777 for (int i = 0; i < channels; i++) {
781 if (c->status[i].idelta < 16)778 if (c->status[i].idelta < 16)
782 c->status[i].idelta = 16;779 c->status[i].idelta = 16;
783 bytestream_put_le16(&dst, c->status[i].idelta);780 bytestream_put_le16(&dst, c->status[i].idelta);
784 }781 }
785 for (int i = 0; i < avctx->channels; i++)782 for (int i = 0; i < channels; i++)
786 c->status[i].sample2= *samples++;783 c->status[i].sample2= *samples++;
787 for (int i = 0; i < avctx->channels; i++) {784 for (int i = 0; i < channels; i++) {
788 c->status[i].sample1 = *samples++;785 c->status[i].sample1 = *samples++;
789 bytestream_put_le16(&dst, c->status[i].sample1);786 bytestream_put_le16(&dst, c->status[i].sample1);
790 }787 }
791 for (int i = 0; i < avctx->channels; i++)788 for (int i = 0; i < channels; i++)
792 bytestream_put_le16(&dst, c->status[i].sample2);789 bytestream_put_le16(&dst, c->status[i].sample2);
793 790
794 if (avctx->trellis > 0) {791 if (avctx->trellis > 0) {
795 const int n = avctx->block_align - 7 * avctx->channels;792 const int n = avctx->block_align - 7 * channels;
796 uint8_t *buf = av_malloc(2 * n);793 uint8_t *buf = av_malloc(2 * n);
797 if (!buf)794 if (!buf)
798 return AVERROR(ENOMEM);795 return AVERROR(ENOMEM);
799 if (avctx->channels == 1) {796 if (channels == 1) {
800 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,797 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
801 avctx->channels);798 channels);
802 for (int i = 0; i < n; i += 2)799 for (int i = 0; i < n; i += 2)
803 *dst++ = (buf[i] << 4) | buf[i + 1];800 *dst++ = (buf[i] << 4) | buf[i + 1];
804 } else {801 } else {
805 adpcm_compress_trellis(avctx, samples, buf,802 adpcm_compress_trellis(avctx, samples, buf,
806 &c->status[0], n, avctx->channels);803 &c->status[0], n, channels);
807 adpcm_compress_trellis(avctx, samples + 1, buf + n,804 adpcm_compress_trellis(avctx, samples + 1, buf + n,
808 &c->status[1], n, avctx->channels);805 &c->status[1], n, channels);
809 for (int i = 0; i < n; i++)806 for (int i = 0; i < n; i++)
810 *dst++ = (buf[i] << 4) | buf[n + i];807 *dst++ = (buf[i] << 4) | buf[n + i];
811 }808 }
812 av_free(buf);809 av_free(buf);
813 } else {810 } else {
814 for (int i = 7 * avctx->channels; i < avctx->block_align; i++) {811 for (int i = 7 * channels; i < avctx->block_align; i++) {
815 int nibble;812 int nibble;
816 nibble = adpcm_ms_compress_sample(&c->status[ 0], *samples++) << 4;813 nibble = adpcm_ms_compress_sample(&c->status[ 0], *samples++) << 4;
817 nibble |= adpcm_ms_compress_sample(&c->status[st], *samples++);814 nibble |= adpcm_ms_compress_sample(&c->status[st], *samples++);
@@ -826,22 +823,22 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 8 unmodified lines
826 if (!buf)823 if (!buf)
827 return AVERROR(ENOMEM);824 return AVERROR(ENOMEM);
828 n *= 2;825 n *= 2;
829 if (avctx->channels == 1) {826 if (channels == 1) {
830 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,827 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
831 avctx->channels);828 channels);
832 for (int i = 0; i < n; i += 2)829 for (int i = 0; i < n; i += 2)
833 *dst++ = buf[i] | (buf[i + 1] << 4);830 *dst++ = buf[i] | (buf[i + 1] << 4);
834 } else {831 } else {
835 adpcm_compress_trellis(avctx, samples, buf,832 adpcm_compress_trellis(avctx, samples, buf,
836 &c->status[0], n, avctx->channels);833 &c->status[0], n, channels);
837 adpcm_compress_trellis(avctx, samples + 1, buf + n,834 adpcm_compress_trellis(avctx, samples + 1, buf + n,
838 &c->status[1], n, avctx->channels);835 &c->status[1], n, channels);
839 for (int i = 0; i < n; i++)836 for (int i = 0; i < n; i++)
840 *dst++ = buf[i] | (buf[n + i] << 4);837 *dst++ = buf[i] | (buf[n + i] << 4);
841 }838 }
842 av_free(buf);839 av_free(buf);
843 } else840 } else
844 for (n *= avctx->channels; n > 0; n--) {841 for (n *= channels; n > 0; n--) {
845 int nibble;842 int nibble;
846 nibble = adpcm_yamaha_compress_sample(&c->status[ 0], *samples++);843 nibble = adpcm_yamaha_compress_sample(&c->status[ 0], *samples++);
847 nibble |= adpcm_yamaha_compress_sample(&c->status[st], *samples++) << 4;844 nibble |= adpcm_yamaha_compress_sample(&c->status[st], *samples++) << 4;
@@ -855,17 +852,17 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 7 unmodified lines
855 av_assert0(avctx->trellis == 0);852 av_assert0(avctx->trellis == 0);
856 853
857 for (int n = frame->nb_samples / 2; n > 0; n--) {854 for (int n = frame->nb_samples / 2; n > 0; n--) {
858 for (int ch = 0; ch < avctx->channels; ch++) {855 for (int ch = 0; ch < channels; ch++) {
859 put_bits(&pb, 4, adpcm_ima_qt_compress_sample(c->status + ch, *samples++));856 put_bits(&pb, 4, adpcm_ima_qt_compress_sample(c->status + ch, *samples++));
860 put_bits(&pb, 4, adpcm_ima_qt_compress_sample(c->status + ch, samples[st]));857 put_bits(&pb, 4, adpcm_ima_qt_compress_sample(c->status + ch, samples[st]));
861 }858 }
862 samples += avctx->channels;859 samples += channels;
863 }860 }
864 861
865 flush_put_bits(&pb);862 flush_put_bits(&pb);
866 ) /* End of CASE */863 ) /* End of CASE */
867 CASE(ADPCM_IMA_AMV,864 CASE(ADPCM_IMA_AMV,
868 av_assert0(avctx->channels == 1);865 av_assert0(channels == 1);
869 866
870 c->status[0].prev_sample = *samples;867 c->status[0].prev_sample = *samples;
871 bytestream_put_le16(&dst, c->status[0].prev_sample);868 bytestream_put_le16(&dst, c->status[0].prev_sample);
@@ -880,7 +877,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 8 unmodified lines
880 if (!buf)877 if (!buf)
881 return AVERROR(ENOMEM);878 return AVERROR(ENOMEM);
882 879
883 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], 2 * n, avctx->channels);880 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], 2 * n, channels);
884 for (int i = 0; i < n; i++)881 for (int i = 0; i < n; i++)
885 bytestream_put_byte(&dst, (buf[2 * i] << 4) | buf[2 * i + 1]);882 bytestream_put_byte(&dst, (buf[2 * i] << 4) | buf[2 * i + 1]);
886 883
@@ -904,7 +901,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 17 unmodified lines
904 901
905 av_assert0(frame->nb_samples == 32);902 av_assert0(frame->nb_samples == 32);
906 903
907 for (int ch = 0; ch < avctx->channels; ch++) {904 for (int ch = 0; ch < channels; ch++) {
908 int64_t error = INT64_MAX, tmperr = INT64_MAX;905 int64_t error = INT64_MAX, tmperr = INT64_MAX;
909 int shift = 2, flag = 0;906 int shift = 2, flag = 0;
910 int saved1 = c->status[ch].sample1;907 int saved1 = c->status[ch].sample1;
@@ -941,14 +938,14 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 30 unmodified lines
941 av_assert0(avctx->trellis == 0);938 av_assert0(avctx->trellis == 0);
942 for (int n = frame->nb_samples / 2; n > 0; n--) {939 for (int n = frame->nb_samples / 2; n > 0; n--) {
943 /* stereo: 1 byte (2 samples) for left, 1 byte for right */940 /* stereo: 1 byte (2 samples) for left, 1 byte for right */
944 for (int ch = 0; ch < avctx->channels; ch++) {941 for (int ch = 0; ch < channels; ch++) {
945 int t1, t2;942 int t1, t2;
946 t1 = adpcm_ima_compress_sample(&c->status[ch], *samples++);943 t1 = adpcm_ima_compress_sample(&c->status[ch], *samples++);
947 t2 = adpcm_ima_compress_sample(&c->status[ch], samples[st]);944 t2 = adpcm_ima_compress_sample(&c->status[ch], samples[st]);
948 put_bits(&pb, 4, t2);945 put_bits(&pb, 4, t2);
949 put_bits(&pb, 4, t1);946 put_bits(&pb, 4, t1);
950 }947 }
951 samples += avctx->channels;948 samples += channels;
952 }949 }
953 flush_put_bits(&pb);950 flush_put_bits(&pb);
954 ) /* End of CASE */951 ) /* End of CASE */
@@ -968,6 +965,12 @@ static const enum AVSampleFormat sample_fmts_p[] = { · 13 unmodified lines
968 AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE965 AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE
969};966};
970 967
968static const AVChannelLayout ch_layouts[] = {
969 AV_CHANNEL_LAYOUT_MONO,
970 AV_CHANNEL_LAYOUT_STEREO,
971 { 0 },
972};
973
971static const AVOption options[] = {974static const AVOption options[] = {
972 {975 {
973 .name = "block_size",976 .name = "block_size",
@@ -1001,6 +1004,7 @@ const AVCodec ff_ ## name_ ## _encoder = { \ · 27 unmodified lines
1001 .encode2 = adpcm_encode_frame, \1004 .encode2 = adpcm_encode_frame, \
1002 .close = adpcm_encode_close, \1005 .close = adpcm_encode_close, \
1003 .sample_fmts = sample_fmts_, \1006 .sample_fmts = sample_fmts_, \
1007 .ch_layouts = ch_layouts, \
1004 .capabilities = capabilities_ | AV_CODEC_CAP_DR1, \1008 .capabilities = capabilities_ | AV_CODEC_CAP_DR1, \
1005 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE, \1009 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE, \
1006 .priv_class = &adpcm_encoder_class, \1010 .priv_class = &adpcm_encoder_class, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t