Clear X87 register state before using double.
MMX and X87 floating point instructions cannot be mixed freely on
the 32 bit x86 architecture.
This fixes a lot of unit tests in the 32bit build with
--enable-ext-intra.
BUG=https://bugs.chromium.org/p/webm/issues/detail?id=1196
Change-Id: I0e1c3565f4b9cb4fc2d716e94d9c40e68b36fac8
diff --git a/test/vp10_dct_test.cc b/test/vp10_dct_test.cc
index b2c301a..8cf034f 100644
--- a/test/vp10_dct_test.cc
+++ b/test/vp10_dct_test.cc
@@ -26,7 +26,6 @@
namespace {
void reference_dct_1d(const double *in, double *out, int size) {
- const double PI = 3.141592653589793238462643383279502884;
const double kInvSqrt2 = 0.707106781186547524400844362104;
for (int k = 0; k < size; ++k) {
out[k] = 0;
diff --git a/test/vp10_inv_txfm_test.cc b/test/vp10_inv_txfm_test.cc
index 6c0a3d2..e37b906 100644
--- a/test/vp10_inv_txfm_test.cc
+++ b/test/vp10_inv_txfm_test.cc
@@ -28,7 +28,6 @@
using libvpx_test::ACMRandom;
namespace {
-const double PI = 3.141592653589793238462643383279502884;
const double kInvSqrt2 = 0.707106781186547524400844362104;
void reference_idct_1d(const double *in, double *out, int size) {
diff --git a/vp10/common/blockd.c b/vp10/common/blockd.c
index 5f45077..ad30bc3 100644
--- a/vp10/common/blockd.c
+++ b/vp10/common/blockd.c
@@ -9,6 +9,9 @@
*/
#include <math.h>
+
+#include "vpx_ports/system_state.h"
+
#include "vp10/common/blockd.h"
PREDICTION_MODE vp10_left_block_mode(const MODE_INFO *cur_mi,
@@ -137,7 +140,6 @@
}
#if CONFIG_EXT_INTRA
-#define PI 3.14159265
// Returns whether filter selection is needed for a given
// intra prediction angle.
int pick_intra_filter(int angle) {
@@ -146,8 +148,12 @@
if (angle > 90 && angle < 180) {
return 1;
} else {
- double t = tan(angle * PI / 180.0);
+ double t;
double n;
+
+ vpx_clear_system_state();
+
+ t = tan(angle * PI / 180.0);
if (angle < 90)
t = 1 / t;
n = floor(t);
diff --git a/vp10/common/common.h b/vp10/common/common.h
index fb5634a..80801aa 100644
--- a/vp10/common/common.h
+++ b/vp10/common/common.h
@@ -25,6 +25,8 @@
extern "C" {
#endif
+#define PI 3.141592653589793238462643383279502884
+
// Only need this for fixed-size arrays, for structs just assign.
#define vp10_copy(dest, src) { \
assert(sizeof(dest) == sizeof(src)); \
diff --git a/vp10/common/reconintra.c b/vp10/common/reconintra.c
index bafd0d6..a7bd6c4 100644
--- a/vp10/common/reconintra.c
+++ b/vp10/common/reconintra.c
@@ -12,6 +12,7 @@
#include "./vpx_config.h"
#include "./vpx_dsp_rtcd.h"
+#include "vpx_ports/system_state.h"
#if CONFIG_VP9_HIGHBITDEPTH
#include "vpx_dsp/vpx_dsp_common.h"
@@ -389,7 +390,6 @@
}
#if CONFIG_EXT_INTRA
-#define PI 3.14159265
#define FILTER_INTRA_PREC_BITS 10
#define FILTER_INTRA_ROUND_VAL 511
@@ -672,10 +672,12 @@
static void dr_predictor(uint8_t *dst, ptrdiff_t stride, TX_SIZE tx_size,
const uint8_t *above, const uint8_t *left, int angle,
INTRA_FILTER filter_type) {
- double t = 0;
+ double t;
int dx, dy;
int bs = 4 << tx_size;
+ vpx_clear_system_state();
+ t = 0;
if (angle != 90 && angle != 180)
t = tan(angle * PI / 180.0);
if (angle > 0 && angle < 90) {
@@ -1008,9 +1010,11 @@
static void highbd_dr_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
const uint16_t *above, const uint16_t *left,
int angle, int bd, INTRA_FILTER filter) {
- double t = 0;
+ double t;
int dx, dy;
+ vpx_clear_system_state();
+ t = 0;
if (angle != 90 && angle != 180)
t = tan(angle * PI / 180.0);
if (angle > 0 && angle < 90) {
diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c
index 6ffa790..34d31cc 100644
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -2523,10 +2523,11 @@
static void angle_estimation(const uint8_t *src, int src_stride,
int rows, int cols, double *hist) {
int r, c, i, index;
- const double pi = 3.1415;
double angle, dx, dy;
- double temp, divisor = 0;
+ double temp, divisor;
+ vpx_clear_system_state();
+ divisor = 0;
for (i = 0; i < DIRECTIONAL_MODES; ++i)
hist[i] = 0;
@@ -2539,7 +2540,7 @@
if (dy == 0)
angle = 90;
else
- angle = (atan((double)dx / (double)dy)) * 180 / pi;
+ angle = (atan((double)dx / (double)dy)) * 180 / PI;
assert(angle >= -90 && angle <= 90);
index = get_angle_index(angle + 180);
if (index < DIRECTIONAL_MODES) {
@@ -2567,11 +2568,12 @@
static void highbd_angle_estimation(const uint8_t *src8, int src_stride,
int rows, int cols, double *hist) {
int r, c, i, index;
- const double pi = 3.1415;
double angle, dx, dy;
- double temp, divisor = 0;
+ double temp, divisor;
uint16_t *src = CONVERT_TO_SHORTPTR(src8);
+ vpx_clear_system_state();
+ divisor = 0;
for (i = 0; i < DIRECTIONAL_MODES; ++i)
hist[i] = 0;
@@ -2584,7 +2586,7 @@
if (dy == 0)
angle = 90;
else
- angle = (atan((double)dx / (double)dy)) * 180 / pi;
+ angle = (atan((double)dx / (double)dy)) * 180 / PI;
assert(angle >= -90 && angle <= 90);
index = get_angle_index(angle + 180);
if (index < DIRECTIONAL_MODES) {