vpp: add threshold to omit irregular screen AR [1/1]
authorBrian Zhu <brian.zhu@amlogic.com>
Wed, 19 Jun 2019 19:36:59 +0000 (03:36 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Thu, 20 Jun 2019 12:05:45 +0000 (05:05 -0700)
PD#TV-3602

Problem:
The irregular aspect ratio of screen will cause that video
position dose not match the axis even if the source aspect
ration matches the display windows's aspect ratio.

Solution:
Add threshold to omit the irregular screen aspect ratio.

Verify:
Verified on X301

Change-Id: Ie375de69e42fc168fb3b5a51d9ab2662789dc807
Signed-off-by: Brian Zhu <brian.zhu@amlogic.com>
drivers/amlogic/media/video_sink/vpp.c

index 6f7771d..d81240d 100644 (file)
@@ -605,6 +605,8 @@ static unsigned int force_no_compress;
 MODULE_PARM_DESC(force_no_compress, "force_no_compress");
 module_param(force_no_compress, uint, 0664);
 
+static unsigned int screen_ar_threshold = 3;
+
 /*
  *test on txlx:
  *Time_out = (V_out/V_screen_total)/FPS_out;
@@ -897,9 +899,24 @@ static int vpp_set_filters_internal(
        u32 sar_width = 0, sar_height = 0;
        bool ext_sar = false;
        bool no_compress = false;
+       u32 min_aspect_ratio_out, max_aspect_ratio_out;
 
        if (!input)
                return VppFilter_Fail;
+       /* min = 0.95 x 1024 * height / width */
+       min_aspect_ratio_out =
+               ((100 - screen_ar_threshold) << 10) / 100;
+       min_aspect_ratio_out =
+               (vinfo->height * min_aspect_ratio_out) / vinfo->width;
+       /* max = 1.05 x 1024 * height / width */
+       max_aspect_ratio_out =
+               ((100 + screen_ar_threshold) << 10) / 100;
+       max_aspect_ratio_out =
+               (vinfo->height * max_aspect_ratio_out) / vinfo->width;
+
+       if ((aspect_ratio_out <= max_aspect_ratio_out)
+               && (aspect_ratio_out >= min_aspect_ratio_out))
+               aspect_ratio_out = (vinfo->height << 10) / vinfo->width;
 
        cur_filter = &gfilter[input->layer_id];
        cur_custom_ar = input->custom_ar;