shithub: libvpx

Download patch

ref: 04f9a1fc05ce9a0bbe07b0ed3d652ca2b9ca2b3f
parent: 80a746f36f87323002889bd0f5d65b23dc00b20b
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Jan 15 15:10:04 EST 2021

plan9: fix compilation on 386 and arm

--- a/mkfile
+++ b/mkfile
@@ -2,7 +2,7 @@
 
 LIB=libvpx.a
 
-CFLAGS=$CFLAGS -I. -Iplan9 -p -D__plan9__ -Dvolatile= -DNDEBUG
+CFLAGS=$CFLAGS -I. -Iplan9 -p -D__plan9__ -D__${objtype}__ -Dvolatile= -DNDEBUG
 
 OFILES=\
 	args.$O\
--- a/plan9/plan9.c
+++ b/plan9/plan9.c
@@ -17,15 +17,16 @@
 		return nsec() - xstart;
 
 	if(fasthz == 0){
-		if((fasthz = _tos->cyclefreq) == 0){
+		fasthz = _tos->cyclefreq;
+		if(fasthz == 0){
 			fasthz = ~0ULL;
 			xstart = nsec();
 			fprint(2, "cyclefreq not available, falling back to nsec()\n");
 			fprint(2, "you might want to disable aux/timesync\n");
-			return 0;
 		}else{
 			cycles(&xstart);
 		}
+		return 0;
 	}
 	cycles(&x);
 	x -= xstart;
--- a/plan9/vpx_config.h
+++ b/plan9/vpx_config.h
@@ -13,15 +13,18 @@
 #include <libc.h>
 #include <thread.h>
 #include </sys/include/stdio.h>
+
 typedef u8int uint8_t;
 typedef u16int uint16_t;
 typedef u32int uint32_t;
 typedef u64int uint64_t;
+
 typedef s8int int8_t;
 typedef s16int int16_t;
 typedef s32int int32_t;
 typedef s64int int64_t;
-typedef ulong size_t;
+
+typedef usize size_t;
 typedef long off_t;
 typedef intptr ptrdiff_t;
 typedef intptr intptr_t;
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -4504,9 +4504,9 @@
 
       compmode_cost = vp9_cost_bit(comp_mode_p, comp_pred);
 
-      tmp_best_rdu =
-          best_rd - VPXMIN(RDCOST(x->rdmult, x->rddiv, rate2, distortion2),
-                           RDCOST(x->rdmult, x->rddiv, 0, total_sse));
+      int64_t a = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
+      int64_t b = RDCOST(x->rdmult, x->rddiv, 0, total_sse);
+      tmp_best_rdu = best_rd - VPXMIN(a, b);
 
       if (tmp_best_rdu > 0) {
         // If even the 'Y' rd value of split is higher than best so far
--- a/vpx_dsp/ssim.c
+++ b/vpx_dsp/ssim.c
@@ -225,11 +225,11 @@
 
   // Since these variables are unsigned sums, convert to double so
   // math is done in double arithmetic.
-  const double v = (2.0 * n * sv->sum_sxr - 2 * sv->sum_s * sv->sum_r + c2) /
-                   (n * sv->sum_sq_s - sv->sum_s * sv->sum_s +
-                    n * sv->sum_sq_r - sv->sum_r * sv->sum_r + c2);
+  const double v = (2.0 * n * sv->sum_sxr - 2 * sv->sum_s * sv->sum_r + c2);
+  double d = n * sv->sum_sq_s - sv->sum_s * sv->sum_s;
+  d += n * sv->sum_sq_r - sv->sum_r * sv->sum_r + c2;
 
-  return l * v;
+  return l * (v / d);
 }
 
 // The first term of the ssim metric is a luminance factor.
@@ -256,11 +256,11 @@
 
   // Since these variables are unsigned, sums convert to double so
   // math is done in double arithmetic.
-  const double v = (2.0 * n * sv->sum_sxr - 2 * sv->sum_s * sv->sum_r + c2) /
-                   (n * sv->sum_sq_s - sv->sum_s * sv->sum_s +
-                    n * sv->sum_sq_r - sv->sum_r * sv->sum_r + c2);
+  const double v = (2.0 * n * sv->sum_sxr - 2 * sv->sum_s * sv->sum_r + c2);
+  double d = n * sv->sum_sq_s - sv->sum_s * sv->sum_s;
+  d += n * sv->sum_sq_r - sv->sum_r * sv->sum_r + c2;
 
-  return l * v;
+  return l * (v / d);
 }
 static void ssimv_parms(uint8_t *img1, int img1_pitch, uint8_t *img2,
                         int img2_pitch, Ssimv *sv) {