Timothy B. Terriberry
authored
If we have some dupe frames right near the end of the buffer, our metric window can be slightly larger than the buffer. However, the clamping we use to determine how many frames' worth of metrics to add to the buffer had a mix of signed and unsigned types, so if that number when negative, instead of clamping against zero, it would ask for all remaining frames in the file. That would cause an infinite loop when we tried to find the last keyframe in the circular buffer in oc_enc_select_qi() (which was not big enough to actually hold that many frames). This patch changes the clamp to a form that works with all unsigned values. Thanks to Brion Vibber for the report. Fixes #2229 Forward-port of r19507 from svn.