mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Don't assume anything about bits spent
This commit is contained in:
parent
3471e2470d
commit
1c8a1f24e2
|
@ -79,26 +79,8 @@ static double gop_allocate_bits(encoder_state_t * const state)
|
|||
int pictures_coded = MAX(0, state->frame->num - encoder->cfg.owf);
|
||||
|
||||
int gop_offset = (state->frame->gop_offset - encoder->cfg.owf) % MAX(1, encoder->cfg.gop_len);
|
||||
|
||||
if(encoder->cfg.gop_lp_definition.d != 0 && encoder->cfg.gop_lp_definition.t != 0)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Only take fully coded GOPs into account.
|
||||
else if (encoder->cfg.gop_len > 0 && gop_offset != encoder->cfg.gop_len - 1) {
|
||||
|
||||
if (encoder->cfg.gop_len > 0 && gop_offset != encoder->cfg.gop_len - 1 && encoder->cfg.gop_lp_definition.d == 0) {
|
||||
// Subtract number of bits in the partially coded GOP.
|
||||
bits_coded -= state->frame->cur_gop_bits_coded;
|
||||
// Subtract number of pictures in the partially coded GOP.
|
||||
|
|
Loading…
Reference in a new issue