aom_ports/mem: add ALIGN_POWER_OF_TWO_UNSIGNED
and use it in av1_cx_iface.c and av1_dx_iface.c.
w/clang -fsanitize=integer quiets warnings of the form:
implicit conversion from type 'int' of value -1 (32-bit, signed) to type
'unsigned int' changed the value to 4294967295 (32-bit, unsigned)
Bug: aomedia:3136
Bug: b/229626362
Change-Id: I5b237fafa5018597ca8488deab8f3ac09ca5c5c9
diff --git a/aom_ports/mem.h b/aom_ports/mem.h
index e9bb8ad..e396842 100644
--- a/aom_ports/mem.h
+++ b/aom_ports/mem.h
@@ -71,6 +71,8 @@
#define ALIGN_POWER_OF_TWO(value, n) \
(((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
+#define ALIGN_POWER_OF_TWO_UNSIGNED(value, n) \
+ (((value) + ((1u << (n)) - 1)) & ~((1u << (n)) - 1))
#define DIVIDE_AND_ROUND(x, y) (((x) + ((y) >> 1)) / (y))
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 85ab9f3..5f67fd4 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -2757,9 +2757,10 @@
if (img != NULL) {
res = validate_img(ctx, img);
if (res == AOM_CODEC_OK) {
- const size_t uncompressed_frame_sz = ALIGN_POWER_OF_TWO(ctx->cfg.g_w, 5) *
- ALIGN_POWER_OF_TWO(ctx->cfg.g_h, 5) *
- av1_get_image_bps(img) / 8;
+ const size_t uncompressed_frame_sz =
+ ALIGN_POWER_OF_TWO_UNSIGNED(ctx->cfg.g_w, 5) *
+ ALIGN_POWER_OF_TWO_UNSIGNED(ctx->cfg.g_h, 5) *
+ av1_get_image_bps(img) / 8;
// Due to the presence of no-show frames, the ctx->cx_data buffer holds
// compressed data corresponding to multiple frames. As no-show frames are
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index cb5c6e3..2567475 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -745,8 +745,8 @@
aom_film_grain_t *grain_params) {
if (!grain_params->apply_grain) return img;
- const int w_even = ALIGN_POWER_OF_TWO(img->d_w, 1);
- const int h_even = ALIGN_POWER_OF_TWO(img->d_h, 1);
+ const int w_even = ALIGN_POWER_OF_TWO_UNSIGNED(img->d_w, 1);
+ const int h_even = ALIGN_POWER_OF_TWO_UNSIGNED(img->d_h, 1);
BufferPool *const pool = ctx->buffer_pool;
aom_codec_frame_buffer_t *fb =