vpp: fix out of one pixel between video and the red frame [1/1]
authorPeng Yixin <yixin.peng@amlogic.com>
Mon, 27 May 2019 14:00:15 +0000 (22:00 +0800)
committerNick Xie <nick@khadas.com>
Mon, 5 Aug 2019 06:45:40 +0000 (14:45 +0800)
PD#TV-5764

Problem:
Goto the wrong case when using ext_sar

Solution:
Using the correct case when using ext_sar

Verify:
verified on r311

Change-Id: I181b9e8d21917840729f2e487b3dae3f41cd2c5a
Signed-off-by: Peng Yixin <yixin.peng@amlogic.com>
drivers/amlogic/media/video_sink/vpp.c

index 734364c..04ad989 100644 (file)
@@ -975,6 +975,11 @@ RESTART:
                ext_sar = false;
        }
 
+       /* speical mode did not use ext sar mode */
+       if ((wide_mode == VIDEO_WIDEOPTION_NONLINEAR) ||
+               (wide_mode == VIDEO_WIDEOPTION_NORMAL_NOSCALEUP))
+               ext_sar = false;
+
        /* keep 8 bits resolution for aspect conversion */
        if (wide_mode == VIDEO_WIDEOPTION_4_3) {
                if (vpp_flags & VPP_FLAG_PORTRAIT_MODE)
@@ -1027,8 +1032,6 @@ RESTART:
                        width_out, h_in, aspect_ratio_out >> 2);
 
        if ((aspect_factor == 0)
-               || (aspect_factor ==
-               (VPP_FLAG_AR_MASK >> VPP_FLAG_AR_BITS))
                || (wide_mode == VIDEO_WIDEOPTION_FULL_STRETCH)
                || (wide_mode == VIDEO_WIDEOPTION_NONLINEAR)) {
                aspect_factor = 0x100;
@@ -1045,8 +1048,13 @@ RESTART:
                                (u64)sar_height *
                                (u64)height_in,
                                (u32)tmp);
-               height_after_ratio /= sar_height;
+               height_after_ratio /= sar_width;
                aspect_factor = (height_after_ratio << 8) / h_in;
+               if (super_debug)
+                       pr_info("ext_sar: aspect_factor=%d, %d,%d,%d,%d,%d\n",
+                               aspect_factor, w_in, h_in,
+                               height_after_ratio,
+                               sar_width, sar_height);
        } else {
                /* avoid the bit length overflow */
                u64 tmp = (u64)((u64)(width_out * h_in) * aspect_ratio_out);
@@ -1163,7 +1171,10 @@ RESTART:
 
                if (wide_mode == VIDEO_WIDEOPTION_NORMAL) {
                        ratio_x = ratio_y = max(ratio_x, ratio_y);
-                       ratio_y = (ratio_y << 8) / aspect_factor;
+                       if (ext_sar)
+                               ratio_y = (ratio_y * h_in) / height_after_ratio;
+                       else
+                               ratio_y = (ratio_y << 8) / aspect_factor;
                } else if (wide_mode == VIDEO_WIDEOPTION_NORMAL_NOSCALEUP) {
                        u32 r1, r2;