...
|
...
|
@@ -184,7 +184,6 @@ typedef struct WMAProDecodeCtx {
|
184
|
184
|
uint8_t bits_per_sample; ///< integer audio sample size for the unscaled IMDCT output (used to scale to [-1.0, 1.0])
|
185
|
185
|
uint16_t samples_per_frame; ///< number of samples to output
|
186
|
186
|
uint16_t log2_frame_size;
|
187
|
|
- int8_t num_channels; ///< number of channels in the stream (same as AVCodecContext.num_channels)
|
188
|
187
|
int8_t lfe_channel; ///< lfe channel index
|
189
|
188
|
uint8_t max_num_subframes;
|
190
|
189
|
uint8_t subframe_len_bits; ///< number of bits used for the subframe length
|
...
|
...
|
@@ -246,7 +245,7 @@ static av_cold void dump_context(WMAProDecodeCtx *s)
|
246
|
246
|
PRINT("log2 frame size", s->log2_frame_size);
|
247
|
247
|
PRINT("max num subframes", s->max_num_subframes);
|
248
|
248
|
PRINT("len prefix", s->len_prefix);
|
249
|
|
- PRINT("num channels", s->num_channels);
|
|
249
|
+ PRINT("num channels", s->avctx->channels);
|
250
|
250
|
}
|
251
|
251
|
|
252
|
252
|
/**
|
...
|
...
|
@@ -337,18 +336,17 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
337
|
337
|
return AVERROR_INVALIDDATA;
|
338
|
338
|
}
|
339
|
339
|
|
340
|
|
- s->num_channels = avctx->channels;
|
341
|
|
-
|
342
|
|
- if (s->num_channels < 0) {
|
343
|
|
- av_log(avctx, AV_LOG_ERROR, "invalid number of channels %d\n", s->num_channels);
|
|
340
|
+ if (avctx->channels < 0) {
|
|
341
|
+ av_log(avctx, AV_LOG_ERROR, "invalid number of channels %d\n",
|
|
342
|
+ avctx->channels);
|
344
|
343
|
return AVERROR_INVALIDDATA;
|
345
|
|
- } else if (s->num_channels > WMAPRO_MAX_CHANNELS) {
|
|
344
|
+ } else if (avctx->channels > WMAPRO_MAX_CHANNELS) {
|
346
|
345
|
av_log_ask_for_sample(avctx, "unsupported number of channels\n");
|
347
|
346
|
return AVERROR_PATCHWELCOME;
|
348
|
347
|
}
|
349
|
348
|
|
350
|
349
|
/** init previous block len */
|
351
|
|
- for (i = 0; i < s->num_channels; i++)
|
|
350
|
+ for (i = 0; i < avctx->channels; i++)
|
352
|
351
|
s->channel[i].prev_block_len = s->samples_per_frame;
|
353
|
352
|
|
354
|
353
|
/** extract lfe channel position */
|
...
|
...
|
@@ -525,7 +523,7 @@ static int decode_tilehdr(WMAProDecodeCtx *s)
|
525
|
525
|
{
|
526
|
526
|
uint16_t num_samples[WMAPRO_MAX_CHANNELS] = { 0 };/**< sum of samples for all currently known subframes of a channel */
|
527
|
527
|
uint8_t contains_subframe[WMAPRO_MAX_CHANNELS]; /**< flag indicating if a channel contains the current subframe */
|
528
|
|
- int channels_for_cur_subframe = s->num_channels; /**< number of channels that contain the current subframe */
|
|
528
|
+ int channels_for_cur_subframe = s->avctx->channels; /**< number of channels that contain the current subframe */
|
529
|
529
|
int fixed_channel_layout = 0; /**< flag indicating that all channels use the same subframe offsets and sizes */
|
530
|
530
|
int min_channel_len = 0; /**< smallest sum of samples (channels with this length will be processed first) */
|
531
|
531
|
int c;
|
...
|
...
|
@@ -537,7 +535,7 @@ static int decode_tilehdr(WMAProDecodeCtx *s)
|
537
|
537
|
*/
|
538
|
538
|
|
539
|
539
|
/** reset tiling information */
|
540
|
|
- for (c = 0; c < s->num_channels; c++)
|
|
540
|
+ for (c = 0; c < s->avctx->channels; c++)
|
541
|
541
|
s->channel[c].num_subframes = 0;
|
542
|
542
|
|
543
|
543
|
if (s->max_num_subframes == 1 || get_bits1(&s->gb))
|
...
|
...
|
@@ -548,7 +546,7 @@ static int decode_tilehdr(WMAProDecodeCtx *s)
|
548
|
548
|
int subframe_len;
|
549
|
549
|
|
550
|
550
|
/** check which channels contain the subframe */
|
551
|
|
- for (c = 0; c < s->num_channels; c++) {
|
|
551
|
+ for (c = 0; c < s->avctx->channels; c++) {
|
552
|
552
|
if (num_samples[c] == min_channel_len) {
|
553
|
553
|
if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
|
554
|
554
|
(min_channel_len == s->samples_per_frame - s->min_samples_per_subframe))
|
...
|
...
|
@@ -565,7 +563,7 @@ static int decode_tilehdr(WMAProDecodeCtx *s)
|
565
|
565
|
|
566
|
566
|
/** add subframes to the individual channels and find new min_channel_len */
|
567
|
567
|
min_channel_len += subframe_len;
|
568
|
|
- for (c = 0; c < s->num_channels; c++) {
|
|
568
|
+ for (c = 0; c < s->avctx->channels; c++) {
|
569
|
569
|
WMAProChannelCtx* chan = &s->channel[c];
|
570
|
570
|
|
571
|
571
|
if (contains_subframe[c]) {
|
...
|
...
|
@@ -592,7 +590,7 @@ static int decode_tilehdr(WMAProDecodeCtx *s)
|
592
|
592
|
}
|
593
|
593
|
} while (min_channel_len < s->samples_per_frame);
|
594
|
594
|
|
595
|
|
- for (c = 0; c < s->num_channels; c++) {
|
|
595
|
+ for (c = 0; c < s->avctx->channels; c++) {
|
596
|
596
|
int i;
|
597
|
597
|
int offset = 0;
|
598
|
598
|
for (i = 0; i < s->channel[c].num_subframes; i++) {
|
...
|
...
|
@@ -618,8 +616,8 @@ static void decode_decorrelation_matrix(WMAProDecodeCtx *s,
|
618
|
618
|
int i;
|
619
|
619
|
int offset = 0;
|
620
|
620
|
int8_t rotation_offset[WMAPRO_MAX_CHANNELS * WMAPRO_MAX_CHANNELS];
|
621
|
|
- memset(chgroup->decorrelation_matrix, 0, s->num_channels *
|
622
|
|
- s->num_channels * sizeof(*chgroup->decorrelation_matrix));
|
|
621
|
+ memset(chgroup->decorrelation_matrix, 0, s->avctx->channels *
|
|
622
|
+ s->avctx->channels * sizeof(*chgroup->decorrelation_matrix));
|
623
|
623
|
|
624
|
624
|
for (i = 0; i < chgroup->num_channels * (chgroup->num_channels - 1) >> 1; i++)
|
625
|
625
|
rotation_offset[i] = get_bits(&s->gb, 6);
|
...
|
...
|
@@ -672,7 +670,7 @@ static int decode_channel_transform(WMAProDecodeCtx* s)
|
672
|
672
|
|
673
|
673
|
/** in the one channel case channel transforms are pointless */
|
674
|
674
|
s->num_chgroups = 0;
|
675
|
|
- if (s->num_channels > 1) {
|
|
675
|
+ if (s->avctx->channels > 1) {
|
676
|
676
|
int remaining_channels = s->channels_for_cur_subframe;
|
677
|
677
|
|
678
|
678
|
if (get_bits1(&s->gb)) {
|
...
|
...
|
@@ -718,7 +716,7 @@ static int decode_channel_transform(WMAProDecodeCtx* s)
|
718
|
718
|
}
|
719
|
719
|
} else {
|
720
|
720
|
chgroup->transform = 1;
|
721
|
|
- if (s->num_channels == 2) {
|
|
721
|
+ if (s->avctx->channels == 2) {
|
722
|
722
|
chgroup->decorrelation_matrix[0] = 1.0;
|
723
|
723
|
chgroup->decorrelation_matrix[1] = -1.0;
|
724
|
724
|
chgroup->decorrelation_matrix[2] = 1.0;
|
...
|
...
|
@@ -1008,7 +1006,7 @@ static void inverse_channel_transform(WMAProDecodeCtx *s)
|
1008
|
1008
|
(*ch)[y] = sum;
|
1009
|
1009
|
}
|
1010
|
1010
|
}
|
1011
|
|
- } else if (s->num_channels == 2) {
|
|
1011
|
+ } else if (s->avctx->channels == 2) {
|
1012
|
1012
|
int len = FFMIN(sfb[1], s->subframe_len) - sfb[0];
|
1013
|
1013
|
s->dsp.vector_fmul_scalar(ch_data[0] + sfb[0],
|
1014
|
1014
|
ch_data[0] + sfb[0],
|
...
|
...
|
@@ -1061,7 +1059,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
|
1061
|
1061
|
int offset = s->samples_per_frame;
|
1062
|
1062
|
int subframe_len = s->samples_per_frame;
|
1063
|
1063
|
int i;
|
1064
|
|
- int total_samples = s->samples_per_frame * s->num_channels;
|
|
1064
|
+ int total_samples = s->samples_per_frame * s->avctx->channels;
|
1065
|
1065
|
int transmit_coeffs = 0;
|
1066
|
1066
|
int cur_subwoofer_cutoff;
|
1067
|
1067
|
|
...
|
...
|
@@ -1071,7 +1069,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
|
1071
|
1071
|
== the next block of the channel with the smallest number of
|
1072
|
1072
|
decoded samples
|
1073
|
1073
|
*/
|
1074
|
|
- for (i = 0; i < s->num_channels; i++) {
|
|
1074
|
+ for (i = 0; i < s->avctx->channels; i++) {
|
1075
|
1075
|
s->channel[i].grouped = 0;
|
1076
|
1076
|
if (offset > s->channel[i].decoded_samples) {
|
1077
|
1077
|
offset = s->channel[i].decoded_samples;
|
...
|
...
|
@@ -1085,7 +1083,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
|
1085
|
1085
|
|
1086
|
1086
|
/** get a list of all channels that contain the estimated block */
|
1087
|
1087
|
s->channels_for_cur_subframe = 0;
|
1088
|
|
- for (i = 0; i < s->num_channels; i++) {
|
|
1088
|
+ for (i = 0; i < s->avctx->channels; i++) {
|
1089
|
1089
|
const int cur_subframe = s->channel[i].cur_subframe;
|
1090
|
1090
|
/** substract already processed samples */
|
1091
|
1091
|
total_samples -= s->channel[i].decoded_samples;
|
...
|
...
|
@@ -1314,9 +1312,9 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
|
1314
|
1314
|
}
|
1315
|
1315
|
|
1316
|
1316
|
/** read postproc transform */
|
1317
|
|
- if (s->num_channels > 1 && get_bits1(gb)) {
|
|
1317
|
+ if (s->avctx->channels > 1 && get_bits1(gb)) {
|
1318
|
1318
|
if (get_bits1(gb)) {
|
1319
|
|
- for (i = 0; i < s->num_channels * s->num_channels; i++)
|
|
1319
|
+ for (i = 0; i < avctx->channels * avctx->channels; i++)
|
1320
|
1320
|
skip_bits(gb, 4);
|
1321
|
1321
|
}
|
1322
|
1322
|
}
|
...
|
...
|
@@ -1351,7 +1349,7 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
|
1351
|
1351
|
|
1352
|
1352
|
/** reset subframe states */
|
1353
|
1353
|
s->parsed_all_subframes = 0;
|
1354
|
|
- for (i = 0; i < s->num_channels; i++) {
|
|
1354
|
+ for (i = 0; i < avctx->channels; i++) {
|
1355
|
1355
|
s->channel[i].decoded_samples = 0;
|
1356
|
1356
|
s->channel[i].cur_subframe = 0;
|
1357
|
1357
|
s->channel[i].reuse_sf = 0;
|
...
|
...
|
@@ -1374,11 +1372,11 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
|
1374
|
1374
|
}
|
1375
|
1375
|
|
1376
|
1376
|
/** copy samples to the output buffer */
|
1377
|
|
- for (i = 0; i < s->num_channels; i++)
|
|
1377
|
+ for (i = 0; i < avctx->channels; i++)
|
1378
|
1378
|
memcpy(s->frame.extended_data[i], s->channel[i].out,
|
1379
|
1379
|
s->samples_per_frame * sizeof(*s->channel[i].out));
|
1380
|
1380
|
|
1381
|
|
- for (i = 0; i < s->num_channels; i++) {
|
|
1381
|
+ for (i = 0; i < avctx->channels; i++) {
|
1382
|
1382
|
/** reuse second half of the IMDCT output for the next frame */
|
1383
|
1383
|
memcpy(&s->channel[i].out[0],
|
1384
|
1384
|
&s->channel[i].out[s->samples_per_frame],
|
...
|
...
|
@@ -1608,7 +1606,7 @@ static void flush(AVCodecContext *avctx)
|
1608
|
1608
|
int i;
|
1609
|
1609
|
/** reset output buffer as a part of it is used during the windowing of a
|
1610
|
1610
|
new frame */
|
1611
|
|
- for (i = 0; i < s->num_channels; i++)
|
|
1611
|
+ for (i = 0; i < avctx->channels; i++)
|
1612
|
1612
|
memset(s->channel[i].out, 0, s->samples_per_frame *
|
1613
|
1613
|
sizeof(*s->channel[i].out));
|
1614
|
1614
|
s->packet_loss = 1;
|