Abstract level_params to AV1_PRIMARY
Moved level_params from AV1_COMP to AV1_PRIMARY.
Change-Id: Ibc81ece5664ce43288b70876210f892f9e4439bf
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 18a89be..6f751cc 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -2405,9 +2405,9 @@
const size_t move_offset = obu_header_size + length_field_size;
memmove(ctx->cx_data + move_offset, ctx->cx_data, frame_size);
- obu_header_size =
- av1_write_obu_header(&cpi->level_params, &cpi->frame_header_count,
- OBU_TEMPORAL_DELIMITER, 0, ctx->cx_data);
+ obu_header_size = av1_write_obu_header(
+ &cpi->ppi->level_params, &cpi->frame_header_count,
+ OBU_TEMPORAL_DELIMITER, 0, ctx->cx_data);
// OBUs are preceded/succeeded by an unsigned leb128 coded integer.
if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size,
@@ -3214,7 +3214,7 @@
int *const arg = va_arg(args, int *);
const AV1_COMP *const cpi = ctx->ppi->cpi;
if (arg == NULL) return AOM_CODEC_INVALID_PARAM;
- return av1_get_seq_level_idx(&cpi->common.seq_params, &cpi->level_params,
+ return av1_get_seq_level_idx(&cpi->common.seq_params, &cpi->ppi->level_params,
arg);
}
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 90b67f3..36c223c 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3475,7 +3475,7 @@
static uint32_t init_large_scale_tile_obu_header(
AV1_COMP *const cpi, uint8_t **data, struct aom_write_bit_buffer *saved_wb,
LargeTileFrameOBU *lst_obu) {
- AV1LevelParams *const level_params = &cpi->level_params;
+ AV1LevelParams *const level_params = &cpi->ppi->level_params;
CurrentFrame *const current_frame = &cpi->common.current_frame;
// For large_scale_tile case, we always have only one tile group, so it can
// be written as an OBU_FRAME.
@@ -3689,7 +3689,7 @@
// tile group header
const OBU_TYPE obu_type = (cpi->num_tg == 1) ? OBU_FRAME : OBU_TILE_GROUP;
*curr_tg_hdr_size = av1_write_obu_header(
- &cpi->level_params, &cpi->frame_header_count, obu_type,
+ &cpi->ppi->level_params, &cpi->frame_header_count, obu_type,
pack_bs_params->obu_extn_header, tile_data_curr);
*pack_bs_params->obu_header_size = *curr_tg_hdr_size;
@@ -3830,7 +3830,7 @@
// Rewrite the OBU header to change the OBU type to Redundant Frame
// Header.
av1_write_obu_header(
- &cpi->level_params, &cpi->frame_header_count,
+ &cpi->ppi->level_params, &cpi->frame_header_count,
OBU_REDUNDANT_FRAME_HEADER, obu_extn_header,
&tile_data_curr[fh_info->obu_header_byte_offset]);
tile_data_curr += fh_info->total_length;
@@ -3972,8 +3972,9 @@
(cm->current_frame.frame_type != KEY_FRAME &&
current_metadata->insert_flag == AOM_MIF_NON_KEY_FRAME) ||
current_metadata->insert_flag == AOM_MIF_ANY_FRAME) {
- obu_header_size = av1_write_obu_header(
- &cpi->level_params, &cpi->frame_header_count, OBU_METADATA, 0, dst);
+ obu_header_size = av1_write_obu_header(&cpi->ppi->level_params,
+ &cpi->frame_header_count,
+ OBU_METADATA, 0, dst);
obu_payload_size =
av1_write_metadata_obu(current_metadata, dst + obu_header_size);
length_field_size = obu_memmove(obu_header_size, obu_payload_size, dst);
@@ -3997,7 +3998,7 @@
uint8_t *data = dst;
uint32_t data_size;
AV1_COMMON *const cm = &cpi->common;
- AV1LevelParams *const level_params = &cpi->level_params;
+ AV1LevelParams *const level_params = &cpi->ppi->level_params;
uint32_t obu_header_size = 0;
uint32_t obu_payload_size = 0;
FrameHeaderInfo fh_info = { NULL, 0, 0 };
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index bdfdcd8..c9fa963 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -588,7 +588,7 @@
SequenceHeader *const seq_params = &cm->seq_params;
RATE_CONTROL *const rc = &cpi->rc;
MACROBLOCK *const x = &cpi->td.mb;
- AV1LevelParams *const level_params = &cpi->level_params;
+ AV1LevelParams *const level_params = &cpi->ppi->level_params;
InitialDimensions *const initial_dimensions = &cpi->initial_dimensions;
RefreshFrameFlagsInfo *const refresh_frame_flags = &cpi->refresh_frame;
const FrameDimensionCfg *const frm_dim_cfg = &cpi->oxcf.frm_dim_cfg;
@@ -1429,6 +1429,9 @@
void av1_remove_primary_compressor(AV1_PRIMARY *ppi) {
if (!ppi) return;
+ for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i) {
+ aom_free(ppi->level_params.level_info[i]);
+ }
av1_lookahead_destroy(ppi->lookahead);
aom_free(ppi);
}
@@ -3781,7 +3784,8 @@
}
}
- if (cpi->level_params.keep_level_stats && !is_stat_generation_stage(cpi)) {
+ if (cpi->ppi->level_params.keep_level_stats &&
+ !is_stat_generation_stage(cpi)) {
// Initialize level info. at the beginning of each sequence.
if (cm->current_frame.frame_type == KEY_FRAME && !cpi->no_show_fwd_kf) {
av1_init_level_info(cpi);
@@ -4055,7 +4059,7 @@
if (payload_offset + sequence_header_size > sizeof(header_buf)) return NULL;
memmove(&header_buf[payload_offset], &header_buf[0], sequence_header_size);
- if (av1_write_obu_header(&cpi->level_params, &cpi->frame_header_count,
+ if (av1_write_obu_header(&cpi->ppi->level_params, &cpi->frame_header_count,
OBU_SEQUENCE_HEADER, 0,
&header_buf[0]) != obu_header_size) {
return NULL;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 021d5ab..823e712 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -2106,6 +2106,11 @@
* Flag indicating whether look ahead processing (LAP) is enabled.
*/
int lap_enabled;
+
+ /*!
+ * Parameters for AV1 bitstream levels.
+ */
+ AV1LevelParams level_params;
} AV1_PRIMARY;
/*!
@@ -2591,11 +2596,6 @@
int frame_header_count;
/*!
- * Parameters for AV1 bitstream levels.
- */
- AV1LevelParams level_params;
-
- /*!
* Whether any no-zero delta_q was actually used.
*/
int deltaq_used;
diff --git a/av1/encoder/encoder_alloc.h b/av1/encoder/encoder_alloc.h
index d6d7a32..3655bf9 100644
--- a/av1/encoder/encoder_alloc.h
+++ b/av1/encoder/encoder_alloc.h
@@ -281,10 +281,6 @@
cpi->film_grain_table = NULL;
}
- for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i) {
- aom_free(cpi->level_params.level_info[i]);
- }
-
if (cpi->use_svc) av1_free_svc_cyclic_refresh(cpi);
if (cpi->consec_zero_mv) {
diff --git a/av1/encoder/level.c b/av1/encoder/level.c
index b56a325..1d74c2d 100644
--- a/av1/encoder/level.c
+++ b/av1/encoder/level.c
@@ -690,7 +690,7 @@
void av1_init_level_info(AV1_COMP *cpi) {
for (int op_index = 0; op_index < MAX_NUM_OPERATING_POINTS; ++op_index) {
AV1LevelInfo *const this_level_info =
- cpi->level_params.level_info[op_index];
+ cpi->ppi->level_params.level_info[op_index];
if (!this_level_info) continue;
memset(this_level_info, 0, sizeof(*this_level_info));
AV1LevelSpec *const level_spec = &this_level_info->level_spec;
@@ -1048,7 +1048,7 @@
void av1_update_level_info(AV1_COMP *cpi, size_t size, int64_t ts_start,
int64_t ts_end) {
AV1_COMMON *const cm = &cpi->common;
- const AV1LevelParams *const level_params = &cpi->level_params;
+ const AV1LevelParams *const level_params = &cpi->ppi->level_params;
const int upscaled_width = cm->superres_upscaled_width;
const int width = cm->width;
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c
index e075ed1..6c97bf0 100644
--- a/av1/encoder/pass2_strategy.c
+++ b/av1/encoder/pass2_strategy.c
@@ -845,7 +845,7 @@
}
const AV1_LEVEL target_level =
- cpi->level_params.target_seq_level_idx[index];
+ cpi->ppi->level_params.target_seq_level_idx[index];
if (target_level >= SEQ_LEVELS) continue;
assert(is_valid_seq_level_idx(target_level));