Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New planar pixel formats: Y_U_V24/Y_U_V16/Y_U_V12 - _LimitedRange/FullRange #7666

Merged
merged 16 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _deps
# Python build artifacts:
__pycache__
*.pyc
*.pyd
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this didn't come up before, but while working on this I accidentally pushed a .pyd file which wasn't on the ignore list. better safe than sorry (again), so I added this here

*.so
**/.pytest_cache

Expand Down
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
77 changes: 75 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,9 @@
namespace rerun.datatypes;

// TODO(andreas): Clarify relationship to color primaries. Right now there's some hardcoded differences between formats.
// See `image_to_gpu.rs`
// Suggestion: guides heuristic but doesn't specify it unless 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 +28,82 @@ 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 expected to be within [16, 235] and U/V within [16, 240].
///
/// First comes entire image in Y in one plane, followed by the U and V planes.
Y_U_V24_LimitedRange = 39,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ordering in respect to the numbers in here is rather dubious
I tried to order this logically rather than by enum numbers (which are derived from Ocean). But that makes it hard for the codes beyond Ocean :/


/// `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 e.g. 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 expected to be within [16, 235] and U/V within [16, 240].
///
/// 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 e.g. 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 expected to be within [16, 235] and U/V within [16, 240].
///
/// 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 e.g. 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,

/// Monochrome Y plane only, essentially a YUV 4:0:0 planar format.
///
/// Also known as just "gray".
///
/// This uses limited range YUV, i.e. Y is expected to be within [16, 235].
/// If not for this range limitation/remapping, this is almost identical to 8bit luminace/grayscale (see [datatypes.ColorModel]).
Y8_LimitedRange = 41,

/// Monochrome Y plane only, essentially a YUV 4:0:0 planar format.
///
/// Also known as just "gray". This is virtually identical to a 8bit luminance/grayscale (see [datatypes.ColorModel]).
///
/// This uses entire range YUV, i.e. Y is expected to be within [0, 255].
/// (as opposed to "limited range" YUV as used e.g. in NV12).
Y8_FullRange = 30,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point it would be nice if LimitedRange/FullRange was its own component. Maybe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... maybe. See PR description 😄


/// `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 expected to be within [16, 235] and U/V within [16, 240].
///
/// 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 expected to be within [16, 235] and U/V within [16, 240].
///
/// 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.

Loading
Loading