hdr: fix hdr gamut convert support 32/64bit
authorMingLiang Dong <mingliang.dong@amlogic.com>
Thu, 30 Aug 2018 05:45:28 +0000 (13:45 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Thu, 30 Aug 2018 06:06:03 +0000 (23:06 -0700)
PD#172813: hdr: fix hdr gamut convert support 32/64bit

Change-Id: Iab330be778920c2d5322d4f29b5673266f065e6f
Signed-off-by: MingLiang Dong <mingliang.dong@amlogic.com>
drivers/amlogic/media/enhancement/amvecm/amcsc.c

index a3fead7..a96196e 100644 (file)
@@ -264,7 +264,7 @@ struct hdr_osd_reg_s hdr_osd_reg = {
        -1 /* shadow mode */
 };
 
-#define HDR_VERSION   "----gxl_20180516---g12a_20180614-----\n"
+#define HDR_VERSION   "----gxl_20180830---g12a_20180614-----\n"
 
 static struct vframe_s *dbg_vf;
 static struct master_display_info_s dbg_hdr_send;
@@ -3728,21 +3728,26 @@ static void mtx_dot_mul(
        int64_t (*out)[3], int32_t norm)
 {
        int i, j;
+       int64_t tmp;
 
        for (i = 0; i < 3; i++)
-               for (j = 0; j < 3; j++)
-                       out[i][j] = (a[i][j] * b[i][j] + (norm >> 1)) / norm;
+               for (j = 0; j < 3; j++) {
+                       tmp = a[i][j] * b[i][j] + (norm >> 1);
+                       out[i][j] = div64_s64(tmp, norm);
+               }
 }
 
 static void mtx_mul(int64_t (*a)[3], int64_t *b, int64_t *out, int32_t norm)
 {
        int j, k;
+       int64_t tmp;
 
        for (j = 0; j < 3; j++) {
                out[j] = 0;
                for (k = 0; k < 3; k++)
                        out[j] += a[k][j] * b[k];
-               out[j] = (out[j] + (norm >> 1)) / norm;
+               tmp = out[j] + (norm >> 1);
+               out[j] = div64_s64(tmp, norm);
        }
 }
 
@@ -3751,13 +3756,15 @@ static void mtx_mul_mtx(
        int64_t (*out)[3], int32_t norm)
 {
        int i, j, k;
+       int64_t tmp;
 
        for (i = 0; i < 3; i++)
                for (j = 0; j < 3; j++) {
                        out[i][j] = 0;
                        for (k = 0; k < 3; k++)
                                out[i][j] += a[k][j] * b[i][k];
-                       out[i][j] = (out[i][j] + (norm >> 1)) / norm;
+                       tmp = out[i][j] + (norm >> 1);
+                       out[i][j] = div64_s64(tmp, norm);
                }
 }
 
@@ -3767,6 +3774,7 @@ static void inverse_3x3(
 {
        int i, j;
        int64_t determinant = 0;
+       int64_t tmp;
 
        for (i = 0; i < 3; i++)
                determinant +=
@@ -3781,8 +3789,8 @@ static void inverse_3x3(
                        out[j][i] -= (in[(i + 1) % 3][(j + 2) % 3]
                                * in[(i + 2) % 3][(j + 1) % 3]);
                        out[j][i] = (out[j][i] * norm) << (obl - 1);
-                       out[j][i] =
-                               (out[j][i] + (determinant >> 1)) / determinant;
+                       tmp = out[j][i] + (determinant >> 1);
+                       out[j][i] = div64_s64(tmp, determinant);
                }
        }
 }
@@ -3798,6 +3806,7 @@ static void calc_T(
        int64_t C[3];
        int64_t D[3][3];
        int64_t E[3][3];
+       int64_t tmp;
 
        for (i = 0; i < 4; i++)
                z[i] = norm - prmy[i][0] - prmy[i][1];
@@ -3807,9 +3816,13 @@ static void calc_T(
                        A[i][j] = prmy[i][j];
                A[i][2] = z[i];
        }
-       B[0] = ((int64_t)norm * prmy[3][0] * 2 / prmy[3][1] + 1) >> 1;
+       tmp = norm * prmy[3][0] * 2;
+       tmp = div64_s64(tmp, prmy[3][1]);
+       B[0] = (tmp + 1) >> 1;
        B[1] = norm;
-       B[2] = (norm * z[3] * 2 / prmy[3][1] + 1) >> 1;
+       tmp = norm * z[3] * 2;
+       tmp = div64_s64(tmp, prmy[3][1]);
+       B[2] = (tmp + 1) >> 1;
        inverse_3x3(A, D, norm, obl);
        mtx_mul(D, B, C, norm);
        for (i = 0; i < 3; i++)