Skip to content

Commit

Permalink
Use vpx_sse instead of vpx_mse to compute SSE
Browse files Browse the repository at this point in the history
Use vpx_sse and vpx_highbd_sse instead of vpx_mse16x16 and
vpx_highbd_8_mse16x16 respectively to compute SSE for PSNR
calculations. This solves an issue whereby vpx_highbd_8_mse16x16
was being used to calculate SSE for 10- and 12-bit input.

This is a port of the libaom CL
https://aomedia-review.googlesource.com/c/aom/+/175063
by Jonathan Wright <[email protected]>.

Bug: webm:1819
Change-Id: I37e3ac72835e67ccb44ac89a4ed16df62c2169a7
  • Loading branch information
wantehchang committed Dec 5, 2023
1 parent 4c2435c commit 7dfe343
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions vpx_dsp/psnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ static int64_t encoder_sse(const uint8_t *a, int a_stride, const uint8_t *b,
}

#if CONFIG_VP9_HIGHBITDEPTH
static int64_t encoder_highbd_8_sse(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride, int w,
int h) {
static int64_t encoder_highbd_sse(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride, int w,
int h) {
int i, j;
int64_t sse = 0;

uint16_t *a = CONVERT_TO_SHORTPTR(a8);
uint16_t *b = CONVERT_TO_SHORTPTR(b8);
const uint16_t *a = CONVERT_TO_SHORTPTR(a8);
const uint16_t *b = CONVERT_TO_SHORTPTR(b8);

for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
Expand Down Expand Up @@ -88,10 +88,8 @@ static int64_t get_sse(const uint8_t *a, int a_stride, const uint8_t *b,
for (y = 0; y < height / 16; ++y) {
const uint8_t *pa = a;
const uint8_t *pb = b;
unsigned int sse;
for (x = 0; x < width / 16; ++x) {
vpx_mse16x16(pa, a_stride, pb, b_stride, &sse);
total_sse += sse;
total_sse += vpx_sse(pa, a_stride, pb, b_stride, 16, 16);

pa += 16;
pb += 16;
Expand Down Expand Up @@ -131,21 +129,19 @@ static int64_t highbd_get_sse(const uint8_t *a, int a_stride, const uint8_t *b,
const int dw = width % 16;
const int dh = height % 16;
if (dw > 0) {
total_sse += encoder_highbd_8_sse(&a[width - dw], a_stride, &b[width - dw],
b_stride, dw, height);
total_sse += encoder_highbd_sse(&a[width - dw], a_stride, &b[width - dw],
b_stride, dw, height);
}
if (dh > 0) {
total_sse += encoder_highbd_8_sse(&a[(height - dh) * a_stride], a_stride,
&b[(height - dh) * b_stride], b_stride,
width - dw, dh);
total_sse += encoder_highbd_sse(&a[(height - dh) * a_stride], a_stride,
&b[(height - dh) * b_stride], b_stride,
width - dw, dh);
}
for (y = 0; y < height / 16; ++y) {
const uint8_t *pa = a;
const uint8_t *pb = b;
unsigned int sse;
for (x = 0; x < width / 16; ++x) {
vpx_highbd_8_mse16x16(pa, a_stride, pb, b_stride, &sse);
total_sse += sse;
total_sse += vpx_highbd_sse(pa, a_stride, pb, b_stride, 16, 16);
pa += 16;
pb += 16;
}
Expand Down

0 comments on commit 7dfe343

Please sign in to comment.