From: Kostya Shishkov Date: Tue, 16 Jun 2020 15:36:15 +0000 (+0200) Subject: make HAMShuffler generic X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=8d7a1c5c2b1c41d284cbe7ab3d3ee344755db7bc;p=nihav.git make HAMShuffler generic --- diff --git a/nihav-codec-support/src/codecs/mod.rs b/nihav-codec-support/src/codecs/mod.rs index 6589e47..389821e 100644 --- a/nihav-codec-support/src/codecs/mod.rs +++ b/nihav-codec-support/src/codecs/mod.rs @@ -25,11 +25,11 @@ use std::mem; /// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference /// ```` #[allow(dead_code)] -pub struct HAMShuffler { - lastframe: Option>, +pub struct HAMShuffler { + lastframe: Option>, } -impl HAMShuffler { +impl HAMShuffler { /// Constructs a new instance of frame manager. #[allow(dead_code)] pub fn new() -> Self { HAMShuffler { lastframe: None } } @@ -38,12 +38,12 @@ impl HAMShuffler { pub fn clear(&mut self) { self.lastframe = None; } /// Sets a new frame reference. #[allow(dead_code)] - pub fn add_frame(&mut self, buf: NAVideoBufferRef) { + pub fn add_frame(&mut self, buf: NAVideoBufferRef) { self.lastframe = Some(buf); } /// Provides a copy of the reference frame if present or `None` if it is not. #[allow(dead_code)] - pub fn clone_ref(&mut self) -> Option> { + pub fn clone_ref(&mut self) -> Option> { if let Some(ref mut frm) = self.lastframe { let newfrm = frm.copy_buffer(); *frm = newfrm.clone().into_ref(); @@ -54,7 +54,7 @@ impl HAMShuffler { } /// Returns the original saved reference frame or `None` if it is not present. #[allow(dead_code)] - pub fn get_output_frame(&mut self) -> Option> { + pub fn get_output_frame(&mut self) -> Option> { match self.lastframe { Some(ref frm) => Some(frm.clone()), None => None, @@ -62,7 +62,7 @@ impl HAMShuffler { } } -impl Default for HAMShuffler { +impl Default for HAMShuffler { fn default() -> Self { Self { lastframe: None } } } diff --git a/nihav-commonfmt/src/codecs/cinepak.rs b/nihav-commonfmt/src/codecs/cinepak.rs index 24d25a8..8c67c5c 100644 --- a/nihav-commonfmt/src/codecs/cinepak.rs +++ b/nihav-commonfmt/src/codecs/cinepak.rs @@ -14,7 +14,7 @@ enum DecodeMode { struct CinepakDecoder { info: NACodecInfoRef, - frmmgr: HAMShuffler, + frmmgr: HAMShuffler, cb_v1: [[u8; 6]; 256], cb_v4: [[u8; 6]; 256], mode: DecodeMode, diff --git a/nihav-commonfmt/src/codecs/clearvideo.rs b/nihav-commonfmt/src/codecs/clearvideo.rs index 6021856..4f24bd4 100644 --- a/nihav-commonfmt/src/codecs/clearvideo.rs +++ b/nihav-commonfmt/src/codecs/clearvideo.rs @@ -373,7 +373,7 @@ struct ClearVideoDecoder { info: NACodecInfoRef, dc_cb: Codebook, ac_cb: Codebook, - frmmgr: HAMShuffler, + frmmgr: HAMShuffler, is_rm: bool, ylev: [LevelCodes; 4], ulev: [LevelCodes; 3], diff --git a/nihav-game/src/codecs/midivid.rs b/nihav-game/src/codecs/midivid.rs index 611ca60..700491e 100644 --- a/nihav-game/src/codecs/midivid.rs +++ b/nihav-game/src/codecs/midivid.rs @@ -5,7 +5,7 @@ use nihav_codec_support::codecs::HAMShuffler; #[derive(Default)] struct MidividDecoder { info: NACodecInfoRef, - hams: HAMShuffler, + hams: HAMShuffler, lzbuf: Vec, width: usize, height: usize, diff --git a/nihav-indeo/src/codecs/indeo2.rs b/nihav-indeo/src/codecs/indeo2.rs index 38079ce..960bc0b 100644 --- a/nihav-indeo/src/codecs/indeo2.rs +++ b/nihav-indeo/src/codecs/indeo2.rs @@ -187,7 +187,7 @@ impl CodebookDescReader for IR2CodeReader { struct Indeo2Decoder { info: NACodecInfoRef, cb: Codebook, - frmmgr: HAMShuffler, + frmmgr: HAMShuffler, } impl Indeo2Decoder { diff --git a/nihav-ms/src/codecs/msrle.rs b/nihav-ms/src/codecs/msrle.rs index 8ebdd56..0c2fc9c 100644 --- a/nihav-ms/src/codecs/msrle.rs +++ b/nihav-ms/src/codecs/msrle.rs @@ -5,7 +5,7 @@ use nihav_codec_support::codecs::HAMShuffler; #[derive(Default)] struct RleDecoder { info: NACodecInfoRef, - hams: HAMShuffler, + hams: HAMShuffler, width: usize, height: usize, is_4bit: bool, diff --git a/nihav-ms/src/codecs/msvideo1.rs b/nihav-ms/src/codecs/msvideo1.rs index 34de894..a3bfebc 100644 --- a/nihav-ms/src/codecs/msvideo1.rs +++ b/nihav-ms/src/codecs/msvideo1.rs @@ -2,36 +2,6 @@ use nihav_core::codecs::*; use nihav_core::io::byteio::*; use nihav_codec_support::codecs::HAMShuffler; -struct HAMShuffler16 { - lastframe: Option>, -} - -impl HAMShuffler16 { - fn clear(&mut self) { self.lastframe = None; } - fn add_frame(&mut self, buf: NAVideoBufferRef) { - self.lastframe = Some(buf); - } - fn clone_ref(&mut self) -> Option> { - if let Some(ref mut frm) = self.lastframe { - let newfrm = frm.copy_buffer(); - *frm = newfrm.clone().into_ref(); - Some(newfrm.into_ref()) - } else { - None - } - } - fn get_output_frame(&mut self) -> Option> { - match self.lastframe { - Some(ref frm) => Some(frm.clone()), - None => None, - } - } -} - -impl Default for HAMShuffler16 { - fn default() -> Self { Self { lastframe: None } } -} - const RGB555_FORMAT: NAPixelFormaton = NAPixelFormaton { model: ColorModel::RGB(RGBSubmodel::RGB), components: 3, comp_info: [ @@ -44,8 +14,8 @@ const RGB555_FORMAT: NAPixelFormaton = NAPixelFormaton { #[derive(Default)] struct Video1Decoder { info: NACodecInfoRef, - hams: HAMShuffler, - hams16: HAMShuffler16, + hams: HAMShuffler, + hams16: HAMShuffler, width: usize, height: usize, is_16bit: bool, diff --git a/nihav-rad/src/codecs/binkvid.rs b/nihav-rad/src/codecs/binkvid.rs index 4de23e7..0c23480 100644 --- a/nihav-rad/src/codecs/binkvid.rs +++ b/nihav-rad/src/codecs/binkvid.rs @@ -476,7 +476,7 @@ impl Default for QuantMats { struct BinkDecoder { info: NACodecInfoRef, ips: IPShuffler, - hams: HAMShuffler, + hams: HAMShuffler, is_ver_b: bool, is_ver_i: bool,