You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-23 21:54:53 +02:00
vf_delogo: switch to filter_frame, this filter did not support slices
Based on patch by Anton Khirnov Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -209,30 +209,39 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
|
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in)
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int end_frame(AVFilterLink *inlink)
|
|
||||||
{
|
{
|
||||||
DelogoContext *delogo = inlink->dst->priv;
|
DelogoContext *delogo = inlink->dst->priv;
|
||||||
AVFilterLink *outlink = inlink->dst->outputs[0];
|
AVFilterLink *outlink = inlink->dst->outputs[0];
|
||||||
AVFilterBufferRef *inpicref = inlink ->cur_buf;
|
|
||||||
AVFilterBufferRef *outpicref = outlink->out_buf;
|
|
||||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
|
||||||
int direct = inpicref->buf == outpicref->buf;
|
AVFilterBufferRef *out;
|
||||||
int hsub0 = desc->log2_chroma_w;
|
int hsub0 = desc->log2_chroma_w;
|
||||||
int vsub0 = desc->log2_chroma_h;
|
int vsub0 = desc->log2_chroma_h;
|
||||||
|
int direct = 0;
|
||||||
int plane;
|
int plane;
|
||||||
int ret;
|
|
||||||
|
|
||||||
for (plane = 0; plane < 4 && inpicref->data[plane]; plane++) {
|
if (in->perms & AV_PERM_WRITE) {
|
||||||
|
direct = 1;
|
||||||
|
out = in;
|
||||||
|
} else {
|
||||||
|
out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
|
||||||
|
if (!out) {
|
||||||
|
avfilter_unref_bufferp(&in);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
avfilter_copy_buffer_ref_props(out, in);
|
||||||
|
|
||||||
|
out->video->w = outlink->w;
|
||||||
|
out->video->h = outlink->h;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (plane = 0; plane < 4 && in->data[plane]; plane++) {
|
||||||
int hsub = plane == 1 || plane == 2 ? hsub0 : 0;
|
int hsub = plane == 1 || plane == 2 ? hsub0 : 0;
|
||||||
int vsub = plane == 1 || plane == 2 ? vsub0 : 0;
|
int vsub = plane == 1 || plane == 2 ? vsub0 : 0;
|
||||||
|
|
||||||
apply_delogo(outpicref->data[plane], outpicref->linesize[plane],
|
apply_delogo(out->data[plane], out->linesize[plane],
|
||||||
inpicref ->data[plane], inpicref ->linesize[plane],
|
in ->data[plane], in ->linesize[plane],
|
||||||
inlink->w>>hsub, inlink->h>>vsub,
|
inlink->w>>hsub, inlink->h>>vsub,
|
||||||
delogo->x>>hsub, delogo->y>>vsub,
|
delogo->x>>hsub, delogo->y>>vsub,
|
||||||
delogo->w>>hsub, delogo->h>>vsub,
|
delogo->w>>hsub, delogo->h>>vsub,
|
||||||
@@ -240,10 +249,10 @@ static int end_frame(AVFilterLink *inlink)
|
|||||||
delogo->show, direct);
|
delogo->show, direct);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = ff_draw_slice(outlink, 0, inlink->h, 1)) < 0 ||
|
if (!direct)
|
||||||
(ret = ff_end_frame(outlink)) < 0)
|
avfilter_unref_bufferp(&in);
|
||||||
return ret;
|
|
||||||
return 0;
|
return ff_filter_frame(outlink, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const AVFilterPad avfilter_vf_delogo_inputs[] = {
|
static const AVFilterPad avfilter_vf_delogo_inputs[] = {
|
||||||
@@ -251,9 +260,7 @@ static const AVFilterPad avfilter_vf_delogo_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,
|
||||||
.start_frame = ff_inplace_start_frame,
|
.filter_frame = filter_frame,
|
||||||
.draw_slice = null_draw_slice,
|
|
||||||
.end_frame = end_frame,
|
|
||||||
.min_perms = AV_PERM_WRITE | AV_PERM_READ,
|
.min_perms = AV_PERM_WRITE | AV_PERM_READ,
|
||||||
},
|
},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
|
|||||||
Reference in New Issue
Block a user