summaryrefslogtreecommitdiffstats
path: root/media/ffvpx/opusenc-dtx.patch
blob: bf9fc9de87fececf9114bcb5e8bf1141b03dc7b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
diff --git a/media/ffvpx/libavcodec/libopusenc.c b/media/ffvpx/libavcodec/libopusenc.c
--- a/media/ffvpx/libavcodec/libopusenc.c
+++ b/media/ffvpx/libavcodec/libopusenc.c
@@ -37,16 +37,17 @@ typedef struct LibopusEncOpts {
     int application;
     int packet_loss;
     int fec;
     int complexity;
     float frame_duration;
     int packet_size;
     int max_bandwidth;
     int mapping_family;
+    int dtx;
 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
     int apply_phase_inv;
 #endif
 } LibopusEncOpts;
 
 typedef struct LibopusEncContext {
     AVClass *class;
     OpusMSEncoder *enc;
@@ -154,16 +155,23 @@ static int libopus_configure_encoder(AVC
 
     ret = opus_multistream_encoder_ctl(enc,
                                        OPUS_SET_INBAND_FEC(opts->fec));
     if (ret != OPUS_OK)
         av_log(avctx, AV_LOG_WARNING,
                "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));
         if (ret != OPUS_OK)
             av_log(avctx, AV_LOG_WARNING,
                    "Unable to set maximum bandwidth: %s\n", opus_strerror(ret));
     }
 
@@ -551,16 +559,17 @@ static const AVOption libopus_options[] 
     { "frame_duration", "Duration of a frame in milliseconds", OFFSET(frame_duration), AV_OPT_TYPE_FLOAT, { .dbl = 20.0 }, 2.5, 120.0, FLAGS },
     { "packet_loss",    "Expected packet loss percentage",     OFFSET(packet_loss),    AV_OPT_TYPE_INT,   { .i64 = 0 },    0,   100,  FLAGS },
     { "fec",             "Enable inband FEC. Expected packet loss must be non-zero",     OFFSET(fec),    AV_OPT_TYPE_BOOL,   { .i64 = 0 }, 0, 1, FLAGS },
     { "vbr",            "Variable bit rate mode",              OFFSET(vbr),            AV_OPT_TYPE_INT,   { .i64 = 1 },    0,   2,    FLAGS, "vbr" },
         { "off",            "Use constant bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "vbr" },
         { "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" },
+    { "dtx", "Enable DTX", 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
     { NULL },
 };
 
 static const AVClass libopus_class = {
     .class_name = "libopus",