Create scaler_ctx_scale_direct

This commit is contained in:
twinaphex 2017-04-16 11:03:29 +02:00
parent 9c7dd3068f
commit 0c5a87b1d7
5 changed files with 32 additions and 19 deletions

View File

@ -36,6 +36,7 @@
#include <retro_assert.h>
#include <retro_miscellaneous.h>
#include <gfx/scaler/scaler.h>
#include <gfx/video_frame.h>
#include <retro_stat.h>
#include <compat/strl.h>
@ -352,6 +353,7 @@ error:
static bool preprocess_image(void *data)
{
struct scaler_ctx *ctx = NULL;
video4linux_t *v4l = (video4linux_t*)data;
struct v4l2_buffer buf = {0};
@ -374,7 +376,9 @@ static bool preprocess_image(void *data)
retro_assert(buf.index < v4l->n_buffers);
scaler_ctx_scale(&v4l->scaler, v4l->buffer_output, (const uint8_t*)v4l->buffers[buf.index].start);
ctx = &v4l->scaler;
scaler_ctx_scale_direct(ctx, v4l->buffer_output, (const uint8_t*)v4l->buffers[buf.index].start);
if (xioctl(v4l->fd, (uint8_t)VIDIOC_QBUF, &buf) == -1)
RARCH_ERR("[V4L2]: VIDIOC_QBUF\n");

View File

@ -2400,7 +2400,10 @@ static bool gl_read_viewport(void *data, uint8_t *buffer, bool is_idle)
#else
ptr = (const uint8_t*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
if (ptr)
scaler_ctx_scale(&gl->pbo_readback_scaler, buffer, ptr);
{
struct scaler_ctx *ctx = &gl->pbo_readback_scaler;
scaler_ctx_scale_direct(ctx, buffer, ptr);
}
#endif
if (!ptr)

View File

@ -21,6 +21,7 @@
#include <compat/strl.h>
#include <gfx/scaler/scaler.h>
#include <gfx/video_frame.h>
#include <formats/image.h>
#include <retro_inline.h>
#include <retro_miscellaneous.h>
@ -2329,7 +2330,8 @@ static bool vulkan_read_viewport(void *data, uint8_t *buffer, bool is_idle)
if (vk->readback.streamed)
{
const uint8_t *src;
const uint8_t *src = NULL;
struct scaler_ctx *ctx = NULL;
if (staging->memory == VK_NULL_HANDLE)
return false;
@ -2342,7 +2344,10 @@ static bool vulkan_read_viewport(void *data, uint8_t *buffer, bool is_idle)
vk->readback.scaler.in_stride = staging->stride;
vk->readback.scaler.out_stride = -(int)vk->vp.width * 3;
scaler_ctx_scale(&vk->readback.scaler, buffer, src);
ctx = &vk->readback.scaler;
scaler_ctx_scale_direct(ctx, buffer, src);
vkUnmapMemory(vk->context->device, staging->memory);
}

View File

@ -305,15 +305,6 @@ void scaler_ctx_scale(struct scaler_ctx *ctx,
int input_stride = ctx->in_stride;
int output_stride = ctx->out_stride;
if (ctx->unscaled)
{
/* Just perform straight pixel conversion. */
ctx->direct_pixconv(output, input,
ctx->out_width, ctx->out_height,
ctx->out_stride, ctx->in_stride);
return;
}
if (ctx->in_fmt != SCALER_FMT_ARGB8888)
{
ctx->in_pixconv(ctx->input.frame, input,

View File

@ -33,6 +33,15 @@
RETRO_BEGIN_DECLS
#define scaler_ctx_scale_direct(ctx, output, input) \
if (ctx->unscaled) \
/* Just perform straight pixel conversion. */ \
ctx->direct_pixconv(output, input, \
ctx->out_width, ctx->out_height, \
ctx->out_stride, ctx->in_stride); \
else \
scaler_ctx_scale(ctx, output, input)
static INLINE void video_frame_convert_rgb16_to_rgb32(
struct scaler_ctx *scaler,
void *output,
@ -55,7 +64,7 @@ static INLINE void video_frame_convert_rgb16_to_rgb32(
scaler->in_stride = in_pitch;
scaler->out_stride = width * sizeof(uint32_t);
scaler_ctx_scale(scaler, output, input);
scaler_ctx_scale_direct(scaler, output, input);
}
static INLINE void video_frame_scale(
@ -89,7 +98,7 @@ static INLINE void video_frame_scale(
scaler_ctx_gen_filter(scaler);
}
scaler_ctx_scale(scaler, output, input);
scaler_ctx_scale_direct(scaler, output, input);
}
static INLINE void video_frame_record_scale(
@ -123,7 +132,7 @@ static INLINE void video_frame_record_scale(
scaler_ctx_gen_filter(scaler);
}
scaler_ctx_scale(scaler, output, input);
scaler_ctx_scale_direct(scaler, output, input);
}
static INLINE void video_frame_convert_argb8888_to_abgr8888(
@ -145,7 +154,8 @@ static INLINE void video_frame_convert_argb8888_to_abgr8888(
scaler->in_stride = in_pitch;
scaler->out_stride = width * sizeof(uint32_t);
scaler_ctx_scale(scaler, output, input);
scaler_ctx_scale_direct(scaler, output, input);
}
static INLINE void video_frame_convert_to_bgr24(
@ -165,7 +175,7 @@ static INLINE void video_frame_convert_to_bgr24(
scaler->in_stride = in_pitch;
scaler->out_stride = width * 3;
scaler_ctx_scale(scaler, output, input);
scaler_ctx_scale_direct(scaler, output, input);
}
static INLINE void video_frame_convert_rgba_to_bgr(
@ -198,7 +208,7 @@ static INLINE bool video_pixel_frame_scale(
scaler->in_stride = (int)pitch;
scaler->out_stride = width * sizeof(uint16_t);
scaler_ctx_scale(scaler, output, data);
scaler_ctx_scale_direct(scaler, output, data);
return true;
}