00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "libavutil/attributes.h"
00026 #include "avcodec.h"
00027 #include "internal.h"
00028 #include "get_bits.h"
00029 #include "put_bits.h"
00030 #include "wma.h"
00031 #include "wma_common.h"
00032
00034 #define WMALL_MAX_CHANNELS 8
00035 #define MAX_SUBFRAMES 32
00036 #define MAX_BANDS 29
00037 #define MAX_FRAMESIZE 32768
00038 #define MAX_ORDER 256
00039
00040 #define WMALL_BLOCK_MIN_BITS 6
00041 #define WMALL_BLOCK_MAX_BITS 12
00042 #define WMALL_BLOCK_MAX_SIZE (1 << WMALL_BLOCK_MAX_BITS)
00043 #define WMALL_BLOCK_SIZES (WMALL_BLOCK_MAX_BITS - WMALL_BLOCK_MIN_BITS + 1)
00044
00045
00049 typedef struct {
00050 int16_t prev_block_len;
00051 uint8_t transmit_coefs;
00052 uint8_t num_subframes;
00053 uint16_t subframe_len[MAX_SUBFRAMES];
00054 uint16_t subframe_offsets[MAX_SUBFRAMES];
00055 uint8_t cur_subframe;
00056 uint16_t decoded_samples;
00057 int quant_step;
00058 int transient_counter;
00059 } WmallChannelCtx;
00060
00064 typedef struct WmallDecodeCtx {
00065
00066 AVCodecContext *avctx;
00067 AVFrame frame;
00068 uint8_t frame_data[MAX_FRAMESIZE + FF_INPUT_BUFFER_PADDING_SIZE];
00069 PutBitContext pb;
00070
00071
00072 uint32_t decode_flags;
00073 int len_prefix;
00074 int dynamic_range_compression;
00075 uint8_t bits_per_sample;
00076 uint16_t samples_per_frame;
00077 uint16_t log2_frame_size;
00078 int8_t num_channels;
00079 int8_t lfe_channel;
00080 uint8_t max_num_subframes;
00081 uint8_t subframe_len_bits;
00082 uint8_t max_subframe_len_bit;
00083 uint16_t min_samples_per_subframe;
00084
00085
00086 GetBitContext pgb;
00087 int next_packet_start;
00088 uint8_t packet_offset;
00089 uint8_t packet_sequence_number;
00090 int num_saved_bits;
00091 int frame_offset;
00092 int subframe_offset;
00093 uint8_t packet_loss;
00094 uint8_t packet_done;
00095
00096
00097 uint32_t frame_num;
00098 GetBitContext gb;
00099 int buf_bit_size;
00100 int16_t *samples_16[WMALL_MAX_CHANNELS];
00101 int32_t *samples_32[WMALL_MAX_CHANNELS];
00102 uint8_t drc_gain;
00103 int8_t skip_frame;
00104 int8_t parsed_all_subframes;
00105
00106
00107 int16_t subframe_len;
00108 int8_t channels_for_cur_subframe;
00109 int8_t channel_indexes_for_cur_subframe[WMALL_MAX_CHANNELS];
00110
00111 WmallChannelCtx channel[WMALL_MAX_CHANNELS];
00112
00113
00114
00115 uint8_t do_arith_coding;
00116 uint8_t do_ac_filter;
00117 uint8_t do_inter_ch_decorr;
00118 uint8_t do_mclms;
00119 uint8_t do_lpc;
00120
00121 int8_t acfilter_order;
00122 int8_t acfilter_scaling;
00123 int64_t acfilter_coeffs[16];
00124 int acfilter_prevvalues[2][16];
00125
00126 int8_t mclms_order;
00127 int8_t mclms_scaling;
00128 int16_t mclms_coeffs[128];
00129 int16_t mclms_coeffs_cur[4];
00130 int16_t mclms_prevvalues[WMALL_MAX_CHANNELS * 2 * 32];
00131 int16_t mclms_updates[WMALL_MAX_CHANNELS * 2 * 32];
00132 int mclms_recent;
00133
00134 int movave_scaling;
00135 int quant_stepsize;
00136
00137 struct {
00138 int order;
00139 int scaling;
00140 int coefsend;
00141 int bitsend;
00142 int16_t coefs[MAX_ORDER];
00143 int16_t lms_prevvalues[MAX_ORDER * 2];
00144 int16_t lms_updates[MAX_ORDER * 2];
00145 int recent;
00146 } cdlms[2][9];
00147
00148 int cdlms_ttl[2];
00149
00150 int bV3RTM;
00151
00152 int is_channel_coded[2];
00153 int update_speed[2];
00154
00155 int transient[2];
00156 int transient_pos[2];
00157 int seekable_tile;
00158
00159 int ave_sum[2];
00160
00161 int channel_residues[2][WMALL_BLOCK_MAX_SIZE];
00162
00163 int lpc_coefs[2][40];
00164 int lpc_order;
00165 int lpc_scaling;
00166 int lpc_intbits;
00167
00168 int channel_coeffs[2][WMALL_BLOCK_MAX_SIZE];
00169 } WmallDecodeCtx;
00170
00171
00172 static av_cold int decode_init(AVCodecContext *avctx)
00173 {
00174 WmallDecodeCtx *s = avctx->priv_data;
00175 uint8_t *edata_ptr = avctx->extradata;
00176 unsigned int channel_mask;
00177 int i, bits, log2_max_num_subframes;
00178
00179 s->avctx = avctx;
00180 init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
00181
00182 if (avctx->extradata_size >= 18) {
00183 s->decode_flags = AV_RL16(edata_ptr + 14);
00184 channel_mask = AV_RL32(edata_ptr + 2);
00185 s->bits_per_sample = AV_RL16(edata_ptr);
00186 if (s->bits_per_sample == 16)
00187 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
00188 else if (s->bits_per_sample == 24) {
00189 avctx->sample_fmt = AV_SAMPLE_FMT_S32;
00190 av_log_missing_feature(avctx, "bit-depth higher than 16", 0);
00191 return AVERROR_PATCHWELCOME;
00192 } else {
00193 av_log(avctx, AV_LOG_ERROR, "Unknown bit-depth: %d\n",
00194 s->bits_per_sample);
00195 return AVERROR_INVALIDDATA;
00196 }
00197
00198 for (i = 0; i < avctx->extradata_size; i++)
00199 av_dlog(avctx, "[%x] ", avctx->extradata[i]);
00200 av_dlog(avctx, "\n");
00201
00202 } else {
00203 av_log_ask_for_sample(avctx, "Unsupported extradata size\n");
00204 return AVERROR_INVALIDDATA;
00205 }
00206
00207
00208 s->log2_frame_size = av_log2(avctx->block_align) + 4;
00209
00210
00211 s->skip_frame = 1;
00212 s->packet_loss = 1;
00213 s->len_prefix = s->decode_flags & 0x40;
00214
00215
00216 bits = ff_wma_get_frame_len_bits(avctx->sample_rate, 3, s->decode_flags);
00217 if (bits > WMALL_BLOCK_MAX_BITS) {
00218 av_log_missing_feature(avctx, "big-bits block sizes", 1);
00219 return AVERROR_INVALIDDATA;
00220 }
00221 s->samples_per_frame = 1 << bits;
00222
00223
00224 for (i = 0; i < avctx->channels; i++)
00225 s->channel[i].prev_block_len = s->samples_per_frame;
00226
00227
00228 log2_max_num_subframes = (s->decode_flags & 0x38) >> 3;
00229 s->max_num_subframes = 1 << log2_max_num_subframes;
00230 s->max_subframe_len_bit = 0;
00231 s->subframe_len_bits = av_log2(log2_max_num_subframes) + 1;
00232
00233 s->min_samples_per_subframe = s->samples_per_frame / s->max_num_subframes;
00234 s->dynamic_range_compression = s->decode_flags & 0x80;
00235 s->bV3RTM = s->decode_flags & 0x100;
00236
00237 if (s->max_num_subframes > MAX_SUBFRAMES) {
00238 av_log(avctx, AV_LOG_ERROR, "invalid number of subframes %i\n",
00239 s->max_num_subframes);
00240 return AVERROR_INVALIDDATA;
00241 }
00242
00243 s->num_channels = avctx->channels;
00244
00245
00246 s->lfe_channel = -1;
00247
00248 if (channel_mask & 8) {
00249 unsigned int mask;
00250 for (mask = 1; mask < 16; mask <<= 1)
00251 if (channel_mask & mask)
00252 ++s->lfe_channel;
00253 }
00254
00255 if (s->num_channels < 0) {
00256 av_log(avctx, AV_LOG_ERROR, "invalid number of channels %d\n",
00257 s->num_channels);
00258 return AVERROR_INVALIDDATA;
00259 } else if (s->num_channels > WMALL_MAX_CHANNELS) {
00260 av_log_ask_for_sample(avctx, "unsupported number of channels\n");
00261 return AVERROR_PATCHWELCOME;
00262 }
00263
00264 avcodec_get_frame_defaults(&s->frame);
00265 avctx->coded_frame = &s->frame;
00266 avctx->channel_layout = channel_mask;
00267 return 0;
00268 }
00269
00276 static int decode_subframe_length(WmallDecodeCtx *s, int offset)
00277 {
00278 int frame_len_ratio, subframe_len, len;
00279
00280
00281 if (offset == s->samples_per_frame - s->min_samples_per_subframe)
00282 return s->min_samples_per_subframe;
00283
00284 len = av_log2(s->max_num_subframes - 1) + 1;
00285 frame_len_ratio = get_bits(&s->gb, len);
00286 subframe_len = s->min_samples_per_subframe * (frame_len_ratio + 1);
00287
00288
00289 if (subframe_len < s->min_samples_per_subframe ||
00290 subframe_len > s->samples_per_frame) {
00291 av_log(s->avctx, AV_LOG_ERROR, "broken frame: subframe_len %i\n",
00292 subframe_len);
00293 return AVERROR_INVALIDDATA;
00294 }
00295 return subframe_len;
00296 }
00297
00318 static int decode_tilehdr(WmallDecodeCtx *s)
00319 {
00320 uint16_t num_samples[WMALL_MAX_CHANNELS] = { 0 };
00321 uint8_t contains_subframe[WMALL_MAX_CHANNELS];
00322 int channels_for_cur_subframe = s->num_channels;
00323 int fixed_channel_layout = 0;
00324 int min_channel_len = 0;
00325 int c, tile_aligned;
00326
00327
00328 for (c = 0; c < s->num_channels; c++)
00329 s->channel[c].num_subframes = 0;
00330
00331 tile_aligned = get_bits1(&s->gb);
00332 if (s->max_num_subframes == 1 || tile_aligned)
00333 fixed_channel_layout = 1;
00334
00335
00336 do {
00337 int subframe_len, in_use = 0;
00338
00339
00340 for (c = 0; c < s->num_channels; c++) {
00341 if (num_samples[c] == min_channel_len) {
00342 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
00343 (min_channel_len == s->samples_per_frame - s->min_samples_per_subframe)) {
00344 contains_subframe[c] = in_use = 1;
00345 } else {
00346 if (get_bits1(&s->gb))
00347 contains_subframe[c] = in_use = 1;
00348 }
00349 } else
00350 contains_subframe[c] = 0;
00351 }
00352
00353 if (!in_use) {
00354 av_log(s->avctx, AV_LOG_ERROR,
00355 "Found empty subframe\n");
00356 return AVERROR_INVALIDDATA;
00357 }
00358
00359
00360 if ((subframe_len = decode_subframe_length(s, min_channel_len)) <= 0)
00361 return AVERROR_INVALIDDATA;
00362
00363 min_channel_len += subframe_len;
00364 for (c = 0; c < s->num_channels; c++) {
00365 WmallChannelCtx *chan = &s->channel[c];
00366
00367 if (contains_subframe[c]) {
00368 if (chan->num_subframes >= MAX_SUBFRAMES) {
00369 av_log(s->avctx, AV_LOG_ERROR,
00370 "broken frame: num subframes > 31\n");
00371 return AVERROR_INVALIDDATA;
00372 }
00373 chan->subframe_len[chan->num_subframes] = subframe_len;
00374 num_samples[c] += subframe_len;
00375 ++chan->num_subframes;
00376 if (num_samples[c] > s->samples_per_frame) {
00377 av_log(s->avctx, AV_LOG_ERROR, "broken frame: "
00378 "channel len(%d) > samples_per_frame(%d)\n",
00379 num_samples[c], s->samples_per_frame);
00380 return AVERROR_INVALIDDATA;
00381 }
00382 } else if (num_samples[c] <= min_channel_len) {
00383 if (num_samples[c] < min_channel_len) {
00384 channels_for_cur_subframe = 0;
00385 min_channel_len = num_samples[c];
00386 }
00387 ++channels_for_cur_subframe;
00388 }
00389 }
00390 } while (min_channel_len < s->samples_per_frame);
00391
00392 for (c = 0; c < s->num_channels; c++) {
00393 int i, offset = 0;
00394 for (i = 0; i < s->channel[c].num_subframes; i++) {
00395 s->channel[c].subframe_offsets[i] = offset;
00396 offset += s->channel[c].subframe_len[i];
00397 }
00398 }
00399
00400 return 0;
00401 }
00402
00403 static void decode_ac_filter(WmallDecodeCtx *s)
00404 {
00405 int i;
00406 s->acfilter_order = get_bits(&s->gb, 4) + 1;
00407 s->acfilter_scaling = get_bits(&s->gb, 4);
00408
00409 for (i = 0; i < s->acfilter_order; i++)
00410 s->acfilter_coeffs[i] = (s->acfilter_scaling ? get_bits(&s->gb, s->acfilter_scaling) : 0) + 1;
00411 }
00412
00413 static void decode_mclms(WmallDecodeCtx *s)
00414 {
00415 s->mclms_order = (get_bits(&s->gb, 4) + 1) * 2;
00416 s->mclms_scaling = get_bits(&s->gb, 4);
00417 if (get_bits1(&s->gb)) {
00418 int i, send_coef_bits;
00419 int cbits = av_log2(s->mclms_scaling + 1);
00420 if (1 << cbits < s->mclms_scaling + 1)
00421 cbits++;
00422
00423 send_coef_bits = (cbits ? get_bits(&s->gb, cbits) : 0) + 2;
00424
00425 for (i = 0; i < s->mclms_order * s->num_channels * s->num_channels; i++)
00426 s->mclms_coeffs[i] = get_bits(&s->gb, send_coef_bits);
00427
00428 for (i = 0; i < s->num_channels; i++) {
00429 int c;
00430 for (c = 0; c < i; c++)
00431 s->mclms_coeffs_cur[i * s->num_channels + c] = get_bits(&s->gb, send_coef_bits);
00432 }
00433 }
00434 }
00435
00436 static int decode_cdlms(WmallDecodeCtx *s)
00437 {
00438 int c, i;
00439 int cdlms_send_coef = get_bits1(&s->gb);
00440
00441 for (c = 0; c < s->num_channels; c++) {
00442 s->cdlms_ttl[c] = get_bits(&s->gb, 3) + 1;
00443 for (i = 0; i < s->cdlms_ttl[c]; i++) {
00444 s->cdlms[c][i].order = (get_bits(&s->gb, 7) + 1) * 8;
00445 if (s->cdlms[c][i].order > MAX_ORDER) {
00446 av_log(s->avctx, AV_LOG_ERROR,
00447 "Order[%d][%d] %d > max (%d), not supported\n",
00448 c, i, s->cdlms[c][i].order, MAX_ORDER);
00449 s->cdlms[0][0].order = 0;
00450 return AVERROR_INVALIDDATA;
00451 }
00452 }
00453
00454 for (i = 0; i < s->cdlms_ttl[c]; i++)
00455 s->cdlms[c][i].scaling = get_bits(&s->gb, 4);
00456
00457 if (cdlms_send_coef) {
00458 for (i = 0; i < s->cdlms_ttl[c]; i++) {
00459 int cbits, shift_l, shift_r, j;
00460 cbits = av_log2(s->cdlms[c][i].order);
00461 if ((1 << cbits) < s->cdlms[c][i].order)
00462 cbits++;
00463 s->cdlms[c][i].coefsend = get_bits(&s->gb, cbits) + 1;
00464
00465 cbits = av_log2(s->cdlms[c][i].scaling + 1);
00466 if ((1 << cbits) < s->cdlms[c][i].scaling + 1)
00467 cbits++;
00468
00469 s->cdlms[c][i].bitsend = get_bits(&s->gb, cbits) + 2;
00470 shift_l = 32 - s->cdlms[c][i].bitsend;
00471 shift_r = 32 - s->cdlms[c][i].scaling - 2;
00472 for (j = 0; j < s->cdlms[c][i].coefsend; j++)
00473 s->cdlms[c][i].coefs[j] =
00474 (get_bits(&s->gb, s->cdlms[c][i].bitsend) << shift_l) >> shift_r;
00475 }
00476 }
00477 }
00478
00479 return 0;
00480 }
00481
00482 static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size)
00483 {
00484 int i = 0;
00485 unsigned int ave_mean;
00486 s->transient[ch] = get_bits1(&s->gb);
00487 if (s->transient[ch]) {
00488 s->transient_pos[ch] = get_bits(&s->gb, av_log2(tile_size));
00489 if (s->transient_pos[ch])
00490 s->transient[ch] = 0;
00491 s->channel[ch].transient_counter =
00492 FFMAX(s->channel[ch].transient_counter, s->samples_per_frame / 2);
00493 } else if (s->channel[ch].transient_counter)
00494 s->transient[ch] = 1;
00495
00496 if (s->seekable_tile) {
00497 ave_mean = get_bits(&s->gb, s->bits_per_sample);
00498 s->ave_sum[ch] = ave_mean << (s->movave_scaling + 1);
00499 }
00500
00501 if (s->seekable_tile) {
00502 if (s->do_inter_ch_decorr)
00503 s->channel_residues[ch][0] = get_sbits_long(&s->gb, s->bits_per_sample + 1);
00504 else
00505 s->channel_residues[ch][0] = get_sbits_long(&s->gb, s->bits_per_sample);
00506 i++;
00507 }
00508 for (; i < tile_size; i++) {
00509 int quo = 0, rem, rem_bits, residue;
00510 while(get_bits1(&s->gb)) {
00511 quo++;
00512 if (get_bits_left(&s->gb) <= 0)
00513 return -1;
00514 }
00515 if (quo >= 32)
00516 quo += get_bits_long(&s->gb, get_bits(&s->gb, 5) + 1);
00517
00518 ave_mean = (s->ave_sum[ch] + (1 << s->movave_scaling)) >> (s->movave_scaling + 1);
00519 if (ave_mean <= 1)
00520 residue = quo;
00521 else {
00522 rem_bits = av_ceil_log2(ave_mean);
00523 rem = get_bits_long(&s->gb, rem_bits);
00524 residue = (quo << rem_bits) + rem;
00525 }
00526
00527 s->ave_sum[ch] = residue + s->ave_sum[ch] -
00528 (s->ave_sum[ch] >> s->movave_scaling);
00529
00530 if (residue & 1)
00531 residue = -(residue >> 1) - 1;
00532 else
00533 residue = residue >> 1;
00534 s->channel_residues[ch][i] = residue;
00535 }
00536
00537 return 0;
00538
00539 }
00540
00541 static void decode_lpc(WmallDecodeCtx *s)
00542 {
00543 int ch, i, cbits;
00544 s->lpc_order = get_bits(&s->gb, 5) + 1;
00545 s->lpc_scaling = get_bits(&s->gb, 4);
00546 s->lpc_intbits = get_bits(&s->gb, 3) + 1;
00547 cbits = s->lpc_scaling + s->lpc_intbits;
00548 for (ch = 0; ch < s->num_channels; ch++)
00549 for (i = 0; i < s->lpc_order; i++)
00550 s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits);
00551 }
00552
00553 static void clear_codec_buffers(WmallDecodeCtx *s)
00554 {
00555 int ich, ilms;
00556
00557 memset(s->acfilter_coeffs, 0, sizeof(s->acfilter_coeffs));
00558 memset(s->acfilter_prevvalues, 0, sizeof(s->acfilter_prevvalues));
00559 memset(s->lpc_coefs, 0, sizeof(s->lpc_coefs));
00560
00561 memset(s->mclms_coeffs, 0, sizeof(s->mclms_coeffs));
00562 memset(s->mclms_coeffs_cur, 0, sizeof(s->mclms_coeffs_cur));
00563 memset(s->mclms_prevvalues, 0, sizeof(s->mclms_prevvalues));
00564 memset(s->mclms_updates, 0, sizeof(s->mclms_updates));
00565
00566 for (ich = 0; ich < s->num_channels; ich++) {
00567 for (ilms = 0; ilms < s->cdlms_ttl[ich]; ilms++) {
00568 memset(s->cdlms[ich][ilms].coefs, 0,
00569 sizeof(s->cdlms[ich][ilms].coefs));
00570 memset(s->cdlms[ich][ilms].lms_prevvalues, 0,
00571 sizeof(s->cdlms[ich][ilms].lms_prevvalues));
00572 memset(s->cdlms[ich][ilms].lms_updates, 0,
00573 sizeof(s->cdlms[ich][ilms].lms_updates));
00574 }
00575 s->ave_sum[ich] = 0;
00576 }
00577 }
00578
00582 static void reset_codec(WmallDecodeCtx *s)
00583 {
00584 int ich, ilms;
00585 s->mclms_recent = s->mclms_order * s->num_channels;
00586 for (ich = 0; ich < s->num_channels; ich++) {
00587 for (ilms = 0; ilms < s->cdlms_ttl[ich]; ilms++)
00588 s->cdlms[ich][ilms].recent = s->cdlms[ich][ilms].order;
00589
00590
00591 s->channel[ich].transient_counter = s->samples_per_frame;
00592 s->transient[ich] = 1;
00593 s->transient_pos[ich] = 0;
00594 }
00595 }
00596
00597 static void mclms_update(WmallDecodeCtx *s, int icoef, int *pred)
00598 {
00599 int i, j, ich, pred_error;
00600 int order = s->mclms_order;
00601 int num_channels = s->num_channels;
00602 int range = 1 << (s->bits_per_sample - 1);
00603
00604 for (ich = 0; ich < num_channels; ich++) {
00605 pred_error = s->channel_residues[ich][icoef] - pred[ich];
00606 if (pred_error > 0) {
00607 for (i = 0; i < order * num_channels; i++)
00608 s->mclms_coeffs[i + ich * order * num_channels] +=
00609 s->mclms_updates[s->mclms_recent + i];
00610 for (j = 0; j < ich; j++) {
00611 if (s->channel_residues[j][icoef] > 0)
00612 s->mclms_coeffs_cur[ich * num_channels + j] += 1;
00613 else if (s->channel_residues[j][icoef] < 0)
00614 s->mclms_coeffs_cur[ich * num_channels + j] -= 1;
00615 }
00616 } else if (pred_error < 0) {
00617 for (i = 0; i < order * num_channels; i++)
00618 s->mclms_coeffs[i + ich * order * num_channels] -=
00619 s->mclms_updates[s->mclms_recent + i];
00620 for (j = 0; j < ich; j++) {
00621 if (s->channel_residues[j][icoef] > 0)
00622 s->mclms_coeffs_cur[ich * num_channels + j] -= 1;
00623 else if (s->channel_residues[j][icoef] < 0)
00624 s->mclms_coeffs_cur[ich * num_channels + j] += 1;
00625 }
00626 }
00627 }
00628
00629 for (ich = num_channels - 1; ich >= 0; ich--) {
00630 s->mclms_recent--;
00631 s->mclms_prevvalues[s->mclms_recent] = s->channel_residues[ich][icoef];
00632 if (s->channel_residues[ich][icoef] > range - 1)
00633 s->mclms_prevvalues[s->mclms_recent] = range - 1;
00634 else if (s->channel_residues[ich][icoef] < -range)
00635 s->mclms_prevvalues[s->mclms_recent] = -range;
00636
00637 s->mclms_updates[s->mclms_recent] = 0;
00638 if (s->channel_residues[ich][icoef] > 0)
00639 s->mclms_updates[s->mclms_recent] = 1;
00640 else if (s->channel_residues[ich][icoef] < 0)
00641 s->mclms_updates[s->mclms_recent] = -1;
00642 }
00643
00644 if (s->mclms_recent == 0) {
00645 memcpy(&s->mclms_prevvalues[order * num_channels],
00646 s->mclms_prevvalues,
00647 2 * order * num_channels);
00648 memcpy(&s->mclms_updates[order * num_channels],
00649 s->mclms_updates,
00650 2 * order * num_channels);
00651 s->mclms_recent = num_channels * order;
00652 }
00653 }
00654
00655 static void mclms_predict(WmallDecodeCtx *s, int icoef, int *pred)
00656 {
00657 int ich, i;
00658 int order = s->mclms_order;
00659 int num_channels = s->num_channels;
00660
00661 for (ich = 0; ich < num_channels; ich++) {
00662 pred[ich] = 0;
00663 if (!s->is_channel_coded[ich])
00664 continue;
00665 for (i = 0; i < order * num_channels; i++)
00666 pred[ich] += s->mclms_prevvalues[i + s->mclms_recent] *
00667 s->mclms_coeffs[i + order * num_channels * ich];
00668 for (i = 0; i < ich; i++)
00669 pred[ich] += s->channel_residues[i][icoef] *
00670 s->mclms_coeffs_cur[i + num_channels * ich];
00671 pred[ich] += 1 << s->mclms_scaling - 1;
00672 pred[ich] >>= s->mclms_scaling;
00673 s->channel_residues[ich][icoef] += pred[ich];
00674 }
00675 }
00676
00677 static void revert_mclms(WmallDecodeCtx *s, int tile_size)
00678 {
00679 int icoef, pred[WMALL_MAX_CHANNELS] = { 0 };
00680 for (icoef = 0; icoef < tile_size; icoef++) {
00681 mclms_predict(s, icoef, pred);
00682 mclms_update(s, icoef, pred);
00683 }
00684 }
00685
00686 static int lms_predict(WmallDecodeCtx *s, int ich, int ilms)
00687 {
00688 int pred = 0, icoef;
00689 int recent = s->cdlms[ich][ilms].recent;
00690
00691 for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
00692 pred += s->cdlms[ich][ilms].coefs[icoef] *
00693 s->cdlms[ich][ilms].lms_prevvalues[icoef + recent];
00694
00695 return pred;
00696 }
00697
00698 static void lms_update(WmallDecodeCtx *s, int ich, int ilms,
00699 int input, int residue)
00700 {
00701 int icoef;
00702 int recent = s->cdlms[ich][ilms].recent;
00703 int range = 1 << s->bits_per_sample - 1;
00704
00705 if (residue < 0) {
00706 for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
00707 s->cdlms[ich][ilms].coefs[icoef] -=
00708 s->cdlms[ich][ilms].lms_updates[icoef + recent];
00709 } else if (residue > 0) {
00710 for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
00711 s->cdlms[ich][ilms].coefs[icoef] +=
00712 s->cdlms[ich][ilms].lms_updates[icoef + recent];
00713 }
00714
00715 if (recent)
00716 recent--;
00717 else {
00718 memcpy(&s->cdlms[ich][ilms].lms_prevvalues[s->cdlms[ich][ilms].order],
00719 s->cdlms[ich][ilms].lms_prevvalues,
00720 2 * s->cdlms[ich][ilms].order);
00721 memcpy(&s->cdlms[ich][ilms].lms_updates[s->cdlms[ich][ilms].order],
00722 s->cdlms[ich][ilms].lms_updates,
00723 2 * s->cdlms[ich][ilms].order);
00724 recent = s->cdlms[ich][ilms].order - 1;
00725 }
00726
00727 s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip(input, -range, range - 1);
00728 if (!input)
00729 s->cdlms[ich][ilms].lms_updates[recent] = 0;
00730 else if (input < 0)
00731 s->cdlms[ich][ilms].lms_updates[recent] = -s->update_speed[ich];
00732 else
00733 s->cdlms[ich][ilms].lms_updates[recent] = s->update_speed[ich];
00734
00735 s->cdlms[ich][ilms].lms_updates[recent + (s->cdlms[ich][ilms].order >> 4)] >>= 2;
00736 s->cdlms[ich][ilms].lms_updates[recent + (s->cdlms[ich][ilms].order >> 3)] >>= 1;
00737 s->cdlms[ich][ilms].recent = recent;
00738 }
00739
00740 static void use_high_update_speed(WmallDecodeCtx *s, int ich)
00741 {
00742 int ilms, recent, icoef;
00743 for (ilms = s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
00744 recent = s->cdlms[ich][ilms].recent;
00745 if (s->update_speed[ich] == 16)
00746 continue;
00747 if (s->bV3RTM) {
00748 for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
00749 s->cdlms[ich][ilms].lms_updates[icoef + recent] *= 2;
00750 } else {
00751 for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
00752 s->cdlms[ich][ilms].lms_updates[icoef] *= 2;
00753 }
00754 }
00755 s->update_speed[ich] = 16;
00756 }
00757
00758 static void use_normal_update_speed(WmallDecodeCtx *s, int ich)
00759 {
00760 int ilms, recent, icoef;
00761 for (ilms = s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
00762 recent = s->cdlms[ich][ilms].recent;
00763 if (s->update_speed[ich] == 8)
00764 continue;
00765 if (s->bV3RTM)
00766 for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
00767 s->cdlms[ich][ilms].lms_updates[icoef + recent] /= 2;
00768 else
00769 for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
00770 s->cdlms[ich][ilms].lms_updates[icoef] /= 2;
00771 }
00772 s->update_speed[ich] = 8;
00773 }
00774
00775 static void revert_cdlms(WmallDecodeCtx *s, int ch,
00776 int coef_begin, int coef_end)
00777 {
00778 int icoef, pred, ilms, num_lms, residue, input;
00779
00780 num_lms = s->cdlms_ttl[ch];
00781 for (ilms = num_lms - 1; ilms >= 0; ilms--) {
00782 for (icoef = coef_begin; icoef < coef_end; icoef++) {
00783 pred = 1 << (s->cdlms[ch][ilms].scaling - 1);
00784 residue = s->channel_residues[ch][icoef];
00785 pred += lms_predict(s, ch, ilms);
00786 input = residue + (pred >> s->cdlms[ch][ilms].scaling);
00787 lms_update(s, ch, ilms, input, residue);
00788 s->channel_residues[ch][icoef] = input;
00789 }
00790 }
00791 }
00792
00793 static void revert_inter_ch_decorr(WmallDecodeCtx *s, int tile_size)
00794 {
00795 if (s->num_channels != 2)
00796 return;
00797 else if (s->is_channel_coded[0] || s->is_channel_coded[1]) {
00798 int icoef;
00799 for (icoef = 0; icoef < tile_size; icoef++) {
00800 s->channel_residues[0][icoef] -= s->channel_residues[1][icoef] >> 1;
00801 s->channel_residues[1][icoef] += s->channel_residues[0][icoef];
00802 }
00803 }
00804 }
00805
00806 static void revert_acfilter(WmallDecodeCtx *s, int tile_size)
00807 {
00808 int ich, pred, i, j;
00809 int64_t *filter_coeffs = s->acfilter_coeffs;
00810 int scaling = s->acfilter_scaling;
00811 int order = s->acfilter_order;
00812
00813 for (ich = 0; ich < s->num_channels; ich++) {
00814 int *prevvalues = s->acfilter_prevvalues[ich];
00815 for (i = 0; i < order; i++) {
00816 pred = 0;
00817 for (j = 0; j < order; j++) {
00818 if (i <= j)
00819 pred += filter_coeffs[j] * prevvalues[j - i];
00820 else
00821 pred += s->channel_residues[ich][i - j - 1] * filter_coeffs[j];
00822 }
00823 pred >>= scaling;
00824 s->channel_residues[ich][i] += pred;
00825 }
00826 for (i = order; i < tile_size; i++) {
00827 pred = 0;
00828 for (j = 0; j < order; j++)
00829 pred += s->channel_residues[ich][i - j - 1] * filter_coeffs[j];
00830 pred >>= scaling;
00831 s->channel_residues[ich][i] += pred;
00832 }
00833 for (j = 0; j < order; j++)
00834 prevvalues[j] = s->channel_residues[ich][tile_size - j - 1];
00835 }
00836 }
00837
00838 static int decode_subframe(WmallDecodeCtx *s)
00839 {
00840 int offset = s->samples_per_frame;
00841 int subframe_len = s->samples_per_frame;
00842 int total_samples = s->samples_per_frame * s->num_channels;
00843 int i, j, rawpcm_tile, padding_zeroes, res;
00844
00845 s->subframe_offset = get_bits_count(&s->gb);
00846
00847
00848
00849
00850 for (i = 0; i < s->num_channels; i++) {
00851 if (offset > s->channel[i].decoded_samples) {
00852 offset = s->channel[i].decoded_samples;
00853 subframe_len =
00854 s->channel[i].subframe_len[s->channel[i].cur_subframe];
00855 }
00856 }
00857
00858
00859 s->channels_for_cur_subframe = 0;
00860 for (i = 0; i < s->num_channels; i++) {
00861 const int cur_subframe = s->channel[i].cur_subframe;
00862
00863 total_samples -= s->channel[i].decoded_samples;
00864
00865
00866 if (offset == s->channel[i].decoded_samples &&
00867 subframe_len == s->channel[i].subframe_len[cur_subframe]) {
00868 total_samples -= s->channel[i].subframe_len[cur_subframe];
00869 s->channel[i].decoded_samples +=
00870 s->channel[i].subframe_len[cur_subframe];
00871 s->channel_indexes_for_cur_subframe[s->channels_for_cur_subframe] = i;
00872 ++s->channels_for_cur_subframe;
00873 }
00874 }
00875
00876
00877
00878 if (!total_samples)
00879 s->parsed_all_subframes = 1;
00880
00881
00882 s->seekable_tile = get_bits1(&s->gb);
00883 if (s->seekable_tile) {
00884 clear_codec_buffers(s);
00885
00886 s->do_arith_coding = get_bits1(&s->gb);
00887 if (s->do_arith_coding) {
00888 av_log_missing_feature(s->avctx, "arithmetic coding", 1);
00889 return AVERROR_PATCHWELCOME;
00890 }
00891 s->do_ac_filter = get_bits1(&s->gb);
00892 s->do_inter_ch_decorr = get_bits1(&s->gb);
00893 s->do_mclms = get_bits1(&s->gb);
00894
00895 if (s->do_ac_filter)
00896 decode_ac_filter(s);
00897
00898 if (s->do_mclms)
00899 decode_mclms(s);
00900
00901 if ((res = decode_cdlms(s)) < 0)
00902 return res;
00903 s->movave_scaling = get_bits(&s->gb, 3);
00904 s->quant_stepsize = get_bits(&s->gb, 8) + 1;
00905
00906 reset_codec(s);
00907 } else if (!s->cdlms[0][0].order) {
00908 av_log(s->avctx, AV_LOG_DEBUG,
00909 "Waiting for seekable tile\n");
00910 s->frame.nb_samples = 0;
00911 return -1;
00912 }
00913
00914 rawpcm_tile = get_bits1(&s->gb);
00915
00916 for (i = 0; i < s->num_channels; i++)
00917 s->is_channel_coded[i] = 1;
00918
00919 if (!rawpcm_tile) {
00920 for (i = 0; i < s->num_channels; i++)
00921 s->is_channel_coded[i] = get_bits1(&s->gb);
00922
00923 if (s->bV3RTM) {
00924
00925 s->do_lpc = get_bits1(&s->gb);
00926 if (s->do_lpc) {
00927 decode_lpc(s);
00928 av_log_ask_for_sample(s->avctx, "Inverse LPC filter not "
00929 "implemented. Expect wrong output.\n");
00930 }
00931 } else
00932 s->do_lpc = 0;
00933 }
00934
00935
00936 if (get_bits1(&s->gb))
00937 padding_zeroes = get_bits(&s->gb, 5);
00938 else
00939 padding_zeroes = 0;
00940
00941 if (rawpcm_tile) {
00942 int bits = s->bits_per_sample - padding_zeroes;
00943 if (bits <= 0) {
00944 av_log(s->avctx, AV_LOG_ERROR,
00945 "Invalid number of padding bits in raw PCM tile\n");
00946 return AVERROR_INVALIDDATA;
00947 }
00948 av_dlog(s->avctx, "RAWPCM %d bits per sample. "
00949 "total %d bits, remain=%d\n", bits,
00950 bits * s->num_channels * subframe_len, get_bits_count(&s->gb));
00951 for (i = 0; i < s->num_channels; i++)
00952 for (j = 0; j < subframe_len; j++)
00953 s->channel_coeffs[i][j] = get_sbits_long(&s->gb, bits);
00954 } else {
00955 for (i = 0; i < s->num_channels; i++)
00956 if (s->is_channel_coded[i]) {
00957 decode_channel_residues(s, i, subframe_len);
00958 if (s->seekable_tile)
00959 use_high_update_speed(s, i);
00960 else
00961 use_normal_update_speed(s, i);
00962 revert_cdlms(s, i, 0, subframe_len);
00963 } else {
00964 memset(s->channel_residues[i], 0, sizeof(**s->channel_residues) * subframe_len);
00965 }
00966 }
00967 if (s->do_mclms)
00968 revert_mclms(s, subframe_len);
00969 if (s->do_inter_ch_decorr)
00970 revert_inter_ch_decorr(s, subframe_len);
00971 if (s->do_ac_filter)
00972 revert_acfilter(s, subframe_len);
00973
00974
00975 if (s->quant_stepsize != 1)
00976 for (i = 0; i < s->num_channels; i++)
00977 for (j = 0; j < subframe_len; j++)
00978 s->channel_residues[i][j] *= s->quant_stepsize;
00979
00980
00981 for (i = 0; i < s->channels_for_cur_subframe; i++) {
00982 int c = s->channel_indexes_for_cur_subframe[i];
00983 int subframe_len = s->channel[c].subframe_len[s->channel[c].cur_subframe];
00984
00985 for (j = 0; j < subframe_len; j++) {
00986 if (s->bits_per_sample == 16) {
00987 *s->samples_16[c] = (int16_t) s->channel_residues[c][j] << padding_zeroes;
00988 s->samples_16[c] += s->num_channels;
00989 } else {
00990 *s->samples_32[c] = s->channel_residues[c][j] << padding_zeroes;
00991 s->samples_32[c] += s->num_channels;
00992 }
00993 }
00994 }
00995
00996
00997 for (i = 0; i < s->channels_for_cur_subframe; i++) {
00998 int c = s->channel_indexes_for_cur_subframe[i];
00999 if (s->channel[c].cur_subframe >= s->channel[c].num_subframes) {
01000 av_log(s->avctx, AV_LOG_ERROR, "broken subframe\n");
01001 return AVERROR_INVALIDDATA;
01002 }
01003 ++s->channel[c].cur_subframe;
01004 }
01005 return 0;
01006 }
01007
01014 static int decode_frame(WmallDecodeCtx *s)
01015 {
01016 GetBitContext* gb = &s->gb;
01017 int more_frames = 0, len = 0, i, ret;
01018
01019 s->frame.nb_samples = s->samples_per_frame;
01020 if ((ret = s->avctx->get_buffer(s->avctx, &s->frame)) < 0) {
01021
01022 av_log(s->avctx, AV_LOG_ERROR,
01023 "not enough space for the output samples\n");
01024 s->packet_loss = 1;
01025 return ret;
01026 }
01027 for (i = 0; i < s->num_channels; i++) {
01028 s->samples_16[i] = (int16_t *)s->frame.data[0] + i;
01029 s->samples_32[i] = (int32_t *)s->frame.data[0] + i;
01030 }
01031
01032
01033 if (s->len_prefix)
01034 len = get_bits(gb, s->log2_frame_size);
01035
01036
01037 if (decode_tilehdr(s)) {
01038 s->packet_loss = 1;
01039 return 0;
01040 }
01041
01042
01043 if (s->dynamic_range_compression)
01044 s->drc_gain = get_bits(gb, 8);
01045
01046
01047
01048 if (get_bits1(gb)) {
01049 int av_unused skip;
01050
01051
01052 if (get_bits1(gb)) {
01053 skip = get_bits(gb, av_log2(s->samples_per_frame * 2));
01054 av_dlog(s->avctx, "start skip: %i\n", skip);
01055 }
01056
01057
01058 if (get_bits1(gb)) {
01059 skip = get_bits(gb, av_log2(s->samples_per_frame * 2));
01060 av_dlog(s->avctx, "end skip: %i\n", skip);
01061 }
01062
01063 }
01064
01065
01066 s->parsed_all_subframes = 0;
01067 for (i = 0; i < s->num_channels; i++) {
01068 s->channel[i].decoded_samples = 0;
01069 s->channel[i].cur_subframe = 0;
01070 }
01071
01072
01073 while (!s->parsed_all_subframes) {
01074 if (decode_subframe(s) < 0) {
01075 s->packet_loss = 1;
01076 return 0;
01077 }
01078 }
01079
01080 av_dlog(s->avctx, "Frame done\n");
01081
01082 if (s->skip_frame)
01083 s->skip_frame = 0;
01084
01085 if (s->len_prefix) {
01086 if (len != (get_bits_count(gb) - s->frame_offset) + 2) {
01087
01088 av_log(s->avctx, AV_LOG_ERROR,
01089 "frame[%i] would have to skip %i bits\n", s->frame_num,
01090 len - (get_bits_count(gb) - s->frame_offset) - 1);
01091 s->packet_loss = 1;
01092 return 0;
01093 }
01094
01095
01096 skip_bits_long(gb, len - (get_bits_count(gb) - s->frame_offset) - 1);
01097 }
01098
01099
01100 more_frames = get_bits1(gb);
01101 ++s->frame_num;
01102 return more_frames;
01103 }
01104
01111 static int remaining_bits(WmallDecodeCtx *s, GetBitContext *gb)
01112 {
01113 return s->buf_bit_size - get_bits_count(gb);
01114 }
01115
01123 static void save_bits(WmallDecodeCtx *s, GetBitContext* gb, int len,
01124 int append)
01125 {
01126 int buflen;
01127 PutBitContext tmp;
01128
01129
01130
01131
01132
01133 if (!append) {
01134 s->frame_offset = get_bits_count(gb) & 7;
01135 s->num_saved_bits = s->frame_offset;
01136 init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
01137 }
01138
01139 buflen = (s->num_saved_bits + len + 8) >> 3;
01140
01141 if (len <= 0 || buflen > MAX_FRAMESIZE) {
01142 av_log_ask_for_sample(s->avctx, "input buffer too small\n");
01143 s->packet_loss = 1;
01144 return;
01145 }
01146
01147 s->num_saved_bits += len;
01148 if (!append) {
01149 avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3),
01150 s->num_saved_bits);
01151 } else {
01152 int align = 8 - (get_bits_count(gb) & 7);
01153 align = FFMIN(align, len);
01154 put_bits(&s->pb, align, get_bits(gb, align));
01155 len -= align;
01156 avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len);
01157 }
01158 skip_bits_long(gb, len);
01159
01160 tmp = s->pb;
01161 flush_put_bits(&tmp);
01162
01163 init_get_bits(&s->gb, s->frame_data, s->num_saved_bits);
01164 skip_bits(&s->gb, s->frame_offset);
01165 }
01166
01167 static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr,
01168 AVPacket* avpkt)
01169 {
01170 WmallDecodeCtx *s = avctx->priv_data;
01171 GetBitContext* gb = &s->pgb;
01172 const uint8_t* buf = avpkt->data;
01173 int buf_size = avpkt->size;
01174 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
01175
01176 s->frame.nb_samples = 0;
01177
01178 if (s->packet_done || s->packet_loss) {
01179 s->packet_done = 0;
01180
01181
01182 if (buf_size < avctx->block_align)
01183 return 0;
01184
01185 s->next_packet_start = buf_size - avctx->block_align;
01186 buf_size = avctx->block_align;
01187 s->buf_bit_size = buf_size << 3;
01188
01189
01190 init_get_bits(gb, buf, s->buf_bit_size);
01191 packet_sequence_number = get_bits(gb, 4);
01192 skip_bits(gb, 1);
01193 spliced_packet = get_bits1(gb);
01194 if (spliced_packet)
01195 av_log_missing_feature(avctx, "Bitstream splicing", 1);
01196
01197
01198 num_bits_prev_frame = get_bits(gb, s->log2_frame_size);
01199
01200
01201 if (!s->packet_loss &&
01202 ((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
01203 s->packet_loss = 1;
01204 av_log(avctx, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n",
01205 s->packet_sequence_number, packet_sequence_number);
01206 }
01207 s->packet_sequence_number = packet_sequence_number;
01208
01209 if (num_bits_prev_frame > 0) {
01210 int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb);
01211 if (num_bits_prev_frame >= remaining_packet_bits) {
01212 num_bits_prev_frame = remaining_packet_bits;
01213 s->packet_done = 1;
01214 }
01215
01216
01217
01218 save_bits(s, gb, num_bits_prev_frame, 1);
01219
01220
01221 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
01222 decode_frame(s);
01223 } else if (s->num_saved_bits - s->frame_offset) {
01224 av_dlog(avctx, "ignoring %x previously saved bits\n",
01225 s->num_saved_bits - s->frame_offset);
01226 }
01227
01228 if (s->packet_loss) {
01229
01230
01231 s->num_saved_bits = 0;
01232 init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
01233 s->packet_loss = 0;
01234 }
01235
01236 } else {
01237 int frame_size;
01238
01239 s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3;
01240 init_get_bits(gb, avpkt->data, s->buf_bit_size);
01241 skip_bits(gb, s->packet_offset);
01242
01243 if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
01244 (frame_size = show_bits(gb, s->log2_frame_size)) &&
01245 frame_size <= remaining_bits(s, gb)) {
01246 save_bits(s, gb, frame_size, 0);
01247 s->packet_done = !decode_frame(s);
01248 } else if (!s->len_prefix
01249 && s->num_saved_bits > get_bits_count(&s->gb)) {
01250
01251
01252
01253
01254
01255
01256 s->packet_done = !decode_frame(s);
01257 } else {
01258 s->packet_done = 1;
01259 }
01260 }
01261
01262 if (s->packet_done && !s->packet_loss &&
01263 remaining_bits(s, gb) > 0) {
01264
01265
01266 save_bits(s, gb, remaining_bits(s, gb), 0);
01267 }
01268
01269 *(AVFrame *)data = s->frame;
01270 *got_frame_ptr = s->frame.nb_samples > 0;
01271 s->packet_offset = get_bits_count(gb) & 7;
01272
01273 return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
01274 }
01275
01276 static void flush(AVCodecContext *avctx)
01277 {
01278 WmallDecodeCtx *s = avctx->priv_data;
01279 s->packet_loss = 1;
01280 s->packet_done = 0;
01281 s->num_saved_bits = 0;
01282 init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
01283 s->frame_offset = 0;
01284 s->next_packet_start = 0;
01285 s->cdlms[0][0].order = 0;
01286 s->frame.nb_samples = 0;
01287 }
01288
01289 AVCodec ff_wmalossless_decoder = {
01290 .name = "wmalossless",
01291 .type = AVMEDIA_TYPE_AUDIO,
01292 .id = AV_CODEC_ID_WMALOSSLESS,
01293 .priv_data_size = sizeof(WmallDecodeCtx),
01294 .init = decode_init,
01295 .decode = decode_packet,
01296 .flush = flush,
01297 .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1 | CODEC_CAP_DELAY,
01298 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Lossless"),
01299 };