Commit 47500a16ce for aom
commit 47500a16ce592afef0c86ce2c147d0894ce93455
Author: Wan-Teh Chang <wtc@google.com>
Date: Mon Mar 30 20:42:14 2026 -0700
Convert some assert() to static_assert()
Change-Id: Id6526814c3d0e3f29bb959561243444ed9bb25b4
diff --git a/aom_dsp/x86/quantize_x86.h b/aom_dsp/x86/quantize_x86.h
index 217989e7ab..deef583379 100644
--- a/aom_dsp/x86/quantize_x86.h
+++ b/aom_dsp/x86/quantize_x86.h
@@ -9,6 +9,7 @@
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
+#include <assert.h>
#include <emmintrin.h>
#include "aom/aom_integer.h"
@@ -125,7 +126,7 @@ static inline int16_t accumulate_eob(__m128i eob) {
}
static inline __m128i load_coefficients(const tran_low_t *coeff_ptr) {
- assert(sizeof(tran_low_t) == 4);
+ static_assert(sizeof(tran_low_t) == 4, "");
const __m128i coeff1 = _mm_load_si128((__m128i *)(coeff_ptr));
const __m128i coeff2 = _mm_load_si128((__m128i *)(coeff_ptr + 4));
return _mm_packs_epi32(coeff1, coeff2);
@@ -133,7 +134,7 @@ static inline __m128i load_coefficients(const tran_low_t *coeff_ptr) {
static inline void store_coefficients(__m128i coeff_vals,
tran_low_t *coeff_ptr) {
- assert(sizeof(tran_low_t) == 4);
+ static_assert(sizeof(tran_low_t) == 4, "");
__m128i one = _mm_set1_epi16(1);
__m128i coeff_vals_hi = _mm_mulhi_epi16(coeff_vals, one);
diff --git a/av1/common/common.h b/av1/common/common.h
index 8bcfed933f..598db30e76 100644
--- a/av1/common/common.h
+++ b/av1/common/common.h
@@ -27,17 +27,17 @@ extern "C" {
#endif
// Only need this for fixed-size arrays, for structs just assign.
-#define av1_copy(dest, src) \
- do { \
- assert(sizeof(dest) == sizeof(src)); \
- memcpy(dest, src, sizeof(src)); \
+#define av1_copy(dest, src) \
+ do { \
+ static_assert(sizeof(dest) == sizeof(src), ""); \
+ memcpy(dest, src, sizeof(src)); \
} while (0)
// Use this for variably-sized arrays.
-#define av1_copy_array(dest, src, n) \
- do { \
- assert(sizeof(*(dest)) == sizeof(*(src))); \
- memcpy(dest, src, n * sizeof(*(src))); \
+#define av1_copy_array(dest, src, n) \
+ do { \
+ static_assert(sizeof(*(dest)) == sizeof(*(src)), ""); \
+ memcpy(dest, src, n * sizeof(*(src))); \
} while (0)
#define av1_zero(dest) memset(&(dest), 0, sizeof(dest))
diff --git a/av1/common/idct.h b/av1/common/idct.h
index c02b70ef15..2dda093a68 100644
--- a/av1/common/idct.h
+++ b/av1/common/idct.h
@@ -12,6 +12,8 @@
#ifndef AOM_AV1_COMMON_IDCT_H_
#define AOM_AV1_COMMON_IDCT_H_
+#include <assert.h>
+
#include "config/aom_config.h"
#include "av1/common/blockd.h"
@@ -40,7 +42,7 @@ void av1_highbd_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
int eob, int bd);
static inline const int32_t *cast_to_int32(const tran_low_t *input) {
- assert(sizeof(int32_t) == sizeof(tran_low_t));
+ static_assert(sizeof(int32_t) == sizeof(tran_low_t), "");
return (const int32_t *)input;
}