[FFmpeg-devel] [PATCH, v2] avcodec/amfenc: increase precision of Sleep() on Windows
Timo Rothenpieler
timo at rothenpieler.org
Mon Aug 19 21:31:35 EEST 2024
On 19.08.2024 16:23, Araz Iusubov wrote:
> From: Evgeny Pavlov <lucenticus at gmail.com>
>
> This commit increase precision of Sleep() function on Windows.
> This fix reduces the sleep time on Windows to improve AMF encoding
> performance on low resolution input videos.
>
> Fix for issue #10622
>
> We evaluated CreateWaitableTimerExW with
> CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag. In fact, this function has
> the same precision level as the Sleep() function.
>
> Usually changing the time resolution will only affect the current
> process and will not impact other processes, thus it will not cause a
> global effect on the current system. Here is an info from
> documentation on timeBeginPeriod
> https://learn.microsoft.com/en-us/windows/win32/api/timeapi/nf-timeapi-timebeginperiod
>
> "Prior to Windows 10, version 2004, this function affects a global
> Windows setting. For all processes Windows uses the lowest value (that
> is, highest resolution) requested by any process. Starting with
> Windows 10, version 2004, this function no longer affects global timer
> resolution. For processes which call this function, Windows uses the
> lowest value (that is, highest resolution) requested by any process.
> For processes which have not called this function, Windows does not
> guarantee a higher resolution than the default system resolution."
Even modifying the current process is not acceptable, since lavc is
frequently embedded in other applications, which might not expect
this/be aversely impacted by it.
Why does the AMF wrapper need to sleep at all?
More information about the ffmpeg-devel
mailing list