Cleanup in av1_setup_shared_coeff_buffer
num_planes is computed based on monochrome flag in SequenceHeader
structure. This change avoids num_planes being passed as a
function argument in av1_setup_shared_coeff_buffer() function.
The CL also reorders function arguments.
Change-Id: Ia96aee799dea6b905ee86336356893d46fd09aa8
diff --git a/av1/encoder/context_tree.c b/av1/encoder/context_tree.c
index ccd6b9d..1407130 100644
--- a/av1/encoder/context_tree.c
+++ b/av1/encoder/context_tree.c
@@ -37,10 +37,10 @@
dst_ctx->rd_mode_is_ready = src_ctx->rd_mode_is_ready;
}
-void av1_setup_shared_coeff_buffer(struct aom_internal_error_info *error,
+void av1_setup_shared_coeff_buffer(const SequenceHeader *const seq_params,
PC_TREE_SHARED_BUFFERS *shared_bufs,
- const SequenceHeader *const seq_params,
- int num_planes) {
+ struct aom_internal_error_info *error) {
+ const int num_planes = seq_params->monochrome ? 1 : MAX_MB_PLANE;
const int max_sb_square_y = 1 << num_pels_log2_lookup[seq_params->sb_size];
const int max_sb_square_uv = max_sb_square_y >> (seq_params->subsampling_x +
seq_params->subsampling_y);
diff --git a/av1/encoder/context_tree.h b/av1/encoder/context_tree.h
index 14c433b..ef74e56 100644
--- a/av1/encoder/context_tree.h
+++ b/av1/encoder/context_tree.h
@@ -102,10 +102,9 @@
int sms_rect_valid;
} SIMPLE_MOTION_DATA_TREE;
-void av1_setup_shared_coeff_buffer(struct aom_internal_error_info *error,
+void av1_setup_shared_coeff_buffer(const SequenceHeader *const seq_params,
PC_TREE_SHARED_BUFFERS *shared_bufs,
- const SequenceHeader *const seq_params,
- int num_planes);
+ struct aom_internal_error_info *error);
void av1_free_shared_coeff_buffer(PC_TREE_SHARED_BUFFERS *shared_bufs);
PC_TREE *av1_alloc_pc_tree_node(BLOCK_SIZE bsize);
diff --git a/av1/encoder/encoder_alloc.h b/av1/encoder/encoder_alloc.h
index cac6bee..0a93488 100644
--- a/av1/encoder/encoder_alloc.h
+++ b/av1/encoder/encoder_alloc.h
@@ -85,8 +85,8 @@
CHECK_MEM_ERROR(cm, cpi->td.mb.dv_costs,
(IntraBCMVCosts *)aom_malloc(sizeof(*cpi->td.mb.dv_costs)));
- av1_setup_shared_coeff_buffer(cm->error, &cpi->td.shared_coeff_buf,
- cm->seq_params, av1_num_planes(cm));
+ av1_setup_shared_coeff_buffer(cm->seq_params, &cpi->td.shared_coeff_buf,
+ cm->error);
av1_setup_sms_tree(cpi, &cpi->td);
cpi->td.firstpass_ctx =
av1_alloc_pmc(cpi, BLOCK_16X16, &cpi->td.shared_coeff_buf);
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index baf9c59..7e34da6 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -617,8 +617,7 @@
// Set up shared coeff buffers.
av1_setup_shared_coeff_buffer(
- &ppi->error, &thread_data->td->shared_coeff_buf, &ppi->seq_params,
- av1_num_planes(&ppi->cpi->common));
+ &ppi->seq_params, &thread_data->td->shared_coeff_buf, &ppi->error);
AOM_CHECK_MEM_ERROR(
&ppi->error, thread_data->td->tmp_conv_dst,
aom_memalign(32, MAX_SB_SIZE * MAX_SB_SIZE *