Removed recursion. Also reduced few if() checks.

Cc: Hans Verkuil <[email protected]>
Cc: Antti Palosaari <[email protected]>
Signed-off-by: Prashant Laddha <[email protected]>
---
 drivers/media/platform/vivid/vivid-sin.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-sin.c 
b/drivers/media/platform/vivid/vivid-sin.c
index 2ed9f7f..c9face9 100644
--- a/drivers/media/platform/vivid/vivid-sin.c
+++ b/drivers/media/platform/vivid/vivid-sin.c
@@ -36,25 +36,23 @@ static s32 sin[65] = {
 
 static s32 get_sin_val(u32 index)
 {
+       s32 sign = 1;
        u32 tab_index;
        u32 new_index;
 
-       if (index <= 64)
-               return sin[index];
-       else if (index > 64 && index <= 128) {
-               tab_index = 64 - (index - 64);
-               return sin[tab_index];
-       } else if (index > 128 && index <= 192) {
-               tab_index = index - 128;
-               return (-1) * sin[tab_index];
-       } else if (index > 192 && index <= 255) {
-               tab_index = 64 - (index - 192);
-               return (-1) * sin[tab_index];
-       }
-
-       new_index = index % 256;
-       return get_sin_val(new_index);
+       new_index = index & 0xFF; /* new_index = index % 256*/
 
+       if (new_index > 128)
+               sign = -1;
+
+       new_index = index & 0x7F; /* new_index = index % 256*/
+
+       if (new_index <= 64)
+               tab_index = new_index;
+       else
+               tab_index = 64 - (new_index - 64);
+
+       return sign * sin[tab_index];
 }
 
 /*
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to