[x265] [PATCH] weightP: fix crash in 32 bit due to fabsf()
kavitha at multicorewareinc.com
kavitha at multicorewareinc.com
Fri Jan 31 15:14:49 CET 2014
# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1391175842 -19800
# Fri Jan 31 19:14:02 2014 +0530
# Node ID 9da6b87cd543df003c3a3d86c23e29ab33bb6217
# Parent eb3713ab0641757729d68d876be4e6737f27eb7e
weightP: fix crash in 32 bit due to fabsf()
diff -r eb3713ab0641 -r 9da6b87cd543 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp Thu Jan 30 18:19:02 2014 -0600
+++ b/source/encoder/slicetype.cpp Fri Jan 31 19:14:02 2014 +0530
@@ -1190,7 +1190,9 @@
refMean = (float)ref->wp_sum[0] / (fenc->lines * fenc->width) / (1 << (X265_DEPTH - 8));
/* Early termination */
- if (fabsf(refMean - fencMean) < 0.5f && fabsf(1.f - guessScale) < epsilon)
+ float meanDiff = refMean < fencMean ? fencMean - refMean : refMean - fencMean;
+ float guessVal = guessScale > 1.f ? guessScale - 1.f : 1.f - guessScale;
+ if (meanDiff < 0.5 && guessVal < epsilon)
return;
/* Don't check chroma in lookahead, or if there wasn't a luma weight. */
diff -r eb3713ab0641 -r 9da6b87cd543 source/encoder/weightPrediction.cpp
--- a/source/encoder/weightPrediction.cpp Thu Jan 30 18:19:02 2014 -0600
+++ b/source/encoder/weightPrediction.cpp Fri Jan 31 19:14:02 2014 +0530
@@ -221,7 +221,9 @@
SET_WEIGHT(w, 0, 1, 0, 0);
SET_WEIGHT(fw[yuv], 0, 1 << denom, denom, 0);
/* Early termination */
- if (fabsf(refMean[yuv] - fencMean[yuv]) < 0.5f && fabsf(1.f - guessScale[yuv]) < epsilon)
+ float meanDiff = refMean[yuv] < fencMean[yuv] ? fencMean[yuv] - refMean[yuv] : refMean[yuv] - fencMean[yuv];
+ float guessVal = guessScale[yuv] > 1.f ? guessScale[yuv] - 1.f : 1.f - guessScale[yuv];
+ if (meanDiff < 0.5 && guessVal < epsilon)
continue;
/* Don't check chroma in lookahead, or if there wasn't a luma weight. */
More information about the x265-devel
mailing list