Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Paul Adenot <padenot@mozilla.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Paul Adenot <padenot@mozilla.com>
Subject: [FFmpeg-devel] [PATCH] avcodec: Allow enabling DTX in libopusenc
Date: Tue, 26 Mar 2024 15:20:29 +0100
Message-ID: <20240326142029.1715497-1-paul@paul.cx> (raw)

From: Paul Adenot <padenot@mozilla.com>

---
 doc/encoders.texi       | 4 ++++
 libavcodec/libopusenc.c | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 7c223ed74c..d459b2865f 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1000,6 +1000,10 @@ 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 dtx (N.A.)
+Allow discontinuous transmission when set to 1. The default value is 0
+(disabled).
+
 @item apply_phase_inv (N.A.) (requires libopus >= 1.2)
 If set to 0, disables the use of phase inversion for intensity stereo,
 improving the quality of mono downmixes, but slightly reducing normal stereo
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index af25f27f74..e727448cdd 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -42,6 +42,7 @@ typedef struct LibopusEncOpts {
     int packet_size;
     int max_bandwidth;
     int mapping_family;
+    int dtx;
 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
     int apply_phase_inv;
 #endif
@@ -159,6 +160,13 @@ static int libopus_configure_encoder(AVCodecContext *avctx, OpusMSEncoder *enc,
                "Unable to set inband FEC: %s\n",
                opus_strerror(ret));
 
+    ret = opus_multistream_encoder_ctl(enc,
+                                       OPUS_SET_DTX(opts->dtx));
+    if (ret != OPUS_OK)
+        av_log(avctx, AV_LOG_WARNING,
+               "Unable to set DTX: %s\n",
+               opus_strerror(ret));
+
     if (avctx->cutoff) {
         ret = opus_multistream_encoder_ctl(enc,
                                            OPUS_SET_MAX_BANDWIDTH(opts->max_bandwidth));
@@ -556,6 +564,7 @@ static const AVOption libopus_options[] = {
         { "on",             "Use variable bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, .unit = "vbr" },
         { "constrained",    "Use constrained VBR",   0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, FLAGS, .unit = "vbr" },
     { "mapping_family", "Channel Mapping Family",              OFFSET(mapping_family), AV_OPT_TYPE_INT,   { .i64 = -1 },   -1,  255,  FLAGS, .unit = "mapping_family" },
+    { "dtx", "Enable DTX (Discontinuous transmission)", OFFSET(dtx), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
     { "apply_phase_inv", "Apply intensity stereo phase inversion", OFFSET(apply_phase_inv), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
 #endif
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

                 reply	other threads:[~2024-03-26 14:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240326142029.1715497-1-paul@paul.cx \
    --to=padenot@mozilla.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git