[FFmpeg-devel] [PATCH 2/2] mcfps filter WIP

wm4 nfxjfg at googlemail.com
Mon Jul 27 16:28:50 CEST 2015


On Mon, 27 Jul 2015 14:16:20 +0200
Michael Niedermayer <michael at niedermayer.cc> wrote:

> On Sun, Jul 26, 2015 at 09:41:51PM +0200, wm4 wrote:
> > On Fri, 24 Jul 2015 20:50:56 +0200
> > Michael Niedermayer <michaelni at gmx.at> wrote:
> > 
> > > Works well with some scenes, works really not well with others
> > > More work needed
> > > if you can improve it, i would not be unhappy
> > > 
> > > this should not be optimized yet except trivial things, first the code
> > > should work well then it should be made to work fast
> > > 
> > > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > > ---
> > >  libavcodec/internal.h    |    3 +
> > >  libavcodec/snow.c        |   30 ++
> > >  libavcodec/utils.c       |   10 +
> > >  libavfilter/Makefile     |    1 +
> > >  libavfilter/allfilters.c |    1 +
> > >  libavfilter/vf_mcfps.c   |  853 ++++++++++++++++++++++++++++++++++++++++++++++
> > >  6 files changed, 898 insertions(+)
> > >  create mode 100644 libavfilter/vf_mcfps.c
> > > 
> > 
> > 
> > > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> > > index d926a26..8bc7b65 100644
> > > --- a/libavcodec/utils.c
> > > +++ b/libavcodec/utils.c
> > > @@ -3906,3 +3906,13 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p,
> > >  
> > >      return p + 4;
> > >  }
> > > +
> > > +int avpriv_get_mvs(AVCodecContext *avctx, int16_t (*mvs)[2], int8_t *refs, int width, int height)
> > > +{
> > > +    switch (avctx->codec_id) {
> > > +    case AV_CODEC_ID_SNOW:
> > > +        return ff_get_mvs_snow(avctx, mvs, refs, width, height);
> > > +    default:
> > > +        return AVERROR(EINVAL);
> > > +    }
> > > +}
> > 
> > > diff --git a/libavfilter/vf_mcfps.c b/libavfilter/vf_mcfps.c
> > > new file mode 100644
> > > index 0000000..784275d
> > > --- /dev/null
> > > +++ b/libavfilter/vf_mcfps.c
> > 
> > > +static int extract_mvs(MCFPSContext *mcfps, InputFrame *f, int dir)
> > > +{
> > > +    if (!f->mv[dir])
> > > +        f->mv[dir] = av_malloc(mcfps->b_width * mcfps->b_height * sizeof(*f->mv[0]));
> > > +    if (!f->ref[dir])
> > > +        f->ref[dir] = av_malloc(mcfps->b_width * mcfps->b_height * sizeof(*f->ref[0]));
> > > +    if (!f->mv[dir] || !f->ref[0])
> > > +        return AVERROR(ENOMEM);
> > > +
> > > +    return avpriv_get_mvs(mcfps->avctx_enc[dir],
> > > +                        f->mv[dir],
> > > +                        f->ref[dir],
> > > +                        mcfps->b_width,
> > > +                        mcfps->b_height);
> > > +}
> > 
> > That reminds me of MPlayer's filter using libavcodec internals. I'm
> > very against this. It's a very awful form of code reuse.
> 
> what exactly are you against ?
> the use of the snow motion estimation, the specific way the motion
> vectors are exported or something else ?
> 
> and what do you suggest instead ?

Don't abuse AVCodecContext as motion vector computation API.


More information about the ffmpeg-devel mailing list