libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.75k stars 1.81k forks source link

Camera(Android): Chroma plane(s) shifted #11114

Open Green-Sky opened 1 week ago

Green-Sky commented 1 week ago

I took a look at the camera code and there is nothing obvious wrong with it, however we are not taking into account the stride of the planes and the crop rect(?).

The color format is yuv NV12, displayed unchanged, but it was copied (SurfaceDuplicated). Both front-facing and back-facing cameras are affected, all resolutions I tried too.

It is also not the upload to texture code that is wrong, as converting it to IYUV and sending it over the wire looks the same.

image

slouken commented 1 day ago

Looking at the camera code it's almost certainly wrong, but it would be helpful to have a repro case to test any fix. What Android device are you using to test this?

I assume you're seeing the same problem with SDL's testcamera test program?

Green-Sky commented 15 hours ago

Ok, I hacked the ci to produce the testcamera-apk, since i have neither freespace on my devmachine nor the motivation to bring in the android sdk/ndk. (interesting ci setup)

The output of the test is actually way worse for some reason, but it is also from latest master, so that might have influenced it.

Screenshot_20241018-172927 This is supposed to be a wall. (same wall as in op, but without paper with drawing)

Both front- and backfacing cameras are affected, there is a pattern difference, which I suppose is a result of a resolution difference.

Another thing, when you touch(click) the image, the camera switches to the other, but the text "testcamer: Front-facing camera (android)" stays the same.

slouken commented 15 hours ago

What Android device is this?

Green-Sky commented 15 hours ago

What Android device is this?

OnePlus Nord CE 5G

I am undusting an old Moto G android 7.1 from my drawer right now.

Green-Sky commented 14 hours ago

I am undusting an old Moto G android 7.1 from my drawer right now.

Despite the ndk camera api being introduced 1 API level earlier (7.0), SDL does not see them on this device. (sad)

SDL/APP : Saw 0 camera devices.
SDL/APP : No cameras available?