From 99d6c4878a076296d9ee6b708ffd2552630b3e3f Mon Sep 17 00:00:00 2001
From: Davinder Singh <ds.mudhar@gmail.com>
Date: Sun, 28 Aug 2016 23:42:20 +0530
Subject: [PATCH 1/2] avfilter: vf_minterpolate: rename chroma log vars

---
 libavfilter/vf_minterpolate.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index 5b41cd8..28bbe19 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -184,10 +184,8 @@ typedef struct MIContext {
     double prev_mafd;
     double scd_threshold;
 
-    int chroma_height;
-    int chroma_width;
-    int chroma_h_shift;
-    int chroma_v_shift;
+    int log2_chroma_w;
+    int log2_chroma_h;
     int nb_planes;
 } MIContext;
 
@@ -330,15 +328,11 @@ static int config_input(AVFilterLink *inlink)
 {
     MIContext *mi_ctx = inlink->dst->priv;
     AVMotionEstContext *me_ctx = &mi_ctx->me_ctx;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
     const int height = inlink->h;
     const int width  = inlink->w;
     int i;
 
-    mi_ctx->chroma_height = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
-    mi_ctx->chroma_width = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
-
-    avcodec_get_chroma_sub_sample(inlink->format, &mi_ctx->chroma_h_shift, &mi_ctx->chroma_v_shift);
+    avcodec_get_chroma_sub_sample(inlink->format, &mi_ctx->log2_chroma_w, &mi_ctx->log2_chroma_h);
 
     mi_ctx->nb_planes = av_pix_fmt_count_planes(inlink->format);
 
@@ -900,6 +894,8 @@ static void bidirectional_obmc(MIContext *mi_ctx, int alpha)
             }
 }
 
+
+
 static void set_frame_data(MIContext *mi_ctx, int alpha, AVFrame *avf_out)
 {
     int x, y, plane;
@@ -936,8 +932,8 @@ static void set_frame_data(MIContext *mi_ctx, int alpha, AVFrame *avf_out)
                 for (i = 0; i < pixel->nb; i++) {
                     Frame *frame = &mi_ctx->frames[pixel->refs[i]];
                     if (chroma) {
-                        x_mv = (x >> mi_ctx->chroma_h_shift) + (pixel->mvs[i][0] >> mi_ctx->chroma_h_shift);
-                        y_mv = (y >> mi_ctx->chroma_v_shift) + (pixel->mvs[i][1] >> mi_ctx->chroma_v_shift);
+                        x_mv = (x >> mi_ctx->log2_chroma_w) + (pixel->mvs[i][0] >> mi_ctx->log2_chroma_w);
+                        y_mv = (y >> mi_ctx->log2_chroma_h) + (pixel->mvs[i][1] >> mi_ctx->log2_chroma_h);
                     } else {
                         x_mv = x + pixel->mvs[i][0];
                         y_mv = y + pixel->mvs[i][1];
@@ -949,7 +945,7 @@ static void set_frame_data(MIContext *mi_ctx, int alpha, AVFrame *avf_out)
                 val = ROUNDED_DIV(val, weight_sum);
 
                 if (chroma)
-                    avf_out->data[plane][(x >> mi_ctx->chroma_h_shift) + (y >> mi_ctx->chroma_v_shift) * avf_out->linesize[plane]] = val;
+                    avf_out->data[plane][(x >> mi_ctx->log2_chroma_w) + (y >> mi_ctx->log2_chroma_h) * avf_out->linesize[plane]] = val;
                 else
                     avf_out->data[plane][x + y * avf_out->linesize[plane]] = val;
             }
@@ -1092,8 +1088,8 @@ static void interpolate(AVFilterLink *inlink, AVFrame *avf_out)
                 int height = avf_out->height;
 
                 if (plane == 1 || plane == 2) {
-                    width = mi_ctx->chroma_width;
-                    height = mi_ctx->chroma_height;
+                    width = width >> mi_ctx->log2_chroma_w;
+                    height = height >> mi_ctx->log2_chroma_h;
                 }
 
                 for (y = 0; y < height; y++) {
-- 
2.9.3

