mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-01-22 01:30:35 -05:00
imageviewer: jpegp: improve downscale quality
Use simple area-averaging for smoother images. Change-Id: I7ac2db05262500041286404c97a615e4b3a43194
This commit is contained in:
parent
64e0ced696
commit
7d067ca798
1 changed files with 32 additions and 3 deletions
|
|
@ -229,9 +229,38 @@ static int get_image(struct image_info *info, int frame, int ds)
|
|||
j->Components[2].du[j->Components[2].du_width * ((y / v2) / 8)] + 8 * ((y / v2) & 7);
|
||||
for (x = 0; x < max_x; x += ds)
|
||||
{
|
||||
TCOEF c0 = C0[(x / h0 / 8) * 64 + ((x / h0) & 7)];
|
||||
TCOEF c1 = C1[(x / h1 / 8) * 64 + ((x / h1) & 7)];
|
||||
TCOEF c2 = C2[(x / h2 / 8) * 64 + ((x / h2) & 7)];
|
||||
int c0, c1, c2;
|
||||
if (ds == 1)
|
||||
{
|
||||
c0 = C0[(x / h0 / 8) * 64 + ((x / h0) & 7)];
|
||||
c1 = C1[(x / h1 / 8) * 64 + ((x / h1) & 7)];
|
||||
c2 = C2[(x / h2 / 8) * 64 + ((x / h2) & 7)];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Box filter downsampling (area averaging):
|
||||
Average a ds*ds block of Y/U/V samples per output pixel
|
||||
for simple anti-aliasing without extra buffers */
|
||||
int sumY = 0, sumU = 0, sumV = 0;
|
||||
int dx, dy;
|
||||
int area = ds * ds;
|
||||
for (dy = 0; dy < ds; dy++)
|
||||
{
|
||||
TCOEF *C0_dy = j->Components[0].du[j->Components[0].du_width * (((y + dy) / v0) / 8)] + 8 * (((y + dy) / v0) & 7);
|
||||
TCOEF *C1_dy = j->Components[1].du[j->Components[1].du_width * (((y + dy) / v1) / 8)] + 8 * (((y + dy) / v1) & 7);
|
||||
TCOEF *C2_dy = j->Components[2].du[j->Components[2].du_width * (((y + dy) / v2) / 8)] + 8 * (((y + dy) / v2) & 7);
|
||||
for (dx = 0; dx < ds; dx++)
|
||||
{
|
||||
int sx = x + dx;
|
||||
sumY += C0_dy[((sx / h0 / 8) * 64) + ((sx / h0) & 7)];
|
||||
sumU += C1_dy[((sx / h1 / 8) * 64) + ((sx / h1) & 7)];
|
||||
sumV += C2_dy[((sx / h2 / 8) * 64) + ((sx / h2) & 7)];
|
||||
}
|
||||
}
|
||||
c0 = (sumY + area/2) / area;
|
||||
c1 = (sumU + area/2) / area;
|
||||
c2 = (sumV + area/2) / area;
|
||||
}
|
||||
|
||||
// ITU BT.601 full-range YUV-to-RGB integer approximation
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue