+ if (ret)
+ ret->type = AVMEDIA_TYPE_VIDEO;
+
+ FF_DPRINTF_START(NULL, get_video_buffer); ff_dlog_link(NULL, link, 0); av_dlog(NULL, " returning "); ff_dlog_ref(NULL, ret, 1);
+
+ return ret;
+}
+
+AVFilterBufferRef *
+avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
+ int w, int h, enum PixelFormat format)
+{
+ AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer));
+ AVFilterBufferRef *picref = av_mallocz(sizeof(AVFilterBufferRef));
+
+ if (!pic || !picref)
+ goto fail;
+
+ picref->buf = pic;
+ picref->buf->free = ff_avfilter_default_free_buffer;
+ if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps))))
+ goto fail;
+
+ pic->w = picref->video->w = w;
+ pic->h = picref->video->h = h;
+
+ /* make sure the buffer gets read permission or it's useless for output */
+ picref->perms = perms | AV_PERM_READ;
+
+ pic->refcount = 1;
+ picref->type = AVMEDIA_TYPE_VIDEO;
+ pic->format = picref->format = format;
+
+ memcpy(pic->data, data, sizeof(pic->data));
+ memcpy(pic->linesize, linesize, sizeof(pic->linesize));
+ memcpy(picref->data, pic->data, sizeof(picref->data));
+ memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
+
+ return picref;
+
+fail:
+ if (picref && picref->video)
+ av_free(picref->video);
+ av_free(picref);
+ av_free(pic);
+ return NULL;
+}
+
+AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
+ enum AVSampleFormat sample_fmt, int size,
+ int64_t channel_layout, int planar)
+{
+ AVFilterBufferRef *ret = NULL;
+
+ if (link->dstpad->get_audio_buffer)
+ ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar);
+
+ if (!ret)
+ ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar);
+
+ if (ret)
+ ret->type = AVMEDIA_TYPE_AUDIO;