X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-core%2Fsrc%2Fframe.rs;h=4e317fe3e76edc36d02bdb95ee4aa48c3fbe14c1;hb=b3247252f111872574c1aa3dc993f11d8aa66282;hp=29db180082eb265f999f4993d702e5236e195265;hpb=fcc25d82096224ba0ba4c8b800038234fbeb82a9;p=nihav.git diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index 29db180..4e317fe 100644 --- a/nihav-core/src/frame.rs +++ b/nihav-core/src/frame.rs @@ -2,7 +2,7 @@ use std::cmp::max; //use std::collections::HashMap; use std::fmt; -use std::sync::Arc; +pub use std::sync::Arc; pub use crate::formats::*; pub use crate::refs::*; @@ -857,21 +857,6 @@ pub const DUMMY_CODEC_INFO: NACodecInfo = NACodecInfo { properties: NACodecTypeInfo::None, extradata: None }; -/// A list of accepted option values. -#[derive(Debug,Clone)] -pub enum NAValue { - /// Empty value. - None, - /// Integer value. - Int(i32), - /// Long integer value. - Long(i64), - /// String value. - String(String), - /// Binary data value. - Data(Arc>), -} - /// A list of recognized frame types. #[derive(Debug,Clone,Copy,PartialEq)] #[allow(dead_code)] @@ -1167,6 +1152,18 @@ impl fmt::Display for NAStream { } } +/// Side data that may accompany demuxed data. +#[derive(Clone)] +pub enum NASideData { + /// Palette information. + /// + /// This side data contains a flag signalling that palette has changed since previous time and a reference to the current palette. + /// Palette is stored in 8-bit RGBA format. + Palette(bool, Arc<[u8; 1024]>), + /// Generic user data. + UserData(Arc>), +} + /// Packet with compressed data. #[allow(dead_code)] pub struct NAPacket { @@ -1177,6 +1174,8 @@ pub struct NAPacket { /// Keyframe flag. pub keyframe: bool, // options: HashMap>, + /// Packet side data (e.g. palette for paletted formats). + pub side_data: Vec, } impl NAPacket { @@ -1184,7 +1183,7 @@ impl NAPacket { pub fn new(str: NAStreamRef, ts: NATimeInfo, kf: bool, vec: Vec) -> Self { // let mut vec: Vec = Vec::new(); // vec.resize(size, 0); - NAPacket { stream: str, ts, keyframe: kf, buffer: NABufferRef::new(vec) } + NAPacket { stream: str, ts, keyframe: kf, buffer: NABufferRef::new(vec), side_data: Vec::new() } } /// Returns information about the stream packet belongs to. pub fn get_stream(&self) -> NAStreamRef { self.stream.clone() } @@ -1200,6 +1199,13 @@ impl NAPacket { pub fn is_keyframe(&self) -> bool { self.keyframe } /// Returns a reference to packet data. pub fn get_buffer(&self) -> NABufferRef> { self.buffer.clone() } + /// Adds side data for a packet. + pub fn add_side_data(&mut self, side_data: NASideData) { self.side_data.push(side_data); } + /// Assigns packet to a new stream. + pub fn reassign(&mut self, str: NAStreamRef, ts: NATimeInfo) { + self.stream = str; + self.ts = ts; + } } impl Drop for NAPacket {