2012-04-21 21:13:50 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2016-01-10 03:06:50 +00:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2011-12-24 12:46:12 +00:00
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
2011-12-24 12:46:12 +00:00
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
2011-12-24 12:46:12 +00:00
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
2012-04-21 21:31:57 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
2011-12-24 12:46:12 +00:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-05-04 09:47:55 +00:00
|
|
|
#include <string.h>
|
2015-09-05 18:34:22 +00:00
|
|
|
|
2015-04-15 10:42:36 +00:00
|
|
|
#include <file/file_path.h>
|
2016-09-01 15:52:22 +00:00
|
|
|
#include <compat/strl.h>
|
2016-01-20 05:11:47 +00:00
|
|
|
#include <string/stdstring.h>
|
2014-10-22 02:27:51 +00:00
|
|
|
|
2016-09-08 06:16:49 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-09-06 12:55:42 +00:00
|
|
|
#include "record_driver.h"
|
|
|
|
|
2016-05-09 18:30:47 +00:00
|
|
|
#include "../command.h"
|
2016-09-01 15:52:22 +00:00
|
|
|
#include "../configuration.h"
|
2016-09-11 14:31:23 +00:00
|
|
|
#include "../driver.h"
|
2016-01-19 22:44:32 +00:00
|
|
|
#include "../retroarch.h"
|
2016-09-01 15:52:22 +00:00
|
|
|
#include "../runloop.h"
|
2015-11-23 11:03:38 +00:00
|
|
|
#include "../verbosity.h"
|
2015-07-02 16:10:52 +00:00
|
|
|
#include "../msg_hash.h"
|
2016-03-20 16:28:24 +00:00
|
|
|
#include "../list_special.h"
|
2011-12-25 11:47:47 +00:00
|
|
|
|
2015-11-18 02:08:19 +00:00
|
|
|
|
2015-04-15 11:37:38 +00:00
|
|
|
static const record_driver_t *record_drivers[] = {
|
2014-05-04 09:47:55 +00:00
|
|
|
#ifdef HAVE_FFMPEG
|
|
|
|
&ffemu_ffmpeg,
|
2012-09-02 21:49:30 +00:00
|
|
|
#endif
|
2015-04-15 11:37:38 +00:00
|
|
|
&ffemu_null,
|
2014-05-04 09:47:55 +00:00
|
|
|
NULL,
|
2011-12-25 15:11:48 +00:00
|
|
|
};
|
2011-01-03 16:51:17 +00:00
|
|
|
|
2016-09-30 22:47:05 +00:00
|
|
|
unsigned recording_width = 0;
|
|
|
|
unsigned recording_height = 0;
|
|
|
|
size_t recording_gpu_width = 0;
|
|
|
|
size_t recording_gpu_height = 0;
|
|
|
|
static bool recording_enable = false;
|
|
|
|
static bool recording_use_output_dir = false;
|
|
|
|
|
|
|
|
static const record_driver_t *recording_driver = NULL;
|
|
|
|
static void *recording_data = NULL;
|
2015-12-05 15:08:08 +00:00
|
|
|
|
2015-04-15 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* record_driver_find_ident:
|
|
|
|
* @idx : index of driver to get handle to.
|
|
|
|
*
|
|
|
|
* Returns: Human-readable identifier of record driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
|
|
|
const char *record_driver_find_ident(int idx)
|
|
|
|
{
|
|
|
|
const record_driver_t *drv = record_drivers[idx];
|
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
return drv->ident;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* record_driver_find_handle:
|
|
|
|
* @idx : index of driver to get handle to.
|
|
|
|
*
|
|
|
|
* Returns: handle to record driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
|
|
|
const void *record_driver_find_handle(int idx)
|
|
|
|
{
|
|
|
|
const void *drv = record_drivers[idx];
|
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* config_get_record_driver_options:
|
|
|
|
*
|
|
|
|
* Get an enumerated list of all record driver names, separated by '|'.
|
|
|
|
*
|
|
|
|
* Returns: string listing of all record driver names, separated by '|'.
|
|
|
|
**/
|
|
|
|
const char* config_get_record_driver_options(void)
|
|
|
|
{
|
2015-10-26 18:41:20 +00:00
|
|
|
return char_list_new_special(STRING_LIST_RECORD_DRIVERS, NULL);
|
2015-04-15 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void find_record_driver(void)
|
|
|
|
{
|
2016-02-01 12:15:53 +00:00
|
|
|
int i;
|
|
|
|
driver_ctx_info_t drv;
|
2015-04-15 11:37:38 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2016-02-01 12:15:53 +00:00
|
|
|
|
|
|
|
drv.label = "record_driver";
|
|
|
|
drv.s = settings->record.driver;
|
|
|
|
|
|
|
|
driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv);
|
|
|
|
|
|
|
|
i = drv.len;
|
2015-04-15 11:37:38 +00:00
|
|
|
|
|
|
|
if (i >= 0)
|
2015-12-05 15:08:08 +00:00
|
|
|
recording_driver = (const record_driver_t*)record_driver_find_handle(i);
|
2015-04-15 11:37:38 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned d;
|
2015-06-12 21:45:01 +00:00
|
|
|
|
2015-07-02 16:10:52 +00:00
|
|
|
RARCH_ERR("Couldn't find any record driver named \"%s\"\n",
|
2015-04-15 11:37:38 +00:00
|
|
|
settings->audio.driver);
|
2015-07-02 16:10:52 +00:00
|
|
|
RARCH_LOG_OUTPUT("Available record drivers are:\n");
|
|
|
|
for (d = 0; record_driver_find_handle(d); d++)
|
2015-04-15 11:37:38 +00:00
|
|
|
RARCH_LOG_OUTPUT("\t%s\n", record_driver_find_ident(d));
|
2015-07-02 16:10:52 +00:00
|
|
|
RARCH_WARN("Going to default to first record driver...\n");
|
2015-04-15 11:37:38 +00:00
|
|
|
|
2015-12-05 15:08:08 +00:00
|
|
|
recording_driver = (const record_driver_t*)record_driver_find_handle(0);
|
2015-04-15 11:37:38 +00:00
|
|
|
|
2015-12-05 15:08:08 +00:00
|
|
|
if (!recording_driver)
|
2016-05-09 05:09:26 +00:00
|
|
|
retroarch_fail(1, "find_record_driver()");
|
2015-04-15 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-12 02:50:54 +00:00
|
|
|
/**
|
|
|
|
* ffemu_find_backend:
|
|
|
|
* @ident : Identifier of driver to find.
|
|
|
|
*
|
|
|
|
* Finds a recording driver with the name @ident.
|
|
|
|
*
|
|
|
|
* Returns: recording driver handle if successful, otherwise
|
|
|
|
* NULL.
|
|
|
|
**/
|
2015-04-15 11:37:38 +00:00
|
|
|
const record_driver_t *ffemu_find_backend(const char *ident)
|
2012-11-28 14:38:43 +00:00
|
|
|
{
|
2013-10-22 19:26:33 +00:00
|
|
|
unsigned i;
|
2015-01-12 02:50:54 +00:00
|
|
|
|
2015-04-15 11:37:38 +00:00
|
|
|
for (i = 0; record_drivers[i]; i++)
|
2012-11-23 21:46:21 +00:00
|
|
|
{
|
2016-01-20 05:11:47 +00:00
|
|
|
if (string_is_equal(record_drivers[i]->ident, ident))
|
2015-04-15 11:37:38 +00:00
|
|
|
return record_drivers[i];
|
2012-11-26 16:37:31 +00:00
|
|
|
}
|
2012-11-23 21:46:21 +00:00
|
|
|
|
2011-01-03 16:51:17 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-04-15 11:37:38 +00:00
|
|
|
|
2015-01-12 02:50:54 +00:00
|
|
|
/**
|
|
|
|
* gfx_ctx_init_first:
|
|
|
|
* @backend : Recording backend handle.
|
|
|
|
* @data : Recording data handle.
|
|
|
|
* @params : Recording info parameters.
|
|
|
|
*
|
|
|
|
* Finds first suitable recording context driver and initializes.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if successful, otherwise false (0).
|
|
|
|
**/
|
2015-04-15 11:37:38 +00:00
|
|
|
bool record_driver_init_first(const record_driver_t **backend, void **data,
|
2014-08-20 15:18:43 +00:00
|
|
|
const struct ffemu_params *params)
|
2011-01-03 16:51:17 +00:00
|
|
|
{
|
2014-05-04 09:47:55 +00:00
|
|
|
unsigned i;
|
2015-01-12 02:50:54 +00:00
|
|
|
|
2015-04-15 11:37:38 +00:00
|
|
|
for (i = 0; record_drivers[i]; i++)
|
2011-06-14 19:35:31 +00:00
|
|
|
{
|
2015-04-15 11:37:38 +00:00
|
|
|
void *handle = record_drivers[i]->init(params);
|
2015-01-12 02:50:54 +00:00
|
|
|
|
|
|
|
if (!handle)
|
|
|
|
continue;
|
|
|
|
|
2015-04-15 11:37:38 +00:00
|
|
|
*backend = record_drivers[i];
|
2015-01-12 02:50:54 +00:00
|
|
|
*data = handle;
|
|
|
|
return true;
|
2011-06-14 19:35:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-04 09:47:55 +00:00
|
|
|
return false;
|
2011-06-14 19:35:31 +00:00
|
|
|
}
|
2015-02-10 20:09:41 +00:00
|
|
|
|
|
|
|
void recording_dump_frame(const void *data, unsigned width,
|
|
|
|
unsigned height, size_t pitch)
|
|
|
|
{
|
|
|
|
struct ffemu_video_data ffemu_data = {0};
|
|
|
|
|
2015-12-05 15:08:08 +00:00
|
|
|
if (!recording_data)
|
2015-02-10 20:09:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
ffemu_data.pitch = pitch;
|
|
|
|
ffemu_data.width = width;
|
|
|
|
ffemu_data.height = height;
|
|
|
|
ffemu_data.data = data;
|
|
|
|
|
2016-05-08 12:00:51 +00:00
|
|
|
if (video_driver_has_gpu_record())
|
2015-02-10 20:09:41 +00:00
|
|
|
{
|
2015-12-06 14:22:20 +00:00
|
|
|
uint8_t *gpu_buf = NULL;
|
2015-02-14 04:52:05 +00:00
|
|
|
struct video_viewport vp = {0};
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2016-05-08 12:00:51 +00:00
|
|
|
video_driver_get_viewport_info(&vp);
|
2015-02-10 20:09:41 +00:00
|
|
|
|
|
|
|
if (!vp.width || !vp.height)
|
|
|
|
{
|
2015-07-02 16:10:52 +00:00
|
|
|
RARCH_WARN("%s \n",
|
|
|
|
msg_hash_to_str(MSG_VIEWPORT_SIZE_CALCULATION_FAILED));
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_GPU_RECORD_DEINIT, NULL);
|
2015-02-10 20:09:41 +00:00
|
|
|
|
|
|
|
recording_dump_frame(data, width, height, pitch);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* User has resized. We kinda have a problem now. */
|
2016-09-30 22:47:05 +00:00
|
|
|
if ( vp.width != recording_gpu_width ||
|
|
|
|
vp.height != recording_gpu_height)
|
2015-02-10 20:09:41 +00:00
|
|
|
{
|
2015-07-02 16:10:52 +00:00
|
|
|
RARCH_WARN("%s\n", msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE));
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2016-01-29 13:30:09 +00:00
|
|
|
runloop_msg_queue_push(
|
|
|
|
msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE),
|
|
|
|
1, 180, true);
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
|
2015-02-10 20:09:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-08 12:00:51 +00:00
|
|
|
gpu_buf = video_driver_get_gpu_record();
|
|
|
|
if (!gpu_buf)
|
2015-12-06 14:22:20 +00:00
|
|
|
return;
|
|
|
|
|
2015-02-10 20:09:41 +00:00
|
|
|
/* Big bottleneck.
|
|
|
|
* Since we might need to do read-backs asynchronously,
|
|
|
|
* it might take 3-4 times before this returns true. */
|
2016-05-08 12:00:51 +00:00
|
|
|
if (!video_driver_read_viewport(gpu_buf))
|
|
|
|
return;
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2016-09-30 22:47:05 +00:00
|
|
|
ffemu_data.pitch = recording_gpu_width * 3;
|
|
|
|
ffemu_data.width = recording_gpu_width;
|
|
|
|
ffemu_data.height = recording_gpu_height;
|
2015-12-06 14:22:20 +00:00
|
|
|
ffemu_data.data = gpu_buf + (ffemu_data.height - 1) * ffemu_data.pitch;
|
2015-02-10 20:09:41 +00:00
|
|
|
|
|
|
|
ffemu_data.pitch = -ffemu_data.pitch;
|
|
|
|
}
|
|
|
|
|
2016-05-08 12:00:51 +00:00
|
|
|
if (!video_driver_has_gpu_record())
|
2015-02-10 20:09:41 +00:00
|
|
|
ffemu_data.is_dupe = !data;
|
|
|
|
|
2015-12-05 15:08:08 +00:00
|
|
|
if (recording_driver && recording_driver->push_video)
|
|
|
|
recording_driver->push_video(recording_data, &ffemu_data);
|
2015-02-10 20:09:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool recording_deinit(void)
|
|
|
|
{
|
2015-12-05 15:08:08 +00:00
|
|
|
if (!recording_data || !recording_driver)
|
2015-02-10 20:09:41 +00:00
|
|
|
return false;
|
|
|
|
|
2015-12-05 15:08:08 +00:00
|
|
|
if (recording_driver->finalize)
|
|
|
|
recording_driver->finalize(recording_data);
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2015-12-05 15:08:08 +00:00
|
|
|
if (recording_driver->free)
|
|
|
|
recording_driver->free(recording_data);
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2015-12-05 15:08:08 +00:00
|
|
|
recording_data = NULL;
|
|
|
|
recording_driver = NULL;
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_GPU_RECORD_DEINIT, NULL);
|
2015-02-10 20:09:41 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-11-18 02:08:19 +00:00
|
|
|
bool *recording_is_enabled(void)
|
|
|
|
{
|
|
|
|
return &recording_enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void recording_set_state(bool state)
|
|
|
|
{
|
|
|
|
recording_enable = state;
|
|
|
|
}
|
|
|
|
|
2015-11-30 00:49:17 +00:00
|
|
|
void recording_push_audio(const int16_t *data, size_t samples)
|
|
|
|
{
|
|
|
|
struct ffemu_audio_data ffemu_data;
|
|
|
|
|
2015-12-05 15:08:08 +00:00
|
|
|
if (!recording_data)
|
2015-11-30 00:49:17 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
ffemu_data.data = data;
|
|
|
|
ffemu_data.frames = samples / 2;
|
|
|
|
|
2015-12-05 15:08:08 +00:00
|
|
|
if (recording_driver && recording_driver->push_audio)
|
|
|
|
recording_driver->push_audio(recording_data, &ffemu_data);
|
2015-11-30 00:49:17 +00:00
|
|
|
}
|
|
|
|
|
2015-02-10 20:09:41 +00:00
|
|
|
/**
|
|
|
|
* recording_init:
|
|
|
|
*
|
|
|
|
* Initializes recording.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if successful, otherwise false (0).
|
|
|
|
**/
|
|
|
|
bool recording_init(void)
|
|
|
|
{
|
2016-10-21 04:15:20 +00:00
|
|
|
char recording_file[PATH_MAX_LENGTH];
|
2015-06-12 21:45:01 +00:00
|
|
|
struct ffemu_params params = {0};
|
2015-05-20 16:57:17 +00:00
|
|
|
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
2015-11-18 02:08:19 +00:00
|
|
|
bool *recording_enabled = recording_is_enabled();
|
2016-10-01 06:24:02 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2015-11-18 02:08:19 +00:00
|
|
|
if (!*recording_enabled)
|
2015-02-10 20:09:41 +00:00
|
|
|
return false;
|
|
|
|
|
2016-10-21 04:15:20 +00:00
|
|
|
recording_file[0] = '\0';
|
|
|
|
|
2016-01-19 22:44:32 +00:00
|
|
|
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
2015-02-10 20:09:41 +00:00
|
|
|
{
|
2016-02-07 19:32:53 +00:00
|
|
|
RARCH_WARN("%s\n",
|
|
|
|
msg_hash_to_str(MSG_USING_LIBRETRO_DUMMY_CORE_RECORDING_SKIPPED));
|
2015-02-10 20:09:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-07 19:32:53 +00:00
|
|
|
if (!settings->video.gpu_record
|
2016-05-08 12:00:51 +00:00
|
|
|
&& video_driver_is_hw_context())
|
2015-02-10 20:09:41 +00:00
|
|
|
{
|
2016-02-07 19:32:53 +00:00
|
|
|
RARCH_WARN("%s.\n",
|
|
|
|
msg_hash_to_str(MSG_HW_RENDERED_MUST_USE_POSTSHADED_RECORDING));
|
2015-02-10 20:09:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-02 16:10:52 +00:00
|
|
|
RARCH_LOG("%s: FPS: %.4f, Sample rate: %.4f\n",
|
|
|
|
msg_hash_to_str(MSG_CUSTOM_TIMING_GIVEN),
|
2015-05-20 16:57:17 +00:00
|
|
|
(float)av_info->timing.fps,
|
|
|
|
(float)av_info->timing.sample_rate);
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2016-10-01 06:17:13 +00:00
|
|
|
strlcpy(recording_file, global->record.path, sizeof(recording_file));
|
2015-04-15 10:42:36 +00:00
|
|
|
|
2016-09-30 22:47:05 +00:00
|
|
|
if (recording_use_output_dir)
|
2015-04-15 10:42:36 +00:00
|
|
|
fill_pathname_join(recording_file,
|
2016-10-01 06:15:07 +00:00
|
|
|
global->record.output_dir,
|
2016-10-01 06:17:13 +00:00
|
|
|
global->record.path, sizeof(recording_file));
|
2015-04-15 10:42:36 +00:00
|
|
|
|
2015-05-20 16:57:17 +00:00
|
|
|
params.out_width = av_info->geometry.base_width;
|
|
|
|
params.out_height = av_info->geometry.base_height;
|
|
|
|
params.fb_width = av_info->geometry.max_width;
|
|
|
|
params.fb_height = av_info->geometry.max_height;
|
2015-02-10 20:09:41 +00:00
|
|
|
params.channels = 2;
|
2015-04-15 10:42:36 +00:00
|
|
|
params.filename = recording_file;
|
2015-05-20 16:57:17 +00:00
|
|
|
params.fps = av_info->timing.fps;
|
|
|
|
params.samplerate = av_info->timing.sample_rate;
|
2015-05-20 18:59:12 +00:00
|
|
|
params.pix_fmt = (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) ?
|
2015-02-10 20:09:41 +00:00
|
|
|
FFEMU_PIX_ARGB8888 : FFEMU_PIX_RGB565;
|
|
|
|
params.config = NULL;
|
|
|
|
|
2016-10-01 06:17:13 +00:00
|
|
|
if (*global->record.config)
|
|
|
|
params.config = global->record.config;
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2016-05-08 12:00:51 +00:00
|
|
|
if (video_driver_supports_recording())
|
2015-02-10 20:09:41 +00:00
|
|
|
{
|
2015-12-06 14:22:20 +00:00
|
|
|
unsigned gpu_size;
|
2015-02-14 04:52:05 +00:00
|
|
|
struct video_viewport vp = {0};
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2016-05-08 12:00:51 +00:00
|
|
|
video_driver_get_viewport_info(&vp);
|
2015-02-10 20:09:41 +00:00
|
|
|
|
|
|
|
if (!vp.width || !vp.height)
|
|
|
|
{
|
|
|
|
RARCH_ERR("Failed to get viewport information from video driver. "
|
|
|
|
"Cannot start recording ...\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
params.out_width = vp.width;
|
|
|
|
params.out_height = vp.height;
|
|
|
|
params.fb_width = next_pow2(vp.width);
|
|
|
|
params.fb_height = next_pow2(vp.height);
|
|
|
|
|
2015-03-20 19:43:22 +00:00
|
|
|
if (settings->video.force_aspect &&
|
2015-05-20 16:24:45 +00:00
|
|
|
(video_driver_get_aspect_ratio() > 0.0f))
|
|
|
|
params.aspect_ratio = video_driver_get_aspect_ratio();
|
2015-02-10 20:09:41 +00:00
|
|
|
else
|
|
|
|
params.aspect_ratio = (float)vp.width / vp.height;
|
|
|
|
|
|
|
|
params.pix_fmt = FFEMU_PIX_BGR24;
|
2016-09-30 22:47:05 +00:00
|
|
|
recording_gpu_width = vp.width;
|
|
|
|
recording_gpu_height = vp.height;
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2015-07-02 16:10:52 +00:00
|
|
|
RARCH_LOG("%s %u x %u\n", msg_hash_to_str(MSG_DETECTED_VIEWPORT_OF),
|
2015-02-10 20:09:41 +00:00
|
|
|
vp.width, vp.height);
|
|
|
|
|
2015-12-06 14:22:20 +00:00
|
|
|
gpu_size = vp.width * vp.height * 3;
|
2016-05-08 12:00:51 +00:00
|
|
|
if (!video_driver_gpu_record_init(gpu_size))
|
2015-02-10 20:09:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-30 22:47:05 +00:00
|
|
|
if (recording_width || recording_height)
|
2015-02-10 20:09:41 +00:00
|
|
|
{
|
2016-09-30 22:47:05 +00:00
|
|
|
params.out_width = recording_width;
|
|
|
|
params.out_height = recording_height;
|
2015-02-10 20:09:41 +00:00
|
|
|
}
|
|
|
|
|
2015-03-20 19:43:22 +00:00
|
|
|
if (settings->video.force_aspect &&
|
2015-05-20 16:24:45 +00:00
|
|
|
(video_driver_get_aspect_ratio() > 0.0f))
|
|
|
|
params.aspect_ratio = video_driver_get_aspect_ratio();
|
2015-02-10 20:09:41 +00:00
|
|
|
else
|
|
|
|
params.aspect_ratio = (float)params.out_width / params.out_height;
|
|
|
|
|
2016-02-07 19:32:53 +00:00
|
|
|
if (settings->video.post_filter_record
|
2016-05-08 12:00:51 +00:00
|
|
|
&& video_driver_frame_filter_alive())
|
2015-02-10 20:09:41 +00:00
|
|
|
{
|
|
|
|
unsigned max_width = 0;
|
|
|
|
unsigned max_height = 0;
|
2015-11-20 14:16:58 +00:00
|
|
|
|
|
|
|
params.pix_fmt = FFEMU_PIX_RGB565;
|
2015-02-10 20:09:41 +00:00
|
|
|
|
2016-05-08 12:00:51 +00:00
|
|
|
if (video_driver_frame_filter_is_32bit())
|
2015-02-10 20:09:41 +00:00
|
|
|
params.pix_fmt = FFEMU_PIX_ARGB8888;
|
|
|
|
|
2015-05-20 18:49:52 +00:00
|
|
|
rarch_softfilter_get_max_output_size(
|
|
|
|
video_driver_frame_filter_get_ptr(),
|
2015-02-10 20:09:41 +00:00
|
|
|
&max_width, &max_height);
|
|
|
|
params.fb_width = next_pow2(max_width);
|
|
|
|
params.fb_height = next_pow2(max_height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-02 16:10:52 +00:00
|
|
|
RARCH_LOG("%s %s @ %ux%u. (FB size: %ux%u pix_fmt: %u)\n",
|
|
|
|
msg_hash_to_str(MSG_RECORDING_TO),
|
2016-10-01 06:17:13 +00:00
|
|
|
global->record.path,
|
2015-02-10 20:09:41 +00:00
|
|
|
params.out_width, params.out_height,
|
|
|
|
params.fb_width, params.fb_height,
|
|
|
|
(unsigned)params.pix_fmt);
|
|
|
|
|
2015-12-05 15:08:08 +00:00
|
|
|
if (!record_driver_init_first(&recording_driver, &recording_data, ¶ms))
|
2015-02-10 20:09:41 +00:00
|
|
|
{
|
2015-08-29 13:05:40 +00:00
|
|
|
RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_START_RECORDING));
|
2016-05-09 18:51:53 +00:00
|
|
|
command_event(CMD_EVENT_GPU_RECORD_DEINIT, NULL);
|
2015-02-10 20:09:41 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-12-05 15:05:35 +00:00
|
|
|
|
|
|
|
void *recording_driver_get_data_ptr(void)
|
|
|
|
{
|
2015-12-05 15:08:08 +00:00
|
|
|
return recording_data;
|
2015-12-05 15:05:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void recording_driver_clear_data_ptr(void)
|
|
|
|
{
|
2015-12-05 15:08:08 +00:00
|
|
|
recording_data = NULL;
|
2015-12-05 15:05:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void recording_driver_set_data_ptr(void *data)
|
|
|
|
{
|
2015-12-05 15:08:08 +00:00
|
|
|
recording_data = data;
|
2015-12-05 15:05:35 +00:00
|
|
|
}
|
2016-09-30 22:47:05 +00:00
|
|
|
|
|
|
|
bool *recording_driver_get_use_output_dir_ptr(void)
|
|
|
|
{
|
|
|
|
return &recording_use_output_dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned *recording_driver_get_width(void)
|
|
|
|
{
|
|
|
|
return &recording_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned *recording_driver_get_height(void)
|
|
|
|
{
|
|
|
|
return &recording_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
void recording_driver_free_state(void)
|
|
|
|
{
|
|
|
|
recording_use_output_dir = false;
|
|
|
|
recording_gpu_width = 0;
|
|
|
|
recording_gpu_height = 0;
|
|
|
|
recording_width = 0;
|
|
|
|
recording_height = 0;
|
|
|
|
}
|