AV1 levels: add min frame width and height
BUG=aomedia:2332
Change-Id: Ic4e0b8d18a8923855e545a22e360be3abfe250b8
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 7716ee2..818e43c 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2556,6 +2556,8 @@
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->min_frame_width = INT_MAX;
+ level_stats->min_frame_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 57e61b0..1668bdf 100644
--- a/av1/encoder/level.c
+++ b/av1/encoder/level.c
@@ -221,6 +221,8 @@
LUMA_PIC_SIZE_TOO_LARGE,
LUMA_PIC_H_SIZE_TOO_LARGE,
LUMA_PIC_V_SIZE_TOO_LARGE,
+ LUMA_PIC_H_SIZE_TOO_SMALL,
+ LUMA_PIC_V_SIZE_TOO_SMALL,
TOO_MANY_TILE_COLUMNS,
TOO_MANY_TILES,
TILE_RATE_TOO_HIGH,
@@ -242,6 +244,8 @@
"The picture size is too large.",
"The picture width is too large.",
"The picture height is too large.",
+ "The picture width is too small.",
+ "The picture height is too small.",
"Too many tile columns are used.",
"Too many tiles are used.",
"The tile rate is too high.",
@@ -339,6 +343,16 @@
break;
}
+ if (level_stats->min_frame_width < 16) {
+ fail_id = LUMA_PIC_H_SIZE_TOO_SMALL;
+ break;
+ }
+
+ if (level_stats->min_frame_height < 16) {
+ fail_id = LUMA_PIC_V_SIZE_TOO_SMALL;
+ break;
+ }
+
if (!level_stats->tile_width_is_valid) {
fail_id = TILE_WIDTH_INVALID;
break;
@@ -495,6 +509,7 @@
int64_t ts_end) {
AV1_COMMON *const cm = &cpi->common;
const int upscaled_width = cm->superres_upscaled_width;
+ const int width = cm->width;
const int height = cm->height;
const int tile_cols = cm->tile_cols;
const int tile_rows = cm->tile_rows;
@@ -559,6 +574,9 @@
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->min_frame_width = AOMMIN(level_stats->min_frame_width, width);
+ level_stats->min_frame_height =
+ AOMMIN(level_stats->min_frame_height, height);
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);
diff --git a/av1/encoder/level.h b/av1/encoder/level.h
index 097ea1d..9f1664d 100644
--- a/av1/encoder/level.h
+++ b/av1/encoder/level.h
@@ -60,6 +60,8 @@
int min_cropped_tile_width;
int min_cropped_tile_height;
int tile_width_is_valid;
+ int min_frame_width;
+ int min_frame_height;
double total_time_encoded;
double min_cr;
} AV1LevelStats;