Skip to content

Commit 8375aa1

Browse files
committed
GameRecorder: Scaling now is trying to set the max possible video size
1 parent ddf2513 commit 8375aa1

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

Source/BetaHubBugReporter/Private/BH_GameRecorder.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,25 +399,15 @@ void UBH_GameRecorder::OnBackBufferResized(const FTexture2DRHIRef& BackBuffer)
399399
int32 OriginalWidth = ViewportWidth = OriginalSize.X;
400400
int32 OriginalHeight = ViewportHeight = OriginalSize.Y;
401401

402-
// Calculate scaling factor while maintaining aspect ratio
402+
// Calculate scaling factor based on the maximum dimension
403403
float WidthRatio = static_cast<float>(OriginalWidth) / MaxVideoWidth;
404404
float HeightRatio = static_cast<float>(OriginalHeight) / MaxVideoHeight;
405405
float ScalingFactor = FMath::Max(WidthRatio, HeightRatio);
406406

407407
if (ScalingFactor > 1.0f)
408408
{
409-
// Scale down by powers of two
410-
int32 ScaledWidth = OriginalWidth;
411-
int32 ScaledHeight = OriginalHeight;
412-
413-
while (ScaledWidth >= MaxVideoWidth || ScaledHeight >= MaxVideoHeight)
414-
{
415-
ScaledWidth /= 2;
416-
ScaledHeight /= 2;
417-
}
418-
419-
FrameWidth = ScaledWidth;
420-
FrameHeight = ScaledHeight;
409+
FrameWidth = FMath::RoundToInt(OriginalWidth / ScalingFactor);
410+
FrameHeight = FMath::RoundToInt(OriginalHeight / ScalingFactor);
421411

422412
UE_LOG(LogBetaHub, Log, TEXT("Resizing frame to %dx%d"), FrameWidth, FrameHeight);
423413
}

0 commit comments

Comments
 (0)