fn adecoder_to_frames<'a, D: AnimationDecoder<'a>>(
        dec: D,
        cancel: &Arc<AtomicBool>,
    ) -> Result<Frames> {
        let raw_frames: std::result::Result<Vec<_>, _> = dec
            .into_frames()
            .take_while(|_| !cancel.load(Ordering::Relaxed))
            .collect();
        // TODO -- could just index and sort these

        Ok(raw_frames?
            .into_par_iter()
            .filter_map(|frame| {
                if cancel.load(Ordering::Relaxed) {
                    return None;
                }

                let dur = frame.delay().into();
                let img = image_23::DynamicImage::ImageRgba8(frame.into_buffer());

                let mut h = AHasher::default();
                img.hash(&mut h);
                let hash = h.finish();

                Some((img.into(), dur, hash))
            })
            .collect::<Vec<_>>()
            .into())
    }
// TODO -- benchmark whether it's actually worthwhile to parallelize the conversions.
- benchmark whether it's actually worthwhile to parallelize the conversions.
- benchmark whether it ' s actually worthwhile to parallelize the conversions .
fn adecoder_to_frames<'a, D: AnimationDecoder<'a>>(
        dec: D,
        cancel: &Arc<AtomicBool>,
    ) -> Result<Frames> {
        let raw_frames: std::result::Result<Vec<_>, _> = dec
            .into_frames()
            .take_while(|_| !cancel.load(Ordering::Relaxed))
            .collect();
        // TODO -- could just index and sort these
        Ok(raw_frames?
            .into_par_iter()
            .filter_map(|frame| {
                if cancel.load(Ordering::Relaxed) {
                    return None;
                }
                let dur = frame.delay().into();
                let img = image_23::DynamicImage::ImageRgba8(frame.into_buffer());
                let mut h = AHasher::default();
                img.hash(&mut h);
                let hash = h.finish();
                Some((img.into(), dur, hash))
            })
            .collect::<Vec<_>>()
            .into())
    }
fn adecoder_to_frames < ' a , D : AnimationDecoder < ' a > > ( dec : D , cancel : & Arc < AtomicBool > , ) -> Result < Frames > { let raw_frames : std :: result :: Result < Vec < _ > , _ > = dec . into_frames ( ) . take_while ( | _ | ! cancel . load ( Ordering :: Relaxed ) ) . collect ( ) ; // TODO -- could just index and sort these Ok ( raw_frames ? . into_par_iter ( ) . filter_map ( | frame | { if cancel . load ( Ordering :: Relaxed ) { return None ; } let dur = frame . delay ( ) . into ( ) ; let img = image_23 :: DynamicImage :: ImageRgba8 ( frame . into_buffer ( ) ) ; let mut h = AHasher :: default ( ) ; img . hash ( & mut h ) ; let hash = h . finish ( ) ; Some ( ( img . into ( ) , dur , hash ) ) } ) . collect :: < Vec < _ > > ( ) . into ( ) ) }
TODO -- benchmark whether it's actually worthwhile to parallelize the conversions.
TODO -- benchmark whether it ' s actually worthwhile to parallelize the conversions .
dec
D
cancel
&Arc<AtomicBool>
dec
D
cancel
&Arc<AtomicBool>