Message ID | 20180122151629.40821-1-mrdegier@gmail.com |
---|---|
State | Superseded |
Headers | show |
On 1/22/2018 3:16 PM, mrdegier@gmail.com wrote: > From: Menno <mrdegier@gmail.com> > > Signed-off-by: Menno <mrdegier@gmail.com> > --- > doc/encoders.texi | 5 +++++ > libavcodec/libopusenc.c | 14 ++++++++++++++ > 2 files changed, 19 insertions(+) > > diff --git a/doc/encoders.texi b/doc/encoders.texi > index 6a410a8cb6..5cd8b1a064 100644 > --- a/doc/encoders.texi > +++ b/doc/encoders.texi > @@ -981,6 +981,11 @@ Other values include 0 for mono and stereo, 1 for surround sound with masking > and LFE bandwidth optimizations, and 255 for independent streams with an > unspecified channel layout. > > +@item disable_phase_inversion (N.A.) (requires libopus >= 1.2) > +If set to 1, disables the use of phase inversion for intensity stereo, > +improving the quality of mono downmixes, but slightly reducing normal stereo > +quality. The default is 0 (phase inversion enabled). Maybe be a bit more drastic. IMO it more than "improves the quality" of mono, but brings it from completely unlistenable to listenable. - Derek > + > @end table > > @anchor{libshine} > diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c > index b449497d15..3ad10502fc 100644 > --- a/libavcodec/libopusenc.c > +++ b/libavcodec/libopusenc.c > @@ -39,6 +39,9 @@ typedef struct LibopusEncOpts { > int packet_size; > int max_bandwidth; > int mapping_family; > +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST > + int disable_phase_inversion; > +#endif > } LibopusEncOpts; > > typedef struct LibopusEncContext { > @@ -154,6 +157,14 @@ static int libopus_configure_encoder(AVCodecContext *avctx, OpusMSEncoder *enc, > "Unable to set maximum bandwidth: %s\n", opus_strerror(ret)); > } > > +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST > + ret = opus_multistream_encoder_ctl(enc, > + OPUS_SET_PHASE_INVERSION_DISABLED(opts->disable_phase_inversion)); > + if (ret != OPUS_OK) > + av_log(avctx, AV_LOG_WARNING, > + "Unable to disable phase inversion: %s\n", > + opus_strerror(ret)); > +#endif > return OPUS_OK; > } > > @@ -530,6 +541,9 @@ static const AVOption libopus_options[] = { > { "on", "Use variable bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "vbr" }, > { "constrained", "Use constrained VBR", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, FLAGS, "vbr" }, > { "mapping_family", "Channel Mapping Family", OFFSET(mapping_family), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, FLAGS, "mapping_family" }, > +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST > + { "disable_phase_inversion", "Disable phase inversion", OFFSET(disable_phase_inversion), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, > +#endif > { NULL }, > }; > >
On 1/22/18, mrdegier@gmail.com <mrdegier@gmail.com> wrote: > From: Menno <mrdegier@gmail.com> > > Signed-off-by: Menno <mrdegier@gmail.com> > --- > doc/encoders.texi | 5 +++++ > libavcodec/libopusenc.c | 14 ++++++++++++++ > 2 files changed, 19 insertions(+) > > diff --git a/doc/encoders.texi b/doc/encoders.texi > index 6a410a8cb6..5cd8b1a064 100644 > --- a/doc/encoders.texi > +++ b/doc/encoders.texi > @@ -981,6 +981,11 @@ Other values include 0 for mono and stereo, 1 for > surround sound with masking > and LFE bandwidth optimizations, and 255 for independent streams with an > unspecified channel layout. > > +@item disable_phase_inversion (N.A.) (requires libopus >= 1.2) > +If set to 1, disables the use of phase inversion for intensity stereo, > +improving the quality of mono downmixes, but slightly reducing normal > stereo > +quality. The default is 0 (phase inversion enabled). > + > @end table > > @anchor{libshine} > diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c > index b449497d15..3ad10502fc 100644 > --- a/libavcodec/libopusenc.c > +++ b/libavcodec/libopusenc.c > @@ -39,6 +39,9 @@ typedef struct LibopusEncOpts { > int packet_size; > int max_bandwidth; > int mapping_family; > +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST > + int disable_phase_inversion; > +#endif > } LibopusEncOpts; > > typedef struct LibopusEncContext { > @@ -154,6 +157,14 @@ static int libopus_configure_encoder(AVCodecContext > *avctx, OpusMSEncoder *enc, > "Unable to set maximum bandwidth: %s\n", > opus_strerror(ret)); > } > > +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST > + ret = opus_multistream_encoder_ctl(enc, > + > OPUS_SET_PHASE_INVERSION_DISABLED(opts->disable_phase_inversion)); > + if (ret != OPUS_OK) > + av_log(avctx, AV_LOG_WARNING, > + "Unable to disable phase inversion: %s\n", > + opus_strerror(ret)); > +#endif > return OPUS_OK; > } > > @@ -530,6 +541,9 @@ static const AVOption libopus_options[] = { > { "on", "Use variable bit rate", 0, AV_OPT_TYPE_CONST, > { .i64 = 1 }, 0, 0, FLAGS, "vbr" }, > { "constrained", "Use constrained VBR", 0, AV_OPT_TYPE_CONST, > { .i64 = 2 }, 0, 0, FLAGS, "vbr" }, > { "mapping_family", "Channel Mapping Family", > OFFSET(mapping_family), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, > FLAGS, "mapping_family" }, > +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST > + { "disable_phase_inversion", "Disable phase inversion", > OFFSET(disable_phase_inversion), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, > FLAGS }, > +#endif > { NULL }, > }; > > -- > 2.14.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > NACK. Option name is too loong, and its type is not boolean.
On 1/22/2018 4:46 PM, Paul B Mahol wrote: > NACK. > > Option name is too loong, and its type is not boolean. Opinions on what to call it welcome. - Derek
2018-01-22 16:16 GMT+01:00 <mrdegier@gmail.com>: > +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST > + { "disable_phase_inversion", "Disable phase inversion", OFFSET(disable_phase_inversion), > AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, One possibility is an option "phase_inversion" that is boolean and defaults to true. Carl Eugen
On 22 January 2018 at 15:16, <mrdegier@gmail.com> wrote: > From: Menno <mrdegier@gmail.com> > > Signed-off-by: Menno <mrdegier@gmail.com> > --- > doc/encoders.texi | 5 +++++ > libavcodec/libopusenc.c | 14 ++++++++++++++ > 2 files changed, 19 insertions(+) > > diff --git a/doc/encoders.texi b/doc/encoders.texi > index 6a410a8cb6..5cd8b1a064 100644 > --- a/doc/encoders.texi > +++ b/doc/encoders.texi > @@ -981,6 +981,11 @@ Other values include 0 for mono and stereo, 1 for > surround sound with masking > and LFE bandwidth optimizations, and 255 for independent streams with an > unspecified channel layout. > > +@item disable_phase_inversion (N.A.) (requires libopus >= 1.2) > +If set to 1, disables the use of phase inversion for intensity stereo, > +improving the quality of mono downmixes, but slightly reducing normal > stereo > +quality. The default is 0 (phase inversion enabled). > + > @end table > > @anchor{libshine} > diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c > index b449497d15..3ad10502fc 100644 > --- a/libavcodec/libopusenc.c > +++ b/libavcodec/libopusenc.c > @@ -39,6 +39,9 @@ typedef struct LibopusEncOpts { > int packet_size; > int max_bandwidth; > int mapping_family; > +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST > + int disable_phase_inversion; > +#endif > } LibopusEncOpts; > > typedef struct LibopusEncContext { > @@ -154,6 +157,14 @@ static int libopus_configure_encoder(AVCodecContext > *avctx, OpusMSEncoder *enc, > "Unable to set maximum bandwidth: %s\n", > opus_strerror(ret)); > } > > +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST > + ret = opus_multistream_encoder_ctl(enc, > + OPUS_SET_PHASE_INVERSION_ > DISABLED(opts->disable_phase_inversion)); > + if (ret != OPUS_OK) > + av_log(avctx, AV_LOG_WARNING, > + "Unable to disable phase inversion: %s\n", > + opus_strerror(ret)); > +#endif > return OPUS_OK; > } > > @@ -530,6 +541,9 @@ static const AVOption libopus_options[] = { > { "on", "Use variable bit rate", 0, > AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "vbr" }, > { "constrained", "Use constrained VBR", 0, > AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, FLAGS, "vbr" }, > { "mapping_family", "Channel Mapping Family", > OFFSET(mapping_family), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, > FLAGS, "mapping_family" }, > +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST > + { "disable_phase_inversion", "Disable phase inversion", > OFFSET(disable_phase_inversion), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, > 1, FLAGS }, > +#endif > { NULL }, > }; > > -- > 2.14.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > Use the existing decoder option: ffmpeg -help decoder=opus > " -apply_phase_inv <boolean> .D..A... Apply intensity stereo phase > inversion (default true)" > Also no patch for the libopus decoder? I wouldn't mind having both in one patch.
diff --git a/doc/encoders.texi b/doc/encoders.texi index 6a410a8cb6..5cd8b1a064 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -981,6 +981,11 @@ Other values include 0 for mono and stereo, 1 for surround sound with masking and LFE bandwidth optimizations, and 255 for independent streams with an unspecified channel layout. +@item disable_phase_inversion (N.A.) (requires libopus >= 1.2) +If set to 1, disables the use of phase inversion for intensity stereo, +improving the quality of mono downmixes, but slightly reducing normal stereo +quality. The default is 0 (phase inversion enabled). + @end table @anchor{libshine} diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index b449497d15..3ad10502fc 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -39,6 +39,9 @@ typedef struct LibopusEncOpts { int packet_size; int max_bandwidth; int mapping_family; +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST + int disable_phase_inversion; +#endif } LibopusEncOpts; typedef struct LibopusEncContext { @@ -154,6 +157,14 @@ static int libopus_configure_encoder(AVCodecContext *avctx, OpusMSEncoder *enc, "Unable to set maximum bandwidth: %s\n", opus_strerror(ret)); } +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST + ret = opus_multistream_encoder_ctl(enc, + OPUS_SET_PHASE_INVERSION_DISABLED(opts->disable_phase_inversion)); + if (ret != OPUS_OK) + av_log(avctx, AV_LOG_WARNING, + "Unable to disable phase inversion: %s\n", + opus_strerror(ret)); +#endif return OPUS_OK; } @@ -530,6 +541,9 @@ static const AVOption libopus_options[] = { { "on", "Use variable bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "vbr" }, { "constrained", "Use constrained VBR", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, FLAGS, "vbr" }, { "mapping_family", "Channel Mapping Family", OFFSET(mapping_family), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, FLAGS, "mapping_family" }, +#ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST + { "disable_phase_inversion", "Disable phase inversion", OFFSET(disable_phase_inversion), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, +#endif { NULL }, };