mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
Merge video_pixel_converter.c with video_driver.c
This commit is contained in:
parent
e970372959
commit
beceaf4a8c
@ -148,7 +148,6 @@ OBJ += frontend/frontend.o \
|
|||||||
input/input_hid_driver.o \
|
input/input_hid_driver.o \
|
||||||
gfx/video_common.o \
|
gfx/video_common.o \
|
||||||
gfx/video_driver.o \
|
gfx/video_driver.o \
|
||||||
gfx/video_pixel_converter.o \
|
|
||||||
camera/camera_driver.o \
|
camera/camera_driver.o \
|
||||||
location/location_driver.o \
|
location/location_driver.o \
|
||||||
driver.o \
|
driver.o \
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../font_driver.h"
|
#include "../font_driver.h"
|
||||||
#include "../video_pixel_converter.h"
|
|
||||||
#include "../video_context_driver.h"
|
#include "../video_context_driver.h"
|
||||||
#include "../video_texture.h"
|
#include "../video_texture.h"
|
||||||
|
|
||||||
|
@ -14,12 +14,14 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <gfx/scaler/pixconv.h>
|
||||||
|
|
||||||
#include <file/config_file.h>
|
#include <file/config_file.h>
|
||||||
|
|
||||||
#include "video_thread_wrapper.h"
|
#include "video_thread_wrapper.h"
|
||||||
#include "video_pixel_converter.h"
|
|
||||||
#include "video_context_driver.h"
|
#include "video_context_driver.h"
|
||||||
#include "../config.def.h"
|
#include "../config.def.h"
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
@ -70,6 +72,10 @@ typedef struct video_driver_state
|
|||||||
static struct retro_system_av_info video_viewport_av_info;
|
static struct retro_system_av_info video_viewport_av_info;
|
||||||
static video_driver_state_t video_state;
|
static video_driver_state_t video_state;
|
||||||
|
|
||||||
|
/* Used for 16-bit -> 16-bit conversions that take place before
|
||||||
|
* being passed to video driver. */
|
||||||
|
static video_pixel_scaler_t *scaler_ptr;
|
||||||
|
|
||||||
char rotation_lut[4][32] =
|
char rotation_lut[4][32] =
|
||||||
{
|
{
|
||||||
"Normal",
|
"Normal",
|
||||||
@ -246,6 +252,11 @@ static bool find_video_driver(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
video_pixel_scaler_t *scaler_get_ptr(void)
|
||||||
|
{
|
||||||
|
return scaler_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* video_driver_get_ptr:
|
* video_driver_get_ptr:
|
||||||
*
|
*
|
||||||
@ -1634,3 +1645,117 @@ struct video_viewport *video_viewport_get_custom(void)
|
|||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
return &settings->video_viewport_custom;
|
return &settings->video_viewport_custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void deinit_pixel_converter(void)
|
||||||
|
{
|
||||||
|
if (!scaler_ptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
scaler_ctx_gen_reset(scaler_ptr->scaler);
|
||||||
|
|
||||||
|
if (scaler_ptr->scaler)
|
||||||
|
free(scaler_ptr->scaler);
|
||||||
|
if (scaler_ptr->scaler_out)
|
||||||
|
free(scaler_ptr->scaler_out);
|
||||||
|
if (scaler_ptr)
|
||||||
|
free(scaler_ptr);
|
||||||
|
|
||||||
|
scaler_ptr->scaler = NULL;
|
||||||
|
scaler_ptr->scaler_out = NULL;
|
||||||
|
scaler_ptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool init_video_pixel_converter(unsigned size)
|
||||||
|
{
|
||||||
|
/* This function can be called multiple times
|
||||||
|
* without deiniting first on consoles. */
|
||||||
|
deinit_pixel_converter();
|
||||||
|
|
||||||
|
/* If pixel format is not 0RGB1555, we don't need to do
|
||||||
|
* any internal pixel conversion. */
|
||||||
|
if (video_driver_get_pixel_format() != RETRO_PIXEL_FORMAT_0RGB1555)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
RARCH_WARN("0RGB1555 pixel format is deprecated, and will be slower. For 15/16-bit, RGB565 format is preferred.\n");
|
||||||
|
|
||||||
|
scaler_ptr = (video_pixel_scaler_t*)calloc(1, sizeof(*scaler_ptr));
|
||||||
|
|
||||||
|
if (!scaler_ptr)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
scaler_ptr->scaler = (struct scaler_ctx*)calloc(1, sizeof(*scaler_ptr->scaler));
|
||||||
|
|
||||||
|
if (!scaler_ptr->scaler)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
scaler_ptr->scaler->scaler_type = SCALER_TYPE_POINT;
|
||||||
|
scaler_ptr->scaler->in_fmt = SCALER_FMT_0RGB1555;
|
||||||
|
|
||||||
|
/* TODO: Pick either ARGB8888 or RGB565 depending on driver. */
|
||||||
|
scaler_ptr->scaler->out_fmt = SCALER_FMT_RGB565;
|
||||||
|
|
||||||
|
if (!scaler_ctx_gen_filter(scaler_ptr->scaler))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
scaler_ptr->scaler_out = calloc(sizeof(uint16_t), size * size);
|
||||||
|
|
||||||
|
if (!scaler_ptr->scaler_out)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (scaler_ptr->scaler_out)
|
||||||
|
free(scaler_ptr->scaler_out);
|
||||||
|
if (scaler_ptr->scaler)
|
||||||
|
free(scaler_ptr->scaler);
|
||||||
|
if (scaler_ptr)
|
||||||
|
free(scaler_ptr);
|
||||||
|
|
||||||
|
scaler_ptr = NULL;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned video_pixel_get_alignment(unsigned pitch)
|
||||||
|
{
|
||||||
|
if (pitch & 1)
|
||||||
|
return 1;
|
||||||
|
if (pitch & 2)
|
||||||
|
return 2;
|
||||||
|
if (pitch & 4)
|
||||||
|
return 4;
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool video_pixel_frame_scale(const void *data,
|
||||||
|
unsigned width, unsigned height,
|
||||||
|
size_t pitch)
|
||||||
|
{
|
||||||
|
static struct retro_perf_counter video_frame_conv = {0};
|
||||||
|
video_pixel_scaler_t *scaler = scaler_get_ptr();
|
||||||
|
|
||||||
|
rarch_perf_init(&video_frame_conv, "video_frame_conv");
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return false;
|
||||||
|
if (video_driver_get_pixel_format() != RETRO_PIXEL_FORMAT_0RGB1555)
|
||||||
|
return false;
|
||||||
|
if (data == RETRO_HW_FRAME_BUFFER_VALID)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
retro_perf_start(&video_frame_conv);
|
||||||
|
|
||||||
|
scaler->scaler->in_width = width;
|
||||||
|
scaler->scaler->in_height = height;
|
||||||
|
scaler->scaler->out_width = width;
|
||||||
|
scaler->scaler->out_height = height;
|
||||||
|
scaler->scaler->in_stride = pitch;
|
||||||
|
scaler->scaler->out_stride = width * sizeof(uint16_t);
|
||||||
|
|
||||||
|
scaler_ctx_scale(scaler->scaler, scaler->scaler_out, data);
|
||||||
|
|
||||||
|
retro_perf_stop(&video_frame_conv);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -33,6 +33,21 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum text_alignment
|
||||||
|
{
|
||||||
|
TEXT_ALIGN_LEFT = 0,
|
||||||
|
TEXT_ALIGN_RIGHT,
|
||||||
|
TEXT_ALIGN_CENTER
|
||||||
|
};
|
||||||
|
|
||||||
|
enum texture_filter_type
|
||||||
|
{
|
||||||
|
TEXTURE_FILTER_LINEAR = 0,
|
||||||
|
TEXTURE_FILTER_NEAREST,
|
||||||
|
TEXTURE_FILTER_MIPMAP_LINEAR,
|
||||||
|
TEXTURE_FILTER_MIPMAP_NEAREST
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct video_info
|
typedef struct video_info
|
||||||
{
|
{
|
||||||
unsigned width;
|
unsigned width;
|
||||||
@ -56,12 +71,6 @@ typedef struct video_info
|
|||||||
bool rgb32;
|
bool rgb32;
|
||||||
} video_info_t;
|
} video_info_t;
|
||||||
|
|
||||||
enum text_alignment
|
|
||||||
{
|
|
||||||
TEXT_ALIGN_LEFT = 0,
|
|
||||||
TEXT_ALIGN_RIGHT,
|
|
||||||
TEXT_ALIGN_CENTER
|
|
||||||
};
|
|
||||||
|
|
||||||
struct font_params
|
struct font_params
|
||||||
{
|
{
|
||||||
@ -79,13 +88,12 @@ struct font_params
|
|||||||
enum text_alignment text_align;
|
enum text_alignment text_align;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum texture_filter_type
|
typedef struct video_pixel_scaler
|
||||||
{
|
{
|
||||||
TEXTURE_FILTER_LINEAR = 0,
|
struct scaler_ctx *scaler;
|
||||||
TEXTURE_FILTER_NEAREST,
|
void *scaler_out;
|
||||||
TEXTURE_FILTER_MIPMAP_LINEAR,
|
} video_pixel_scaler_t;
|
||||||
TEXTURE_FILTER_MIPMAP_NEAREST
|
|
||||||
};
|
|
||||||
|
|
||||||
#define FONT_COLOR_RGBA(r, g, b, a) (((r) << 24) | ((g) << 16) | ((b) << 8) | ((a) << 0))
|
#define FONT_COLOR_RGBA(r, g, b, a) (((r) << 24) | ((g) << 16) | ((b) << 8) | ((a) << 0))
|
||||||
#define FONT_COLOR_GET_RED(col) (((col) >> 24) & 0xff)
|
#define FONT_COLOR_GET_RED(col) (((col) >> 24) & 0xff)
|
||||||
@ -496,6 +504,18 @@ bool video_monitor_fps_statistics(double *refresh_rate,
|
|||||||
bool video_monitor_get_fps(char *buf, size_t size,
|
bool video_monitor_get_fps(char *buf, size_t size,
|
||||||
char *buf_fps, size_t size_fps);
|
char *buf_fps, size_t size_fps);
|
||||||
|
|
||||||
|
void deinit_pixel_converter(void);
|
||||||
|
|
||||||
|
bool init_video_pixel_converter(unsigned size);
|
||||||
|
|
||||||
|
unsigned video_pixel_get_alignment(unsigned pitch);
|
||||||
|
|
||||||
|
bool video_pixel_frame_scale(const void *data,
|
||||||
|
unsigned width, unsigned height,
|
||||||
|
size_t pitch);
|
||||||
|
|
||||||
|
video_pixel_scaler_t *scaler_get_ptr(void);
|
||||||
|
|
||||||
extern video_driver_t video_gl;
|
extern video_driver_t video_gl;
|
||||||
extern video_driver_t video_psp1;
|
extern video_driver_t video_psp1;
|
||||||
extern video_driver_t video_vita2d;
|
extern video_driver_t video_vita2d;
|
||||||
|
@ -1,147 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2015 - 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include <gfx/scaler/pixconv.h>
|
|
||||||
|
|
||||||
#include "../general.h"
|
|
||||||
#include "../performance.h"
|
|
||||||
#include "../verbosity.h"
|
|
||||||
#include "video_pixel_converter.h"
|
|
||||||
|
|
||||||
/* Used for 16-bit -> 16-bit conversions that take place before
|
|
||||||
* being passed to video driver. */
|
|
||||||
static video_pixel_scaler_t *scaler_ptr;
|
|
||||||
|
|
||||||
video_pixel_scaler_t *scaler_get_ptr(void)
|
|
||||||
{
|
|
||||||
return scaler_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void deinit_pixel_converter(void)
|
|
||||||
{
|
|
||||||
if (!scaler_ptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
scaler_ctx_gen_reset(scaler_ptr->scaler);
|
|
||||||
|
|
||||||
if (scaler_ptr->scaler)
|
|
||||||
free(scaler_ptr->scaler);
|
|
||||||
if (scaler_ptr->scaler_out)
|
|
||||||
free(scaler_ptr->scaler_out);
|
|
||||||
if (scaler_ptr)
|
|
||||||
free(scaler_ptr);
|
|
||||||
|
|
||||||
scaler_ptr->scaler = NULL;
|
|
||||||
scaler_ptr->scaler_out = NULL;
|
|
||||||
scaler_ptr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool init_video_pixel_converter(unsigned size)
|
|
||||||
{
|
|
||||||
/* This function can be called multiple times
|
|
||||||
* without deiniting first on consoles. */
|
|
||||||
deinit_pixel_converter();
|
|
||||||
|
|
||||||
/* If pixel format is not 0RGB1555, we don't need to do
|
|
||||||
* any internal pixel conversion. */
|
|
||||||
if (video_driver_get_pixel_format() != RETRO_PIXEL_FORMAT_0RGB1555)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
RARCH_WARN("0RGB1555 pixel format is deprecated, and will be slower. For 15/16-bit, RGB565 format is preferred.\n");
|
|
||||||
|
|
||||||
scaler_ptr = (video_pixel_scaler_t*)calloc(1, sizeof(*scaler_ptr));
|
|
||||||
|
|
||||||
if (!scaler_ptr)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
scaler_ptr->scaler = (struct scaler_ctx*)calloc(1, sizeof(*scaler_ptr->scaler));
|
|
||||||
|
|
||||||
if (!scaler_ptr->scaler)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
scaler_ptr->scaler->scaler_type = SCALER_TYPE_POINT;
|
|
||||||
scaler_ptr->scaler->in_fmt = SCALER_FMT_0RGB1555;
|
|
||||||
|
|
||||||
/* TODO: Pick either ARGB8888 or RGB565 depending on driver. */
|
|
||||||
scaler_ptr->scaler->out_fmt = SCALER_FMT_RGB565;
|
|
||||||
|
|
||||||
if (!scaler_ctx_gen_filter(scaler_ptr->scaler))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
scaler_ptr->scaler_out = calloc(sizeof(uint16_t), size * size);
|
|
||||||
|
|
||||||
if (!scaler_ptr->scaler_out)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
error:
|
|
||||||
if (scaler_ptr->scaler_out)
|
|
||||||
free(scaler_ptr->scaler_out);
|
|
||||||
if (scaler_ptr->scaler)
|
|
||||||
free(scaler_ptr->scaler);
|
|
||||||
if (scaler_ptr)
|
|
||||||
free(scaler_ptr);
|
|
||||||
|
|
||||||
scaler_ptr = NULL;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned video_pixel_get_alignment(unsigned pitch)
|
|
||||||
{
|
|
||||||
if (pitch & 1)
|
|
||||||
return 1;
|
|
||||||
if (pitch & 2)
|
|
||||||
return 2;
|
|
||||||
if (pitch & 4)
|
|
||||||
return 4;
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool video_pixel_frame_scale(const void *data,
|
|
||||||
unsigned width, unsigned height,
|
|
||||||
size_t pitch)
|
|
||||||
{
|
|
||||||
static struct retro_perf_counter video_frame_conv = {0};
|
|
||||||
video_pixel_scaler_t *scaler = scaler_get_ptr();
|
|
||||||
|
|
||||||
rarch_perf_init(&video_frame_conv, "video_frame_conv");
|
|
||||||
|
|
||||||
if (!data)
|
|
||||||
return false;
|
|
||||||
if (video_driver_get_pixel_format() != RETRO_PIXEL_FORMAT_0RGB1555)
|
|
||||||
return false;
|
|
||||||
if (data == RETRO_HW_FRAME_BUFFER_VALID)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
retro_perf_start(&video_frame_conv);
|
|
||||||
|
|
||||||
scaler->scaler->in_width = width;
|
|
||||||
scaler->scaler->in_height = height;
|
|
||||||
scaler->scaler->out_width = width;
|
|
||||||
scaler->scaler->out_height = height;
|
|
||||||
scaler->scaler->in_stride = pitch;
|
|
||||||
scaler->scaler->out_stride = width * sizeof(uint16_t);
|
|
||||||
|
|
||||||
scaler_ctx_scale(scaler->scaler, scaler->scaler_out, data);
|
|
||||||
|
|
||||||
retro_perf_stop(&video_frame_conv);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2015 - 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VIDEO_PIXEL_CONVERTER_H
|
|
||||||
#define _VIDEO_PIXEL_CONVERTER_H
|
|
||||||
|
|
||||||
#include <boolean.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct video_pixel_scaler
|
|
||||||
{
|
|
||||||
struct scaler_ctx *scaler;
|
|
||||||
void *scaler_out;
|
|
||||||
} video_pixel_scaler_t;
|
|
||||||
|
|
||||||
void deinit_pixel_converter(void);
|
|
||||||
|
|
||||||
bool init_video_pixel_converter(unsigned size);
|
|
||||||
|
|
||||||
unsigned video_pixel_get_alignment(unsigned pitch);
|
|
||||||
|
|
||||||
bool video_pixel_frame_scale(const void *data,
|
|
||||||
unsigned width, unsigned height,
|
|
||||||
size_t pitch);
|
|
||||||
|
|
||||||
video_pixel_scaler_t *scaler_get_ptr(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -17,8 +17,8 @@
|
|||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <formats/image.h>
|
#include <formats/image.h>
|
||||||
|
|
||||||
|
#include "video_driver.h"
|
||||||
#include "video_texture.h"
|
#include "video_texture.h"
|
||||||
#include "video_pixel_converter.h"
|
|
||||||
#include "video_thread_wrapper.h"
|
#include "video_thread_wrapper.h"
|
||||||
|
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
|
@ -535,7 +535,6 @@ DRIVERS
|
|||||||
============================================================ */
|
============================================================ */
|
||||||
#include "../gfx/video_driver.c"
|
#include "../gfx/video_driver.c"
|
||||||
#include "../gfx/video_common.c"
|
#include "../gfx/video_common.c"
|
||||||
#include "../gfx/video_pixel_converter.c"
|
|
||||||
#include "../input/input_driver.c"
|
#include "../input/input_driver.c"
|
||||||
#include "../audio/audio_driver.c"
|
#include "../audio/audio_driver.c"
|
||||||
#include "../camera/camera_driver.c"
|
#include "../camera/camera_driver.c"
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include "performance.h"
|
#include "performance.h"
|
||||||
#include "input/input_remapping.h"
|
#include "input/input_remapping.h"
|
||||||
#include "record/record_driver.h"
|
#include "record/record_driver.h"
|
||||||
#include "gfx/video_pixel_converter.h"
|
|
||||||
#include "verbosity.h"
|
#include "verbosity.h"
|
||||||
|
|
||||||
#ifdef HAVE_NETPLAY
|
#ifdef HAVE_NETPLAY
|
||||||
|
Loading…
x
Reference in New Issue
Block a user