diff mbox

[FFmpeg-devel] lavfi/minterpolate: fix blending calc issue.

Message ID 1530092681-31230-1-git-send-email-mypopydev@gmail.com
State Accepted
Commit eb776a16ea3c02096ee4eff2f12da0f03cb03ef3
Headers show

Commit Message

Jun Zhao June 27, 2018, 9:44 a.m. UTC
the right blending calc is:
(alpha * Frame_2 + (MAX - alpha) * Frame_1 + 512) >> 10

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
---
 libavfilter/vf_minterpolate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

mypopy@gmail.com July 4, 2018, 6:59 a.m. UTC | #1
On Wed, Jun 27, 2018 at 5:52 PM Jun Zhao <mypopydev@gmail.com> wrote:
>
> the right blending calc is:
> (alpha * Frame_2 + (MAX - alpha) * Frame_1 + 512) >> 10
>
> Signed-off-by: Jun Zhao <mypopydev@gmail.com>
> ---
>  libavfilter/vf_minterpolate.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
> index d534315..c6a5e63 100644
> --- a/libavfilter/vf_minterpolate.c
> +++ b/libavfilter/vf_minterpolate.c
> @@ -1122,8 +1122,8 @@ static void interpolate(AVFilterLink *inlink,
AVFrame *avf_out)
>                  for (y = 0; y < height; y++) {
>                      for (x = 0; x < width; x++) {
>                          avf_out->data[plane][x + y * avf_out->linesize[plane]]
=
> -                                          alpha  * mi_ctx->frames[2].avf->data[plane][x
+ y * mi_ctx->frames[2].avf->linesize[plane]] +
> -                            ((ALPHA_MAX - alpha) * mi_ctx->frames[1].avf->data[plane][x
+ y * mi_ctx->frames[1].avf->linesize[plane]] + 512) >> 10;
> +                            (alpha  * mi_ctx->frames[2].avf->data[plane][x
+ y * mi_ctx->frames[2].avf->linesize[plane]] +
> +                             (ALPHA_MAX - alpha) * mi_ctx->frames[1].avf->data[plane][x
+ y * mi_ctx->frames[1].avf->linesize[plane]] + 512) >> 10;
>                      }
>                  }
>              }
> --
> 2.7.4
>
ping, any comments for this fix?
Steven Liu July 6, 2018, 7:12 a.m. UTC | #2
mypopy@gmail.com <mypopy@gmail.com> 于2018年7月4日周三 下午3:05写道:
>
> On Wed, Jun 27, 2018 at 5:52 PM Jun Zhao <mypopydev@gmail.com> wrote:
> >
> > the right blending calc is:
> > (alpha * Frame_2 + (MAX - alpha) * Frame_1 + 512) >> 10
> >
> > Signed-off-by: Jun Zhao <mypopydev@gmail.com>
> > ---
> >  libavfilter/vf_minterpolate.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
> > index d534315..c6a5e63 100644
> > --- a/libavfilter/vf_minterpolate.c
> > +++ b/libavfilter/vf_minterpolate.c
> > @@ -1122,8 +1122,8 @@ static void interpolate(AVFilterLink *inlink,
> AVFrame *avf_out)
> >                  for (y = 0; y < height; y++) {
> >                      for (x = 0; x < width; x++) {
> >                          avf_out->data[plane][x + y * avf_out->linesize[plane]]
> =
> > -                                          alpha  * mi_ctx->frames[2].avf->data[plane][x
> + y * mi_ctx->frames[2].avf->linesize[plane]] +
> > -                            ((ALPHA_MAX - alpha) * mi_ctx->frames[1].avf->data[plane][x
> + y * mi_ctx->frames[1].avf->linesize[plane]] + 512) >> 10;
> > +                            (alpha  * mi_ctx->frames[2].avf->data[plane][x
> + y * mi_ctx->frames[2].avf->linesize[plane]] +
> > +                             (ALPHA_MAX - alpha) * mi_ctx->frames[1].avf->data[plane][x
> + y * mi_ctx->frames[1].avf->linesize[plane]] + 512) >> 10;
> >                      }
> >                  }
> >              }
> > --
> > 2.7.4
> >
> ping, any comments for this fix?

LGTM

Go on improve it to OpenCL :D
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
mypopy@gmail.com July 9, 2018, 12:19 a.m. UTC | #3
On Fri, Jul 6, 2018 at 3:21 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>
> mypopy@gmail.com <mypopy@gmail.com> 于2018年7月4日周三 下午3:05写道:
> >
> > On Wed, Jun 27, 2018 at 5:52 PM Jun Zhao <mypopydev@gmail.com> wrote:
> > >
> > > the right blending calc is:
> > > (alpha * Frame_2 + (MAX - alpha) * Frame_1 + 512) >> 10
> > >
> > > Signed-off-by: Jun Zhao <mypopydev@gmail.com>
> > > ---
> > >  libavfilter/vf_minterpolate.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
> > > index d534315..c6a5e63 100644
> > > --- a/libavfilter/vf_minterpolate.c
> > > +++ b/libavfilter/vf_minterpolate.c
> > > @@ -1122,8 +1122,8 @@ static void interpolate(AVFilterLink *inlink,
> > AVFrame *avf_out)
> > >                  for (y = 0; y < height; y++) {
> > >                      for (x = 0; x < width; x++) {
> > >                          avf_out->data[plane][x + y * avf_out->linesize[plane]]
> > =
> > > -                                          alpha  * mi_ctx->frames[2].avf->data[plane][x
> > + y * mi_ctx->frames[2].avf->linesize[plane]] +
> > > -                            ((ALPHA_MAX - alpha) * mi_ctx->frames[1].avf->data[plane][x
> > + y * mi_ctx->frames[1].avf->linesize[plane]] + 512) >> 10;
> > > +                            (alpha  * mi_ctx->frames[2].avf->data[plane][x
> > + y * mi_ctx->frames[2].avf->linesize[plane]] +
> > > +                             (ALPHA_MAX - alpha) * mi_ctx->frames[1].avf->data[plane][x
> > + y * mi_ctx->frames[1].avf->linesize[plane]] + 512) >> 10;
> > >                      }
> > >                  }
> > >              }
> > > --
> > > 2.7.4
> > >
> > ping, any comments for this fix?
>
> LGTM
Applied, thanks
>
diff mbox

Patch

diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index d534315..c6a5e63 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -1122,8 +1122,8 @@  static void interpolate(AVFilterLink *inlink, AVFrame *avf_out)
                 for (y = 0; y < height; y++) {
                     for (x = 0; x < width; x++) {
                         avf_out->data[plane][x + y * avf_out->linesize[plane]] =
-                                          alpha  * mi_ctx->frames[2].avf->data[plane][x + y * mi_ctx->frames[2].avf->linesize[plane]] +
-                            ((ALPHA_MAX - alpha) * mi_ctx->frames[1].avf->data[plane][x + y * mi_ctx->frames[1].avf->linesize[plane]] + 512) >> 10;
+                            (alpha  * mi_ctx->frames[2].avf->data[plane][x + y * mi_ctx->frames[2].avf->linesize[plane]] +
+                             (ALPHA_MAX - alpha) * mi_ctx->frames[1].avf->data[plane][x + y * mi_ctx->frames[1].avf->linesize[plane]] + 512) >> 10;
                     }
                 }
             }