Skip to content

Commit

Permalink
Create scaler_ctx_scale_direct
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Apr 16, 2017
1 parent 9c7dd30 commit 0c5a87b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
6 changes: 5 additions & 1 deletion camera/drivers/video4linux2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -352,6 +353,7 @@ static void *v4l_init(const char *device, uint64_t caps,

static bool preprocess_image(void *data)
{
struct scaler_ctx *ctx = NULL;
video4linux_t *v4l = (video4linux_t*)data;
struct v4l2_buffer buf = {0};

Expand All @@ -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");
Expand Down
5 changes: 4 additions & 1 deletion gfx/drivers/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions gfx/drivers/vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
9 changes: 0 additions & 9 deletions libretro-common/gfx/scaler/scaler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 16 additions & 6 deletions libretro-common/include/gfx/video_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 0c5a87b

Please sign in to comment.