]> git.nihav.org Git - nihav.git/blobdiff - nihav-core/src/frame.rs
core/byteio: reexport SeekFrom
[nihav.git] / nihav-core / src / frame.rs
index 14e5b63a284902a73fef97238291d098acf024ec..091ba99a688aac8e077ba3b4f1304146c9d713ed 100644 (file)
@@ -268,7 +268,7 @@ pub struct NASimpleVideoFrame<'a, T: Copy> {
     pub stride:     [usize; NA_SIMPLE_VFRAME_COMPONENTS],
     pub offset:     [usize; NA_SIMPLE_VFRAME_COMPONENTS],
     pub components: usize,
-    pub data:       &'a mut Vec<T>,
+    pub data:       &'a mut [T],
 }
 
 impl<'a, T:Copy> NASimpleVideoFrame<'a, T> {
@@ -297,7 +297,7 @@ impl<'a, T:Copy> NASimpleVideoFrame<'a, T> {
             stride: s,
             offset: o,
             components,
-            data: vbuf.data.as_mut().unwrap(),
+            data: vbuf.data.as_mut_slice(),
             })
     }
 }
@@ -360,9 +360,7 @@ pub fn alloc_video_buffer(vinfo: NAVideoInfo, align: u8) -> Result<NABufferType,
             let ochr = fmt.get_chromaton(i);
             if ochr.is_none() { continue; }
             let chr = ochr.unwrap();
-            if !vinfo.is_flipped() {
-                offs.push(new_size as usize);
-            }
+            offs.push(new_size as usize);
             let stride = chr.get_linesize(width);
             let cur_h = chr.get_height(height);
             let cur_sz = stride.checked_mul(cur_h);
@@ -370,9 +368,6 @@ pub fn alloc_video_buffer(vinfo: NAVideoInfo, align: u8) -> Result<NABufferType,
             let new_sz = new_size.checked_add(cur_sz.unwrap());
             if new_sz == None { return Err(AllocatorError::TooLargeDimensions); }
             new_size = new_sz.unwrap();
-            if vinfo.is_flipped() {
-                offs.push(new_size as usize);
-            }
             strides.push(stride);
         }
         if max_depth <= 8 {
@@ -674,6 +669,7 @@ impl NATimeInfo {
 #[derive(Clone)]
 pub struct NAFrame {
     ts:             NATimeInfo,
+    id:             i64,
     buffer:         NABufferType,
     info:           NACodecInfoRef,
     ftype:          FrameType,
@@ -699,7 +695,7 @@ impl NAFrame {
                info:           NACodecInfoRef,
                options:        HashMap<String, NAValue>,
                buffer:         NABufferType) -> Self {
-        NAFrame { ts, buffer, info, ftype, key: keyframe, options }
+        NAFrame { ts, id: 0, buffer, info, ftype, key: keyframe, options }
     }
     pub fn get_info(&self) -> NACodecInfoRef { self.info.clone() }
     pub fn get_frame_type(&self) -> FrameType { self.ftype }
@@ -709,9 +705,11 @@ impl NAFrame {
     pub fn get_time_information(&self) -> NATimeInfo { self.ts }
     pub fn get_pts(&self) -> Option<u64> { self.ts.get_pts() }
     pub fn get_dts(&self) -> Option<u64> { self.ts.get_dts() }
+    pub fn get_id(&self) -> i64 { self.id }
     pub fn get_duration(&self) -> Option<u64> { self.ts.get_duration() }
     pub fn set_pts(&mut self, pts: Option<u64>) { self.ts.set_pts(pts); }
     pub fn set_dts(&mut self, dts: Option<u64>) { self.ts.set_dts(dts); }
+    pub fn set_id(&mut self, id: i64) { self.id = id; }
     pub fn set_duration(&mut self, dur: Option<u64>) { self.ts.set_duration(dur); }
 
     pub fn get_buffer(&self) -> NABufferType { self.buffer.clone() }