fn score(&self) -> (u8, usize, [usize; 9]) {
        let n_fragments = min(self.fragments.len(), 8);

        // Buffer position indicies of each fragment.
        let mut indicies = [0; 8 + 1];

        // Do the frame stream parameters match the global stream parameters (sample rate, and
        // bits per sample)?
        let mut score_par = 0u8;

        // Is the number of samples in the decoded frame consistent with the stream parameters?
        let mut score_len = 0u8;

        // Is the frame or sample sequence number monotonic? Is the blocking strategy
        // consistent with the stream parameters?
        let mut score_seq = 0u8;

        let iter = self.fragments.iter().zip(&mut indicies[0..n_fragments]).enumerate();

        let is_fixed = self.stream_info.block_len_min == self.stream_info.block_len_max;

        for (i, (fragment, index)) in iter {
            // Stream parameter scoring: The optional parameters of the stream information block
            // match that of the fragment.
            if let Some(sample_rate) = fragment.header.sample_rate {
                if let Some(bps) = fragment.header.bits_per_sample {
                    if sample_rate == self.stream_info.sample_rate
                        && bps == self.stream_info.bits_per_sample
                    {
                        score_par |= 1 << i;
                    }
                }
            }

            // Fragment length scoring: The fragment's sample length is within the range provided in
            // the stream information block.
            if fragment.header.block_num_samples >= self.stream_info.block_len_min
                && fragment.header.block_num_samples <= self.stream_info.block_len_max
            {
                score_len |= 1 << i;
            }

            // Sequence scoring: The fragment's blocking strategy is consistent with the stream
            // information block, and the sequence number (frame number or sample number) is
            // monotonic given the current state.
            let is_monotonic = match fragment.header.block_sequence {
                BlockSequence::BySample(sample) => {
                    !is_fixed && (sample > self.last_seq || sample == 0)
                }
                BlockSequence::ByFrame(frame) => {
                    is_fixed && (u64::from(frame) > self.last_seq || frame == 0)
                }
            };

            if is_monotonic {
                score_seq |= 1 << i;
            }

            *index = fragment.pos;
        }

        indicies[n_fragments] = match self.fragments.get(n_fragments) {
            Some(fragment) => fragment.pos,
            None           => self.buf_write,
        };

        // First, second, and third represent three descending tiers of confidence. A set bit
        // indicates that the fragment at the index of the set bit is likely to be a valid
        // fragment. If absolutely no bits are set then the stream is either very corrupt,
        // malicious, or not FLAC.
        let first  = (score_par & score_len) & score_seq;
        let second = (score_par | score_len) & score_seq;
        let third  = (score_par | score_len) | score_seq;

        let best = match (first, second, third) {
            (0, 0, _) => third,
            (0, _, _) => second,
            (_, _, _) => first,
        };

        // trace!("indicies={:?}", &indicies);

        // trace!(
        //     "score_par={:#04x}, score_len={:#04x}, score_seq={:#04x}, best={:#04x}",
        //     score_par,
        //     score_len,
        //     score_seq,
        //     best,
        // );

        (best, n_fragments, indicies)
    }
/// Scores up-to 8 fragments, and returns the score, the number of fragments scored, and an
/// array of bounds for those fragments.
Scores up-to 8 fragments, and returns the score, the number of fragments scored, and an
array of bounds for those fragments.
Scores up - to 8 fragments and returns the score the number of fragments scored and an array of bounds for those fragments .
fn score(&self) -> (u8, usize, [usize; 9]) {
        let n_fragments = min(self.fragments.len(), 8);
        // Buffer position indicies of each fragment.
        let mut indicies = [0; 8 + 1];
        // Do the frame stream parameters match the global stream parameters (sample rate, and
        // bits per sample)?
        let mut score_par = 0u8;
        // Is the number of samples in the decoded frame consistent with the stream parameters?
        let mut score_len = 0u8;
        // Is the frame or sample sequence number monotonic? Is the blocking strategy
        // consistent with the stream parameters?
        let mut score_seq = 0u8;
        let iter = self.fragments.iter().zip(&mut indicies[0..n_fragments]).enumerate();
        let is_fixed = self.stream_info.block_len_min == self.stream_info.block_len_max;
        for (i, (fragment, index)) in iter {
            // Stream parameter scoring: The optional parameters of the stream information block
            // match that of the fragment.
            if let Some(sample_rate) = fragment.header.sample_rate {
                if let Some(bps) = fragment.header.bits_per_sample {
                    if sample_rate == self.stream_info.sample_rate
                        && bps == self.stream_info.bits_per_sample
                    {
                        score_par |= 1 << i;
                    }
                }
            }
            // Fragment length scoring: The fragment's sample length is within the range provided in
            // the stream information block.
            if fragment.header.block_num_samples >= self.stream_info.block_len_min
                && fragment.header.block_num_samples <= self.stream_info.block_len_max
            {
                score_len |= 1 << i;
            }
            // Sequence scoring: The fragment's blocking strategy is consistent with the stream
            // information block, and the sequence number (frame number or sample number) is
            // monotonic given the current state.
            let is_monotonic = match fragment.header.block_sequence {
                BlockSequence::BySample(sample) => {
                    !is_fixed && (sample > self.last_seq || sample == 0)
                }
                BlockSequence::ByFrame(frame) => {
                    is_fixed && (u64::from(frame) > self.last_seq || frame == 0)
                }
            };
            if is_monotonic {
                score_seq |= 1 << i;
            }
            *index = fragment.pos;
        }
        indicies[n_fragments] = match self.fragments.get(n_fragments) {
            Some(fragment) => fragment.pos,
            None           => self.buf_write,
        };
        // First, second, and third represent three descending tiers of confidence. A set bit
        // indicates that the fragment at the index of the set bit is likely to be a valid
        // fragment. If absolutely no bits are set then the stream is either very corrupt,
        // malicious, or not FLAC.
        let first  = (score_par & score_len) & score_seq;
        let second = (score_par | score_len) & score_seq;
        let third  = (score_par | score_len) | score_seq;
        let best = match (first, second, third) {
            (0, 0, _) => third,
            (0, _, _) => second,
            (_, _, _) => first,
        };
        // trace!("indicies={:?}", &indicies);
        // trace!(
        //     "score_par={:#04x}, score_len={:#04x}, score_seq={:#04x}, best={:#04x}",
        //     score_par,
        //     score_len,
        //     score_seq,
        //     best,
        // );
        (best, n_fragments, indicies)
    }
