Sunshine icon indicating copy to clipboard operation
Sunshine copied to clipboard

Fix CUDA RGBA to NV12 conversion

Open w0utert opened this issue 3 years ago • 2 comments

Description

On linux hosts with Nvidia GPU and CUDA support enabled, a CUDA kernel is used to convert captured RGBA frames to NV12 before encoding. This kernel contained a bug affecting image quality, in particular when rendering high-contrast colored text and sharp lines. See [1] for more information.

This commit fixes the format conversion kernel by taking 2x2 RGBA blocks to generate 4 luma (Y) values and 1 chroma (UV) pair, ie: 12 bits per pixel YUV420 (NV12). Previous code incorrectly generated 1 UV pair for every 2 pixels.

[1] https://github.com/LizardByte/Sunshine/issues/154

Screenshot

Issues Fixed or Closed

  • Fixes #154

Type of Change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have added or updated the docstring/documentation-blocks for new or existing methods/components

w0utert avatar Oct 10 '22 19:10 w0utert

Does this completely fix 154? Or partially?

ReenigneArcher avatar Oct 10 '22 19:10 ReenigneArcher

Yes, it completely fixes #154

w0utert avatar Oct 10 '22 19:10 w0utert