From: Adrian Grange Date: Tue, 10 Mar 2015 16:14:54 +0000 (-0700) Subject: Fix vp9_compute_qdelta_by_rate loop behavior X-Git-Tag: v1.4.0~66 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78df71221656b0a0d37bff6c16efd743347fa30d;p=platform%2Fupstream%2Flibvpx.git Fix vp9_compute_qdelta_by_rate loop behavior The return value from vp9_compute_qdelta_by_rate, which is a delta value for the quantizer, could never be 0 if (qindex == rc->worst_quality). This occurs because target_index was setup unconditionally in the loop and yet the loop counter stopped at (rc->worst_quality - 1). Change-Id: I6b59cd9b5811ff33357e71cd7d814c5e53d291f2 --- diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index f33fe51..79a89af 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -1595,11 +1595,12 @@ int vp9_compute_qdelta_by_rate(const RATE_CONTROL *rc, FRAME_TYPE frame_type, // Convert the q target to an index for (i = rc->best_quality; i < rc->worst_quality; ++i) { - target_index = i; - if (vp9_rc_bits_per_mb(frame_type, i, 1.0, bit_depth) <= target_bits_per_mb) + if (vp9_rc_bits_per_mb(frame_type, i, 1.0, bit_depth) <= + target_bits_per_mb) { + target_index = i; break; + } } - return target_index - qindex; }