Skip to content

Commit

Permalink
Calculate the 50% scanlines with bit-fiddling.
Browse files Browse the repository at this point in the history
(cherry picked from commit 4669590)
  • Loading branch information
cybersphinx committed May 6, 2011
1 parent 9698470 commit 549c476
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/sequence/sequence.c
Expand Up @@ -356,14 +356,13 @@ static void video_write(bool update)
int G = Vclip((A - 100 * U - (C >> 1) + 128) >> 8);
int B = Vclip((A + 516 * U + 128) >> 8);

RGBAframe[rgb_offset] = (B << 16) | (G << 8) | (R << 0) | (0xFF << 24);
uint32_t rgba = (B << 16) | (G << 8) | (R << 0) | (0xFF << 24);

RGBAframe[rgb_offset] = rgba;
if (use_scanlines == SCANLINES_50)
{
// halve the rgb values for a dimmed scanline
R /= 2;
G /= 2;
B /= 2;
RGBAframe[rgb_offset + video_width] = (B << 16) | (G << 8) | (R << 0) | (0xff << 24);
RGBAframe[rgb_offset + video_width] = (rgba >> 1 & 0x007f7f7f) | 0xff000000;
}
else if (use_scanlines == SCANLINES_BLACK)
{
Expand All @@ -379,14 +378,12 @@ static void video_write(bool update)
G = Vclip((A - 100 * U - (C >> 1) + 128) >> 8);
B = Vclip((A + 516 * U + 128) >> 8);

RGBAframe[rgb_offset] = (B << 16) | (G << 8) | (R << 0) | (0xFF << 24);
rgba = (B << 16) | (G << 8) | (R << 0) | (0xFF << 24);
RGBAframe[rgb_offset] = rgba;
if (use_scanlines == SCANLINES_50)
{
// halve the rgb values for a dimmed scanline
R /= 2;
G /= 2;
B /= 2;
RGBAframe[rgb_offset + video_width] = (B << 16) | (G << 8) | (R << 0) | (0xff << 24);
RGBAframe[rgb_offset + video_width] = (rgba >> 1 & 0x007f7f7f) | 0xff000000;
}
else if (use_scanlines == SCANLINES_BLACK)
{
Expand Down

0 comments on commit 549c476

Please sign in to comment.