Skip to content

Commit

Permalink
av1 decoder colorspace from dav1d (#2200)
Browse files Browse the repository at this point in the history
  • Loading branch information
kozakura913 committed Apr 11, 2024
1 parent 1c95b86 commit dff0e20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -41,7 +41,7 @@ num-traits = { version = "0.2.0" }

# Optional dependencies
color_quant = { version = "1.1", optional = true }
dav1d = { version = "0.10.2", optional = true }
dav1d = { version = "0.10.3", optional = true }
dcv-color-primitives = { version = "0.6.1", optional = true }
exr = { version = "1.5.0", optional = true }
gif = { version = "0.13", optional = true }
Expand Down
13 changes: 12 additions & 1 deletion src/codecs/avif/decoder.rs
Expand Up @@ -109,9 +109,20 @@ impl<R: Read> ImageDecoder for AvifDecoder<R> {
PixelLayout::I422 => dcp::PixelFormat::I422,
PixelLayout::I444 => dcp::PixelFormat::I444,
};
let src_color_space = match (self.picture.color_primaries(), self.picture.color_range())
{
(dav1d::pixel::ColorPrimaries::BT709, dav1d::pixel::YUVRange::Full) => {
dcp::ColorSpace::Bt709FR
}
(dav1d::pixel::ColorPrimaries::BT709, dav1d::pixel::YUVRange::Limited) => {
dcp::ColorSpace::Bt709
}
(_, dav1d::pixel::YUVRange::Full) => dcp::ColorSpace::Bt601FR,
(_, dav1d::pixel::YUVRange::Limited) => dcp::ColorSpace::Bt601,
};
let src_format = dcp::ImageFormat {
pixel_format,
color_space: dcp::ColorSpace::Bt601,
color_space: src_color_space,
num_planes: 3,
};
let dst_format = dcp::ImageFormat {
Expand Down

0 comments on commit dff0e20

Please sign in to comment.