Separate flat and pyramid gop structures
New define_flat_gf_group_structure() function taking most of the body of
define_gf_group_structure(). define_gf_group_structure() now just
decides whether to call define_flat_gf_group_structure() or
define_pyramid_gf_group_structure(). This minor restructure should make
it clearer that there are two distinct GOP structures which may be used
and how/where the choice between them is made.
Change-Id: I4211c848421b73581c1a054ad52776a32785313c
diff --git a/av1/encoder/gop_structure.c b/av1/encoder/gop_structure.c
index 2c7dde7..1e3940c 100644
--- a/av1/encoder/gop_structure.c
+++ b/av1/encoder/gop_structure.c
@@ -149,7 +149,7 @@
}
}
-static void define_customized_gf_group_structure(
+static void define_pyramid_gf_group_structure(
AV1_COMP *cpi, const EncodeFrameParams *const frame_params) {
RATE_CONTROL *const rc = &cpi->rc;
TWO_PASS *const twopass = &cpi->twopass;
@@ -221,25 +221,9 @@
#endif
}
-void av1_gop_setup_structure(AV1_COMP *cpi,
- const EncodeFrameParams *const frame_params) {
+static void define_flat_gf_group_structure(
+ AV1_COMP *cpi, const EncodeFrameParams *const frame_params) {
RATE_CONTROL *const rc = &cpi->rc;
-
- const int max_pyr_height = cpi->oxcf.gf_max_pyr_height;
- const int valid_customized_gf_length =
- max_pyr_height >= MIN_PYRAMID_LVL && max_pyr_height <= MAX_PYRAMID_LVL &&
- rc->baseline_gf_interval >= MIN_GF_INTERVAL &&
- rc->baseline_gf_interval <= get_max_gf_length(max_pyr_height);
- // used the new structure only if extra_arf is allowed
- if (valid_customized_gf_length && rc->source_alt_ref_pending &&
- cpi->extra_arf_allowed > 0) {
- define_customized_gf_group_structure(cpi, frame_params);
- cpi->new_bwdref_update_rule = 1;
- return;
- } else {
- cpi->new_bwdref_update_rule = 0;
- }
-
TWO_PASS *const twopass = &cpi->twopass;
GF_GROUP *const gf_group = &twopass->gf_group;
int i;
@@ -454,3 +438,24 @@
gf_group->bidir_pred_enabled[frame_index] = 0;
gf_group->brf_src_offset[frame_index] = 0;
}
+
+void av1_gop_setup_structure(AV1_COMP *cpi,
+ const EncodeFrameParams *const frame_params) {
+ RATE_CONTROL *const rc = &cpi->rc;
+
+ const int max_pyr_height = cpi->oxcf.gf_max_pyr_height;
+ const int valid_pyramid_gf_length =
+ max_pyr_height >= MIN_PYRAMID_LVL && max_pyr_height <= MAX_PYRAMID_LVL &&
+ rc->baseline_gf_interval >= MIN_GF_INTERVAL &&
+ rc->baseline_gf_interval <= get_max_gf_length(max_pyr_height);
+
+ // Decide whether to use a flat or pyramid structure for this GF
+ if (valid_pyramid_gf_length && rc->source_alt_ref_pending &&
+ cpi->extra_arf_allowed > 0) {
+ define_pyramid_gf_group_structure(cpi, frame_params);
+ cpi->new_bwdref_update_rule = 1;
+ } else {
+ define_flat_gf_group_structure(cpi, frame_params);
+ cpi->new_bwdref_update_rule = 0;
+ }
+}
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c
index 32c3bde..d5e8a36 100644
--- a/av1/encoder/pass2_strategy.c
+++ b/av1/encoder/pass2_strategy.c
@@ -1032,7 +1032,7 @@
} else {
// Calculate 'num_extra_arfs' (internal alt-refs) that we are allowed.
// Note: When new pyramid structure is used through
- // 'define_customized_gf_group_structure()' function, this value is
+ // 'define_pyramid_gf_group_structure()' function, this value is
// overridden.
if (rc->baseline_gf_interval == MIN_GF_INTERVAL &&
rc->source_alt_ref_pending) {
@@ -1111,6 +1111,7 @@
gf_group_error_left = gf_group_err;
}
+ // Set up the structure of this Group-Of-Pictures (same as GF_GROUP)
av1_gop_setup_structure(cpi, frame_params);
// Allocate bits to each of the frames in the GF group.