aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2022-10-02 18:44:47 +0200
committerArisotura <thetotalworm@gmail.com>2022-10-02 18:44:47 +0200
commitaf9a77b0b4880f7362ac85e468a98315133bd39e (patch)
treefedc822baa9955264aa2f09ae3c05a01d1200752 /src
parent3f4573574a581da849408ebc376ca97d5e82bc7d (diff)
camera: fix x-flip crustiness
Diffstat (limited to 'src')
-rw-r--r--src/DSi_Camera.cpp27
-rw-r--r--src/frontend/qt_sdl/CameraManager.cpp32
2 files changed, 45 insertions, 14 deletions
diff --git a/src/DSi_Camera.cpp b/src/DSi_Camera.cpp
index 842a9ee..3c9db2d 100644
--- a/src/DSi_Camera.cpp
+++ b/src/DSi_Camera.cpp
@@ -505,16 +505,29 @@ int Camera::TransferScanline(u32* buffer, int maxlen)
if (FrameReadMode & (1<<1))
sy = 479 - sy;
- for (int dx = 0; dx < retlen; dx++)
+ if (FrameReadMode & (1<<0))
{
- if (dx >= maxlen) break;
+ for (int dx = 0; dx < retlen; dx++)
+ {
+ if (dx >= maxlen) break;
- int sx = (dx * 640) / FrameWidth;
- if (!(FrameReadMode & (1<<0)))
- sx = 639 - sx;
+ int sx = (dx * 640) / FrameWidth;
- u32 pixel3 = FrameBuffer[sy*320 + sx];
- buffer[dx] = pixel3;
+ u32 val = FrameBuffer[sy*320 + sx];
+ buffer[dx] = val;
+ }
+ }
+ else
+ {
+ for (int dx = 0; dx < retlen; dx++)
+ {
+ if (dx >= maxlen) break;
+
+ int sx = 638 - ((dx * 640) / FrameWidth);
+
+ u32 val = FrameBuffer[sy*320 + sx];
+ buffer[dx] = (val & 0xFF00FF00) | ((val >> 16) & 0xFF) | ((val & 0xFF) << 16);
+ }
}
TransferY++;
diff --git a/src/frontend/qt_sdl/CameraManager.cpp b/src/frontend/qt_sdl/CameraManager.cpp
index 23f25a6..d2cb1e5 100644
--- a/src/frontend/qt_sdl/CameraManager.cpp
+++ b/src/frontend/qt_sdl/CameraManager.cpp
@@ -447,13 +447,10 @@ void CameraManager::feedFrame_NV12(u8* planeY, u8* planeUV, int width, int heigh
void CameraManager::copyFrame_Straight(u32* src, int swidth, int sheight, u32* dst, int dwidth, int dheight, bool xflip, bool yuv)
{
- u32 alpha = 0xFF000000;
-
if (yuv)
{
swidth /= 2;
dwidth /= 2;
- alpha = 0;
}
for (int dy = 0; dy < dheight; dy++)
@@ -465,7 +462,19 @@ void CameraManager::copyFrame_Straight(u32* src, int swidth, int sheight, u32* d
int sx = (dx * swidth) / dwidth;
if (xflip) sx = swidth-1 - sx;
- dst[(dy * dwidth) + dx] = src[(sy * swidth) + sx] | alpha;
+ u32 val = src[(sy * swidth) + sx];
+
+ if (yuv)
+ {
+ if (xflip)
+ val = (val & 0xFF00FF00) |
+ ((val >> 16) & 0xFF) |
+ ((val & 0xFF) << 16);
+ }
+ else
+ val |= 0xFF000000;
+
+ dst[(dy * dwidth) + dx] = val;
}
}
}
@@ -530,13 +539,22 @@ void CameraManager::copyFrame_YUVtoRGB(u32* src, int swidth, int sheight, u32* d
for (int dx = 0; dx < dwidth; dx+=2)
{
int sx = (dx * swidth) / dwidth;
- if (xflip) sx = swidth-1 - sx;
+ if (xflip) sx = swidth-2 - sx;
u32 val = src[(sy*swidth + sx) / 2];
- int y1 = val & 0xFF;
+ int y1, y2;
+ if (xflip)
+ {
+ y1 = (val >> 16) & 0xFF;
+ y2 = val & 0xFF;
+ }
+ else
+ {
+ y1 = val & 0xFF;
+ y2 = (val >> 16) & 0xFF;
+ }
int u = (val >> 8) & 0xFF;
- int y2 = (val >> 16) & 0xFF;
int v = (val >> 24) & 0xFF;
u -= 128; v -= 128;