FFmpeg
af_acopy.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 #include "audio.h"
20 #include "avfilter.h"
21 #include "internal.h"
22 
24 {
25  AVFilterLink *outlink = inlink->dst->outputs[0];
26  AVFrame *out = ff_get_audio_buffer(outlink, in->nb_samples);
27  int ret;
28 
29  if (!out) {
30  ret = AVERROR(ENOMEM);
31  goto fail;
32  }
33 
35  if (ret < 0)
36  goto fail;
37  ret = av_frame_copy(out, in);
38  if (ret < 0)
39  goto fail;
40  av_frame_free(&in);
41  return ff_filter_frame(outlink, out);
42 fail:
43  av_frame_free(&in);
45  return ret;
46 }
47 
48 static const AVFilterPad acopy_inputs[] = {
49  {
50  .name = "default",
51  .type = AVMEDIA_TYPE_AUDIO,
52  .filter_frame = filter_frame,
53  },
54 };
55 
56 static const AVFilterPad acopy_outputs[] = {
57  {
58  .name = "default",
59  .type = AVMEDIA_TYPE_AUDIO,
60  },
61 };
62 
64  .name = "acopy",
65  .description = NULL_IF_CONFIG_SMALL("Copy the input audio unchanged to the output."),
69 };
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:100
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:969
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:99
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
ff_af_acopy
const AVFilter ff_af_acopy
Definition: af_acopy.c:63
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:165
fail
#define fail()
Definition: checkasm.h:134
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:49
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:194
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:594
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_acopy.c:23
acopy_inputs
static const AVFilterPad acopy_inputs[]
Definition: af_acopy.c:48
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:115
av_frame_copy
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
Definition: frame.c:762
acopy_outputs
static const AVFilterPad acopy_outputs[]
Definition: af_acopy.c:56
internal.h
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:410
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:55
AVFilter
Filter definition.
Definition: avfilter.h:161
ret
ret
Definition: filter_design.txt:187
avfilter.h
AVFILTER_FLAG_METADATA_ONLY
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition: avfilter.h:133
audio.h
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:195