Skip to content

Commit

Permalink
af_lavcac3enc: make encoder configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
wm4 committed Jun 23, 2016
1 parent 5c74da4 commit e911e20
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion DOCS/man/af.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Available filters are:
Set AVOptions on the SwrContext or AVAudioResampleContext. These should
be documented by FFmpeg or Libav.

``lavcac3enc[=tospdif[:bitrate[:minch]]]``
``lavcac3enc[=options]``
Encode multi-channel audio to AC-3 at runtime using libavcodec. Supports
16-bit native-endian input format, maximum 6 channels. The output is
big-endian when outputting a raw AC-3 stream, native-endian when
Expand Down Expand Up @@ -103,6 +103,10 @@ Available filters are:
If the input channel number is less than ``<minch>``, the filter will
detach itself (default: 3).

``encoder=<name>``
Select the libavcodec encoder used. Currently, this should be an AC-3
encoder, and using another codec will fail horribly.

``equalizer=g1:g2:g3:...:g10``
10 octave band graphic equalizer, implemented using 10 IIR band-pass
filters. This means that it works regardless of what type of audio is
Expand Down
7 changes: 5 additions & 2 deletions audio/filter/af_lavcac3enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef struct af_ac3enc_s {
int cfg_add_iec61937_header;
int cfg_bit_rate;
int cfg_min_channel_num;
char *cfg_encoder;
} af_ac3enc_t;

// fmt carries the input format. Change it to the best next-possible format
Expand Down Expand Up @@ -374,9 +375,9 @@ static int af_open(struct af_instance* af){
af->filter_frame = filter_frame;
af->filter_out = filter_out;

s->lavc_acodec = avcodec_find_encoder_by_name("ac3");
s->lavc_acodec = avcodec_find_encoder_by_name(s->cfg_encoder);
if (!s->lavc_acodec) {
MP_ERR(af, "Audio LAVC, couldn't find encoder for codec %s.\n", "ac3");
MP_ERR(af, "Couldn't find encoder %s.\n", s->cfg_encoder);
return AF_ERROR;
}

Expand Down Expand Up @@ -426,12 +427,14 @@ const struct af_info af_info_lavcac3enc = {
.cfg_add_iec61937_header = 1,
.cfg_bit_rate = 640,
.cfg_min_channel_num = 3,
.cfg_encoder = "ac3",
},
.options = (const struct m_option[]) {
OPT_FLAG("tospdif", cfg_add_iec61937_header, 0),
OPT_CHOICE_OR_INT("bitrate", cfg_bit_rate, 0, 32, 640,
({"auto", 0}, {"default", 0})),
OPT_INTRANGE("minch", cfg_min_channel_num, 0, 2, 6),
OPT_STRING("encoder", cfg_encoder, 0),
{0}
},
};

0 comments on commit e911e20

Please sign in to comment.