summaryrefslogtreecommitdiffstats
path: root/libavcodec/wmalosslessdec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/wmalosslessdec.c')
-rw-r--r--libavcodec/wmalosslessdec.c278
1 files changed, 139 insertions, 139 deletions
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 9b54abf..9f1e328 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -610,26 +610,26 @@ static void decode_mclms(WmallDecodeCtx *s)
s->mclms_order = (get_bits(&s->gb, 4) + 1) * 2;
s->mclms_scaling = get_bits(&s->gb, 4);
if(get_bits1(&s->gb)) {
- // mclms_send_coef
- int i;
- int send_coef_bits;
- int cbits = av_log2(s->mclms_scaling + 1);
- assert(cbits == my_log2(s->mclms_scaling + 1));
- if(1 << cbits < s->mclms_scaling + 1)
- cbits++;
-
- send_coef_bits = (cbits ? get_bits(&s->gb, cbits) : 0) + 2;
-
- for(i = 0; i < s->mclms_order * s->num_channels * s->num_channels; i++) {
- s->mclms_coeffs[i] = get_bits(&s->gb, send_coef_bits);
- }
-
- for(i = 0; i < s->num_channels; i++) {
- int c;
- for(c = 0; c < i; c++) {
- s->mclms_coeffs_cur[i * s->num_channels + c] = get_bits(&s->gb, send_coef_bits);
- }
- }
+ // mclms_send_coef
+ int i;
+ int send_coef_bits;
+ int cbits = av_log2(s->mclms_scaling + 1);
+ assert(cbits == my_log2(s->mclms_scaling + 1));
+ if(1 << cbits < s->mclms_scaling + 1)
+ cbits++;
+
+ send_coef_bits = (cbits ? get_bits(&s->gb, cbits) : 0) + 2;
+
+ for(i = 0; i < s->mclms_order * s->num_channels * s->num_channels; i++) {
+ s->mclms_coeffs[i] = get_bits(&s->gb, send_coef_bits);
+ }
+
+ for(i = 0; i < s->num_channels; i++) {
+ int c;
+ for(c = 0; c < i; c++) {
+ s->mclms_coeffs_cur[i * s->num_channels + c] = get_bits(&s->gb, send_coef_bits);
+ }
+ }
}
}
@@ -643,36 +643,36 @@ static void decode_cdlms(WmallDecodeCtx *s)
int cdlms_send_coef = get_bits1(&s->gb);
for(c = 0; c < s->num_channels; c++) {
- s->cdlms_ttl[c] = get_bits(&s->gb, 3) + 1;
- for(i = 0; i < s->cdlms_ttl[c]; i++) {
- s->cdlms[c][i].order = (get_bits(&s->gb, 7) + 1) * 8;
- }
-
- for(i = 0; i < s->cdlms_ttl[c]; i++) {
- s->cdlms[c][i].scaling = get_bits(&s->gb, 4);
- }
-
- if(cdlms_send_coef) {
- for(i = 0; i < s->cdlms_ttl[c]; i++) {
- int cbits, shift_l, shift_r, j;
- cbits = av_log2(s->cdlms[c][i].order);
- if(1 << cbits < s->cdlms[c][i].order)
- cbits++;
- s->cdlms[c][i].coefsend = get_bits(&s->gb, cbits) + 1;
-
- cbits = av_log2(s->cdlms[c][i].scaling + 1);
- if(1 << cbits < s->cdlms[c][i].scaling + 1)
- cbits++;
-
- s->cdlms[c][i].bitsend = get_bits(&s->gb, cbits) + 2;
- shift_l = 32 - s->cdlms[c][i].bitsend;
- shift_r = 32 - 2 - s->cdlms[c][i].scaling;
- for(j = 0; j < s->cdlms[c][i].coefsend; j++) {
- s->cdlms[c][i].coefs[j] =
- (get_bits(&s->gb, s->cdlms[c][i].bitsend) << shift_l) >> shift_r;
- }
- }
- }
+ s->cdlms_ttl[c] = get_bits(&s->gb, 3) + 1;
+ for(i = 0; i < s->cdlms_ttl[c]; i++) {
+ s->cdlms[c][i].order = (get_bits(&s->gb, 7) + 1) * 8;
+ }
+
+ for(i = 0; i < s->cdlms_ttl[c]; i++) {
+ s->cdlms[c][i].scaling = get_bits(&s->gb, 4);
+ }
+
+ if(cdlms_send_coef) {
+ for(i = 0; i < s->cdlms_ttl[c]; i++) {
+ int cbits, shift_l, shift_r, j;
+ cbits = av_log2(s->cdlms[c][i].order);
+ if(1 << cbits < s->cdlms[c][i].order)
+ cbits++;
+ s->cdlms[c][i].coefsend = get_bits(&s->gb, cbits) + 1;
+
+ cbits = av_log2(s->cdlms[c][i].scaling + 1);
+ if(1 << cbits < s->cdlms[c][i].scaling + 1)
+ cbits++;
+
+ s->cdlms[c][i].bitsend = get_bits(&s->gb, cbits) + 2;
+ shift_l = 32 - s->cdlms[c][i].bitsend;
+ shift_r = 32 - 2 - s->cdlms[c][i].scaling;
+ for(j = 0; j < s->cdlms[c][i].coefsend; j++) {
+ s->cdlms[c][i].coefs[j] =
+ (get_bits(&s->gb, s->cdlms[c][i].bitsend) << shift_l) >> shift_r;
+ }
+ }
+ }
}
}
@@ -685,34 +685,34 @@ static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size)
unsigned int ave_mean;
s->transient[ch] = get_bits1(&s->gb);
if(s->transient[ch]) {
- s->transient_pos[ch] = get_bits(&s->gb, av_log2(tile_size));
+ s->transient_pos[ch] = get_bits(&s->gb, av_log2(tile_size));
if (s->transient_pos[ch])
- s->transient[ch] = 0;
- s->channel[ch].transient_counter =
- FFMAX(s->channel[ch].transient_counter, s->samples_per_frame / 2);
- } else if (s->channel[ch].transient_counter)
- s->transient[ch] = 1;
+ s->transient[ch] = 0;
+ s->channel[ch].transient_counter =
+ FFMAX(s->channel[ch].transient_counter, s->samples_per_frame / 2);
+ } else if (s->channel[ch].transient_counter)
+ s->transient[ch] = 1;
if(s->seekable_tile) {
- ave_mean = get_bits(&s->gb, s->bits_per_sample);
- s->ave_sum[ch] = ave_mean << (s->movave_scaling + 1);
-// s->ave_sum[ch] *= 2;
+ ave_mean = get_bits(&s->gb, s->bits_per_sample);
+ s->ave_sum[ch] = ave_mean << (s->movave_scaling + 1);
+// s->ave_sum[ch] *= 2;
}
if(s->seekable_tile) {
- if(s->do_inter_ch_decorr)
- s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample + 1);
- else
- s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample);
- i++;
+ if(s->do_inter_ch_decorr)
+ s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample + 1);
+ else
+ s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample);
+ i++;
}
//av_log(0, 0, "%8d: ", num_logged_tiles++);
for(; i < tile_size; i++) {
- int quo = 0, rem, rem_bits, residue;
- while(get_bits1(&s->gb))
- quo++;
- if(quo >= 32)
- quo += get_bits_long(&s->gb, get_bits(&s->gb, 5) + 1);
+ int quo = 0, rem, rem_bits, residue;
+ while(get_bits1(&s->gb))
+ quo++;
+ if(quo >= 32)
+ quo += get_bits_long(&s->gb, get_bits(&s->gb, 5) + 1);
ave_mean = (s->ave_sum[ch] + (1 << s->movave_scaling)) >> (s->movave_scaling + 1);
if (ave_mean <= 1)
@@ -724,13 +724,13 @@ static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size)
residue = (quo << rem_bits) + rem;
}
- s->ave_sum[ch] = residue + s->ave_sum[ch] - (s->ave_sum[ch] >> s->movave_scaling);
+ s->ave_sum[ch] = residue + s->ave_sum[ch] - (s->ave_sum[ch] >> s->movave_scaling);
- if(residue & 1)
- residue = -(residue >> 1) - 1;
- else
- residue = residue >> 1;
- s->channel_residues[ch][i] = residue;
+ if(residue & 1)
+ residue = -(residue >> 1) - 1;
+ else
+ residue = residue >> 1;
+ s->channel_residues[ch][i] = residue;
}
//dump_int_buffer(s->channel_residues[ch], 4, tile_size, 16);
@@ -751,9 +751,9 @@ decode_lpc(WmallDecodeCtx *s)
s->lpc_intbits = get_bits(&s->gb, 3) + 1;
cbits = s->lpc_scaling + s->lpc_intbits;
for(ch = 0; ch < s->num_channels; ch++) {
- for(i = 0; i < s->lpc_order; i++) {
- s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits);
- }
+ for(i = 0; i < s->lpc_order; i++) {
+ s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits);
+ }
}
}
@@ -1124,72 +1124,72 @@ static int decode_subframe(WmallDecodeCtx *s)
if(s->seekable_tile) {
clear_codec_buffers(s);
- s->do_arith_coding = get_bits1(&s->gb);
- if(s->do_arith_coding) {
- dprintf(s->avctx, "do_arith_coding == 1");
- abort();
- }
- s->do_ac_filter = get_bits1(&s->gb);
- s->do_inter_ch_decorr = get_bits1(&s->gb);
- s->do_mclms = get_bits1(&s->gb);
-
- if(s->do_ac_filter)
- decode_ac_filter(s);
-
- if(s->do_mclms)
- decode_mclms(s);
-
- decode_cdlms(s);
- s->movave_scaling = get_bits(&s->gb, 3);
- s->quant_stepsize = get_bits(&s->gb, 8) + 1;
-
- reset_codec(s);
+ s->do_arith_coding = get_bits1(&s->gb);
+ if(s->do_arith_coding) {
+ dprintf(s->avctx, "do_arith_coding == 1");
+ abort();
+ }
+ s->do_ac_filter = get_bits1(&s->gb);
+ s->do_inter_ch_decorr = get_bits1(&s->gb);
+ s->do_mclms = get_bits1(&s->gb);
+
+ if(s->do_ac_filter)
+ decode_ac_filter(s);
+
+ if(s->do_mclms)
+ decode_mclms(s);
+
+ decode_cdlms(s);
+ s->movave_scaling = get_bits(&s->gb, 3);
+ s->quant_stepsize = get_bits(&s->gb, 8) + 1;
+
+ reset_codec(s);
}
rawpcm_tile = get_bits1(&s->gb);
for(i = 0; i < s->num_channels; i++) {
- s->is_channel_coded[i] = 1;
+ s->is_channel_coded[i] = 1;
}
if(!rawpcm_tile) {
- for(i = 0; i < s->num_channels; i++) {
- s->is_channel_coded[i] = get_bits1(&s->gb);
- }
-
- if(s->bV3RTM) {
- // LPC
- s->do_lpc = get_bits1(&s->gb);
- if(s->do_lpc) {
- decode_lpc(s);
- }
- } else {
- s->do_lpc = 0;
- }
+ for(i = 0; i < s->num_channels; i++) {
+ s->is_channel_coded[i] = get_bits1(&s->gb);
+ }
+
+ if(s->bV3RTM) {
+ // LPC
+ s->do_lpc = get_bits1(&s->gb);
+ if(s->do_lpc) {
+ decode_lpc(s);
+ }
+ } else {
+ s->do_lpc = 0;
+ }
}
if(get_bits1(&s->gb)) {
- padding_zeroes = get_bits(&s->gb, 5);
+ padding_zeroes = get_bits(&s->gb, 5);
} else {
- padding_zeroes = 0;
+ padding_zeroes = 0;
}
if(rawpcm_tile) {
-
- int bits = s->bits_per_sample - padding_zeroes;
- dprintf(s->avctx, "RAWPCM %d bits per sample. total %d bits, remain=%d\n", bits,
- bits * s->num_channels * subframe_len, get_bits_count(&s->gb));
- for(i = 0; i < s->num_channels; i++) {
- for(j = 0; j < subframe_len; j++) {
- s->channel_coeffs[i][j] = get_sbits(&s->gb, bits);
-// dprintf(s->avctx, "PCM[%d][%d] = 0x%04x\n", i, j, s->channel_coeffs[i][j]);
- }
- }
+
+ int bits = s->bits_per_sample - padding_zeroes;
+ dprintf(s->avctx, "RAWPCM %d bits per sample. total %d bits, remain=%d\n", bits,
+ bits * s->num_channels * subframe_len, get_bits_count(&s->gb));
+ for(i = 0; i < s->num_channels; i++) {
+ for(j = 0; j < subframe_len; j++) {
+ s->channel_coeffs[i][j] = get_sbits(&s->gb, bits);
+// dprintf(s->avctx, "PCM[%d][%d] = 0x%04x\n", i, j, s->channel_coeffs[i][j]);
+ }
+ }
} else {
- for(i = 0; i < s->num_channels; i++)
- if(s->is_channel_coded[i]) {
+ for(i = 0; i < s->num_channels; i++)
+ if(s->is_channel_coded[i]) {
decode_channel_residues(s, i, subframe_len);
if (s->seekable_tile)
use_high_update_speed(s, i);
@@ -1332,7 +1332,7 @@ static int decode_frame(WmallDecodeCtx *s)
} else {
/*
while (get_bits_count(gb) < s->num_saved_bits && get_bits1(gb) == 0) {
- dprintf(s->avctx, "skip1\n");
+ dprintf(s->avctx, "skip1\n");
}
*/
}
@@ -1430,12 +1430,13 @@ static int decode_packet(AVCodecContext *avctx,
s->samples_16 = (int16_t *) data;
s->samples_16_end = (int16_t *) ((int8_t*)data + *data_size);
} else {
- s->samples_32 = (int *) data;
- s->samples_32_end = (int *) ((int8_t*)data + *data_size);
+ s->samples_32 = (void *) data;
+ s->samples_32_end = (void *) ((int8_t*)data + *data_size);
}
*data_size = 0;
if (s->packet_done || s->packet_loss) {
+ int seekable_frame_in_packet, spliced_packet;
s->packet_done = 0;
/** sanity check for the buffer length */
@@ -1555,15 +1556,14 @@ static void flush(AVCodecContext *avctx)
*@brief wmall decoder
*/
AVCodec ff_wmalossless_decoder = {
- "wmalossless",
- AVMEDIA_TYPE_AUDIO,
- CODEC_ID_WMALOSSLESS,
- sizeof(WmallDecodeCtx),
- decode_init,
- NULL,
- decode_end,
- decode_packet,
- .capabilities = CODEC_CAP_SUBFRAMES,
- .flush= flush,
+ .name = "wmalossless",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = CODEC_ID_WMALOSSLESS,
+ .priv_data_size = sizeof(WmallDecodeCtx),
+ .init = decode_init,
+ .close = decode_end,
+ .decode = decode_packet,
+ .flush = flush,
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_EXPERIMENTAL,
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Lossless"),
};
OpenPOWER on IntegriCloud