hpvcd
June 7, 2026 ยท View on GitHub
A tiny HEVC decoder in Rust.
Example
fn main() {
let decoded = hpvcd::decode_heic(&bytes).unwrap();
let diff = decoded.bit_depth.bits() - 8;
let img = DynamicImage::ImageRgb8(
RgbImage::from_vec(
decoded.width,
decoded.height,
match decoded.pixels {
ImageBuffer::Luma8(luma) => luma.iter().flat_map(|&x| [x, x, x]).collect(),
ImageBuffer::Luma16(luma) => luma
.iter()
.flat_map(|&x| [(x >> diff) as u8, (x >> diff) as u8, (x >> diff) as u8])
.collect(),
ImageBuffer::Rgb8(rgb) => rgb.to_vec(),
ImageBuffer::Rgb16(rgb16) => rgb16.iter().map(|&x| (x >> diff) as u8).collect(),
},
)
.unwrap(),
);
img.save("./out.jpg").unwrap();
}
License
This project is licensed under either of
at your option.