rigaya / NVEnc

NVENCによる高速エンコードの性能実験
https://rigaya34589.blog.fc2.com/blog-category-17.html
Other
1.09k stars 114 forks source link

Can you implement OPENCL or CUDA support option for motion estimation in NVENC HEVC and AVC? #95

Closed Truth1234 closed 3 months ago

Truth1234 commented 5 years ago

Hello Rigaya!

I asked Nvidia forum about that topic. What do you think about it? What is your own opinion about this idea?

The content of the post:

https://devtalk.nvidia.com/default/topic/1045756/can-you-implement-opencl-or-cuda-support-option-for-motion-estimation-in-nvenc-hevc-and-avc-/

"The X264 codec developers had a great idea, when they gave an option for OPENCL motion estimation in their codec. I know that you can use for example: CUDA for weighted prediction in the NVENC. So it means that you can creatively use the various parts of the GPU in cooperative way. "When OPENCL is enabled, lookahead thread is mostly off-loaded to your OpenCL capable GPU device. Lowres intra cost prediction, lowres motion search (including subpel) and bidir cost predictions are all done on the GPU. " You can add motion perdiction too. However it went trough the CPU and caused bottleneck. However you can avoild this in such way, that all of that computings go trough in the videocard only.

You can use OPENCL or CUDA acceleration for these stuff, it could greatly improve the quality of the best compression modes.

Motion estimation modes: 1. dia, 2. hex, 3. UMH, 4. star, 5. sea, 6. full

Sub pixel precision: 1 half pixel only. 2. half and quarter pixel, 3. 2X half + 1X quartel pixel, 4. 2X(SATD half) + 1Xquarter pixel 5. 2X(SATD half) + 2Xquarter pixel, 6. (SATD half)+ and quarter pixel deep 7. 2X(SATD half)+ quarter pixel deep 8. 2X(SATD half) 2X quarter pixel deep

MAx pixel search range

option for temporar motion perdiction

How can it look in command prompt?

OP = accelerated OPENCL or Cu= if you choose Cuda

Opencl Motion estimation mode =opmem

Opencl Sub pixel precision = opspp

OpenCL Max pixel search range = opmpsr

An example if you want to implement OPENCL: -opmem 4 -opspp 6 -opmpsr 57

An example if you want to implement rather the CUDA : -cumem 4 -cuspp 6 -cumpsr 57

Of course it would be part of quality encoding, so it wouldn't matter if it is not enough fast for 4K live streaming etc. It would be only an option/extension for people who like the better quality encoding like transcoding blu-ray or compressing own video files on the computer. So even the lack of very ultrafast speed encoding is not a huge propblem. Those who care about speed (live streaming of high res video) don't use such options. I think the Opencl or Cuda motion estimation can be enough fast even for high resolution videos too, and more importantly it can make a much better quality motion prediction/estimation than the motion estimation / prediction technology of the NVENC fixed HW unit! So OPENCL and CUDA support for NVENC HW encoding would be a great leap in video quality!"

Best regards!

rigaya commented 5 years ago

Somehow I can't see the page on the link you have shown... https://devtalk.nvidia.com/default/topic/1045756/can-you-implement-opencl-or-cuda-support-option-for-motion-estimation-in-nvenc-hevc-and-avc-/.

Using GPU computing for encoding like x264 OpenCL lookahead accerelation might be interesting, but is difficult for me to implement as I'm not expert in encoders internals. Also current NVENC SDK doesn't seem to allow applications to control the internals of NVENC, so implementing OPENCL or CUDA based motion estimation might not be possible(?)

By the way, I think there had been some other works using GPU computing power for encoding.

Before NVIDIA released NVENC, there was full CUDA based H.264 encoder which could be used by some apps like MediaCoder, but had worse quality than current NVENC.

Also, current implementation of Intel QSV (QuickSyncVideo) partially uses their iGPU Execution Units for motion estimation and some other workloads. (Please checkout the doc p.11) I think this is successful, as QSV on Intel 9.5Gen GPUs are likely to have better quality than Pascal's NVENC.

I think that the implementation of NVENC might be focusing more on realtime streaming (during gaming perhaps(?)), and trying not to use GPU computing power, as it will effect gaming performance.

NoLimits2018 commented 5 years ago

Somehow I can't see the page on the link you have shown... https://devtalk.nvidia.com/default/topic/1045756/can-you-implement-opencl-or-cuda-support-option-for-motion-estimation-in-nvenc-hevc-and-avc-/.

Using GPU computing for encoding like x264 OpenCL lookahead accerelation might be interesting, but is difficult for me to implement as I'm not expert in encoders internals. Also current NVENC SDK doesn't seem to allow applications to control the internals of NVENC, so implementing OPENCL or CUDA based motion estimation might not be possible(?)

By the way, I think there had been some other works using GPU computing power for encoding.

Before NVIDIA released NVENC, there was full CUDA based H.264 encoder which could be used by some apps like MediaCoder, but had worse quality than current NVENC.

Also, current implementation of Intel QSV (QuickSyncVideo) partially uses their iGPU Execution Units for motion estimation and some other workloads. (Please checkout the doc p.11) I think this is successful, as QSV on Intel 9.5Gen GPUs are likely to have better quality than Pascal's NVENC.

I think that the implementation of NVENC might be focusing more on realtime streaming (during gaming perhaps(?)), and trying not to use GPU computing power, as it will effect gaming performance.

Hello Rigaya!

I think the new Nvidia RTX cards has superior quality hevc and AVC encoding performance, according to all tests. There is no higher quality HW encoding than the Turing based NVENC on this planet. Does the Rigaya nvenc support the new Turing based features in HEVC and AVC?

rigaya commented 5 years ago

We'll need NVENC SDK 9.0 for full support of Turing, but has not yet released...

rigaya commented 5 years ago

NVEnc 4.31 adds support for NVENC SDK 9.0, enabling B frame reference mode option(--bref-mode) for HEVC encoding.