[FFmpeg-devel] [PATCH] Allow client to enable/disable openh264 load balancing.

Gregory J. Wolfe gregory.wolfe at kodakalaris.com
Mon Nov 28 23:29:01 EET 2016


The libopenh264 library allows the client to enable or disable
load balancing when running multi-threaded.  When enabled, the
slice sizes are dynamically adjusted in order to use the
multiple threads more efficiently.  However, this can also lead
to valid but slightly different results from run to run.
Disabling load balancing prevents dynamic slice adjustment and
yields repeatable results when running multi-threaded, which can
be important when running test cases.

Signed-off-by: Gregory J. Wolfe <gregory.wolfe at kodakalaris.com>
---
 libavcodec/libopenh264enc.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 648f59b..5aa1596 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -47,6 +47,9 @@ typedef struct SVCContext {
     int skip_frames;
     int skipped;
     int cabac;
+#if OPENH264_VER_AT_LEAST(1, 6)
+    int load_balancing;
+#endif
 } SVCContext;
 
 #define OFFSET(x) offsetof(SVCContext, x)
@@ -71,6 +74,9 @@ static const AVOption options[] = {
     { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
     { "allow_skip_frames", "allow skipping frames to hit the target bitrate", OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
     { "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+#if OPENH264_VER_AT_LEAST(1, 6)
+    { "load_balancing", "enable/disable load balancing", OFFSET(load_balancing), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE },
+#endif
     { NULL }
 };
 
@@ -150,6 +156,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
     param.iLoopFilterDisableIdc      = !s->loopfilter;
     param.iEntropyCodingModeFlag     = 0;
     param.iMultipleThreadIdc         = avctx->thread_count;
+#if OPENH264_VER_AT_LEAST(1, 6)
+    param.bUseLoadBalancing          = s->load_balancing;
+#endif
     if (s->profile && !strcmp(s->profile, "main"))
         param.iEntropyCodingModeFlag = 1;
     else if (!s->profile && s->cabac)
-- 
2.5.1.windows.1



More information about the ffmpeg-devel mailing list