mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 11:24:05 +00:00
Fix checking if a low delay GOP structure is used
Stops assuming that having cfg->gop_lowdelay set means that GOP structure is used since it is possible that cfg->gop_lowdelay is true but cfg->gop_len is zero. Adds checks for cfg->gop_len where needed. Fixes a possible division by zero in kvz_encoder_feed_frame.
This commit is contained in:
parent
4f56b04239
commit
fb10b56b82
|
@ -90,7 +90,7 @@ static int select_owf_auto(const kvz_config *const cfg)
|
|||
threads_per_frame -= 2;
|
||||
}
|
||||
|
||||
if (cfg->gop_lowdelay && cfg->gop_lp_definition.t > 1) {
|
||||
if (cfg->gop_len && cfg->gop_lowdelay && cfg->gop_lp_definition.t > 1) {
|
||||
// Temporal skipping makes every other frame very fast to encode so
|
||||
// more parallel frames should be used.
|
||||
frames *= 2;
|
||||
|
|
|
@ -987,7 +987,9 @@ static void encoder_state_init_new_frame(encoder_state_t * const state, kvz_pict
|
|||
state->frame->slicetype = cfg->intra_period==1 ? KVZ_SLICE_I : (state->encoder_control->cfg->gop_len?KVZ_SLICE_B:KVZ_SLICE_P);
|
||||
|
||||
// Use P-slice for lowdelay.
|
||||
if (state->frame->slicetype == KVZ_SLICE_B && cfg->gop_lowdelay) {
|
||||
if (state->frame->slicetype == KVZ_SLICE_B &&
|
||||
cfg->gop_len > 0 &&
|
||||
cfg->gop_lowdelay) {
|
||||
state->frame->slicetype = KVZ_SLICE_P;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,8 @@ kvz_picture* kvz_encoder_feed_frame(input_frame_buffer_t *buf,
|
|||
|
||||
img_in->dts = img_in->pts;
|
||||
state->frame->gop_offset = 0;
|
||||
if (cfg->gop_lowdelay) {
|
||||
if (cfg->gop_len > 0) {
|
||||
// Using a low delay GOP structure.
|
||||
state->frame->gop_offset = (state->frame->num - 1) % cfg->gop_len;
|
||||
if (state->frame->gop_offset < 0) {
|
||||
// Set gop_offset of IDR as the highest quality picture.
|
||||
|
|
Loading…
Reference in a new issue