[libvpx] Update to v1.12.0

This commit is contained in:
Andrey Volk committed 2026-07-10 19:38:46 +03:00
1 parent 287a71dc66
commit b5046d2a76
572 files changed
+52900 -29493

No files matched your search

+40 -306
View File
@@ -204,19 +204,21 @@ void vp8_init3smotion_compensation(MACROBLOCK *x, int stride) {
/* returns distortion + motion vector cost */
#define ERR(r, c) (MVC(r, c) + DIST(r, c))
/* checks if (r,c) has better score than previous best */
#define CHECK_BETTER(v, r, c) \
IFMVCV(r, c, \
{ \
thismse = DIST(r, c); \
if ((v = (MVC(r, c) + thismse)) < besterr) { \
besterr = v; \
br = r; \
bc = c; \
*distortion = thismse; \
*sse1 = sse; \
} \
}, \
v = UINT_MAX;)
#define CHECK_BETTER(v, r, c) \
do { \
IFMVCV(r, c, \
{ \
thismse = DIST(r, c); \
if ((v = (MVC(r, c) + thismse)) < besterr) { \
besterr = v; \
br = r; \
bc = c; \
*distortion = thismse; \
*sse1 = sse; \
} \
}, \
v = UINT_MAX;) \
} while (0)
int vp8_find_best_sub_pixel_step_iteratively(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int_mv *bestmv, int_mv *ref_mv,
@@ -251,7 +253,7 @@ int vp8_find_best_sub_pixel_step_iteratively(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int pre_stride = x->e_mbd.pre.y_stride;
unsigned char *base_pre = x->e_mbd.pre.y_buffer;
#if ARCH_X86 || ARCH_X86_64
#if VPX_ARCH_X86 || VPX_ARCH_X86_64
MACROBLOCKD *xd = &x->e_mbd;
unsigned char *y_0 = base_pre + d->offset + (bestmv->as_mv.row) * pre_stride +
bestmv->as_mv.col;
@@ -380,7 +382,7 @@ int vp8_find_best_sub_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int pre_stride = x->e_mbd.pre.y_stride;
unsigned char *base_pre = x->e_mbd.pre.y_buffer;
#if ARCH_X86 || ARCH_X86_64
#if VPX_ARCH_X86 || VPX_ARCH_X86_64
MACROBLOCKD *xd = &x->e_mbd;
unsigned char *y_0 = base_pre + d->offset + (bestmv->as_mv.row) * pre_stride +
bestmv->as_mv.col;
@@ -676,7 +678,7 @@ int vp8_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int pre_stride = x->e_mbd.pre.y_stride;
unsigned char *base_pre = x->e_mbd.pre.y_buffer;
#if ARCH_X86 || ARCH_X86_64
#if VPX_ARCH_X86 || VPX_ARCH_X86_64
MACROBLOCKD *xd = &x->e_mbd;
unsigned char *y_0 = base_pre + d->offset + (bestmv->as_mv.row) * pre_stride +
bestmv->as_mv.col;
@@ -800,13 +802,13 @@ int vp8_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
}
#define CHECK_BOUNDS(range) \
{ \
do { \
all_in = 1; \
all_in &= ((br - range) >= x->mv_row_min); \
all_in &= ((br + range) <= x->mv_row_max); \
all_in &= ((bc - range) >= x->mv_col_min); \
all_in &= ((bc + range) <= x->mv_col_max); \
}
} while (0)
#define CHECK_POINT \
{ \
@@ -817,7 +819,7 @@ int vp8_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
}
#define CHECK_BETTER \
{ \
do { \
if (thissad < bestsad) { \
thissad += \
mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit); \
@@ -826,7 +828,7 @@ int vp8_find_best_half_pixel_step(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
best_site = i; \
} \
} \
}
} while (0)
static const MV next_chkpts[6][3] = {
{ { -2, 0 }, { -1, -2 }, { 1, -2 } }, { { -1, -2 }, { 1, -2 }, { 2, 0 } },
@@ -837,7 +839,7 @@ static const MV next_chkpts[6][3] = {
int vp8_hex_search(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
int_mv *best_mv, int search_param, int sad_per_bit,
const vp8_variance_fn_ptr_t *vfp, int *mvsadcost[2],
int *mvcost[2], int_mv *center_mv) {
int_mv *center_mv) {
MV hex[6] = {
{ -1, -2 }, { 1, -2 }, { 2, 0 }, { 1, 2 }, { -1, 2 }, { -2, 0 }
};
@@ -866,8 +868,6 @@ int vp8_hex_search(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
(void)mvcost;
/* adjust ref_mv to make sure it is within MV range */
vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min,
x->mv_row_max);
@@ -903,7 +903,7 @@ int vp8_hex_search(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
#endif
/* hex search */
CHECK_BOUNDS(2)
CHECK_BOUNDS(2);
if (all_in) {
for (i = 0; i < 6; ++i) {
@@ -912,7 +912,7 @@ int vp8_hex_search(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) +
this_mv.as_mv.col;
thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride);
CHECK_BETTER
CHECK_BETTER;
}
} else {
for (i = 0; i < 6; ++i) {
@@ -922,7 +922,7 @@ int vp8_hex_search(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) +
this_mv.as_mv.col;
thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride);
CHECK_BETTER
CHECK_BETTER;
}
}
@@ -936,7 +936,7 @@ int vp8_hex_search(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
for (j = 1; j < hex_range; ++j) {
best_site = -1;
CHECK_BOUNDS(2)
CHECK_BOUNDS(2);
if (all_in) {
for (i = 0; i < 3; ++i) {
@@ -945,7 +945,7 @@ int vp8_hex_search(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) +
this_mv.as_mv.col;
thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride);
CHECK_BETTER
CHECK_BETTER;
}
} else {
for (i = 0; i < 3; ++i) {
@@ -955,7 +955,7 @@ int vp8_hex_search(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) +
this_mv.as_mv.col;
thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride);
CHECK_BETTER
CHECK_BETTER;
}
}
@@ -977,7 +977,7 @@ int vp8_hex_search(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
cal_neighbors:
for (j = 0; j < dia_range; ++j) {
best_site = -1;
CHECK_BOUNDS(1)
CHECK_BOUNDS(1);
if (all_in) {
for (i = 0; i < 4; ++i) {
@@ -986,7 +986,7 @@ cal_neighbors:
this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) +
this_mv.as_mv.col;
thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride);
CHECK_BETTER
CHECK_BETTER;
}
} else {
for (i = 0; i < 4; ++i) {
@@ -996,7 +996,7 @@ cal_neighbors:
this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) +
this_mv.as_mv.col;
thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride);
CHECK_BETTER
CHECK_BETTER;
}
}
@@ -1129,7 +1129,7 @@ int vp8_diamond_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
}
#if HAVE_SSE2 || HAVE_MSA
#if HAVE_SSE2 || HAVE_MSA || HAVE_LSX
int vp8_diamond_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
int_mv *best_mv, int search_param, int sad_per_bit,
int *num00, vp8_variance_fn_ptr_t *fn_ptr,
@@ -1278,12 +1278,12 @@ int vp8_diamond_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
return fn_ptr->vf(what, what_stride, best_address, in_what_stride, &thissad) +
mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
}
#endif // HAVE_SSE2 || HAVE_MSA
#endif // HAVE_SSE2 || HAVE_MSA || HAVE_LSX
int vp8_full_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
int sad_per_bit, int distance,
vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2],
int_mv *center_mv) {
int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
int sad_per_bit, int distance,
vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2],
int_mv *center_mv) {
unsigned char *what = (*(b->base_src) + b->src);
int what_stride = b->src_stride;
unsigned char *in_what;
@@ -1327,8 +1327,8 @@ int vp8_full_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride) +
mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
/* Apply further limits to prevent us looking using vectors that
* stretch beyiond the UMV border
/* Apply further limits to prevent us looking using vectors that stretch
* beyond the UMV border
*/
if (col_min < x->mv_col_min) col_min = x->mv_col_min;
@@ -1345,122 +1345,6 @@ int vp8_full_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
for (c = col_min; c < col_max; ++c) {
thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride);
this_mv.as_mv.col = c;
thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
bestsad = thissad;
best_mv->as_mv.row = r;
best_mv->as_mv.col = c;
bestaddress = check_here;
}
check_here++;
}
}
this_mv.as_mv.row = best_mv->as_mv.row << 3;
this_mv.as_mv.col = best_mv->as_mv.col << 3;
return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, &thissad) +
mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
}
#if HAVE_SSSE3
int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
int sad_per_bit, int distance,
vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2],
int_mv *center_mv) {
unsigned char *what = (*(b->base_src) + b->src);
int what_stride = b->src_stride;
unsigned char *in_what;
int pre_stride = x->e_mbd.pre.y_stride;
unsigned char *base_pre = x->e_mbd.pre.y_buffer;
int in_what_stride = pre_stride;
int mv_stride = pre_stride;
unsigned char *bestaddress;
int_mv *best_mv = &d->bmi.mv;
int_mv this_mv;
unsigned int bestsad;
unsigned int thissad;
int r, c;
unsigned char *check_here;
int ref_row = ref_mv->as_mv.row;
int ref_col = ref_mv->as_mv.col;
int row_min = ref_row - distance;
int row_max = ref_row + distance;
int col_min = ref_col - distance;
int col_max = ref_col + distance;
unsigned int sad_array[3];
int *mvsadcost[2];
int_mv fcenter_mv;
mvsadcost[0] = x->mvsadcost[0];
mvsadcost[1] = x->mvsadcost[1];
fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
/* Work out the mid point for the search */
in_what = base_pre + d->offset;
bestaddress = in_what + (ref_row * pre_stride) + ref_col;
best_mv->as_mv.row = ref_row;
best_mv->as_mv.col = ref_col;
/* Baseline value at the centre */
bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride) +
mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
/* Apply further limits to prevent us looking using vectors that stretch
* beyond the UMV border
*/
if (col_min < x->mv_col_min) col_min = x->mv_col_min;
if (col_max > x->mv_col_max) col_max = x->mv_col_max;
if (row_min < x->mv_row_min) row_min = x->mv_row_min;
if (row_max > x->mv_row_max) row_max = x->mv_row_max;
for (r = row_min; r < row_max; ++r) {
this_mv.as_mv.row = r;
check_here = r * mv_stride + in_what + col_min;
c = col_min;
while ((c + 2) < col_max) {
int i;
fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array);
for (i = 0; i < 3; ++i) {
thissad = sad_array[i];
if (thissad < bestsad) {
this_mv.as_mv.col = c;
thissad +=
mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
bestsad = thissad;
best_mv->as_mv.row = r;
best_mv->as_mv.col = c;
bestaddress = check_here;
}
}
check_here++;
c++;
}
}
while (c < col_max) {
thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride);
if (thissad < bestsad) {
this_mv.as_mv.col = c;
thissad +=
@@ -1475,155 +1359,6 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
}
check_here++;
c++;
}
}
this_mv.as_mv.row = best_mv->as_mv.row << 3;
this_mv.as_mv.col = best_mv->as_mv.col << 3;
return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, &thissad) +
mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
}
#endif // HAVE_SSSE3
#if HAVE_SSE4_1
int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
int sad_per_bit, int distance,
vp8_variance_fn_ptr_t *fn_ptr, int *mvcost[2],
int_mv *center_mv) {
unsigned char *what = (*(b->base_src) + b->src);
int what_stride = b->src_stride;
int pre_stride = x->e_mbd.pre.y_stride;
unsigned char *base_pre = x->e_mbd.pre.y_buffer;
unsigned char *in_what;
int in_what_stride = pre_stride;
int mv_stride = pre_stride;
unsigned char *bestaddress;
int_mv *best_mv = &d->bmi.mv;
int_mv this_mv;
unsigned int bestsad;
unsigned int thissad;
int r, c;
unsigned char *check_here;
int ref_row = ref_mv->as_mv.row;
int ref_col = ref_mv->as_mv.col;
int row_min = ref_row - distance;
int row_max = ref_row + distance;
int col_min = ref_col - distance;
int col_max = ref_col + distance;
DECLARE_ALIGNED(16, unsigned int, sad_array8[8]);
unsigned int sad_array[3];
int *mvsadcost[2];
int_mv fcenter_mv;
mvsadcost[0] = x->mvsadcost[0];
mvsadcost[1] = x->mvsadcost[1];
fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
/* Work out the mid point for the search */
in_what = base_pre + d->offset;
bestaddress = in_what + (ref_row * pre_stride) + ref_col;
best_mv->as_mv.row = ref_row;
best_mv->as_mv.col = ref_col;
/* Baseline value at the centre */
bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride) +
mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit);
/* Apply further limits to prevent us looking using vectors that stretch
* beyond the UMV border
*/
if (col_min < x->mv_col_min) col_min = x->mv_col_min;
if (col_max > x->mv_col_max) col_max = x->mv_col_max;
if (row_min < x->mv_row_min) row_min = x->mv_row_min;
if (row_max > x->mv_row_max) row_max = x->mv_row_max;
for (r = row_min; r < row_max; ++r) {
this_mv.as_mv.row = r;
check_here = r * mv_stride + in_what + col_min;
c = col_min;
while ((c + 7) < col_max) {
int i;
fn_ptr->sdx8f(what, what_stride, check_here, in_what_stride, sad_array8);
for (i = 0; i < 8; ++i) {
thissad = sad_array8[i];
if (thissad < bestsad) {
this_mv.as_mv.col = c;
thissad +=
mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
bestsad = thissad;
best_mv->as_mv.row = r;
best_mv->as_mv.col = c;
bestaddress = check_here;
}
}
check_here++;
c++;
}
}
while ((c + 2) < col_max) {
int i;
fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array);
for (i = 0; i < 3; ++i) {
thissad = sad_array[i];
if (thissad < bestsad) {
this_mv.as_mv.col = c;
thissad +=
mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
bestsad = thissad;
best_mv->as_mv.row = r;
best_mv->as_mv.col = c;
bestaddress = check_here;
}
}
check_here++;
c++;
}
}
while (c < col_max) {
thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride);
if (thissad < bestsad) {
this_mv.as_mv.col = c;
thissad +=
mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit);
if (thissad < bestsad) {
bestsad = thissad;
best_mv->as_mv.row = r;
best_mv->as_mv.col = c;
bestaddress = check_here;
}
}
check_here++;
c++;
}
}
@@ -1633,7 +1368,6 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, &thissad) +
mv_err_cost(&this_mv, center_mv, mvcost, x->errorperbit);
}
#endif // HAVE_SSE4_1
int vp8_refining_search_sad_c(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
int_mv *ref_mv, int error_per_bit,