Add default initialization of xd->tile_ctx for row-mt=1
When master thread does not pick any encode job for row-mt=1,
xd->tile_ctx contains NULL pointer. This can result in NULL
pointer violation if accessed beyond the encode stage.
Hence, this CL updates xd->tile_ctx with pointer to common frame
context (cm->fc) in enc_row_mt_worker_hook() to avoid such cases.
This patch also reverts following patch, as xd->tile_ctx
is updated appropriately in enc_row_mt_worker_hook().
https://aomedia-review.googlesource.com/c/aom/+/136384
BUG=aomedia:3036
Change-Id: Id5642a4b335537e654cd5c3f0d0cb564490889ea
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index a9e158e..fb428a1 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -444,6 +444,13 @@
const BLOCK_SIZE fp_block_size = cpi->fp_block_size;
int end_of_frame = 0;
+
+ // When master thread does not have a valid job to process, xd->tile_ctx
+ // is not set and it contains NULL pointer. This can result in NULL pointer
+ // access violation if accessed beyond the encode stage. Hence, updating
+ // thread_data->td->mb.e_mbd.tile_ctx is initialized with common frame
+ // context to avoid NULL pointer access in subsequent stages.
+ thread_data->td->mb.e_mbd.tile_ctx = cm->fc;
while (1) {
int current_mi_row = -1;
#if CONFIG_MULTITHREAD
diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index 4933be3..2c12cb0 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -1708,7 +1708,7 @@
const int num_planes = av1_num_planes(cm);
assert(!cm->features.all_lossless);
- av1_fill_lr_rates(&x->mode_costs, cm->fc);
+ av1_fill_lr_rates(&x->mode_costs, x->e_mbd.tile_ctx);
int ntiles[2];
for (int is_uv = 0; is_uv < 2; ++is_uv)