OSDN Git Service

Small optimization while removing warning
authorVictor Toso <me@victortoso.com>
Mon, 18 Dec 2017 15:01:24 +0000 (16:01 +0100)
committerXiang, Haihao <haihao.xiang@intel.com>
Wed, 10 Jan 2018 01:12:43 +0000 (09:12 +0800)
Removed the helper array and its initialization loop as we can achieve the
same with two variables in one loop.

This patch also removes the warning below:

> gen8_mfc.c:2735:9: warning: variable 'i' is incremented both in the loop
> header and in the loop body [-Wfor-loop-analysis]
>         i++;
>         ^
> gen8_mfc.c:2732:25: note: incremented here
>     for (i = 0; i < 64; i++) {
>                         ^

Signed-off-by: Victor Toso <victortoso@redhat.com>
src/gen8_mfc.c

index b62e71f..7ab46d7 100644 (file)
@@ -2723,18 +2723,13 @@ static void
 get_reciprocal_dword_qm(unsigned char *raster_qm, uint32_t *dword_qm)
 {
     int i = 0, j = 0;
-    short reciprocal_qm[64];
+    short hdw, ldw;
 
-    for (i = 0; i < 64; i++) {
-        reciprocal_qm[i] = 65535 / (raster_qm[i]);
+    for (i = 0, j = 0; i < 64; i += 2, j++) {
+        hdw = 65535 / (raster_qm[i]);
+        ldw = 65535 / (raster_qm[i + 1]);
+        dword_qm[j] = (hdw << 16) | ldw;
     }
-
-    for (i = 0; i < 64; i++) {
-        dword_qm[j] = ((reciprocal_qm[i + 1] << 16) | (reciprocal_qm[i]));
-        j++;
-        i++;
-    }
-
 }