#include "libavcodec/imgconvert.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
+#include "internal.h"
unsigned avfilter_version(void) {
return LIBAVFILTER_VERSION_INT;
#define link_dpad(link) link->dst-> input_pads[link->dstpad]
#define link_spad(link) link->src->output_pads[link->srcpad]
-AVFilterPicRef *avfilter_ref_pic(AVFilterPicRef *ref, int pmask)
+AVFilterBufferRef *avfilter_ref_pic(AVFilterBufferRef *ref, int pmask)
{
- AVFilterPicRef *ret = av_malloc(sizeof(AVFilterPicRef));
+ AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef));
*ret = *ref;
ret->perms &= pmask;
ret->pic->refcount ++;
return ret;
}
-void avfilter_unref_pic(AVFilterPicRef *ref)
+void avfilter_unref_pic(AVFilterBufferRef *ref)
{
if(!(--ref->pic->refcount))
ref->pic->free(ref->pic);
link->dst = dst;
link->srcpad = srcpad;
link->dstpad = dstpad;
- link->format = PIX_FMT_NONE;
+ link->type = src->output_pads[srcpad].type;
+ assert(PIX_FMT_NONE == -1 && SAMPLE_FMT_NONE == -1);
+ link->format = -1;
return 0;
}
link->dstpad = in;
filt->inputs[in] = link;
- /* if any information on supported colorspaces already exists on the
+ /* if any information on supported media formats already exists on the
* link, we need to preserve that */
if(link->out_formats)
avfilter_formats_changeref(&link->out_formats,
return 0;
}
-static void dprintf_picref(void *ctx, AVFilterPicRef *picref, int end)
+void ff_dprintf_picref(void *ctx, AVFilterBufferRef *picref, int end)
{
dprintf(ctx,
"picref[%p data[%p, %p, %p, %p] linesize[%d, %d, %d, %d] pts:%"PRId64" pos:%"PRId64" a:%d/%d s:%dx%d]%s",
end ? "\n" : "");
}
-static void dprintf_link(void *ctx, AVFilterLink *link, int end)
+void ff_dprintf_link(void *ctx, AVFilterLink *link, int end)
{
dprintf(ctx,
"link[%p s:%dx%d fmt:%-16s %-16s->%-16s]%s",
end ? "\n" : "");
}
-#define DPRINTF_START(ctx, func) dprintf(NULL, "%-16s: ", #func)
-
-AVFilterPicRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
+AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
{
- AVFilterPicRef *ret = NULL;
+ AVFilterBufferRef *ret = NULL;
- DPRINTF_START(NULL, get_video_buffer); dprintf_link(NULL, link, 0); dprintf(NULL, " perms:%d w:%d h:%d\n", perms, w, h);
+ FF_DPRINTF_START(NULL, get_video_buffer); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " perms:%d w:%d h:%d\n", perms, w, h);
if(link_dpad(link).get_video_buffer)
ret = link_dpad(link).get_video_buffer(link, perms, w, h);
if(!ret)
ret = avfilter_default_get_video_buffer(link, perms, w, h);
- DPRINTF_START(NULL, get_video_buffer); dprintf_link(NULL, link, 0); dprintf(NULL, " returning "); dprintf_picref(NULL, ret, 1);
+ FF_DPRINTF_START(NULL, get_video_buffer); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " returning "); ff_dprintf_picref(NULL, ret, 1);
return ret;
}
int avfilter_request_frame(AVFilterLink *link)
{
- DPRINTF_START(NULL, request_frame); dprintf_link(NULL, link, 1);
+ FF_DPRINTF_START(NULL, request_frame); ff_dprintf_link(NULL, link, 1);
if(link_spad(link).request_frame)
return link_spad(link).request_frame(link);
/* XXX: should we do the duplicating of the picture ref here, instead of
* forcing the source filter to do it? */
-void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref)
+void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
{
- void (*start_frame)(AVFilterLink *, AVFilterPicRef *);
+ void (*start_frame)(AVFilterLink *, AVFilterBufferRef *);
AVFilterPad *dst = &link_dpad(link);
- DPRINTF_START(NULL, start_frame); dprintf_link(NULL, link, 0); dprintf(NULL, " "); dprintf_picref(NULL, picref, 1);
+ FF_DPRINTF_START(NULL, start_frame); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " "); ff_dprintf_picref(NULL, picref, 1);
if(!(start_frame = dst->start_frame))
start_frame = avfilter_default_start_frame;
int i, j, vsub;
void (*draw_slice)(AVFilterLink *, int, int, int);
- DPRINTF_START(NULL, draw_slice); dprintf_link(NULL, link, 0); dprintf(NULL, " y:%d h:%d dir:%d\n", y, h, slice_dir);
+ FF_DPRINTF_START(NULL, draw_slice); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " y:%d h:%d dir:%d\n", y, h, slice_dir);
/* copy the slice if needed for permission reasons */
if(link->srcpic) {
filter->filter->uninit(filter);
for(i = 0; i < filter->input_count; i ++) {
- if(filter->inputs[i])
- filter->inputs[i]->src->outputs[filter->inputs[i]->srcpad] = NULL;
+ if(filter->inputs[i]) {
+ if (filter->inputs[i]->src)
+ filter->inputs[i]->src->outputs[filter->inputs[i]->srcpad] = NULL;
+ avfilter_formats_unref(&filter->inputs[i]->in_formats);
+ avfilter_formats_unref(&filter->inputs[i]->out_formats);
+ }
av_freep(&filter->inputs[i]);
}
for(i = 0; i < filter->output_count; i ++) {
- if(filter->outputs[i])
- filter->outputs[i]->dst->inputs[filter->outputs[i]->dstpad] = NULL;
+ if(filter->outputs[i]) {
+ if (filter->outputs[i]->dst)
+ filter->outputs[i]->dst->inputs[filter->outputs[i]->dstpad] = NULL;
+ avfilter_formats_unref(&filter->outputs[i]->in_formats);
+ avfilter_formats_unref(&filter->outputs[i]->out_formats);
+ }
av_freep(&filter->outputs[i]);
}