diff options
author | Nico Weber <thakis@chromium.org> | 2023-02-08 14:16:37 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-09 16:35:08 +0000 |
commit | 89b98830f6ddcfe87f6d1b41244ca910be108401 (patch) | |
tree | 75aab65d4a5f2bb438cc32b13dbedb23882036cc /Userland/Libraries/LibVideo | |
parent | 49474d8718e0a95f43631501ae17e21612d1aed1 (diff) | |
download | serenity-89b98830f6ddcfe87f6d1b41244ca910be108401.zip |
LibVideo: Rename "ColorRange" to "VideoFullRangeFlag"
That matches the terminology used in ITU-T Rec. H.273,
PNG's cICP chunk, and the ICC cicpTag.
Also change the enum values to match the values in the spec --
0 means "not full range" and 1 means "full range".
(For now, keep the "Unspecified" entry around, and give it value 2.
This value is not in the spec.)
No intended behavior change.
Diffstat (limited to 'Userland/Libraries/LibVideo')
7 files changed, 29 insertions, 29 deletions
diff --git a/Userland/Libraries/LibVideo/Color/CodingIndependentCodePoints.h b/Userland/Libraries/LibVideo/Color/CodingIndependentCodePoints.h index 5d42ace027..a4de5049a9 100644 --- a/Userland/Libraries/LibVideo/Color/CodingIndependentCodePoints.h +++ b/Userland/Libraries/LibVideo/Color/CodingIndependentCodePoints.h @@ -72,20 +72,20 @@ enum class MatrixCoefficients : u8 { // All other values are Reserved for later use. }; -enum class ColorRange : u8 { - Unspecified, - Studio, // Y range 16..235, UV range 16..240 - Full, // 0..255 +enum class VideoFullRangeFlag : u8 { + Studio = 0, // Y range 16..235, UV range 16..240 + Full = 1, // 0..255 + Unspecified = 2, // Not part of the spec, serenity-specific addition for convenience. }; // https://en.wikipedia.org/wiki/Coding-independent_code_points struct CodingIndependentCodePoints { public: - constexpr CodingIndependentCodePoints(ColorPrimaries color_primaries, TransferCharacteristics transfer_characteristics, MatrixCoefficients matrix_coefficients, ColorRange color_range) + constexpr CodingIndependentCodePoints(ColorPrimaries color_primaries, TransferCharacteristics transfer_characteristics, MatrixCoefficients matrix_coefficients, VideoFullRangeFlag video_full_range_flag) : m_color_primaries(color_primaries) , m_transfer_characteristics(transfer_characteristics) , m_matrix_coefficients(matrix_coefficients) - , m_color_range(color_range) + , m_video_full_range_flag(video_full_range_flag) { } @@ -95,8 +95,8 @@ public: constexpr void set_transfer_characteristics(TransferCharacteristics value) { m_transfer_characteristics = value; } constexpr MatrixCoefficients matrix_coefficients() const { return m_matrix_coefficients; } constexpr void set_matrix_coefficients(MatrixCoefficients value) { m_matrix_coefficients = value; } - constexpr ColorRange color_range() const { return m_color_range; } - constexpr void set_color_range(ColorRange value) { m_color_range = value; } + constexpr VideoFullRangeFlag video_full_range_flag() const { return m_video_full_range_flag; } + constexpr void set_video_full_range_flag(VideoFullRangeFlag value) { m_video_full_range_flag = value; } constexpr void default_code_points_if_unspecified(CodingIndependentCodePoints cicp) { @@ -106,8 +106,8 @@ public: set_transfer_characteristics(cicp.transfer_characteristics()); if (matrix_coefficients() == MatrixCoefficients::Unspecified) set_matrix_coefficients(cicp.matrix_coefficients()); - if (color_range() == ColorRange::Unspecified) - set_color_range(cicp.color_range()); + if (video_full_range_flag() == VideoFullRangeFlag::Unspecified) + set_video_full_range_flag(cicp.video_full_range_flag()); } constexpr void adopt_specified_values(CodingIndependentCodePoints cicp) @@ -118,15 +118,15 @@ public: set_transfer_characteristics(cicp.transfer_characteristics()); if (cicp.matrix_coefficients() != MatrixCoefficients::Unspecified) set_matrix_coefficients(cicp.matrix_coefficients()); - if (cicp.color_range() != ColorRange::Unspecified) - set_color_range(cicp.color_range()); + if (cicp.video_full_range_flag() != VideoFullRangeFlag::Unspecified) + set_video_full_range_flag(cicp.video_full_range_flag()); } private: ColorPrimaries m_color_primaries; TransferCharacteristics m_transfer_characteristics; MatrixCoefficients m_matrix_coefficients; - ColorRange m_color_range; + VideoFullRangeFlag m_video_full_range_flag; }; constexpr StringView color_primaries_to_string(ColorPrimaries color_primaries) diff --git a/Userland/Libraries/LibVideo/Color/ColorConverter.cpp b/Userland/Libraries/LibVideo/Color/ColorConverter.cpp index b5c43a4afa..2420275f26 100644 --- a/Userland/Libraries/LibVideo/Color/ColorConverter.cpp +++ b/Userland/Libraries/LibVideo/Color/ColorConverter.cpp @@ -87,7 +87,7 @@ DecoderErrorOr<ColorConverter> ColorConverter::create(u8 bit_depth, CodingIndepe float y_max; float uv_min; float uv_max; - if (cicp.color_range() == ColorRange::Studio) { + if (cicp.video_full_range_flag() == VideoFullRangeFlag::Studio) { y_min = 16.0f / 255.0f; y_max = 235.0f / 255.0f; uv_min = y_min; diff --git a/Userland/Libraries/LibVideo/Containers/Matroska/Document.h b/Userland/Libraries/LibVideo/Containers/Matroska/Document.h index 325cb32e12..29571e42f2 100644 --- a/Userland/Libraries/LibVideo/Containers/Matroska/Document.h +++ b/Userland/Libraries/LibVideo/Containers/Matroska/Document.h @@ -77,24 +77,24 @@ public: CodingIndependentCodePoints to_cicp() const { - Video::ColorRange color_range; + Video::VideoFullRangeFlag video_full_range_flag; switch (range) { case ColorRange::Full: - color_range = Video::ColorRange::Full; + video_full_range_flag = Video::VideoFullRangeFlag::Full; break; case ColorRange::Broadcast: - color_range = Video::ColorRange::Studio; + video_full_range_flag = Video::VideoFullRangeFlag::Studio; break; case ColorRange::Unspecified: case ColorRange::UseCICP: // FIXME: Figure out what UseCICP should do here. Matroska specification did not // seem to explain in the 'colour' section. When this is fixed, change // replace_code_points_if_specified to match. - color_range = Video::ColorRange::Unspecified; + video_full_range_flag = Video::VideoFullRangeFlag::Unspecified; break; } - return { color_primaries, transfer_characteristics, matrix_coefficients, color_range }; + return { color_primaries, transfer_characteristics, matrix_coefficients, video_full_range_flag }; } }; diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp index 5a49f32bd2..296c78bfe6 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.cpp +++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp @@ -190,7 +190,7 @@ bool PlaybackManager::decode_and_queue_one_sample() auto& cicp = decoded_frame->cicp(); cicp.adopt_specified_values(frame_sample->container_cicp()); - cicp.default_code_points_if_unspecified({ ColorPrimaries::BT709, TransferCharacteristics::BT709, MatrixCoefficients::BT709, ColorRange::Studio }); + cicp.default_code_points_if_unspecified({ ColorPrimaries::BT709, TransferCharacteristics::BT709, MatrixCoefficients::BT709, VideoFullRangeFlag::Studio }); // BT.601, BT.709 and BT.2020 have a similar transfer function to sRGB, so other applications // (Chromium, VLC) forgo transfer characteristics conversion. We will emulate that behavior by diff --git a/Userland/Libraries/LibVideo/VP9/ContextStorage.h b/Userland/Libraries/LibVideo/VP9/ContextStorage.h index 356defc932..29e17f4071 100644 --- a/Userland/Libraries/LibVideo/VP9/ContextStorage.h +++ b/Userland/Libraries/LibVideo/VP9/ContextStorage.h @@ -241,7 +241,7 @@ struct SegmentFeature { struct ColorConfig { u8 bit_depth { 8 }; ColorSpace color_space { ColorSpace::Bt601 }; - ColorRange color_range { ColorRange::Studio }; + VideoFullRangeFlag color_range { VideoFullRangeFlag::Studio }; bool subsampling_x { true }; bool subsampling_y { true }; }; diff --git a/Userland/Libraries/LibVideo/VP9/Parser.cpp b/Userland/Libraries/LibVideo/VP9/Parser.cpp index d8ba61be79..c7e7443237 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.cpp +++ b/Userland/Libraries/LibVideo/VP9/Parser.cpp @@ -143,11 +143,11 @@ DecoderErrorOr<void> Parser::refresh_probs(FrameContext const& frame_context) return {}; } -DecoderErrorOr<ColorRange> Parser::read_color_range() +DecoderErrorOr<VideoFullRangeFlag> Parser::read_video_full_range_flag() { if (TRY_READ(m_bit_stream->read_bit())) - return ColorRange::Full; - return ColorRange::Studio; + return VideoFullRangeFlag::Full; + return VideoFullRangeFlag::Studio; } /* (6.2) */ @@ -303,11 +303,11 @@ DecoderErrorOr<ColorConfig> Parser::parse_color_config(FrameContext const& frame auto color_space = static_cast<ColorSpace>(TRY_READ(m_bit_stream->read_bits(3))); VERIFY(color_space <= ColorSpace::RGB); - ColorRange color_range; + VideoFullRangeFlag video_full_range_flag; bool subsampling_x, subsampling_y; if (color_space != ColorSpace::RGB) { - color_range = TRY(read_color_range()); + video_full_range_flag = TRY(read_video_full_range_flag()); if (frame_context.profile == 1 || frame_context.profile == 3) { subsampling_x = TRY_READ(m_bit_stream->read_bit()); subsampling_y = TRY_READ(m_bit_stream->read_bit()); @@ -318,7 +318,7 @@ DecoderErrorOr<ColorConfig> Parser::parse_color_config(FrameContext const& frame subsampling_y = true; } } else { - color_range = ColorRange::Full; + video_full_range_flag = VideoFullRangeFlag::Full; if (frame_context.profile == 1 || frame_context.profile == 3) { subsampling_x = false; subsampling_y = false; @@ -330,7 +330,7 @@ DecoderErrorOr<ColorConfig> Parser::parse_color_config(FrameContext const& frame } } - return ColorConfig { bit_depth, color_space, color_range, subsampling_x, subsampling_y }; + return ColorConfig { bit_depth, color_space, video_full_range_flag, subsampling_x, subsampling_y }; } DecoderErrorOr<Gfx::Size<u32>> Parser::parse_frame_size() diff --git a/Userland/Libraries/LibVideo/VP9/Parser.h b/Userland/Libraries/LibVideo/VP9/Parser.h index eab988d2ac..3a9f0cdcd2 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.h +++ b/Userland/Libraries/LibVideo/VP9/Parser.h @@ -45,7 +45,7 @@ private: * See also section 5.26. */ Vector<size_t> parse_superframe_sizes(ReadonlyBytes); - DecoderErrorOr<ColorRange> read_color_range(); + DecoderErrorOr<VideoFullRangeFlag> read_video_full_range_flag(); /* (6.1) Frame Syntax */ bool trailing_bits(); |