summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2020-05-25 14:41:33 +0100
committerLynne <dev@lynne.ee>2020-05-26 10:52:12 +0100
commit2502e13b073370edd62451808ed286f2d7d7a196 (patch)
treeeddc662ca386257b483c868e10214a9f6222f018 /libavcodec
parentc0344cbfb0a11bf76860a660c3662cf469449e24 (diff)
opusenc: add apply_phase_inv option
By popular request. Does the same as in libopusenc.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/opus_pvq.c2
-rw-r--r--libavcodec/opusenc.c3
-rw-r--r--libavcodec/opusenc.h1
3 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c
index 9c21d67298..a4ab7c46eb 100644
--- a/libavcodec/opus_pvq.c
+++ b/libavcodec/opus_pvq.c
@@ -627,7 +627,7 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
}
} else if (stereo) {
if (quant) {
- inv = itheta > 8192;
+ inv = f->apply_phase_inv ? itheta > 8192 : 0;
if (inv) {
for (i = 0; i < N; i++)
Y[i] *= -1;
diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index 3c08ebcf69..953749af3a 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -691,7 +691,7 @@ static av_cold int opus_encode_init(AVCodecContext *avctx)
s->frame[i].avctx = s->avctx;
s->frame[i].seed = 0;
s->frame[i].pvq = s->pvq;
- s->frame[i].apply_phase_inv = 1;
+ s->frame[i].apply_phase_inv = s->options.apply_phase_inv;
s->frame[i].block[0].emph_coeff = s->frame[i].block[1].emph_coeff = 0.0f;
}
@@ -701,6 +701,7 @@ static av_cold int opus_encode_init(AVCodecContext *avctx)
#define OPUSENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
static const AVOption opusenc_options[] = {
{ "opus_delay", "Maximum delay in milliseconds", offsetof(OpusEncContext, options.max_delay_ms), AV_OPT_TYPE_FLOAT, { .dbl = OPUS_MAX_LOOKAHEAD }, 2.5f, OPUS_MAX_LOOKAHEAD, OPUSENC_FLAGS, "max_delay_ms" },
+ { "apply_phase_inv", "Apply intensity stereo phase inversion", offsetof(OpusEncContext, options.apply_phase_inv), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, OPUSENC_FLAGS, "apply_phase_inv" },
{ NULL },
};
diff --git a/libavcodec/opusenc.h b/libavcodec/opusenc.h
index b9162ebec6..b623b3e948 100644
--- a/libavcodec/opusenc.h
+++ b/libavcodec/opusenc.h
@@ -42,6 +42,7 @@
typedef struct OpusEncOptions {
float max_delay_ms;
+ int apply_phase_inv;
} OpusEncOptions;
typedef struct OpusPacketInfo {