[FFmpeg-devel] [PATCH 1/3] lavc/qsv: apply AVCodecContext AVOption -threads to QSV
Xiang, Haihao
haihao.xiang at intel.com
Mon Apr 12 09:31:50 EEST 2021
On Sat, 2021-04-10 at 13:32 +0800, Linjie Fu wrote:
> Hi Haihao,
>
> On Thu, Apr 8, 2021 at 3:10 PM Haihao Xiang <haihao.xiang at intel.com> wrote:
> >
> > By default the SDK creates a thread for each CPU when creating a mfx
> > session for decoding / encoding, which results in CPU overhead on a
> > multi CPU system. Actually creating 2 threads is a better choice for
> > most cases in practice.
> >
> > This patch allows user to specify the number of threads created for a
> > mfx session via option -threads. If the number is not specified, 2
> > threads will be created by default.
> >
> > Note the SDK requires at least 2 threads to avoid dead locks[1]
> >
> > [1]
> > https://github.com/Intel-Media-SDK/MediaSDK/blob/master/_studio/mfx_lib/scheduler/linux/src/mfx_scheduler_core_ischeduler.cpp#L90-L93
> > ---
>
> Optional choice for users to specify the thread number looks reasonable to me,
> and decreasing the CPU overhead makes sense for HW encoding pipeline.
>
> Also curious about what's the tradeoff of decreasing the thread number to 2.
> Would the performance or something else drop?
Thanks for the comment. MSDK threads are used to execute MSDK tasks. For hw
decoding /encoding pipeline, these tasks are very light, so we may use a few
threads for msdk tasks. I didn't see performance drop in my testing after
applying this patch.
Regards
Haihao
>
> - linjie
More information about the ffmpeg-devel
mailing list