mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 23:27:44 +00:00
LibVideo: Set CodingIndependentCodePoints in its member functions
This moves the setting of code points in CICP structs to member functions completely so that the code having to set these code points can be much cleaner.
This commit is contained in:
parent
074f771b59
commit
3720f66bb1
3 changed files with 42 additions and 27 deletions
|
@ -65,27 +65,26 @@ public:
|
|||
u64 bits_per_channel = 0;
|
||||
ColorRange range = ColorRange::Unspecified;
|
||||
|
||||
Video::ColorRange full_or_studio_range() const
|
||||
CodingIndependentCodePoints to_cicp() const
|
||||
{
|
||||
// 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.
|
||||
VERIFY(range == ColorRange::Full || range == ColorRange::Broadcast);
|
||||
if (range == ColorRange::Full)
|
||||
return Video::ColorRange::Full;
|
||||
return Video::ColorRange::Studio;
|
||||
}
|
||||
Video::ColorRange color_range;
|
||||
switch (range) {
|
||||
case ColorRange::Full:
|
||||
color_range = Video::ColorRange::Full;
|
||||
break;
|
||||
case ColorRange::Broadcast:
|
||||
color_range = Video::ColorRange::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;
|
||||
break;
|
||||
}
|
||||
|
||||
void replace_code_points_if_specified(CodingIndependentCodePoints& cicp) const
|
||||
{
|
||||
if (color_primaries != ColorPrimaries::Unspecified)
|
||||
cicp.set_color_primaries(color_primaries);
|
||||
if (transfer_characteristics != TransferCharacteristics::Unspecified)
|
||||
cicp.set_transfer_characteristics(transfer_characteristics);
|
||||
if (matrix_coefficients != MatrixCoefficients::Unspecified)
|
||||
cicp.set_matrix_coefficients(matrix_coefficients);
|
||||
if (range != ColorRange::Unspecified && range != ColorRange::UseCICP)
|
||||
cicp.set_color_range(full_or_studio_range());
|
||||
return { color_primaries, transfer_characteristics, matrix_coefficients, color_range };
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue