Commit 2eb6abc83e for aom
commit 2eb6abc83e0059c8baee58830561f1a451eb2483
Author: James Zern <jzern@google.com>
Date: Thu Jul 23 16:21:14 2026 -0700
rm aom_highbd_calc_variance_stat() in non-hbd builds
Change-Id: I1c84b8446cede6009c3bcfebf958723f168f4a25
diff --git a/aom_dsp/aom_dsp_rtcd_defs.pl b/aom_dsp/aom_dsp_rtcd_defs.pl
index 0abd0137c6..5c274aaa9e 100755
--- a/aom_dsp/aom_dsp_rtcd_defs.pl
+++ b/aom_dsp/aom_dsp_rtcd_defs.pl
@@ -1388,8 +1388,10 @@ if (aom_config("CONFIG_AV1_ENCODER") eq "yes") {
add_proto qw/int64_t/, "aom_calc_variance_stat", "const uint8_t *src, int stride, int bw, int bh";
specialize qw/aom_calc_variance_stat avx2/;
- add_proto qw/int64_t/, "aom_highbd_calc_variance_stat", "const uint16_t *src, int stride, int bw, int bh";
- specialize qw/aom_highbd_calc_variance_stat avx2/;
+ if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+ add_proto qw/int64_t/, "aom_highbd_calc_variance_stat", "const uint16_t *src, int stride, int bw, int bh";
+ specialize qw/aom_highbd_calc_variance_stat avx2/;
+ }
add_proto qw/uint64_t/, "aom_mse_16xh_16bit", "uint8_t *dst, int dstride,uint16_t *src, int w, int h";
specialize qw/aom_mse_16xh_16bit sse2 avx2 neon/;
diff --git a/aom_dsp/variance.c b/aom_dsp/variance.c
index 04096527a3..e360741ebf 100644
--- a/aom_dsp/variance.c
+++ b/aom_dsp/variance.c
@@ -1145,6 +1145,7 @@ int64_t aom_calc_variance_stat_c(const uint8_t *src, int stride, int bw,
return var_stats;
}
+#if CONFIG_AV1_HIGHBITDEPTH
int64_t aom_highbd_calc_variance_stat_c(const uint16_t *src, int stride, int bw,
int bh) {
DECLARE_ALIGNED(16, uint16_t, dclevel[(MAX_SB_SIZE + 2) * (MAX_SB_SIZE + 2)]);
@@ -1192,7 +1193,6 @@ int64_t aom_highbd_calc_variance_stat_c(const uint16_t *src, int stride, int bw,
return var_stats;
}
-#if CONFIG_AV1_HIGHBITDEPTH
uint64_t aom_mse_wxh_16bit_highbd_c(uint16_t *dst, int dstride, uint16_t *src,
int sstride, int w, int h) {
uint64_t sum = 0;
diff --git a/aom_dsp/x86/variance_avx2.c b/aom_dsp/x86/variance_avx2.c
index 9b264c83aa..f74eb95154 100644
--- a/aom_dsp/x86/variance_avx2.c
+++ b/aom_dsp/x86/variance_avx2.c
@@ -1131,6 +1131,7 @@ int64_t aom_calc_variance_stat_avx2(const uint8_t *src, int stride, int bw,
return total_var << 4;
}
+#if CONFIG_AV1_HIGHBITDEPTH
static inline int64_t yy_hsum_epi64_si64(__m256i v) {
__m128i v128 =
_mm_add_epi64(_mm256_castsi256_si128(v), _mm256_extracti128_si256(v, 1));
@@ -1310,6 +1311,7 @@ int64_t aom_highbd_calc_variance_stat_avx2(const uint16_t *src, int stride,
return total_var << 4;
}
+#endif // CONFIG_AV1_HIGHBITDEPTH
void aom_get_var_sse_sum_8x8_quad_avx2(const uint8_t *src_ptr,
int source_stride,
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 5d00742bce..5f0edb1872 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -621,6 +621,7 @@ void av1_get_horver_correlation_full_c(const int16_t *diff, int stride,
}
}
+#if CONFIG_AV1_HIGHBITDEPTH
static void get_variance_stats_hbd(const MACROBLOCK *x, int64_t *src_var,
int64_t *rec_var) {
const MACROBLOCKD *xd = &x->e_mbd;
@@ -637,9 +638,16 @@ static void get_variance_stats_hbd(const MACROBLOCK *x, int64_t *src_var,
*src_var = aom_highbd_calc_variance_stat(CONVERT_TO_SHORTPTR(p->src.buf),
p->src.stride, bw, bh);
}
+#endif // CONFIG_AV1_HIGHBITDEPTH
static void get_variance_stats(const MACROBLOCK *x, int64_t *src_var,
int64_t *rec_var) {
+#if CONFIG_AV1_HIGHBITDEPTH
+ if (is_cur_buf_hbd(&x->e_mbd)) {
+ get_variance_stats_hbd(x, src_var, rec_var);
+ return;
+ }
+#endif // CONFIG_AV1_HIGHBITDEPTH
const MACROBLOCKD *xd = &x->e_mbd;
const MB_MODE_INFO *mbmi = xd->mi[0];
const struct macroblockd_plane *const pd = &xd->plane[AOM_PLANE_Y];
@@ -681,12 +689,7 @@ static void adjust_rdcost(const AV1_COMP *cpi, const MACROBLOCK *x,
if (frame_is_kf_gf_arf(cpi)) return;
int64_t src_var, rec_var;
-
- const bool is_hbd = is_cur_buf_hbd(&x->e_mbd);
- if (is_hbd)
- get_variance_stats_hbd(x, &src_var, &rec_var);
- else
- get_variance_stats(x, &src_var, &rec_var);
+ get_variance_stats(x, &src_var, &rec_var);
if (src_var <= rec_var) return;
@@ -711,12 +714,7 @@ static void adjust_cost(const AV1_COMP *cpi, const MACROBLOCK *x,
if (frame_is_kf_gf_arf(cpi)) return;
int64_t src_var, rec_var;
- const bool is_hbd = is_cur_buf_hbd(&x->e_mbd);
-
- if (is_hbd)
- get_variance_stats_hbd(x, &src_var, &rec_var);
- else
- get_variance_stats(x, &src_var, &rec_var);
+ get_variance_stats(x, &src_var, &rec_var);
if (src_var <= rec_var) return;