libfreerdp-rfx: correct the way of filling tile edge for better encoding quality.

This commit is contained in:
Vic Lee 2011-08-26 15:01:57 +08:00
parent 4d1344c698
commit a5e8bc64cf

View File

@ -37,6 +37,8 @@ static void rfx_encode_format_rgb(const uint8* rgb_data, int width, int height,
int x_exceed; int x_exceed;
int y_exceed; int y_exceed;
const uint8* src; const uint8* src;
sint16 r, g, b;
sint16 *r_last, *g_last, *b_last;
x_exceed = 64 - width; x_exceed = 64 - width;
y_exceed = 64 - height; y_exceed = 64 - height;
@ -83,24 +85,37 @@ static void rfx_encode_format_rgb(const uint8* rgb_data, int width, int height,
default: default:
break; break;
} }
/* Fill the horizontal region outside of 64x64 tile size to 0 in order to be better compressed. */ /* Fill the horizontal region outside of 64x64 tile size with the right-most pixel for best quality */
if (x_exceed > 0) if (x_exceed > 0)
{ {
memset(r_buf, 0, x_exceed * sizeof(sint16)); r = *(r_buf - 1);
memset(g_buf, 0, x_exceed * sizeof(sint16)); g = *(g_buf - 1);
memset(b_buf, 0, x_exceed * sizeof(sint16)); b = *(b_buf - 1);
r_buf += x_exceed; for (x = 0; x < x_exceed; x++)
g_buf += x_exceed; {
b_buf += x_exceed; *r_buf++ = r;
*g_buf++ = g;
*b_buf++ = b;
}
} }
} }
/* Fill the vertical region outside of 64x64 tile size to 0 in order to be better compressed. */ /* Fill the vertical region outside of 64x64 tile size with the last line. */
if (y_exceed > 0) if (y_exceed > 0)
{ {
memset(r_buf, 0, y_exceed * 64 * sizeof(sint16)); r_last = r_buf - 64;
memset(g_buf, 0, y_exceed * 64 * sizeof(sint16)); g_last = g_buf - 64;
memset(b_buf, 0, y_exceed * 64 * sizeof(sint16)); b_last = b_buf - 64;
while (y_exceed > 0)
{
memcpy(r_buf, r_last, 64 * sizeof(sint16));
memcpy(g_buf, g_last, 64 * sizeof(sint16));
memcpy(b_buf, b_last, 64 * sizeof(sint16));
r_buf += 64;
g_buf += 64;
b_buf += 64;
y_exceed--;
}
} }
} }