microsoft / WSA

Developer-related issues and feature requests for Windows Subsystem for Android
MIT License
1.52k stars 836 forks source link

Incorrect frame color when using Nvidia as the WSA graphic device with mediacodec hwaccel #464

Open julee opened 11 months ago

julee commented 11 months ago

Steps to reproduce

My laptop possesses two graphic cards—the integrated Intel graphics card and the NVIDIA GTX 1650 Ti.

Test 1. When I select the NVIDIA graphics card in the WSA configuration and employ the hardware acceleration mediacodec to decode a full-range HEVC video, the information obtained from the logcat log and the MediaFormat after the output format change indicates that the output video frame is in mpeg range. However, when I convert this mpeg range yuv frame to rgba, I discern a deviation in its color from the correct shade (the correct result is using ffmpeg software decoding and converting from full-range yuv to rgba).

Test 2. When I switch the graphics settings to Intel, reboot WSA and the app, the information from the mediacodec decoding illustrates that the output video frame is in mpeg range, which is same with NVIDIA. Howerver, when I convert this mpeg range yuv frame to rgba, the color appears to be accurate.

It appears that irrespective of the original color range of the video, the mediacodec decoder implemented by WSA will uniformly convert it to mpeg range. This poses no issue on the Intel graphics card but results in incorrect colors on NVIDIA. Even when I attempted to convert the yuv frame in Test 1 to rgba as per the full range, the color still was not accurate. It seems that an erroneous conversion occurs in the entire color conversion process when NVIDIA is used as the graphics device for WSA.

✔️ Expected Behavior

Test 1 should have the same result with test2.

And, I don't know why wsa do this color transformation. The most prudent approach would be to abstain from any color transformations and preserve the original color format of the video.

❌ Actual Behavior

NVIDIA mediacodec: nvidia-bug-ffmpegmediacodec-say-output-tv-frame-forcetv

Intel mediacodec: intel-ffmpegmediacodec-say-output-tv-frame-forcesettotv

Software decoding and convert the output frame from yuvj420(full range yuv) to rgba: nvidia-bug-softwaredecode-frame-pc

Other Software

intel driver version: 27.20.100.8935 nvidia driver version: 31.0.15.3667 (536.67) Windows: 11 22H2 22621.2428

Please specify the version of Windows Subsystem for Android

2309.40000.10.0