Guard out of boundary write in rate allocation
This fixes an encoder crash issue due to out-of-boundary write
in GOP construction. This happens when a large chunk of frames
are static and the encoder decides to use maximum GOP length.
BUG=b/182490901
STATS_CHANGED
Change-Id: I8a7925af244f066b48ff5dd9256bf9891a807a70
(cherry picked from commit 169849bea5c983abce9f998547c93d94063240a8)
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c
index b1c52bd..482e260 100644
--- a/av1/encoder/pass2_strategy.c
+++ b/av1/encoder/pass2_strategy.c
@@ -943,7 +943,8 @@
// in the next GOP. For GF group, next GOP will overwrite the rate allocation.
// Setting this frame to use 0 bit (of out the current GOP budget) will
// simplify logics in reference frame management.
- gf_group->bit_allocation[gf_group_size] = 0;
+ if (gf_group_size < MAX_STATIC_GF_GROUP_LENGTH)
+ gf_group->bit_allocation[gf_group_size] = 0;
}
// Returns true if KF group and GF group both are almost completely static.