diff --git a/vpx_dsp/ssim.c b/vpx_dsp/ssim.c index c795a9313..e69c8131b 100644 --- a/vpx_dsp/ssim.c +++ b/vpx_dsp/ssim.c @@ -13,7 +13,7 @@ #include "vpx_dsp/ssim.h" #include "vpx_ports/mem.h" -void vpx_ssim_parms_16x16_c(uint8_t *s, int sp, uint8_t *r, +void vpx_ssim_parms_16x16_c(const uint8_t *s, int sp, const uint8_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr) { @@ -28,7 +28,7 @@ void vpx_ssim_parms_16x16_c(uint8_t *s, int sp, uint8_t *r, } } } -void vpx_ssim_parms_8x8_c(uint8_t *s, int sp, uint8_t *r, int rp, +void vpx_ssim_parms_8x8_c(const uint8_t *s, int sp, const uint8_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr) { @@ -45,7 +45,8 @@ void vpx_ssim_parms_8x8_c(uint8_t *s, int sp, uint8_t *r, int rp, } #if CONFIG_VP9_HIGHBITDEPTH -void vpx_highbd_ssim_parms_8x8_c(uint16_t *s, int sp, uint16_t *r, int rp, +void vpx_highbd_ssim_parms_8x8_c(const uint16_t *s, int sp, + const uint16_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr) { @@ -85,7 +86,7 @@ static double similarity(uint32_t sum_s, uint32_t sum_r, return ssim_n * 1.0 / ssim_d; } -static double ssim_8x8(uint8_t *s, int sp, uint8_t *r, int rp) { +static double ssim_8x8(const uint8_t *s, int sp, const uint8_t *r, int rp) { uint32_t sum_s = 0, sum_r = 0, sum_sq_s = 0, sum_sq_r = 0, sum_sxr = 0; vpx_ssim_parms_8x8(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r, &sum_sxr); @@ -93,8 +94,8 @@ static double ssim_8x8(uint8_t *s, int sp, uint8_t *r, int rp) { } #if CONFIG_VP9_HIGHBITDEPTH -static double highbd_ssim_8x8(uint16_t *s, int sp, uint16_t *r, int rp, - unsigned int bd) { +static double highbd_ssim_8x8(const uint16_t *s, int sp, const uint16_t *r, + int rp, unsigned int bd) { uint32_t sum_s = 0, sum_r = 0, sum_sq_s = 0, sum_sq_r = 0, sum_sxr = 0; const int oshift = bd - 8; vpx_highbd_ssim_parms_8x8(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r, @@ -111,8 +112,9 @@ static double highbd_ssim_8x8(uint16_t *s, int sp, uint16_t *r, int rp, // We are using a 8x8 moving window with starting location of each 8x8 window // on the 4x4 pixel grid. Such arrangement allows the windows to overlap // block boundaries to penalize blocking artifacts. -double vpx_ssim2(uint8_t *img1, uint8_t *img2, int stride_img1, - int stride_img2, int width, int height) { +static double vpx_ssim2(const uint8_t *img1, const uint8_t *img2, + int stride_img1, int stride_img2, int width, + int height) { int i, j; int samples = 0; double ssim_total = 0; @@ -131,9 +133,9 @@ double vpx_ssim2(uint8_t *img1, uint8_t *img2, int stride_img1, } #if CONFIG_VP9_HIGHBITDEPTH -double vpx_highbd_ssim2(uint8_t *img1, uint8_t *img2, int stride_img1, - int stride_img2, int width, int height, - unsigned int bd) { +static double vpx_highbd_ssim2(const uint8_t *img1, const uint8_t *img2, + int stride_img1, int stride_img2, int width, + int height, unsigned int bd) { int i, j; int samples = 0; double ssim_total = 0; @@ -154,7 +156,8 @@ double vpx_highbd_ssim2(uint8_t *img1, uint8_t *img2, int stride_img1, } #endif // CONFIG_VP9_HIGHBITDEPTH -double vpx_calc_ssim(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, +double vpx_calc_ssim(const YV12_BUFFER_CONFIG *source, + const YV12_BUFFER_CONFIG *dest, double *weight) { double a, b, c; double ssimv; @@ -178,7 +181,8 @@ double vpx_calc_ssim(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, return ssimv; } -double vpx_calc_ssimg(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, +double vpx_calc_ssimg(const YV12_BUFFER_CONFIG *source, + const YV12_BUFFER_CONFIG *dest, double *ssim_y, double *ssim_u, double *ssim_v) { double ssim_all = 0; double a, b, c; @@ -231,7 +235,7 @@ double vpx_calc_ssimg(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, // Replace c1 with n*n * c1 for the final step that leads to this code: // The final step scales by 12 bits so we don't lose precision in the constants. -double ssimv_similarity(Ssimv *sv, int64_t n) { +static double ssimv_similarity(const Ssimv *sv, int64_t n) { // Scale the constants by number of pixels. const int64_t c1 = (cc1 * n * n) >> 12; const int64_t c2 = (cc2 * n * n) >> 12; @@ -262,7 +266,7 @@ double ssimv_similarity(Ssimv *sv, int64_t n) { // // 255 * 255 - (sum_s - sum_r) / count * (sum_s - sum_r) / count // -double ssimv_similarity2(Ssimv *sv, int64_t n) { +static double ssimv_similarity2(const Ssimv *sv, int64_t n) { // Scale the constants by number of pixels. const int64_t c1 = (cc1 * n * n) >> 12; const int64_t c2 = (cc2 * n * n) >> 12; @@ -278,8 +282,8 @@ double ssimv_similarity2(Ssimv *sv, int64_t n) { return l * v; } -void ssimv_parms(uint8_t *img1, int img1_pitch, uint8_t *img2, int img2_pitch, - Ssimv *sv) { +static void ssimv_parms(uint8_t *img1, int img1_pitch, uint8_t *img2, + int img2_pitch, Ssimv *sv) { vpx_ssim_parms_8x8(img1, img1_pitch, img2, img2_pitch, &sv->sum_s, &sv->sum_r, &sv->sum_sq_s, &sv->sum_sq_r, &sv->sum_sxr); @@ -448,8 +452,8 @@ double vpx_get_ssim_metrics(uint8_t *img1, int img1_pitch, #if CONFIG_VP9_HIGHBITDEPTH -double vpx_highbd_calc_ssim(YV12_BUFFER_CONFIG *source, - YV12_BUFFER_CONFIG *dest, +double vpx_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source, + const YV12_BUFFER_CONFIG *dest, double *weight, unsigned int bd) { double a, b, c; double ssimv; @@ -473,8 +477,8 @@ double vpx_highbd_calc_ssim(YV12_BUFFER_CONFIG *source, return ssimv; } -double vpx_highbd_calc_ssimg(YV12_BUFFER_CONFIG *source, - YV12_BUFFER_CONFIG *dest, double *ssim_y, +double vpx_highbd_calc_ssimg(const YV12_BUFFER_CONFIG *source, + const YV12_BUFFER_CONFIG *dest, double *ssim_y, double *ssim_u, double *ssim_v, unsigned int bd) { double ssim_all = 0; double a, b, c; diff --git a/vpx_dsp/ssim.h b/vpx_dsp/ssim.h index 47c48788f..d25e7145d 100644 --- a/vpx_dsp/ssim.h +++ b/vpx_dsp/ssim.h @@ -72,10 +72,12 @@ double vpx_get_ssim_metrics(uint8_t *img1, int img1_pitch, uint8_t *img2, int img2_pitch, int width, int height, Ssimv *sv2, Metrics *m, int do_inconsistency); -double vpx_calc_ssim(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, +double vpx_calc_ssim(const YV12_BUFFER_CONFIG *source, + const YV12_BUFFER_CONFIG *dest, double *weight); -double vpx_calc_ssimg(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, +double vpx_calc_ssimg(const YV12_BUFFER_CONFIG *source, + const YV12_BUFFER_CONFIG *dest, double *ssim_y, double *ssim_u, double *ssim_v); double vpx_calc_fastssim(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, @@ -86,13 +88,13 @@ double vpx_psnrhvs(const YV12_BUFFER_CONFIG *source, double *ssim_y, double *ssim_u, double *ssim_v); #if CONFIG_VP9_HIGHBITDEPTH -double vpx_highbd_calc_ssim(YV12_BUFFER_CONFIG *source, - YV12_BUFFER_CONFIG *dest, +double vpx_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source, + const YV12_BUFFER_CONFIG *dest, double *weight, unsigned int bd); -double vpx_highbd_calc_ssimg(YV12_BUFFER_CONFIG *source, - YV12_BUFFER_CONFIG *dest, +double vpx_highbd_calc_ssimg(const YV12_BUFFER_CONFIG *source, + const YV12_BUFFER_CONFIG *dest, double *ssim_y, double *ssim_u, double *ssim_v, diff --git a/vpx_dsp/vpx_dsp_rtcd_defs.pl b/vpx_dsp/vpx_dsp_rtcd_defs.pl index f1a366c3f..6c8420e8b 100644 --- a/vpx_dsp/vpx_dsp_rtcd_defs.pl +++ b/vpx_dsp/vpx_dsp_rtcd_defs.pl @@ -994,10 +994,10 @@ specialize qw/vpx_sad4x4x4d msa/, "$sse_x86inc"; # Structured Similarity (SSIM) # if (vpx_config("CONFIG_INTERNAL_STATS") eq "yes") { - add_proto qw/void vpx_ssim_parms_8x8/, "uint8_t *s, int sp, uint8_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr"; + add_proto qw/void vpx_ssim_parms_8x8/, "const uint8_t *s, int sp, const uint8_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr"; specialize qw/vpx_ssim_parms_8x8/, "$sse2_x86_64"; - add_proto qw/void vpx_ssim_parms_16x16/, "uint8_t *s, int sp, uint8_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr"; + add_proto qw/void vpx_ssim_parms_16x16/, "const uint8_t *s, int sp, const uint8_t *r, int rp, uint32_t *sum_s, uint32_t *sum_r, uint32_t *sum_sq_s, uint32_t *sum_sq_r, uint32_t *sum_sxr"; specialize qw/vpx_ssim_parms_16x16/, "$sse2_x86_64"; }