resize-refactor: Make av1_set_size_literal use int
av1_set_size_literal took unsigned ints as its size inputs. This was
inconsistent with elsewhere in the code base so this change makes it
take signed ints instead.
Change-Id: I5f39f813714f5d6cb1fc93f928f33b3633b653ec
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index bf1c333..f9e770e 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -5993,8 +5993,7 @@
return 0;
}
-int av1_set_size_literal(AV1_COMP *cpi, unsigned int width,
- unsigned int height) {
+int av1_set_size_literal(AV1_COMP *cpi, int width, int height) {
AV1_COMMON *cm = &cpi->common;
#if CONFIG_HIGHBITDEPTH
check_initial_width(cpi, cm->use_highbitdepth, 1, 1);
@@ -6002,21 +6001,20 @@
check_initial_width(cpi, 1, 1);
#endif // CONFIG_HIGHBITDEPTH
- if (width) {
- cm->width = width;
- if (cm->width > cpi->initial_width) {
- cm->width = cpi->initial_width;
- printf("Warning: Desired width too large, changed to %d\n", cm->width);
- }
+ if (width <= 0 || height <= 0) return 1;
+
+ cm->width = width;
+ if (cm->width > cpi->initial_width) {
+ cm->width = cpi->initial_width;
+ printf("Warning: Desired width too large, changed to %d\n", cm->width);
}
- if (height) {
- cm->height = height;
- if (cm->height > cpi->initial_height) {
- cm->height = cpi->initial_height;
- printf("Warning: Desired height too large, changed to %d\n", cm->height);
- }
+ cm->height = height;
+ if (cm->height > cpi->initial_height) {
+ cm->height = cpi->initial_height;
+ printf("Warning: Desired height too large, changed to %d\n", cm->height);
}
+
assert(cm->width <= cpi->initial_width);
assert(cm->height <= cpi->initial_height);
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 164a6d9..8c82197 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -714,8 +714,8 @@
int av1_set_internal_size(AV1_COMP *cpi, AOM_SCALING horiz_mode,
AOM_SCALING vert_mode);
-int av1_set_size_literal(AV1_COMP *cpi, unsigned int width,
- unsigned int height);
+// Returns 1 if the assigned width or height was <= 0.
+int av1_set_size_literal(AV1_COMP *cpi, int width, int height);
int av1_get_quantizer(struct AV1_COMP *cpi);