shithub: libvpx

Download patch

ref: c65e79d2e5d0d0ff42d17198ca9f5960e802ea55
parent: 17cfee3cb55b016aa2c1677bdebb9d2b8d0d7f3d
author: Alex Converse <[email protected]>
date: Thu Aug 6 09:46:28 EDT 2015

ssim: Replace unsigned long with uint32_t.

The assembly only writes the low 4 bytes, and the HBD version only uses
uint32_t bytes.

Change-Id: Ie3694ecda511c231e55870df814cbae30e588073

--- a/vpx_dsp/ssim.c
+++ b/vpx_dsp/ssim.c
@@ -14,9 +14,9 @@
 #include "vpx_ports/mem.h"
 
 void vpx_ssim_parms_16x16_c(uint8_t *s, int sp, uint8_t *r,
-                            int rp, unsigned long *sum_s, unsigned long *sum_r,
-                            unsigned long *sum_sq_s, unsigned long *sum_sq_r,
-                            unsigned long *sum_sxr) {
+                            int rp, uint32_t *sum_s, uint32_t *sum_r,
+                            uint32_t *sum_sq_s, uint32_t *sum_sq_r,
+                            uint32_t *sum_sxr) {
   int i, j;
   for (i = 0; i < 16; i++, s += sp, r += rp) {
     for (j = 0; j < 16; j++) {
@@ -29,9 +29,9 @@
   }
 }
 void vpx_ssim_parms_8x8_c(uint8_t *s, int sp, uint8_t *r, int rp,
-                          unsigned long *sum_s, unsigned long *sum_r,
-                          unsigned long *sum_sq_s, unsigned long *sum_sq_r,
-                          unsigned long *sum_sxr) {
+                          uint32_t *sum_s, uint32_t *sum_r,
+                          uint32_t *sum_sq_s, uint32_t *sum_sq_r,
+                          uint32_t *sum_sxr) {
   int i, j;
   for (i = 0; i < 8; i++, s += sp, r += rp) {
     for (j = 0; j < 8; j++) {
@@ -65,9 +65,9 @@
 static const int64_t cc1 =  26634;  // (64^2*(.01*255)^2
 static const int64_t cc2 = 239708;  // (64^2*(.03*255)^2
 
-static double similarity(unsigned long sum_s, unsigned long sum_r,
-                         unsigned long sum_sq_s, unsigned long sum_sq_r,
-                         unsigned long sum_sxr, int count) {
+static double similarity(uint32_t sum_s, uint32_t sum_r,
+                         uint32_t sum_sq_s, uint32_t sum_sq_r,
+                         uint32_t sum_sxr, int count) {
   int64_t ssim_n, ssim_d;
   int64_t c1, c2;
 
@@ -86,7 +86,7 @@
 }
 
 static double ssim_8x8(uint8_t *s, int sp, uint8_t *r, int rp) {
-  unsigned long sum_s = 0, sum_r = 0, sum_sq_s = 0, sum_sq_r = 0, sum_sxr = 0;
+  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);
   return similarity(sum_s, sum_r, sum_sq_s, sum_sq_r, sum_sxr, 64);
--- a/vpx_dsp/ssim.h
+++ b/vpx_dsp/ssim.h
@@ -8,8 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#ifndef VPX_ENCODER_VP9_SSIM_H_
-#define VPX_ENCODER_VP9_SSIM_H_
+#ifndef VPX_DSP_SSIM_H_
+#define VPX_DSP_SSIM_H_
 
 #ifdef __cplusplus
 extern "C" {
@@ -29,19 +29,19 @@
 // metrics used for calculating ssim, ssim2, dssim, and ssimc
 typedef struct {
   // source sum ( over 8x8 region )
-  uint64_t sum_s;
+  uint32_t sum_s;
 
   // reference sum (over 8x8 region )
-  uint64_t sum_r;
+  uint32_t sum_r;
 
   // source sum squared ( over 8x8 region )
-  uint64_t sum_sq_s;
+  uint32_t sum_sq_s;
 
   // reference sum squared (over 8x8 region )
-  uint64_t sum_sq_r;
+  uint32_t sum_sq_r;
 
   // sum of source times reference (over 8x8 region)
-  uint64_t sum_sxr;
+  uint32_t sum_sxr;
 
   // calculated ssim score between source and reference
   double ssim;
@@ -102,4 +102,4 @@
 }  // extern "C"
 #endif
 
-#endif  // VPX_ENCODER_VP9_SSIM_H_
+#endif  // VPX_DSP_SSIM_H_
--- a/vpx_dsp/vpx_dsp_rtcd_defs.pl
+++ b/vpx_dsp/vpx_dsp_rtcd_defs.pl
@@ -994,10 +994,10 @@
 # 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, unsigned long *sum_s, unsigned long *sum_r, unsigned long *sum_sq_s, unsigned long *sum_sq_r, unsigned long *sum_sxr";
+    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";
     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, unsigned long *sum_s, unsigned long *sum_r, unsigned long *sum_sq_s, unsigned long *sum_sq_r, unsigned long *sum_sxr";
+    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";
     specialize qw/vpx_ssim_parms_16x16/, "$sse2_x86_64";
 }
 
--- a/vpx_dsp/x86/ssim_opt_x86_64.asm
+++ b/vpx_dsp/x86/ssim_opt_x86_64.asm
@@ -49,11 +49,11 @@
 ;    int sp,
 ;    unsigned char *r,
 ;    int rp
-;    unsigned long *sum_s,
-;    unsigned long *sum_r,
-;    unsigned long *sum_sq_s,
-;    unsigned long *sum_sq_r,
-;    unsigned long *sum_sxr);
+;    uint32_t *sum_s,
+;    uint32_t *sum_r,
+;    uint32_t *sum_sq_s,
+;    uint32_t *sum_sq_r,
+;    uint32_t *sum_sxr);
 ;
 ; TODO: Use parm passing through structure, probably don't need the pxors
 ; ( calling app will initialize to 0 ) could easily fit everything in sse2
@@ -139,11 +139,11 @@
 ;    int sp,
 ;    unsigned char *r,
 ;    int rp
-;    unsigned long *sum_s,
-;    unsigned long *sum_r,
-;    unsigned long *sum_sq_s,
-;    unsigned long *sum_sq_r,
-;    unsigned long *sum_sxr);
+;    uint32_t *sum_s,
+;    uint32_t *sum_r,
+;    uint32_t *sum_sq_s,
+;    uint32_t *sum_sq_r,
+;    uint32_t *sum_sxr);
 ;
 ; TODO: Use parm passing through structure, probably don't need the pxors
 ; ( calling app will initialize to 0 ) could easily fit everything in sse2