summaryrefslogtreecommitdiffstats
path: root/libs/utils
diff options
context:
space:
mode:
authorJohn Grossman <johngro@google.com>2012-06-27 15:34:43 -0700
committerJohn Grossman <johngro@google.com>2012-06-27 15:34:43 -0700
commitec44ed0758871db896d9c7d5c09f7084ddea1c7a (patch)
tree5cb5531020a1bb40bfd96dd570ca3c89b98409db /libs/utils
parent3443b333f16cd356d7cc7322810fe6188f58f1d9 (diff)
downloadframeworks_native-ec44ed0758871db896d9c7d5c09f7084ddea1c7a.zip
frameworks_native-ec44ed0758871db896d9c7d5c09f7084ddea1c7a.tar.gz
frameworks_native-ec44ed0758871db896d9c7d5c09f7084ddea1c7a.tar.bz2
Utils: Fix a bug in the linear transformation code.
Hand merge from ics-aah > Utils: Fix a bug in the linear transformation code. > > Fix a bug where an incorrect result would be computed if you used the > linear transformation code to do a reverse transformation (from B's > domain into A's domain) when the scaler fraction was negative. > > Change-Id: I8e5f109314d235a177ab41f65d3c4cd08cff78be > Signed-off-by: John Grossman <johngro@google.com> Change-Id: Id90e18f685c61c1a89fd91c32adcf01363b3e8f3 Signed-off-by: John Grossman <johngro@google.com>
Diffstat (limited to 'libs/utils')
-rw-r--r--libs/utils/LinearTransform.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/libs/utils/LinearTransform.cpp b/libs/utils/LinearTransform.cpp
index d752415..b7d28d4 100644
--- a/libs/utils/LinearTransform.cpp
+++ b/libs/utils/LinearTransform.cpp
@@ -114,6 +114,7 @@ static bool linear_transform_s64_to_s64(
int64_t basis1,
int32_t N,
uint32_t D,
+ bool invert_frac,
int64_t basis2,
int64_t* out) {
uint64_t scaled, res;
@@ -137,8 +138,8 @@ static bool linear_transform_s64_to_s64(
is_neg = !is_neg;
if (!scale_u64_to_u64(abs_val,
- ABS(N),
- D,
+ invert_frac ? D : ABS(N),
+ invert_frac ? ABS(N) : D,
&scaled,
is_neg))
return false; // overflow/undeflow
@@ -191,6 +192,7 @@ bool LinearTransform::doForwardTransform(int64_t a_in, int64_t* b_out) const {
a_zero,
a_to_b_numer,
a_to_b_denom,
+ false,
b_zero,
b_out);
}
@@ -201,8 +203,9 @@ bool LinearTransform::doReverseTransform(int64_t b_in, int64_t* a_out) const {
return linear_transform_s64_to_s64(b_in,
b_zero,
- a_to_b_denom,
a_to_b_numer,
+ a_to_b_denom,
+ true,
a_zero,
a_out);
}