From: Josh Coalson Date: Sun, 17 Dec 2000 19:07:46 +0000 (+0000) Subject: Fixed bug in constant-detection. X-Git-Tag: 1.2.0~2769 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d44feb11d996c2a0b642027329013363c692949f;p=platform%2Fupstream%2Fflac.git Fixed bug in constant-detection. --- diff --git a/src/libFLAC/encoder.c b/src/libFLAC/encoder.c index 2a6fffa..512b626 100644 --- a/src/libFLAC/encoder.c +++ b/src/libFLAC/encoder.c @@ -627,10 +627,20 @@ bool encoder_process_subframes_(FLAC__Encoder *encoder, bool is_last_frame, cons /* check for constant subframe */ guess_fixed_order = FLAC__fixed_compute_best_predictor(integer_signal[channel]+FLAC__MAX_FIXED_ORDER, frame_header->blocksize-FLAC__MAX_FIXED_ORDER, fixed_residual_bits_per_sample); if(fixed_residual_bits_per_sample[1] == 0.0) { - candidate_bits = encoder_evaluate_constant_subframe_(integer_signal[channel][0], frame_header->bits_per_sample, &(encoder->guts->candidate_subframe)); - if(candidate_bits < best_bits) { - encoder_promote_candidate_subframe_(encoder); - best_bits = candidate_bits; + /* the above means integer_signal[channel]+FLAC__MAX_FIXED_ORDER is constant, now we just have to check the warmup samples */ + unsigned i, signal_is_constant = true; + for(i = 1; i <= FLAC__MAX_FIXED_ORDER; i++) { + if(integer_signal[channel][0] != integer_signal[channel][i]) { + signal_is_constant = false; + break; + } + } + if(signal_is_constant) { + candidate_bits = encoder_evaluate_constant_subframe_(integer_signal[channel][0], frame_header->bits_per_sample, &(encoder->guts->candidate_subframe)); + if(candidate_bits < best_bits) { + encoder_promote_candidate_subframe_(encoder); + best_bits = candidate_bits; + } } } else {