FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/dump.c
Date: 2026-11-04 23:20:56
Exec Total Coverage
Lines: 539 674 80.0%
Functions: 24 30 80.0%
Branches: 305 442 69.0%

Line Branch Exec Source
1 /*
2 * Various pretty-printing functions for use within FFmpeg
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <stdio.h>
23 #include <stdint.h>
24
25 #include "libavutil/avstring.h"
26 #include "libavutil/channel_layout.h"
27 #include "libavutil/display.h"
28 #include "libavutil/gain_map.h"
29 #include "libavutil/iamf.h"
30 #include "libavutil/intreadwrite.h"
31 #include "libavutil/log.h"
32 #include "libavutil/mastering_display_metadata.h"
33 #include "libavutil/ambient_viewing_environment.h"
34 #include "libavutil/dovi_meta.h"
35 #include "libavutil/mathematics.h"
36 #include "libavutil/mem.h"
37 #include "libavutil/opt.h"
38 #include "libavutil/replaygain.h"
39 #include "libavutil/spherical.h"
40 #include "libavutil/stereo3d.h"
41 #include "libavutil/tdrdi.h"
42 #include "libavutil/timecode.h"
43
44 #include "libavcodec/avcodec.h"
45
46 #include "avformat.h"
47 #include "internal.h"
48
49 #define HEXDUMP_PRINT(...) \
50 do { \
51 if (!f) \
52 av_log(avcl, level, __VA_ARGS__); \
53 else \
54 fprintf(f, __VA_ARGS__); \
55 } while (0)
56
57 1 static void hex_dump_internal(void *avcl, FILE *f, int level,
58 const uint8_t *buf, int size)
59 {
60 int len, i, j, c;
61
62
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (i = 0; i < size; i += 16) {
63 2 len = size - i;
64
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (len > 16)
65 1 len = 16;
66
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 HEXDUMP_PRINT("%08x ", i);
67
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 2 times.
34 for (j = 0; j < 16; j++) {
68
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
32 if (j < len)
69
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 HEXDUMP_PRINT(" %02x", buf[i + j]);
70 else
71
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 HEXDUMP_PRINT(" ");
72 }
73
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 HEXDUMP_PRINT(" ");
74
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2 times.
26 for (j = 0; j < len; j++) {
75 24 c = buf[i + j];
76
4/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 9 times.
24 if (c < ' ' || c > '~')
77 15 c = '.';
78
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 HEXDUMP_PRINT("%c", c);
79 }
80
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 HEXDUMP_PRINT("\n");
81 }
82 1 }
83
84 ✗ void av_hex_dump(FILE *f, const uint8_t *buf, int size)
85 {
86 ✗ hex_dump_internal(NULL, f, 0, buf, size);
87 ✗ }
88
89 1 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
90 {
91 1 hex_dump_internal(avcl, NULL, level, buf, size);
92 1 }
93
94 ✗ static void pkt_dump_internal(void *avcl, FILE *f, int level, const AVPacket *pkt,
95 int dump_payload, AVRational time_base)
96 {
97 ✗ HEXDUMP_PRINT("stream #%d:\n", pkt->stream_index);
98 ✗ HEXDUMP_PRINT(" keyframe=%d\n", (pkt->flags & AV_PKT_FLAG_KEY) != 0);
99 ✗ HEXDUMP_PRINT(" duration=%0.3f\n", pkt->duration * av_q2d(time_base));
100 /* DTS is _always_ valid after av_read_frame() */
101 ✗ HEXDUMP_PRINT(" dts=");
102 ✗ if (pkt->dts == AV_NOPTS_VALUE)
103 ✗ HEXDUMP_PRINT("N/A");
104 else
105 ✗ HEXDUMP_PRINT("%0.3f", pkt->dts * av_q2d(time_base));
106 /* PTS may not be known if B-frames are present. */
107 ✗ HEXDUMP_PRINT(" pts=");
108 ✗ if (pkt->pts == AV_NOPTS_VALUE)
109 ✗ HEXDUMP_PRINT("N/A");
110 else
111 ✗ HEXDUMP_PRINT("%0.3f", pkt->pts * av_q2d(time_base));
112 ✗ HEXDUMP_PRINT("\n");
113 ✗ HEXDUMP_PRINT(" size=%d\n", pkt->size);
114 ✗ if (dump_payload)
115 ✗ hex_dump_internal(avcl, f, level, pkt->data, pkt->size);
116 ✗ }
117
118 ✗ void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st)
119 {
120 ✗ pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base);
121 ✗ }
122
123 ✗ void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload,
124 const AVStream *st)
125 {
126 ✗ pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base);
127 ✗ }
128
129
130 34599 static void print_fps(double d, const char *postfix, int log_level)
131 {
132 34599 uint64_t v = lrintf(d * 100);
133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34599 times.
34599 if (!v)
134 ✗ av_log(NULL, log_level, "%1.4f %s", d, postfix);
135
2/2
✓ Branch 0 taken 2208 times.
✓ Branch 1 taken 32391 times.
34599 else if (v % 100)
136 2208 av_log(NULL, log_level, "%3.2f %s", d, postfix);
137
2/2
✓ Branch 0 taken 29847 times.
✓ Branch 1 taken 2544 times.
32391 else if (v % (100 * 1000))
138 29847 av_log(NULL, log_level, "%1.0f %s", d, postfix);
139 else
140 2544 av_log(NULL, log_level, "%1.0fk %s", d / 1000, postfix);
141 34599 }
142
143 14384 static void dump_dictionary(void *ctx, const AVDictionary *m,
144 const char *name, const char *indent,
145 int log_level)
146 {
147 14384 const AVDictionaryEntry *tag = NULL;
148
149
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 14375 times.
14384 if (!m)
150 9 return;
151
152 14375 av_log(ctx, log_level, "%s%s:\n", indent, name);
153
2/2
✓ Branch 1 taken 24678 times.
✓ Branch 2 taken 14375 times.
39053 while ((tag = av_dict_iterate(m, tag)))
154
2/2
✓ Branch 0 taken 23084 times.
✓ Branch 1 taken 1594 times.
24678 if (strcmp("language", tag->key)) {
155 23084 const char *p = tag->value;
156 23084 av_log(ctx, log_level,
157 23084 "%s %-16s: ", indent, tag->key);
158
2/2
✓ Branch 0 taken 23582 times.
✓ Branch 1 taken 23084 times.
46666 while (*p) {
159 23582 size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
160
2/2
✓ Branch 0 taken 23580 times.
✓ Branch 1 taken 2 times.
23582 av_log(ctx, log_level, "%.*s", (int)(FFMIN(255, len)), p);
161 23582 p += len;
162
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 23302 times.
23582 if (*p == 0xd) av_log(ctx, log_level, " ");
163
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 23192 times.
23582 if (*p == 0xa) av_log(ctx, log_level, "\n%s %-16s: ", indent, "");
164
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 22890 times.
23582 if (*p) p++;
165 }
166 23084 av_log(ctx, log_level, "\n");
167 }
168 }
169
170 37092 static void dump_metadata(void *ctx, const AVDictionary *m, const char *indent,
171 int log_level)
172 {
173
6/6
✓ Branch 0 taken 14624 times.
✓ Branch 1 taken 22468 times.
✓ Branch 3 taken 10944 times.
✓ Branch 4 taken 3680 times.
✓ Branch 6 taken 10576 times.
✓ Branch 7 taken 368 times.
37092 if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0)))
174 14256 dump_dictionary(ctx, m, "Metadata", indent, log_level);
175 37092 }
176
177 /* param change side data*/
178 ✗ static void dump_paramchange(void *ctx, const AVPacketSideData *sd, int log_level)
179 {
180 ✗ int size = sd->size;
181 ✗ const uint8_t *data = sd->data;
182 uint32_t flags, sample_rate, width, height;
183
184 ✗ if (!data || sd->size < 4)
185 ✗ goto fail;
186
187 ✗ flags = AV_RL32(data);
188 ✗ data += 4;
189 ✗ size -= 4;
190
191 ✗ if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
192 ✗ if (size < 4)
193 ✗ goto fail;
194 ✗ sample_rate = AV_RL32(data);
195 ✗ data += 4;
196 ✗ size -= 4;
197 ✗ av_log(ctx, log_level, "sample_rate %"PRIu32", ", sample_rate);
198 }
199 ✗ if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) {
200 ✗ if (size < 8)
201 ✗ goto fail;
202 ✗ width = AV_RL32(data);
203 ✗ data += 4;
204 ✗ size -= 4;
205 ✗ height = AV_RL32(data);
206 ✗ data += 4;
207 ✗ size -= 4;
208 ✗ av_log(ctx, log_level, "width %"PRIu32" height %"PRIu32, width, height);
209 }
210
211 ✗ return;
212 ✗ fail:
213 ✗ av_log(ctx, AV_LOG_ERROR, "unknown param\n");
214 }
215
216 /* replaygain side data*/
217 2 static void print_gain(void *ctx, const char *str, int32_t gain, int log_level)
218 {
219 2 av_log(ctx, log_level, "%s - ", str);
220
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (gain == INT32_MIN)
221 1 av_log(ctx, log_level, "unknown");
222 else
223 1 av_log(ctx, log_level, "%f", gain / 100000.0f);
224 2 av_log(ctx, log_level, ", ");
225 2 }
226
227 2 static void print_peak(void *ctx, const char *str, uint32_t peak, int log_level)
228 {
229 2 av_log(ctx, log_level, "%s - ", str);
230
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (!peak)
231 2 av_log(ctx, log_level, "unknown");
232 else
233 ✗ av_log(ctx, log_level, "%f", (float) peak / UINT32_MAX);
234 2 av_log(ctx, log_level, ", ");
235 2 }
236
237 1 static void dump_replaygain(void *ctx, const AVPacketSideData *sd, int log_level)
238 {
239 const AVReplayGain *rg;
240
241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (sd->size < sizeof(*rg)) {
242 ✗ av_log(ctx, AV_LOG_ERROR, "invalid data\n");
243 ✗ return;
244 }
245 1 rg = (const AVReplayGain *)sd->data;
246
247 1 print_gain(ctx, "track gain", rg->track_gain, log_level);
248 1 print_peak(ctx, "track peak", rg->track_peak, log_level);
249 1 print_gain(ctx, "album gain", rg->album_gain, log_level);
250 1 print_peak(ctx, "album peak", rg->album_peak, log_level);
251 }
252
253 493 static void dump_stereo3d(void *ctx, const AVPacketSideData *sd, int log_level)
254 {
255 const AVStereo3D *stereo;
256
257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 493 times.
493 if (sd->size < sizeof(*stereo)) {
258 ✗ av_log(ctx, AV_LOG_ERROR, "invalid data\n");
259 ✗ return;
260 }
261
262 493 stereo = (const AVStereo3D *)sd->data;
263
264 493 av_log(ctx, log_level, "%s, view: %s, primary eye: %s",
265 493 av_stereo3d_type_name(stereo->type), av_stereo3d_view_name(stereo->view),
266 493 av_stereo3d_primary_eye_name(stereo->primary_eye));
267
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 486 times.
493 if (stereo->baseline)
268 7 av_log(ctx, log_level, ", baseline: %"PRIu32"", stereo->baseline);
269
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 486 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
493 if (stereo->horizontal_disparity_adjustment.num && stereo->horizontal_disparity_adjustment.den)
270 7 av_log(ctx, log_level, ", horizontal_disparity_adjustment: %0.4f",
271 av_q2d(stereo->horizontal_disparity_adjustment));
272
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 486 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
493 if (stereo->horizontal_field_of_view.num && stereo->horizontal_field_of_view.den)
273 7 av_log(ctx, log_level, ", horizontal_field_of_view: %0.3f", av_q2d(stereo->horizontal_field_of_view));
274
275
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 483 times.
493 if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
276 10 av_log(ctx, log_level, " (inverted)");
277 }
278
279 21 static void dump_audioservicetype(void *ctx, const AVPacketSideData *sd, int log_level)
280 {
281 21 const enum AVAudioServiceType *ast = (const enum AVAudioServiceType *)sd->data;
282
283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (sd->size < sizeof(*ast)) {
284 ✗ av_log(ctx, AV_LOG_ERROR, "invalid data\n");
285 ✗ return;
286 }
287
288
1/10
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
21 switch (*ast) {
289 21 case AV_AUDIO_SERVICE_TYPE_MAIN:
290 21 av_log(ctx, log_level, "main");
291 21 break;
292 ✗ case AV_AUDIO_SERVICE_TYPE_EFFECTS:
293 ✗ av_log(ctx, log_level, "effects");
294 ✗ break;
295 ✗ case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:
296 ✗ av_log(ctx, log_level, "visually impaired");
297 ✗ break;
298 ✗ case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:
299 ✗ av_log(ctx, log_level, "hearing impaired");
300 ✗ break;
301 ✗ case AV_AUDIO_SERVICE_TYPE_DIALOGUE:
302 ✗ av_log(ctx, log_level, "dialogue");
303 ✗ break;
304 ✗ case AV_AUDIO_SERVICE_TYPE_COMMENTARY:
305 ✗ av_log(ctx, log_level, "commentary");
306 ✗ break;
307 ✗ case AV_AUDIO_SERVICE_TYPE_EMERGENCY:
308 ✗ av_log(ctx, log_level, "emergency");
309 ✗ break;
310 ✗ case AV_AUDIO_SERVICE_TYPE_VOICE_OVER:
311 ✗ av_log(ctx, log_level, "voice over");
312 ✗ break;
313 ✗ case AV_AUDIO_SERVICE_TYPE_KARAOKE:
314 ✗ av_log(ctx, log_level, "karaoke");
315 ✗ break;
316 ✗ default:
317 ✗ av_log(ctx, AV_LOG_WARNING, "unknown");
318 ✗ break;
319 }
320 }
321
322 404 static void dump_cpb(void *ctx, const AVPacketSideData *sd, int log_level)
323 {
324 404 const AVCPBProperties *cpb = (const AVCPBProperties *)sd->data;
325
326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 if (sd->size < sizeof(*cpb)) {
327 ✗ av_log(ctx, AV_LOG_ERROR, "invalid data\n");
328 ✗ return;
329 }
330
331 404 av_log(ctx, log_level,
332 "bitrate max/min/avg: %"PRId64"/%"PRId64"/%"PRId64" buffer size: %"PRId64" ",
333 404 cpb->max_bitrate, cpb->min_bitrate, cpb->avg_bitrate,
334 404 cpb->buffer_size);
335
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if (cpb->vbv_delay == UINT64_MAX)
336 404 av_log(ctx, log_level, "vbv_delay: N/A");
337 else
338 ✗ av_log(ctx, log_level, "vbv_delay: %"PRIu64"", cpb->vbv_delay);
339 }
340
341 43 static void dump_mastering_display_metadata(void *ctx, const AVPacketSideData *sd,
342 int log_level)
343 {
344 43 const AVMasteringDisplayMetadata *metadata =
345 (const AVMasteringDisplayMetadata *)sd->data;
346 43 av_log(ctx, log_level,
347 "has_primaries:%d has_luminance:%d "
348 "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) "
349 "min_luminance=%f, max_luminance=%f",
350 43 metadata->has_primaries, metadata->has_luminance,
351 av_q2d(metadata->display_primaries[0][0]),
352 av_q2d(metadata->display_primaries[0][1]),
353 av_q2d(metadata->display_primaries[1][0]),
354 av_q2d(metadata->display_primaries[1][1]),
355 av_q2d(metadata->display_primaries[2][0]),
356 av_q2d(metadata->display_primaries[2][1]),
357 av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1]),
358 av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance));
359 43 }
360
361 40 static void dump_content_light_metadata(void *ctx, const AVPacketSideData *sd,
362 int log_level)
363 {
364 40 const AVContentLightMetadata *metadata =
365 (const AVContentLightMetadata *)sd->data;
366 40 av_log(ctx, log_level,
367 "MaxCLL=%d, MaxFALL=%d",
368 40 metadata->MaxCLL, metadata->MaxFALL);
369 40 }
370
371 6 static void dump_ambient_viewing_environment_metadata(void *ctx, const AVPacketSideData *sd, int log_level)
372 {
373 6 const AVAmbientViewingEnvironment *ambient =
374 (const AVAmbientViewingEnvironment *)sd->data;
375 6 av_log(ctx, log_level,
376 "ambient_illuminance=%f, ambient_light_x=%f, ambient_light_y=%f",
377 av_q2d(ambient->ambient_illuminance),
378 av_q2d(ambient->ambient_light_x),
379 av_q2d(ambient->ambient_light_y));
380 6 }
381
382 18 static void dump_spherical(void *ctx, int w, int h,
383 const AVPacketSideData *sd, int log_level)
384 {
385 18 const AVSphericalMapping *spherical = (const AVSphericalMapping *)sd->data;
386 double yaw, pitch, roll;
387
388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (sd->size < sizeof(*spherical)) {
389 ✗ av_log(ctx, AV_LOG_ERROR, "invalid data\n");
390 ✗ return;
391 }
392
393 18 av_log(ctx, log_level, "%s ", av_spherical_projection_name(spherical->projection));
394
395
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
18 if (spherical->yaw || spherical->pitch || spherical->roll) {
396 11 yaw = ((double)spherical->yaw) / (1 << 16);
397 11 pitch = ((double)spherical->pitch) / (1 << 16);
398 11 roll = ((double)spherical->roll) / (1 << 16);
399 11 av_log(ctx, log_level, "(%f/%f/%f) ", yaw, pitch, roll);
400 }
401
402
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7 times.
18 if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
403 size_t l, t, r, b;
404 11 av_spherical_tile_bounds(spherical, w, h,
405 &l, &t, &r, &b);
406 11 av_log(ctx, log_level, "[%zu, %zu, %zu, %zu] ", l, t, r, b);
407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 } else if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
408 ✗ av_log(ctx, log_level, "[pad %"PRIu32"] ", spherical->padding);
409 }
410 }
411
412 49 static void dump_dovi_conf(void *ctx, const AVPacketSideData *sd,
413 int log_level)
414 {
415 49 const AVDOVIDecoderConfigurationRecord *dovi =
416 (const AVDOVIDecoderConfigurationRecord *)sd->data;
417
418 49 av_log(ctx, log_level, "version: %d.%d, profile: %d, level: %d, "
419 "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d, "
420 "compression: %d",
421 49 dovi->dv_version_major, dovi->dv_version_minor,
422 49 dovi->dv_profile, dovi->dv_level,
423 49 dovi->rpu_present_flag,
424 49 dovi->el_present_flag,
425 49 dovi->bl_present_flag,
426 49 dovi->dv_bl_signal_compatibility_id,
427 49 dovi->dv_md_compression);
428 49 }
429
430 ✗ static void dump_s12m_timecode(void *ctx, AVRational avg_frame_rate, const AVPacketSideData *sd,
431 int log_level)
432 {
433 ✗ const uint32_t *tc = (const uint32_t *)sd->data;
434
435 ✗ if ((sd->size != sizeof(uint32_t) * 4) || (tc[0] > 3)) {
436 ✗ av_log(ctx, AV_LOG_ERROR, "invalid data\n");
437 ✗ return;
438 }
439
440 ✗ for (int j = 1; j <= tc[0]; j++) {
441 char tcbuf[AV_TIMECODE_STR_SIZE];
442 ✗ av_timecode_make_smpte_tc_string2(tcbuf, avg_frame_rate, tc[j], 0, 0);
443 ✗ av_log(ctx, log_level, "timecode - %s%s", tcbuf, j != tc[0] ? ", " : "");
444 }
445 }
446
447 31 static void dump_cropping(void *ctx, const AVPacketSideData *sd, int log_level)
448 {
449 uint32_t top, bottom, left, right;
450
451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (sd->size < sizeof(uint32_t) * 4) {
452 ✗ av_log(ctx, log_level, "invalid data\n");
453 ✗ return;
454 }
455
456 31 top = AV_RL32(sd->data + 0);
457 31 bottom = AV_RL32(sd->data + 4);
458 31 left = AV_RL32(sd->data + 8);
459 31 right = AV_RL32(sd->data + 12);
460
461 31 av_log(ctx, log_level, "%"PRIu32"/%"PRIu32"/%"PRIu32"/%"PRIu32"", left, right, top, bottom);
462 }
463
464 2 static void dump_tdrdi(void *ctx, const AVPacketSideData *sd, int log_level)
465 {
466 2 const AV3DReferenceDisplaysInfo *tdrdi =
467 (const AV3DReferenceDisplaysInfo *)sd->data;
468
469 2 av_log(ctx, log_level, "number of reference displays: %u", tdrdi->num_ref_displays);
470 2 }
471
472 4 static void dump_gain_map_params(void *ctx, const AVPacketSideData *sd, int log_level)
473 {
474 4 const AVGainMapParams *p = (const AVGainMapParams *) sd->data;
475
476 4 av_log(ctx, log_level, "version=%d, nb_channels=%d, use_base_color_space=%d, "
477 "base_hdr_headroom=%f, alternate_hdr_headroom=%f, channels={ ",
478 4 p->version, p->nb_channels, p->use_base_color_space,
479 av_q2d(p->base_hdr_headroom), av_q2d(p->alternate_hdr_headroom));
480
481
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if (!(p->nb_channels == 1 || p->nb_channels == 3)) {
482 ✗ av_log(ctx, AV_LOG_ERROR, "invalid data }\n");
483 ✗ return;
484 }
485
486
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 for (int c = 0; c < p->nb_channels; c++) {
487 4 const struct AVGainMapChannel *ch = &p->channels[c];
488 4 av_log(ctx, log_level,
489 "{ gain_map_min=%f, gain_map_max=%f, gamma=%f, "
490 "base_offset=%f, alternate_offset=%f } ",
491 av_q2d(ch->gain_map_min), av_q2d(ch->gain_map_max),
492 av_q2d(ch->gamma), av_q2d(ch->base_offset),
493 av_q2d(ch->alternate_offset));
494 }
495
496 4 av_log(ctx, log_level, "}");
497 }
498
499 19355 static void dump_sidedata(void *ctx, const AVPacketSideData *side_data, int nb_side_data,
500 int w, int h, AVRational avg_frame_rate,
501 const char *indent, int log_level)
502 {
503 int i;
504
505
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 18245 times.
19355 if (nb_side_data)
506 1110 av_log(ctx, log_level, "%sSide data:\n", indent);
507
508
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 19355 times.
20611 for (i = 0; i < nb_side_data; i++) {
509 1256 const AVPacketSideData *sd = &side_data[i];
510 1256 const char *name = av_packet_side_data_name(sd->type);
511
512 1256 av_log(ctx, log_level, "%s ", indent);
513
1/2
✓ Branch 0 taken 1256 times.
✗ Branch 1 not taken.
1256 if (name)
514 1256 av_log(ctx, log_level, "%s: ", name);
515
14/17
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 493 times.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 404 times.
✓ Branch 7 taken 43 times.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 40 times.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 31 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 4 times.
✓ Branch 16 taken 85 times.
1256 switch (sd->type) {
516 ✗ case AV_PKT_DATA_PARAM_CHANGE:
517 ✗ dump_paramchange(ctx, sd, log_level);
518 ✗ break;
519 1 case AV_PKT_DATA_REPLAYGAIN:
520 1 dump_replaygain(ctx, sd, log_level);
521 1 break;
522 59 case AV_PKT_DATA_DISPLAYMATRIX:
523 59 av_log(ctx, log_level, "rotation of %.2f degrees",
524 59 av_display_rotation_get((const int32_t *)sd->data));
525 59 break;
526 493 case AV_PKT_DATA_STEREO3D:
527 493 dump_stereo3d(ctx, sd, log_level);
528 493 break;
529 21 case AV_PKT_DATA_AUDIO_SERVICE_TYPE:
530 21 dump_audioservicetype(ctx, sd, log_level);
531 21 break;
532 ✗ case AV_PKT_DATA_QUALITY_STATS:
533 ✗ av_log(ctx, log_level, "%"PRId32", pict_type: %c",
534 ✗ AV_RL32(sd->data), av_get_picture_type_char(sd->data[4]));
535 ✗ break;
536 404 case AV_PKT_DATA_CPB_PROPERTIES:
537 404 dump_cpb(ctx, sd, log_level);
538 404 break;
539 43 case AV_PKT_DATA_MASTERING_DISPLAY_METADATA:
540 43 dump_mastering_display_metadata(ctx, sd, log_level);
541 43 break;
542 18 case AV_PKT_DATA_SPHERICAL:
543 18 dump_spherical(ctx, w, h, sd, log_level);
544 18 break;
545 40 case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:
546 40 dump_content_light_metadata(ctx, sd, log_level);
547 40 break;
548 49 case AV_PKT_DATA_DOVI_CONF:
549 49 dump_dovi_conf(ctx, sd, log_level);
550 49 break;
551 ✗ case AV_PKT_DATA_S12M_TIMECODE:
552 ✗ dump_s12m_timecode(ctx, avg_frame_rate, sd, log_level);
553 ✗ break;
554 6 case AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT:
555 6 dump_ambient_viewing_environment_metadata(ctx, sd, log_level);
556 6 break;
557 31 case AV_PKT_DATA_FRAME_CROPPING:
558 31 dump_cropping(ctx, sd, log_level);
559 31 break;
560 2 case AV_PKT_DATA_3D_REFERENCE_DISPLAYS:
561 2 dump_tdrdi(ctx, sd, log_level);
562 2 break;
563 4 case AV_PKT_DATA_GAIN_MAP_PARAMS:
564 4 dump_gain_map_params(ctx, sd, log_level);
565 4 break;
566 85 default:
567
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if (name)
568 85 av_log(ctx, log_level, "(%zu bytes)", sd->size);
569 else
570 ✗ av_log(ctx, log_level, "unknown side data type %d "
571 ✗ "(%zu bytes)", sd->type, sd->size);
572 85 break;
573 }
574
575 1256 av_log(ctx, log_level, "\n");
576 }
577 19355 }
578
579 19477 static void dump_disposition(int disposition, int log_level)
580 {
581
2/2
✓ Branch 0 taken 2282 times.
✓ Branch 1 taken 17195 times.
19477 if (disposition & AV_DISPOSITION_DEFAULT)
582 2282 av_log(NULL, log_level, " (default)");
583
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 19473 times.
19477 if (disposition & AV_DISPOSITION_DUB)
584 4 av_log(NULL, log_level, " (dub)");
585
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 19473 times.
19477 if (disposition & AV_DISPOSITION_ORIGINAL)
586 4 av_log(NULL, log_level, " (original)");
587
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19472 times.
19477 if (disposition & AV_DISPOSITION_COMMENT)
588 5 av_log(NULL, log_level, " (comment)");
589
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 19476 times.
19477 if (disposition & AV_DISPOSITION_LYRICS)
590 1 av_log(NULL, log_level, " (lyrics)");
591
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 19476 times.
19477 if (disposition & AV_DISPOSITION_KARAOKE)
592 1 av_log(NULL, log_level, " (karaoke)");
593
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 19470 times.
19477 if (disposition & AV_DISPOSITION_FORCED)
594 7 av_log(NULL, log_level, " (forced)");
595
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 19450 times.
19477 if (disposition & AV_DISPOSITION_HEARING_IMPAIRED)
596 27 av_log(NULL, log_level, " (hearing impaired)");
597
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 19461 times.
19477 if (disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
598 16 av_log(NULL, log_level, " (visual impaired)");
599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19477 times.
19477 if (disposition & AV_DISPOSITION_CLEAN_EFFECTS)
600 ✗ av_log(NULL, log_level, " (clean effects)");
601
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 19368 times.
19477 if (disposition & AV_DISPOSITION_ATTACHED_PIC)
602 109 av_log(NULL, log_level, " (attached pic)");
603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19477 times.
19477 if (disposition & AV_DISPOSITION_TIMED_THUMBNAILS)
604 ✗ av_log(NULL, log_level, " (timed thumbnails)");
605
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 19471 times.
19477 if (disposition & AV_DISPOSITION_CAPTIONS)
606 6 av_log(NULL, log_level, " (captions)");
607
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 19459 times.
19477 if (disposition & AV_DISPOSITION_DESCRIPTIONS)
608 18 av_log(NULL, log_level, " (descriptions)");
609
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 19473 times.
19477 if (disposition & AV_DISPOSITION_METADATA)
610 4 av_log(NULL, log_level, " (metadata)");
611
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 18919 times.
19477 if (disposition & AV_DISPOSITION_DEPENDENT)
612 558 av_log(NULL, log_level, " (dependent)");
613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19477 times.
19477 if (disposition & AV_DISPOSITION_STILL_IMAGE)
614 ✗ av_log(NULL, log_level, " (still image)");
615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19477 times.
19477 if (disposition & AV_DISPOSITION_NON_DIEGETIC)
616 ✗ av_log(NULL, log_level, " (non-diegetic)");
617
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 19468 times.
19477 if (disposition & AV_DISPOSITION_MULTILAYER)
618 9 av_log(NULL, log_level, " (multilayer)");
619 19477 }
620
621 /* "user interface" functions */
622 19312 static void dump_stream_format(const AVFormatContext *ic, int i,
623 int group_index, int index, int is_output,
624 int log_level)
625 {
626 char buf[256];
627
2/2
✓ Branch 0 taken 9768 times.
✓ Branch 1 taken 9544 times.
19312 int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
628 19312 const AVStream *st = ic->streams[i];
629 19312 const FFStream *const sti = cffstream(st);
630 19312 const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
631 19312 const char *separator = ic->dump_separator;
632
2/2
✓ Branch 0 taken 723 times.
✓ Branch 1 taken 18589 times.
19312 const char *group_indent = group_index >= 0 ? " " : "";
633
2/2
✓ Branch 0 taken 723 times.
✓ Branch 1 taken 18589 times.
19312 const char *extra_indent = group_index >= 0 ? " " : " ";
634 AVCodecContext *avctx;
635 int ret;
636
637 19312 avctx = avcodec_alloc_context3(NULL);
638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19312 times.
19312 if (!avctx)
639 ✗ return;
640
641 19312 ret = avcodec_parameters_to_context(avctx, st->codecpar);
642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19312 times.
19312 if (ret < 0) {
643 ✗ avcodec_free_context(&avctx);
644 ✗ return;
645 }
646
647 // Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext
648
2/2
✓ Branch 0 taken 9544 times.
✓ Branch 1 taken 9768 times.
19312 if (sti->avctx) {
649 9544 avctx->codec = sti->avctx->codec;
650 9544 avctx->qmin = sti->avctx->qmin;
651 9544 avctx->qmax = sti->avctx->qmax;
652 9544 avctx->coded_width = sti->avctx->coded_width;
653 9544 avctx->coded_height = sti->avctx->coded_height;
654 }
655
656
1/2
✓ Branch 0 taken 19312 times.
✗ Branch 1 not taken.
19312 if (separator)
657 19312 av_opt_set(avctx, "dump_separator", separator, 0);
658 19312 avcodec_string(buf, sizeof(buf), avctx, is_output);
659 19312 avcodec_free_context(&avctx);
660
661 19312 av_log(NULL, log_level, "%s Stream #%d", group_indent, index);
662 19312 av_log(NULL, log_level, ":%d", i);
663
664 /* the pid is an important information, so we display it */
665 /* XXX: add a generic system */
666
2/2
✓ Branch 0 taken 1632 times.
✓ Branch 1 taken 17680 times.
19312 if (flags & AVFMT_SHOW_IDS)
667 1632 av_log(NULL, log_level, "[0x%x]", st->id);
668
2/2
✓ Branch 0 taken 1915 times.
✓ Branch 1 taken 17397 times.
19312 if (lang)
669 1915 av_log(NULL, log_level, "(%s)", lang->value);
670 19312 av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", sti->codec_info_nb_frames,
671 19312 st->time_base.num, st->time_base.den);
672 19312 av_log(NULL, log_level, ": %s", buf);
673
674
4/4
✓ Branch 0 taken 2839 times.
✓ Branch 1 taken 16473 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 2435 times.
22151 if (st->sample_aspect_ratio.num &&
675 2839 av_cmp_q(st->sample_aspect_ratio, st->codecpar->sample_aspect_ratio)) {
676 AVRational display_aspect_ratio;
677 404 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
678 404 st->codecpar->width * (int64_t)st->sample_aspect_ratio.num,
679 404 st->codecpar->height * (int64_t)st->sample_aspect_ratio.den,
680 1024 * 1024);
681 404 av_log(NULL, log_level, ", SAR %d:%d DAR %d:%d",
682 404 st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
683 display_aspect_ratio.num, display_aspect_ratio.den);
684 }
685
686
2/2
✓ Branch 0 taken 14168 times.
✓ Branch 1 taken 5144 times.
19312 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
687
3/4
✓ Branch 0 taken 13271 times.
✓ Branch 1 taken 897 times.
✓ Branch 2 taken 13271 times.
✗ Branch 3 not taken.
14168 int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
688
3/4
✓ Branch 0 taken 7160 times.
✓ Branch 1 taken 7008 times.
✓ Branch 2 taken 7160 times.
✗ Branch 3 not taken.
14168 int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
689
2/4
✓ Branch 0 taken 14168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14168 times.
✗ Branch 3 not taken.
14168 int tbn = st->time_base.den && st->time_base.num;
690
691
5/6
✓ Branch 0 taken 897 times.
✓ Branch 1 taken 13271 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 877 times.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
14168 if (fps || tbr || tbn)
692 14168 av_log(NULL, log_level, "%s", separator);
693
694
2/2
✓ Branch 0 taken 13271 times.
✓ Branch 1 taken 897 times.
14168 if (fps)
695
3/4
✓ Branch 0 taken 6988 times.
✓ Branch 1 taken 6283 times.
✓ Branch 2 taken 6988 times.
✗ Branch 3 not taken.
13271 print_fps(av_q2d(st->avg_frame_rate), tbr || tbn ? "fps, " : "fps", log_level);
696
2/2
✓ Branch 0 taken 7160 times.
✓ Branch 1 taken 7008 times.
14168 if (tbr)
697
1/2
✓ Branch 0 taken 7160 times.
✗ Branch 1 not taken.
7160 print_fps(av_q2d(st->r_frame_rate), tbn ? "tbr, " : "tbr", log_level);
698
1/2
✓ Branch 0 taken 14168 times.
✗ Branch 1 not taken.
14168 if (tbn)
699 14168 print_fps(1 / av_q2d(st->time_base), "tbn", log_level);
700 }
701
702
6/8
✓ Branch 0 taken 7329 times.
✓ Branch 1 taken 11983 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 6772 times.
✓ Branch 4 taken 557 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 557 times.
✗ Branch 7 not taken.
19312 if (st->start_time != AV_NOPTS_VALUE && st->start_time != 0 && st->time_base.den && st->time_base.num) {
703 557 const double stream_start = av_q2d(st->time_base) * st->start_time;
704 557 av_log(NULL, log_level, ", start %.6f", stream_start);
705 }
706
707 19312 dump_disposition(st->disposition, log_level);
708 19312 av_log(NULL, log_level, "\n");
709
710 19312 dump_metadata(NULL, st->metadata, extra_indent, log_level);
711
712 19312 dump_sidedata(NULL, st->codecpar->coded_side_data, st->codecpar->nb_coded_side_data,
713 19312 st->codecpar->width, st->codecpar->height, st->avg_frame_rate,
714 extra_indent, log_level);
715 }
716
717 204 static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed,
718 int i, int index, int is_output, int log_level)
719 {
720 204 const AVStreamGroup *stg = ic->stream_groups[i];
721
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 198 times.
204 const char *group_indent = log_level != AV_LOG_INFO ? " " : "";
722
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 198 times.
204 const char *extra_indent = log_level != AV_LOG_INFO ? " " : " ";
723
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 169 times.
204 int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
724 char buf[512];
725 int ret;
726
727 204 av_log(NULL, log_level, "%s Stream group #%d:%d", group_indent, index, i);
728
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 39 times.
204 if (flags & AVFMT_SHOW_IDS)
729 165 av_log(NULL, log_level, "[0x%"PRIx64"]", stg->id);
730 204 av_log(NULL, log_level, ":");
731
732
5/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
204 switch (stg->type) {
733 64 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT: {
734 64 const AVIAMFAudioElement *audio_element = stg->params.iamf_audio_element;
735 64 av_log(NULL, log_level, " IAMF Audio Element:");
736 64 dump_disposition(stg->disposition, log_level);
737 64 av_log(NULL, log_level, "\n");
738 64 dump_metadata(NULL, stg->metadata, " ", log_level);
739
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 64 times.
185 for (int j = 0; j < audio_element->nb_layers; j++) {
740 121 const AVIAMFLayer *layer = audio_element->layers[j];
741 121 int channel_count = layer->ch_layout.nb_channels;
742 121 av_log(NULL, log_level, " Layer %d:", j);
743 121 ret = av_channel_layout_describe(&layer->ch_layout, buf, sizeof(buf));
744
1/2
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
121 if (ret >= 0)
745 121 av_log(NULL, log_level, " %s", buf);
746 121 av_log(NULL, log_level, "\n");
747
4/6
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 524 times.
✓ Branch 3 taken 121 times.
✓ Branch 4 taken 524 times.
✗ Branch 5 not taken.
645 for (int k = 0; log_level == AV_LOG_INFO && channel_count > 0 && k < stg->nb_entries; k++) {
748 524 const AVStreamGroupEntry *entry = stg->entries[k];
749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
524 if (entry->type != AV_STREAM_GROUP_ENTRY_STREAM)
750 ✗ continue;
751 524 const AVStream *st = entry->stream;
752
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 337 times.
524 int loglevel = printed[st->index] ? AV_LOG_VERBOSE : AV_LOG_INFO;
753 524 av_log(NULL, loglevel, " ");
754 524 dump_stream_format(ic, st->index, i, index, is_output, loglevel);
755 524 printed[st->index] = 1;
756 524 channel_count -= st->codecpar->ch_layout.nb_channels;
757 }
758 }
759 64 break;
760 }
761 58 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: {
762 58 const AVIAMFMixPresentation *mix_presentation = stg->params.iamf_mix_presentation;
763 58 av_log(NULL, log_level, " IAMF Mix Presentation:");
764 58 dump_disposition(stg->disposition, log_level);
765 58 av_log(NULL, log_level, "\n");
766 58 dump_metadata(NULL, stg->metadata, " ", log_level);
767 58 dump_dictionary(NULL, mix_presentation->annotations, "Annotations", " ", log_level);
768
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 58 times.
122 for (int j = 0; j < mix_presentation->nb_submixes; j++) {
769 64 AVIAMFSubmix *sub_mix = mix_presentation->submixes[j];
770 64 av_log(NULL, log_level, " Submix %d:\n", j);
771
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 64 times.
134 for (int k = 0; k < sub_mix->nb_elements; k++) {
772 70 const AVIAMFSubmixElement *submix_element = sub_mix->elements[k];
773 70 const AVStreamGroup *audio_element = NULL;
774
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 for (int l = 0; l < ic->nb_stream_groups; l++)
775
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if (ic->stream_groups[l]->type == AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT &&
776
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 6 times.
76 ic->stream_groups[l]->id == submix_element->audio_element_id) {
777 70 audio_element = ic->stream_groups[l];
778 70 break;
779 }
780
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (audio_element) {
781 70 av_log(NULL, log_level, " IAMF Audio Element #%d:%d",
782 70 index, audio_element->index);
783
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 19 times.
70 if (flags & AVFMT_SHOW_IDS)
784 51 av_log(NULL, log_level, "[0x%"PRIx64"]", audio_element->id);
785 70 av_log(NULL, log_level, "\n");
786 70 dump_dictionary(NULL, submix_element->annotations, "Annotations", " ", log_level);
787 }
788 }
789
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 64 times.
194 for (int k = 0; k < sub_mix->nb_layouts; k++) {
790 130 const AVIAMFSubmixLayout *submix_layout = sub_mix->layouts[k];
791 130 av_log(NULL, log_level, " Layout #%d:", k);
792
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 118 times.
130 if (submix_layout->layout_type == 2 ||
793
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 submix_layout->layout_type == 3) {
794 130 ret = av_channel_layout_describe(&submix_layout->sound_system, buf, sizeof(buf));
795
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if (ret >= 0)
796 130 av_log(NULL, log_level, " %s", buf);
797 }
798 130 av_log(NULL, log_level, "\n");
799 }
800 }
801 58 break;
802 }
803 21 case AV_STREAM_GROUP_PARAMS_TILE_GRID: {
804 21 const AVStreamGroupTileGrid *tile_grid = stg->params.tile_grid;
805 21 AVCodecContext *avctx = avcodec_alloc_context3(NULL);
806 21 const char *ptr = NULL;
807 21 av_log(NULL, log_level, " Tile Grid:");
808
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 if (avctx && stg->nb_entries && stg->entries[0]->type == AV_STREAM_GROUP_ENTRY_STREAM) {
809 21 const AVStream *st = stg->entries[0]->stream;
810
1/2
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
21 if (!avcodec_parameters_to_context(avctx, st->codecpar)) {
811 21 avctx->width = tile_grid->width;
812 21 avctx->height = tile_grid->height;
813 21 avctx->coded_width = tile_grid->coded_width;
814 21 avctx->coded_height = tile_grid->coded_height;
815
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if (ic->dump_separator)
816 21 av_opt_set(avctx, "dump_separator", ic->dump_separator, 0);
817 21 buf[0] = 0;
818 21 avcodec_string(buf, sizeof(buf), avctx, is_output);
819 21 ptr = av_stristr(buf, " ");
820 }
821 }
822 21 avcodec_free_context(&avctx);
823
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if (ptr)
824 21 av_log(NULL, log_level, "%s", ptr);
825 21 dump_disposition(stg->disposition, log_level);
826 21 av_log(NULL, log_level, "\n");
827 21 dump_metadata(NULL, stg->metadata, extra_indent, log_level);
828 21 dump_sidedata(NULL, stg->coded_side_data, stg->nb_coded_side_data,
829 21 tile_grid->width, tile_grid->height, (AVRational) {0,1},
830 extra_indent, log_level);
831
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 21 times.
161 for (int i = 0; i < tile_grid->nb_tiles; i++) {
832 140 const AVStream *st = NULL;
833
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if (tile_grid->offsets[i].idx < stg->nb_entries) {
834 140 const AVStreamGroupEntry *entry = stg->entries[tile_grid->offsets[i].idx];
835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (entry->type != AV_STREAM_GROUP_ENTRY_STREAM)
836 ✗ continue;
837 140 st = entry->stream;
838 }
839
3/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 58 times.
140 if (st && !printed[st->index]) {
840 82 dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE);
841 82 printed[st->index] = 1;
842 }
843 }
844
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 21 times.
159 for (int i = 0; i < stg->nb_entries; i++) {
845 138 const AVStreamGroupEntry *entry = stg->entries[i];
846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if (entry->type != AV_STREAM_GROUP_ENTRY_STREAM)
847 ✗ continue;
848 138 const AVStream *st = entry->stream;
849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if (!printed[st->index]) {
850 ✗ dump_stream_format(ic, st->index, i, index, is_output, log_level);
851 ✗ printed[st->index] = 1;
852 }
853 }
854 21 break;
855 }
856 22 case AV_STREAM_GROUP_PARAMS_ALPHA:
857 case AV_STREAM_GROUP_PARAMS_DOLBY_VISION:
858 case AV_STREAM_GROUP_PARAMS_GAIN_MAP:
859 case AV_STREAM_GROUP_PARAMS_LCEVC: {
860 22 const AVStreamGroupLayeredVideo *layered_video = stg->params.layered_video;
861 22 AVCodecContext *avctx = avcodec_alloc_context3(NULL);
862 22 const char *ptr = NULL;
863
4/5
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
22 switch (stg->type) {
864 3 case AV_STREAM_GROUP_PARAMS_ALPHA:
865 3 av_log(NULL, AV_LOG_INFO, " Alpha:");
866 3 break;
867 2 case AV_STREAM_GROUP_PARAMS_DOLBY_VISION:
868 2 av_log(NULL, AV_LOG_INFO, " Dolby Vision:");
869 2 break;
870 5 case AV_STREAM_GROUP_PARAMS_GAIN_MAP:
871 5 av_log(NULL, AV_LOG_INFO, " Gain Map:");
872 5 break;
873 12 case AV_STREAM_GROUP_PARAMS_LCEVC:
874 12 av_log(NULL, AV_LOG_INFO, " LCEVC:");
875 12 break;
876 }
877
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if (avctx && stg->nb_entries == 2 &&
878
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
22 (stg->entries[ layered_video->el_index]->type == AV_STREAM_GROUP_ENTRY_STREAM ||
879
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
22 stg->entries[!layered_video->el_index]->type == AV_STREAM_GROUP_ENTRY_STREAM)) {
880
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 2 times.
20 const AVStream *st = stg->entries[!layered_video->el_index]->type == AV_STREAM_GROUP_ENTRY_STREAM ?
881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 stg->entries[!layered_video->el_index]->stream :
882 2 stg->entries[ layered_video->el_index]->stream;
883
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 if (!avcodec_parameters_to_context(avctx, st->codecpar)) {
884 20 avctx->width = layered_video->width;
885 20 avctx->height = layered_video->height;
886 20 avctx->coded_width = layered_video->width;
887 20 avctx->coded_height = layered_video->height;
888
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if (ic->dump_separator)
889 20 av_opt_set(avctx, "dump_separator", ic->dump_separator, 0);
890 20 buf[0] = 0;
891 20 avcodec_string(buf, sizeof(buf), avctx, is_output);
892 20 ptr = av_stristr(buf, " ");
893 }
894 } else {
895 2 buf[0] = 0;
896 2 av_strlcatf(buf, sizeof(buf), " %dx%d", layered_video->width, layered_video->height);
897 }
898 22 avcodec_free_context(&avctx);
899
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 2 times.
22 if (ptr)
900 20 av_log(NULL, log_level, "%s", ptr);
901 22 dump_disposition(stg->disposition, log_level);
902 22 av_log(NULL, log_level, "\n");
903 22 dump_metadata(NULL, stg->metadata, extra_indent, log_level);
904 22 dump_sidedata(NULL, stg->coded_side_data, stg->nb_coded_side_data,
905 22 layered_video->width, layered_video->height, (AVRational) {0,1},
906 extra_indent, log_level);
907
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 22 times.
66 for (int i = 0; i < stg->nb_entries; i++) {
908 44 const AVStreamGroupEntry *entry = stg->entries[i];
909
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 6 times.
44 if (entry->type == AV_STREAM_GROUP_ENTRY_STREAM) {
910 38 const AVStream *st = entry->stream;
911 38 dump_stream_format(ic, st->index, i, index, is_output, log_level);
912 38 printed[st->index] = 1;
913
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 } else if (entry->type == AV_STREAM_GROUP_ENTRY_STREAM_GROUP)
914 6 dump_stream_group(ic, printed, entry->stream_group->index, index,
915 is_output, AV_LOG_VERBOSE);
916 }
917 22 break;
918 }
919 39 case AV_STREAM_GROUP_PARAMS_TREF: {
920 39 av_log(NULL, log_level, " Track Reference:\n");
921
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 39 times.
118 for (int i = 0; i < stg->nb_entries; i++) {
922 79 const AVStreamGroupEntry *entry = stg->entries[i];
923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if (entry->type != AV_STREAM_GROUP_ENTRY_STREAM)
924 ✗ continue;
925 79 const AVStream *st = entry->stream;
926 79 dump_stream_format(ic, st->index, i, index, is_output, log_level);
927 79 printed[st->index] = 1;
928 }
929 39 break;
930 }
931 ✗ default:
932 ✗ break;
933 }
934 204 }
935
936 17285 void av_dump_format(AVFormatContext *ic, int index,
937 const char *url, int is_output)
938 {
939 int i;
940
2/2
✓ Branch 0 taken 17283 times.
✓ Branch 1 taken 2 times.
17285 uint8_t *printed = ic->nb_streams ? av_mallocz(ic->nb_streams) : NULL;
941
3/4
✓ Branch 0 taken 17283 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17283 times.
17285 if (ic->nb_streams && !printed)
942 ✗ return;
943
944
6/6
✓ Branch 0 taken 9020 times.
✓ Branch 1 taken 8265 times.
✓ Branch 2 taken 9020 times.
✓ Branch 3 taken 8265 times.
✓ Branch 4 taken 9020 times.
✓ Branch 5 taken 8265 times.
34570 av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
945 is_output ? "Output" : "Input",
946 index,
947 17285 is_output ? ic->oformat->name : ic->iformat->name,
948 is_output ? "to" : "from", url);
949 17285 dump_metadata(NULL, ic->metadata, " ", AV_LOG_INFO);
950
951
2/2
✓ Branch 0 taken 8265 times.
✓ Branch 1 taken 9020 times.
17285 if (!is_output) {
952 8265 av_log(NULL, AV_LOG_INFO, " Duration: ");
953
2/2
✓ Branch 0 taken 6944 times.
✓ Branch 1 taken 1321 times.
8265 if (ic->duration != AV_NOPTS_VALUE) {
954 int64_t hours, mins, secs, us;
955
1/2
✓ Branch 0 taken 6944 times.
✗ Branch 1 not taken.
6944 int64_t duration = ic->duration + (ic->duration <= INT64_MAX - 5000 ? 5000 : 0);
956 6944 secs = duration / AV_TIME_BASE;
957 6944 us = duration % AV_TIME_BASE;
958 6944 mins = secs / 60;
959 6944 secs %= 60;
960 6944 hours = mins / 60;
961 6944 mins %= 60;
962 6944 av_log(NULL, AV_LOG_INFO, "%02"PRId64":%02"PRId64":%02"PRId64".%02"PRId64"", hours, mins, secs,
963 (100 * us) / AV_TIME_BASE);
964 } else {
965 1321 av_log(NULL, AV_LOG_INFO, "N/A");
966 }
967
2/2
✓ Branch 0 taken 6296 times.
✓ Branch 1 taken 1969 times.
8265 if (ic->start_time != AV_NOPTS_VALUE) {
968 int secs, us;
969 6296 av_log(NULL, AV_LOG_INFO, ", start: ");
970 6296 secs = llabs(ic->start_time / AV_TIME_BASE);
971 6296 us = llabs(ic->start_time % AV_TIME_BASE);
972 6296 av_log(NULL, AV_LOG_INFO, "%s%d.%06d",
973 6296 ic->start_time >= 0 ? "" : "-",
974 secs,
975
2/2
✓ Branch 0 taken 6293 times.
✓ Branch 1 taken 3 times.
6296 (int) av_rescale(us, 1000000, AV_TIME_BASE));
976 }
977 8265 av_log(NULL, AV_LOG_INFO, ", bitrate: ");
978
2/2
✓ Branch 0 taken 3904 times.
✓ Branch 1 taken 4361 times.
8265 if (ic->bit_rate)
979 3904 av_log(NULL, AV_LOG_INFO, "%"PRId64" kb/s", ic->bit_rate / 1000);
980 else
981 4361 av_log(NULL, AV_LOG_INFO, "N/A");
982 8265 av_log(NULL, AV_LOG_INFO, "\n");
983 }
984
985
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 17185 times.
17285 if (ic->nb_chapters)
986 100 av_log(NULL, AV_LOG_INFO, " Chapters:\n");
987
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 17285 times.
17510 for (i = 0; i < ic->nb_chapters; i++) {
988 225 const AVChapter *ch = ic->chapters[i];
989 225 av_log(NULL, AV_LOG_INFO, " Chapter #%d:%d: ", index, i);
990 225 av_log(NULL, AV_LOG_INFO,
991 225 "start %f, ", ch->start * av_q2d(ch->time_base));
992 225 av_log(NULL, AV_LOG_INFO,
993 225 "end %f\n", ch->end * av_q2d(ch->time_base));
994
995 225 dump_metadata(NULL, ch->metadata, " ", AV_LOG_INFO);
996 }
997
998
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 17182 times.
17285 if (ic->nb_programs) {
999 103 int j, k, total = 0;
1000
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 103 times.
208 for (j = 0; j < ic->nb_programs; j++) {
1001 105 const AVProgram *program = ic->programs[j];
1002 105 const AVDictionaryEntry *name = av_dict_get(program->metadata,
1003 "name", NULL, 0);
1004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 av_log(NULL, AV_LOG_INFO, " Program %d %s\n", program->id,
1005 name ? name->value : "");
1006 105 dump_metadata(NULL, program->metadata, " ", AV_LOG_INFO);
1007
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 105 times.
386 for (k = 0; k < program->nb_stream_indexes; k++) {
1008 281 dump_stream_format(ic, program->stream_index[k],
1009 -1, index, is_output, AV_LOG_INFO);
1010 281 printed[program->stream_index[k]] = 1;
1011 }
1012 105 total += program->nb_stream_indexes;
1013 }
1014
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 97 times.
103 if (total < ic->nb_streams)
1015 6 av_log(NULL, AV_LOG_INFO, " No Program\n");
1016 }
1017
1018
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 17285 times.
17483 for (i = 0; i < ic->nb_stream_groups; i++)
1019 198 dump_stream_group(ic, printed, i, index, is_output, AV_LOG_INFO);
1020
1021
2/2
✓ Branch 0 taken 19089 times.
✓ Branch 1 taken 17285 times.
36374 for (i = 0; i < ic->nb_streams; i++)
1022
2/2
✓ Branch 0 taken 18308 times.
✓ Branch 1 taken 781 times.
19089 if (!printed[i])
1023 18308 dump_stream_format(ic, i, -1, index, is_output, AV_LOG_INFO);
1024
1025 17285 av_free(printed);
1026 }
1027