FFmpeg
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 "internal.h"
28 #include "video.h"
29 
31 {
33  int ret;
34 
37  if (ret < 0)
38  return ret;
40 }
41 
43 {
44  AVFilterLink *outlink = inlink->dst->outputs[0];
45  AVFrame *out = ff_get_video_buffer(outlink, in->width, in->height);
46  int ret;
47 
48  if (!out) {
49  ret = AVERROR(ENOMEM);
50  goto fail;
51  }
52 
54  if (ret < 0)
55  goto fail;
56  ret = av_frame_copy(out, in);
57  if (ret < 0)
58  goto fail;
59  av_frame_free(&in);
60  return ff_filter_frame(outlink, out);
61 fail:
62  av_frame_free(&in);
64  return ret;
65 }
66 
68  {
69  .name = "default",
70  .type = AVMEDIA_TYPE_VIDEO,
71  .filter_frame = filter_frame,
72  },
73  { NULL }
74 };
75 
77  {
78  .name = "default",
79  .type = AVMEDIA_TYPE_VIDEO,
80  },
81  { NULL }
82 };
83 
85  .name = "copy",
86  .description = NULL_IF_CONFIG_SMALL("Copy the input video unchanged to the output."),
87  .inputs = avfilter_vf_copy_inputs,
88  .outputs = avfilter_vf_copy_outputs,
89  .query_formats = query_formats,
90 };
formats
formats
Definition: signature.h:48
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:97
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:978
ff_formats_pixdesc_filter
int ff_formats_pixdesc_filter(AVFilterFormats **rfmts, unsigned want, unsigned rej)
Construct a formats list containing all pixel formats with certain properties.
Definition: formats.c:360
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:112
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
AVFrame::width
int width
Definition: frame.h:361
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:149
video.h
ff_vf_copy
const AVFilter ff_vf_copy
Definition: vf_copy.c:84
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_copy.c:30
fail
#define fail()
Definition: checkasm.h:136
AV_PIX_FMT_FLAG_HWACCEL
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:128
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
ff_set_common_formats
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:580
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_copy.c:42
ctx
AVFormatContext * ctx
Definition: movenc.c:48
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:537
avfilter_vf_copy_inputs
static const AVFilterPad avfilter_vf_copy_inputs[]
Definition: vf_copy.c:67
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:116
av_frame_copy
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
Definition: frame.c:678
internal.h
avfilter_vf_copy_outputs
static const AVFilterPad avfilter_vf_copy_outputs[]
Definition: vf_copy.c:76
internal.h
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AVFilter
Filter definition.
Definition: avfilter.h:145
ret
ret
Definition: filter_design.txt:187
AVFrame::height
int height
Definition: frame.h:361
avfilter.h
AVFilterContext
An instance of a filter.
Definition: avfilter.h:333
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
imgutils.h