mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #3930 from RisingFog/split_video_dump_resolution
Split Video Dumps on Resolution Change
This commit is contained in:
commit
28a3691e70
@ -880,12 +880,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dump frames
|
// Dump frames
|
||||||
static int w = 0, h = 0;
|
|
||||||
if (SConfig::GetInstance().m_DumpFrames)
|
if (SConfig::GetInstance().m_DumpFrames)
|
||||||
{
|
{
|
||||||
static int s_recordWidth;
|
|
||||||
static int s_recordHeight;
|
|
||||||
|
|
||||||
if (!s_screenshot_texture)
|
if (!s_screenshot_texture)
|
||||||
CreateScreenshotTexture();
|
CreateScreenshotTexture();
|
||||||
|
|
||||||
@ -897,9 +893,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||||||
&source_box);
|
&source_box);
|
||||||
if (!bLastFrameDumped)
|
if (!bLastFrameDumped)
|
||||||
{
|
{
|
||||||
s_recordWidth = source_width;
|
bAVIDumping = AVIDump::Start(source_width, source_height, AVIDump::DumpFormat::FORMAT_BGR);
|
||||||
s_recordHeight = source_height;
|
|
||||||
bAVIDumping = AVIDump::Start(s_recordWidth, s_recordHeight, AVIDump::DumpFormat::FORMAT_BGR);
|
|
||||||
if (!bAVIDumping)
|
if (!bAVIDumping)
|
||||||
{
|
{
|
||||||
PanicAlert("Error dumping frames to AVI.");
|
PanicAlert("Error dumping frames to AVI.");
|
||||||
@ -908,7 +902,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||||||
{
|
{
|
||||||
std::string msg = StringFromFormat("Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)",
|
std::string msg = StringFromFormat("Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)",
|
||||||
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
|
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
|
||||||
s_recordWidth, s_recordHeight);
|
source_width, source_height);
|
||||||
|
|
||||||
OSD::AddMessage(msg, 2000);
|
OSD::AddMessage(msg, 2000);
|
||||||
}
|
}
|
||||||
@ -918,14 +912,11 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||||||
D3D11_MAPPED_SUBRESOURCE map;
|
D3D11_MAPPED_SUBRESOURCE map;
|
||||||
D3D::context->Map(s_screenshot_texture, 0, D3D11_MAP_READ, 0, &map);
|
D3D::context->Map(s_screenshot_texture, 0, D3D11_MAP_READ, 0, &map);
|
||||||
|
|
||||||
if (frame_data.empty() || w != s_recordWidth || h != s_recordHeight)
|
if (frame_data.capacity() != 3 * source_width * source_height)
|
||||||
{
|
frame_data.resize(3 * source_width * source_height);
|
||||||
frame_data.resize(3 * s_recordWidth * s_recordHeight);
|
|
||||||
w = s_recordWidth;
|
|
||||||
h = s_recordHeight;
|
|
||||||
}
|
|
||||||
formatBufferDump((u8*)map.pData, &frame_data[0], source_width, source_height, map.RowPitch);
|
formatBufferDump((u8*)map.pData, &frame_data[0], source_width, source_height, map.RowPitch);
|
||||||
FlipImageData(&frame_data[0], w, h);
|
FlipImageData(&frame_data[0], source_width, source_height);
|
||||||
AVIDump::AddFrame(&frame_data[0], source_width, source_height);
|
AVIDump::AddFrame(&frame_data[0], source_width, source_height);
|
||||||
D3D::context->Unmap(s_screenshot_texture, 0);
|
D3D::context->Unmap(s_screenshot_texture, 0);
|
||||||
}
|
}
|
||||||
@ -936,8 +927,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||||||
if (bLastFrameDumped && bAVIDumping)
|
if (bLastFrameDumped && bAVIDumping)
|
||||||
{
|
{
|
||||||
std::vector<u8>().swap(frame_data);
|
std::vector<u8>().swap(frame_data);
|
||||||
w = h = 0;
|
|
||||||
|
|
||||||
AVIDump::Stop();
|
AVIDump::Stop();
|
||||||
bAVIDumping = false;
|
bAVIDumping = false;
|
||||||
OSD::AddMessage("Stop dumping frames to AVI", 2000);
|
OSD::AddMessage("Stop dumping frames to AVI", 2000);
|
||||||
|
@ -836,12 +836,8 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dump frames
|
// Dump frames
|
||||||
static int w = 0, h = 0;
|
|
||||||
if (SConfig::GetInstance().m_DumpFrames)
|
if (SConfig::GetInstance().m_DumpFrames)
|
||||||
{
|
{
|
||||||
static unsigned int s_record_width;
|
|
||||||
static unsigned int s_record_height;
|
|
||||||
|
|
||||||
if (!s_screenshot_texture)
|
if (!s_screenshot_texture)
|
||||||
CreateScreenshotTexture();
|
CreateScreenshotTexture();
|
||||||
|
|
||||||
@ -875,10 +871,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
|||||||
|
|
||||||
if (!bLastFrameDumped)
|
if (!bLastFrameDumped)
|
||||||
{
|
{
|
||||||
s_record_width = source_width;
|
bAVIDumping = AVIDump::Start(source_width, source_height, AVIDump::DumpFormat::FORMAT_BGR);
|
||||||
s_record_height = source_height;
|
|
||||||
bAVIDumping =
|
|
||||||
AVIDump::Start(s_record_width, s_record_height, AVIDump::DumpFormat::FORMAT_BGR);
|
|
||||||
if (!bAVIDumping)
|
if (!bAVIDumping)
|
||||||
{
|
{
|
||||||
PanicAlert("Error dumping frames to AVI.");
|
PanicAlert("Error dumping frames to AVI.");
|
||||||
@ -887,19 +880,15 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
|||||||
{
|
{
|
||||||
std::string msg = StringFromFormat("Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)",
|
std::string msg = StringFromFormat("Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)",
|
||||||
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
|
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
|
||||||
s_record_width, s_record_height);
|
source_width, source_height);
|
||||||
|
|
||||||
OSD::AddMessage(msg, 2000);
|
OSD::AddMessage(msg, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bAVIDumping)
|
if (bAVIDumping)
|
||||||
{
|
{
|
||||||
if (frame_data.empty() || w != s_record_width || h != s_record_height)
|
if (frame_data.capacity() != 3 * source_width * source_height)
|
||||||
{
|
frame_data.resize(3 * source_width * source_height);
|
||||||
frame_data.resize(3 * s_record_width * s_record_height);
|
|
||||||
w = s_record_width;
|
|
||||||
h = s_record_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* screenshot_texture_map;
|
void* screenshot_texture_map;
|
||||||
D3D12_RANGE read_range = {0, dst_location.PlacedFootprint.Footprint.RowPitch * source_height};
|
D3D12_RANGE read_range = {0, dst_location.PlacedFootprint.Footprint.RowPitch * source_height};
|
||||||
@ -910,7 +899,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
|||||||
D3D12_RANGE write_range = {};
|
D3D12_RANGE write_range = {};
|
||||||
s_screenshot_texture->Unmap(0, &write_range);
|
s_screenshot_texture->Unmap(0, &write_range);
|
||||||
|
|
||||||
FlipImageData(&frame_data[0], w, h);
|
FlipImageData(&frame_data[0], source_width, source_height);
|
||||||
AVIDump::AddFrame(&frame_data[0], source_width, source_height);
|
AVIDump::AddFrame(&frame_data[0], source_width, source_height);
|
||||||
}
|
}
|
||||||
bLastFrameDumped = true;
|
bLastFrameDumped = true;
|
||||||
@ -920,7 +909,6 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
|||||||
if (bLastFrameDumped && bAVIDumping)
|
if (bLastFrameDumped && bAVIDumping)
|
||||||
{
|
{
|
||||||
std::vector<u8>().swap(frame_data);
|
std::vector<u8>().swap(frame_data);
|
||||||
w = h = 0;
|
|
||||||
|
|
||||||
AVIDump::Stop();
|
AVIDump::Stop();
|
||||||
bAVIDumping = false;
|
bAVIDumping = false;
|
||||||
|
@ -45,6 +45,10 @@ static int s_size;
|
|||||||
static u64 s_last_frame;
|
static u64 s_last_frame;
|
||||||
static bool s_start_dumping = false;
|
static bool s_start_dumping = false;
|
||||||
static u64 s_last_pts;
|
static u64 s_last_pts;
|
||||||
|
static int s_current_width;
|
||||||
|
static int s_current_height;
|
||||||
|
static int s_file_index = 0;
|
||||||
|
static AVIDump::DumpFormat s_current_format;
|
||||||
|
|
||||||
static void InitAVCodec()
|
static void InitAVCodec()
|
||||||
{
|
{
|
||||||
@ -63,8 +67,12 @@ bool AVIDump::Start(int w, int h, DumpFormat format)
|
|||||||
else
|
else
|
||||||
s_pix_fmt = AV_PIX_FMT_RGBA;
|
s_pix_fmt = AV_PIX_FMT_RGBA;
|
||||||
|
|
||||||
|
s_current_format = format;
|
||||||
|
|
||||||
s_width = w;
|
s_width = w;
|
||||||
s_height = h;
|
s_height = h;
|
||||||
|
s_current_width = w;
|
||||||
|
s_current_height = h;
|
||||||
|
|
||||||
s_last_frame = CoreTiming::GetTicks();
|
s_last_frame = CoreTiming::GetTicks();
|
||||||
s_last_pts = 0;
|
s_last_pts = 0;
|
||||||
@ -81,8 +89,11 @@ bool AVIDump::CreateFile()
|
|||||||
AVCodec* codec = nullptr;
|
AVCodec* codec = nullptr;
|
||||||
|
|
||||||
s_format_context = avformat_alloc_context();
|
s_format_context = avformat_alloc_context();
|
||||||
|
std::stringstream s_file_index_str;
|
||||||
|
s_file_index_str << s_file_index;
|
||||||
snprintf(s_format_context->filename, sizeof(s_format_context->filename), "%s",
|
snprintf(s_format_context->filename, sizeof(s_format_context->filename), "%s",
|
||||||
(File::GetUserPath(D_DUMPFRAMES_IDX) + "framedump0.avi").c_str());
|
(File::GetUserPath(D_DUMPFRAMES_IDX) + "framedump" + s_file_index_str.str() + ".avi")
|
||||||
|
.c_str());
|
||||||
File::CreateFullPath(s_format_context->filename);
|
File::CreateFullPath(s_format_context->filename);
|
||||||
|
|
||||||
// Ask to delete file
|
// Ask to delete file
|
||||||
@ -156,6 +167,7 @@ static void PreparePacket(AVPacket* pkt)
|
|||||||
|
|
||||||
void AVIDump::AddFrame(const u8* data, int width, int height)
|
void AVIDump::AddFrame(const u8* data, int width, int height)
|
||||||
{
|
{
|
||||||
|
CheckResolution(width, height);
|
||||||
avpicture_fill((AVPicture*)s_src_frame, const_cast<u8*>(data), s_pix_fmt, width, height);
|
avpicture_fill((AVPicture*)s_src_frame, const_cast<u8*>(data), s_pix_fmt, width, height);
|
||||||
|
|
||||||
// Convert image from {BGR24, RGBA} to desired pixel format, and scale to initial
|
// Convert image from {BGR24, RGBA} to desired pixel format, and scale to initial
|
||||||
@ -232,6 +244,7 @@ void AVIDump::Stop()
|
|||||||
{
|
{
|
||||||
av_write_trailer(s_format_context);
|
av_write_trailer(s_format_context);
|
||||||
CloseFile();
|
CloseFile();
|
||||||
|
s_file_index = 0;
|
||||||
NOTICE_LOG(VIDEO, "Stopping frame dump");
|
NOTICE_LOG(VIDEO, "Stopping frame dump");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,3 +286,16 @@ void AVIDump::DoState()
|
|||||||
{
|
{
|
||||||
s_last_frame = CoreTiming::GetTicks();
|
s_last_frame = CoreTiming::GetTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AVIDump::CheckResolution(int width, int height)
|
||||||
|
{
|
||||||
|
if (width != s_current_width || height != s_current_height)
|
||||||
|
{
|
||||||
|
int temp_file_index = s_file_index;
|
||||||
|
Stop();
|
||||||
|
s_file_index = temp_file_index + 1;
|
||||||
|
Start(width, height, s_current_format);
|
||||||
|
s_current_width = width;
|
||||||
|
s_current_height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -11,6 +11,7 @@ class AVIDump
|
|||||||
private:
|
private:
|
||||||
static bool CreateFile();
|
static bool CreateFile();
|
||||||
static void CloseFile();
|
static void CloseFile();
|
||||||
|
static void CheckResolution(int width, int height);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class DumpFormat
|
enum class DumpFormat
|
||||||
|
Loading…
Reference in New Issue
Block a user