From 10b6384bb225e003b6f35e1c7b8d3af35fbf9f20 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 23 Sep 2014 03:14:25 +0200 Subject: [PATCH] Move recording_dump_frame back to retroarch.c --- general.h | 3 ++ libretro_version_1.c | 69 ++------------------------------------------ retroarch.c | 65 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 66 deletions(-) diff --git a/general.h b/general.h index c0d27c1109..b3362c43dc 100644 --- a/general.h +++ b/general.h @@ -833,6 +833,9 @@ int rarch_defer_core(core_info_list_t *data, void rarch_update_system_info(struct retro_system_info *info, bool *load_no_content); +void rarch_recording_dump_frame(const void *data, unsigned width, + unsigned height, size_t pitch); + #ifdef __cplusplus } #endif diff --git a/libretro_version_1.c b/libretro_version_1.c index c74744e6a8..a334d0170f 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -25,70 +25,6 @@ #include "general.h" #include "performance.h" -static void recording_dump_frame(const void *data, unsigned width, - unsigned height, size_t pitch) -{ - struct ffemu_video_data ffemu_data = {0}; - - ffemu_data.pitch = pitch; - ffemu_data.width = width; - ffemu_data.height = height; - ffemu_data.data = data; - - if (g_extern.record_gpu_buffer) - { - struct rarch_viewport vp = {0}; - - if (driver.video && driver.video->viewport_info) - driver.video->viewport_info(driver.video_data, &vp); - - if (!vp.width || !vp.height) - { - RARCH_WARN("Viewport size calculation failed! Will continue using raw data. This will probably not work right ...\n"); - rarch_deinit_gpu_recording(); - - recording_dump_frame(data, width, height, pitch); - return; - } - - /* User has resized. We kinda have a problem now. */ - if (vp.width != g_extern.record_gpu_width || - vp.height != g_extern.record_gpu_height) - { - static const char msg[] = "Recording terminated due to resize."; - RARCH_WARN("%s\n", msg); - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, msg, 1, 180); - - rarch_deinit_recording(); - return; - } - - /* Big bottleneck. - * Since we might need to do read-backs asynchronously, - * it might take 3-4 times before this returns true. */ - if (driver.video && driver.video->read_viewport) - if (!driver.video->read_viewport(driver.video_data, - g_extern.record_gpu_buffer)) - return; - - ffemu_data.pitch = g_extern.record_gpu_width * 3; - ffemu_data.width = g_extern.record_gpu_width; - ffemu_data.height = g_extern.record_gpu_height; - ffemu_data.data = g_extern.record_gpu_buffer + - (ffemu_data.height - 1) * ffemu_data.pitch; - - ffemu_data.pitch = -ffemu_data.pitch; - } - - if (!g_extern.record_gpu_buffer) - ffemu_data.is_dupe = !data; - - if (g_extern.rec_driver && g_extern.rec_driver->push_video) - g_extern.rec_driver->push_video(g_extern.rec, &ffemu_data); -} - - static void video_frame(const void *data, unsigned width, unsigned height, size_t pitch) { @@ -128,7 +64,7 @@ static void video_frame(const void *data, unsigned width, || !g_settings.video.post_filter_record || !data || g_extern.record_gpu_buffer) ) - recording_dump_frame(data, width, height, pitch); + rarch_recording_dump_frame(data, width, height, pitch); msg = msg_queue_pull(g_extern.msg_queue); driver.current_msg = msg; @@ -152,7 +88,8 @@ static void video_frame(const void *data, unsigned width, RARCH_PERFORMANCE_STOP(softfilter_process); if (g_extern.rec && g_settings.video.post_filter_record) - recording_dump_frame(g_extern.filter.buffer, owidth, oheight, opitch); + rarch_recording_dump_frame(g_extern.filter.buffer, + owidth, oheight, opitch); data = g_extern.filter.buffer; width = owidth; diff --git a/retroarch.c b/retroarch.c index b7640ca214..24c06f6f36 100644 --- a/retroarch.c +++ b/retroarch.c @@ -226,6 +226,69 @@ void rarch_deinit_gpu_recording(void) g_extern.record_gpu_buffer = NULL; } +void rarch_recording_dump_frame(const void *data, unsigned width, + unsigned height, size_t pitch) +{ + struct ffemu_video_data ffemu_data = {0}; + + ffemu_data.pitch = pitch; + ffemu_data.width = width; + ffemu_data.height = height; + ffemu_data.data = data; + + if (g_extern.record_gpu_buffer) + { + struct rarch_viewport vp = {0}; + + if (driver.video && driver.video->viewport_info) + driver.video->viewport_info(driver.video_data, &vp); + + if (!vp.width || !vp.height) + { + RARCH_WARN("Viewport size calculation failed! Will continue using raw data. This will probably not work right ...\n"); + rarch_deinit_gpu_recording(); + + rarch_recording_dump_frame(data, width, height, pitch); + return; + } + + /* User has resized. We kinda have a problem now. */ + if (vp.width != g_extern.record_gpu_width || + vp.height != g_extern.record_gpu_height) + { + static const char msg[] = "Recording terminated due to resize."; + RARCH_WARN("%s\n", msg); + msg_queue_clear(g_extern.msg_queue); + msg_queue_push(g_extern.msg_queue, msg, 1, 180); + + rarch_deinit_recording(); + return; + } + + /* Big bottleneck. + * Since we might need to do read-backs asynchronously, + * it might take 3-4 times before this returns true. */ + if (driver.video && driver.video->read_viewport) + if (!driver.video->read_viewport(driver.video_data, + g_extern.record_gpu_buffer)) + return; + + ffemu_data.pitch = g_extern.record_gpu_width * 3; + ffemu_data.width = g_extern.record_gpu_width; + ffemu_data.height = g_extern.record_gpu_height; + ffemu_data.data = g_extern.record_gpu_buffer + + (ffemu_data.height - 1) * ffemu_data.pitch; + + ffemu_data.pitch = -ffemu_data.pitch; + } + + if (!g_extern.record_gpu_buffer) + ffemu_data.is_dupe = !data; + + if (g_extern.rec_driver && g_extern.rec_driver->push_video) + g_extern.rec_driver->push_video(g_extern.rec, &ffemu_data); +} + static void init_recording(void) { struct ffemu_params params = {0}; @@ -2664,6 +2727,8 @@ static void init_system_av_info(void) static void verify_api_version(void) { + /* TODO - when libretro v2 gets added, allow for switching + * between libretro version backend dynamically. */ RARCH_LOG("Version of libretro API: %u\n", pretro_api_version()); RARCH_LOG("Compiled against API: %u\n", RETRO_API_VERSION); if (pretro_api_version() != RETRO_API_VERSION)