Move some data from AV1LevelSpec to AV1LevelStats
Some metrics are not level-dependent. For example, the min cropped tile
width is 8 for all levels. Move these data to AV1LevelStats instead.
BUG=aomedia:2332
Change-Id: I6bc5fc6ae597828bc10ffc55663b5c5af5f9aa92
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index b4381cb..7716ee2 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2553,10 +2553,10 @@
for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i) {
AV1LevelSpec *const level_spec = &level_info[i].level_spec;
level_spec->level = SEQ_LEVEL_MAX;
- level_spec->min_cropped_tile_width = INT_MAX;
- level_spec->min_cropped_tile_height = INT_MAX;
- level_spec->tile_width_is_valid = 1;
AV1LevelStats *const level_stats = &level_info[i].level_stats;
+ level_stats->min_cropped_tile_width = INT_MAX;
+ level_stats->min_cropped_tile_height = INT_MAX;
+ level_stats->tile_width_is_valid = 1;
level_stats->min_cr = 1e8;
}
}
diff --git a/av1/encoder/level.c b/av1/encoder/level.c
index 1746267..be5099f 100644
--- a/av1/encoder/level.c
+++ b/av1/encoder/level.c
@@ -302,26 +302,6 @@
break;
}
- if (level_spec->max_tile_size > 4096 * 2304) {
- fail_id = TILE_TOO_LARGE;
- break;
- }
-
- if (level_spec->min_cropped_tile_width < 8) {
- fail_id = CROPPED_TILE_WIDTH_TOO_SMALL;
- break;
- }
-
- if (level_spec->min_cropped_tile_height < 8) {
- fail_id = CROPPED_TILE_HEIGHT_TOO_SMALL;
- break;
- }
-
- if (!level_spec->tile_width_is_valid) {
- fail_id = TILE_WIDTH_INVALID;
- break;
- }
-
if (level_spec->max_header_rate > target_level_spec->max_header_rate) {
fail_id = FRAME_HEADER_RATE_TOO_HIGH;
break;
@@ -337,6 +317,26 @@
break;
}
+ if (level_stats->max_tile_size > 4096 * 2304) {
+ fail_id = TILE_TOO_LARGE;
+ break;
+ }
+
+ if (level_stats->min_cropped_tile_width < 8) {
+ fail_id = CROPPED_TILE_WIDTH_TOO_SMALL;
+ break;
+ }
+
+ if (level_stats->min_cropped_tile_height < 8) {
+ fail_id = CROPPED_TILE_HEIGHT_TOO_SMALL;
+ break;
+ }
+
+ if (!level_stats->tile_width_is_valid) {
+ fail_id = TILE_WIDTH_INVALID;
+ break;
+ }
+
if (level_stats->min_cr < min_cr) {
fail_id = CR_TOO_SMALL;
break;
@@ -537,6 +537,13 @@
AV1LevelInfo *const level_info = &cpi->level_info[i];
AV1LevelStats *const level_stats = &level_info->level_stats;
+ level_stats->max_tile_size =
+ AOMMAX(level_stats->max_tile_size, max_tile_size);
+ level_stats->min_cropped_tile_width =
+ AOMMIN(level_stats->min_cropped_tile_width, min_cropped_tile_width);
+ level_stats->min_cropped_tile_height =
+ AOMMIN(level_stats->min_cropped_tile_height, min_cropped_tile_height);
+ level_stats->tile_width_is_valid &= tile_width_is_valid;
level_stats->total_compressed_size += frame_compressed_size;
if (show_frame) level_stats->total_time_encoded = total_time_encoded;
level_stats->min_cr = AOMMIN(level_stats->min_cr, compression_ratio);
@@ -551,13 +558,6 @@
level_spec->max_v_size = AOMMAX(level_spec->max_v_size, height);
level_spec->max_tile_cols = AOMMAX(level_spec->max_tile_cols, tile_cols);
level_spec->max_tiles = AOMMAX(level_spec->max_tiles, tiles);
- level_spec->max_tile_size =
- AOMMAX(level_spec->max_tile_size, max_tile_size);
- level_spec->min_cropped_tile_width =
- AOMMIN(level_spec->min_cropped_tile_width, min_cropped_tile_width);
- level_spec->min_cropped_tile_height =
- AOMMIN(level_spec->min_cropped_tile_height, min_cropped_tile_height);
- level_spec->tile_width_is_valid &= tile_width_is_valid;
if (show_frame) {
scan_past_frames(buffer, encoded_frames_in_last_second, level_spec);
diff --git a/av1/encoder/level.h b/av1/encoder/level.h
index 9178e12..8fff600 100644
--- a/av1/encoder/level.h
+++ b/av1/encoder/level.h
@@ -25,10 +25,6 @@
int max_header_rate;
int max_tiles;
int max_tile_cols;
- int max_tile_size;
- int min_cropped_tile_width;
- int min_cropped_tile_height;
- int tile_width_is_valid;
int64_t max_display_rate;
int64_t max_decode_rate;
double main_mbps;
@@ -57,6 +53,10 @@
// Used to keep track of AV1 Level Stats. Currently unimplemented.
typedef struct {
uint64_t total_compressed_size;
+ int max_tile_size;
+ int min_cropped_tile_width;
+ int min_cropped_tile_height;
+ int tile_width_is_valid;
double total_time_encoded;
double min_cr;
} AV1LevelStats;