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 * Bauer stereo-to-binaural filter
22 */
23
24 #include <bs2b.h>
25
29
34
37
41
43
46
47 #define OFFSET(x) offsetof(Bs2bContext, x)
48 #define A AV_OPT_FLAG_AUDIO_PARAM
49
51 { "profile", "Apply a pre-defined crossfeed level",
53 {
"default",
"default profile", 0,
AV_OPT_TYPE_CONST, { .i64 = BS2B_DEFAULT_CLEVEL }, 0, 0,
A,
"profile" },
54 {
"cmoy",
"Chu Moy circuit", 0,
AV_OPT_TYPE_CONST, { .i64 = BS2B_CMOY_CLEVEL }, 0, 0,
A,
"profile" },
55 {
"jmeier",
"Jan Meier circuit", 0,
AV_OPT_TYPE_CONST, { .i64 = BS2B_JMEIER_CLEVEL }, 0, 0,
A,
"profile" },
56 { "fcut", "Set cut frequency (in Hz)",
58 { "feed", "Set feed level (in Hz)",
61 };
62
64
66 {
68
69 if (!(bs2b->
bs2bp = bs2b_open()))
71
73
75 bs2b_set_level_fcut(bs2b->
bs2bp, bs2b->
fcut);
76
78 bs2b_set_level_feed(bs2b->
bs2bp, bs2b->
feed);
79
80 return 0;
81 }
82
84 {
86
88 bs2b_close(bs2b->
bs2bp);
89 }
90
92 {
95
103 };
104 int ret;
105
109 if (ret < 0)
110 return ret;
111
113 if (!formats)
116 if (ret < 0)
117 return ret;
118
120 if (!formats)
123 }
124
126 {
127 int ret;
129
132
135 } else {
137 if (!out_frame)
141 if (ret < 0) {
144 return ret;
145 }
146 }
147
149
150 if (frame != out_frame)
152
154 }
155
157 {
161
163
166 bs2b->
filter = bs2b_cross_feed_u8;
167 break;
169 bs2b->
filter = (
void*)bs2b_cross_feed_s16;
170 break;
172 bs2b->
filter = (
void*)bs2b_cross_feed_s32;
173 break;
175 bs2b->
filter = (
void*)bs2b_cross_feed_f;
176 break;
178 bs2b->
filter = (
void*)bs2b_cross_feed_d;
179 break;
180 default:
182 }
183
184 if ((srate < BS2B_MINSRATE) || (srate > BS2B_MAXSRATE))
186
187 bs2b_set_srate(bs2b->
bs2bp, srate);
188
189 return 0;
190 }
191
193 {
197 },
199 };
200
202 {
206 },
208 };
209
215 .priv_class = &bs2b_class,
220 };
This structure describes decoded (raw) audio or video data.
Main libavfilter public API header.
static const AVFilterPad bs2b_inputs[]
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static enum AVSampleFormat formats[]
#define AV_CH_LAYOUT_STEREO
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int query_formats(AVFilterContext *ctx)
A filter pad used for either input or output.
A link between two filters.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
audio channel layout utility functions
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
int format
agreed upon media format
static int config_output(AVFilterLink *outlink)
A list of supported channel layouts.
static const AVFilterPad inputs[]
AVSampleFormat
Audio sample formats.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
AVFILTER_DEFINE_CLASS(bs2b)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Describe the class of an AVClass context structure.
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
void(* filter)(t_bs2bdp bs2bdp, uint8_t *sample, int n)
static const AVOption bs2b_options[]
common internal and external API header
static const AVFilterPad bs2b_outputs[]
AVFilterContext * dst
dest filter
static av_cold void uninit(AVFilterContext *ctx)
static enum AVSampleFormat sample_fmts[]
uint8_t ** extended_data
pointers to the data planes/channels.
static av_cold int init(AVFilterContext *ctx)
int nb_samples
number of audio samples (per channel) described by this frame
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.