[FFmpeg-devel] Flushing yadif
Robert Nagy
ronag89 at gmail.com
Wed May 2 13:27:50 CEST 2012
> From 853df5acd3a1f563853b8a9c877373df48dec866 Mon Sep 17 00:00:00 2001
> From: Robert Nagy <ronag89 at gmail.com>
> Date: Wed, 2 May 2012 10:03:22 +0200
> Subject: [PATCH] yadif: Add flushing of last frame.
>
> ---
> libavfilter/vf_yadif.c | 24 ++++++++++++++++++------
> 1 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
> index d8e2ad6..2c2bc60 100644
> --- a/libavfilter/vf_yadif.c
> +++ b/libavfilter/vf_yadif.c
> @@ -155,7 +155,7 @@ static void filter(AVFilterContext *ctx,
AVFilterBufferRef *dstpic,
> if ((y ^ parity) & 1) {
> uint8_t *prev = &yadif->prev->data[i][y*refs];
> uint8_t *cur = &yadif->cur ->data[i][y*refs];
> - uint8_t *next = &yadif->next->data[i][y*refs];
> + uint8_t *next = yadif->next ?
&yadif->next->data[i][y*refs] : cur; // Should optimally only use last
field of "cur".
> uint8_t *dst = &dstpic->data[i][y*dstpic->linesize[i]];
> int mode = y==1 || y+2==h ? 2 : yadif->mode;
> yadif->filter_line(dst, prev, cur, next, w, y+1<h ? refs
: -refs, y ? -refs : refs, parity ^ tff, mode);
> @@ -216,9 +216,9 @@ static void return_frame(AVFilterContext *ctx, int
is_second)
> filter(ctx, yadif->out, tff ^ !is_second, tff);
>
> if (is_second) {
> - if (yadif->next->pts != AV_NOPTS_VALUE &&
> + if ((!yadif->next || yadif->next->pts != AV_NOPTS_VALUE) &&
> yadif->cur->pts != AV_NOPTS_VALUE) {
> - uint64_t next_pts = yadif->next->pts;
> + uint64_t next_pts = yadif->next ? yadif->next->pts :
yadif->cur->pts * 2 - yadif->prev->pts ;
> uint64_t cur_pts = yadif->cur->pts;
> uint64_t prev_pts = yadif->prev->pts;
>
> @@ -307,10 +307,22 @@ static int request_frame(AVFilterLink *link)
> }
>
> do {
> - int ret;
> -
> - if ((ret = avfilter_request_frame(link->src->inputs[0])))
> + if(!yadif->next && yadif->cur) { // If there is no next then it
is EOF.
> + // Allow the filter to restart.
> + avfilter_unref_bufferp(yadif->prev);
> + avfilter_unref_bufferp(yadif->cur );
> + return AVERRROR_EOF;
> + }
> +
> + int ret = avfilter_request_frame(link->src->inputs[0]);
> +
> + if(ret == AVERRROR_EOF) {
> + start_frame(link->src->inputs[0], NULL);
> + end_frame(link->src->inputs[0]);
> + } else if(ret < 0) {
> return ret;
> + }
> } while (!yadif->cur);
>
> return 0;
> --
> 1.7.6.msysgit.0
More information about the ffmpeg-devel
mailing list