unsigned int cur_frame_length; ///< length of the current frame to decode
unsigned int frame_id; ///< the frame ID / number of the current frame
unsigned int js_switch; ///< if true, joint-stereo decoding is enforced
unsigned int num_blocks; ///< number of blocks used in the current frame
unsigned int s_max; ///< maximum Rice parameter allowed in entropy coding
uint8_t *bgmc_lut; ///< pointer at lookup tables used for BGMC
unsigned int cur_frame_length; ///< length of the current frame to decode
unsigned int frame_id; ///< the frame ID / number of the current frame
unsigned int js_switch; ///< if true, joint-stereo decoding is enforced
unsigned int num_blocks; ///< number of blocks used in the current frame
unsigned int s_max; ///< maximum Rice parameter allowed in entropy coding
uint8_t *bgmc_lut; ///< pointer at lookup tables used for BGMC
- dprintf(avctx, "resolution = %i\n", sconf->resolution);
- dprintf(avctx, "floating = %i\n", sconf->floating);
- dprintf(avctx, "frame_length = %i\n", sconf->frame_length);
- dprintf(avctx, "ra_distance = %i\n", sconf->ra_distance);
- dprintf(avctx, "ra_flag = %i\n", sconf->ra_flag);
- dprintf(avctx, "adapt_order = %i\n", sconf->adapt_order);
- dprintf(avctx, "coef_table = %i\n", sconf->coef_table);
- dprintf(avctx, "long_term_prediction = %i\n", sconf->long_term_prediction);
- dprintf(avctx, "max_order = %i\n", sconf->max_order);
- dprintf(avctx, "block_switching = %i\n", sconf->block_switching);
- dprintf(avctx, "bgmc = %i\n", sconf->bgmc);
- dprintf(avctx, "sb_part = %i\n", sconf->sb_part);
- dprintf(avctx, "joint_stereo = %i\n", sconf->joint_stereo);
- dprintf(avctx, "mc_coding = %i\n", sconf->mc_coding);
- dprintf(avctx, "chan_config = %i\n", sconf->chan_config);
- dprintf(avctx, "chan_sort = %i\n", sconf->chan_sort);
- dprintf(avctx, "RLSLMS = %i\n", sconf->rlslms);
- dprintf(avctx, "chan_config_info = %i\n", sconf->chan_config_info);
+ av_dlog(avctx, "resolution = %i\n", sconf->resolution);
+ av_dlog(avctx, "floating = %i\n", sconf->floating);
+ av_dlog(avctx, "frame_length = %i\n", sconf->frame_length);
+ av_dlog(avctx, "ra_distance = %i\n", sconf->ra_distance);
+ av_dlog(avctx, "ra_flag = %i\n", sconf->ra_flag);
+ av_dlog(avctx, "adapt_order = %i\n", sconf->adapt_order);
+ av_dlog(avctx, "coef_table = %i\n", sconf->coef_table);
+ av_dlog(avctx, "long_term_prediction = %i\n", sconf->long_term_prediction);
+ av_dlog(avctx, "max_order = %i\n", sconf->max_order);
+ av_dlog(avctx, "block_switching = %i\n", sconf->block_switching);
+ av_dlog(avctx, "bgmc = %i\n", sconf->bgmc);
+ av_dlog(avctx, "sb_part = %i\n", sconf->sb_part);
+ av_dlog(avctx, "joint_stereo = %i\n", sconf->joint_stereo);
+ av_dlog(avctx, "mc_coding = %i\n", sconf->mc_coding);
+ av_dlog(avctx, "chan_config = %i\n", sconf->chan_config);
+ av_dlog(avctx, "chan_sort = %i\n", sconf->chan_sort);
+ av_dlog(avctx, "RLSLMS = %i\n", sconf->rlslms);
+ av_dlog(avctx, "chan_config_info = %i\n", sconf->chan_config_info);
+ // update CRC
+ if (sconf->crc_enabled && avctx->error_recognition >= FF_ER_CAREFUL) {
+ int swap = HAVE_BIGENDIAN != sconf->msb_first;
+
+ if (ctx->avctx->bits_per_raw_sample == 24) {
+ int32_t *src = data;
+
+ for (sample = 0;
+ sample < ctx->cur_frame_length * avctx->channels;
+ sample++) {
+ int32_t v;
+
+ if (swap)
+ v = av_bswap32(src[sample]);
+ else
+ v = src[sample];
+ if (!HAVE_BIGENDIAN)
+ v >>= 8;
+
+ ctx->crc = av_crc(ctx->crc_table, ctx->crc, (uint8_t*)(&v), 3);
+ }
+ } else {
+ uint8_t *crc_source;
+
+ if (swap) {
+ if (ctx->avctx->bits_per_raw_sample <= 16) {
+ int16_t *src = (int16_t*) data;
+ int16_t *dest = (int16_t*) ctx->crc_buffer;
+ for (sample = 0;
+ sample < ctx->cur_frame_length * avctx->channels;
+ sample++)
+ *dest++ = av_bswap16(src[sample]);
+ } else {
+ ctx->dsp.bswap_buf((uint32_t*)ctx->crc_buffer, data,
+ ctx->cur_frame_length * avctx->channels);
+ }
+ crc_source = ctx->crc_buffer;
+ } else {
+ crc_source = data;
+ }
+
+ ctx->crc = av_crc(ctx->crc_table, ctx->crc, crc_source, size);
+ }
+
+
+ // check CRC sums if this is the last frame
+ if (ctx->cur_frame_length != sconf->frame_length &&
+ ctx->crc_org != ctx->crc) {
+ av_log(avctx, AV_LOG_ERROR, "CRC error.\n");
+ }
+ }
+
+
+ // allocate crc buffer
+ if (HAVE_BIGENDIAN != sconf->msb_first && sconf->crc_enabled &&
+ avctx->error_recognition >= FF_ER_CAREFUL) {
+ ctx->crc_buffer = av_malloc(sizeof(*ctx->crc_buffer) *
+ ctx->cur_frame_length *
+ avctx->channels *
+ (av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3));
+ if (!ctx->crc_buffer) {
+ av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
+ decode_end(avctx);
+ return AVERROR(ENOMEM);
+ }
+ }
+
+ dsputil_init(&ctx->dsp, avctx);
+