/// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference
 /// ````
 #[allow(dead_code)]
-pub struct HAMShuffler {
-    lastframe: Option<NAVideoBufferRef<u8>>,
+pub struct HAMShuffler<T: Copy> {
+    lastframe: Option<NAVideoBufferRef<T>>,
 }
 
-impl HAMShuffler {
+impl<T: Copy> HAMShuffler<T> {
     /// Constructs a new instance of frame manager.
     #[allow(dead_code)]
     pub fn new() -> Self { HAMShuffler { lastframe: None } }
     pub fn clear(&mut self) { self.lastframe = None; }
     /// Sets a new frame reference.
     #[allow(dead_code)]
-    pub fn add_frame(&mut self, buf: NAVideoBufferRef<u8>) {
+    pub fn add_frame(&mut self, buf: NAVideoBufferRef<T>) {
         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<NAVideoBufferRef<u8>> {
+    pub fn clone_ref(&mut self) -> Option<NAVideoBufferRef<T>> {
         if let Some(ref mut frm) = self.lastframe {
             let newfrm = frm.copy_buffer();
             *frm = newfrm.clone().into_ref();
     }
     /// Returns the original saved reference frame or `None` if it is not present.
     #[allow(dead_code)]
-    pub fn get_output_frame(&mut self) -> Option<NAVideoBufferRef<u8>> {
+    pub fn get_output_frame(&mut self) -> Option<NAVideoBufferRef<T>> {
         match self.lastframe {
             Some(ref frm) => Some(frm.clone()),
             None => None,
     }
 }
 
-impl Default for HAMShuffler {
+impl<T: Copy> Default for HAMShuffler<T> {
     fn default() -> Self { Self { lastframe: None } }
 }
 
 
 use nihav_core::io::byteio::*;
 use nihav_codec_support::codecs::HAMShuffler;
 
-struct HAMShuffler16 {
-    lastframe: Option<NAVideoBufferRef<u16>>,
-}
-
-impl HAMShuffler16 {
-    fn clear(&mut self) { self.lastframe = None; }
-    fn add_frame(&mut self, buf: NAVideoBufferRef<u16>) {
-        self.lastframe = Some(buf);
-    }
-    fn clone_ref(&mut self) -> Option<NAVideoBufferRef<u16>> {
-        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<NAVideoBufferRef<u16>> {
-        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: [
 #[derive(Default)]
 struct Video1Decoder {
     info:       NACodecInfoRef,
-    hams:       HAMShuffler,
-    hams16:     HAMShuffler16,
+    hams:       HAMShuffler<u8>,
+    hams16:     HAMShuffler<u16>,
     width:      usize,
     height:     usize,
     is_16bit:   bool,