Unified · Split
| @@ -349,8 +349,12 @@ static void calc_iframe_target_size(VP8_COMP *cpi) { · 348 unmodified lines | ||
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | if (cpi->oxcf.rc_max_intra_bitrate_pct) { |
| 352 | − unsigned int max_rate = | |
| 353 | − cpi->per_frame_bandwidth * cpi->oxcf.rc_max_intra_bitrate_pct / 100; | |
| 352 | + unsigned int max_rate; | |
| 353 | + // This product may overflow unsigned int | |
| 354 | + uint64_t product = cpi->per_frame_bandwidth; | |
| 355 | + product *= cpi->oxcf.rc_max_intra_bitrate_pct; | |
| 356 | + product /= 100; | |
| 357 | + max_rate = (unsigned int)VPXMIN(INT_MAX, product); | |
| 354 | 358 | |
| 355 | 359 | if (target > max_rate) target = max_rate; |
| 356 | 360 | } |