mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Create video_pixel_frame_scale and move it to gfx/video_pixel_converter.c
This commit is contained in:
parent
177f6104d4
commit
9f93373286
@ -14,9 +14,13 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "video_pixel_converter.h"
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <gfx/scaler/pixconv.h>
|
#include <gfx/scaler/pixconv.h>
|
||||||
|
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
|
#include "../performance.h"
|
||||||
|
#include "video_pixel_converter.h"
|
||||||
|
|
||||||
void deinit_pixel_converter(void)
|
void deinit_pixel_converter(void)
|
||||||
{
|
{
|
||||||
@ -70,3 +74,34 @@ unsigned video_pixel_get_alignment(unsigned pitch)
|
|||||||
return 4;
|
return 4;
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool video_pixel_frame_scale(const void *data,
|
||||||
|
unsigned width, unsigned height,
|
||||||
|
size_t pitch)
|
||||||
|
{
|
||||||
|
driver_t *driver = driver_get_ptr();
|
||||||
|
|
||||||
|
RARCH_PERFORMANCE_INIT(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;
|
||||||
|
|
||||||
|
RARCH_PERFORMANCE_START(video_frame_conv);
|
||||||
|
|
||||||
|
driver->scaler.in_width = width;
|
||||||
|
driver->scaler.in_height = height;
|
||||||
|
driver->scaler.out_width = width;
|
||||||
|
driver->scaler.out_height = height;
|
||||||
|
driver->scaler.in_stride = pitch;
|
||||||
|
driver->scaler.out_stride = width * sizeof(uint16_t);
|
||||||
|
|
||||||
|
scaler_ctx_scale(&driver->scaler, driver->scaler_out, data);
|
||||||
|
|
||||||
|
RARCH_PERFORMANCE_STOP(video_frame_conv);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -29,6 +29,10 @@ bool init_video_pixel_converter(unsigned size);
|
|||||||
|
|
||||||
unsigned video_pixel_get_alignment(unsigned pitch);
|
unsigned video_pixel_get_alignment(unsigned pitch);
|
||||||
|
|
||||||
|
bool video_pixel_frame_scale(const void *data,
|
||||||
|
unsigned width, unsigned height,
|
||||||
|
size_t pitch);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,43 +36,13 @@
|
|||||||
#include "audio/audio_utils.h"
|
#include "audio/audio_utils.h"
|
||||||
#include "retroarch_logger.h"
|
#include "retroarch_logger.h"
|
||||||
#include "record/record_driver.h"
|
#include "record/record_driver.h"
|
||||||
|
#include "gfx/video_pixel_converter.h"
|
||||||
#include "intl/intl.h"
|
#include "intl/intl.h"
|
||||||
|
|
||||||
#ifdef HAVE_NETPLAY
|
#ifdef HAVE_NETPLAY
|
||||||
#include "netplay.h"
|
#include "netplay.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool video_frame_scale(const void *data,
|
|
||||||
unsigned width, unsigned height,
|
|
||||||
size_t pitch)
|
|
||||||
{
|
|
||||||
driver_t *driver = driver_get_ptr();
|
|
||||||
|
|
||||||
RARCH_PERFORMANCE_INIT(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;
|
|
||||||
|
|
||||||
RARCH_PERFORMANCE_START(video_frame_conv);
|
|
||||||
|
|
||||||
driver->scaler.in_width = width;
|
|
||||||
driver->scaler.in_height = height;
|
|
||||||
driver->scaler.out_width = width;
|
|
||||||
driver->scaler.out_height = height;
|
|
||||||
driver->scaler.in_stride = pitch;
|
|
||||||
driver->scaler.out_stride = width * sizeof(uint16_t);
|
|
||||||
|
|
||||||
scaler_ctx_scale(&driver->scaler, driver->scaler_out, data);
|
|
||||||
|
|
||||||
RARCH_PERFORMANCE_STOP(video_frame_conv);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* video_frame:
|
* video_frame:
|
||||||
* @data : pointer to data of the video frame.
|
* @data : pointer to data of the video frame.
|
||||||
@ -94,7 +64,7 @@ static void video_frame(const void *data, unsigned width,
|
|||||||
if (!driver->video_active)
|
if (!driver->video_active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (video_frame_scale(data, width, height, pitch))
|
if (video_pixel_frame_scale(data, width, height, pitch))
|
||||||
{
|
{
|
||||||
data = driver->scaler_out;
|
data = driver->scaler_out;
|
||||||
pitch = driver->scaler.out_stride;
|
pitch = driver->scaler.out_stride;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user