diff options
author | Paul Wilkins <paulwilkins@google.com> | 2014-06-03 13:03:49 +0100 |
---|---|---|
committer | Paul Wilkins <paulwilkins@google.com> | 2014-06-03 13:31:32 +0100 |
commit | 090d07984fef6bbd967d52569197f81e75c83d4e (patch) | |
tree | b01ecd88330a4fc231bf28d66ce1a51e98003789 | |
parent | 81c2fcccbc04e8d264029484205586b2acc8dc5b (diff) | |
download | libvpx-090d07984fef6bbd967d52569197f81e75c83d4e.tar libvpx-090d07984fef6bbd967d52569197f81e75c83d4e.tar.gz libvpx-090d07984fef6bbd967d52569197f81e75c83d4e.tar.bz2 libvpx-090d07984fef6bbd967d52569197f81e75c83d4e.zip |
Fix AQ mode 2 bug where delta causes Q 0.
In Aq mode 2 for kf/arf/gf the segment q delta
is calculated and then applied by re-quantization without
going through the rd loop again. If the base Q != 0
but the segment Q == 0 (lossless) this can could give rise
to a situation where we have an illegal combination of
transform size and Q. (Q == 0 requires that all blocks
are coded 4x4 WHT).
Change-Id: I241a58c6494ed442e9e4630070b0cde0fb99ae45
-rw-r--r-- | vp9/encoder/vp9_aq_complexity.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/vp9/encoder/vp9_aq_complexity.c b/vp9/encoder/vp9_aq_complexity.c index 47ad8d8cc..0d6b41d15 100644 --- a/vp9/encoder/vp9_aq_complexity.c +++ b/vp9/encoder/vp9_aq_complexity.c @@ -47,11 +47,21 @@ void vp9_setup_in_frame_q_adj(VP9_COMP *cpi) { // Use some of the segments for in frame Q adjustment. for (segment = 1; segment < 2; segment++) { - const int qindex_delta = + int qindex_delta = vp9_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex, in_frame_q_adj_ratio[segment]); - vp9_enable_segfeature(seg, segment, SEG_LVL_ALT_Q); - vp9_set_segdata(seg, segment, SEG_LVL_ALT_Q, qindex_delta); + + // For AQ mode 2, we dont allow Q0 in a segment if the base Q is not 0. + // Q0 (lossless) implies 4x4 only and in AQ mode 2 a segment Q delta + // is sometimes applied without going back around the rd loop. + // This could lead to an illegal combination of partition size and q. + if ((cm->base_qindex != 0) && ((cm->base_qindex + qindex_delta) == 0)) { + qindex_delta = -cm->base_qindex + 1; + } + if ((cm->base_qindex + qindex_delta) > 0) { + vp9_enable_segfeature(seg, segment, SEG_LVL_ALT_Q); + vp9_set_segdata(seg, segment, SEG_LVL_ALT_Q, qindex_delta); + } } } } |