Skip to content

Commit 549c476

Browse files
committedMay 6, 2011
Calculate the 50% scanlines with bit-fiddling.
(cherry picked from commit 4669590)
1 parent 9698470 commit 549c476

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed
 

‎lib/sequence/sequence.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,13 @@ static void video_write(bool update)
356356
int G = Vclip((A - 100 * U - (C >> 1) + 128) >> 8);
357357
int B = Vclip((A + 516 * U + 128) >> 8);
358358

359-
RGBAframe[rgb_offset] = (B << 16) | (G << 8) | (R << 0) | (0xFF << 24);
359+
uint32_t rgba = (B << 16) | (G << 8) | (R << 0) | (0xFF << 24);
360+
361+
RGBAframe[rgb_offset] = rgba;
360362
if (use_scanlines == SCANLINES_50)
361363
{
362364
// halve the rgb values for a dimmed scanline
363-
R /= 2;
364-
G /= 2;
365-
B /= 2;
366-
RGBAframe[rgb_offset + video_width] = (B << 16) | (G << 8) | (R << 0) | (0xff << 24);
365+
RGBAframe[rgb_offset + video_width] = (rgba >> 1 & 0x007f7f7f) | 0xff000000;
367366
}
368367
else if (use_scanlines == SCANLINES_BLACK)
369368
{
@@ -379,14 +378,12 @@ static void video_write(bool update)
379378
G = Vclip((A - 100 * U - (C >> 1) + 128) >> 8);
380379
B = Vclip((A + 516 * U + 128) >> 8);
381380

382-
RGBAframe[rgb_offset] = (B << 16) | (G << 8) | (R << 0) | (0xFF << 24);
381+
rgba = (B << 16) | (G << 8) | (R << 0) | (0xFF << 24);
382+
RGBAframe[rgb_offset] = rgba;
383383
if (use_scanlines == SCANLINES_50)
384384
{
385385
// halve the rgb values for a dimmed scanline
386-
R /= 2;
387-
G /= 2;
388-
B /= 2;
389-
RGBAframe[rgb_offset + video_width] = (B << 16) | (G << 8) | (R << 0) | (0xff << 24);
386+
RGBAframe[rgb_offset + video_width] = (rgba >> 1 & 0x007f7f7f) | 0xff000000;
390387
}
391388
else if (use_scanlines == SCANLINES_BLACK)
392389
{

0 commit comments

Comments
 (0)