FFmpeg
Loading...
Searching...
No Matches
af_ashowinfo.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Stefano Sabatini
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/**
22 * @file
23 * filter for showing textual audio frame information
24 */
25
26#include <inttypes.h>
27
28#include "libavutil/adler32.h"
32#include "libavutil/iamf.h"
33#include "libavutil/mem.h"
35#include "libavutil/timestamp.h"
36#include "libavutil/samplefmt.h"
37
38#include "libavcodec/defs.h"
39
40#include "audio.h"
41#include "avfilter.h"
42#include "filters.h"
43
44typedef struct AShowInfoContext {
45 /**
46 * Scratch space for individual plane checksums for planar audio
47 */
48 uint32_t *plane_checksums;
50
52{
53 AShowInfoContext *s = ctx->priv;
54 av_freep(&s->plane_checksums);
55}
56
58{
59 enum AVMatrixEncoding enc;
60
61 av_log(ctx, AV_LOG_INFO, "matrix encoding: ");
62
63 if (sd->size < sizeof(enum AVMatrixEncoding)) {
64 av_log(ctx, AV_LOG_INFO, "invalid data");
65 return;
66 }
67
68 enc = *(enum AVMatrixEncoding *)sd->data;
69 switch (enc) {
70 case AV_MATRIX_ENCODING_NONE: av_log(ctx, AV_LOG_INFO, "none"); break;
71 case AV_MATRIX_ENCODING_DOLBY: av_log(ctx, AV_LOG_INFO, "Dolby Surround"); break;
72 case AV_MATRIX_ENCODING_DPLII: av_log(ctx, AV_LOG_INFO, "Dolby Pro Logic II"); break;
73 case AV_MATRIX_ENCODING_DPLIIX: av_log(ctx, AV_LOG_INFO, "Dolby Pro Logic IIx"); break;
74 case AV_MATRIX_ENCODING_DPLIIZ: av_log(ctx, AV_LOG_INFO, "Dolby Pro Logic IIz"); break;
75 case AV_MATRIX_ENCODING_DOLBYEX: av_log(ctx, AV_LOG_INFO, "Dolby EX"); break;
76 case AV_MATRIX_ENCODING_DOLBYHEADPHONE: av_log(ctx, AV_LOG_INFO, "Dolby Headphone"); break;
77 default: av_log(ctx, AV_LOG_WARNING, "unknown"); break;
78 }
79}
80
82{
83 AVDownmixInfo *di;
84
85 av_log(ctx, AV_LOG_INFO, "downmix: ");
86 if (sd->size < sizeof(*di)) {
87 av_log(ctx, AV_LOG_INFO, "invalid data");
88 return;
89 }
90
91 di = (AVDownmixInfo *)sd->data;
92
93 av_log(ctx, AV_LOG_INFO, "preferred downmix type - ");
94 switch (di->preferred_downmix_type) {
95 case AV_DOWNMIX_TYPE_LORO: av_log(ctx, AV_LOG_INFO, "Lo/Ro"); break;
96 case AV_DOWNMIX_TYPE_LTRT: av_log(ctx, AV_LOG_INFO, "Lt/Rt"); break;
97 case AV_DOWNMIX_TYPE_DPLII: av_log(ctx, AV_LOG_INFO, "Dolby Pro Logic II"); break;
98 default: av_log(ctx, AV_LOG_WARNING, "unknown"); break;
99 }
100
101 av_log(ctx, AV_LOG_INFO, " Mix levels: center %f (%f ltrt) - "
102 "surround %f (%f ltrt) - lfe %f",
105 di->lfe_mix_level);
106}
107
114
116{
118 char buf[128];
119
120 av_log(ctx, AV_LOG_INFO, "downmix matrix: ");
121 if (dm->in_ch_count != ch_layout->nb_channels) {
122 av_log(ctx, AV_LOG_INFO, "invalid data");
123 return;
124 }
125
126 av_log(ctx, AV_LOG_INFO, "downmix type - ");
127 switch (dm->downmix_type) {
128 case AV_DOWNMIX_TYPE_LORO: av_log(ctx, AV_LOG_INFO, "Lo/Ro\n"); break;
129 case AV_DOWNMIX_TYPE_LTRT: av_log(ctx, AV_LOG_INFO, "Lt/Rt\n"); break;
130 case AV_DOWNMIX_TYPE_DPLII: av_log(ctx, AV_LOG_INFO, "Dolby Pro Logic II\n"); break;
131 default: av_log(ctx, AV_LOG_WARNING, "invalid data"); return;
132 }
133
134 for (int i = 0; i < downmix_type_map[dm->downmix_type]; i++) {
135 av_log(ctx, AV_LOG_INFO, "[%s] = { ", i ? "FR" : "FL");
136 for (int j = 0; j < dm->in_ch_count; j++) {
137 av_channel_name(buf, sizeof(buf), av_channel_layout_channel_from_index(ch_layout, j));
138 av_log(ctx, AV_LOG_INFO, ".%s = %f, ", buf, *av_downmix_matrix_coeff(dm, i, j));
139 }
140 av_log(ctx, AV_LOG_INFO, "}%s", i == downmix_type_map[dm->downmix_type] - 1 ? "" : ",\n");
141 }
142}
143
144static void print_gain(AVFilterContext *ctx, const char *str, int32_t gain)
145{
146 av_log(ctx, AV_LOG_INFO, "%s - ", str);
147 if (gain == INT32_MIN)
148 av_log(ctx, AV_LOG_INFO, "unknown");
149 else
150 av_log(ctx, AV_LOG_INFO, "%f", gain / 100000.0f);
151 av_log(ctx, AV_LOG_INFO, ", ");
152}
153
154static void print_peak(AVFilterContext *ctx, const char *str, uint32_t peak)
155{
156 av_log(ctx, AV_LOG_INFO, "%s - ", str);
157 if (!peak)
158 av_log(ctx, AV_LOG_INFO, "unknown");
159 else
160 av_log(ctx, AV_LOG_INFO, "%f", peak / 100000.0f);
161 av_log(ctx, AV_LOG_INFO, ", ");
162}
163
165{
166 AVReplayGain *rg;
167
168 av_log(ctx, AV_LOG_INFO, "replaygain: ");
169 if (sd->size < sizeof(*rg)) {
170 av_log(ctx, AV_LOG_INFO, "invalid data");
171 return;
172 }
173 rg = (AVReplayGain*)sd->data;
174
175 print_gain(ctx, "track gain", rg->track_gain);
176 print_peak(ctx, "track peak", rg->track_peak);
177 print_gain(ctx, "album gain", rg->album_gain);
178 print_peak(ctx, "album peak", rg->album_peak);
179}
180
182{
183 enum AVAudioServiceType *ast;
184
185 av_log(ctx, AV_LOG_INFO, "audio service type: ");
186 if (sd->size < sizeof(*ast)) {
187 av_log(ctx, AV_LOG_INFO, "invalid data");
188 return;
189 }
190 ast = (enum AVAudioServiceType*)sd->data;
191 switch (*ast) {
192 case AV_AUDIO_SERVICE_TYPE_MAIN: av_log(ctx, AV_LOG_INFO, "Main Audio Service"); break;
193 case AV_AUDIO_SERVICE_TYPE_EFFECTS: av_log(ctx, AV_LOG_INFO, "Effects"); break;
194 case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED: av_log(ctx, AV_LOG_INFO, "Visually Impaired"); break;
195 case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED: av_log(ctx, AV_LOG_INFO, "Hearing Impaired"); break;
196 case AV_AUDIO_SERVICE_TYPE_DIALOGUE: av_log(ctx, AV_LOG_INFO, "Dialogue"); break;
197 case AV_AUDIO_SERVICE_TYPE_COMMENTARY: av_log(ctx, AV_LOG_INFO, "Commentary"); break;
198 case AV_AUDIO_SERVICE_TYPE_EMERGENCY: av_log(ctx, AV_LOG_INFO, "Emergency"); break;
199 case AV_AUDIO_SERVICE_TYPE_VOICE_OVER: av_log(ctx, AV_LOG_INFO, "Voice Over"); break;
200 case AV_AUDIO_SERVICE_TYPE_KARAOKE: av_log(ctx, AV_LOG_INFO, "Karaoke"); break;
201 default: av_log(ctx, AV_LOG_INFO, "unknown"); break;
202 }
203}
204
206{
208
209 switch (param->type) {
211 av_log(ctx, AV_LOG_INFO, "iamf mix gain parameters: ");
212 break;
214 av_log(ctx, AV_LOG_INFO, "iamf demixing parameters: ");
215 break;
217 av_log(ctx, AV_LOG_INFO, "iamf recon gain parameters: ");
218 break;
219 default:
220 av_log(ctx, AV_LOG_ERROR, "unknown iamf parameter definition type: %d",
221 param->type);
222 return;
223 }
224
226 "nb_subblocks=%d, "
227 "parameter_id=%d, "
228 "parameter_rate=%d, "
229 "duration=%d, "
230 "constant_subblock_duration=%d,",
231 param->nb_subblocks,
232 param->parameter_id,
233 param->parameter_rate,
234 param->duration,
236 );
237
238 for (unsigned i = 0; i < param->nb_subblocks; i++) {
239 const void *subblock = av_iamf_param_definition_get_subblock(param, i);
240
241 av_log(ctx, AV_LOG_INFO, " subblock[%d]={ ", i);
242 switch (param->type) {
244 const AVIAMFMixGain *mix = subblock;
246 "subblock_duration=%d, "
247 "animation_type=%d, "
248 "start_point_value=%d/%d, "
249 "end_point_value=%d/%d, "
250 "control_point_value=%d/%d, "
251 "control_point_relative_time=%d/%d",
252 mix->subblock_duration,
253 mix->animation_type,
254 mix->start_point_value.num, mix->start_point_value.den,
255 mix->end_point_value.num, mix->end_point_value.den,
256 mix->control_point_value.num, mix->control_point_value.den,
257 mix->control_point_relative_time.num, mix->control_point_relative_time.den
258 );
259 break;
260 }
262 const AVIAMFDemixingInfo *demix = subblock;
264 "subblock_duration=%d, "
265 "dmixp_mode=%d",
266 demix->subblock_duration,
267 demix->dmixp_mode
268 );
269 break;
270 }
272 const AVIAMFReconGain *recon = subblock;
274 "subblock_duration=%d", recon->subblock_duration
275 );
276 break;
277 }
278 }
279 av_log(ctx, AV_LOG_INFO, (i == param->nb_subblocks - 1) ? " }" : " },");
280 }
281
282}
283
285{
286 av_log(ctx, AV_LOG_INFO, "unknown side data type: %d, size "
287 "%zu bytes", sd->type, sd->size);
288}
289
290static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
291{
292 FilterLink *inl = ff_filter_link(inlink);
293 AVFilterContext *ctx = inlink->dst;
294 AShowInfoContext *s = ctx->priv;
295 char chlayout_str[128];
296 uint32_t checksum = 0;
297 int channels = inlink->ch_layout.nb_channels;
299 int block_align = av_get_bytes_per_sample(buf->format) * (planar ? 1 : channels);
300 int data_size = buf->nb_samples * block_align;
301 int planes = planar ? channels : 1;
302 int i;
303 void *tmp_ptr = av_realloc_array(s->plane_checksums, channels, sizeof(*s->plane_checksums));
304
305 if (!tmp_ptr)
306 return AVERROR(ENOMEM);
307 s->plane_checksums = tmp_ptr;
308
309 for (i = 0; i < planes; i++) {
310 uint8_t *data = buf->extended_data[i];
311
312 s->plane_checksums[i] = av_adler32_update(0, data, data_size);
313 checksum = i ? av_adler32_update(checksum, data, data_size) :
314 s->plane_checksums[0];
315 }
316
317 av_channel_layout_describe(&buf->ch_layout, chlayout_str, sizeof(chlayout_str));
318
320 "n:%"PRId64" pts:%s pts_time:%s "
321 "fmt:%s channels:%d chlayout:%s rate:%d nb_samples:%d "
322 "checksum:%08"PRIX32" ",
323 inl->frame_count_out,
324 av_ts2str(buf->pts), av_ts2timestr(buf->pts, &inlink->time_base),
325 av_get_sample_fmt_name(buf->format), buf->ch_layout.nb_channels, chlayout_str,
326 buf->sample_rate, buf->nb_samples,
327 checksum);
328
329 av_log(ctx, AV_LOG_INFO, "plane_checksums: [ ");
330 for (i = 0; i < planes; i++)
331 av_log(ctx, AV_LOG_INFO, "%08"PRIX32" ", s->plane_checksums[i]);
332 av_log(ctx, AV_LOG_INFO, "]\n");
333
334 for (i = 0; i < buf->nb_side_data; i++) {
335 AVFrameSideData *sd = buf->side_data[i];
336
337 av_log(ctx, AV_LOG_INFO, " side data - ");
338 switch (sd->type) {
348 break;
349 default: dump_unknown (ctx, sd); break;
350 }
351
352 av_log(ctx, AV_LOG_INFO, "\n");
353 }
354
355 return ff_filter_frame(inlink->dst->outputs[0], buf);
356}
357
358static const AVFilterPad inputs[] = {
359 {
360 .name = "default",
361 .type = AVMEDIA_TYPE_AUDIO,
362 .filter_frame = filter_frame,
363 },
364};
365
367 .p.name = "ashowinfo",
368 .p.description = NULL_IF_CONFIG_SMALL("Show textual information for each audio frame."),
370 .priv_size = sizeof(AShowInfoContext),
371 .uninit = uninit,
374};
Public header for Adler-32 hash function implementation.
static const AVFilterPad inputs[]
Definition af_aap.c:299
static void dump_audio_service_type(AVFilterContext *ctx, AVFrameSideData *sd)
static void dump_downmix(AVFilterContext *ctx, AVFrameSideData *sd)
static const int downmix_type_map[AV_DOWNMIX_TYPE_NB]
static void dump_iamf_parameter_definition(AVFilterContext *ctx, const AVFrameSideData *sd)
static void dump_downmix_matrix(AVFilterContext *ctx, AVFrameSideData *sd, AVChannelLayout *ch_layout)
static void dump_replaygain(AVFilterContext *ctx, AVFrameSideData *sd)
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
static void print_peak(AVFilterContext *ctx, const char *str, uint32_t peak)
static void print_gain(AVFilterContext *ctx, const char *str, int32_t gain)
static void dump_unknown(AVFilterContext *ctx, AVFrameSideData *sd)
const FFFilter ff_af_ashowinfo
static av_cold void uninit(AVFilterContext *ctx)
static void dump_matrixenc(AVFilterContext *ctx, AVFrameSideData *sd)
static AVFormatContext * ctx
channels
Definition aptx.h:31
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
Definition audio.c:34
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi > >8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1<< 16)) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi > >24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi > >56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(UINT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out->ch+ch,(const uint8_t **) in->ch+ch, off *(out-> planar
int32_t
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
Public libavutil channel layout APIs header.
Misc types and constants that do not belong anywhere else.
AVAudioServiceType
Definition defs.h:235
@ AV_AUDIO_SERVICE_TYPE_VOICE_OVER
Definition defs.h:243
@ AV_AUDIO_SERVICE_TYPE_EMERGENCY
Definition defs.h:242
@ AV_AUDIO_SERVICE_TYPE_EFFECTS
Definition defs.h:237
@ AV_AUDIO_SERVICE_TYPE_MAIN
Definition defs.h:236
@ AV_AUDIO_SERVICE_TYPE_DIALOGUE
Definition defs.h:240
@ AV_AUDIO_SERVICE_TYPE_KARAOKE
Definition defs.h:244
@ AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED
Definition defs.h:239
@ AV_AUDIO_SERVICE_TYPE_COMMENTARY
Definition defs.h:241
@ AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED
Definition defs.h:238
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
audio downmix medatata
AVMatrixEncoding
@ AV_MATRIX_ENCODING_DPLIIX
@ AV_MATRIX_ENCODING_NONE
@ AV_MATRIX_ENCODING_DOLBY
@ AV_MATRIX_ENCODING_DPLII
@ AV_MATRIX_ENCODING_DPLIIZ
@ AV_MATRIX_ENCODING_DOLBYEX
@ AV_MATRIX_ENCODING_DOLBYHEADPHONE
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.
@ 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.
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition avfilter.h:182
AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, size_t len)
Calculate the Adler32 checksum of a buffer.
Definition adler32.c:44
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.
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
#define AVERROR(e)
Definition error.h:45
@ AV_FRAME_DATA_DOWNMIX_MATRIX
Metadata relevant to a downmix procedure in the form of a remixig matrix.
Definition frame.h:307
@ AV_FRAME_DATA_AUDIO_SERVICE_TYPE
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
Definition frame.h:114
@ AV_FRAME_DATA_REPLAYGAIN
ReplayGain information in the form of the AVReplayGain struct.
Definition frame.h:77
@ AV_FRAME_DATA_IAMF_RECON_GAIN_INFO_PARAM
IAMF Recon Gain Info Parameter Data associated with the audio frame.
Definition frame.h:294
@ AV_FRAME_DATA_IAMF_MIX_GAIN_PARAM
IAMF Mix Gain Parameter Data associated with the audio frame.
Definition frame.h:278
@ AV_FRAME_DATA_DOWNMIX_INFO
Metadata relevant to a downmix procedure.
Definition frame.h:73
@ AV_FRAME_DATA_MATRIXENCODING
The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
Definition frame.h:68
@ AV_FRAME_DATA_IAMF_DEMIXING_INFO_PARAM
IAMF Demixing Info Parameter Data associated with the audio frame.
Definition frame.h:286
static av_always_inline void * av_iamf_param_definition_get_subblock(const AVIAMFParamDefinition *par, unsigned int idx)
Get the subblock at the specified idx.
Definition iamf.h:260
@ AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN
Subblocks are of struct type AVIAMFReconGain.
Definition iamf.h:181
@ AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN
Subblocks are of struct type AVIAMFMixGain.
Definition iamf.h:173
@ AV_IAMF_PARAMETER_DEFINITION_DEMIXING
Subblocks are of struct type AVIAMFDemixingInfo.
Definition iamf.h:177
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition mem.c:217
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition samplefmt.c:114
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition samplefmt.c:108
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Definition samplefmt.c:51
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int mix(int c0, int c1)
Definition 4xm.c:717
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
Immersive Audio Model and Formats API header.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static const struct @257111027162314367033347246032313251342043035002 planes[]
Memory handling functions.
const char data[16]
Definition mxf.c:149
uint32_t * plane_checksums
Scratch space for individual plane checksums for planar audio.
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
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 ...
int in_ch_count
Input channel count.
enum AVDownmixType downmix_type
Type of downmix the coeffs will produce.
An instance of a filter.
Definition avfilter.h:273
AVFilterLink ** outputs
array of pointers to output links
Definition avfilter.h:285
A filter pad used for either input or output.
Definition filters.h:40
Structure to hold side data for an AVFrame.
Definition frame.h:327
enum AVFrameSideDataType type
Definition frame.h:328
size_t size
Definition frame.h:330
uint8_t * data
Definition frame.h:329
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
int nb_samples
number of audio samples (per channel) described by this frame
Definition frame.h:552
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition frame.h:574
AVFrameSideData ** side_data
Definition frame.h:669
int nb_side_data
Definition frame.h:670
int sample_rate
Sample rate of the audio data.
Definition frame.h:635
AVChannelLayout ch_layout
Channel layout of the audio data.
Definition frame.h:815
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition frame.h:559
uint8_t ** extended_data
pointers to the data planes/channels.
Definition frame.h:533
Demixing Info Parameter Data as defined in section 3.8.2 of IAMF.
Definition iamf.h:128
unsigned int dmixp_mode
Pre-defined combination of demixing parameters.
Definition iamf.h:140
unsigned int subblock_duration
Duration for the given subblock, in units of 1 / parameter_rate.
Definition iamf.h:136
Mix Gain Parameter Data as defined in section 3.8.1 of IAMF.
Definition iamf.h:77
Parameters as defined in section 3.6.1 of IAMF.
Definition iamf.h:193
unsigned int parameter_rate
Sample rate for the parameter substream.
Definition iamf.h:222
unsigned int duration
The accumulated duration of all blocks in this parameter definition, in units of 1 / parameter_rate.
Definition iamf.h:231
unsigned int constant_subblock_duration
The duration of every subblock in the case where all subblocks, with the optional exception of the la...
Definition iamf.h:238
unsigned int parameter_id
Identifier for the parameter substream.
Definition iamf.h:218
enum AVIAMFParamDefinitionType type
Parameters type.
Definition iamf.h:213
unsigned int nb_subblocks
Number of subblocks in the array.
Definition iamf.h:208
Recon Gain Info Parameter Data as defined in section 3.8.3 of IAMF.
Definition iamf.h:148
unsigned int subblock_duration
Duration for the given subblock, in units of 1 / parameter_rate.
Definition iamf.h:156
ReplayGain information (see http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1....
Definition replaygain.h:29
uint32_t track_peak
Peak track amplitude, with 100000 representing full scale (but values may overflow).
Definition replaygain.h:39
uint32_t album_peak
Same as track_peak, but for the whole album,.
Definition replaygain.h:47
int32_t track_gain
Track replay gain in microbels (divide by 100000 to get the value in dB).
Definition replaygain.h:34
int32_t album_gain
Same as track_gain, but for the whole album.
Definition replaygain.h:43
#define av_freep(p)
#define av_log(a,...)
timestamp utils, mostly useful for debugging/logging purposes
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition timestamp.h:54
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition timestamp.h:83