From 8efe2de0ecec95a7c76493f563bed72e5b87dfc8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 09:08:32 +0200 Subject: [PATCH] (RJPEG/RPNG) Add debug logs and change function signatures --- gfx/video_texture_image.c | 3 +- libretro-common/formats/image_transfer.c | 35 ++++++++++++++++++++++-- libretro-common/formats/jpeg/rjpeg.c | 9 +++--- libretro-common/formats/png/rpng.c | 4 ++- libretro-common/include/formats/rjpeg.h | 2 +- libretro-common/include/formats/rpng.h | 2 +- 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 8949781813..d133e11930 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -184,7 +184,8 @@ static bool video_texture_image_load_png( do { - ret = rpng_nbio_load_image_argb_process(rpng, &out_img->pixels, &out_img->width, + ret = rpng_nbio_load_image_argb_process(rpng, + (void**)&out_img->pixels, &out_img->width, &out_img->height); }while(ret == IMAGE_PROCESS_NEXT); diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c index b0a756163e..16e1943421 100644 --- a/libretro-common/formats/image_transfer.c +++ b/libretro-common/formats/image_transfer.c @@ -11,8 +11,16 @@ #include +#if 0 +#define DEBUG +#endif + void image_transfer_free(void *data, enum image_type_enum type) { +#ifdef DEBUG + printf("image_transfer_free\n"); +#endif + switch (type) { case IMAGE_TYPE_PNG: @@ -30,6 +38,10 @@ void image_transfer_free(void *data, enum image_type_enum type) void *image_transfer_new(enum image_type_enum type) { +#ifdef DEBUG + printf("image_transfer_new\n"); +#endif + switch (type) { case IMAGE_TYPE_PNG: @@ -53,6 +65,10 @@ void *image_transfer_new(enum image_type_enum type) bool image_transfer_start(void *data, enum image_type_enum type) { +#ifdef DEBUG + printf("image_transfer_start\n"); +#endif + switch (type) { case IMAGE_TYPE_PNG: @@ -95,6 +111,10 @@ int image_transfer_process( uint32_t **buf, size_t len, unsigned *width, unsigned *height) { +#ifdef DEBUG + printf("image_transfer_process\n"); +#endif + switch (type) { case IMAGE_TYPE_PNG: @@ -104,14 +124,17 @@ int image_transfer_process( return rpng_nbio_load_image_argb_process( (rpng_t*)data, - buf, width, height); + (void**)buf, width, height); #else break; #endif case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG +#ifdef DEBUG + printf("len is: %d\n", len); +#endif return rjpeg_process_image((rjpeg_t*)data, - buf, len, width, height); + (void**)buf, len, width, height); #else break; #endif @@ -122,6 +145,10 @@ int image_transfer_process( bool image_transfer_iterate(void *data, enum image_type_enum type) { +#ifdef DEBUG + printf("image_transfer_iterate\n"); +#endif + switch (type) { case IMAGE_TYPE_PNG: @@ -132,8 +159,10 @@ bool image_transfer_iterate(void *data, enum image_type_enum type) break; case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG -#endif + return false; +#else break; +#endif } return true; diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 4ac0defbff..887c6e3667 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -2446,17 +2446,18 @@ static INLINE void video_frame_convert_rgba_to_bgra( } } -int rjpeg_process_image(void *data, uint8_t *buf, +int rjpeg_process_image(void *data, void **buf_data, size_t size, unsigned *width, unsigned *height) { int comp; struct texture_image *out_img = (struct texture_image*)data; + uint8_t **buf = (uint8_t**)buf_data; - out_img->pixels = (uint32_t*)rjpeg_load_from_memory(buf, size, width, height, &comp, 4); + 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; + return IMAGE_PROCESS_END; } bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, @@ -2467,7 +2468,7 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, unsigned height = 0; struct texture_image *out_img = (struct texture_image*)data; - if (rjpeg_process_image(out_img, buf, size, &width, &height)) + if (rjpeg_process_image(out_img, (void**)&buf, size, &width, &height) == IMAGE_PROCESS_END) return true; return false; diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index 3a52e2d2fc..81f85258d1 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -943,8 +943,10 @@ error: } int rpng_nbio_load_image_argb_process(rpng_t *rpng, - uint32_t **data, unsigned *width, unsigned *height) + void **_data, unsigned *width, unsigned *height) { + uint32_t **data = (uint32_t**)_data; + if (!rpng->process.initialized) { if (!rpng->process.stream_backend) diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index afb51c942e..a73de52340 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -34,7 +34,7 @@ RETRO_BEGIN_DECLS typedef struct rjpeg rjpeg_t; -int rjpeg_process_image(void *data, uint8_t *buf, +int rjpeg_process_image(void *data, void **buf, size_t size, unsigned *width, unsigned *height); bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, diff --git a/libretro-common/include/formats/rpng.h b/libretro-common/include/formats/rpng.h index b9fa108b62..47a30630bf 100644 --- a/libretro-common/include/formats/rpng.h +++ b/libretro-common/include/formats/rpng.h @@ -48,7 +48,7 @@ void rpng_nbio_load_image_free(rpng_t *rpng); bool rpng_nbio_load_image_argb_iterate(rpng_t *rpng); int rpng_nbio_load_image_argb_process(rpng_t *rpng, - uint32_t **data, unsigned *width, unsigned *height); + void **data, unsigned *width, unsigned *height); bool rpng_nbio_load_image_argb_start(rpng_t *rpng);