rigaya / NVEnc

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

Green color tint in output file after conversion YUV422P10 source into NV12 format (h264 8bit) #278

Closed vasyl-zabolotniy closed 3 years ago

vasyl-zabolotniy commented 3 years ago

Hi. Looks like I've found a bug - green color tint in output file after conversion YUV422P10 source to NV12 (h264 8bit) Confirmed for YUV422P10 input in the form of Prores/Cineform/Avisynth+ files. Tested on v5.15 and 5.21, no difference. Reported conversion path looks like this: prores (yuv422(10bit)) -> p210 [SSE2] -> ... cspconv ( p210->nv12 ) Would be nice if you can fix it or propose a workaround. Thanks.

rigaya commented 3 years ago

I were not able to find the output file getting green with my 422 10bit input files, it might depend on the input resolution or other conditions.

Would you share the full log and the small screenshot of the green tint?

vasyl-zabolotniy commented 3 years ago

The color tint is very slight, you need to switch between frames/screenshots to see a difference. Also it may depend on the frame content. Another way to check the difference: Load some encoded frame in photoshop, subtract the source frame from it, layers->flatten, image -> auto-contrast, and finally apply 'blur->average' filter. Now, why I thought that it can be a bug. All because of inconsistency:

yuv420p8/yuv422p8 input: both x264 and nvenc shows same slight violet/dark magenta tint in photoshop, but I can't really detect it by eye, even when switching to original frame and back.

yuv422p10/RGB24(magy) input: x264 image shows the same kind of difference to original, but nvenc is different, now it shows green tint in photoshop, and I can see it by eye. So to me it looks like a bug of some kind.

Here is the google-drive link with logs and sample files to test: https://drive.google.com/drive/folders/1qZE0mGMR7OiSP_fV4JgqveRu-kGd8Q1P?usp=sharing

BTW, one of the newly created files (via x265) refuses to be decoded by NVEncc, while plays without issues in HW accel mode on GTX750 ... one more bug to fix I guess ;)

rigaya commented 3 years ago

It seems to be due to handling of truncation in downward bit depth conversion. I have changed the conversion in NVEnc 5.22 which should improve this problem.

vasyl-zabolotniy commented 3 years ago

Just tested v5.22, partially fixed: 10bit -> 8bit is now OK, but the issue is still there for rgb24 -> yuv 8bit conversion

rigaya commented 3 years ago

I have done nothing about RGB in NVEnc 5.22.

You might try adding "--colormatrix smpte170m" as RGB→YUV conversion in NVEncC uses this. As I'm not going to support others, if you are to use other colorspaces, use Avisynth or VapourSynth to convert to YUV.