Fix frame dump issues where frame dumping stops before next drawn frame
This commit is contained in:
parent
40f4308dc2
commit
df0f7657d0
|
@ -48,6 +48,9 @@ static int s_current_width;
|
||||||
static int s_current_height;
|
static int s_current_height;
|
||||||
static int s_file_index = 0;
|
static int s_file_index = 0;
|
||||||
static AVIDump::DumpFormat s_current_format;
|
static AVIDump::DumpFormat s_current_format;
|
||||||
|
static const u8* s_stored_frame_data;
|
||||||
|
static int s_stored_frame_width;
|
||||||
|
static int s_stored_frame_height;
|
||||||
|
|
||||||
static void InitAVCodec()
|
static void InitAVCodec()
|
||||||
{
|
{
|
||||||
|
@ -177,6 +180,8 @@ 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)
|
||||||
{
|
{
|
||||||
|
// Store current frame data in case frame dumping stops before next frame update
|
||||||
|
StoreFrameData(data, width, height);
|
||||||
CheckResolution(width, height);
|
CheckResolution(width, height);
|
||||||
s_src_frame->data[0] = const_cast<u8*>(data);
|
s_src_frame->data[0] = const_cast<u8*>(data);
|
||||||
s_src_frame->linesize[0] = width * s_bytes_per_pixel;
|
s_src_frame->linesize[0] = width * s_bytes_per_pixel;
|
||||||
|
@ -252,6 +257,8 @@ void AVIDump::AddFrame(const u8* data, int width, int height)
|
||||||
|
|
||||||
void AVIDump::Stop()
|
void AVIDump::Stop()
|
||||||
{
|
{
|
||||||
|
// Write the last stored frame just in case frame dumping stops before the next frame update
|
||||||
|
AddFrame(s_stored_frame_data, s_stored_frame_width, s_stored_frame_height);
|
||||||
av_write_trailer(s_format_context);
|
av_write_trailer(s_format_context);
|
||||||
CloseFile();
|
CloseFile();
|
||||||
s_file_index = 0;
|
s_file_index = 0;
|
||||||
|
@ -311,3 +318,10 @@ void AVIDump::CheckResolution(int width, int height)
|
||||||
s_current_height = height;
|
s_current_height = height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AVIDump::StoreFrameData(const u8* data, int width, int height)
|
||||||
|
{
|
||||||
|
s_stored_frame_data = data;
|
||||||
|
s_stored_frame_width = width;
|
||||||
|
s_stored_frame_height = height;
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ private:
|
||||||
static bool CreateFile();
|
static bool CreateFile();
|
||||||
static void CloseFile();
|
static void CloseFile();
|
||||||
static void CheckResolution(int width, int height);
|
static void CheckResolution(int width, int height);
|
||||||
|
static void StoreFrameData(const u8* data, int width, int height);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class DumpFormat
|
enum class DumpFormat
|
||||||
|
|
Loading…
Reference in New Issue