set_ld_layer_depth: cap max_layer_depth to MAX_ARF_LAYERS
fixes a crash in allocate_gf_group_bits() after:
52fa570301 Set max layer depth for low delay settings
Bug: aomedia:3390
Change-Id: Idb53a29bd4a6f52a0cdbf7a13c1b5f73dd9eabf7
(cherry picked from commit e772cb13a03fc43b36d6cfb9baa24a21f45b348d)
diff --git a/av1/encoder/gop_structure.c b/av1/encoder/gop_structure.c
index 4a9ed08..d76efb1 100644
--- a/av1/encoder/gop_structure.c
+++ b/av1/encoder/gop_structure.c
@@ -865,7 +865,7 @@
}
gf_group->layer_depth[gf_index] = AOMMAX(log_gop_length - count, 0);
}
- gf_group->max_layer_depth = log_gop_length;
+ gf_group->max_layer_depth = AOMMIN(log_gop_length, MAX_ARF_LAYERS);
}
void av1_gop_setup_structure(AV1_COMP *cpi) {
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c
index 134c6ce..312e131 100644
--- a/av1/encoder/pass2_strategy.c
+++ b/av1/encoder/pass2_strategy.c
@@ -17,6 +17,7 @@
*/
/*! @} - end defgroup gf_group_algo */
+#include <assert.h>
#include <stdint.h>
#include "av1/encoder/thirdpass.h"
@@ -879,6 +880,7 @@
// Allocate extra bits to each ARF layer
int i;
int layer_extra_bits[MAX_ARF_LAYERS + 1] = { 0 };
+ assert(max_arf_layer <= MAX_ARF_LAYERS);
for (i = 1; i <= max_arf_layer; ++i) {
double fraction = (i == max_arf_layer) ? 1.0 : layer_fraction[i];
layer_extra_bits[i] =