Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

imageviewer: jpegp: improve downscale quality

Use simple area-averaging for smoother images.

Change-Id: I7ac2db05262500041286404c97a615e4b3a43194

authored by

Roman Artiukhin and committed by
Solomon Peachy
7d067ca7 64e0ced6

+32 -3
+32 -3
apps/plugins/imageviewer/jpegp/jpegp.c
··· 229 229 j->Components[2].du[j->Components[2].du_width * ((y / v2) / 8)] + 8 * ((y / v2) & 7); 230 230 for (x = 0; x < max_x; x += ds) 231 231 { 232 - TCOEF c0 = C0[(x / h0 / 8) * 64 + ((x / h0) & 7)]; 233 - TCOEF c1 = C1[(x / h1 / 8) * 64 + ((x / h1) & 7)]; 234 - TCOEF c2 = C2[(x / h2 / 8) * 64 + ((x / h2) & 7)]; 232 + int c0, c1, c2; 233 + if (ds == 1) 234 + { 235 + c0 = C0[(x / h0 / 8) * 64 + ((x / h0) & 7)]; 236 + c1 = C1[(x / h1 / 8) * 64 + ((x / h1) & 7)]; 237 + c2 = C2[(x / h2 / 8) * 64 + ((x / h2) & 7)]; 238 + } 239 + else 240 + { 241 + /* Box filter downsampling (area averaging): 242 + Average a ds*ds block of Y/U/V samples per output pixel 243 + for simple anti-aliasing without extra buffers */ 244 + int sumY = 0, sumU = 0, sumV = 0; 245 + int dx, dy; 246 + int area = ds * ds; 247 + for (dy = 0; dy < ds; dy++) 248 + { 249 + TCOEF *C0_dy = j->Components[0].du[j->Components[0].du_width * (((y + dy) / v0) / 8)] + 8 * (((y + dy) / v0) & 7); 250 + TCOEF *C1_dy = j->Components[1].du[j->Components[1].du_width * (((y + dy) / v1) / 8)] + 8 * (((y + dy) / v1) & 7); 251 + TCOEF *C2_dy = j->Components[2].du[j->Components[2].du_width * (((y + dy) / v2) / 8)] + 8 * (((y + dy) / v2) & 7); 252 + for (dx = 0; dx < ds; dx++) 253 + { 254 + int sx = x + dx; 255 + sumY += C0_dy[((sx / h0 / 8) * 64) + ((sx / h0) & 7)]; 256 + sumU += C1_dy[((sx / h1 / 8) * 64) + ((sx / h1) & 7)]; 257 + sumV += C2_dy[((sx / h2 / 8) * 64) + ((sx / h2) & 7)]; 258 + } 259 + } 260 + c0 = (sumY + area/2) / area; 261 + c1 = (sumU + area/2) / area; 262 + c2 = (sumV + area/2) / area; 263 + } 235 264 236 265 // ITU BT.601 full-range YUV-to-RGB integer approximation 237 266 {