FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
video.c
Go to the documentation of this file.
1 /*
2  * Copyright 2007 Bobby Bingham
3  * Copyright Stefano Sabatini <stefasab gmail com>
4  * Copyright Vitor Sessak <vitor1001 gmail com>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include <string.h>
24 #include <stdio.h>
25 
26 #include "libavutil/avassert.h"
27 #include "libavutil/buffer.h"
28 #include "libavutil/imgutils.h"
29 #include "libavutil/mem.h"
30 
31 #include "avfilter.h"
32 #include "internal.h"
33 #include "video.h"
34 
35 #define BUFFER_ALIGN 32
36 
37 
39 {
40  return ff_get_video_buffer(link->dst->outputs[0], w, h);
41 }
42 
44 {
45  int pool_width = 0;
46  int pool_height = 0;
47  int pool_align = 0;
48  enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
49 
50  if (!link->video_frame_pool) {
52  link->format, BUFFER_ALIGN);
53  if (!link->video_frame_pool)
54  return NULL;
55  } else {
57  &pool_width, &pool_height,
58  &pool_format, &pool_align) < 0) {
59  return NULL;
60  }
61 
62  if (pool_width != w || pool_height != h ||
63  pool_format != link->format || pool_align != BUFFER_ALIGN) {
64 
67  link->format, BUFFER_ALIGN);
68  if (!link->video_frame_pool)
69  return NULL;
70  }
71  }
72 
74 }
75 
77 {
78  AVFrame *ret = NULL;
79 
81 
82  if (link->dstpad->get_video_buffer)
83  ret = link->dstpad->get_video_buffer(link, w, h);
84 
85  if (!ret)
86  ret = ff_default_get_video_buffer(link, w, h);
87 
88  return ret;
89 }
#define NULL
Definition: coverity.c:32
This structure describes decoded (raw) audio or video data.
Definition: frame.h:184
misc image utilities
void ff_video_frame_pool_uninit(FFVideoFramePool **pool)
Deallocate the video frame pool.
Definition: framepool.c:177
Main libavfilter public API header.
memory handling functions
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:38
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:76
FFVideoFramePool * ff_video_frame_pool_init(AVBufferRef *(*alloc)(int size), int width, int height, enum AVPixelFormat format, int align)
Allocate and initialize a video frame pool.
Definition: framepool.c:40
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: avf_concat.c:206
Video frame pool.
Definition: framepool.c:29
int ff_video_frame_pool_get_config(FFVideoFramePool *pool, int *width, int *height, enum AVPixelFormat *format, int *align)
Get the video frame pool configuration.
Definition: framepool.c:107
AVFrame * ff_video_frame_pool_get(FFVideoFramePool *pool)
Allocate a new AVFrame, reussing old buffers from the pool when available.
Definition: framepool.c:125
simple assert() macros that are a bit more flexible than ISO C assert().
#define FF_TPRINTF_START(ctx, func)
Definition: internal.h:256
AVFrame *(* get_video_buffer)(AVFilterLink *link, int w, int h)
Callback function to get a video buffer.
Definition: internal.h:72
void ff_tlog_link(void *ctx, AVFilterLink *link, int end)
Definition: avfilter.c:345
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
Definition: buffer.c:82
refcounted data buffer API
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:317
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:43
#define BUFFER_ALIGN
Definition: video.c:35
internal API functions
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60