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

Reworking YCgCo -> RGB #60

Merged
merged 3 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ The following planar formats are used for HDR content, with either **10-bit** or
### Format Breakdown:

- **I**: Represents the color space (as defined above), and these formats use **3 planes**: Y (luminance), U (chrominance), and V (chrominance).
- **ICgC**: Represents the color space (as defined above), and these formats use **3 planes**: Y (luminance), Cg (chrominance), and Co (chrominance).
- **P**: A **biplanar format** (similar to **NV12**), but with **16-bit precision**, where the valid bits are stored in the high bits. This format has:
- A **Y plane**
- A **UV plane** (with U and V interleaved)
Expand Down
34 changes: 30 additions & 4 deletions app/benches/yuv8/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ use yuv_sys::{
use yuvutils_rs::{
gbr_to_rgba, rgb_to_gbr, rgb_to_yuv400, rgb_to_yuv420, rgb_to_yuv422, rgb_to_yuv444,
rgb_to_yuv_nv12, rgb_to_yuv_nv16, rgba_to_yuv420, rgba_to_yuv422, rgba_to_yuv444,
rgba_to_yuv_nv12, yuv400_to_rgba, yuv420_to_rgb, yuv420_to_rgba, yuv422_to_rgba,
yuv444_to_rgba, yuv_nv12_to_rgb, yuv_nv12_to_rgba, yuv_nv16_to_rgb, YuvBiPlanarImageMut,
YuvChromaSubsampling, YuvConversionMode, YuvGrayImageMut, YuvPlanarImageMut, YuvRange,
YuvStandardMatrix,
rgba_to_yuv_nv12, ycgco420_to_rgba, ycgco444_to_rgba, yuv400_to_rgba, yuv420_to_rgb,
yuv420_to_rgba, yuv422_to_rgba, yuv444_to_rgba, yuv_nv12_to_rgb, yuv_nv12_to_rgba,
yuv_nv16_to_rgb, YuvBiPlanarImageMut, YuvChromaSubsampling, YuvConversionMode, YuvGrayImageMut,
YuvPlanarImageMut, YuvRange, YuvStandardMatrix,
};

pub fn criterion_benchmark(c: &mut Criterion) {
Expand Down Expand Up @@ -675,6 +675,19 @@ pub fn criterion_benchmark(c: &mut Criterion) {
})
});

c.bench_function("yuvutils YCgCo 4:2:0 -> RGBA", |b| {
let mut rgb_bytes = vec![0u8; dimensions.0 as usize * 4 * dimensions.1 as usize];
b.iter(|| {
ycgco420_to_rgba(
&fixed_planar,
&mut rgb_bytes,
dimensions.0 * 4u32,
YuvRange::Full,
)
.unwrap();
})
});

c.bench_function("yuvutils YUV 4:2:0 -> RGBA", |b| {
let mut rgb_bytes = vec![0u8; dimensions.0 as usize * 4 * dimensions.1 as usize];
b.iter(|| {
Expand Down Expand Up @@ -769,6 +782,19 @@ pub fn criterion_benchmark(c: &mut Criterion) {

let fixed_planar444 = planar_image444.to_fixed();

c.bench_function("yuvutils YCgCo 4:4:4 -> RGBA", |b| {
let mut rgb_bytes = vec![0u8; dimensions.0 as usize * 4 * dimensions.1 as usize];
b.iter(|| {
ycgco444_to_rgba(
&fixed_planar444,
&mut rgb_bytes,
dimensions.0 * 4u32,
YuvRange::Full,
)
.unwrap();
})
});

c.bench_function("yuvutils YUV 4:4:4 -> RGBA", |b| {
let mut rgb_bytes = vec![0u8; dimensions.0 as usize * 4 * dimensions.1 as usize];
b.iter(|| {
Expand Down
14 changes: 0 additions & 14 deletions src/avx2/avx2_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,20 +1191,6 @@ pub(crate) unsafe fn _mm256_expand_rgb_to_rgba(
(v0, v1, v2, v3)
}

#[inline(always)]
pub(crate) unsafe fn sse_interleave_even(x: __m128i) -> __m128i {
#[rustfmt::skip]
let shuffle = _mm_setr_epi8(0, 0, 2, 2, 4, 4, 6, 6,
8, 8, 10, 10, 12, 12, 14, 14);
_mm_shuffle_epi8(x, shuffle)
}

#[inline(always)]
pub(crate) unsafe fn sse_interleave_odd(x: __m128i) -> __m128i {
let shuffle = _mm_setr_epi8(1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15);
_mm_shuffle_epi8(x, shuffle)
}

#[inline(always)]
pub(crate) unsafe fn _avx_from_msb_epi16<const BIT_DEPTH: usize>(a: __m128i) -> __m128i {
if BIT_DEPTH == 10 {
Expand Down
2 changes: 0 additions & 2 deletions src/avx2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ mod rgba_to_yuv_fast420;
mod shuffle;
mod y_to_rgba;
mod y_to_rgba_alpha;
mod ycgco_to_rgba_alpha;
mod yuv_nv_to_rgba;
mod yuv_nv_to_rgba420;
#[cfg(feature = "professional_mode")]
Expand Down Expand Up @@ -119,7 +118,6 @@ pub(crate) use rgba_to_yuv_fast420::avx2_rgba_to_yuv_dot_rgba420;
pub(crate) use shuffle::{ShuffleConverterAvx2, ShuffleQTableConverterAvx2};
pub(crate) use y_to_rgba::avx2_y_to_rgba_row;
pub(crate) use y_to_rgba_alpha::avx2_y_to_rgba_alpha_row;
pub(crate) use ycgco_to_rgba_alpha::avx2_ycgco_to_rgba_alpha;
pub(crate) use yuv_nv_to_rgba::avx2_yuv_nv_to_rgba_row;
pub(crate) use yuv_nv_to_rgba420::avx2_yuv_nv_to_rgba_row420;
#[cfg(feature = "professional_mode")]
Expand Down
251 changes: 0 additions & 251 deletions src/avx2/ycgco_to_rgba_alpha.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/avx512bw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ mod rgba_to_yuv_fast;
#[cfg(feature = "fast_mode")]
mod rgba_to_yuv_fast420;
mod y_to_rgb;
mod ycgco_to_rgba_alpha;
mod yuv_nv_to_rgba;
mod yuv_nv_to_rgba420;
mod yuv_nv_to_rgba422;
Expand Down Expand Up @@ -70,7 +69,6 @@ pub(crate) use rgba_to_yuv_fast420::{
avx512_rgba_to_yuv_dot_rgba420, avx512_rgba_to_yuv_dot_rgba420_vbmi,
};
pub(crate) use y_to_rgb::avx512_y_to_rgb_row;
pub(crate) use ycgco_to_rgba_alpha::avx512_ycgco_to_rgba_alpha;
pub(crate) use yuv_nv_to_rgba::avx512_yuv_nv_to_rgba;
pub(crate) use yuv_nv_to_rgba420::avx512_yuv_nv_to_rgba420;
pub(crate) use yuv_nv_to_rgba422::avx512_yuv_nv_to_rgba422;
Expand Down
Loading