simgear/screen/video-encoder*: build fixes for ffmpeg code on Windows.

simgear/screen/video-encoder-internal.hxx:
    Fixed initialisation of AVRational instance to work on Windows.
simgear/screen/video-encoder.cxx:
    av_log(): vasprintf() is not available on Windows so use fixed buffer on
    Windows.
This commit is contained in:
Julian Smith 2022-05-04 17:51:50 +01:00
parent 20898923e0
commit 13ca3cec56
2 changed files with 12 additions and 4 deletions

View File

@ -279,7 +279,7 @@ struct FfmpegEncoder
/* Resolution must be a multiple of two. */
m_codec_context->width = width / 2 * 2;
m_codec_context->height = height / 2 * 2;
m_codec_context->time_base = (AVRational){ 1, 60 };
m_codec_context->time_base = AVRational{ 1, 60 };
//m_codec_context->gop_size = 12; /* emit one intra m_frame every twelve frames at most */
m_codec_context->pix_fmt = AV_PIX_FMT_YUV420P;
/* Some formats want m_stream headers to be separate. */

View File

@ -170,10 +170,18 @@ static void av_log(void* /*avcl*/, int level, const char* format, va_list va)
if (level < 44) sglevel = SG_DEBUG;
if (level < 54) sglevel = SG_BULK;
else sglevel = SG_BULK;
#ifdef _WIN32
/* Windows does not have vasprintf(). */
char message[200];
vsnprintf(message, sizeof(message), format, va);
#else
char* message = nullptr;
vasprintf(&message, format, va);
#endif
SG_LOG(SG_VIEW, sglevel, "level=" << level << ": " << message);
#ifndef _WIN32
free(message);
#endif
}
VideoEncoder::VideoEncoder(