1 use std::collections::HashMap;
15 pub const SND_U8_FORMAT: NASoniton = NASoniton { bits: 8, is_be: false, packed: false, planar: false, float: false };
17 pub const SND_S16_FORMAT: NASoniton = NASoniton { bits: 16, is_be: false, packed: false, planar: false, float: false };
21 pub struct NAAudioInfo {
29 pub fn new(sr: u32, ch: u8, fmt: NASoniton, bl: usize) -> Self {
30 NAAudioInfo { sample_rate: sr, channels: ch, format: fmt, block_len: bl }
34 #[derive(Debug,Clone,Copy)]
45 pub struct NAPixelChromaton {
57 pub struct NAPixelFormaton {
60 comp_info: [Option<NAPixelChromaton>; 5],
66 macro_rules! chromaton {
67 ($hs: expr, $vs: expr, $pck: expr, $d: expr, $sh: expr, $co: expr, $ne: expr) => ({
68 Some(NAPixelChromaton{ h_ss: $hs, v_ss: $vs, is_packed: $pck, depth: $d, shift: $sh, comp_offs: $co, next_elem: $ne })
70 (yuv8; $hs: expr, $vs: expr, $co: expr) => ({
71 Some(NAPixelChromaton{ h_ss: $hs, v_ss: $vs, is_packed: false, depth: 8, shift: 0, comp_offs: $co, next_elem: 1 })
73 (pal8; $co: expr) => ({
74 Some(NAPixelChromaton{ h_ss: 0, v_ss: 0, is_packed: true, depth: 8, shift: 0, comp_offs: $co, next_elem: 3 })
79 pub const YUV420_FORMAT: NAPixelFormaton = NAPixelFormaton { model: ColorModel::YUV, components: 3,
81 chromaton!(0, 0, false, 8, 0, 0, 1),
82 chromaton!(yuv8; 1, 1, 1),
83 chromaton!(yuv8; 1, 1, 2),
85 elem_size: 0, has_alpha: false, is_palette: false };
88 pub const PAL8_FORMAT: NAPixelFormaton = NAPixelFormaton { model: ColorModel::RGB, components: 3,
94 elem_size: 1, has_alpha: false, is_palette: true };
99 pub struct NAVideoInfo {
103 format: NAPixelFormaton,
107 pub fn new(w: u32, h: u32, flip: bool, fmt: NAPixelFormaton) -> Self {
108 NAVideoInfo { width: w, height: h, flipped: flip, format: fmt }
112 #[derive(Clone,Copy)]
113 pub enum NACodecTypeInfo {
120 pub struct NABuffer<'a> {
127 pub struct NACodecInfo {
128 properties: NACodecTypeInfo,
129 extradata: Option<Rc<Vec<u8>>>,
133 pub fn new(p: NACodecTypeInfo, edata: Option<Vec<u8>>) -> Self {
134 let extradata = match edata {
136 Some(vec) => Some(Rc::new(vec)),
138 NACodecInfo { properties: p, extradata: extradata }
140 pub fn get_properties(&self) -> NACodecTypeInfo { self.properties }
141 pub fn get_extradata(&self) -> Option<Rc<Vec<u8>>> {
142 if let Some(ref vec) = self.extradata { return Some(vec.clone()); }
147 pub trait NABufferAllocator {
148 fn alloc_buf(info: &NACodecInfo) -> NABuffer<'static>;
152 pub enum NAValue<'a> {
161 pub struct NAFrame<'a> {
164 duration: Option<u64>,
165 buffer: &'a mut NABuffer<'a>,
166 info: &'a NACodecInfo,
167 options: HashMap<String, NAValue<'a>>,
171 pub struct NACodecContext<'a> {
172 info: &'a NACodecInfo,