[FFmpeg-devel] [PATCH] avfilter: add framerate video filter

Michael Niedermayer michael at niedermayer.cc
Fri Jul 24 23:40:40 CEST 2015


On Fri, Jul 24, 2015 at 07:09:16AM +0000, Paul B Mahol wrote:
[..]

> +static av_cold void uninit(AVFilterContext *ctx)
> +{
> +    FrameRateContext *s = ctx->priv;
> +    int i;
> +
> +    for (i = s->frst + 1; i > s->last; i++) {
> +        if (s->srce[i] && (s->srce[i] != s->srce[i + 1]))
> +            av_frame_free(&s->srce[i]);
> +    }
> +    av_frame_free(&s->srce[s->last]);
> +}
> +
> +static int query_formats(AVFilterContext *ctx)
> +{

> +    static const enum PixelFormat pix_fmts[] = {

AVPixelFormat

> +        PIX_FMT_YUV410P,
> +        PIX_FMT_YUV411P,
> +        PIX_FMT_YUV420P,
> +        PIX_FMT_YUV422P,
> +        PIX_FMT_YUV440P,
> +        PIX_FMT_YUV444P,
> +        PIX_FMT_NONE

AV_PIX_FMT_*


> +    };
> +
> +    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
> +    if (!fmts_list)
> +        return AVERROR(ENOMEM);
> +    return ff_set_common_formats(ctx, fmts_list);
> +}
> +
> +static int config_input(AVFilterLink *inlink)
> +{
> +    AVFilterContext *ctx = inlink->dst;
> +    FrameRateContext *s = ctx->priv;
> +    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
> +    int plane;
> +

> +    /** full an array with the number of bytes that the video
> +     *  data occupies per line for each plane of the input video */
> +    for (plane = 0; plane < 4; plane++) {

doxygen comment in the middle looks a bit odd


> +        s->line_size[plane] = av_image_get_linesize(
> +                inlink->format,
> +                inlink->w,
> +                plane);
> +    }
> +
> +    s->vsub = pix_desc->log2_chroma_h;
> +
> +    s->sad = av_pixelutils_get_sad_fn(3, 3, 2, s); // 8x8 both sources aligned
> +    if (!s->sad)
> +        return AVERROR(EINVAL);
> +
> +    s->srce_time_base = inlink->time_base;
> +
> +    return 0;
> +}
> +
> +static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
> +{
> +    AVFilterContext *ctx = inlink->dst;
> +    FrameRateContext *s = ctx->priv;
> +    AVFilterLink *outlink = ctx->outputs[0];
> +
> +    // we have one new frame
> +    s->pending_srce_frames++;
> +
> +    if (inpicref->interlaced_frame)
> +        av_log(ctx, AV_LOG_WARNING, "Interlaced frame found - the output will not be correct\n");
> +
> +    // store the pointer to the new frame
> +    av_frame_free(&s->srce[s->frst]);
> +    s->srce[s->frst] = inpicref;
> +
> +    if (!s->pending_end_frame && s->srce[s->crnt]) {
> +        s->work = ff_get_video_buffer(outlink, outlink->w, outlink->h);
> +        av_frame_copy_props(s->work, s->srce[s->crnt]);
> +        set_work_frame_pts(ctx);
> +
> +        s->pending_end_frame = 1;
> +    } else {
> +        set_srce_frame_dest_pts(ctx);
> +    }
> +

> +//    if (!s->srce[s->crnt]) {
> +//        av_dlog(ctx, "end_frame() no current frame\n");
> +//        return;
> +//    }

the patch contains several outcomented pieces of code, is that
intended ?


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150724/336471f5/attachment.sig>


More information about the ffmpeg-devel mailing list