mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
lavfi/removelogo: switch to ff_filter_frame.
This commit is contained in:
parent
3313e46c4a
commit
ef1868351d
@ -72,6 +72,7 @@
|
|||||||
#include "libavutil/imgutils.h"
|
#include "libavutil/imgutils.h"
|
||||||
#include "avfilter.h"
|
#include "avfilter.h"
|
||||||
#include "formats.h"
|
#include "formats.h"
|
||||||
|
#include "internal.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "bbox.h"
|
#include "bbox.h"
|
||||||
#include "lavfutils.h"
|
#include "lavfutils.h"
|
||||||
@ -472,24 +473,24 @@ static void blur_image(int ***mask,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
|
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
|
||||||
{
|
|
||||||
AVFilterLink *outlink = inlink->dst->outputs[0];
|
|
||||||
AVFilterBufferRef *outpicref;
|
|
||||||
|
|
||||||
outpicref = inpicref;
|
|
||||||
|
|
||||||
outlink->out_buf = outpicref;
|
|
||||||
return ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int end_frame(AVFilterLink *inlink)
|
|
||||||
{
|
{
|
||||||
RemovelogoContext *removelogo = inlink->dst->priv;
|
RemovelogoContext *removelogo = inlink->dst->priv;
|
||||||
AVFilterLink *outlink = inlink->dst->outputs[0];
|
AVFilterLink *outlink = inlink->dst->outputs[0];
|
||||||
AVFilterBufferRef *inpicref = inlink ->cur_buf;
|
AVFilterBufferRef *outpicref;
|
||||||
AVFilterBufferRef *outpicref = outlink->out_buf;
|
int direct = 0;
|
||||||
int direct = inpicref == outpicref;
|
|
||||||
|
if (inpicref->perms & AV_PERM_WRITE) {
|
||||||
|
direct = 1;
|
||||||
|
outpicref = inpicref;
|
||||||
|
} else {
|
||||||
|
outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
|
||||||
|
if (!outpicref) {
|
||||||
|
avfilter_unref_bufferp(&inpicref);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
avfilter_copy_buffer_ref_props(outpicref, inpicref);
|
||||||
|
}
|
||||||
|
|
||||||
blur_image(removelogo->mask,
|
blur_image(removelogo->mask,
|
||||||
inpicref ->data[0], inpicref ->linesize[0],
|
inpicref ->data[0], inpicref ->linesize[0],
|
||||||
@ -507,8 +508,10 @@ static int end_frame(AVFilterLink *inlink)
|
|||||||
removelogo->half_mask_data, inlink->w/2,
|
removelogo->half_mask_data, inlink->w/2,
|
||||||
inlink->w/2, inlink->h/2, direct, &removelogo->half_mask_bbox);
|
inlink->w/2, inlink->h/2, direct, &removelogo->half_mask_bbox);
|
||||||
|
|
||||||
ff_draw_slice(outlink, 0, inlink->h, 1);
|
if (!direct)
|
||||||
return ff_end_frame(outlink);
|
avfilter_unref_bufferp(&inpicref);
|
||||||
|
|
||||||
|
return ff_filter_frame(outlink, outpicref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uninit(AVFilterContext *ctx)
|
static void uninit(AVFilterContext *ctx)
|
||||||
@ -533,18 +536,14 @@ static void uninit(AVFilterContext *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; }
|
|
||||||
|
|
||||||
static const AVFilterPad removelogo_inputs[] = {
|
static const AVFilterPad removelogo_inputs[] = {
|
||||||
{
|
{
|
||||||
.name = "default",
|
.name = "default",
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.get_video_buffer = ff_null_get_video_buffer,
|
.get_video_buffer = ff_null_get_video_buffer,
|
||||||
.config_props = config_props_input,
|
.config_props = config_props_input,
|
||||||
.draw_slice = null_draw_slice,
|
.filter_frame = filter_frame,
|
||||||
.start_frame = start_frame,
|
.min_perms = AV_PERM_READ,
|
||||||
.end_frame = end_frame,
|
|
||||||
.min_perms = AV_PERM_WRITE | AV_PERM_READ,
|
|
||||||
},
|
},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user