diff options
| author | Glenn Rice <glennricster@gmail.com> | 2011-03-25 18:12:40 +0000 |
|---|---|---|
| committer | Glenn Rice <glennricster@gmail.com> | 2011-03-25 18:12:40 +0000 |
| commit | c99c247ed598ff902221bf90b0972350f253bf4a (patch) | |
| tree | b75af17c0fb2436384c61627ccd4d19b33df8bd0 /Source/Core/VideoCommon | |
| parent | df9f614b58f373ffc2b03bb1039274528ba3a15d (diff) | |
When using the "Start Renderer in Fullscreen" option, really start in fullscreen. In other words this now switches to fullscreen before the renderer is initiated instead of after. This is a partial fix for issue 4316.
Also, if the render window size changes while frame dumping, scale the resulting video to prevent clipping on linux. This is a complete fix for issue 4316 on linux. I don't know how to implement this on windows though.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7412 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/Src/AVIDump.cpp | 40 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/AVIDump.h | 2 |
2 files changed, 17 insertions, 25 deletions
diff --git a/Source/Core/VideoCommon/Src/AVIDump.cpp b/Source/Core/VideoCommon/Src/AVIDump.cpp index ac075ecce5..cfd34e5cdb 100644 --- a/Source/Core/VideoCommon/Src/AVIDump.cpp +++ b/Source/Core/VideoCommon/Src/AVIDump.cpp @@ -214,7 +214,6 @@ AVStream *s_Stream = NULL; AVFrame *s_BGRFrame = NULL, *s_YUVFrame = NULL; uint8_t *s_YUVBuffer = NULL; uint8_t *s_OutBuffer = NULL; -struct SwsContext *s_SwsContext = NULL; int s_width; int s_height; int s_size; @@ -254,19 +253,15 @@ bool AVIDump::CreateFile() return false; } - if (g_Config.bUseFFV1) - { - s_FormatContext->oformat->video_codec = CODEC_ID_FFV1; - } - - s_Stream->codec->codec_id = s_FormatContext->oformat->video_codec; + s_Stream->codec->codec_id = + g_Config.bUseFFV1 ? CODEC_ID_FFV1 : s_FormatContext->oformat->video_codec; s_Stream->codec->codec_type = AVMEDIA_TYPE_VIDEO; s_Stream->codec->bit_rate = 400000; s_Stream->codec->width = s_width; s_Stream->codec->height = s_height; s_Stream->codec->time_base = (AVRational){1, VideoInterface::TargetRefreshRate}; s_Stream->codec->gop_size = 12; - s_Stream->codec->pix_fmt = (g_Config.bUseFFV1) ? PIX_FMT_BGRA : PIX_FMT_YUV420P; + s_Stream->codec->pix_fmt = g_Config.bUseFFV1 ? PIX_FMT_BGRA : PIX_FMT_YUV420P; av_set_parameters(s_FormatContext, NULL); @@ -277,13 +272,6 @@ bool AVIDump::CreateFile() return false; } - if(!(s_SwsContext = sws_getContext(s_width, s_height, PIX_FMT_BGR24, s_width, s_height, - s_Stream->codec->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL))) - { - CloseFile(); - return false; - } - s_BGRFrame = avcodec_alloc_frame(); s_YUVFrame = avcodec_alloc_frame(); @@ -307,13 +295,20 @@ bool AVIDump::CreateFile() return true; } -void AVIDump::AddFrame(uint8_t *data) +void AVIDump::AddFrame(uint8_t *data, int width, int height) { - avpicture_fill((AVPicture *)s_BGRFrame, data, PIX_FMT_BGR24, s_width, s_height); + avpicture_fill((AVPicture *)s_BGRFrame, data, PIX_FMT_BGR24, width, height); - // Convert image from BGR24 to YUV420P - sws_scale(s_SwsContext, s_BGRFrame->data, s_BGRFrame->linesize, 0, - s_height, s_YUVFrame->data, s_YUVFrame->linesize); + // Convert image from BGR24 to desired pixel format, and scale to initial + // width and height + struct SwsContext *s_SwsContext; + if ((s_SwsContext = sws_getContext(width, height, PIX_FMT_BGR24, s_width, s_height, + s_Stream->codec->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL))) + { + sws_scale(s_SwsContext, s_BGRFrame->data, s_BGRFrame->linesize, 0, + height, s_YUVFrame->data, s_YUVFrame->linesize); + sws_freeContext(s_SwsContext); + } // Encode and write the image int outsize = avcodec_encode_video(s_Stream->codec, s_OutBuffer, s_size, s_YUVFrame); @@ -372,15 +367,12 @@ void AVIDump::CloseFile() av_free(s_YUVFrame); s_YUVFrame = NULL; - if (s_SwsContext) - sws_freeContext(s_SwsContext); - s_SwsContext = NULL; - if (s_FormatContext) { if (s_FormatContext->pb) url_fclose(s_FormatContext->pb); av_free(s_FormatContext); + s_FormatContext = NULL; } } diff --git a/Source/Core/VideoCommon/Src/AVIDump.h b/Source/Core/VideoCommon/Src/AVIDump.h index ae5f37579a..e74df05db4 100644 --- a/Source/Core/VideoCommon/Src/AVIDump.h +++ b/Source/Core/VideoCommon/Src/AVIDump.h @@ -39,7 +39,7 @@ class AVIDump static void AddFrame(char *data); #else static bool Start(int w, int h); - static void AddFrame(uint8_t *data); + static void AddFrame(uint8_t *data, int width, int height); #endif static void Stop(); }; |
