Commit 069e052f authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Improved renderering of YUVA/P onto YUV variants. refs #539

  I420 still not fixed for this bug.

  A simple average of the UV pixels, wasn't giving satisfying results, so I added a bit more logic, to decide based on the transparency value if UY averaging is desireable for the pixels. Produces nice results now, with a very slight shadow somtimes to the right side of the images/glyphs. Looks quite good. 
parent b7d2846e
...@@ -591,11 +591,19 @@ static void BlendYUVPacked( filter_t *p_filter, picture_t *p_dst_pic, ...@@ -591,11 +591,19 @@ static void BlendYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
p_dst[i_x * 2 + i_l_offset] = p_src2_y[i_x]; p_dst[i_x * 2 + i_l_offset] = p_src2_y[i_x];
if( b_even ) if( b_even )
{
if( p_trans[i_x+1] > 0xaa )
{
p_dst[i_x * 2 + i_u_offset] = (p_src2_u[i_x]+p_src2_u[i_x+1])>>1;
p_dst[i_x * 2 + i_v_offset] = (p_src2_v[i_x]+p_src2_v[i_x+1])>>1;
}
else
{ {
p_dst[i_x * 2 + i_u_offset] = p_src2_u[i_x]; p_dst[i_x * 2 + i_u_offset] = p_src2_u[i_x];
p_dst[i_x * 2 + i_v_offset] = p_src2_v[i_x]; p_dst[i_x * 2 + i_v_offset] = p_src2_v[i_x];
} }
} }
}
else else
{ {
/* Blending */ /* Blending */
...@@ -605,10 +613,22 @@ static void BlendYUVPacked( filter_t *p_filter, picture_t *p_dst_pic, ...@@ -605,10 +613,22 @@ static void BlendYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
if( b_even ) if( b_even )
{ {
p_dst[i_x * 2 + i_u_offset] = ( (uint16_t)p_src2_u[i_x] * i_trans + uint16_t i_u = 0;
uint16_t i_v = 0;
if( p_trans[i_x+1] > 0xaa )
{
i_u = (p_src2_u[i_x]+p_src2_u[i_x+1])>>1;
i_v = (p_src2_v[i_x]+p_src2_v[i_x+1])>>1;
}
else
{
i_u = p_src2_u[i_x];
i_v = p_src2_v[i_x];
}
p_dst[i_x * 2 + i_u_offset] = ( (uint16_t)i_u * i_trans +
(uint16_t)p_src1[i_x * 2 + i_u_offset] * (MAX_TRANS - i_trans) ) (uint16_t)p_src1[i_x * 2 + i_u_offset] * (MAX_TRANS - i_trans) )
>> TRANS_BITS; >> TRANS_BITS;
p_dst[i_x * 2 + i_v_offset] = ( (uint16_t)p_src2_v[i_x] * i_trans + p_dst[i_x * 2 + i_v_offset] = ( (uint16_t)i_v * i_trans +
(uint16_t)p_src1[i_x * 2 + i_v_offset] * (MAX_TRANS - i_trans) ) (uint16_t)p_src1[i_x * 2 + i_v_offset] * (MAX_TRANS - i_trans) )
>> TRANS_BITS; >> TRANS_BITS;
} }
...@@ -799,11 +819,19 @@ static void BlendPalYUVPacked( filter_t *p_filter, picture_t *p_dst_pic, ...@@ -799,11 +819,19 @@ static void BlendPalYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
p_dst[i_x * 2 + i_l_offset] = p_pal[p_src2[i_x]][0]; p_dst[i_x * 2 + i_l_offset] = p_pal[p_src2[i_x]][0];
if( b_even ) if( b_even )
{
if( p_trans[i_x+1] > 0xaa )
{
p_dst[i_x * 2 + i_u_offset] = (p_pal[p_src2[i_x]][1] + p_pal[p_src2[i_x+1]][1]) >> 1;
p_dst[i_x * 2 + i_v_offset] = (p_pal[p_src2[i_x]][2] + p_pal[p_src2[i_x+1]][2]) >> 1;
}
else
{ {
p_dst[i_x * 2 + i_u_offset] = p_pal[p_src2[i_x]][1]; p_dst[i_x * 2 + i_u_offset] = p_pal[p_src2[i_x]][1];
p_dst[i_x * 2 + i_v_offset] = p_pal[p_src2[i_x]][2]; p_dst[i_x * 2 + i_v_offset] = p_pal[p_src2[i_x]][2];
} }
} }
}
else else
{ {
/* Blending */ /* Blending */
...@@ -813,10 +841,23 @@ static void BlendPalYUVPacked( filter_t *p_filter, picture_t *p_dst_pic, ...@@ -813,10 +841,23 @@ static void BlendPalYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
if( b_even ) if( b_even )
{ {
p_dst[i_x * 2 + i_u_offset] = ( (uint16_t)p_pal[p_src2[i_x]][1] * uint16_t i_u = 0;
uint16_t i_v = 0;
if( p_trans[i_x+1] > 0xaa )
{
i_u = (p_pal[p_src2[i_x]][1] + p_pal[p_src2[i_x+1]][1]) >> 1;
i_v = (p_pal[p_src2[i_x]][2] + p_pal[p_src2[i_x+1]][2]) >> 1;
}
else
{
i_u = p_pal[p_src2[i_x]][1];
i_v = p_pal[p_src2[i_x]][2];
}
p_dst[i_x * 2 + i_u_offset] = ( (uint16_t)i_u *
i_trans + (uint16_t)p_src1[i_x * 2 + i_u_offset] * i_trans + (uint16_t)p_src1[i_x * 2 + i_u_offset] *
(MAX_TRANS - i_trans) ) >> TRANS_BITS; (MAX_TRANS - i_trans) ) >> TRANS_BITS;
p_dst[i_x * 2 + i_v_offset] = ( (uint16_t)p_pal[p_src2[i_x]][2] * p_dst[i_x * 2 + i_v_offset] = ( (uint16_t)i_v *
i_trans + (uint16_t)p_src1[i_x * 2 + i_v_offset] * i_trans + (uint16_t)p_src1[i_x * 2 + i_v_offset] *
(MAX_TRANS - i_trans) ) >> TRANS_BITS; (MAX_TRANS - i_trans) ) >> TRANS_BITS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment