Commit 1bca72e1 authored by Justin Ruggles's avatar Justin Ruggles

eac3enc: support writing of basic mixing and info metadata

parent e72f3d10
This diff is collapsed.
......@@ -91,6 +91,8 @@ typedef struct AC3EncOptions {
int dolby_surround_ex_mode;
int dolby_headphone_mode;
int ad_converter_type;
int eac3_mixing_metadata;
int eac3_info_metadata;
/* other encoding options */
int allow_per_frame_metadata;
......
......@@ -29,12 +29,13 @@ static const AVOption ac3_options[] = {
#else /* AC3ENC_TYPE_EAC3 */
static const AVOption eac3_options[] = {
#endif
#if AC3ENC_TYPE != AC3ENC_TYPE_EAC3
/* Metadata Options */
{"per_frame_metadata", "Allow Changing Metadata Per-Frame", OFFSET(allow_per_frame_metadata), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, 1, AC3ENC_PARAM},
/* downmix levels */
#if AC3ENC_TYPE != AC3ENC_TYPE_EAC3
/* AC-3 downmix levels */
{"center_mixlev", "Center Mix Level", OFFSET(center_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_4POINT5DB }, 0.0, 1.0, AC3ENC_PARAM},
{"surround_mixlev", "Surround Mix Level", OFFSET(surround_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_6DB }, 0.0, 1.0, AC3ENC_PARAM},
#endif
/* audio production information */
{"mixing_level", "Mixing Level", OFFSET(mixing_level), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 111, AC3ENC_PARAM},
{"room_type", "Room Type", OFFSET(room_type), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 2, AC3ENC_PARAM, "room_type"},
......@@ -42,15 +43,13 @@ static const AVOption eac3_options[] = {
{"large", "Large Room", 0, FF_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
{"small", "Small Room", 0, FF_OPT_TYPE_CONST, {.dbl = 2 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
/* other metadata options */
{"copyright", "Copyright Bit", OFFSET(copyright), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, 1, AC3ENC_PARAM},
#endif
{"copyright", "Copyright Bit", OFFSET(copyright), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 1, AC3ENC_PARAM},
{"dialnorm", "Dialogue Level (dB)", OFFSET(dialogue_level), FF_OPT_TYPE_INT, {.dbl = -31 }, -31, -1, AC3ENC_PARAM},
#if AC3ENC_TYPE != AC3ENC_TYPE_EAC3
{"dsur_mode", "Dolby Surround Mode", OFFSET(dolby_surround_mode), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, 2, AC3ENC_PARAM, "dsur_mode"},
{"dsur_mode", "Dolby Surround Mode", OFFSET(dolby_surround_mode), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 2, AC3ENC_PARAM, "dsur_mode"},
{"notindicated", "Not Indicated (default)", 0, FF_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
{"on", "Dolby Surround Encoded", 0, FF_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
{"off", "Not Dolby Surround Encoded", 0, FF_OPT_TYPE_CONST, {.dbl = 2 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
{"original", "Original Bit Stream", OFFSET(original), FF_OPT_TYPE_INT, {.dbl = 1 }, 0, 1, AC3ENC_PARAM},
{"original", "Original Bit Stream", OFFSET(original), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 1, AC3ENC_PARAM},
/* extended bitstream information */
{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 2, AC3ENC_PARAM, "dmix_mode"},
{"notindicated", "Not Indicated (default)", 0, FF_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
......@@ -71,7 +70,6 @@ static const AVOption eac3_options[] = {
{"ad_conv_type", "A/D Converter Type", OFFSET(ad_converter_type), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 1, AC3ENC_PARAM, "ad_conv_type"},
{"standard", "Standard (default)", 0, FF_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"},
{"hdcd", "HDCD", 0, FF_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"},
#endif
/* Other Encoding Options */
{"stereo_rematrixing", "Stereo Rematrixing", OFFSET(stereo_rematrixing), FF_OPT_TYPE_INT, {.dbl = 1 }, 0, 1, AC3ENC_PARAM},
#if AC3ENC_TYPE != AC3ENC_TYPE_AC3_FIXED
......
......@@ -423,7 +423,7 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame,
const SampleType *samples = data;
int ret;
if (!s->eac3 && s->options.allow_per_frame_metadata) {
if (s->options.allow_per_frame_metadata) {
ret = ff_ac3_validate_metadata(s);
if (ret)
return ret;
......
......@@ -142,10 +142,48 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s)
put_bits(&s->pb, 5, s->bitstream_id); /* bitstream id (EAC3=16) */
put_bits(&s->pb, 5, -opt->dialogue_level); /* dialogue normalization level */
put_bits(&s->pb, 1, 0); /* no compression gain */
put_bits(&s->pb, 1, 0); /* no mixing metadata */
/* TODO: mixing metadata */
put_bits(&s->pb, 1, 0); /* no info metadata */
/* TODO: info metadata */
/* mixing metadata*/
put_bits(&s->pb, 1, opt->eac3_mixing_metadata);
if (opt->eac3_mixing_metadata) {
if (s->channel_mode > AC3_CHMODE_STEREO)
put_bits(&s->pb, 2, opt->preferred_stereo_downmix);
if (s->has_center) {
put_bits(&s->pb, 3, s->ltrt_center_mix_level);
put_bits(&s->pb, 3, s->loro_center_mix_level);
}
if (s->has_surround) {
put_bits(&s->pb, 3, s->ltrt_surround_mix_level);
put_bits(&s->pb, 3, s->loro_surround_mix_level);
}
if (s->lfe_on)
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0); /* no program scale */
put_bits(&s->pb, 1, 0); /* no ext program scale */
put_bits(&s->pb, 2, 0); /* no mixing parameters */
if (s->channel_mode < AC3_CHMODE_STEREO)
put_bits(&s->pb, 1, 0); /* no pan info */
put_bits(&s->pb, 1, 0); /* no frame mix config info */
}
/* info metadata*/
put_bits(&s->pb, 1, opt->eac3_info_metadata);
if (opt->eac3_info_metadata) {
put_bits(&s->pb, 3, s->bitstream_mode);
put_bits(&s->pb, 1, opt->copyright);
put_bits(&s->pb, 1, opt->original);
if (s->channel_mode == AC3_CHMODE_STEREO) {
put_bits(&s->pb, 2, opt->dolby_surround_mode);
put_bits(&s->pb, 2, opt->dolby_headphone_mode);
}
if (s->channel_mode >= AC3_CHMODE_2F2R)
put_bits(&s->pb, 2, opt->dolby_surround_ex_mode);
put_bits(&s->pb, 1, opt->audio_production_info);
if (opt->audio_production_info) {
put_bits(&s->pb, 5, opt->mixing_level - 80);
put_bits(&s->pb, 2, opt->room_type);
put_bits(&s->pb, 1, opt->ad_converter_type);
}
put_bits(&s->pb, 1, 0);
}
if (s->num_blocks != 6)
put_bits(&s->pb, 1, !(s->avctx->frame_number % 6)); /* converter sync flag */
put_bits(&s->pb, 1, 0); /* no additional bit stream info */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment