Fix null pointer access in av1_setup_pc_tree
Fixed a null pointer access in av1_setup_pc_tree in the case
of firstpass/LAP stage when CONFIG_INTERNAL_STATS is enabled.
Change-Id: Ic1b2fb8263d9ac28db3d9b420b29c09dc35956dd
diff --git a/av1/encoder/context_tree.c b/av1/encoder/context_tree.c
index 78ccd4f..5544ce9 100644
--- a/av1/encoder/context_tree.c
+++ b/av1/encoder/context_tree.c
@@ -205,12 +205,14 @@
#if CONFIG_INTERNAL_STATS
td->pc_root[i]->none.best_mode_index = THR_INVALID;
#endif // CONFIG_INTERNAL_STATS
- // Set up the root nodes for the rest of the possible superblock sizes
- while (--i >= 0) {
- td->pc_root[i] = td->pc_root[i + 1]->split[0];
+ if (!stat_generation_stage) {
+ // Set up the root nodes for the rest of the possible superblock sizes
+ while (--i >= 0) {
+ td->pc_root[i] = td->pc_root[i + 1]->split[0];
#if CONFIG_INTERNAL_STATS
- td->pc_root[i]->none.best_mode_index = THR_INVALID;
+ td->pc_root[i]->none.best_mode_index = THR_INVALID;
#endif // CONFIG_INTERNAL_STATS
+ }
}
}