fn score ( & self ) -> ( u8 , usize , [ usize ; 9 ] ) { let n_fragments = min ( self . fragments . len ( ) , 8 ) ; // Buffer position indicies of each fragment. let mut indicies = [ 0 ; 8 + 1 ] ; // Do the frame stream parameters match the global stream parameters (sample rate, and // bits per sample)? let mut score_par = 0u8 ; // Is the number of samples in the decoded frame consistent with the stream parameters? let mut score_len = 0u8 ; // Is the frame or sample sequence number monotonic? Is the blocking strategy // consistent with the stream parameters? let mut score_seq = 0u8 ; let iter = self . fragments . iter ( ) . zip ( & mut indicies [ 0 .. n_fragments ] ) . enumerate ( ) ; let is_fixed = self . stream_info . block_len_min == self . stream_info . block_len_max ; for ( i , ( fragment , index ) ) in iter { // Stream parameter scoring: The optional parameters of the stream information block // match that of the fragment. if let Some ( sample_rate ) = fragment . header . sample_rate { if let Some ( bps ) = fragment . header . bits_per_sample { if sample_rate == self . stream_info . sample_rate && bps == self . stream_info . bits_per_sample { score_par |= 1 << i ; } } } // Fragment length scoring: The fragment's sample length is within the range provided in // the stream information block. if fragment . header . block_num_samples >= self . stream_info . block_len_min && fragment . header . block_num_samples <= self . stream_info . block_len_max { score_len |= 1 << i ; } // Sequence scoring: The fragment's blocking strategy is consistent with the stream // information block, and the sequence number (frame number or sample number) is // monotonic given the current state. let is_monotonic = match fragment . header . block_sequence { BlockSequence :: BySample ( sample ) => { ! is_fixed && ( sample > self . last_seq || sample == 0 ) } BlockSequence :: ByFrame ( frame ) => { is_fixed && ( u64 :: from ( frame ) > self . last_seq || frame == 0 ) } } ; if is_monotonic { score_seq |= 1 << i ; } * index = fragment . pos ; } indicies [ n_fragments ] = match self . fragments . get ( n_fragments ) { Some ( fragment ) => fragment . pos , None => self . buf_write , } ; // First, second, and third represent three descending tiers of confidence. A set bit // indicates that the fragment at the index of the set bit is likely to be a valid // fragment. If absolutely no bits are set then the stream is either very corrupt, // malicious, or not FLAC. let first = ( score_par & score_len ) & score_seq ; let second = ( score_par | score_len ) & score_seq ; let third = ( score_par | score_len ) | score_seq ; let best = match ( first , second , third ) { ( 0 , 0 , _ ) => third , ( 0 , _ , _ ) => second , ( _ , _ , _ ) => first , } ; // trace!("indicies={:?}", &indicies); // trace!( //     "score_par={:#04x}, score_len={:#04x}, score_seq={:#04x}, best={:#04x}", //     score_par, //     score_len, //     score_seq, //     best, // ); ( best , n_fragments , indicies ) }
Scores up-to 8 fragments, and returns the score, the number of fragments scored, and an
array of bounds for those fragments.
Scores up - to 8 fragments and returns the score the number of fragments scored and an array of bounds for those fragments .
&self
&self