FIXED_GF_INTERVAL], cm->bit_depth);
active_best_quality = VPXMAX(qindex + delta_qindex, rc->best_quality);
} else {
- // Use the lower of active_worst_quality and recent/average Q.
- if (cm->current_video_frame > 1)
- active_best_quality = inter_minq[rc->avg_frame_qindex[INTER_FRAME]];
- else
+ // Use the min of the average Q (with some increase) and
+ // active_worst_quality as basis for active_best.
+ if (cm->current_video_frame > 1) {
+ q = VPXMIN(((17 * rc->avg_frame_qindex[INTER_FRAME]) >> 4),
+ active_worst_quality);
+ active_best_quality = inter_minq[q];
+ } else {
active_best_quality = inter_minq[rc->avg_frame_qindex[KEY_FRAME]];
+ }
// For the constrained quality mode we don't want
// q to fall below the cq level.
if ((oxcf->rc_mode == VPX_CQ) &&