Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multithreading support #11

Open
creativefctr opened this issue Feb 23, 2021 · 5 comments
Open

Multithreading support #11

creativefctr opened this issue Feb 23, 2021 · 5 comments

Comments

@creativefctr
Copy link

I couldn't find any info about the state of multithreading in this library. Can you please explain more?

@lieff
Copy link
Owner

lieff commented Feb 23, 2021

Hi)
Multi-threading is supported, but slightly reduces quality.
You need to compile test application with -DH264E_MAX_THREADS=n (where n=max number of threads) and use -threads command line switch:

$ ./h264enc_x64                                                                                                                     ↑
Usage:
    h264e_test [options] <input[frame_size].yuv> <output.264>
Frame size can be: WxH sqcif qvga svga 4vga sxga xga vga qcif 4cif
    4sif cif sif pal ntsc d1 16cif 16sif 720p 4SVGA 4XGA 16VGA 16VGA
Options:
    -gen            - generate input instead of passing <input.yuv>
    -qop<n>         - key frame period >= 0
    -qp<n>          - set QP [10..51]
    -kbps<n>        - set bitrate (fps=30 assumed)
    -maxframes<n>   - encode no more than given number of frames
    -threads<n>     - use <n> threads for encode
    -speed<n>       - speed [0..10], 0 means best quality
    -denoise        - use temporal noise supression
    -stats          - print frame statistics
    -psnr           - print psnr statistics

For example:

./scripts/build_x86.sh
./h264enc_x64 -threads4 vectors/foreman.cif

@creativefctr
Copy link
Author

Thanks! I am curious though as how multi-threading would reduce quality...

@lieff
Copy link
Owner

lieff commented Feb 23, 2021

Quality reduction happen because of image split on n (number of threads) independent parts.

@creativefctr
Copy link
Author

so are you slicing one frame between multiple parts? Or each frame on one thread?

@lieff
Copy link
Owner

lieff commented Feb 23, 2021

Yes, slices are used. Here where per thread start\end macro-block params calculated https://github.com/lieff/minih264/blob/master/minih264e.h#L11323 .

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

No branches or pull requests

2 participants