This source file includes following definitions.
- ff_null_get_video_buffer
- ff_default_get_video_buffer
- avfilter_get_video_buffer_ref_from_arrays
- ff_get_video_buffer
#include <string.h>
#include <stdio.h>
#include "libavutil/avassert.h"
#include "libavutil/buffer.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "avfilter.h"
#include "internal.h"
#include "video.h"
AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
{
    return ff_get_video_buffer(link->dst->outputs[0], w, h);
}
AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
{
    AVFrame *frame = av_frame_alloc();
    int ret;
    if (!frame)
        return NULL;
    frame->width  = w;
    frame->height = h;
    frame->format = link->format;
    ret = av_frame_get_buffer(frame, 32);
    if (ret < 0)
        av_frame_free(&frame);
    return frame;
}
#if FF_API_AVFILTERBUFFER
AVFilterBufferRef *
avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
                                          int w, int h, enum AVPixelFormat 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;
    
    picref->perms = perms | AV_PERM_READ;
    pic->refcount = 1;
    picref->type = AVMEDIA_TYPE_VIDEO;
    pic->format = picref->format = format;
    memcpy(pic->data,        data,          4*sizeof(data[0]));
    memcpy(pic->linesize,    linesize,      4*sizeof(linesize[0]));
    memcpy(picref->data,     pic->data,     sizeof(picref->data));
    memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
    pic->   extended_data = pic->data;
    picref->extended_data = picref->data;
    picref->pts = AV_NOPTS_VALUE;
    return picref;
fail:
    if (picref && picref->video)
        av_free(picref->video);
    av_free(picref);
    av_free(pic);
    return NULL;
}
#endif
AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int h)
{
    AVFrame *ret = NULL;
    FF_TPRINTF_START(NULL, get_video_buffer); ff_tlog_link(NULL, link, 0);
    if (link->dstpad->get_video_buffer)
        ret = link->dstpad->get_video_buffer(link, w, h);
    if (!ret)
        ret = ff_default_get_video_buffer(link, w, h);
    return ret;
}