[FFmpeg-devel] [PATCH] video stabilization plugins using vid.stab library

Paul B Mahol onemda at gmail.com
Fri Apr 19 01:33:20 CEST 2013


On Fri, 19 Apr 2013 01:15 +0200, Georg Martius <georg.martius at web.de> wrote:
> Dear Clement,
>
> On Sunday 14 April 2013 13:00:54 Clement Boesch wrote:
>> [...]
>>
>> Your patch was not rebased on the master since a long time, so we can't
>> apply it. Additionally, some recent changes in libavfilter will require
>> some little adjustments in your filters...
>
> sorry for the trouble and the delay. Now I have changed my library to code
> to
> cope with the new initialization - it only got better ;-)
>
> The new patch is attached.
>
> Regards
>   Georg
> --
> ---- Georg Martius,  Tel: +49 177 6413311  -----
> --------- http://georg.hronopik.de -------------


> Subject: [PATCH] video stabilization plugins using vid.stab library:
>  vidstabdetect and vidstabtransform common functions for
>  interfacing vid.stab are in libavfilter/vidstabutils.c
>
>
> Signed-off-by: Georg Martius <georg.martius at web.de>
> ---
>  Changelog                         |    1 +
>  LICENSE                           |    4 +-
>  configure                         |    6 +
>  doc/filters.texi                  |  222 ++++++++++++++++++++++++++++
>  libavfilter/Makefile              |    2 +
>  libavfilter/allfilters.c          |    2 +
>  libavfilter/vf_vidstabdetect.c    |  238 ++++++++++++++++++++++++++++++
>  libavfilter/vf_vidstabtransform.c |  294 +++++++++++++++++++++++++++++++++++++
>  libavfilter/vidstabutils.c        |   84 +++++++++++
>  libavfilter/vidstabutils.h        |   36 +++++
>  10 files changed, 887 insertions(+), 2 deletions(-)
>  create mode 100644 libavfilter/vf_vidstabdetect.c
>  create mode 100644 libavfilter/vf_vidstabtransform.c
>  create mode 100644 libavfilter/vidstabutils.c
>  create mode 100644 libavfilter/vidstabutils.h
>

[...]

> diff --git a/libavfilter/vf_vidstabdetect.c b/libavfilter/vf_vidstabdetect.c
> new file mode 100644
> index 0000000..6c78444
> --- /dev/null
> +++ b/libavfilter/vf_vidstabdetect.c

[...]

> +static av_cold void uninit(AVFilterContext *ctx)
> +{
> +    StabData *sd = ctx->priv;
> +    VSMotionDetect* md = &(sd->md);
> +
> +    av_opt_free(sd);

not needed anymore.

> +    if (sd->f) {
> +        fclose(sd->f);
> +        sd->f = NULL;
> +    }
> +
> +    vsMotionDetectionCleanup(md);
> +
> +}
> +
> +static int query_formats(AVFilterContext *ctx)
> +{
> +    // If you add something here also add it to the above mapping function

stale comment

> +    static const enum AVPixelFormat pix_fmts[] = {
> +        AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P,
> +        AV_PIX_FMT_YUV411P,  AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUVA420P,
> +        AV_PIX_FMT_YUV440P,  AV_PIX_FMT_GRAY8,
> +        AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, AV_PIX_FMT_RGBA,
> +        AV_PIX_FMT_NONE
> +    };
> +
> +    ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
> +    return 0;
> +}
> +

[...]

> diff --git a/libavfilter/vf_vidstabtransform.c b/libavfilter/vf_vidstabtransform.c
> new file mode 100644
> index 0000000..3826781
> --- /dev/null
> +++ b/libavfilter/vf_vidstabtransform.c

[...]

> +static av_cold void uninit(AVFilterContext *ctx)
> +{
> +    TransformContext *tc = ctx->priv;
> +
> +    av_opt_free(tc);
> +

not needed anymore.

> +    vsTransformDataCleanup(&tc->td);
> +    vsTransformationsCleanup(&tc->trans);
> +}
> +

[...]

> +static int config_input(AVFilterLink *inlink)
> +{
> +    AVFilterContext *ctx = inlink->dst;
> +    TransformContext *tc = ctx->priv;
> +    FILE* f;
> +
> +    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
> +
> +    VSTransformData* td = &(tc->td);
> +
> +    VSFrameInfo fi_src;
> +    VSFrameInfo fi_dest;
> +
> +    if(!vsFrameInfoInit(&fi_src, inlink->w, inlink->h,
> +                      av_2_vs_pixel_format(ctx,inlink->format)) ||
> +       !vsFrameInfoInit(&fi_dest, inlink->w, inlink->h,
> +                      av_2_vs_pixel_format(ctx, inlink->format))){
> +        av_log(ctx, AV_LOG_ERROR, "unknown pixel format: %i (%s)",
> +               inlink->format, desc->name);
> +        return AVERROR(EINVAL);
> +    }
> +
> +    if(fi_src.bytesPerPixel != av_get_bits_per_pixel(desc)/8 ||
> +       fi_src.log2ChromaW != desc->log2_chroma_w ||
> +       fi_src.log2ChromaH != desc->log2_chroma_h){
> +        av_log(ctx, AV_LOG_ERROR, "pixel-format error: bpp %i<>%i  ",
> +               fi_src.bytesPerPixel, av_get_bits_per_pixel(desc)/8);
> +        av_log(ctx, AV_LOG_ERROR, "chroma_subsampl: w: %i<>%i  h: %i<>%i\n",
> +               fi_src.log2ChromaW, desc->log2_chroma_w,
> +               fi_src.log2ChromaH, desc->log2_chroma_h);
> +        return AVERROR(EINVAL);
> +    }
> +
> +    tc->conf.modName = "vidstabtransform";
> +    tc->conf.verbose=1;
> +    if(tc->tripod){
> +        av_log(ctx, AV_LOG_INFO, "Virtual tripod mode: relative=0, smoothing=0");
> +        tc->conf.relative=0;
> +        tc->conf.smoothing=0;
> +    }
> +
> +    if(vsTransformDataInit(td, &tc->conf, &fi_src, &fi_dest) != VS_OK){
> +      av_log(ctx, AV_LOG_ERROR, "initialization of vid.stab transform failed, please report a BUG\n");
> +      return AVERROR(EINVAL);

weird indentation

[...]


More information about the ffmpeg-devel mailing list