Should improve bitrate accuracy in 2-pass mode.
May also slightly improve quality by allowing more variation earlier-on in a file.
Also fix abr_buffer with 1-pass: it does something very different than what it does for 2-pass.
Thus, the earlier change that increased it based on threads caused 1-pass ABR to be somewhat less accurate.
}
else
{
- double abr_buffer = 2 * rcc->rate_tolerance * rcc->bitrate * h->i_thread_frames;
+ double abr_buffer = 2 * rcc->rate_tolerance * rcc->bitrate;
if( rcc->b_2pass )
{
- //FIXME adjust abr_buffer based on distance to the end of the video
int64_t diff;
int64_t predicted_bits = total_bits;
+ /* Adjust ABR buffer based on distance to the end of the video. */
+ if( rcc->num_entries > h->fenc->i_frame )
+ abr_buffer *= 0.5 * sqrt( rcc->num_entries - h->fenc->i_frame );
if( rcc->b_vbv )
{