5#include "interlacingpass.h"
21int InterlacingPass::roundToNearestPositiveOdd(
const double value)
24 int rounded = qRound((value - 1.0) / 2.0) * 2 + 1;
25 return qMax(1, rounded);
43InterlacingPass::InterlacingPass(
const double passCount)
45 const int roundedPassCount = roundToNearestPositiveOdd(passCount);
47 const int floorOfHalfCoundown = qFloor(roundedPassCount / 2.0);
48 const int baseSize = qRound(qPow(2, floorOfHalfCoundown));
50 countdown = roundedPassCount;
51 rectangleSize.setWidth(baseSize);
52 rectangleSize.setHeight(baseSize);
53 columnFrequency = baseSize;
55 lineFrequency = baseSize;
63void InterlacingPass::switchToNextPass()
71 const int floorOfHalfCoundown = qFloor(countdown / 2.0);
72 const int baseSize = qRound(qPow(2, floorOfHalfCoundown));
74 if (isOdd(countdown)) {
75 rectangleSize.setWidth(baseSize);
76 rectangleSize.setHeight(baseSize);
77 columnFrequency = baseSize;
79 lineFrequency = baseSize * 2;
80 lineOffset = baseSize;
82 const int halfBaseSize = baseSize / 2;
85 rectangleSize.setWidth(halfBaseSize);
86 rectangleSize.setHeight(baseSize);
87 columnFrequency = baseSize;
88 columnOffset = halfBaseSize;
89 lineFrequency = baseSize;
94static_assert(std::is_trivially_copyable_v<InterlacingPass>);
96static_assert(std::is_standard_layout_v<InterlacingPass>);
The namespace of this library.