Message ID | 1480368541-28996-1-git-send-email-gregory.wolfe@kodakalaris.com |
---|---|
State | Superseded |
Headers | show |
On Mon, Nov 28, 2016 at 16:29:01 -0500, Gregory J. Wolfe wrote: > +#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 This could use a documentation update. And since documentation isn't built conditionally, the option could be made available unconditionally, and this: > +#if OPENH264_VER_AT_LEAST(1, 6) > + param.bUseLoadBalancing = s->load_balancing; > +#endif be made to print a warning in an #else .. #endif case. (Perhaps make the AV_OPT_TYPE_BOOL option default to -1 in order to detect whether it was set.) Just suggesting, Moritz
> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On > Behalf Of Moritz Barsnick > Sent: Tuesday, November 29, 2016 7:15 AM > To: FFmpeg development discussions and patches <ffmpeg- > devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] Allow client to enable/disable > openh264 load balancing. > > On Mon, Nov 28, 2016 at 16:29:01 -0500, Gregory J. Wolfe wrote: > > +#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 > > This could use a documentation update. Not sure exactly what you mean by "documentation update". Some comments in the code, or more verbosity than "enable/disable load balancing"? Please elaborate. > > And since documentation isn't built conditionally, the option could be > made available unconditionally, and this: > > > +#if OPENH264_VER_AT_LEAST(1, 6) > > + param.bUseLoadBalancing = s->load_balancing; > > +#endif > > be made to print a warning in an #else .. #endif case. (Perhaps make > the AV_OPT_TYPE_BOOL option default to -1 in order to detect > whether it > was set.) WRT "default to -1", original intent was to have the default value match the libopenh264 internal default value. What should happen if the value is not set? > > Just suggesting, > Moritz More than happy to enhance this patch, waiting for clarification. Greg W.
On Wed, Nov 30, 2016 at 16:44:40 +0000, Gregory J Wolfe wrote: > Not sure exactly what you mean by "documentation update". Some > comments in the code, or more verbosity than "enable/disable load > balancing"? Please elaborate. I was referring to doc/encoders.texi, but just noticed that libopenh264enc already supports a whole host of options which have remained undocumented so far. So no point in complaining now, sorry. ;-) > WRT "default to -1", original intent was to have the default value match > the libopenh264 internal default value. What should happen if the value > is not set? Your newer patch is what I was looking for. Cheers, Moritz
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)
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 | 9 +++++++++ 1 file changed, 9 insertions(+)