From 9853ca927890dffb0798752800f33dc61ed618dd Mon Sep 17 00:00:00 2001 From: Crend King <975235+CrendKing@users.noreply.github.com> Date: Sat, 30 Sep 2023 19:57:26 -0700 Subject: [PATCH] Fix bug overflowing dwPictAspectRatioX --- filter_common/src/frameserver_common.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/filter_common/src/frameserver_common.cpp b/filter_common/src/frameserver_common.cpp index e896360..a2db5e0 100644 --- a/filter_common/src/frameserver_common.cpp +++ b/filter_common/src/frameserver_common.cpp @@ -36,9 +36,11 @@ auto AuxFrameServer::GenerateMediaType(const Format::PixelFormat &pixelFormat, c // assuming the pixel aspect ratio remains the same, new DAR = PAR / new (script) SAR const auto &sourceVideoInfo = FrameServerCommon::GetInstance()._sourceVideoInfo; if (_scriptVideoInfo.width != sourceVideoInfo.width || _scriptVideoInfo.height != sourceVideoInfo.height) { - newVih2->dwPictAspectRatioX = newVih2->dwPictAspectRatioX * sourceVideoInfo.height * _scriptVideoInfo.width; - newVih2->dwPictAspectRatioY = newVih2->dwPictAspectRatioY * sourceVideoInfo.width * _scriptVideoInfo.height; - CoprimeIntegers(newVih2->dwPictAspectRatioX, newVih2->dwPictAspectRatioY); + unsigned long long darX = static_cast(newVih2->dwPictAspectRatioX) * sourceVideoInfo.height * _scriptVideoInfo.width; + unsigned long long darY = static_cast(newVih2->dwPictAspectRatioY) * sourceVideoInfo.width * _scriptVideoInfo.height; + CoprimeIntegers(darX, darY); + newVih2->dwPictAspectRatioX = static_cast(darX); + newVih2->dwPictAspectRatioY = static_cast(darY); } } else { newBmi = &newVih->bmiHeader;