2 * Copyright (c) 2026 Ayoub Nabil Boubagrat
4 * This file is part of FFmpeg.
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.
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.
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
28/* swr_build_matrix2() accesses an internal SWR_CH_MAX by SWR_CH_MAX matrix. */
29 #define MATRIX_STRIDE 64
38 int out,
const char *out_name)
42 printf(
"[%s] = { ", out_name);
43 for (
int i = 0;
i < 64;
i++) {
64 /* ensure swr_build_matrix2() overwrites unused columns and rows with zero. */
71 /* Disable normalization so the raw downmix gains can be checked. */
77 fprintf(stderr,
"swr_build_matrix2 failed with error %d\n", ret);
82 for (
int in = 0; in < in_layout->
nb_channels; in++) {
86 fprintf(stderr,
"unused matrix position %d:%d is non-zero\n",
98 snprintf(out_name,
sizeof(out_name),
"UNSD%d",
i);
107 int main(
int argc,
char **argv)
110 const char *in, *
out;
114 printf(
"usage: rematrix input_layout output_layout\n");
124 fprintf(stderr,
"Invalid input layout %s\n", in);
132 fprintf(stderr,
"Invalid output layout %s\n",
out);
139 fprintf(stderr,
"channel layout exceeds matrix capacity\n");
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
__device__ int printf(const char *,...)
int av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str)
Initialize a channel layout from a given string description.
int av_channel_name(char *buf, size_t buf_size, enum AVChannel channel_id)
Get a human readable string in an abbreviated form describing a given channel.
enum AVChannel av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx)
Get the channel with the given index in a channel layout.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
@ AV_CHAN_UNUSED
Channel is empty can be safely skipped.
@ AV_CHAN_NONE
Invalid channel index.
@ AV_MATRIX_ENCODING_NONE
av_cold int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelLayout *out_layout, double center_mix_level, double surround_mix_level, double lfe_mix_level, double maxval, double rematrix_volume, double *matrix_param, ptrdiff_t stride, enum AVMatrixEncoding matrix_encoding, void *log_context)
Generate a channel mixing matrix.
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
libswresample public header
static int channel_is_unused(const AVChannelLayout *layout, int index)
static int print_matrix(const AVChannelLayout *in_layout, const AVChannelLayout *out_layout)
static void print_matrix_row(const double *matrix, const AVChannelLayout *in_layout, int out, const char *out_name)