/* * Copyright (c) 2024, Gregory Bertilson * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include namespace Media { struct Subsampling { public: Subsampling(bool x, bool y) : m_x(x) , m_y(y) { } Subsampling() = default; bool x() const { return m_x; } bool y() const { return m_y; } static u32 subsampled_size(bool subsampled, u32 size) { u32 subsampled_as_int = static_cast(subsampled); return (size + subsampled_as_int) >> subsampled_as_int; } template Gfx::Size subsampled_size(Gfx::Size size) const { return { subsampled_size(x(), size.width()), subsampled_size(y(), size.height()) }; } private: bool m_x = false; bool m_y = false; }; }