FFmpeg
Loading...
Searching...
No Matches
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 */
59typedef 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 */
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 */
116typedef 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 */
144typedef 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 */
154av_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 */
simple assert() macros that are a bit more flexible than ISO C assert().
static AVFrame * frame
reference-counted frame API
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 in_ch_count times the implic...
double AVDownmixCoeff
Data type for storing coefficients, which are allocated as a part of AVDownmixMatrix and should be re...
AVDownmixType
Possible downmix types.
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 in in output channel out.
AVDownmixInfo * av_downmix_info_update_side_data(AVFrame *frame)
Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing.
@ AV_DOWNMIX_TYPE_UNKNOWN
Not indicated.
@ AV_DOWNMIX_TYPE_LTRT
Lt/Rt 2-channel downmix, Dolby Surround compatible.
@ AV_DOWNMIX_TYPE_LORO
Lo/Ro 2-channel downmix (Stereo).
@ AV_DOWNMIX_TYPE_DPLII
Lt/Rt 2-channel downmix, Dolby Pro Logic II compatible.
@ AV_DOWNMIX_TYPE_NB
Number of downmix types.
cl_device_type type
#define av_always_inline
Definition attributes.h:72
This structure describes optional metadata relevant to a downmix procedure.
double lfe_mix_level
Absolute scale factor representing the level at which the LFE data is mixed into L/R channels during ...
double surround_mix_level_ltrt
Absolute scale factor representing the nominal level of the surround channels during an Lt/Rt compati...
double surround_mix_level
Absolute scale factor representing the nominal level of the surround channels during a regular downmi...
double center_mix_level
Absolute scale factor representing the nominal level of the center channel during a regular downmix.
enum AVDownmixType preferred_downmix_type
Type of downmix preferred by the mastering engineer.
double center_mix_level_ltrt
Absolute scale factor representing the nominal level of the center channel during an Lt/Rt compatible...
This structure describes optional metadata relevant to a downmix procedure in the form of a remixing ...
size_t coeffs_offset
Offset in bytes from the beginning of this structure at which the array of coefficients starts.
int in_ch_count
Input channel count.
unsigned int nb_coeffs
Amount of coefficients in the matrix.
enum AVDownmixType downmix_type
Type of downmix the coeffs will produce.
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
static FILE * out
Definition movenc.c:55
static int out_size
Definition movenc.c:56
static const double coeff[2][5]