RetroArch icon indicating copy to clipboard operation
RetroArch copied to clipboard

Android: jpeg loading is broken.

Open kokoko3k opened this issue 2 years ago • 11 comments

Description

Jpg luts loads fine on pc, but have issues on Android.

-Edit: the issue is general and happens even on image display core. example file here, some jpgs loads fine tho: https://raw.githubusercontent.com/kokoko3k/koko-aio-slang/main/textures/overlays/gba.jpg

Expected behavior

Same behaviour between pc and mobile, possibly the best of all.

Actual behavior

On pc it works good, on mobile it does not so. Android: image PC: image

Steps to reproduce the bug

  1. use this preset On PC https://github.com/kokoko3k/koko-aio-slang/blob/main/presets-ng/Handhelds/GameboyAdvance-Overlay.slangp
  2. use the same on android
  3. Spot differences

Version/Commit

You can find this information under Information/System Information

  • RetroArch: 1581ece Mar 17, 2023

  • OS: Android 10

kokoko3k avatar May 30 '23 08:05 kokoko3k

Looks like maybe it's not handling semi-alpha properly?

hizzlekizzle avatar May 30 '23 13:05 hizzlekizzle

What's semi-alpha in jpg? I don't think i enabled anything like that in gimp, it is just a background picture, so no apha use intended.

kokoko3k avatar May 30 '23 14:05 kokoko3k

it needs alpha to let the game come through, right? or are you mixing them based on texcoord or something? Most of the png borders use alpha for the viewport and then mix(screen, border, border.a).

hizzlekizzle avatar May 30 '23 14:05 hizzlekizzle

Yes, this is a Jpg, no alpha involved. I just paint the content over it, that way i can have 350KB instead of 1.9MB.

kokoko3k avatar May 30 '23 15:05 kokoko3k

I just tried to load the following image via retroarch image display core and the artifacts are still there as well, so the issue is not bound to shader ecosystem:

https://raw.githubusercontent.com/kokoko3k/koko-aio-slang/main/textures/overlays/gba.jpg

This would hopefully simplify the bug reproduction.

kokoko3k avatar Jun 20 '23 00:06 kokoko3k

You need to use PNG if you want transparency

LibretroAdmin avatar Jul 17 '23 11:07 LibretroAdmin

You need to use PNG if you want transparency

But i dont want transparency, my intent is to use a jpg since i DONT need transparency, so that i can keep filesize low.

Other than that, the issue seems to be deeper; jpg loading is completely broken on android, not just the shader luts, it is all described.

kokoko3k avatar Jul 17 '23 11:07 kokoko3k

Inspecting the zones where artifacts are shown reveals that the artifacts appear where some components are set to 0.0, so It seems i found a workaround; highering the image black level to +5 via gimp and then export it to jpg, makes the glitches go away.

image

This works in image viewer and in lut loading by the shader, as I suspect they share the same texture load function; of course the issue persists and this is just a lucky workaround.

kokoko3k avatar Sep 21 '23 12:09 kokoko3k

Ah-hah! Same problem is behind #16927 . I checked it by modding the image attached in that issue with imagemagick: convert-im6 bad_color_on_Android.jpg +level 10%,100% bad_color_adjusted.jpg The resulting image loads nicely. (But does not look the same, of course.)

I took a look at the included RJPEG code, but it is not likely that the problem is in the decoding part (and also it was customized quite a bit, so getting the changes from upstream is non-trivial).

zoltanvb avatar Sep 15 '24 07:09 zoltanvb

I took a look at the included RJPEG code, but it is not likely that the problem is in the decoding part

Why do you think that?

kokoko3k avatar Sep 15 '24 07:09 kokoko3k

It is common for all platforms, and I see no similar issue reported against upstream (stb_image). On the other hand, it is weird that it is only JPGs, I have not spent so much time so far on this part of RA code.

zoltanvb avatar Sep 15 '24 07:09 zoltanvb