Skip to content

Color shift on cv::cudacodec::VideoReader when using multiple threads reading videos from different color spaces in parallel #3934

Open
@laurentchicoine

Description

@laurentchicoine

Following latest updates to fix YUV Conversion #3828, I started to notice an issue with some video colors that is flickering. The issue only happens when launching multiple video readers from multiple threads on a single process (using Python) and when these videos have a different color space for example some videos with yuvj420p (BT470) and others in yuv420p.

In my use case, as a video is being read, new VideoReader are being created on seperate threads.

When investigating the issue I found that this is caused because the code is using a global constant matYuv2Color that is being updated in SetMatYuv2Rgb with call to cudaMemcpyToSymbol.
https://github.com/opencv/opencv_contrib/blame/eebd8977e158d81a4aaf41653a038b82cf6507d4/modules/cudacodec/src/cuda/ColorSpace.cu#L11

So therefore instanciating a new video reader seems to alter that common constant in some way causing a shift of color since the values in the matrix are different for the other video. I'm not yet 100% sure this is the issue since I did not yet work on fixing it.

I'm unsure how to best resolve this optimally for a proper PR.

@cudawarped since you worked on the original fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions