-
Notifications
You must be signed in to change notification settings - Fork 269
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
Optimise decklink producer video filtering #1253
Conversation
Where is the correct colorspace conversion code? Server 2.1 was simply wrong on this. |
The mixer was already coded to account for rec709 (or the sd equivalent) when converting ycbcr to rgb, so this is leaving it to be done there rather than via ffmpeg. |
Ok, but how does the mixer decide about the color matrix to use? |
The mixer decides which color matrix to use based on an sd/hd swiitch set from the channel image height. |
Ok, but that might lead to problems for 1080p50 and higher resolutions as they can be BT.709 or BT.2020. |
If/when that is a problem then it would be simple to inform the mixer of what to use rather than leaving it guess. |
I would prefer to add a colormatrix parameter to the mixerright now instead of guessing only on picture height. |
Yes, I agree that a parameter would be a good idea. Should be pretty quick to add an auto/sd/hd enum on whatever pix_desc is for that. |
I agree it would be much better to handle colorspace correctly but there are a few issues:
All of this is addressable but I imagine any changes ought to propagate to all producers. On a more pedantic point, should we worry about the fact that the current code is not taking any account of the differing chromaticity coordinates and potential differing gamma of the various standards? BT.2020 in particular includes a wider color gamut which means that more processing is required to correctly handle it when mixing with other standards. The other outlier is sRGB which has a quite different gamma curve and does not seem to be handled in the code currently. I would have some concerns about trying to address these issues in an 8-bit processing pipeline and fixing all this systematically will consume more CPU and or GPU cycles and may lead to some 8-bit processing artefacts that are not visible right now. Then we just have to worry about HDR! Since the existing code doesn't handle 2020 either I propose that these proposed changes should be carefully written up as a new issue. Thoughts? |
Well, in the meantine I thought a littlebit about it. As CasparCG currently does only support SDR and all mixing is done in 8-bit sRGB (and „full range“) only conversion from/to BT.709 and BT.601/BT.470 needs to be supported. For WCG and HDR much more things need to be changed so I think this should be out of the focus for now. sRGB and BT.709 share at least the same primary chromaticities. Other charcteristics are at least simillar so I think it should be ok for now. Maybe we should have a look at it at a later time again to make shure it is accurate enough. |
What is an issue is the different gamma curve between BT.709 and sRGB. Well I think sooner or later it is You can find some informations here https://stackoverflow.com/questions/6397817/color-spaces-gamma-and-image-enhancement |
@premultiply we did internally briefly discuss larger changes like that to the mixer, but it was decided to not do it yet @scriptorian Ah, I did not realise we were creating it from an AVFrame via some abstractions. That does make it fiddlier than I was hoping. Lets leave it like this for now then as it should be accurate, and it can be revisited with larger work on the mixer |
Comparing V2.1 and V2.2 decklink producers there is a lot more CPU processing required by FFmpeg filters in V2.2. Interlaced sources are now always deinterlaced but in addition there are colorspace and fps filters added. In addition the filter output pixel format is set to BGRA which requires a CPU-based color conversion when this conversion is available on the GPU as part of the mixer.
This pull request optimises these extra filters to reduce CPU load as follows:
Early testing showed a 30% reduction in CPU load on a 6-channel setup.
Comments welcome.