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.
next
Julian Smith 2 years ago
parent 20898923e0
commit 13ca3cec56

@ -279,7 +279,7 @@ struct FfmpegEncoder
/* Resolution must be a multiple of two. */ /* Resolution must be a multiple of two. */
m_codec_context->width = width / 2 * 2; m_codec_context->width = width / 2 * 2;
m_codec_context->height = height / 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->gop_size = 12; /* emit one intra m_frame every twelve frames at most */
m_codec_context->pix_fmt = AV_PIX_FMT_YUV420P; m_codec_context->pix_fmt = AV_PIX_FMT_YUV420P;
/* Some formats want m_stream headers to be separate. */ /* Some formats want m_stream headers to be separate. */

@ -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 < 44) sglevel = SG_DEBUG;
if (level < 54) sglevel = SG_BULK; if (level < 54) sglevel = SG_BULK;
else sglevel = SG_BULK; else sglevel = SG_BULK;
char* message = nullptr; #ifdef _WIN32
vasprintf(&message, format, va); /* 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); SG_LOG(SG_VIEW, sglevel, "level=" << level << ": " << message);
free(message); #ifndef _WIN32
free(message);
#endif
} }
VideoEncoder::VideoEncoder( VideoEncoder::VideoEncoder(

Loading…
Cancel
Save