mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-25 20:25:42 +00:00
Start preparing image transfer for RJPEG
This commit is contained in:
parent
17d39fd54f
commit
5068accc4e
@ -92,7 +92,7 @@ void image_transfer_set_buffer_ptr(
|
||||
int image_transfer_process(
|
||||
void *data,
|
||||
enum image_type_enum type,
|
||||
uint32_t **buf,
|
||||
uint32_t **buf, size_t len,
|
||||
unsigned *width, unsigned *height)
|
||||
{
|
||||
switch (type)
|
||||
@ -104,14 +104,17 @@ int image_transfer_process(
|
||||
|
||||
return rpng_nbio_load_image_argb_process(
|
||||
(rpng_t*)data,
|
||||
buf,
|
||||
width, height);
|
||||
#endif
|
||||
buf, width, height);
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
case IMAGE_TYPE_JPEG:
|
||||
#ifdef HAVE_RJPEG
|
||||
#endif
|
||||
return rjpeg_process_image((rjpeg_t*)data,
|
||||
buf, len, width, height);
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -181,7 +181,7 @@ static void rjpeg__rewind(rjpeg__context *s)
|
||||
}
|
||||
|
||||
static int rjpeg__jpeg_test(rjpeg__context *s);
|
||||
static uint8_t *rjpeg__jpeg_load(rjpeg__context *s, int *x, int *y, int *comp, int req_comp);
|
||||
static uint8_t *rjpeg__jpeg_load(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp);
|
||||
|
||||
/* this is not threadsafe */
|
||||
static const char *rjpeg__g_failure_reason;
|
||||
@ -205,7 +205,7 @@ static INLINE int rjpeg__err(const char *str)
|
||||
|
||||
static int rjpeg__vertically_flip_on_load = 0;
|
||||
|
||||
static unsigned char *rjpeg__load_main(rjpeg__context *s, int *x, int *y, int *comp, int req_comp)
|
||||
static unsigned char *rjpeg__load_main(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp)
|
||||
{
|
||||
if (rjpeg__jpeg_test(s))
|
||||
return rjpeg__jpeg_load(s,x,y,comp,req_comp);
|
||||
@ -213,7 +213,7 @@ static unsigned char *rjpeg__load_main(rjpeg__context *s, int *x, int *y, int *c
|
||||
return rjpeg__errpuc("unknown image type", "Image not of any known type, or corrupt");
|
||||
}
|
||||
|
||||
static unsigned char *rjpeg__load_flip(rjpeg__context *s, int *x, int *y, int *comp, int req_comp)
|
||||
static unsigned char *rjpeg__load_flip(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp)
|
||||
{
|
||||
unsigned char *result = rjpeg__load_main(s, x, y, comp, req_comp);
|
||||
|
||||
@ -241,7 +241,7 @@ static unsigned char *rjpeg__load_flip(rjpeg__context *s, int *x, int *y, int *c
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint8_t *rjpeg_load_from_memory(const uint8_t *buffer, int len, int *x, int *y, int *comp, int req_comp)
|
||||
static uint8_t *rjpeg_load_from_memory(const uint8_t *buffer, int len, unsigned *x, unsigned *y, int *comp, int req_comp)
|
||||
{
|
||||
rjpeg__context s;
|
||||
rjpeg__start_mem(&s,buffer,len);
|
||||
@ -2279,7 +2279,7 @@ static void rjpeg__cleanup_jpeg(rjpeg__jpeg *j)
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t *rjpeg_load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp)
|
||||
static uint8_t *rjpeg_load_jpeg_image(rjpeg__jpeg *z, unsigned *out_x, unsigned *out_y, int *comp, int req_comp)
|
||||
{
|
||||
int n, decode_n;
|
||||
z->s->img_n = 0; /* make rjpeg__cleanup_jpeg safe */
|
||||
@ -2409,7 +2409,7 @@ static uint8_t *rjpeg_load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, in
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char *rjpeg__jpeg_load(rjpeg__context *s, int *x, int *y, int *comp, int req_comp)
|
||||
static unsigned char *rjpeg__jpeg_load(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp)
|
||||
{
|
||||
rjpeg__jpeg j;
|
||||
j.s = s;
|
||||
@ -2446,25 +2446,31 @@ static INLINE void video_frame_convert_rgba_to_bgra(
|
||||
}
|
||||
}
|
||||
|
||||
bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size,
|
||||
int rjpeg_process_image(void *data, uint8_t *buf,
|
||||
size_t size, unsigned *width, unsigned *height)
|
||||
{
|
||||
int comp;
|
||||
struct texture_image *out_img = (struct texture_image*)data;
|
||||
|
||||
out_img->pixels = (uint32_t*)rjpeg_load_from_memory(buf, size, width, height, &comp, 4);
|
||||
out_img->width = *width;
|
||||
out_img->height = *height;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool rjpeg_image_load(uint8_t *buf, void *data, size_t size,
|
||||
unsigned a_shift, unsigned r_shift,
|
||||
unsigned g_shift, unsigned b_shift)
|
||||
{
|
||||
int comp;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
struct texture_image *out_img = (struct texture_image*)data;
|
||||
|
||||
out_img->pixels = (uint32_t*)rjpeg_load_from_memory(_buf, size, &x, &y, &comp, 4);
|
||||
if (rjpeg_process_image(out_img, buf, size, &width, &height))
|
||||
return true;
|
||||
|
||||
out_img->width = x;
|
||||
out_img->height = y;
|
||||
|
||||
if (r_shift == 0 && b_shift == 16) { } /* RGBA, doesn't need conversion */
|
||||
else
|
||||
video_frame_convert_rgba_to_bgra(_buf, out_img->pixels, x);
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void rjpeg_free(rjpeg_t *rjpeg)
|
||||
|
@ -1019,12 +1019,12 @@ bool rpng_is_valid(rpng_t *rpng)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool rpng_set_buf_ptr(rpng_t *rpng, uint8_t *data)
|
||||
bool rpng_set_buf_ptr(rpng_t *rpng, void *data)
|
||||
{
|
||||
if (!rpng)
|
||||
return false;
|
||||
|
||||
rpng->buff_data = data;
|
||||
rpng->buff_data = (uint8_t*)data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void image_transfer_set_buffer_ptr(
|
||||
int image_transfer_process(
|
||||
void *data,
|
||||
enum image_type_enum type,
|
||||
uint32_t **buf,
|
||||
uint32_t **buf, size_t size,
|
||||
unsigned *width, unsigned *height);
|
||||
|
||||
bool image_transfer_iterate(void *data, enum image_type_enum type);
|
||||
|
@ -34,6 +34,9 @@ RETRO_BEGIN_DECLS
|
||||
|
||||
typedef struct rjpeg rjpeg_t;
|
||||
|
||||
int rjpeg_process_image(void *data, uint8_t *buf,
|
||||
size_t size, unsigned *width, unsigned *height);
|
||||
|
||||
bool rjpeg_image_load(uint8_t *buf, void *data, size_t size,
|
||||
unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift);
|
||||
|
||||
|
@ -39,7 +39,7 @@ rpng_t *rpng_nbio_load_image_argb_init(const char *path);
|
||||
|
||||
bool rpng_is_valid(rpng_t *rpng);
|
||||
|
||||
bool rpng_set_buf_ptr(rpng_t *rpng, uint8_t *data);
|
||||
bool rpng_set_buf_ptr(rpng_t *rpng, void *data);
|
||||
|
||||
rpng_t *rpng_alloc(void);
|
||||
|
||||
|
@ -101,7 +101,7 @@ static int rarch_main_data_image_process(
|
||||
int retval = image_transfer_process(
|
||||
nbio->image.handle,
|
||||
nbio->image_type,
|
||||
&nbio->image.ti.pixels, width, height);
|
||||
&nbio->image.ti.pixels, nbio->image.size, width, height);
|
||||
|
||||
if (retval == IMAGE_PROCESS_ERROR)
|
||||
return IMAGE_PROCESS_ERROR;
|
||||
@ -220,6 +220,7 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len)
|
||||
|
||||
image_transfer_set_buffer_ptr(nbio->image.handle, nbio->image_type, ptr);
|
||||
|
||||
nbio->image.size = *len;
|
||||
nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1;
|
||||
nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1;
|
||||
|
||||
@ -245,6 +246,7 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len)
|
||||
return -1;
|
||||
|
||||
nbio->image.handle = image_transfer_new(nbio->image_type);
|
||||
nbio->image.size = len;
|
||||
|
||||
if (!nbio->image.handle)
|
||||
goto error;
|
||||
|
@ -62,6 +62,7 @@ typedef struct nbio_image_handle
|
||||
bool is_finished;
|
||||
transfer_cb_t cb;
|
||||
void *handle;
|
||||
size_t size;
|
||||
unsigned processing_pos_increment;
|
||||
unsigned pos_increment;
|
||||
uint64_t frame_count;
|
||||
|
Loading…
Reference in New Issue
Block a user