Commit 6d58358a authored by Anton Khirnov's avatar Anton Khirnov

lavfi: make avfilter_get_video_buffer() private on next bump.

They are only useful inside filters and we don't allow user filters for
now.
parent 8772997d
...@@ -573,19 +573,11 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, ...@@ -573,19 +573,11 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
*/ */
int avfilter_config_links(AVFilterContext *filter); int avfilter_config_links(AVFilterContext *filter);
/** #if FF_API_FILTERS_PUBLIC
* Request a picture buffer with a specific set of permissions. attribute_deprecated
*
* @param link the output link to the filter from which the buffer will
* be requested
* @param perms the required access permissions
* @param w the minimum width of the buffer to allocate
* @param h the minimum height of the buffer to allocate
* @return A reference to the buffer. This must be unreferenced with
* avfilter_unref_buffer when you are finished with it.
*/
AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms,
int w, int h); int w, int h);
#endif
/** /**
* Create a buffer reference wrapped around an already allocated image * Create a buffer reference wrapped around an already allocated image
......
...@@ -109,8 +109,8 @@ int av_buffersrc_write_frame(AVFilterContext *buffer_filter, AVFrame *frame) ...@@ -109,8 +109,8 @@ int av_buffersrc_write_frame(AVFilterContext *buffer_filter, AVFrame *frame)
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
CHECK_VIDEO_PARAM_CHANGE(buffer_filter, c, frame->width, frame->height, CHECK_VIDEO_PARAM_CHANGE(buffer_filter, c, frame->width, frame->height,
frame->format); frame->format);
buf = avfilter_get_video_buffer(buffer_filter->outputs[0], AV_PERM_WRITE, buf = ff_get_video_buffer(buffer_filter->outputs[0], AV_PERM_WRITE,
c->w, c->h); c->w, c->h);
av_image_copy(buf->data, buf->linesize, frame->data, frame->linesize, av_image_copy(buf->data, buf->linesize, frame->data, frame->linesize,
c->pix_fmt, c->w, c->h); c->pix_fmt, c->w, c->h);
break; break;
......
...@@ -219,8 +219,8 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) ...@@ -219,8 +219,8 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
AVFilterBufferRef *outpicref; AVFilterBufferRef *outpicref;
if (inpicref->perms & AV_PERM_PRESERVE) { if (inpicref->perms & AV_PERM_PRESERVE) {
outpicref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->h); outlink->w, outlink->h);
avfilter_copy_buffer_ref_props(outpicref, inpicref); avfilter_copy_buffer_ref_props(outpicref, inpicref);
outpicref->video->w = outlink->w; outpicref->video->w = outlink->w;
outpicref->video->h = outlink->h; outpicref->video->h = outlink->h;
......
...@@ -112,7 +112,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int ...@@ -112,7 +112,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0]; AVFilterLink *outlink = ctx->outputs[0];
return avfilter_get_video_buffer(outlink, perms, w, h); return ff_get_video_buffer(outlink, perms, w, h);
} }
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
......
...@@ -432,7 +432,7 @@ static int source_config_props(AVFilterLink *outlink) ...@@ -432,7 +432,7 @@ static int source_config_props(AVFilterLink *outlink)
static int source_request_frame(AVFilterLink *outlink) static int source_request_frame(AVFilterLink *outlink)
{ {
Frei0rContext *frei0r = outlink->src->priv; Frei0rContext *frei0r = outlink->src->priv;
AVFilterBufferRef *picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); AVFilterBufferRef *picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
picref->video->pixel_aspect = (AVRational) {1, 1}; picref->video->pixel_aspect = (AVRational) {1, 1};
picref->pts = frei0r->pts++; picref->pts = frei0r->pts++;
picref->pos = -1; picref->pos = -1;
......
...@@ -190,7 +190,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) ...@@ -190,7 +190,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
AVFilterBufferRef *outpicref; AVFilterBufferRef *outpicref;
if (inpicref->perms & AV_PERM_PRESERVE) { if (inpicref->perms & AV_PERM_PRESERVE) {
outpicref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
avfilter_copy_buffer_ref_props(outpicref, inpicref); avfilter_copy_buffer_ref_props(outpicref, inpicref);
outpicref->video->w = outlink->w; outpicref->video->w = outlink->w;
outpicref->video->h = outlink->h; outpicref->video->h = outlink->h;
......
...@@ -205,7 +205,7 @@ static int config_output(AVFilterLink *outlink) ...@@ -205,7 +205,7 @@ static int config_output(AVFilterLink *outlink)
static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int w, int h) static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int w, int h)
{ {
return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); return ff_get_video_buffer(link->dst->outputs[0], perms, w, h);
} }
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
......
...@@ -256,9 +256,9 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int ...@@ -256,9 +256,9 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int
{ {
PadContext *pad = inlink->dst->priv; PadContext *pad = inlink->dst->priv;
AVFilterBufferRef *picref = avfilter_get_video_buffer(inlink->dst->outputs[0], perms, AVFilterBufferRef *picref = ff_get_video_buffer(inlink->dst->outputs[0], perms,
w + (pad->w - pad->in_w), w + (pad->w - pad->in_w),
h + (pad->h - pad->in_h)); h + (pad->h - pad->in_h));
int plane; int plane;
picref->video->w = w; picref->video->w = w;
...@@ -327,9 +327,9 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) ...@@ -327,9 +327,9 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
if(pad->needs_copy){ if(pad->needs_copy){
av_log(inlink->dst, AV_LOG_DEBUG, "Direct padding impossible allocating new frame\n"); av_log(inlink->dst, AV_LOG_DEBUG, "Direct padding impossible allocating new frame\n");
avfilter_unref_buffer(outpicref); avfilter_unref_buffer(outpicref);
outpicref = avfilter_get_video_buffer(inlink->dst->outputs[0], AV_PERM_WRITE | AV_PERM_NEG_LINESIZES, outpicref = ff_get_video_buffer(inlink->dst->outputs[0], AV_PERM_WRITE | AV_PERM_NEG_LINESIZES,
FFMAX(inlink->w, pad->w), FFMAX(inlink->w, pad->w),
FFMAX(inlink->h, pad->h)); FFMAX(inlink->h, pad->h));
avfilter_copy_buffer_ref_props(outpicref, inpicref); avfilter_copy_buffer_ref_props(outpicref, inpicref);
} }
......
...@@ -57,8 +57,8 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) ...@@ -57,8 +57,8 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
AVFilterBufferRef *outpicref; AVFilterBufferRef *outpicref;
int i; int i;
outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->h); outlink->w, outlink->h);
outpicref = outlink->out_buf; outpicref = outlink->out_buf;
avfilter_copy_buffer_ref_props(outpicref, picref); avfilter_copy_buffer_ref_props(outpicref, picref);
......
...@@ -265,7 +265,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) ...@@ -265,7 +265,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
scale->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w; scale->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w;
scale->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h; scale->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h;
outpicref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
avfilter_copy_buffer_ref_props(outpicref, picref); avfilter_copy_buffer_ref_props(outpicref, picref);
outpicref->video->w = outlink->w; outpicref->video->w = outlink->w;
outpicref->video->h = outlink->h; outpicref->video->h = outlink->h;
......
...@@ -120,8 +120,8 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) ...@@ -120,8 +120,8 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{ {
AVFilterLink *outlink = inlink->dst->outputs[0]; AVFilterLink *outlink = inlink->dst->outputs[0];
outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->h); outlink->w, outlink->h);
outlink->out_buf->pts = picref->pts; outlink->out_buf->pts = picref->pts;
if (picref->video->pixel_aspect.num == 0) { if (picref->video->pixel_aspect.num == 0) {
......
...@@ -50,7 +50,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, ...@@ -50,7 +50,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms,
if (!(perms & AV_PERM_NEG_LINESIZES)) if (!(perms & AV_PERM_NEG_LINESIZES))
return ff_default_get_video_buffer(link, perms, w, h); return ff_default_get_video_buffer(link, perms, w, h);
picref = avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); picref = ff_get_video_buffer(link->dst->outputs[0], perms, w, h);
for (i = 0; i < 4; i ++) { for (i = 0; i < 4; i ++) {
int vsub = i == 1 || i == 2 ? flip->vsub : 0; int vsub = i == 1 || i == 2 ? flip->vsub : 0;
......
...@@ -208,8 +208,8 @@ static void return_frame(AVFilterContext *ctx, int is_second) ...@@ -208,8 +208,8 @@ static void return_frame(AVFilterContext *ctx, int is_second)
} }
if (is_second) { if (is_second) {
yadif->out = avfilter_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE | yadif->out = ff_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE, link->w, link->h); AV_PERM_REUSE, link->w, link->h);
avfilter_copy_buffer_ref_props(yadif->out, yadif->cur); avfilter_copy_buffer_ref_props(yadif->out, yadif->cur);
yadif->out->video->interlaced = 0; yadif->out->video->interlaced = 0;
} }
...@@ -268,8 +268,8 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) ...@@ -268,8 +268,8 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
if (!yadif->prev) if (!yadif->prev)
yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ); yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ);
yadif->out = avfilter_get_video_buffer(ctx->outputs[0], AV_PERM_WRITE | AV_PERM_PRESERVE | yadif->out = ff_get_video_buffer(ctx->outputs[0], AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE, link->w, link->h); AV_PERM_REUSE, link->w, link->h);
avfilter_copy_buffer_ref_props(yadif->out, yadif->cur); avfilter_copy_buffer_ref_props(yadif->out, yadif->cur);
yadif->out->video->interlaced = 0; yadif->out->video->interlaced = 0;
......
...@@ -67,7 +67,7 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end) ...@@ -67,7 +67,7 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end)
AVFilterBufferRef *ff_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h) AVFilterBufferRef *ff_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
{ {
return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); return ff_get_video_buffer(link->dst->outputs[0], perms, w, h);
} }
/* TODO: set the buffer's priv member to a context structure for the whole /* TODO: set the buffer's priv member to a context structure for the whole
...@@ -138,7 +138,7 @@ fail: ...@@ -138,7 +138,7 @@ fail:
return NULL; return NULL;
} }
AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h) AVFilterBufferRef *ff_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
{ {
AVFilterBufferRef *ret = NULL; AVFilterBufferRef *ret = NULL;
...@@ -173,7 +173,7 @@ static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) ...@@ -173,7 +173,7 @@ static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
outlink = inlink->dst->outputs[0]; outlink = inlink->dst->outputs[0];
if (outlink) { if (outlink) {
outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
avfilter_copy_buffer_ref_props(outlink->out_buf, picref); avfilter_copy_buffer_ref_props(outlink->out_buf, picref);
ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
} }
...@@ -201,7 +201,7 @@ void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) ...@@ -201,7 +201,7 @@ void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
picref->perms, picref->perms,
link->dstpad->min_perms, link->dstpad->rej_perms); link->dstpad->min_perms, link->dstpad->rej_perms);
link->cur_buf = avfilter_get_video_buffer(link, dst->min_perms, link->w, link->h); link->cur_buf = ff_get_video_buffer(link, dst->min_perms, link->w, link->h);
link->src_buf = picref; link->src_buf = picref;
avfilter_copy_buffer_ref_props(link->cur_buf, link->src_buf); avfilter_copy_buffer_ref_props(link->cur_buf, link->src_buf);
} }
...@@ -354,4 +354,8 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) ...@@ -354,4 +354,8 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
{ {
ff_draw_slice(link, y, h, slice_dir); ff_draw_slice(link, y, h, slice_dir);
} }
AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
{
return ff_get_video_buffer(link, perms, w, h);
}
#endif #endif
...@@ -25,6 +25,20 @@ AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, ...@@ -25,6 +25,20 @@ AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link,
int perms, int w, int h); int perms, int w, int h);
AVFilterBufferRef *ff_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h); AVFilterBufferRef *ff_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h);
/**
* Request a picture buffer with a specific set of permissions.
*
* @param link the output link to the filter from which the buffer will
* be requested
* @param perms the required access permissions
* @param w the minimum width of the buffer to allocate
* @param h the minimum height of the buffer to allocate
* @return A reference to the buffer. This must be unreferenced with
* avfilter_unref_buffer when you are finished with it.
*/
AVFilterBufferRef *ff_get_video_buffer(AVFilterLink *link, int perms,
int w, int h);
void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
void ff_null_end_frame(AVFilterLink *link); void ff_null_end_frame(AVFilterLink *link);
......
...@@ -140,7 +140,7 @@ static int color_config_props(AVFilterLink *inlink) ...@@ -140,7 +140,7 @@ static int color_config_props(AVFilterLink *inlink)
static int color_request_frame(AVFilterLink *link) static int color_request_frame(AVFilterLink *link)
{ {
ColorContext *color = link->src->priv; ColorContext *color = link->src->priv;
AVFilterBufferRef *picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, color->w, color->h); AVFilterBufferRef *picref = ff_get_video_buffer(link, AV_PERM_WRITE, color->w, color->h);
picref->video->pixel_aspect = (AVRational) {1, 1}; picref->video->pixel_aspect = (AVRational) {1, 1};
picref->pts = color->pts++; picref->pts = color->pts++;
picref->pos = -1; picref->pos = -1;
......
...@@ -237,8 +237,8 @@ static int movie_get_frame(AVFilterLink *outlink) ...@@ -237,8 +237,8 @@ static int movie_get_frame(AVFilterLink *outlink)
if (frame_decoded) { if (frame_decoded) {
/* FIXME: avoid the memcpy */ /* FIXME: avoid the memcpy */
movie->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE | AV_PERM_PRESERVE | movie->picref = ff_get_video_buffer(outlink, AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE2, outlink->w, outlink->h); AV_PERM_REUSE2, outlink->w, outlink->h);
av_image_copy(movie->picref->data, movie->picref->linesize, av_image_copy(movie->picref->data, movie->picref->linesize,
movie->frame->data, movie->frame->linesize, movie->frame->data, movie->frame->linesize,
movie->picref->format, outlink->w, outlink->h); movie->picref->format, outlink->w, outlink->h);
......
...@@ -132,8 +132,7 @@ static int request_frame(AVFilterLink *outlink) ...@@ -132,8 +132,7 @@ static int request_frame(AVFilterLink *outlink)
if (test->max_pts >= 0 && test->pts > test->max_pts) if (test->max_pts >= 0 && test->pts > test->max_pts)
return AVERROR_EOF; return AVERROR_EOF;
picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, test->w, test->h);
test->w, test->h);
picref->pts = test->pts++; picref->pts = test->pts++;
picref->pos = -1; picref->pos = -1;
picref->video->key_frame = 1; picref->video->key_frame = 1;
......
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