Skip to content

Commit

Permalink
expose new planar yuv formats, including limited/full range
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Oct 9, 2024
1 parent 08057ef commit 656f530
Show file tree
Hide file tree
Showing 31 changed files with 642 additions and 58 deletions.
5 changes: 5 additions & 0 deletions crates/build/re_types_builder/src/codegen/rust/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ fn generate_object_file(
code.push_str("#![allow(deprecated)]\n");
}

if obj.is_enum() {
// Needed for PixelFormat. Should we limit this via attribute to just that?
code.push_str("#![allow(non_camel_case_types)]\n");
}

code.push_str("\n\n");

code.push_str("use ::re_types_core::external::arrow2;\n");
Expand Down
65 changes: 63 additions & 2 deletions crates/store/re_types/definitions/rerun/datatypes/pixel_format.fbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace rerun.datatypes;

// TODO(andreas): Clarify relationship to color primaries.
// Suggestion: guides heuristic but doesn't specify it unless explicitely noted.

/// Specifieds a particular format of an [archetypes.Image].
///
/// Most images can be described by a [datatypes.ColorModel] and a [datatypes.ChannelDatatype],
Expand All @@ -24,13 +27,71 @@ enum PixelFormat: ubyte {
// this organization and subsequently reduce the chance we may find ourselves wanting to
// change the values in the future.

/// `NV12` (aka `Y_UV12`) is a YUV 4:2:0 chroma downsampled format with 12 bits per pixel and 8 bits per channel.
/// `Y_U_V24` is a YUV 4:4:4 fully planar YUV format without chroma downsampling, also known as `I444`.
///
/// This uses limited range YUV, i.e. Y is valid in [16, 235] and U/V [16, 240].
/// Outside of it is clamped.
///
/// First comes entire image in Y in one plane, followed by the U and V planes.
Y_U_V24_LimitedRange = 39,

/// `Y_U_V24` is a YUV 4:4:4 fully planar YUV format without chroma downsampling, also known as `I444`.
///
/// This uses full range YUV with all components ranging from 0 to 255
/// (as opposed to "limited range" YUV as used in NV12).
///
/// First comes entire image in Y in one plane, followed by the U and V planes.
Y_U_V24_FullRange = 40,

/// `Y_U_V16` is a YUV 4:2:2 fully planar YUV format without chroma downsampling, also known as `I422`.
///
/// This uses limited range YUV, i.e. Y is valid in [16, 235] and U/V [16, 240].
/// Outside of it is clamped.
///
/// First comes entire image in Y in one plane, followed by the U and V planes, which each only have half
/// the horizontal resolution of the Y plane.
Y_U_V16_LimitedRange = 49, // Ocean doesn't have a short codes for this

/// `Y_U_V16` is a YUV 4:2:2 fully planar YUV format without chroma downsampling, also known as `I422`.
///
/// This uses full range YUV with all components ranging from 0 to 255
/// (as opposed to "limited range" YUV as used in NV12).
///
/// First comes entire image in Y in one plane, followed by the U and V planes, which each only have half
/// the horizontal resolution of the Y plane.
Y_U_V16_FullRange = 50, // Ocean doesn't have a short codes for this

/// `Y_U_V12` is a YUV 4:2:0 fully planar YUV format without chroma downsampling, also known as `I420`.
///
/// This uses limited range YUV, i.e. Y is valid in [16, 235] and U/V [16, 240].
/// Outside of it is clamped.
///
/// First comes entire image in Y in one plane, followed by the U and V planes, which each only have half
/// the resolution of the Y plane.
Y_U_V12_LimitedRange = 20,

/// `Y_U_V12` is a YUV 4:2:0 fully planar YUV format without chroma downsampling, also known as `I420`.
///
/// This uses full range YUV with all components ranging from 0 to 255
/// (as opposed to "limited range" YUV as used in NV12).
///
/// First comes entire image in Y in one plane, followed by the U and V planes, which each only have half
/// the resolution of the Y plane.
Y_U_V12_FullRange = 44,

/// `NV12` (aka `Y_UV12`) is a YUV 4:2:0 chroma downsampled form at with 12 bits per pixel and 8 bits per channel.
///
/// This uses limited range YUV, i.e. Y is valid in [16, 235] and U/V [16, 240].
/// Outside of it is clamped.
///
/// First comes entire image in Y in one plane,
/// followed by a plane with interleaved lines ordered as U0, V0, U1, V1, etc.
NV12 = 26 (default), // _something_ has to be the default 🤷‍♀️

/// `YUY2` (aka `YUYV` or `YUYV16`), is a YUV 4:2:2 chroma downsampled format with 16 bits per pixel and 8 bits per channel.
/// `YUY2` (aka `YUYV`, `YUYV16` or `NV21`), is a YUV 4:2:2 chroma downsampled format with 16 bits per pixel and 8 bits per channel.
///
/// This uses limited range YUV, i.e. Y is valid in [16, 235] and U/V [16, 240].
/// Outside of it is clamped.
///
/// The order of the channels is Y0, U0, Y1, V0, all in the same plane.
YUY2 = 27,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/store/re_types/src/blueprint/components/corner2d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/store/re_types/src/blueprint/components/view_fit.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/store/re_types/src/components/aggregation_policy.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/store/re_types/src/components/colormap.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/store/re_types/src/components/fill_mode.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/store/re_types/src/components/marker_shape.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/store/re_types/src/components/transform_relation.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/store/re_types/src/datatypes/channel_datatype.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/store/re_types/src/datatypes/color_model.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 109 additions & 5 deletions crates/store/re_types/src/datatypes/pixel_format.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 656f530

Please sign in to comment.