opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

[Feature] Support 10 bit YUV video in `cv::cudacodec::VideoWriter` and `cv::cudacodec::VideoReader`

Open tvercaut opened this issue 1 year ago • 0 comments

System information (version)
  • OpenCV => 4.9
Detailed description

10 bit video encoding is becoming more mainstream and is supported in nvdec / nvenc. It would thus be great to also support it in cudacodec.

As discussed in https://forum.opencv.org/t/status-and-usage-of-cudacodec-videowriter/17396, 10 bit YUV images could be represented as 16bit integers with the 10 most significant bits corresponding to the actual data.

The relevant nvdec/nvenc pixel formats are:

    NV_ENC_BUFFER_FORMAT_YUV420_10BIT                    = 0x00010000,  /**< 10 bit Semi-Planar YUV [Y plane followed by interleaved UV plane]. Each pixel of size 2 bytes. Most Significant 10 bits contain pixel data. */
    NV_ENC_BUFFER_FORMAT_YUV444_10BIT                    = 0x00100000,  /**< 10 bit Planar YUV444 [Y plane followed by U and V planes]. Each pixel of size 2 bytes. Most Significant 10 bits contain pixel data.  */

https://github.com/FFmpeg/nv-codec-headers/blob/9934f17316b66ce6de12f3b82203a298bc9351d8/include/ffnvcodec/nvEncodeAPI.h#L385-L386

tvercaut avatar Apr 25 '24 16:04 tvercaut