FFmpeg
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVRESAMPLE_INTERNAL_H
22 #define AVRESAMPLE_INTERNAL_H
23 
24 #include "libavutil/audio_fifo.h"
25 #include "libavutil/log.h"
26 #include "libavutil/opt.h"
27 #include "libavutil/samplefmt.h"
28 #include "avresample.h"
29 
30 typedef struct AudioData AudioData;
31 typedef struct AudioConvert AudioConvert;
32 typedef struct AudioMix AudioMix;
33 typedef struct ResampleContext ResampleContext;
34 
35 enum RemapPoint {
41 };
42 
43 typedef struct ChannelMapInfo {
44  int channel_map[AVRESAMPLE_MAX_CHANNELS]; /**< source index of each output channel, -1 if not remapped */
45  int do_remap; /**< remap needed */
46  int channel_copy[AVRESAMPLE_MAX_CHANNELS]; /**< dest index to copy from */
47  int do_copy; /**< copy needed */
48  int channel_zero[AVRESAMPLE_MAX_CHANNELS]; /**< dest index to zero */
49  int do_zero; /**< zeroing needed */
50  int input_map[AVRESAMPLE_MAX_CHANNELS]; /**< dest index of each input channel */
52 
54  const AVClass *av_class; /**< AVClass for logging and AVOptions */
55 
56  uint64_t in_channel_layout; /**< input channel layout */
57  enum AVSampleFormat in_sample_fmt; /**< input sample format */
58  int in_sample_rate; /**< input sample rate */
59  uint64_t out_channel_layout; /**< output channel layout */
60  enum AVSampleFormat out_sample_fmt; /**< output sample format */
61  int out_sample_rate; /**< output sample rate */
62  enum AVSampleFormat internal_sample_fmt; /**< internal sample format */
63  enum AVMixCoeffType mix_coeff_type; /**< mixing coefficient type */
64  double center_mix_level; /**< center mix level */
65  double surround_mix_level; /**< surround mix level */
66  double lfe_mix_level; /**< lfe mix level */
67  int normalize_mix_level; /**< enable mix level normalization */
68  int force_resampling; /**< force resampling */
69  int filter_size; /**< length of each FIR filter in the resampling filterbank relative to the cutoff frequency */
70  int phase_shift; /**< log2 of the number of entries in the resampling polyphase filterbank */
71  int linear_interp; /**< if 1 then the resampling FIR filter will be linearly interpolated */
72  double cutoff; /**< resampling cutoff frequency. 1.0 corresponds to half the output sample rate */
73  enum AVResampleFilterType filter_type; /**< resampling filter type */
74  int kaiser_beta; /**< beta value for Kaiser window (only applicable if filter_type == AV_FILTER_TYPE_KAISER) */
75  enum AVResampleDitherMethod dither_method; /**< dither method */
76 
77  int in_channels; /**< number of input channels */
78  int out_channels; /**< number of output channels */
79  int resample_channels; /**< number of channels used for resampling */
80  int downmix_needed; /**< downmixing is needed */
81  int upmix_needed; /**< upmixing is needed */
82  int mixing_needed; /**< either upmixing or downmixing is needed */
83  int resample_needed; /**< resampling is needed */
84  int in_convert_needed; /**< input sample format conversion is needed */
85  int out_convert_needed; /**< output sample format conversion is needed */
86  int in_copy_needed; /**< input data copy is needed */
87 
88  AudioData *in_buffer; /**< buffer for converted input */
89  AudioData *resample_out_buffer; /**< buffer for output from resampler */
90  AudioData *out_buffer; /**< buffer for converted output */
91  AVAudioFifo *out_fifo; /**< FIFO for output samples */
92 
93  AudioConvert *ac_in; /**< input sample format conversion context */
94  AudioConvert *ac_out; /**< output sample format conversion context */
95  ResampleContext *resample; /**< resampling context */
96  AudioMix *am; /**< channel mixing context */
97  enum AVMatrixEncoding matrix_encoding; /**< matrixed stereo encoding */
98 
99  /**
100  * mix matrix
101  * only used if avresample_set_matrix() is called before avresample_open()
102  */
103  double *mix_matrix;
104 
108 };
109 
110 
112  enum AVSampleFormat sample_fmt);
114  enum AVSampleFormat sample_fmt);
115 
116 #endif /* AVRESAMPLE_INTERNAL_H */
AVAudioResampleContext::in_sample_fmt
enum AVSampleFormat in_sample_fmt
input sample format
Definition: internal.h:57
AVAudioResampleContext::mix_matrix
double * mix_matrix
mix matrix only used if avresample_set_matrix() is called before avresample_open()
Definition: internal.h:103
AVAudioResampleContext::in_convert_needed
int in_convert_needed
input sample format conversion is needed
Definition: internal.h:84
AVAudioResampleContext::filter_size
int filter_size
length of each FIR filter in the resampling filterbank relative to the cutoff frequency
Definition: internal.h:69
ChannelMapInfo::do_copy
int do_copy
copy needed
Definition: internal.h:47
opt.h
AVAudioResampleContext::lfe_mix_level
double lfe_mix_level
lfe mix level
Definition: internal.h:66
AVAudioResampleContext::downmix_needed
int downmix_needed
downmixing is needed
Definition: internal.h:80
AVRESAMPLE_MAX_CHANNELS
#define AVRESAMPLE_MAX_CHANNELS
Definition: avresample.h:104
ff_audio_resample_init_aarch64
void ff_audio_resample_init_aarch64(ResampleContext *c, enum AVSampleFormat sample_fmt)
Definition: resample_init.c:48
AVAudioResampleContext::out_channels
int out_channels
number of output channels
Definition: internal.h:78
AVAudioResampleContext::matrix_encoding
enum AVMatrixEncoding matrix_encoding
matrixed stereo encoding
Definition: internal.h:97
ff_audio_resample_init_arm
void ff_audio_resample_init_arm(ResampleContext *c, enum AVSampleFormat sample_fmt)
Definition: resample_init.c:52
avresample.h
AudioData
Audio buffer used for intermediate storage between conversion phases.
Definition: audio_data.h:37
AVAudioFifo
Context for an Audio FIFO Buffer.
Definition: audio_fifo.c:34
AVAudioResampleContext
Definition: internal.h:53
ChannelMapInfo
Definition: internal.h:43
AVAudioResampleContext::ch_map_info
ChannelMapInfo ch_map_info
Definition: internal.h:107
AVAudioResampleContext::linear_interp
int linear_interp
if 1 then the resampling FIR filter will be linearly interpolated
Definition: internal.h:71
samplefmt.h
AVAudioResampleContext::cutoff
double cutoff
resampling cutoff frequency.
Definition: internal.h:72
AVMixCoeffType
enum attribute_deprecated AVMixCoeffType
Definition: avresample.h:112
AVAudioResampleContext::in_buffer
AudioData * in_buffer
buffer for converted input
Definition: internal.h:88
REMAP_IN_CONVERT
@ REMAP_IN_CONVERT
Definition: internal.h:38
AVAudioResampleContext::ac_out
AudioConvert * ac_out
output sample format conversion context
Definition: internal.h:94
ChannelMapInfo::channel_map
int channel_map[AVRESAMPLE_MAX_CHANNELS]
source index of each output channel, -1 if not remapped
Definition: internal.h:44
AVAudioResampleContext::filter_type
enum AVResampleFilterType filter_type
resampling filter type
Definition: internal.h:73
REMAP_NONE
@ REMAP_NONE
Definition: internal.h:36
AVAudioResampleContext::ac_in
AudioConvert * ac_in
input sample format conversion context
Definition: internal.h:93
AVAudioResampleContext::av_class
const AVClass * av_class
AVClass for logging and AVOptions
Definition: internal.h:54
ChannelMapInfo::do_remap
int do_remap
remap needed
Definition: internal.h:45
ResampleContext
Definition: af_resample.c:38
AudioMix
Definition: audio_mix.c:33
AVAudioResampleContext::in_copy_needed
int in_copy_needed
input data copy is needed
Definition: internal.h:86
AVAudioResampleContext::upmix_needed
int upmix_needed
upmixing is needed
Definition: internal.h:81
AVMatrixEncoding
AVMatrixEncoding
Definition: channel_layout.h:120
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
AVAudioResampleContext::out_convert_needed
int out_convert_needed
output sample format conversion is needed
Definition: internal.h:85
AVAudioResampleContext::surround_mix_level
double surround_mix_level
surround mix level
Definition: internal.h:65
AVAudioResampleContext::resample_out_buffer
AudioData * resample_out_buffer
buffer for output from resampler
Definition: internal.h:89
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AVResampleFilterType
enum attribute_deprecated AVResampleFilterType
Definition: avresample.h:123
AVAudioResampleContext::resample
ResampleContext * resample
resampling context
Definition: internal.h:95
ChannelMapInfo::channel_copy
int channel_copy[AVRESAMPLE_MAX_CHANNELS]
dest index to copy from
Definition: internal.h:46
REMAP_OUT_CONVERT
@ REMAP_OUT_CONVERT
Definition: internal.h:40
AVAudioResampleContext::force_resampling
int force_resampling
force resampling
Definition: internal.h:68
AVAudioResampleContext::out_sample_rate
int out_sample_rate
output sample rate
Definition: internal.h:61
AVAudioResampleContext::am
AudioMix * am
channel mixing context
Definition: internal.h:96
AVAudioResampleContext::dither_method
enum AVResampleDitherMethod dither_method
dither method
Definition: internal.h:75
AVAudioResampleContext::kaiser_beta
int kaiser_beta
beta value for Kaiser window (only applicable if filter_type == AV_FILTER_TYPE_KAISER)
Definition: internal.h:74
AVAudioResampleContext::out_sample_fmt
enum AVSampleFormat out_sample_fmt
output sample format
Definition: internal.h:60
AVAudioResampleContext::in_channel_layout
uint64_t in_channel_layout
input channel layout
Definition: internal.h:56
log.h
AVAudioResampleContext::in_channels
int in_channels
number of input channels
Definition: internal.h:77
AVAudioResampleContext::in_sample_rate
int in_sample_rate
input sample rate
Definition: internal.h:58
AVAudioResampleContext::center_mix_level
double center_mix_level
center mix level
Definition: internal.h:64
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
AVAudioResampleContext::resample_needed
int resample_needed
resampling is needed
Definition: internal.h:83
REMAP_IN_COPY
@ REMAP_IN_COPY
Definition: internal.h:37
RemapPoint
RemapPoint
Definition: internal.h:35
audio_fifo.h
ChannelMapInfo::input_map
int input_map[AVRESAMPLE_MAX_CHANNELS]
dest index of each input channel
Definition: internal.h:50
REMAP_OUT_COPY
@ REMAP_OUT_COPY
Definition: internal.h:39
AVAudioResampleContext::out_fifo
AVAudioFifo * out_fifo
FIFO for output samples
Definition: internal.h:91
AVAudioResampleContext::out_buffer
AudioData * out_buffer
buffer for converted output
Definition: internal.h:90
AVAudioResampleContext::internal_sample_fmt
enum AVSampleFormat internal_sample_fmt
internal sample format
Definition: internal.h:62
AVAudioResampleContext::remap_point
enum RemapPoint remap_point
Definition: internal.h:106
AVAudioResampleContext::phase_shift
int phase_shift
log2 of the number of entries in the resampling polyphase filterbank
Definition: internal.h:70
AudioConvert
Definition: audio_convert.c:48
AVResampleDitherMethod
enum attribute_deprecated AVResampleDitherMethod
Definition: avresample.h:132
AVAudioResampleContext::mixing_needed
int mixing_needed
either upmixing or downmixing is needed
Definition: internal.h:82
ChannelMapInfo::channel_zero
int channel_zero[AVRESAMPLE_MAX_CHANNELS]
dest index to zero
Definition: internal.h:48
AVAudioResampleContext::mix_coeff_type
enum AVMixCoeffType mix_coeff_type
mixing coefficient type
Definition: internal.h:63
AVAudioResampleContext::resample_channels
int resample_channels
number of channels used for resampling
Definition: internal.h:79
AVAudioResampleContext::use_channel_map
int use_channel_map
Definition: internal.h:105
ChannelMapInfo::do_zero
int do_zero
zeroing needed
Definition: internal.h:49
AVAudioResampleContext::normalize_mix_level
int normalize_mix_level
enable mix level normalization
Definition: internal.h:67
AVAudioResampleContext::out_channel_layout
uint64_t out_channel_layout
output channel layout
Definition: internal.h:59