di: fix TL1 cave video 1080i 60hz have drawing [1/1]
authorWenfeng Guo <wenfeng.guo@amlogic.com>
Tue, 16 Apr 2019 08:06:37 +0000 (16:06 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Wed, 24 Apr 2019 02:58:33 +0000 (19:58 -0700)
PD#SWPL-7006

Problem:
TL1 cave video 1080i 60hz have drawing.

Solution:
dark scenes don't into pulldown32 by vlsi yanling

Verify:
TL1

Signed

Change-Id: Ib77c0f99940c416943baa9b9a8a02a059b274e5b
Signed-off-by: Wenfeng Guo <wenfeng.guo@amlogic.com>
drivers/amlogic/media/deinterlace/deinterlace.c
drivers/amlogic/media/deinterlace/film_mode_fmw/film_fw1.c
drivers/amlogic/media/deinterlace/film_mode_fmw/film_vof_soft.h
drivers/amlogic/media/deinterlace/pulldown_drv.c
drivers/amlogic/media/deinterlace/pulldown_drv.h

index 7374b00..777354b 100644 (file)
@@ -3172,7 +3172,8 @@ static void pre_de_done_buf_config(void)
                                &glb_field_mot_num);
                        if (pulldown_enable)
                                pulldown_detection(&post_wr_buf->pd_config,
-                                       di_pre_stru.mtn_status, overturn);
+                                       di_pre_stru.mtn_status, overturn,
+                                       di_pre_stru.di_inp_buf->vframe);
                        if (combing_fix_en)
                                cur_lev = adaptive_combing_fixing(
                                di_pre_stru.mtn_status,
index 9fefa75..609d08b 100644 (file)
@@ -17,7 +17,9 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/amlogic/media/vfm/vframe.h>
 #include "film_vof_soft.h"
+#include "../deinterlace.h"
 
 
 static int DIweavedetec(struct sFlmSftPar *pPar, int nDif01);
@@ -68,6 +70,8 @@ UINT8 FlmVOFSftInt(struct sFlmSftPar *pPar)
        pPar->dif01rate = 20;
        pPar->flag_di01th = 0;
        pPar->numthd = 60;
+       pPar->flm32_dif02_gap_th = 7;
+       pPar->flm32_luma_th = 90;
        pPar->sF32Dif02M0 = 4096;/* mpeg-4096, cvbs-8192 */
        pPar->sF32Dif02M1 = 4096;
 
@@ -230,6 +234,7 @@ static int dif01_ratio = 10;
 module_param(dif01_ratio,  int, 0644);
 MODULE_PARM_DESC(dif01_ratio, "dif01_ratio");
 
+
 int comsum;
 
 int FlmVOFSftTop(UINT8 *rCmb32Spcl, unsigned short *rPstCYWnd0,
@@ -239,7 +244,8 @@ int FlmVOFSftTop(UINT8 *rCmb32Spcl, unsigned short *rPstCYWnd0,
        UINT8 *dif01flag, UINT32 *rROFldDif01, UINT32 *rROFrmDif02,
        UINT32 *rROCmbInf, UINT32 glb_frame_mot_num,
        UINT32 glb_field_mot_num, unsigned int *combing_row_num,
-       unsigned int *frame_diff_avg, struct sFlmSftPar *pPar, bool reverse)
+       unsigned int *frame_diff_avg, struct sFlmSftPar *pPar, bool reverse,
+       struct vframe_s *vf)
 {
        static UINT32 DIF01[HISDIFNUM]; /* Last one is global */
        static UINT32 DIF02[HISDIFNUM]; /* Last one is global */
@@ -374,7 +380,7 @@ int FlmVOFSftTop(UINT8 *rCmb32Spcl, unsigned short *rPstCYWnd0,
        }
        /* --------------------------------------------------------- */
        /* Film-Detection */
-       nS1 = FlmDetSft(&pRDat, nDIF01, nDIF02, nT0, pPar);
+       nS1 = FlmDetSft(&pRDat, nDIF01, nDIF02, nT0, pPar, vf);
 
        nS0 = FlmModsDet(&pRDat, rROFldDif01[0], rROFrmDif02[0]);
        /* --------------------------------------------------------- */
@@ -601,12 +607,12 @@ int FlmVOFSftTop(UINT8 *rCmb32Spcl, unsigned short *rPstCYWnd0,
 /* nDif02: Frame Difference */
 /* WND: The index of Window */
 int FlmDetSft(struct sFlmDatSt *pRDat, int *nDif01, int *nDif02,
-             int WND, struct sFlmSftPar *pPar)
+             int WND, struct sFlmSftPar *pPar, struct vframe_s *vf)
 {
        int nT0 = 0;
 
        /* 3-2 */
-       Flm32DetSft(pRDat, nDif02, nDif01, pPar);
+       Flm32DetSft(pRDat, nDif02, nDif01, pPar, vf);
 
        /* Film2-2 Detection */
        /* debug0304 */
@@ -619,7 +625,7 @@ int FlmDetSft(struct sFlmDatSt *pRDat, int *nDif01, int *nDif02,
 /* pFlm02[0:nLEN-1] : recursive, 0-2 dif */
 /* pFlm01[0:nLEN-1] : recursive, 0-1 dif */
 int Flm32DetSft(struct sFlmDatSt *pRDat, int *nDif02,
-               int *nDif01, struct sFlmSftPar *pPar)
+               int *nDif01, struct sFlmSftPar *pPar, struct vframe_s *vf)
 {
        int sFrmDifAvgRat = pPar->sFrmDifAvgRat;        /* 16;  //0~32 */
        /*  The Large Decision should be: (large>average+LgDifThrd) */
@@ -627,7 +633,6 @@ int Flm32DetSft(struct sFlmDatSt *pRDat, int *nDif02,
        int sF32StpWgt01 = pPar->sF32StpWgt01;  /* 15; */
        int sF32StpWgt02 = pPar->sF32StpWgt02;  /* 15; */
        int sF32DifLgRat = pPar->sF32DifLgRat;  /* 16; Dif>Rat*Min-->Larger */
-
        /* int sF32DifSmRat = 16;  //Dif*Rat<Max  --> Smaller */
 
        UINT8 *pFlm02 = pRDat->pFrm32;
@@ -661,6 +666,29 @@ int Flm32DetSft(struct sFlmDatSt *pRDat, int *nDif02,
        int nFlgChk2 = 0;
        int nFlgChk3 = 0; /* for Mit32VHLine */
 
+       int luma_avg = 0;
+       int flm32_dif02_gap = 0;
+
+       int flm32_luma_th = pPar->flm32_luma_th; // APL th
+       int flm32_dif02_gap_th = pPar->flm32_dif02_gap_th;
+
+       /* ============================================= */
+       /*patch for dark scenes don't into pulldown32 by vlsi yanling*/
+       if (vf == NULL || !IS_VDIN_SRC(vf->source_type))
+               luma_avg = flm32_luma_th;
+       else {
+               if (vf->prop.hist.pixel_sum > 0)
+                       luma_avg = vf->prop.hist.luma_sum /
+                               vf->prop.hist.pixel_sum;
+               else
+                       luma_avg = flm32_luma_th;
+       }
+       if (luma_avg < flm32_luma_th)
+               flm32_dif02_gap = flm32_dif02_gap_th * 2;
+       else
+               flm32_dif02_gap = flm32_dif02_gap_th;
+       /*---------------------------------*/
+
        prt_flg = ((pr_pd >> 2) & 0x1);
        if (prt_flg)
                sprintf(debug_str, "#Dbg32:\n");
@@ -759,7 +787,6 @@ int Flm32DetSft(struct sFlmDatSt *pRDat, int *nDif02,
                nFlgChk1 = 0;
                nFlgChk2 = 0;
        }
-       /* ============================================= */
 
        nT2 = 5 * nDif02[HISDIFNUM - 1] / (nMn + sFrmDifLgTDif + 1);
        nT2 = nT2>>1;
@@ -779,7 +806,10 @@ int Flm32DetSft(struct sFlmDatSt *pRDat, int *nDif02,
 
        if (nSTP > 16)
                nSTP = 16;
-
+               /*patch for dark scenes don't into pulldown32 by vlsi yanling*/
+       if (((nMx + nMn/2) / (nMn + 1)) < flm32_dif02_gap)
+               nSTP = 0;
+       /*---------------*/
        for (nT0 = 1; nT0 < HISDETNUM; nT0++) {
                pFlm02[nT0 - 1] = pFlm02[nT0];
                pFlm02t[nT0 - 1] = pFlm02t[nT0];
index d5c2d48..0fa9ac8 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef _FLMVOFSFT_H_
 #define _FLMVOFSFT_H_
 #include <linux/kernel.h>
+#include <linux/amlogic/media/vfm/vframe.h>
+
 /* Film Detection and VOF detection Software implementation */
 /* Designer: Xin.Hu@amlogic.com */
 /* Date: 12/06/13 */
@@ -129,6 +131,9 @@ struct sFlmSftPar {
        int flag_di01th;
        int numthd;
 
+       int flm32_dif02_gap_th;
+       int flm32_luma_th;
+
        UINT32 sF32Dif02M0;     /* mpeg-4096, cvbs-8192 */
        UINT32 sF32Dif02M1;     /* mpeg-4096, cvbs-8192 */
        unsigned int field_count;
@@ -163,7 +168,8 @@ int FlmVOFSftTop(UINT8 *rCmb32Spcl, unsigned short *rPstCYWnd0,
        UINT8 *dif01flag, UINT32 *rROFldDif01, UINT32 *rROFrmDif02,
        UINT32 *rROCmbInf, UINT32 glb_frame_mot_num,
        UINT32 glb_field_mot_num, unsigned int *cmb_row_num,
-       unsigned int *frame_diff_avg, struct sFlmSftPar *pPar, bool reverse);
+       unsigned int *frame_diff_avg, struct sFlmSftPar *pPar, bool reverse,
+       struct vframe_s *vf);
 
 /* length of pFlm01/nDif01: [0:5]; */
 /* iDx: index of minimum dif02 ([0:5] */
@@ -174,7 +180,7 @@ int Cal32Flm01(UINT8 *pFlm01, int *nDif01, int iDx, struct sFlmSftPar *pPar);
 /* nDif02: Frame Difference */
 /* WND: The index of Window */
 int FlmDetSft(struct sFlmDatSt *pRDat, int *nDif01, int *nDif02, int WND,
-             struct sFlmSftPar *pPar);
+             struct sFlmSftPar *pPar, struct vframe_s *vf);
 
 int VOFDetSub1(int *PREWV, int *nCNum, int nMod, UINT32 *nRCmb, int nROW,
               struct sFlmSftPar *pPar);
@@ -186,7 +192,7 @@ int VOFDetSft(int *VOFWnd, int *nCNum, int *nGCmb,
 
 /*  */
 int Flm32DetSft(struct sFlmDatSt *pRDat, int *nDif02, int *nDif01,
-               struct sFlmSftPar *pPar);
+               struct sFlmSftPar *pPar, struct vframe_s *vf);
 
 /* Film2-2 Detection */
 int Flm22DetSft(struct sFlmDatSt *pRDat, int *nDif02,
index 94544a2..7ab71aa 100644 (file)
@@ -112,7 +112,7 @@ module_param(cmb_3point_rrat, uint, 0644);
 MODULE_PARM_DESC(cmb_3point_rrat, "cmb_3point_rrat/n");
 
 unsigned int pulldown_detection(struct pulldown_detected_s *res,
-       struct combing_status_s *cmb_sts, bool reverse)
+       struct combing_status_s *cmb_sts, bool reverse, struct vframe_s *vf)
 {
        unsigned int glb_frame_mot_num, glb_field_mot_num, i;
        unsigned int mot_row = 0, mot_max = 0, ntmp = 0;
@@ -142,7 +142,8 @@ unsigned int pulldown_detection(struct pulldown_detected_s *res,
                &cmb_sts->cmb_row_num,
                &cmb_sts->frame_diff_avg,
                &pd_param,
-               reverse);
+               reverse,
+               vf);
 
        difflag = dectres.dif01flag;
        if (dectres.rFlmPstMod == 1)
@@ -411,6 +412,10 @@ static struct pd_param_s pd_params[] = {
          &(pd_param.flag_di01th)   },
        { "numthd",
          &(pd_param.numthd)        },
+       { "flm32_dif02_gap_th",
+         &(pd_param.flm32_dif02_gap_th) },
+       { "flm32_luma_th",
+         &(pd_param.flm32_luma_th)   },
        { "sF32Dif02M0",
          &(pd_param.sF32Dif02M0)   },        /* mpeg-4096, cvbs-8192 */
        { "sF32Dif02M1",
index 912119b..e670f0f 100644 (file)
@@ -46,7 +46,7 @@ struct pulldown_detected_s {
 unsigned char pulldown_init(unsigned short width, unsigned short height);
 
 unsigned int pulldown_detection(struct pulldown_detected_s *res,
-       struct combing_status_s *cmb_sts, bool reverse);
+       struct combing_status_s *cmb_sts, bool reverse, struct vframe_s *vf);
 
 void pulldown_vof_win_vshift(struct pulldown_detected_s *wins,
        unsigned short v_offset);