Commit fef7b2e0 authored by Stefano Sabatini's avatar Stefano Sabatini

lavfi/tinterlace: switch to filter_frame API

Also add missing NULL checks.
parent 656500c5
...@@ -202,28 +202,20 @@ void copy_picture_field(uint8_t *dst[4], int dst_linesize[4], ...@@ -202,28 +202,20 @@ void copy_picture_field(uint8_t *dst[4], int dst_linesize[4],
} }
} }
static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0];
TInterlaceContext *tinterlace = ctx->priv; TInterlaceContext *tinterlace = ctx->priv;
AVFilterBufferRef *cur, *next, *out;
int field, tff, ret;
avfilter_unref_buffer(tinterlace->cur); avfilter_unref_buffer(tinterlace->cur);
tinterlace->cur = tinterlace->next; tinterlace->cur = tinterlace->next;
tinterlace->next = picref; tinterlace->next = picref;
inlink->cur_buf = NULL;
return 0;
}
static int end_frame(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0];
TInterlaceContext *tinterlace = ctx->priv;
AVFilterBufferRef *cur = tinterlace->cur;
AVFilterBufferRef *next = tinterlace->next;
AVFilterBufferRef *out = NULL;
int field, tff;
cur = tinterlace->cur;
next = tinterlace->next;
/* we need at least two frames */ /* we need at least two frames */
if (!tinterlace->cur) if (!tinterlace->cur)
return 0; return 0;
...@@ -232,6 +224,8 @@ static int end_frame(AVFilterLink *inlink) ...@@ -232,6 +224,8 @@ static int end_frame(AVFilterLink *inlink)
case MODE_MERGE: /* move the odd frame into the upper field of the new image, even into case MODE_MERGE: /* move the odd frame into the upper field of the new image, even into
* the lower field, generating a double-height video at half framerate */ * the lower field, generating a double-height video at half framerate */
out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
if (!out)
return AVERROR(ENOMEM);
avfilter_copy_buffer_ref_props(out, cur); avfilter_copy_buffer_ref_props(out, cur);
out->video->h = outlink->h; out->video->h = outlink->h;
out->video->interlaced = 1; out->video->interlaced = 1;
...@@ -281,6 +275,8 @@ static int end_frame(AVFilterLink *inlink) ...@@ -281,6 +275,8 @@ static int end_frame(AVFilterLink *inlink)
case MODE_INTERLEAVE_BOTTOM: /* bottom field first */ case MODE_INTERLEAVE_BOTTOM: /* bottom field first */
tff = tinterlace->mode == MODE_INTERLEAVE_TOP; tff = tinterlace->mode == MODE_INTERLEAVE_TOP;
out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
if (!out)
return AVERROR(ENOMEM);
avfilter_copy_buffer_ref_props(out, cur); avfilter_copy_buffer_ref_props(out, cur);
out->video->interlaced = 1; out->video->interlaced = 1;
out->video->top_field_first = tff; out->video->top_field_first = tff;
...@@ -300,15 +296,18 @@ static int end_frame(AVFilterLink *inlink) ...@@ -300,15 +296,18 @@ static int end_frame(AVFilterLink *inlink)
case MODE_INTERLACEX2: /* re-interlace preserving image height, double frame rate */ case MODE_INTERLACEX2: /* re-interlace preserving image height, double frame rate */
/* output current frame first */ /* output current frame first */
out = avfilter_ref_buffer(cur, ~AV_PERM_WRITE); out = avfilter_ref_buffer(cur, ~AV_PERM_WRITE);
if (!out)
return AVERROR(ENOMEM);
out->video->interlaced = 1; out->video->interlaced = 1;
ff_start_frame(outlink, out); if ((ret = ff_filter_frame(outlink, out)) < 0)
ff_draw_slice(outlink, 0, outlink->h, 1); return ret;
ff_end_frame(outlink);
/* output mix of current and next frame */ /* output mix of current and next frame */
tff = next->video->top_field_first; tff = next->video->top_field_first;
out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
if (!out)
return AVERROR(ENOMEM);
avfilter_copy_buffer_ref_props(out, next); avfilter_copy_buffer_ref_props(out, next);
out->video->interlaced = 1; out->video->interlaced = 1;
...@@ -325,13 +324,10 @@ static int end_frame(AVFilterLink *inlink) ...@@ -325,13 +324,10 @@ static int end_frame(AVFilterLink *inlink)
break; break;
} }
ff_start_frame(outlink, out); ret = ff_filter_frame(outlink, out);
ff_draw_slice(outlink, 0, outlink->h, 1);
ff_end_frame(outlink);
tinterlace->frame++; tinterlace->frame++;
return 0; return ret;
} }
static int request_frame(AVFilterLink *outlink) static int request_frame(AVFilterLink *outlink)
...@@ -349,15 +345,11 @@ static int request_frame(AVFilterLink *outlink) ...@@ -349,15 +345,11 @@ static int request_frame(AVFilterLink *outlink)
return 0; return 0;
} }
static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; }
static const AVFilterPad tinterlace_inputs[] = { static const AVFilterPad tinterlace_inputs[] = {
{ {
.name = "default", .name = "default",
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.start_frame = start_frame, .filter_frame = filter_frame,
.draw_slice = null_draw_slice,
.end_frame = end_frame,
}, },
{ NULL } { NULL }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment