diff --git a/src/encoder.c b/src/encoder.c index 486cb449..0bcd30ac 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -27,6 +27,7 @@ #include #include "cfg.h" +#include "gop.h" #include "strategyselector.h" #include "kvz_math.h" @@ -234,7 +235,11 @@ encoder_control_t* kvz_encoder_control_init(const kvz_config *const cfg) if (encoder->cfg.gop_len > 0) { if (encoder->cfg.gop_lowdelay) { - kvz_config_process_lp_gop(&encoder->cfg); + if (encoder->cfg.gop_len == 4 && encoder->cfg.ref_frames == 4) { + memcpy(encoder->cfg.gop, kvz_gop_lowdelay4, sizeof(kvz_gop_lowdelay4)); + } else { + kvz_config_process_lp_gop(&encoder->cfg); + } } } diff --git a/src/gop.h b/src/gop.h index 4347edb4..3a57f624 100644 --- a/src/gop.h +++ b/src/gop.h @@ -23,6 +23,62 @@ #include +static const kvz_gop_config kvz_gop_lowdelay4[4] = { + { + .poc_offset = 1, + .layer = 1, + .qp_offset = 5, + .qp_factor = 1.0, + .qp_model_offset = -6.5, + .qp_model_scale = 0.2590, + .is_ref = 1, + .ref_neg_count = 4, + .ref_neg = { 1, 5, 9, 13 }, + .ref_pos_count = 0, + .ref_pos = { 0 }, + }, + { + .poc_offset = 2, + .layer = 1, + .qp_offset = 4, + .qp_factor = 1.0, + .qp_model_offset = -6.5, + .qp_model_scale = 0.2590, + .is_ref = 1, + .ref_neg_count = 3, + .ref_neg = { 1, 2, 6, 10 }, + .ref_pos_count = 0, + .ref_pos = { 0 }, + }, + { + .poc_offset = 3, + .layer = 1, + .qp_offset = 5, + .qp_factor = 1.0, + .qp_model_offset = -6.5, + .qp_model_scale = 0.2590, + .is_ref = 1, + .ref_neg_count = 3, + .ref_neg = { 1, 3, 7, 11 }, + .ref_pos_count = 0, + .ref_pos = { 0 }, + }, + { + .poc_offset = 4, + .layer = 1, + .qp_offset = 1, + .qp_factor = 1.0, + .qp_model_offset = 0.0, + .qp_model_scale = 0.0, + .is_ref = 1, + .ref_neg_count = 3, + .ref_neg = { 1, 4, 8, 12 }, + .ref_pos_count = 0, + .ref_pos = { 0 }, + }, +}; + + static const kvz_gop_config kvz_gop_ra8[8] = { { .poc_offset = 8,