Fix using uninitialized value for the first frame

This commit is contained in:
Joose Sainio 2018-11-07 08:17:39 +02:00
parent d95ac11a3b
commit 3471e2470d

View file

@ -84,8 +84,15 @@ static double gop_allocate_bits(encoder_state_t * const state)
{
// With LP-GOP the bits coded is not always updated correctly so this is
// a band-aid fix for getting a better bit allocation
if (state->frame->num > 0) {
uint64_t previous_bits = state->previous_encoder_state->frame->cur_pic_target_bits;
bits_coded = previous_bits > bits_coded ? 0 : bits_coded - previous_bits;
}
else
{
bits_coded = 0;
}
// Subtract number of pictures in the partially coded GOP.
pictures_coded -= gop_offset + 1;
}