Skip to content

perf(decode): enable frame/slice threading - #72

Merged
blocksmith314 merged 1 commit into
mainfrom
perf/decoder-threads
Nov 18, 2026
Merged

blocksmith314 merged 1 commit into
mainfrom
perf/decoder-threads

Conversation

@blocksmith314

Copy link
Copy Markdown
Owner

Summary

Fixes #71: enable FFmpeg frame/slice threading.

  • thread_count defaults to half of the logical cores (minimum 1), leaving headroom for the UI, audio and the rest of the system.
  • thread_type = FF_THREAD_FRAME | FF_THREAD_SLICE; FFmpeg reports the active mode in active_thread_type.
  • DIA_THREADS overrides the count (1 disables threading) for A/B measurements.

Benchmark

big_buck_bunny.h264, 1920x1080, 600 frames (B 494 / P 103 / I 3), 10-core host, decode-only measurements:

Frames Single thread Threaded Speedup
12 35.1 ms 14.1 ms 2.5x
30 69.6 ms 21.0 ms 3.3x
200 362.6 ms 88.6 ms 4.1x
600 1047.6 ms 246.4 ms 4.25x

Backward/large seeks benefit most; short forward jumps from #66 improve less in absolute terms. Slice threading stays inactive on single-slice streams.

Verification

  • ctest: 72/72 pass (seek/step tests with frame threading enabled).
  • tidy.sh ffmpeg/decoder.cpp: 0 issues.

Notes

  • Frame threading adds memory and a small pipeline delay; playback should be checked for dropped frames/CPU.
  • DIA_THREADS=1 gives the old single-threaded behaviour when comparing.

Fixes #71

Use half of the logical cores for decoding (at least one), with
FF_THREAD_FRAME | FF_THREAD_SLICE so FFmpeg picks the usable mode.
DIA_THREADS overrides the count for A/B measurements and 1 disables
threading.

Measured on a 1080p 600-frame B-heavy stream: decoding 200 frames drops
from 363 ms to 89 ms and 600 frames from 1048 ms to 246 ms on a 10-core
host.

Fixes #71
@blocksmith314
blocksmith314 merged commit 23d959e into main Nov 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable FFmpeg frame/slice threading for decoding

1 participant