mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Further video filter additions
This commit is contained in:
parent
9ac393fa02
commit
54f2156954
@ -2260,8 +2260,11 @@ ifeq ($(HAVE_STATIC_VIDEO_FILTERS), 1)
|
||||
gfx/video_filters/lq2x.o \
|
||||
gfx/video_filters/phosphor2x.o \
|
||||
gfx/video_filters/normal2x.o \
|
||||
gfx/video_filters/normal2x_width.o \
|
||||
gfx/video_filters/normal2x_height.o \
|
||||
gfx/video_filters/scanline2x.o \
|
||||
gfx/video_filters/grid2x.o \
|
||||
gfx/video_filters/grid3x.o \
|
||||
gfx/video_filters/gameboy3x.o \
|
||||
gfx/video_filters/gameboy4x.o \
|
||||
gfx/video_filters/dot_matrix_3x.o \
|
||||
|
@ -280,8 +280,11 @@ extern const struct softfilter_implementation *twoxbr_get_implementation(softfil
|
||||
extern const struct softfilter_implementation *darken_get_implementation(softfilter_simd_mask_t simd);
|
||||
extern const struct softfilter_implementation *scale2x_get_implementation(softfilter_simd_mask_t simd);
|
||||
extern const struct softfilter_implementation *normal2x_get_implementation(softfilter_simd_mask_t simd);
|
||||
extern const struct softfilter_implementation *normal2x_width_get_implementation(softfilter_simd_mask_t simd);
|
||||
extern const struct softfilter_implementation *normal2x_height_get_implementation(softfilter_simd_mask_t simd);
|
||||
extern const struct softfilter_implementation *scanline2x_get_implementation(softfilter_simd_mask_t simd);
|
||||
extern const struct softfilter_implementation *grid2x_get_implementation(softfilter_simd_mask_t simd);
|
||||
extern const struct softfilter_implementation *grid3x_get_implementation(softfilter_simd_mask_t simd);
|
||||
extern const struct softfilter_implementation *gameboy3x_get_implementation(softfilter_simd_mask_t simd);
|
||||
extern const struct softfilter_implementation *gameboy4x_get_implementation(softfilter_simd_mask_t simd);
|
||||
extern const struct softfilter_implementation *dot_matrix_3x_get_implementation(softfilter_simd_mask_t simd);
|
||||
@ -299,8 +302,11 @@ static const softfilter_get_implementation_t soft_plugs_builtin[] = {
|
||||
epx_get_implementation,
|
||||
scale2x_get_implementation,
|
||||
normal2x_get_implementation,
|
||||
normal2x_width_get_implementation,
|
||||
normal2x_height_get_implementation,
|
||||
scanline2x_get_implementation,
|
||||
grid2x_get_implementation,
|
||||
grid3x_get_implementation,
|
||||
gameboy3x_get_implementation,
|
||||
gameboy4x_get_implementation,
|
||||
dot_matrix_3x_get_implementation,
|
||||
|
4
gfx/video_filters/Dot_Matrix_3x_Dark_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_3x_Dark_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_3x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_3x_grid_color = 0x808080
|
4
gfx/video_filters/Dot_Matrix_3x_GB_DMG_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_3x_GB_DMG_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_3x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_3x_grid_color = 0x5C8A00
|
4
gfx/video_filters/Dot_Matrix_3x_GB_Greenscale_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_3x_GB_Greenscale_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_3x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_3x_grid_color = 0xA3C70D
|
4
gfx/video_filters/Dot_Matrix_3x_GB_Light_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_3x_GB_Light_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_3x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_3x_grid_color = 0x01D3E8
|
4
gfx/video_filters/Dot_Matrix_3x_GB_Pocket_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_3x_GB_Pocket_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_3x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_3x_grid_color = 0xADB8A0
|
4
gfx/video_filters/Dot_Matrix_3x_GB_TI-83_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_3x_GB_TI-83_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_3x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_3x_grid_color = 0xA3AD8A
|
4
gfx/video_filters/Dot_Matrix_4x_Dark_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_4x_Dark_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_4x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_4x_grid_color = 0x808080
|
4
gfx/video_filters/Dot_Matrix_4x_GB_DMG_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_4x_GB_DMG_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_4x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_4x_grid_color = 0x5C8A00
|
4
gfx/video_filters/Dot_Matrix_4x_GB_Greenscale_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_4x_GB_Greenscale_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_4x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_4x_grid_color = 0xA3C70D
|
4
gfx/video_filters/Dot_Matrix_4x_GB_Light_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_4x_GB_Light_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_4x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_4x_grid_color = 0x01D3E8
|
4
gfx/video_filters/Dot_Matrix_4x_GB_Pocket_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_4x_GB_Pocket_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_4x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_4x_grid_color = 0xADB8A0
|
4
gfx/video_filters/Dot_Matrix_4x_GB_TI-83_Grid.filt
Normal file
4
gfx/video_filters/Dot_Matrix_4x_GB_TI-83_Grid.filt
Normal file
@ -0,0 +1,4 @@
|
||||
filter = dot_matrix_4x
|
||||
|
||||
# Colour format: 0xRRGGBB
|
||||
dot_matrix_4x_grid_color = 0xA3AD8A
|
1
gfx/video_filters/Grid3x.filt
Normal file
1
gfx/video_filters/Grid3x.filt
Normal file
@ -0,0 +1 @@
|
||||
filter = grid3x
|
@ -69,9 +69,11 @@ endif
|
||||
|
||||
objects += blargg_ntsc_snes.$(DYLIB) phosphor2x.$(DYLIB) epx.$(DYLIB) lq2x.$(DYLIB) \
|
||||
2xsai.$(DYLIB) super2xsai.$(DYLIB) supereagle.$(DYLIB) 2xbr.$(DYLIB) \
|
||||
darken.$(DYLIB) scale2x.$(DYLIB) normal2x.$(DYLIB) scanline2x.$(DYLIB)\
|
||||
grid2x.$(DYLIB) gameboy3x.$(DYLIB) gameboy4x.$(DYLIB) dot_matrix_3x.$(DYLIB) \
|
||||
dot_matrix_4x.$(DYLIB)
|
||||
darken.$(DYLIB) scale2x.$(DYLIB) normal2x.$(DYLIB) \
|
||||
normal2x_width.$(DYLIB) normal2x_height.$(DYLIB) \
|
||||
scanline2x.$(DYLIB) grid2x.$(DYLIB) grid3x.$(DYLIB) \
|
||||
gameboy3x.$(DYLIB) gameboy4x.$(DYLIB) \
|
||||
dot_matrix_3x.$(DYLIB) dot_matrix_4x.$(DYLIB)
|
||||
|
||||
all: build;
|
||||
|
||||
|
1
gfx/video_filters/Normal2x_Height.filt
Normal file
1
gfx/video_filters/Normal2x_Height.filt
Normal file
@ -0,0 +1 @@
|
||||
filter = normal2x_height
|
1
gfx/video_filters/Normal2x_Width.filt
Normal file
1
gfx/video_filters/Normal2x_Width.filt
Normal file
@ -0,0 +1 @@
|
||||
filter = normal2x_width
|
266
gfx/video_filters/grid3x.c
Normal file
266
gfx/video_filters/grid3x.c
Normal file
@ -0,0 +1,266 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2018 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Compile: gcc -o grid3x.so -shared grid3x.c -std=c99 -O3 -Wall -pedantic -fPIC */
|
||||
|
||||
#include "softfilter.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#define softfilter_get_implementation grid3x_get_implementation
|
||||
#define softfilter_thread_data grid3x_softfilter_thread_data
|
||||
#define filter_data grid3x_filter_data
|
||||
#endif
|
||||
|
||||
struct softfilter_thread_data
|
||||
{
|
||||
void *out_data;
|
||||
const void *in_data;
|
||||
size_t out_pitch;
|
||||
size_t in_pitch;
|
||||
unsigned colfmt;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
int first;
|
||||
int last;
|
||||
};
|
||||
|
||||
struct filter_data
|
||||
{
|
||||
unsigned threads;
|
||||
struct softfilter_thread_data *workers;
|
||||
unsigned in_fmt;
|
||||
};
|
||||
|
||||
static unsigned grid3x_generic_input_fmts(void)
|
||||
{
|
||||
return SOFTFILTER_FMT_XRGB8888 | SOFTFILTER_FMT_RGB565;
|
||||
}
|
||||
|
||||
static unsigned grid3x_generic_output_fmts(unsigned input_fmts)
|
||||
{
|
||||
return input_fmts;
|
||||
}
|
||||
|
||||
static unsigned grid3x_generic_threads(void *data)
|
||||
{
|
||||
struct filter_data *filt = (struct filter_data*)data;
|
||||
return filt->threads;
|
||||
}
|
||||
|
||||
static void *grid3x_generic_create(const struct softfilter_config *config,
|
||||
unsigned in_fmt, unsigned out_fmt,
|
||||
unsigned max_width, unsigned max_height,
|
||||
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
|
||||
{
|
||||
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
|
||||
(void)simd;
|
||||
(void)config;
|
||||
(void)userdata;
|
||||
|
||||
if (!filt) {
|
||||
return NULL;
|
||||
}
|
||||
/* Apparently the code is not thread-safe,
|
||||
* so force single threaded operation... */
|
||||
filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data));
|
||||
filt->threads = 1;
|
||||
filt->in_fmt = in_fmt;
|
||||
if (!filt->workers) {
|
||||
free(filt);
|
||||
return NULL;
|
||||
}
|
||||
return filt;
|
||||
}
|
||||
|
||||
static void grid3x_generic_output(void *data,
|
||||
unsigned *out_width, unsigned *out_height,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
*out_width = width * 3;
|
||||
*out_height = height * 3;
|
||||
}
|
||||
|
||||
static void grid3x_generic_destroy(void *data)
|
||||
{
|
||||
struct filter_data *filt = (struct filter_data*)data;
|
||||
if (!filt) {
|
||||
return;
|
||||
}
|
||||
free(filt->workers);
|
||||
free(filt);
|
||||
}
|
||||
|
||||
static void grid3x_work_cb_xrgb8888(void *data, void *thread_data)
|
||||
{
|
||||
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
|
||||
const uint32_t *input = (const uint32_t*)thr->in_data;
|
||||
uint32_t *output = (uint32_t*)thr->out_data;
|
||||
uint32_t in_stride = (uint32_t)(thr->in_pitch >> 2);
|
||||
uint32_t out_stride = (uint32_t)(thr->out_pitch >> 2);
|
||||
uint32_t x, y;
|
||||
|
||||
for (y = 0; y < thr->height; ++y)
|
||||
{
|
||||
uint32_t *out_ptr = output;
|
||||
for (x = 0; x < thr->width; ++x)
|
||||
{
|
||||
/* Note: We process the 'padding' bits as though they
|
||||
* matter (they don't), since this deals with any potential
|
||||
* byte swapping issues */
|
||||
uint32_t *out_line_ptr = out_ptr;
|
||||
uint32_t color = *(input + x);
|
||||
uint32_t p = (color >> 24 & 0xFF); /* Padding bits */
|
||||
uint32_t r = (color >> 16 & 0xFF);
|
||||
uint32_t g = (color >> 8 & 0xFF);
|
||||
uint32_t b = (color & 0xFF);
|
||||
uint32_t scanline_color =
|
||||
((p - (p >> 2)) << 24) |
|
||||
((r - (r >> 2)) << 16) |
|
||||
((g - (g >> 2)) << 8) |
|
||||
((b - (b >> 2)) );
|
||||
|
||||
/* Row 1: <colour><colour><scanline> */
|
||||
*out_line_ptr = color;
|
||||
*(out_line_ptr + 1) = color;
|
||||
*(out_line_ptr + 2) = scanline_color;
|
||||
out_line_ptr += out_stride;
|
||||
|
||||
/* Row 2: <colour><colour><scanline> */
|
||||
*out_line_ptr = color;
|
||||
*(out_line_ptr + 1) = color;
|
||||
*(out_line_ptr + 2) = scanline_color;
|
||||
out_line_ptr += out_stride;
|
||||
|
||||
/* Row 3: <scanline><scanline><scanline> */
|
||||
*out_line_ptr = scanline_color;
|
||||
*(out_line_ptr + 1) = scanline_color;
|
||||
*(out_line_ptr + 2) = scanline_color;
|
||||
|
||||
out_ptr += 3;
|
||||
}
|
||||
|
||||
input += in_stride;
|
||||
output += out_stride * 3;
|
||||
}
|
||||
}
|
||||
|
||||
static void grid3x_work_cb_rgb565(void *data, void *thread_data)
|
||||
{
|
||||
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
|
||||
const uint16_t *input = (const uint16_t*)thr->in_data;
|
||||
uint16_t *output = (uint16_t*)thr->out_data;
|
||||
uint16_t in_stride = (uint16_t)(thr->in_pitch >> 1);
|
||||
uint16_t out_stride = (uint16_t)(thr->out_pitch >> 1);
|
||||
uint16_t x, y;
|
||||
|
||||
for (y = 0; y < thr->height; ++y)
|
||||
{
|
||||
uint16_t *out_ptr = output;
|
||||
for (x = 0; x < thr->width; ++x)
|
||||
{
|
||||
uint16_t *out_line_ptr = out_ptr;
|
||||
uint16_t color = *(input + x);
|
||||
uint16_t r = (color >> 11 & 0x1F);
|
||||
uint16_t g = (color >> 6 & 0x1F);
|
||||
uint16_t b = (color & 0x1F);
|
||||
uint16_t scanline_color =
|
||||
((r - (r >> 2)) << 11) |
|
||||
((g - (g >> 2)) << 6) |
|
||||
((b - (b >> 2)) );
|
||||
|
||||
/* Row 1: <colour><colour><scanline> */
|
||||
*out_line_ptr = color;
|
||||
*(out_line_ptr + 1) = color;
|
||||
*(out_line_ptr + 2) = scanline_color;
|
||||
out_line_ptr += out_stride;
|
||||
|
||||
/* Row 2: <colour><colour><scanline> */
|
||||
*out_line_ptr = color;
|
||||
*(out_line_ptr + 1) = color;
|
||||
*(out_line_ptr + 2) = scanline_color;
|
||||
out_line_ptr += out_stride;
|
||||
|
||||
/* Row 3: <scanline><scanline><scanline> */
|
||||
*out_line_ptr = scanline_color;
|
||||
*(out_line_ptr + 1) = scanline_color;
|
||||
*(out_line_ptr + 2) = scanline_color;
|
||||
|
||||
out_ptr += 3;
|
||||
}
|
||||
|
||||
input += in_stride;
|
||||
output += out_stride * 3;
|
||||
}
|
||||
}
|
||||
|
||||
static void grid3x_generic_packets(void *data,
|
||||
struct softfilter_work_packet *packets,
|
||||
void *output, size_t output_stride,
|
||||
const void *input, unsigned width, unsigned height, size_t input_stride)
|
||||
{
|
||||
/* We are guaranteed single threaded operation
|
||||
* (filt->threads = 1) so we don't need to loop
|
||||
* over threads and can cull some code. This only
|
||||
* makes the tiniest performance difference, but
|
||||
* every little helps when running on an o3DS... */
|
||||
struct filter_data *filt = (struct filter_data*)data;
|
||||
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0];
|
||||
|
||||
thr->out_data = (uint8_t*)output;
|
||||
thr->in_data = (const uint8_t*)input;
|
||||
thr->out_pitch = output_stride;
|
||||
thr->in_pitch = input_stride;
|
||||
thr->width = width;
|
||||
thr->height = height;
|
||||
|
||||
if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) {
|
||||
packets[0].work = grid3x_work_cb_xrgb8888;
|
||||
} else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) {
|
||||
packets[0].work = grid3x_work_cb_rgb565;
|
||||
}
|
||||
packets[0].thread_data = thr;
|
||||
}
|
||||
|
||||
static const struct softfilter_implementation grid3x_generic = {
|
||||
grid3x_generic_input_fmts,
|
||||
grid3x_generic_output_fmts,
|
||||
|
||||
grid3x_generic_create,
|
||||
grid3x_generic_destroy,
|
||||
|
||||
grid3x_generic_threads,
|
||||
grid3x_generic_output,
|
||||
grid3x_generic_packets,
|
||||
|
||||
SOFTFILTER_API_VERSION,
|
||||
"Grid3x",
|
||||
"grid3x",
|
||||
};
|
||||
|
||||
const struct softfilter_implementation *softfilter_get_implementation(
|
||||
softfilter_simd_mask_t simd)
|
||||
{
|
||||
(void)simd;
|
||||
return &grid3x_generic;
|
||||
}
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#undef softfilter_get_implementation
|
||||
#undef softfilter_thread_data
|
||||
#undef filter_data
|
||||
#endif
|
219
gfx/video_filters/normal2x_height.c
Normal file
219
gfx/video_filters/normal2x_height.c
Normal file
@ -0,0 +1,219 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2018 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Compile: gcc -o normal2x_height.so -shared normal2x_height.c -std=c99 -O3 -Wall -pedantic -fPIC */
|
||||
|
||||
#include "softfilter.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#define softfilter_get_implementation normal2x_height_get_implementation
|
||||
#define softfilter_thread_data normal2x_height_softfilter_thread_data
|
||||
#define filter_data normal2x_height_filter_data
|
||||
#endif
|
||||
|
||||
struct softfilter_thread_data
|
||||
{
|
||||
void *out_data;
|
||||
const void *in_data;
|
||||
size_t out_pitch;
|
||||
size_t in_pitch;
|
||||
unsigned colfmt;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
int first;
|
||||
int last;
|
||||
};
|
||||
|
||||
struct filter_data
|
||||
{
|
||||
unsigned threads;
|
||||
struct softfilter_thread_data *workers;
|
||||
unsigned in_fmt;
|
||||
};
|
||||
|
||||
static unsigned normal2x_height_generic_input_fmts(void)
|
||||
{
|
||||
return SOFTFILTER_FMT_XRGB8888 | SOFTFILTER_FMT_RGB565;
|
||||
}
|
||||
|
||||
static unsigned normal2x_height_generic_output_fmts(unsigned input_fmts)
|
||||
{
|
||||
return input_fmts;
|
||||
}
|
||||
|
||||
static unsigned normal2x_height_generic_threads(void *data)
|
||||
{
|
||||
struct filter_data *filt = (struct filter_data*)data;
|
||||
return filt->threads;
|
||||
}
|
||||
|
||||
static void *normal2x_height_generic_create(const struct softfilter_config *config,
|
||||
unsigned in_fmt, unsigned out_fmt,
|
||||
unsigned max_width, unsigned max_height,
|
||||
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
|
||||
{
|
||||
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
|
||||
(void)simd;
|
||||
(void)config;
|
||||
(void)userdata;
|
||||
|
||||
if (!filt) {
|
||||
return NULL;
|
||||
}
|
||||
/* Apparently the code is not thread-safe,
|
||||
* so force single threaded operation... */
|
||||
filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data));
|
||||
filt->threads = 1;
|
||||
filt->in_fmt = in_fmt;
|
||||
if (!filt->workers) {
|
||||
free(filt);
|
||||
return NULL;
|
||||
}
|
||||
return filt;
|
||||
}
|
||||
|
||||
static void normal2x_height_generic_output(void *data,
|
||||
unsigned *out_width, unsigned *out_height,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
*out_width = width;
|
||||
*out_height = height << 1;
|
||||
}
|
||||
|
||||
static void normal2x_height_generic_destroy(void *data)
|
||||
{
|
||||
struct filter_data *filt = (struct filter_data*)data;
|
||||
if (!filt) {
|
||||
return;
|
||||
}
|
||||
free(filt->workers);
|
||||
free(filt);
|
||||
}
|
||||
|
||||
static void normal2x_height_work_cb_xrgb8888(void *data, void *thread_data)
|
||||
{
|
||||
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
|
||||
const uint32_t *input = (const uint32_t*)thr->in_data;
|
||||
uint32_t *output = (uint32_t*)thr->out_data;
|
||||
uint32_t in_stride = (uint32_t)(thr->in_pitch >> 2);
|
||||
uint32_t out_stride = (uint32_t)(thr->out_pitch >> 2);
|
||||
uint32_t x, y;
|
||||
|
||||
for (y = 0; y < thr->height; ++y)
|
||||
{
|
||||
uint32_t *out_ptr = output;
|
||||
for (x = 0; x < thr->width; ++x)
|
||||
{
|
||||
uint32_t color = *(input + x);
|
||||
|
||||
/* Duplicate pixels in the y direction */
|
||||
*out_ptr = color;
|
||||
*(out_ptr + out_stride) = color;
|
||||
|
||||
out_ptr++;
|
||||
}
|
||||
|
||||
input += in_stride;
|
||||
output += out_stride << 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void normal2x_height_work_cb_rgb565(void *data, void *thread_data)
|
||||
{
|
||||
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
|
||||
const uint16_t *input = (const uint16_t*)thr->in_data;
|
||||
uint16_t *output = (uint16_t*)thr->out_data;
|
||||
uint16_t in_stride = (uint16_t)(thr->in_pitch >> 1);
|
||||
uint16_t out_stride = (uint16_t)(thr->out_pitch >> 1);
|
||||
uint16_t x, y;
|
||||
|
||||
for (y = 0; y < thr->height; ++y)
|
||||
{
|
||||
uint16_t *out_ptr = output;
|
||||
for (x = 0; x < thr->width; ++x)
|
||||
{
|
||||
uint16_t color = *(input + x);
|
||||
|
||||
/* Duplicate pixels in the y direction */
|
||||
*out_ptr = color;
|
||||
*(out_ptr + out_stride) = color;
|
||||
|
||||
out_ptr++;
|
||||
}
|
||||
|
||||
input += in_stride;
|
||||
output += out_stride << 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void normal2x_height_generic_packets(void *data,
|
||||
struct softfilter_work_packet *packets,
|
||||
void *output, size_t output_stride,
|
||||
const void *input, unsigned width, unsigned height, size_t input_stride)
|
||||
{
|
||||
/* We are guaranteed single threaded operation
|
||||
* (filt->threads = 1) so we don't need to loop
|
||||
* over threads and can cull some code. This only
|
||||
* makes the tiniest performance difference, but
|
||||
* every little helps when running on an o3DS... */
|
||||
struct filter_data *filt = (struct filter_data*)data;
|
||||
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0];
|
||||
|
||||
thr->out_data = (uint8_t*)output;
|
||||
thr->in_data = (const uint8_t*)input;
|
||||
thr->out_pitch = output_stride;
|
||||
thr->in_pitch = input_stride;
|
||||
thr->width = width;
|
||||
thr->height = height;
|
||||
|
||||
if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) {
|
||||
packets[0].work = normal2x_height_work_cb_xrgb8888;
|
||||
} else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) {
|
||||
packets[0].work = normal2x_height_work_cb_rgb565;
|
||||
}
|
||||
packets[0].thread_data = thr;
|
||||
}
|
||||
|
||||
static const struct softfilter_implementation normal2x_height_generic = {
|
||||
normal2x_height_generic_input_fmts,
|
||||
normal2x_height_generic_output_fmts,
|
||||
|
||||
normal2x_height_generic_create,
|
||||
normal2x_height_generic_destroy,
|
||||
|
||||
normal2x_height_generic_threads,
|
||||
normal2x_height_generic_output,
|
||||
normal2x_height_generic_packets,
|
||||
|
||||
SOFTFILTER_API_VERSION,
|
||||
"Normal2x Height",
|
||||
"normal2x_height",
|
||||
};
|
||||
|
||||
const struct softfilter_implementation *softfilter_get_implementation(
|
||||
softfilter_simd_mask_t simd)
|
||||
{
|
||||
(void)simd;
|
||||
return &normal2x_height_generic;
|
||||
}
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#undef softfilter_get_implementation
|
||||
#undef softfilter_thread_data
|
||||
#undef filter_data
|
||||
#endif
|
221
gfx/video_filters/normal2x_width.c
Normal file
221
gfx/video_filters/normal2x_width.c
Normal file
@ -0,0 +1,221 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2018 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Compile: gcc -o normal2x_width.so -shared normal2x_width.c -std=c99 -O3 -Wall -pedantic -fPIC */
|
||||
|
||||
#include "softfilter.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#define softfilter_get_implementation normal2x_width_get_implementation
|
||||
#define softfilter_thread_data normal2x_width_softfilter_thread_data
|
||||
#define filter_data normal2x_width_filter_data
|
||||
#endif
|
||||
|
||||
struct softfilter_thread_data
|
||||
{
|
||||
void *out_data;
|
||||
const void *in_data;
|
||||
size_t out_pitch;
|
||||
size_t in_pitch;
|
||||
unsigned colfmt;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
int first;
|
||||
int last;
|
||||
};
|
||||
|
||||
struct filter_data
|
||||
{
|
||||
unsigned threads;
|
||||
struct softfilter_thread_data *workers;
|
||||
unsigned in_fmt;
|
||||
};
|
||||
|
||||
static unsigned normal2x_width_generic_input_fmts(void)
|
||||
{
|
||||
return SOFTFILTER_FMT_XRGB8888 | SOFTFILTER_FMT_RGB565;
|
||||
}
|
||||
|
||||
static unsigned normal2x_width_generic_output_fmts(unsigned input_fmts)
|
||||
{
|
||||
return input_fmts;
|
||||
}
|
||||
|
||||
static unsigned normal2x_width_generic_threads(void *data)
|
||||
{
|
||||
struct filter_data *filt = (struct filter_data*)data;
|
||||
return filt->threads;
|
||||
}
|
||||
|
||||
static void *normal2x_width_generic_create(const struct softfilter_config *config,
|
||||
unsigned in_fmt, unsigned out_fmt,
|
||||
unsigned max_width, unsigned max_height,
|
||||
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
|
||||
{
|
||||
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
|
||||
(void)simd;
|
||||
(void)config;
|
||||
(void)userdata;
|
||||
|
||||
if (!filt) {
|
||||
return NULL;
|
||||
}
|
||||
/* Apparently the code is not thread-safe,
|
||||
* so force single threaded operation... */
|
||||
filt->workers = (struct softfilter_thread_data*)calloc(1, sizeof(struct softfilter_thread_data));
|
||||
filt->threads = 1;
|
||||
filt->in_fmt = in_fmt;
|
||||
if (!filt->workers) {
|
||||
free(filt);
|
||||
return NULL;
|
||||
}
|
||||
return filt;
|
||||
}
|
||||
|
||||
static void normal2x_width_generic_output(void *data,
|
||||
unsigned *out_width, unsigned *out_height,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
*out_width = width << 1;
|
||||
*out_height = height;
|
||||
}
|
||||
|
||||
static void normal2x_width_generic_destroy(void *data)
|
||||
{
|
||||
struct filter_data *filt = (struct filter_data*)data;
|
||||
if (!filt) {
|
||||
return;
|
||||
}
|
||||
free(filt->workers);
|
||||
free(filt);
|
||||
}
|
||||
|
||||
static void normal2x_width_work_cb_xrgb8888(void *data, void *thread_data)
|
||||
{
|
||||
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
|
||||
const uint32_t *input = (const uint32_t*)thr->in_data;
|
||||
uint32_t *output = (uint32_t*)thr->out_data;
|
||||
uint32_t in_stride = (uint32_t)(thr->in_pitch >> 2);
|
||||
uint32_t out_stride = (uint32_t)(thr->out_pitch >> 2);
|
||||
uint32_t x, y;
|
||||
|
||||
for (y = 0; y < thr->height; ++y)
|
||||
{
|
||||
uint32_t *out_ptr = output;
|
||||
for (x = 0; x < thr->width; ++x)
|
||||
{
|
||||
uint32_t *out_line_ptr = out_ptr;
|
||||
uint32_t color = *(input + x);
|
||||
|
||||
/* Duplicate pixels in the x direction */
|
||||
*out_line_ptr = color;
|
||||
*(out_line_ptr + 1) = color;
|
||||
|
||||
out_ptr += 2;
|
||||
}
|
||||
|
||||
input += in_stride;
|
||||
output += out_stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void normal2x_width_work_cb_rgb565(void *data, void *thread_data)
|
||||
{
|
||||
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
|
||||
const uint16_t *input = (const uint16_t*)thr->in_data;
|
||||
uint16_t *output = (uint16_t*)thr->out_data;
|
||||
uint16_t in_stride = (uint16_t)(thr->in_pitch >> 1);
|
||||
uint16_t out_stride = (uint16_t)(thr->out_pitch >> 1);
|
||||
uint16_t x, y;
|
||||
|
||||
for (y = 0; y < thr->height; ++y)
|
||||
{
|
||||
uint16_t *out_ptr = output;
|
||||
for (x = 0; x < thr->width; ++x)
|
||||
{
|
||||
uint16_t *out_line_ptr = out_ptr;
|
||||
uint16_t color = *(input + x);
|
||||
|
||||
/* Duplicate pixels in the x direction */
|
||||
*out_line_ptr = color;
|
||||
*(out_line_ptr + 1) = color;
|
||||
|
||||
out_ptr += 2;
|
||||
}
|
||||
|
||||
input += in_stride;
|
||||
output += out_stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void normal2x_width_generic_packets(void *data,
|
||||
struct softfilter_work_packet *packets,
|
||||
void *output, size_t output_stride,
|
||||
const void *input, unsigned width, unsigned height, size_t input_stride)
|
||||
{
|
||||
/* We are guaranteed single threaded operation
|
||||
* (filt->threads = 1) so we don't need to loop
|
||||
* over threads and can cull some code. This only
|
||||
* makes the tiniest performance difference, but
|
||||
* every little helps when running on an o3DS... */
|
||||
struct filter_data *filt = (struct filter_data*)data;
|
||||
struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[0];
|
||||
|
||||
thr->out_data = (uint8_t*)output;
|
||||
thr->in_data = (const uint8_t*)input;
|
||||
thr->out_pitch = output_stride;
|
||||
thr->in_pitch = input_stride;
|
||||
thr->width = width;
|
||||
thr->height = height;
|
||||
|
||||
if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) {
|
||||
packets[0].work = normal2x_width_work_cb_xrgb8888;
|
||||
} else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) {
|
||||
packets[0].work = normal2x_width_work_cb_rgb565;
|
||||
}
|
||||
packets[0].thread_data = thr;
|
||||
}
|
||||
|
||||
static const struct softfilter_implementation normal2x_width_generic = {
|
||||
normal2x_width_generic_input_fmts,
|
||||
normal2x_width_generic_output_fmts,
|
||||
|
||||
normal2x_width_generic_create,
|
||||
normal2x_width_generic_destroy,
|
||||
|
||||
normal2x_width_generic_threads,
|
||||
normal2x_width_generic_output,
|
||||
normal2x_width_generic_packets,
|
||||
|
||||
SOFTFILTER_API_VERSION,
|
||||
"Normal2x Width",
|
||||
"normal2x_width",
|
||||
};
|
||||
|
||||
const struct softfilter_implementation *softfilter_get_implementation(
|
||||
softfilter_simd_mask_t simd)
|
||||
{
|
||||
(void)simd;
|
||||
return &normal2x_width_generic;
|
||||
}
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#undef softfilter_get_implementation
|
||||
#undef softfilter_thread_data
|
||||
#undef filter_data
|
||||
#endif
|
@ -1004,8 +1004,11 @@ FILTERS
|
||||
#include "../gfx/video_filters/lq2x.c"
|
||||
#include "../gfx/video_filters/phosphor2x.c"
|
||||
#include "../gfx/video_filters/normal2x.c"
|
||||
#include "../gfx/video_filters/normal2x_width.c"
|
||||
#include "../gfx/video_filters/normal2x_height.c"
|
||||
#include "../gfx/video_filters/scanline2x.c"
|
||||
#include "../gfx/video_filters/grid2x.c"
|
||||
#include "../gfx/video_filters/grid3x.c"
|
||||
#include "../gfx/video_filters/gameboy3x.c"
|
||||
#include "../gfx/video_filters/gameboy4x.c"
|
||||
#include "../gfx/video_filters/dot_matrix_3x.c"
|
||||
|
Loading…
x
Reference in New Issue
Block a user