amvecm: Coverity defect cleanup [1/1]
authorCheng Wang <cheng.wang@amlogic.com>
Mon, 16 Sep 2019 12:52:53 +0000 (20:52 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Thu, 24 Oct 2019 15:48:46 +0000 (08:48 -0700)
PD#SWPL-13978

Problem:
Defective code in trunk

Solution:
fix defective code

Verify:
on x301

Change-Id: I94d25695c248d9281b59f30f1c6c42e51c9af1dc
Signed-off-by: Cheng Wang <cheng.wang@amlogic.com>
drivers/amlogic/media/enhancement/amvecm/amcsc.c
drivers/amlogic/media/enhancement/amvecm/amcsc_pip.c
drivers/amlogic/media/enhancement/amvecm/hdr/am_hdr10_plus_ootf.c

index 379b1df..014928b 100644 (file)
@@ -124,11 +124,12 @@ static ssize_t write_file_hdr_cfgosd(
        int val;
        char buf[20];
        int ret = 0;
+       int cont2;
 
-       count = min_t(size_t, count, (sizeof(buf)-1));
-       if (copy_from_user(buf, userbuf, count))
+       cont2 = min_t(size_t, count, (sizeof(buf) - 1));
+       if (copy_from_user(buf, userbuf, cont2))
                return -EFAULT;
-       buf[count] = 0;
+       buf[cont2] = 0;
        ret = kstrtoint(buf, 0, &val);
        if (ret != 0) {
                pr_info("cfg_en_osd_100 do nothing!\n");
@@ -6541,6 +6542,8 @@ void update_hdr10_plus_pkt(bool enable,
                hdr10_plus_pkt_update = HDRPLUS_PKT_UPDATE;
                pr_csc(2, "update_hdr10_plus_pkt on\n");
        } else {
+               if (!vdev)
+                       return;
                vdev->fresh_tx_hdr_pkt(
                        &cur_send_info);
                vdev->fresh_tx_hdr10plus_pkt(0,
@@ -6566,6 +6569,8 @@ void send_hdr10_plus_pkt(enum vd_path_e vd_path)
                        return;
        }
        if (hdr10_plus_pkt_update == HDRPLUS_PKT_UPDATE) {
+               if (!vdev)
+                       return;
                vdev->fresh_tx_hdr_pkt(
                        &cur_send_info);
                vdev->fresh_tx_hdr10plus_pkt(
@@ -6578,6 +6583,8 @@ void send_hdr10_plus_pkt(enum vd_path_e vd_path)
                pr_csc(2, "send_hdr10_plus_pkt update\n");
        } else if ((hdr10_plus_pkt_update == HDRPLUS_PKT_REPEAT) &&
                (get_hdr10_plus_pkt_delay() > 1)) {
+               if (!vdev)
+                       return;
                vdev->fresh_tx_hdr_pkt(
                        &cur_send_info);
                vdev->fresh_tx_hdr10plus_pkt(
index e621b50..b684bce 100644 (file)
@@ -556,8 +556,8 @@ int hdr_policy_process(
                                        } else if (target_format[oth_path]
                                        == BT2020_HLG) {
                                                /* hdr->hlg */
-                                               hdr_process_mode[vd_path] =
-                                                       PROC_HDR_TO_HLG;
+                                               hdr10_plus_process_mode[vd_path]
+                                                       PROC_HDR_TO_HLG;
                                                target_format[vd_path] =
                                                        BT2020_HLG;
                                        } else {
@@ -732,8 +732,8 @@ int hdr_policy_process(
                                        } else if (target_format[oth_path]
                                        == BT2020_HLG) {
                                                /* hdr->hlg */
-                                               hdr_process_mode[vd_path] =
-                                                       PROC_HDR_TO_HLG;
+                                               hdr10_plus_process_mode[vd_path]
+                                                       PROC_HDR_TO_HLG;
                                                target_format[vd_path] =
                                                        BT2020_HLG;
                                        } else {
index b118457..d3273e9 100644 (file)
@@ -729,8 +729,7 @@ uint64_t curveX[POINTS], curveY[POINTS];
 
 int hdr10_plus_ootf_gen(void)
 {
-       int referenceCurve_flag = 1;
-
+       /*int referenceCurve_flag = 1;*/
        int order, i;
        uint64_t Kx, Ky;
        uint64_t  AnchorY[15];
@@ -753,15 +752,7 @@ int hdr10_plus_ootf_gen(void)
                HDR_MAX
        };
 
-       int productPeak = 700;
-
-/*     for (i = 0; i < POINTS; i++) {
- *     curveX[i] = 0;
- *  curveY[i] = 0;
- *     gain[i]   = 0;
- *     gain_ter[i] = 0;
- *     }
- */
+       int productpeak = 700;
 
        memset(curveX,   0, sizeof(uint64_t) * POINTS);
        memset(curveY,   0, sizeof(uint64_t) * POINTS);
@@ -772,6 +763,7 @@ int hdr10_plus_ootf_gen(void)
 
        /* the final tv OOTF curve params init*/
        EBZCurveParametersInit(&productBezierParams);
+
        /* the bezier parameters from metadata init*/
        EBZCurveParametersInit(&referenceBezierParams);
 
@@ -780,18 +772,23 @@ int hdr10_plus_ootf_gen(void)
 
        /*step 1. get metadata from vframe*/
        MetaDataInit(&metadata, &hdr10_plus_sei);
+
        /*step 2. get bezier params from metadata*/
        getMetaData(&metadata, &referenceBezierParams);
+
        /*step 3. gen final guided OOTF*/
-       if (referenceCurve_flag == 0)
+       /*if (referenceCurve_flag == 0)*/
                /* Basis OOTF : Direct calculation of product TM curve from*/
                /*ST-2094 percentile metadata */
-               basisOOTF(&metadata, &basisOOTF_Params, productPeak,
+               /*basisOOTF(&metadata, &basisOOTF_Params, productPeak,*/
                /* here  length(minBezierParams->Anchor) =order*/
-               metadata.maxSceneSourceLuminance, &productBezierParams);
-       else
-               GuidedOOTF(&metadata, &basisOOTF_Params, &referenceBezierParams,
-                       productPeak, &productBezierParams);
+               /*metadata.maxSceneSourceLuminance, &productBezierParams);*/
+       /*else*/
+
+       GuidedOOTF(
+               &metadata, &basisOOTF_Params,
+               &referenceBezierParams, productpeak,
+               &productBezierParams);
 
        /*step 4. get guided bezier params*/
        Kx    = (uint64_t)productBezierParams.Sx;
@@ -824,4 +821,3 @@ int hdr10_plus_ootf_gen(void)
        return 0;
 }
 
-