This fixes an overflow problem in the frame error accumulators. The overflow condition is extreme but did trigger when Frank B. coded some high motion interlaced HD content. The observed effect was a catastrophic breakdown of the rate control leading to massive undershoot and poor bit allocation. All the error values should really be unsigned but I will look at this separately.
Unified · Split
| @@ -560,8 +560,8 @@ void vp8_first_pass(VP8_COMP *cpi) · 559 unmodified lines | ||
| 560 | 560 | YV12_BUFFER_CONFIG *gld_yv12 = &cm->yv12_fb[cm->gld_fb_idx]; |
| 561 | 561 | int recon_y_stride = lst_yv12->y_stride; |
| 562 | 562 | int recon_uv_stride = lst_yv12->uv_stride; |
| 563 | − int intra_error = 0; | |
| 564 | − int coded_error = 0; | |
| 563 | + long long intra_error = 0; | |
| 564 | + long long coded_error = 0; | |
| 565 | 565 | |
| 566 | 566 | int sum_mvr = 0, sum_mvc = 0; |
| 567 | 567 | int sum_mvr_abs = 0, sum_mvc_abs = 0; |
| @@ -648,7 +648,7 @@ void vp8_first_pass(VP8_COMP *cpi) · 80 unmodified lines | ||
| 648 | 648 | this_error += intrapenalty; |
| 649 | 649 | |
| 650 | 650 | // Cumulative intra error total |
| 651 | − intra_error += this_error; | |
| 651 | + intra_error += (long long)this_error; | |
| 652 | 652 | |
| 653 | 653 | // Indicate default assumption of intra in the motion map |
| 654 | 654 | *fp_motion_map_ptr = 0; |
| @@ -800,7 +800,7 @@ void vp8_first_pass(VP8_COMP *cpi) · 145 unmodified lines | ||
| 800 | 800 | } |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | − coded_error += this_error; | |
| 803 | + coded_error += (long long)this_error; | |
| 804 | 804 | |
| 805 | 805 | // adjust to the next column of macroblocks |
| 806 | 806 | x->src.y_buffer += 16; |