Change interface of av1_select_sb_size()
This patch changes the interface of av1_select_sb_size() to take the
required inputs and remove the dependency on cpi.
This is to facilitate subsequent CLs.
Change-Id: I0d28eca7a024387449804ab2222ae49aefc1d319
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 29fb21c..327acbb 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -309,7 +309,9 @@
alloc_context_buffers_ext(cm, &cpi->mbmi_ext_info);
if (!cpi->ppi->seq_params_locked)
- set_sb_size(&cm->seq_params, av1_select_sb_size(cpi));
+ set_sb_size(&cm->seq_params,
+ av1_select_sb_size(&cpi->oxcf, cm->width, cm->height,
+ cpi->svc.number_spatial_layers));
set_tile_info(cm, &cpi->oxcf.tile_cfg);
}
@@ -549,8 +551,9 @@
cm->width = oxcf->frm_dim_cfg.width;
cm->height = oxcf->frm_dim_cfg.height;
- set_sb_size(seq_params,
- av1_select_sb_size(cpi)); // set sb size before allocations
+ // set sb size before allocations
+ set_sb_size(seq_params, av1_select_sb_size(&cpi->oxcf, cm->width, cm->height,
+ cpi->svc.number_spatial_layers));
alloc_compressor_data(cpi);
av1_update_film_grain_parameters(cpi, oxcf);
@@ -761,7 +764,10 @@
int sb_size = seq_params->sb_size;
// Superblock size should not be updated after the first key frame.
if (!cpi->ppi->seq_params_locked) {
- set_sb_size(&cm->seq_params, av1_select_sb_size(cpi));
+ set_sb_size(
+ &cm->seq_params,
+ av1_select_sb_size(oxcf, frm_dim_cfg->width, frm_dim_cfg->height,
+ cpi->svc.number_spatial_layers));
for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i)
seq_params->tier[i] = (oxcf->tier_mask >> i) & 1;
}
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c
index 70bc130..c6d99e1 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -704,10 +704,8 @@
}
}
-BLOCK_SIZE av1_select_sb_size(const AV1_COMP *const cpi) {
- const AV1_COMMON *const cm = &cpi->common;
- const AV1EncoderConfig *const oxcf = &cpi->oxcf;
-
+BLOCK_SIZE av1_select_sb_size(const AV1EncoderConfig *const oxcf, int width,
+ int height, int number_spatial_layers) {
if (oxcf->tool_cfg.superblock_size == AOM_SUPERBLOCK_SIZE_64X64)
return BLOCK_64X64;
if (oxcf->tool_cfg.superblock_size == AOM_SUPERBLOCK_SIZE_128X128)
@@ -715,7 +713,7 @@
assert(oxcf->tool_cfg.superblock_size == AOM_SUPERBLOCK_SIZE_DYNAMIC);
- if (cpi->svc.number_spatial_layers > 1 ||
+ if (number_spatial_layers > 1 ||
oxcf->resize_cfg.resize_mode != RESIZE_NONE) {
// Use the configured size (top resolution) for spatial layers or
// on resize.
@@ -732,7 +730,7 @@
// speed-feature.
if (oxcf->superres_cfg.superres_mode == AOM_SUPERRES_NONE &&
oxcf->resize_cfg.resize_mode == RESIZE_NONE && oxcf->speed >= 1) {
- return AOMMIN(cm->width, cm->height) > 480 ? BLOCK_128X128 : BLOCK_64X64;
+ return AOMMIN(width, height) > 480 ? BLOCK_128X128 : BLOCK_64X64;
}
return BLOCK_128X128;
@@ -754,7 +752,9 @@
if ((cm->current_frame.frame_type == KEY_FRAME && cm->show_frame) ||
frame_is_sframe(cm)) {
if (!cpi->ppi->seq_params_locked) {
- set_sb_size(&cm->seq_params, av1_select_sb_size(cpi));
+ set_sb_size(&cm->seq_params,
+ av1_select_sb_size(&cpi->oxcf, cm->width, cm->height,
+ cpi->svc.number_spatial_layers));
}
} else {
const RefCntBuffer *const primary_ref_buf = get_primary_ref_frame_buf(cm);
diff --git a/av1/encoder/encoder_utils.h b/av1/encoder/encoder_utils.h
index 936141e..3bffb10 100644
--- a/av1/encoder/encoder_utils.h
+++ b/av1/encoder/encoder_utils.h
@@ -981,7 +981,8 @@
void av1_setup_frame(AV1_COMP *cpi);
-BLOCK_SIZE av1_select_sb_size(const AV1_COMP *const cpi);
+BLOCK_SIZE av1_select_sb_size(const AV1EncoderConfig *const oxcf, int width,
+ int height, int number_spatial_layers);
void av1_apply_active_map(AV1_COMP *cpi);