1 use std::collections::HashMap;
16 pub const SND_U8_FORMAT: NASoniton = NASoniton { bits: 8, is_be: false, packed: false, planar: false, float: false, signed: false };
18 pub const SND_S16_FORMAT: NASoniton = NASoniton { bits: 16, is_be: false, packed: false, planar: false, float: false, signed: true };
22 pub struct NAAudioInfo {
30 pub fn new(sr: u32, ch: u8, fmt: NASoniton, bl: usize) -> Self {
31 NAAudioInfo { sample_rate: sr, channels: ch, format: fmt, block_len: bl }
35 #[derive(Debug,Clone,Copy)]
46 pub struct NAPixelChromaton {
58 pub struct NAPixelFormaton {
61 comp_info: [Option<NAPixelChromaton>; 5],
67 macro_rules! chromaton {
68 ($hs: expr, $vs: expr, $pck: expr, $d: expr, $sh: expr, $co: expr, $ne: expr) => ({
69 Some(NAPixelChromaton{ h_ss: $hs, v_ss: $vs, is_packed: $pck, depth: $d, shift: $sh, comp_offs: $co, next_elem: $ne })
71 (yuv8; $hs: expr, $vs: expr, $co: expr) => ({
72 Some(NAPixelChromaton{ h_ss: $hs, v_ss: $vs, is_packed: false, depth: 8, shift: 0, comp_offs: $co, next_elem: 1 })
74 (pal8; $co: expr) => ({
75 Some(NAPixelChromaton{ h_ss: 0, v_ss: 0, is_packed: true, depth: 8, shift: 0, comp_offs: $co, next_elem: 3 })
80 pub const YUV420_FORMAT: NAPixelFormaton = NAPixelFormaton { model: ColorModel::YUV, components: 3,
82 chromaton!(0, 0, false, 8, 0, 0, 1),
83 chromaton!(yuv8; 1, 1, 1),
84 chromaton!(yuv8; 1, 1, 2),
86 elem_size: 0, has_alpha: false, is_palette: false };
89 pub const PAL8_FORMAT: NAPixelFormaton = NAPixelFormaton { model: ColorModel::RGB, components: 3,
95 elem_size: 1, has_alpha: false, is_palette: true };
100 pub struct NAVideoInfo {
104 format: NAPixelFormaton,
108 pub fn new(w: u32, h: u32, flip: bool, fmt: NAPixelFormaton) -> Self {
109 NAVideoInfo { width: w, height: h, flipped: flip, format: fmt }
113 #[derive(Clone,Copy)]
114 pub enum NACodecTypeInfo {
121 pub struct NABuffer<'a> {
128 pub struct NACodecInfo {
129 properties: NACodecTypeInfo,
130 extradata: Option<Rc<Vec<u8>>>,
134 pub fn new(p: NACodecTypeInfo, edata: Option<Vec<u8>>) -> Self {
135 let extradata = match edata {
137 Some(vec) => Some(Rc::new(vec)),
139 NACodecInfo { properties: p, extradata: extradata }
141 pub fn get_properties(&self) -> NACodecTypeInfo { self.properties }
142 pub fn get_extradata(&self) -> Option<Rc<Vec<u8>>> {
143 if let Some(ref vec) = self.extradata { return Some(vec.clone()); }
148 pub trait NABufferAllocator {
149 fn alloc_buf(info: &NACodecInfo) -> NABuffer<'static>;
153 pub enum NAValue<'a> {
162 pub struct NAFrame<'a> {
165 duration: Option<u64>,
166 buffer: &'a mut NABuffer<'a>,
167 info: &'a NACodecInfo,
168 options: HashMap<String, NAValue<'a>>,
172 pub struct NACodecContext<'a> {
173 info: &'a NACodecInfo,