0
};
+/**
+ * Table to remap channels from SMPTE order to AC-3 order.
+ * [channel_mode][lfe][ch]
+ */
+static const uint8_t ac3_enc_channel_map[8][2][6] = {
+ COMMON_CHANNEL_MAP
+ { { 0, 1, 2, 3, }, { 0, 1, 3, 4, 2, } },
+ { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 4, 5, 3 } },
+};
/**
* LUT to select the bandwidth code based on the bit rate, sample rate, and
if (s->eac3)
frame_bits++;
+ /* coupling strategy exists: cplstre */
+ if (!s->eac3)
+ frame_bits++;
+
if (!s->eac3) {
/* exponent strategy */
frame_bits += 2 * s->fbw_channels;
frame_bits += 2 + 2 + 2 + 2 + 3;
}
- /* converter snr offset */
- if (s->eac3)
- frame_bits++;
+ /* snroffste for AC-3, convsnroffste for E-AC-3 */
+ frame_bits++;
if (!s->eac3) {
/* delta bit allocation */
/* coupling exponent strategy */
if (s->cpl_on) {
if (s->use_frame_exp_strategy) {
- frame_bits += 5 * s->cpl_on;
+ frame_bits += 5;
} else {
for (blk = 0; blk < s->num_blocks; blk++)
frame_bits += 2 * s->blocks[blk].cpl_in_use;
AC3Block *block = &s->blocks[blk];
/* coupling strategy */
- if (!s->eac3)
- frame_bits++;
if (block->new_cpl_strategy) {
if (!s->eac3)
frame_bits++;
/* snr offsets and fast gain codes */
if (!s->eac3) {
- frame_bits++;
if (block->new_snr_offsets)
frame_bits += 6 + (s->channels + block->cpl_in_use) * (4 + 3);
}
int c = fixed_coef[i];
int e = exp[i];
int v = bap[i];
- if (v)
switch (v) {
+ case 0:
+ break;
case 1:
v = sym_quant(c, e, 3);
switch (s->mant1_cnt) {
put_bits(&s->pb, 9, 0); /* xbsi2 and encinfo : reserved */
}
} else {
- put_bits(&s->pb, 1, 0); /* no time code 1 */
- put_bits(&s->pb, 1, 0); /* no time code 2 */
+ put_bits(&s->pb, 1, 0); /* no time code 1 */
+ put_bits(&s->pb, 1, 0); /* no time code 2 */
}
put_bits(&s->pb, 1, 0); /* no additional bit stream info */
}
/* compute crc2 */
crc2_partial = av_crc(crc_ctx, 0, frame + 2, s->frame_size - 5);
} else {
- /* compute crc1 */
- /* this is not so easy because it is at the beginning of the data... */
- crc1 = av_bswap16(av_crc(crc_ctx, 0, frame + 4, frame_size_58 - 4));
- crc_inv = s->crc_inv[s->frame_size > s->frame_size_min];
- crc1 = mul_poly(crc_inv, crc1, CRC16_POLY);
- AV_WB16(frame + 2, crc1);
+ /* compute crc1 */
+ /* this is not so easy because it is at the beginning of the data... */
+ crc1 = av_bswap16(av_crc(crc_ctx, 0, frame + 4, frame_size_58 - 4));
+ crc_inv = s->crc_inv[s->frame_size > s->frame_size_min];
+ crc1 = mul_poly(crc_inv, crc1, CRC16_POLY);
+ AV_WB16(frame + 2, crc1);
- /* compute crc2 */
- crc2_partial = av_crc(crc_ctx, 0, frame + frame_size_58,
- s->frame_size - frame_size_58 - 3);
+ /* compute crc2 */
+ crc2_partial = av_crc(crc_ctx, 0, frame + frame_size_58,
+ s->frame_size - frame_size_58 - 3);
}
crc2 = av_crc(crc_ctx, crc2_partial, frame + s->frame_size - 3, 1);
/* ensure crc2 does not match sync word by flipping crcrsv bit if needed */
{
int blk;
- init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
+ init_put_bits(&s->pb, frame, s->frame_size);
s->output_frame_header(s);
ac3_quantize_mantissas(s);
- if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size, 0)) < 0)
+ ret = ff_alloc_packet2(avctx, avpkt, s->frame_size, s->frame_size);
+ if (ret < 0)
return ret;
ac3_output_frame(s, avpkt->data);
if (!s->eac3) {
if (s->has_center) {
validate_mix_level(avctx, "center_mix_level", &opt->center_mix_level,
- cmixlev_options, CMIXLEV_NUM_OPTIONS, 1, 0,
- &s->center_mix_level);
+ cmixlev_options, CMIXLEV_NUM_OPTIONS, 1, 0,
+ &s->center_mix_level);
}
if (s->has_surround) {
validate_mix_level(avctx, "surround_mix_level", &opt->surround_mix_level,
- surmixlev_options, SURMIXLEV_NUM_OPTIONS, 1, 0,
- &s->surround_mix_level);
+ surmixlev_options, SURMIXLEV_NUM_OPTIONS, 1, 0,
+ &s->surround_mix_level);
}
}
av_freep(&s->mdct_window);
av_freep(&s->windowed_samples);
if (s->planar_samples)
- for (ch = 0; ch < s->channels; ch++)
- av_freep(&s->planar_samples[ch]);
+ for (ch = 0; ch < s->channels; ch++)
+ av_freep(&s->planar_samples[ch]);
av_freep(&s->planar_samples);
av_freep(&s->bap_buffer);
av_freep(&s->bap1_buffer);
s->has_center = (s->channel_mode & 0x01) && s->channel_mode != AC3_CHMODE_MONO;
s->has_surround = s->channel_mode & 0x04;
- s->channel_map = ff_ac3_enc_channel_map[s->channel_mode][s->lfe_on];
+ s->channel_map = ac3_enc_channel_map[s->channel_mode][s->lfe_on];
*channel_layout = ch_layout;
if (s->lfe_on)
*channel_layout |= AV_CH_LOW_FREQUENCY;
}
if (CONFIG_EAC3_ENCODER && s->eac3) {
- static AVOnce init_static_once = AV_ONCE_INIT;
- ff_thread_once(&init_static_once, ff_eac3_exponent_init);
+ static AVOnce init_static_once_eac3 = AV_ONCE_INIT;
+ ff_thread_once(&init_static_once_eac3, ff_eac3_exponent_init);
s->output_frame_header = ff_eac3_output_frame_header;
} else
s->output_frame_header = ac3_output_frame_header;