validate!(is_intra);
let fmt = match mode {
DecodeMode::YUV => YUV420_FORMAT,
- DecodeMode::Gray => NAPixelFormaton {
- model: ColourModel::YUV(YUVSubmodel::YUVJ),
- components: 1,
- comp_info: [Some(NAPixelChromaton{h_ss: 0, v_ss: 0, packed: false, depth: 8, shift: 0, comp_offs: 0, next_elem: 1}), None, None, None, None],
- elem_size: 1,
- be: true,
- alpha: false,
- palette: false,
- },
+ DecodeMode::Gray => GREY_FORMAT,
DecodeMode::Palette => PAL8_FORMAT,
_ => unreachable!(),
};
}
}
-const GRAY_FORMAT: NAPixelFormaton = NAPixelFormaton {
- model: ColourModel::YUV(YUVSubmodel::YUVJ),
- components: 1,
- comp_info: [Some(NAPixelChromaton{h_ss: 0, v_ss: 0, packed: false, depth: 8, shift: 0, comp_offs: 0, next_elem: 1}), None, None, None, None],
- elem_size: 1,
- be: true,
- alpha: false,
- palette: false,
- };
-
struct MaskWriter {
masks: Vec<u32>,
mask: u32,
},
NACodecTypeInfo::Audio(_) => Err(EncoderError::FormatError),
NACodecTypeInfo::Video(vinfo) => {
- let pix_fmt = if vinfo.format == GRAY_FORMAT { GRAY_FORMAT } else { YUV420_FORMAT };
+ let pix_fmt = if vinfo.format == GREY_FORMAT { GREY_FORMAT } else { YUV420_FORMAT };
let outinfo = NAVideoInfo::new((vinfo.width + 3) & !3, (vinfo.height + 3) & !3, false, pix_fmt);
let mut ofmt = *encinfo;
ofmt.format = NACodecTypeInfo::Video(outinfo);
NACodecTypeInfo::None => Err(EncoderError::FormatError),
NACodecTypeInfo::Audio(_) => Err(EncoderError::FormatError),
NACodecTypeInfo::Video(vinfo) => {
- if vinfo.format != YUV420_FORMAT && vinfo.format != GRAY_FORMAT {
+ if vinfo.format != YUV420_FORMAT && vinfo.format != GREY_FORMAT {
return Err(EncoderError::FormatError);
}
if ((vinfo.width | vinfo.height) & 3) != 0 {
use nihav_core::io::byteio::*;
use nihav_core::io::bitwriter::*;
-const GRAY_FORMAT: NAPixelFormaton = NAPixelFormaton {
- model: ColourModel::YUV(YUVSubmodel::YUVJ),
- components: 1,
- comp_info: [Some(NAPixelChromaton{h_ss: 0, v_ss: 0, packed: false, depth: 8, shift: 0, comp_offs: 0, next_elem: 1}), None, None, None, None],
- elem_size: 1,
- be: true,
- alpha: false,
- palette: false,
- };
-
#[derive(Clone,Copy,Default,PartialEq)]
enum CompressionLevel {
None,
},
NACodecTypeInfo::Audio(_) => Err(EncoderError::FormatError),
NACodecTypeInfo::Video(vinfo) => {
- let format = if vinfo.format == GRAY_FORMAT { GRAY_FORMAT } else { PAL8_FORMAT };
+ let format = if vinfo.format == GREY_FORMAT { GREY_FORMAT } else { PAL8_FORMAT };
let outinfo = NAVideoInfo::new(vinfo.width, vinfo.height, false, format);
let mut ofmt = *encinfo;
ofmt.format = NACodecTypeInfo::Video(outinfo);
if vinfo.width > 65535 || vinfo.height > 65535 {
return Err(EncoderError::FormatError);
}
- if vinfo.format != PAL8_FORMAT && vinfo.format != GRAY_FORMAT {
+ if vinfo.format != PAL8_FORMAT && vinfo.format != GREY_FORMAT {
return Err(EncoderError::FormatError);
}
self.width = vinfo.width;
self.height = vinfo.height;
- self.grayscale = vinfo.format == GRAY_FORMAT;
+ self.grayscale = vinfo.format == GREY_FORMAT;
let edata = self.tr_idx.map(|val| vec![val]);
None, None],
elem_size: 3, be: false, alpha: false, palette: true };
+/// Pre-defined format for 8-bit greyscale.
+pub const GREY_FORMAT: NAPixelFormaton = NAPixelFormaton { model: ColourModel::YUV(YUVSubmodel::YUVJ), components: 1,
+ comp_info: [
+ chromaton!(0, 0, false, 8, 0, 0, 1),
+ None, None, None, None],
+ elem_size: 1, be: true, alpha: false, palette: false };
+
/// Predefined format for RGB555 packed video.
pub const RGB555_FORMAT: NAPixelFormaton = NAPixelFormaton::make_rgb16_fmt(5, 5, 5, true, false);
let mut vinfo = NAVideoInfo::new(w, h, false, RGB24_FORMAT);
match magic[1] {
b'5' | b'2' if !pgmyuv => {
- vinfo.format = NAPixelFormaton {
- model: ColourModel::YUV(YUVSubmodel::YUVJ),
- components: 1,
- comp_info: [Some(NAPixelChromaton{h_ss: 0, v_ss: 0, packed: false, depth: 8, shift: 0, comp_offs: 0, next_elem: 1}), None, None, None, None],
- elem_size: 1,
- be: true,
- alpha: false,
- palette: false,
- };
+ // todo: modify format for different bit-depths
+ vinfo.format = GREY_FORMAT;
vinfo.bits = bits;
},
b'5' | b'2' => {
use std::collections::VecDeque;
use nihav_core::demuxers::*;
-const GRAY_FORMAT: NAPixelFormaton = NAPixelFormaton {
- model: ColourModel::YUV(YUVSubmodel::YUVJ),
- components: 1,
- comp_info: [Some(NAPixelChromaton{h_ss: 0, v_ss: 0, packed: false, depth: 8, shift: 0, comp_offs: 0, next_elem: 1}), None, None, None, None],
- elem_size: 1,
- be: true,
- alpha: false,
- palette: false,
-};
-
struct DVIDemuxer<'a> {
src: &'a mut dyn ByteIO,
data_end: u64,
};
let fmt = match hdr_subtype {
- 1 | 11 | 12 => GRAY_FORMAT, // Y/U/V component only
+ 1 | 11 | 12 => GREY_FORMAT, // Y/U/V component only
_ => YUV410_FORMAT,
};