Skip to content

Force VideoReader to decode all YUV video formats to NV12 #3248

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

Merged
merged 3 commits into from
May 27, 2022

Conversation

cudawarped
Copy link
Contributor

@cudawarped cudawarped commented May 8, 2022

Currently VideoReader only supports 8 bit YUV 422/420 video's. This fix allows all supported YUV inputs 10 bit 420, and 8 and 16 bit 444 to be decoded. The approach taken is to truncate all YUV formats to to NV12 instead of including CUDA kernels to convert from P016, YUV444 and YUV444_16Bit to BGR, which is probably overkill for OpenCV and can be included at a later date if desired.

The PR also allows the raw YUV frame to be output as well if desired.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

… indicate this is taking place.

Add YUV output.
@asmorkalov asmorkalov self-requested a review May 18, 2022 07:57
@asmorkalov
Copy link
Contributor

I get build error:

/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_reader.cpp: At global scope:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_reader.cpp:102:14: error: extra qualification ‘{anonymous}::VideoReaderImpl::’ on member ‘set’ [-fpermissive]
         void VideoReaderImpl::set(const ColorFormat _colorFormat) CV_OVERRIDE;

System: Ubuntu 18.04, Video Codec SDK 11.1, Cuda 10.2.

(cherry picked from commit 8f6820c)
@cudawarped
Copy link
Contributor Author

cudawarped commented May 26, 2022

I get build error:

Apologies, I thought I had changed that. Now fixed on both PR's.

@asmorkalov asmorkalov self-requested a review May 27, 2022 05:49
Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

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

👍 LGTM.
Tested on Ubuntu 18.04, CUDA 102, NVIDIA Video Codec SDK 11.1.

@alalek alalek merged commit 9c4738b into opencv:4.x May 27, 2022
hakaboom pushed a commit to hakaboom/opencv_contrib that referenced this pull request Jul 1, 2022
…_to_nv12

Force VideoReader to decode all YUV video formats to NV12

* Force decoding of all supported YUV inputs  to NV12 and log warning to indicate this is taking place.
Add YUV output.

* Update to include missing CUDA stream argument to raw frame copy.

* Fix copy paste oversight.
@alalek alalek mentioned this pull request Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants