FFmpeg
downmix_info.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Tim Walker <tdskywalker@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 AVUTIL_DOWNMIX_INFO_H
22 #define AVUTIL_DOWNMIX_INFO_H
23 
24 #include "avassert.h"
25 #include "frame.h"
26 
27 /**
28  * @file
29  * audio downmix medatata
30  */
31 
32 /**
33  * @addtogroup lavu_audio
34  * @{
35  */
36 
37 /**
38  * @defgroup downmix_info Audio downmix metadata
39  * @{
40  */
41 
42 /**
43  * Possible downmix types.
44  */
46  AV_DOWNMIX_TYPE_UNKNOWN, /**< Not indicated. */
47  AV_DOWNMIX_TYPE_LORO, /**< Lo/Ro 2-channel downmix (Stereo). */
48  AV_DOWNMIX_TYPE_LTRT, /**< Lt/Rt 2-channel downmix, Dolby Surround compatible. */
49  AV_DOWNMIX_TYPE_DPLII, /**< Lt/Rt 2-channel downmix, Dolby Pro Logic II compatible. */
50  AV_DOWNMIX_TYPE_NB /**< Number of downmix types. Not part of ABI. */
51 };
52 
53 /**
54  * This structure describes optional metadata relevant to a downmix procedure.
55  *
56  * All fields are set by the decoder to the value indicated in the audio
57  * bitstream (if present), or to a "sane" default otherwise.
58  */
59 typedef struct AVDownmixInfo {
60  /**
61  * Type of downmix preferred by the mastering engineer.
62  */
64 
65  /**
66  * Absolute scale factor representing the nominal level of the center
67  * channel during a regular downmix.
68  */
70 
71  /**
72  * Absolute scale factor representing the nominal level of the center
73  * channel during an Lt/Rt compatible downmix.
74  */
76 
77  /**
78  * Absolute scale factor representing the nominal level of the surround
79  * channels during a regular downmix.
80  */
82 
83  /**
84  * Absolute scale factor representing the nominal level of the surround
85  * channels during an Lt/Rt compatible downmix.
86  */
88 
89  /**
90  * Absolute scale factor representing the level at which the LFE data is
91  * mixed into L/R channels during downmixing.
92  */
93  double lfe_mix_level;
95 
96 /**
97  * Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing.
98  *
99  * If the side data is absent, it is created and added to the frame.
100  *
101  * @param frame the frame for which the side data is to be obtained or created
102  *
103  * @return the AVDownmixInfo structure to be edited by the caller, or NULL if
104  * the structure cannot be allocated.
105  */
107 
108 /**
109  * This structure describes optional metadata relevant to a downmix procedure
110  * in the form of a remixing matrix allocated as an array of AVDownmixCoeff.
111  * Must be allocated with @ref av_downmix_matrix_alloc.
112  *
113  * sizeof(AVDownmixMatrix) is not a part of the ABI and new fields may be
114  * added to it.
115  */
116 typedef struct AVDownmixMatrix {
117  /**
118  * Type of downmix the coeffs will produce.
119  * Output channel count is derived from this value.
120  */
122 
123  /**
124  * Input channel count.
125  */
127 
128  /**
129  * Amount of coefficients in the matrix.
130  */
131  unsigned int nb_coeffs;
132 
133  /**
134  * Offset in bytes from the beginning of this structure at which the array
135  * of coefficients starts.
136  */
139 
140 /**
141  * Data type for storing coefficients, which are allocated as a part of
142  * AVDownmixMatrix and should be retrieved with @ref av_downmix_matrix_coeff.
143  */
144 typedef double AVDownmixCoeff;
145 
146 /**
147  * Get a pointer to the coeff that represents the weight of input channel
148  * {@code in} in output channel {@code out}.
149  * in must be between 0 and @ref AVDownmixMatrix.in_ch_count "in_ch_count" - 1.
150  * out must be between 0 and the implicit output channel count from
151  * @ref AVDownmixMatrix.downmix_type "downmix_type" - 1.
152  */
154 av_downmix_matrix_coeff(AVDownmixMatrix *dm, unsigned int out, unsigned int in)
155 {
156  AVDownmixCoeff *coeff = (AVDownmixCoeff *)((uint8_t *)dm + dm->coeffs_offset);
157  return &coeff[in + dm->in_ch_count * out];
158 }
159 
160 /**
161  * Allocates memory for AVDownmixMatrix of the given type, plus an array of
162  * {@code in_ch_count} times the implicit output channel count from {@code type}
163  * of AVDownmixCoeff and initializes the variables. Can be freed with a normal
164  * av_free() call.
165  *
166  * @param out_size if non-NULL, the size in bytes of the resulting data array is
167  * written here.
168  */
170  int in_ch_count, size_t *out_size);
171 
172 /**
173  * @}
174  */
175 
176 /**
177  * @}
178  */
179 
180 #endif /* AVUTIL_DOWNMIX_INFO_H */
out
static FILE * out
Definition: movenc.c:55
AVDownmixMatrix::downmix_type
enum AVDownmixType downmix_type
Type of downmix the coeffs will produce.
Definition: downmix_info.h:121
out_size
static int out_size
Definition: movenc.c:56
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:472
av_downmix_matrix_coeff
static av_always_inline AVDownmixCoeff * av_downmix_matrix_coeff(AVDownmixMatrix *dm, unsigned int out, unsigned int in)
Get a pointer to the coeff that represents the weight of input channel.
Definition: downmix_info.h:154
AVDownmixInfo::surround_mix_level_ltrt
double surround_mix_level_ltrt
Absolute scale factor representing the nominal level of the surround channels during an Lt/Rt compati...
Definition: downmix_info.h:87
av_always_inline
#define av_always_inline
Definition: attributes.h:76
AV_DOWNMIX_TYPE_UNKNOWN
@ AV_DOWNMIX_TYPE_UNKNOWN
Not indicated.
Definition: downmix_info.h:46
AVDownmixMatrix::nb_coeffs
unsigned int nb_coeffs
Amount of coefficients in the matrix.
Definition: downmix_info.h:131
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
AVDownmixInfo
This structure describes optional metadata relevant to a downmix procedure.
Definition: downmix_info.h:59
AVDownmixMatrix::in_ch_count
int in_ch_count
Input channel count.
Definition: downmix_info.h:126
avassert.h
AVDownmixInfo::surround_mix_level
double surround_mix_level
Absolute scale factor representing the nominal level of the surround channels during a regular downmi...
Definition: downmix_info.h:81
AVDownmixCoeff
double AVDownmixCoeff
Data type for storing coefficients, which are allocated as a part of AVDownmixMatrix and should be re...
Definition: downmix_info.h:144
AVDownmixInfo::center_mix_level_ltrt
double center_mix_level_ltrt
Absolute scale factor representing the nominal level of the center channel during an Lt/Rt compatible...
Definition: downmix_info.h:75
frame.h
AVDownmixType
AVDownmixType
Possible downmix types.
Definition: downmix_info.h:45
AVDownmixInfo::lfe_mix_level
double lfe_mix_level
Absolute scale factor representing the level at which the LFE data is mixed into L/R channels during ...
Definition: downmix_info.h:93
AVDownmixInfo::center_mix_level
double center_mix_level
Absolute scale factor representing the nominal level of the center channel during a regular downmix.
Definition: downmix_info.h:69
AVDownmixInfo::preferred_downmix_type
enum AVDownmixType preferred_downmix_type
Type of downmix preferred by the mastering engineer.
Definition: downmix_info.h:63
AV_DOWNMIX_TYPE_LORO
@ AV_DOWNMIX_TYPE_LORO
Lo/Ro 2-channel downmix (Stereo).
Definition: downmix_info.h:47
AV_DOWNMIX_TYPE_NB
@ AV_DOWNMIX_TYPE_NB
Number of downmix types.
Definition: downmix_info.h:50
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
AVDownmixMatrix
This structure describes optional metadata relevant to a downmix procedure in the form of a remixing ...
Definition: downmix_info.h:116
AVDownmixMatrix::coeffs_offset
size_t coeffs_offset
Offset in bytes from the beginning of this structure at which the array of coefficients starts.
Definition: downmix_info.h:137
AV_DOWNMIX_TYPE_DPLII
@ AV_DOWNMIX_TYPE_DPLII
Lt/Rt 2-channel downmix, Dolby Pro Logic II compatible.
Definition: downmix_info.h:49
av_downmix_matrix_alloc
AVDownmixMatrix * av_downmix_matrix_alloc(enum AVDownmixType type, int in_ch_count, size_t *out_size)
Allocates memory for AVDownmixMatrix of the given type, plus an array of.
Definition: downmix_info.c:53
av_downmix_info_update_side_data
AVDownmixInfo * av_downmix_info_update_side_data(AVFrame *frame)
Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing.
Definition: downmix_info.c:25
coeff
static const double coeff[2][5]
Definition: vf_owdenoise.c:80
AV_DOWNMIX_TYPE_LTRT
@ AV_DOWNMIX_TYPE_LTRT
Lt/Rt 2-channel downmix, Dolby Surround compatible.
Definition: downmix_info.h:48