[FFmpeg-devel] [Ffmpeg-devel] [PATCH] Add a maximum constraint of 16 encoder threads.
Chirag Lathia
clathia at google.com
Fri Nov 16 02:21:58 EET 2018
Updated with James' review comment to cover the avctx->thread_count as well.
Signed-off-by: Chirag Lathia <clathia at google.com>
---
libavcodec/libvpxenc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index ad440a9c21..da9b9c6d46 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -497,7 +497,8 @@ static av_cold int vpx_init(AVCodecContext *avctx,
enccfg.g_h = avctx->height;
enccfg.g_timebase.num = avctx->time_base.num;
enccfg.g_timebase.den = avctx->time_base.den;
- enccfg.g_threads = avctx->thread_count ? avctx->thread_count
: av_cpu_count();
+ enccfg.g_threads =
+ FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 16);
enccfg.g_lag_in_frames= ctx->lag_in_frames;
if (avctx->flags & AV_CODEC_FLAG_PASS1)
--
On Thu, Nov 15, 2018 at 3:00 PM James Almer <jamrial at gmail.com> wrote:
>
> On 11/15/2018 4:45 PM, Chirag Lathia wrote:
> > libvpx supports a maximum of 16 encoder threads.
> >
> > Signed-off-by: Chirag Lathia <clathia at google.com>
> > ---
> > libavcodec/libvpxenc.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> > index ad440a9c21..dda4b96fb2 100644
> > --- a/libavcodec/libvpxenc.c
> > +++ b/libavcodec/libvpxenc.c
> > @@ -497,7 +497,8 @@ static av_cold int vpx_init(AVCodecContext *avctx,
> > enccfg.g_h = avctx->height;
> > enccfg.g_timebase.num = avctx->time_base.num;
> > enccfg.g_timebase.den = avctx->time_base.den;
> > - enccfg.g_threads = avctx->thread_count ? avctx->thread_count
> > : av_cpu_count();
> > + enccfg.g_threads =
> > + avctx->thread_count ? avctx->thread_count : FFMIN(av_cpu_count(), 16);
> > enccfg.g_lag_in_frames= ctx->lag_in_frames;
>
> The FFMIN should also cover the case where the value is set to
> avctx->thread_count, as it may also be > 16.
>
> See the libvpx decoder wrapper.
>
> >
> > if (avctx->flags & AV_CODEC_FLAG_PASS1)
> > --
> >
> >
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-a-maximum-constraint-of-16-encoder-threads.patch
Type: text/x-patch
Size: 1051 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20181115/f92e5136/attachment.bin>
More information about the ffmpeg-devel
mailing list