diff mbox

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

Message ID 1480625575-2184-1-git-send-email-gregory.wolfe@kodakalaris.com
State Changes Requested
Headers show

Commit Message

Gregory J. Wolfe Dec. 1, 2016, 8:52 p.m. UTC
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@kodakalaris.com>
---
 libavcodec/libopenh264enc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Michael Niedermayer Dec. 13, 2016, 7:28 p.m. UTC | #1
On Thu, Dec 01, 2016 at 03:52:55PM -0500, Gregory J. Wolfe wrote:
> 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@kodakalaris.com>
> ---
>  libavcodec/libopenh264enc.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Commit messages should start with the part that is changes like
libavcodec/libopenh264enc: ...

please see the developer docs, if you havent read them

thx

[...]
Gregory J. Wolfe Dec. 14, 2016, 3:11 p.m. UTC | #2
> -----Original Message-----
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On
> Behalf Of Michael Niedermayer
> Sent: Tuesday, December 13, 2016 2:28 PM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] Allow client to enable/disable
> openh264 load balancing.
> 
> On Thu, Dec 01, 2016 at 03:52:55PM -0500, Gregory J. Wolfe wrote:
> > 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@kodakalaris.com>
> > ---
> >  libavcodec/libopenh264enc.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> 
> Commit messages should start with the part that is changes like
> libavcodec/libopenh264enc: ...
> 
> please see the developer docs, if you haven't read them

Sorry about that.  Before submitting I carefully reviewed the
"Submitting patches" and "patch submission checklist" sections,
but neglected to also go back and review the "Development
Policy" section where it talks about "area changed: ..." in the
commit message.  Will fix and resubmit.

Suggestion:  Add to the patch checklist section a reference back
to this information (to remind infrequent patch submitters like me
who forget stuff from the last time we submitted a patch).

Greg W.

> 
> thx
> 
> [...]
> --
> Michael     GnuPG fingerprint:
> 9FF2128B147EF6730BADF133611EC787040B0FAB
Michael Niedermayer Dec. 14, 2016, 6:20 p.m. UTC | #3
On Wed, Dec 14, 2016 at 03:11:45PM +0000, Gregory J Wolfe wrote:
> > -----Original Message-----
> > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On
> > Behalf Of Michael Niedermayer
> > Sent: Tuesday, December 13, 2016 2:28 PM
> > To: FFmpeg development discussions and patches <ffmpeg-
> > devel@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH] Allow client to enable/disable
> > openh264 load balancing.
> > 
> > On Thu, Dec 01, 2016 at 03:52:55PM -0500, Gregory J. Wolfe wrote:
> > > 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@kodakalaris.com>
> > > ---
> > >  libavcodec/libopenh264enc.c | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > 
> > Commit messages should start with the part that is changes like
> > libavcodec/libopenh264enc: ...
> > 
> > please see the developer docs, if you haven't read them
> 
> Sorry about that.  Before submitting I carefully reviewed the
> "Submitting patches" and "patch submission checklist" sections,
> but neglected to also go back and review the "Development
> Policy" section where it talks about "area changed: ..." in the
> commit message.  Will fix and resubmit.
> 

> Suggestion:  Add to the patch checklist section a reference back
> to this information (to remind infrequent patch submitters like me
> who forget stuff from the last time we submitted a patch).

you can send a patch to improve the patch submission checklist
its in doc/developer.texi

[...]
diff mbox

Patch

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 648f59b..e84de27 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -47,6 +47,7 @@  typedef struct SVCContext {
     int skip_frames;
     int skipped;
     int cabac;
+    int load_balancing;
 } SVCContext;
 
 #define OFFSET(x) offsetof(SVCContext, x)
@@ -71,6 +72,7 @@  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 },
+    { "load_balancing", "enable/disable dynamic slice adjustment for efficient use of multiple threads; if enabled, can produce valid but slightly different results from run to run", OFFSET(load_balancing), AV_OPT_TYPE_BOOL, { .i64 = -1 }, 0, 1, VE },
     { NULL }
 };
 
@@ -150,6 +152,12 @@  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; // default is enabled; -1 means not specified by client
+#else
+    if  ( s->load_balancing != -1 )
+        av_log(avctx, AV_LOG_WARNING, "load_balancing = %d specified, but not supported prior to libopenh264 v1.6\n", s->load_balancing);
+#endif
     if (s->profile && !strcmp(s->profile, "main"))
         param.iEntropyCodingModeFlag = 1;
     else if (!s->profile && s->cabac)