+char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms)
+{
+ snprintf(buf, buf_size, "%s%s%s%s%s",
+ perms & AV_PERM_READ ? "r" : "",
+ perms & AV_PERM_WRITE ? "w" : "",
+ perms & AV_PERM_PRESERVE ? "p" : "",
+ perms & AV_PERM_REUSE ? "r" : "",
+ perms & AV_PERM_REUSE2 ? "R" : "");
+ return buf;
+}
+
+void ff_dprintf_ref(void *ctx, AVFilterBufferRef *ref, int end)
+{
+ av_unused char buf[16];
+ dprintf(ctx,
+ "ref[%p buf:%p refcount:%d perms:%s data:%p linesize[%d, %d, %d, %d] pts:%"PRId64" pos:%"PRId64,
+ ref, ref->buf, ref->buf->refcount, ff_get_ref_perms_string(buf, sizeof(buf), ref->perms), ref->data[0],
+ ref->linesize[0], ref->linesize[1], ref->linesize[2], ref->linesize[3],
+ ref->pts, ref->pos);
+
+ if (ref->video) {
+ dprintf(ctx, " a:%d/%d s:%dx%d i:%c",
+ ref->video->pixel_aspect.num, ref->video->pixel_aspect.den,
+ ref->video->w, ref->video->h,
+ !ref->video->interlaced ? 'P' : /* Progressive */
+ ref->video->top_field_first ? 'T' : 'B'); /* Top / Bottom */
+ }
+ if (ref->audio) {
+ dprintf(ctx, " cl:%"PRId64"d sn:%d s:%d sr:%d p:%d",
+ ref->audio->channel_layout,
+ ref->audio->samples_nb,
+ ref->audio->size,
+ ref->audio->sample_rate,
+ ref->audio->planar);
+ }
+
+ dprintf(ctx, "]%s", end ? "\n" : "");
+}
+
+void ff_dprintf_link(void *ctx, AVFilterLink *link, int end)
+{
+ dprintf(ctx,
+ "link[%p s:%dx%d fmt:%-16s %-16s->%-16s]%s",
+ link, link->w, link->h,
+ av_pix_fmt_descriptors[link->format].name,
+ link->src ? link->src->filter->name : "",
+ link->dst ? link->dst->filter->name : "",
+ end ? "\n" : "");
+}
+
+AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)