Skip to content

[Draft] Convert input media type from RBG to YUV #17

Open
federicoveronesi wants to merge 1 commit intoforderud:masterfrom
federicoveronesi:YUV
Open

[Draft] Convert input media type from RBG to YUV #17
federicoveronesi wants to merge 1 commit intoforderud:masterfrom
federicoveronesi:YUV

Conversation

@federicoveronesi
Copy link
Copy Markdown

@federicoveronesi federicoveronesi commented Sep 30, 2021

In this proof of concept code change we remove the implicit conversion from RGB32 to a format supported by H264 MF encoder.
MF H246 encoder support MFVideoFormat_IYUV format
https://docs.microsoft.com/en-us/windows/win32/medfound/h-264-video-encoder

In this code change the frame acquired from screen is converted to YUV and the passed to video encoder.
The result has the same image quality but CPU usage is reduced by ~50% and GPU usage is also reduced by ~30%.

Note: Code seems to be copied from https://github.com/descampsa/yuv2rgb

@forderud
Copy link
Copy Markdown
Owner

Wow! That was a surprisingly large speedup. I guess we can live with a bit more complex implementation if reducing CPU & GPU load as much as 30-40%.

Have you checked if the speedup is consistent across Nvidia vs. Intel vs. no-GPU back-ends, or is it only one of them that is slow without this optimization?

@federicoveronesi
Copy link
Copy Markdown
Author

federicoveronesi commented Oct 1, 2021 via email

@forderud
Copy link
Copy Markdown
Owner

forderud commented Oct 1, 2021

Could it be an idea to combine this PR with a ENABLE_RGB2YUV preprocessor define, so that it becomes simple to compare results with vs. without YUV conversion moving forward?

It seems to me like the code bloat associated with a ENABLE_RGB2YUV define would be quite small. This could be useful both for performance profiling and for color "correctness" comparison.

Comment thread yuv_rgb.h
@@ -0,0 +1,155 @@
// Copyright 2016 Adrien Descamps
// Distributed under BSD 3-Clause License
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a comment that explains where the yuv_rgb.h/cc files are copied from, so that we get some traceability for future updates of this code? You can either add the comment at the top of the files or in the commit comment.

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.

3 participants