FFmpeg
Loading...
Searching...
No Matches
vf_copy.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19/**
20 * @file
21 * copy video filter
22 */
23
24#include "libavutil/imgutils.h"
25#include "libavutil/internal.h"
26#include "avfilter.h"
27#include "filters.h"
28#include "formats.h"
29#include "video.h"
30
32 AVFilterFormatsConfig **cfg_in,
33 AVFilterFormatsConfig **cfg_out)
34{
35 return ff_set_common_formats2(ctx, cfg_in, cfg_out,
37}
38
39static int filter_frame(AVFilterLink *inlink, AVFrame *in)
40{
41 AVFilterLink *outlink = inlink->dst->outputs[0];
42 AVFrame *out = ff_get_video_buffer(outlink, in->width, in->height);
43 int ret;
44
45 if (!out) {
46 ret = AVERROR(ENOMEM);
47 goto fail;
48 }
49
50 ret = av_frame_copy_props(out, in);
51 if (ret < 0)
52 goto fail;
53 ret = av_frame_copy(out, in);
54 if (ret < 0)
55 goto fail;
56 av_frame_free(&in);
57 return ff_filter_frame(outlink, out);
58fail:
59 av_frame_free(&in);
61 return ret;
62}
63
65 {
66 .name = "default",
67 .type = AVMEDIA_TYPE_VIDEO,
68 .filter_frame = filter_frame,
69 },
70};
71
73 .p.name = "copy",
74 .p.description = NULL_IF_CONFIG_SMALL("Copy the input video unchanged to the output."),
79};
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
const FFFilter ff_vf_copy
Definition vf_copy.c:72
static FILE * out
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
Main libavfilter public API header.
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
int ff_set_common_formats2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, AVFilterFormats *formats)
Definition formats.c:1137
AVFilterFormats * ff_formats_pixdesc_filter(unsigned want, unsigned rej)
Construct a formats list containing all pixel formats with certain properties.
Definition formats.c:620
#define fail
Definition test.h:479
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition avfilter.h:182
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:599
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
Definition frame.c:711
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
misc image utilities
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition pixdesc.h:128
An instance of a filter.
Definition avfilter.h:273
AVFilterLink ** outputs
array of pointers to output links
Definition avfilter.h:285
Lists of formats / etc.
Definition avfilter.h:120
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
int width
Definition frame.h:544
int height
Definition frame.h:544
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition vf_copy.c:39
static const AVFilterPad avfilter_vf_copy_inputs[]
Definition vf_copy.c:64
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition vf_copy.c:31
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition video.c:37
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:89