Add simple 2x-4x filters.

This commit is contained in:
Brandon Wright 2010-10-28 05:05:23 -05:00
parent 8b64d6d5a8
commit 4aa58f6dbd
4 changed files with 2478 additions and 2297 deletions

View File

@ -966,6 +966,122 @@ S9xForceHires (void *buffer,
return;
}
void
filter_2x (void *src,
int src_pitch,
void *dst,
int dst_pitch,
int width,
int height)
{
int x, y;
for (y = 0; y < height; y++)
{
uint16 *in = (uint16 *) ((uint8 *) src + y * src_pitch);
uint16 *out1 = (uint16 *) ((uint8 *) dst + (y * 2) * dst_pitch);
uint16 *out2 = (uint16 *) ((uint8 *) dst + ((y * 2) + 1) * dst_pitch);
for (x = 0; x < width; x++)
{
uint16 pixel = *in++;
*out1++ = pixel;
*out1++ = pixel;
*out2++ = pixel;
*out2++ = pixel;
}
}
return;
}
void
filter_3x (void *src,
int src_pitch,
void *dst,
int dst_pitch,
int width,
int height)
{
int x, y;
for (y = 0; y < height; y++)
{
uint16 *in = (uint16 *) ((uint8 *) src + y * src_pitch);
uint16 *out1 = (uint16 *) ((uint8 *) dst + (y * 3) * dst_pitch);
uint16 *out2 = (uint16 *) ((uint8 *) dst + ((y * 3) + 1) * dst_pitch);
uint16 *out3 = (uint16 *) ((uint8 *) dst + ((y * 3) + 2) * dst_pitch);
for (x = 0; x < width; x++)
{
uint16 pixel = *in++;
*out1++ = pixel;
*out1++ = pixel;
*out1++ = pixel;
*out2++ = pixel;
*out2++ = pixel;
*out2++ = pixel;
*out3++ = pixel;
*out3++ = pixel;
*out3++ = pixel;
}
}
return;
}
void
filter_4x (void *src,
int src_pitch,
void *dst,
int dst_pitch,
int width,
int height)
{
int x, y;
for (y = 0; y < height; y++)
{
uint16 *in = (uint16 *) ((uint8 *) src + y * src_pitch);
uint16 *out1 = (uint16 *) ((uint8 *) dst + (y * 4) * dst_pitch);
uint16 *out2 = (uint16 *) ((uint8 *) dst + ((y * 4) + 1) * dst_pitch);
uint16 *out3 = (uint16 *) ((uint8 *) dst + ((y * 4) + 2) * dst_pitch);
uint16 *out4 = (uint16 *) ((uint8 *) dst + ((y * 4) + 3) * dst_pitch);
for (x = 0; x < width; x++)
{
uint16 pixel = *in++;
*out1++ = pixel;
*out1++ = pixel;
*out1++ = pixel;
*out1++ = pixel;
*out2++ = pixel;
*out2++ = pixel;
*out2++ = pixel;
*out2++ = pixel;
*out3++ = pixel;
*out3++ = pixel;
*out3++ = pixel;
*out3++ = pixel;
*out4++ = pixel;
*out4++ = pixel;
*out4++ = pixel;
*out4++ = pixel;
}
}
return;
}
void
filter_scanlines (void *src_buffer,
int src_pitch,
@ -1032,6 +1148,21 @@ get_filter_scale (int &width, int &height)
height *= 2;
break;
case FILTER_SIMPLE2X:
width *= 2;
height *= 2;
break;
case FILTER_SIMPLE3X:
width *= 3;
height *= 3;
break;
case FILTER_SIMPLE4X:
width *= 4;
height *= 4;
break;
#ifdef USE_HQ2X
case FILTER_HQ4X:
if (((width * 4) <= S9xDisplayDriver::scaled_max_width) &&
@ -1168,6 +1299,47 @@ internal_filter (uint8 *src_buffer,
break;
#endif /* USE_HQ2X */
case FILTER_SIMPLE4X:
if (((width * 4) <= S9xDisplayDriver::scaled_max_width) &&
((height * 4) <= S9xDisplayDriver::scaled_max_height))
{
filter_4x (src_buffer,
src_pitch,
dst_buffer,
dst_pitch,
width,
height);
break;
}
case FILTER_SIMPLE3X:
if (width * 3 <= S9xDisplayDriver::scaled_max_width &&
height * 3 <= S9xDisplayDriver::scaled_max_height)
{
filter_3x (src_buffer,
src_pitch,
dst_buffer,
dst_pitch,
width,
height);
break;
}
case FILTER_SIMPLE2X:
filter_2x (src_buffer,
src_pitch,
dst_buffer,
dst_pitch,
width,
height);
break;
case FILTER_EPX:
EPX_16_unsafe (src_buffer,

View File

@ -17,10 +17,13 @@
#define FILTER_EPX_SMOOTH 5
#define FILTER_NTSC 6
#define FILTER_SCANLINES 7
#define FILTER_HQ2X 8
#define FILTER_HQ3X 9
#define FILTER_HQ4X 10
#define NUM_FILTERS 11
#define FILTER_SIMPLE2X 8
#define FILTER_SIMPLE3X 9
#define FILTER_SIMPLE4X 10
#define FILTER_HQ2X 11
#define FILTER_HQ3X 12
#define FILTER_HQ4X 13
#define NUM_FILTERS 14
#define NTSC_COMPOSITE 0
#define NTSC_SVIDEO 1

View File

@ -228,10 +228,7 @@ event_shader_select (GtkButton *widget, gpointer data)
gint result;
GtkEntry *entry;
if (!strcmp (gtk_buildable_get_name (GTK_BUILDABLE (widget)), "fragment_shader_button"))
{
entry = GTK_ENTRY (window->get_widget ("fragment_shader"));
}
entry = GTK_ENTRY (window->get_widget ("fragment_shader"));
dialog = gtk_file_chooser_dialog_new ("Select Shader File",
window->get_window (),

File diff suppressed because it is too large Load Diff