FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/dump.c
Date: 2025-07-28 20:30:09
Exec Total Coverage
Lines: 438 625 70.1%
Functions: 20 29 69.0%
Branches: 252 393 64.1%

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/iamf.h"
29 #include "libavutil/intreadwrite.h"
30 #include "libavutil/log.h"
31 #include "libavutil/mastering_display_metadata.h"
32 #include "libavutil/ambient_viewing_environment.h"
33 #include "libavutil/dovi_meta.h"
34 #include "libavutil/mathematics.h"
35 #include "libavutil/mem.h"
36 #include "libavutil/opt.h"
37 #include "libavutil/replaygain.h"
38 #include "libavutil/spherical.h"
39 #include "libavutil/stereo3d.h"
40 #include "libavutil/tdrdi.h"
41 #include "libavutil/timecode.h"
42
43 #include "libavcodec/avcodec.h"
44
45 #include "avformat.h"
46 #include "internal.h"
47
48 #define HEXDUMP_PRINT(...) \
49 do { \
50 if (!f) \
51 av_log(avcl, level, __VA_ARGS__); \
52 else \
53 fprintf(f, __VA_ARGS__); \
54 } while (0)
55
56 1 static void hex_dump_internal(void *avcl, FILE *f, int level,
57 const uint8_t *buf, int size)
58 {
59 int len, i, j, c;
60
61
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (i = 0; i < size; i += 16) {
62 2 len = size - i;
63
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (len > 16)
64 1 len = 16;
65
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 HEXDUMP_PRINT("%08x ", i);
66
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 2 times.
34 for (j = 0; j < 16; j++) {
67
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
32 if (j < len)
68
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 HEXDUMP_PRINT(" %02x", buf[i + j]);
69 else
70
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 HEXDUMP_PRINT(" ");
71 }
72
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 HEXDUMP_PRINT(" ");
73
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2 times.
26 for (j = 0; j < len; j++) {
74 24 c = buf[i + j];
75
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 > '~')
76 15 c = '.';
77
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 HEXDUMP_PRINT("%c", c);
78 }
79
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 HEXDUMP_PRINT("\n");
80 }
81 1 }
82
83 void av_hex_dump(FILE *f, const uint8_t *buf, int size)
84 {
85 hex_dump_internal(NULL, f, 0, buf, size);
86 }
87
88 1 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
89 {
90 1 hex_dump_internal(avcl, NULL, level, buf, size);
91 1 }
92
93 static void pkt_dump_internal(void *avcl, FILE *f, int level, const AVPacket *pkt,
94 int dump_payload, AVRational time_base)
95 {
96 HEXDUMP_PRINT("stream #%d:\n", pkt->stream_index);
97 HEXDUMP_PRINT(" keyframe=%d\n", (pkt->flags & AV_PKT_FLAG_KEY) != 0);
98 HEXDUMP_PRINT(" duration=%0.3f\n", pkt->duration * av_q2d(time_base));
99 /* DTS is _always_ valid after av_read_frame() */
100 HEXDUMP_PRINT(" dts=");
101 if (pkt->dts == AV_NOPTS_VALUE)
102 HEXDUMP_PRINT("N/A");
103 else
104 HEXDUMP_PRINT("%0.3f", pkt->dts * av_q2d(time_base));
105 /* PTS may not be known if B-frames are present. */
106 HEXDUMP_PRINT(" pts=");
107 if (pkt->pts == AV_NOPTS_VALUE)
108 HEXDUMP_PRINT("N/A");
109 else
110 HEXDUMP_PRINT("%0.3f", pkt->pts * av_q2d(time_base));
111 HEXDUMP_PRINT("\n");
112 HEXDUMP_PRINT(" size=%d\n", pkt->size);
113 if (dump_payload)
114 hex_dump_internal(avcl, f, level, pkt->data, pkt->size);
115 }
116
117 void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st)
118 {
119 pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base);
120 }
121
122 void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload,
123 const AVStream *st)
124 {
125 pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base);
126 }
127
128
129 32425 static void print_fps(double d, const char *postfix, int log_level)
130 {
131 32425 uint64_t v = lrintf(d * 100);
132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32425 times.
32425 if (!v)
133 av_log(NULL, log_level, "%1.4f %s", d, postfix);
134
2/2
✓ Branch 0 taken 2017 times.
✓ Branch 1 taken 30408 times.
32425 else if (v % 100)
135 2017 av_log(NULL, log_level, "%3.2f %s", d, postfix);
136
2/2
✓ Branch 0 taken 28164 times.
✓ Branch 1 taken 2244 times.
30408 else if (v % (100 * 1000))
137 28164 av_log(NULL, log_level, "%1.0f %s", d, postfix);
138 else
139 2244 av_log(NULL, log_level, "%1.0fk %s", d / 1000, postfix);
140 32425 }
141
142 12580 static void dump_dictionary(void *ctx, const AVDictionary *m,
143 const char *name, const char *indent,
144 int log_level)
145 {
146 12580 const AVDictionaryEntry *tag = NULL;
147
148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12580 times.
12580 if (!m)
149 return;
150
151 12580 av_log(ctx, log_level, "%s%s:\n", indent, name);
152
2/2
✓ Branch 1 taken 21677 times.
✓ Branch 2 taken 12580 times.
34257 while ((tag = av_dict_iterate(m, tag)))
153
2/2
✓ Branch 0 taken 20579 times.
✓ Branch 1 taken 1098 times.
21677 if (strcmp("language", tag->key)) {
154 20579 const char *p = tag->value;
155 20579 av_log(ctx, log_level,
156 20579 "%s %-16s: ", indent, tag->key);
157
2/2
✓ Branch 0 taken 21099 times.
✓ Branch 1 taken 20579 times.
41678 while (*p) {
158 21099 size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
159
1/2
✓ Branch 0 taken 21099 times.
✗ Branch 1 not taken.
21099 av_log(ctx, log_level, "%.*s", (int)(FFMIN(255, len)), p);
160 21099 p += len;
161
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 20819 times.
21099 if (*p == 0xd) av_log(ctx, log_level, " ");
162
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 20740 times.
21099 if (*p == 0xa) av_log(ctx, log_level, "\n%s %-16s: ", indent, "");
163
2/2
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 20438 times.
21099 if (*p) p++;
164 }
165 20579 av_log(ctx, log_level, "\n");
166 }
167 }
168
169 33321 static void dump_metadata(void *ctx, const AVDictionary *m, const char *indent,
170 int log_level)
171 {
172
6/6
✓ Branch 0 taken 12863 times.
✓ Branch 1 taken 20458 times.
✓ Branch 3 taken 9857 times.
✓ Branch 4 taken 3006 times.
✓ Branch 6 taken 9489 times.
✓ Branch 7 taken 368 times.
33321 if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0)))
173 12495 dump_dictionary(ctx, m, "Metadata", indent, log_level);
174 33321 }
175
176 /* param change side data*/
177 static void dump_paramchange(void *ctx, const AVPacketSideData *sd, int log_level)
178 {
179 int size = sd->size;
180 const uint8_t *data = sd->data;
181 uint32_t flags, sample_rate, width, height;
182
183 if (!data || sd->size < 4)
184 goto fail;
185
186 flags = AV_RL32(data);
187 data += 4;
188 size -= 4;
189
190 if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
191 if (size < 4)
192 goto fail;
193 sample_rate = AV_RL32(data);
194 data += 4;
195 size -= 4;
196 av_log(ctx, log_level, "sample_rate %"PRIu32", ", sample_rate);
197 }
198 if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) {
199 if (size < 8)
200 goto fail;
201 width = AV_RL32(data);
202 data += 4;
203 size -= 4;
204 height = AV_RL32(data);
205 data += 4;
206 size -= 4;
207 av_log(ctx, log_level, "width %"PRIu32" height %"PRIu32, width, height);
208 }
209
210 return;
211 fail:
212 av_log(ctx, AV_LOG_ERROR, "unknown param\n");
213 }
214
215 /* replaygain side data*/
216 static void print_gain(void *ctx, const char *str, int32_t gain, int log_level)
217 {
218 av_log(ctx, log_level, "%s - ", str);
219 if (gain == INT32_MIN)
220 av_log(ctx, log_level, "unknown");
221 else
222 av_log(ctx, log_level, "%f", gain / 100000.0f);
223 av_log(ctx, log_level, ", ");
224 }
225
226 static void print_peak(void *ctx, const char *str, uint32_t peak, int log_level)
227 {
228 av_log(ctx, log_level, "%s - ", str);
229 if (!peak)
230 av_log(ctx, log_level, "unknown");
231 else
232 av_log(ctx, log_level, "%f", (float) peak / UINT32_MAX);
233 av_log(ctx, log_level, ", ");
234 }
235
236 static void dump_replaygain(void *ctx, const AVPacketSideData *sd, int log_level)
237 {
238 const AVReplayGain *rg;
239
240 if (sd->size < sizeof(*rg)) {
241 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
242 return;
243 }
244 rg = (const AVReplayGain *)sd->data;
245
246 print_gain(ctx, "track gain", rg->track_gain, log_level);
247 print_peak(ctx, "track peak", rg->track_peak, log_level);
248 print_gain(ctx, "album gain", rg->album_gain, log_level);
249 print_peak(ctx, "album peak", rg->album_peak, log_level);
250 }
251
252 476 static void dump_stereo3d(void *ctx, const AVPacketSideData *sd, int log_level)
253 {
254 const AVStereo3D *stereo;
255
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 if (sd->size < sizeof(*stereo)) {
257 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
258 return;
259 }
260
261 476 stereo = (const AVStereo3D *)sd->data;
262
263 476 av_log(ctx, log_level, "%s, view: %s, primary eye: %s",
264 476 av_stereo3d_type_name(stereo->type), av_stereo3d_view_name(stereo->view),
265 476 av_stereo3d_primary_eye_name(stereo->primary_eye));
266
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 469 times.
476 if (stereo->baseline)
267 7 av_log(ctx, log_level, ", baseline: %"PRIu32"", stereo->baseline);
268
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 469 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
476 if (stereo->horizontal_disparity_adjustment.num && stereo->horizontal_disparity_adjustment.den)
269 7 av_log(ctx, log_level, ", horizontal_disparity_adjustment: %0.4f",
270 av_q2d(stereo->horizontal_disparity_adjustment));
271
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 469 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
476 if (stereo->horizontal_field_of_view.num && stereo->horizontal_field_of_view.den)
272 7 av_log(ctx, log_level, ", horizontal_field_of_view: %0.3f", av_q2d(stereo->horizontal_field_of_view));
273
274
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 467 times.
476 if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
275 9 av_log(ctx, log_level, " (inverted)");
276 }
277
278 12 static void dump_audioservicetype(void *ctx, const AVPacketSideData *sd, int log_level)
279 {
280 12 const enum AVAudioServiceType *ast = (const enum AVAudioServiceType *)sd->data;
281
282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (sd->size < sizeof(*ast)) {
283 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
284 return;
285 }
286
287
1/10
✓ Branch 0 taken 12 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.
12 switch (*ast) {
288 12 case AV_AUDIO_SERVICE_TYPE_MAIN:
289 12 av_log(ctx, log_level, "main");
290 12 break;
291 case AV_AUDIO_SERVICE_TYPE_EFFECTS:
292 av_log(ctx, log_level, "effects");
293 break;
294 case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:
295 av_log(ctx, log_level, "visually impaired");
296 break;
297 case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:
298 av_log(ctx, log_level, "hearing impaired");
299 break;
300 case AV_AUDIO_SERVICE_TYPE_DIALOGUE:
301 av_log(ctx, log_level, "dialogue");
302 break;
303 case AV_AUDIO_SERVICE_TYPE_COMMENTARY:
304 av_log(ctx, log_level, "commentary");
305 break;
306 case AV_AUDIO_SERVICE_TYPE_EMERGENCY:
307 av_log(ctx, log_level, "emergency");
308 break;
309 case AV_AUDIO_SERVICE_TYPE_VOICE_OVER:
310 av_log(ctx, log_level, "voice over");
311 break;
312 case AV_AUDIO_SERVICE_TYPE_KARAOKE:
313 av_log(ctx, log_level, "karaoke");
314 break;
315 default:
316 av_log(ctx, AV_LOG_WARNING, "unknown");
317 break;
318 }
319 }
320
321 322 static void dump_cpb(void *ctx, const AVPacketSideData *sd, int log_level)
322 {
323 322 const AVCPBProperties *cpb = (const AVCPBProperties *)sd->data;
324
325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if (sd->size < sizeof(*cpb)) {
326 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
327 return;
328 }
329
330 322 av_log(ctx, log_level,
331 "bitrate max/min/avg: %"PRId64"/%"PRId64"/%"PRId64" buffer size: %"PRId64" ",
332 322 cpb->max_bitrate, cpb->min_bitrate, cpb->avg_bitrate,
333 322 cpb->buffer_size);
334
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if (cpb->vbv_delay == UINT64_MAX)
335 322 av_log(ctx, log_level, "vbv_delay: N/A");
336 else
337 av_log(ctx, log_level, "vbv_delay: %"PRIu64"", cpb->vbv_delay);
338 }
339
340 23 static void dump_mastering_display_metadata(void *ctx, const AVPacketSideData *sd,
341 int log_level)
342 {
343 23 const AVMasteringDisplayMetadata *metadata =
344 (const AVMasteringDisplayMetadata *)sd->data;
345 23 av_log(ctx, log_level, "Mastering Display Metadata, "
346 "has_primaries:%d has_luminance:%d "
347 "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) "
348 "min_luminance=%f, max_luminance=%f",
349 23 metadata->has_primaries, metadata->has_luminance,
350 av_q2d(metadata->display_primaries[0][0]),
351 av_q2d(metadata->display_primaries[0][1]),
352 av_q2d(metadata->display_primaries[1][0]),
353 av_q2d(metadata->display_primaries[1][1]),
354 av_q2d(metadata->display_primaries[2][0]),
355 av_q2d(metadata->display_primaries[2][1]),
356 av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1]),
357 av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance));
358 23 }
359
360 20 static void dump_content_light_metadata(void *ctx, const AVPacketSideData *sd,
361 int log_level)
362 {
363 20 const AVContentLightMetadata *metadata =
364 (const AVContentLightMetadata *)sd->data;
365 20 av_log(ctx, log_level, "Content Light Level Metadata, "
366 "MaxCLL=%d, MaxFALL=%d",
367 20 metadata->MaxCLL, metadata->MaxFALL);
368 20 }
369
370 6 static void dump_ambient_viewing_environment_metadata(void *ctx, const AVPacketSideData *sd)
371 {
372 6 const AVAmbientViewingEnvironment *ambient =
373 (const AVAmbientViewingEnvironment *)sd->data;
374 6 av_log(ctx, AV_LOG_INFO, "Ambient Viewing Environment, "
375 "ambient_illuminance=%f, ambient_light_x=%f, ambient_light_y=%f",
376 av_q2d(ambient->ambient_illuminance),
377 av_q2d(ambient->ambient_light_x),
378 av_q2d(ambient->ambient_light_y));
379 6 }
380
381 18 static void dump_spherical(void *ctx, int w, int h,
382 const AVPacketSideData *sd, int log_level)
383 {
384 18 const AVSphericalMapping *spherical = (const AVSphericalMapping *)sd->data;
385 double yaw, pitch, roll;
386
387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (sd->size < sizeof(*spherical)) {
388 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
389 return;
390 }
391
392 18 av_log(ctx, log_level, "%s ", av_spherical_projection_name(spherical->projection));
393
394
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) {
395 11 yaw = ((double)spherical->yaw) / (1 << 16);
396 11 pitch = ((double)spherical->pitch) / (1 << 16);
397 11 roll = ((double)spherical->roll) / (1 << 16);
398 11 av_log(ctx, log_level, "(%f/%f/%f) ", yaw, pitch, roll);
399 }
400
401
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7 times.
18 if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
402 size_t l, t, r, b;
403 11 av_spherical_tile_bounds(spherical, w, h,
404 &l, &t, &r, &b);
405 11 av_log(ctx, log_level,
406 "[%"SIZE_SPECIFIER", %"SIZE_SPECIFIER", %"SIZE_SPECIFIER", %"SIZE_SPECIFIER"] ",
407 l, t, r, b);
408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 } else if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
409 av_log(ctx, log_level, "[pad %"PRIu32"] ", spherical->padding);
410 }
411 }
412
413 13 static void dump_dovi_conf(void *ctx, const AVPacketSideData *sd,
414 int log_level)
415 {
416 13 const AVDOVIDecoderConfigurationRecord *dovi =
417 (const AVDOVIDecoderConfigurationRecord *)sd->data;
418
419 13 av_log(ctx, log_level, "version: %d.%d, profile: %d, level: %d, "
420 "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d, "
421 "compression: %d",
422 13 dovi->dv_version_major, dovi->dv_version_minor,
423 13 dovi->dv_profile, dovi->dv_level,
424 13 dovi->rpu_present_flag,
425 13 dovi->el_present_flag,
426 13 dovi->bl_present_flag,
427 13 dovi->dv_bl_signal_compatibility_id,
428 13 dovi->dv_md_compression);
429 13 }
430
431 static void dump_s12m_timecode(void *ctx, AVRational avg_frame_rate, const AVPacketSideData *sd,
432 int log_level)
433 {
434 const uint32_t *tc = (const uint32_t *)sd->data;
435
436 if ((sd->size != sizeof(uint32_t) * 4) || (tc[0] > 3)) {
437 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
438 return;
439 }
440
441 for (int j = 1; j <= tc[0]; j++) {
442 char tcbuf[AV_TIMECODE_STR_SIZE];
443 av_timecode_make_smpte_tc_string2(tcbuf, avg_frame_rate, tc[j], 0, 0);
444 av_log(ctx, log_level, "timecode - %s%s", tcbuf, j != tc[0] ? ", " : "");
445 }
446 }
447
448 18 static void dump_cropping(void *ctx, const AVPacketSideData *sd)
449 {
450 uint32_t top, bottom, left, right;
451
452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (sd->size < sizeof(uint32_t) * 4) {
453 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
454 return;
455 }
456
457 18 top = AV_RL32(sd->data + 0);
458 18 bottom = AV_RL32(sd->data + 4);
459 18 left = AV_RL32(sd->data + 8);
460 18 right = AV_RL32(sd->data + 12);
461
462 18 av_log(ctx, AV_LOG_INFO, "%d/%d/%d/%d", left, right, top, bottom);
463 }
464
465 2 static void dump_tdrdi(void *ctx, const AVPacketSideData *sd)
466 {
467 2 const AV3DReferenceDisplaysInfo *tdrdi =
468 (const AV3DReferenceDisplaysInfo *)sd->data;
469
470 2 av_log(ctx, AV_LOG_INFO, "number of reference displays: %u", tdrdi->num_ref_displays);
471 2 }
472
473 17239 static void dump_sidedata(void *ctx, const AVPacketSideData *side_data, int nb_side_data,
474 int w, int h, AVRational avg_frame_rate,
475 const char *indent, int log_level)
476 {
477 int i;
478
479
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 16349 times.
17239 if (nb_side_data)
480 890 av_log(ctx, log_level, "%sSide data:\n", indent);
481
482
2/2
✓ Branch 0 taken 953 times.
✓ Branch 1 taken 17239 times.
18192 for (i = 0; i < nb_side_data; i++) {
483 953 const AVPacketSideData *sd = &side_data[i];
484 953 av_log(ctx, log_level, "%s ", indent);
485
486
13/20
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 476 times.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 322 times.
✓ Branch 10 taken 23 times.
✓ Branch 11 taken 18 times.
✓ Branch 12 taken 20 times.
✓ Branch 13 taken 8 times.
✓ Branch 14 taken 13 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 6 times.
✓ Branch 17 taken 18 times.
✓ Branch 18 taken 2 times.
✓ Branch 19 taken 2 times.
953 switch (sd->type) {
487 case AV_PKT_DATA_PALETTE:
488 av_log(ctx, log_level, "palette");
489 break;
490 case AV_PKT_DATA_NEW_EXTRADATA:
491 av_log(ctx, log_level, "new extradata");
492 break;
493 case AV_PKT_DATA_PARAM_CHANGE:
494 av_log(ctx, log_level, "paramchange: ");
495 dump_paramchange(ctx, sd, log_level);
496 break;
497 case AV_PKT_DATA_H263_MB_INFO:
498 av_log(ctx, log_level, "H.263 macroblock info");
499 break;
500 case AV_PKT_DATA_REPLAYGAIN:
501 av_log(ctx, log_level, "replaygain: ");
502 dump_replaygain(ctx, sd, log_level);
503 break;
504 33 case AV_PKT_DATA_DISPLAYMATRIX:
505 33 av_log(ctx, log_level, "displaymatrix: rotation of %.2f degrees",
506 33 av_display_rotation_get((const int32_t *)sd->data));
507 33 break;
508 476 case AV_PKT_DATA_STEREO3D:
509 476 av_log(ctx, log_level, "stereo3d: ");
510 476 dump_stereo3d(ctx, sd, log_level);
511 476 break;
512 12 case AV_PKT_DATA_AUDIO_SERVICE_TYPE:
513 12 av_log(ctx, log_level, "audio service type: ");
514 12 dump_audioservicetype(ctx, sd, log_level);
515 12 break;
516 case AV_PKT_DATA_QUALITY_STATS:
517 av_log(ctx, log_level, "quality factor: %"PRId32", pict_type: %c",
518 AV_RL32(sd->data), av_get_picture_type_char(sd->data[4]));
519 break;
520 322 case AV_PKT_DATA_CPB_PROPERTIES:
521 322 av_log(ctx, log_level, "cpb: ");
522 322 dump_cpb(ctx, sd, log_level);
523 322 break;
524 23 case AV_PKT_DATA_MASTERING_DISPLAY_METADATA:
525 23 dump_mastering_display_metadata(ctx, sd, log_level);
526 23 break;
527 18 case AV_PKT_DATA_SPHERICAL:
528 18 av_log(ctx, log_level, "spherical: ");
529 18 dump_spherical(ctx, w, h, sd, log_level);
530 18 break;
531 20 case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:
532 20 dump_content_light_metadata(ctx, sd, log_level);
533 20 break;
534 8 case AV_PKT_DATA_ICC_PROFILE:
535 8 av_log(ctx, log_level, "ICC Profile");
536 8 break;
537 13 case AV_PKT_DATA_DOVI_CONF:
538 13 av_log(ctx, log_level, "DOVI configuration record: ");
539 13 dump_dovi_conf(ctx, sd, log_level);
540 13 break;
541 case AV_PKT_DATA_S12M_TIMECODE:
542 av_log(ctx, log_level, "SMPTE ST 12-1:2014: ");
543 dump_s12m_timecode(ctx, avg_frame_rate, sd, log_level);
544 break;
545 6 case AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT:
546 6 dump_ambient_viewing_environment_metadata(ctx, sd);
547 6 break;
548 18 case AV_PKT_DATA_FRAME_CROPPING:
549 18 av_log(ctx, AV_LOG_INFO, "Frame cropping: ");
550 18 dump_cropping(ctx, sd);
551 18 break;
552 2 case AV_PKT_DATA_3D_REFERENCE_DISPLAYS:
553 2 av_log(ctx, log_level, "3D Reference Displays Information: ");
554 2 dump_tdrdi(ctx, sd);
555 2 break;
556 2 default:
557 2 av_log(ctx, log_level, "unknown side data type %d "
558 2 "(%"SIZE_SPECIFIER" bytes)", sd->type, sd->size);
559 2 break;
560 }
561
562 953 av_log(ctx, log_level, "\n");
563 }
564 17239 }
565
566 17318 static void dump_disposition(int disposition, int log_level)
567 {
568
2/2
✓ Branch 0 taken 1838 times.
✓ Branch 1 taken 15480 times.
17318 if (disposition & AV_DISPOSITION_DEFAULT)
569 1838 av_log(NULL, log_level, " (default)");
570
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 17314 times.
17318 if (disposition & AV_DISPOSITION_DUB)
571 4 av_log(NULL, log_level, " (dub)");
572
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 17314 times.
17318 if (disposition & AV_DISPOSITION_ORIGINAL)
573 4 av_log(NULL, log_level, " (original)");
574
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 17313 times.
17318 if (disposition & AV_DISPOSITION_COMMENT)
575 5 av_log(NULL, log_level, " (comment)");
576
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17317 times.
17318 if (disposition & AV_DISPOSITION_LYRICS)
577 1 av_log(NULL, log_level, " (lyrics)");
578
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17317 times.
17318 if (disposition & AV_DISPOSITION_KARAOKE)
579 1 av_log(NULL, log_level, " (karaoke)");
580
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 17311 times.
17318 if (disposition & AV_DISPOSITION_FORCED)
581 7 av_log(NULL, log_level, " (forced)");
582
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 17296 times.
17318 if (disposition & AV_DISPOSITION_HEARING_IMPAIRED)
583 22 av_log(NULL, log_level, " (hearing impaired)");
584
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 17302 times.
17318 if (disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
585 16 av_log(NULL, log_level, " (visual impaired)");
586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17318 times.
17318 if (disposition & AV_DISPOSITION_CLEAN_EFFECTS)
587 av_log(NULL, log_level, " (clean effects)");
588
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 17221 times.
17318 if (disposition & AV_DISPOSITION_ATTACHED_PIC)
589 97 av_log(NULL, log_level, " (attached pic)");
590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17318 times.
17318 if (disposition & AV_DISPOSITION_TIMED_THUMBNAILS)
591 av_log(NULL, log_level, " (timed thumbnails)");
592
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 17312 times.
17318 if (disposition & AV_DISPOSITION_CAPTIONS)
593 6 av_log(NULL, log_level, " (captions)");
594
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 17300 times.
17318 if (disposition & AV_DISPOSITION_DESCRIPTIONS)
595 18 av_log(NULL, log_level, " (descriptions)");
596
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 17314 times.
17318 if (disposition & AV_DISPOSITION_METADATA)
597 4 av_log(NULL, log_level, " (metadata)");
598
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 17068 times.
17318 if (disposition & AV_DISPOSITION_DEPENDENT)
599 250 av_log(NULL, log_level, " (dependent)");
600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17318 times.
17318 if (disposition & AV_DISPOSITION_STILL_IMAGE)
601 av_log(NULL, log_level, " (still image)");
602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17318 times.
17318 if (disposition & AV_DISPOSITION_NON_DIEGETIC)
603 av_log(NULL, log_level, " (non-diegetic)");
604
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 17311 times.
17318 if (disposition & AV_DISPOSITION_MULTILAYER)
605 7 av_log(NULL, log_level, " (multilayer)");
606 17318 }
607
608 /* "user interface" functions */
609 17233 static void dump_stream_format(const AVFormatContext *ic, int i,
610 int group_index, int index, int is_output,
611 int log_level)
612 {
613 char buf[256];
614
2/2
✓ Branch 0 taken 8910 times.
✓ Branch 1 taken 8323 times.
17233 int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
615 17233 const AVStream *st = ic->streams[i];
616 17233 const FFStream *const sti = cffstream(st);
617 17233 const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
618 17233 const char *separator = ic->dump_separator;
619
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 16869 times.
17233 const char *group_indent = group_index >= 0 ? " " : "";
620
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 16869 times.
17233 const char *extra_indent = group_index >= 0 ? " " : " ";
621 AVCodecContext *avctx;
622 int ret;
623
624 17233 avctx = avcodec_alloc_context3(NULL);
625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17233 times.
17233 if (!avctx)
626 return;
627
628 17233 ret = avcodec_parameters_to_context(avctx, st->codecpar);
629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17233 times.
17233 if (ret < 0) {
630 avcodec_free_context(&avctx);
631 return;
632 }
633
634 // Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext
635
2/2
✓ Branch 0 taken 8323 times.
✓ Branch 1 taken 8910 times.
17233 if (sti->avctx) {
636 #if FF_API_CODEC_PROPS
637 FF_DISABLE_DEPRECATION_WARNINGS
638 8323 avctx->properties = sti->avctx->properties;
639 FF_ENABLE_DEPRECATION_WARNINGS
640 #endif
641 8323 avctx->codec = sti->avctx->codec;
642 8323 avctx->qmin = sti->avctx->qmin;
643 8323 avctx->qmax = sti->avctx->qmax;
644 8323 avctx->coded_width = sti->avctx->coded_width;
645 8323 avctx->coded_height = sti->avctx->coded_height;
646 }
647
648
1/2
✓ Branch 0 taken 17233 times.
✗ Branch 1 not taken.
17233 if (separator)
649 17233 av_opt_set(avctx, "dump_separator", separator, 0);
650 17233 avcodec_string(buf, sizeof(buf), avctx, is_output);
651 17233 avcodec_free_context(&avctx);
652
653 17233 av_log(NULL, log_level, "%s Stream #%d", group_indent, index);
654 17233 av_log(NULL, log_level, ":%d", i);
655
656 /* the pid is an important information, so we display it */
657 /* XXX: add a generic system */
658
2/2
✓ Branch 0 taken 1000 times.
✓ Branch 1 taken 16233 times.
17233 if (flags & AVFMT_SHOW_IDS)
659 1000 av_log(NULL, log_level, "[0x%x]", st->id);
660
2/2
✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 15787 times.
17233 if (lang)
661 1446 av_log(NULL, log_level, "(%s)", lang->value);
662 17233 av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", sti->codec_info_nb_frames,
663 17233 st->time_base.num, st->time_base.den);
664 17233 av_log(NULL, log_level, ": %s", buf);
665
666
4/4
✓ Branch 0 taken 2461 times.
✓ Branch 1 taken 14772 times.
✓ Branch 2 taken 375 times.
✓ Branch 3 taken 2086 times.
19694 if (st->sample_aspect_ratio.num &&
667 2461 av_cmp_q(st->sample_aspect_ratio, st->codecpar->sample_aspect_ratio)) {
668 AVRational display_aspect_ratio;
669 375 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
670 375 st->codecpar->width * (int64_t)st->sample_aspect_ratio.num,
671 375 st->codecpar->height * (int64_t)st->sample_aspect_ratio.den,
672 1024 * 1024);
673 375 av_log(NULL, log_level, ", SAR %d:%d DAR %d:%d",
674 375 st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
675 display_aspect_ratio.num, display_aspect_ratio.den);
676 }
677
678
2/2
✓ Branch 0 taken 13354 times.
✓ Branch 1 taken 3879 times.
17233 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
679
3/4
✓ Branch 0 taken 12499 times.
✓ Branch 1 taken 855 times.
✓ Branch 2 taken 12499 times.
✗ Branch 3 not taken.
13354 int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
680
3/4
✓ Branch 0 taken 6572 times.
✓ Branch 1 taken 6782 times.
✓ Branch 2 taken 6572 times.
✗ Branch 3 not taken.
13354 int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
681
2/4
✓ Branch 0 taken 13354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13354 times.
✗ Branch 3 not taken.
13354 int tbn = st->time_base.den && st->time_base.num;
682
683
5/6
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 12499 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 835 times.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
13354 if (fps || tbr || tbn)
684 13354 av_log(NULL, log_level, "%s", separator);
685
686
2/2
✓ Branch 0 taken 12499 times.
✓ Branch 1 taken 855 times.
13354 if (fps)
687
3/4
✓ Branch 0 taken 6762 times.
✓ Branch 1 taken 5737 times.
✓ Branch 2 taken 6762 times.
✗ Branch 3 not taken.
12499 print_fps(av_q2d(st->avg_frame_rate), tbr || tbn ? "fps, " : "fps", log_level);
688
2/2
✓ Branch 0 taken 6572 times.
✓ Branch 1 taken 6782 times.
13354 if (tbr)
689
1/2
✓ Branch 0 taken 6572 times.
✗ Branch 1 not taken.
6572 print_fps(av_q2d(st->r_frame_rate), tbn ? "tbr, " : "tbr", log_level);
690
1/2
✓ Branch 0 taken 13354 times.
✗ Branch 1 not taken.
13354 if (tbn)
691 13354 print_fps(1 / av_q2d(st->time_base), "tbn", log_level);
692 }
693
694
6/8
✓ Branch 0 taken 6421 times.
✓ Branch 1 taken 10812 times.
✓ Branch 2 taken 328 times.
✓ Branch 3 taken 6093 times.
✓ Branch 4 taken 328 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 328 times.
✗ Branch 7 not taken.
17233 if (st->start_time != AV_NOPTS_VALUE && st->start_time != 0 && st->time_base.den && st->time_base.num) {
695 328 const double stream_start = av_q2d(st->time_base) * st->start_time;
696 328 av_log(NULL, AV_LOG_INFO, ", start %.6f", stream_start);
697 }
698
699 17233 dump_disposition(st->disposition, log_level);
700 17233 av_log(NULL, log_level, "\n");
701
702 17233 dump_metadata(NULL, st->metadata, extra_indent, log_level);
703
704 17233 dump_sidedata(NULL, st->codecpar->coded_side_data, st->codecpar->nb_coded_side_data,
705 17233 st->codecpar->width, st->codecpar->height, st->avg_frame_rate,
706 extra_indent, log_level);
707 }
708
709 85 static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed,
710 int i, int index, int is_output)
711 {
712 85 const AVStreamGroup *stg = ic->stream_groups[i];
713
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 62 times.
85 int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
714 char buf[512];
715 int ret;
716
717 85 av_log(NULL, AV_LOG_INFO, " Stream group #%d:%d", index, i);
718
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 23 times.
85 if (flags & AVFMT_SHOW_IDS)
719 62 av_log(NULL, AV_LOG_INFO, "[0x%"PRIx64"]", stg->id);
720 85 av_log(NULL, AV_LOG_INFO, ":");
721
722
3/5
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
85 switch (stg->type) {
723 41 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT: {
724 41 const AVIAMFAudioElement *audio_element = stg->params.iamf_audio_element;
725 41 av_log(NULL, AV_LOG_INFO, " IAMF Audio Element:");
726 41 dump_disposition(stg->disposition, AV_LOG_INFO);
727 41 av_log(NULL, AV_LOG_INFO, "\n");
728 41 dump_metadata(NULL, stg->metadata, " ", AV_LOG_INFO);
729
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 41 times.
133 for (int j = 0; j < audio_element->nb_layers; j++) {
730 92 const AVIAMFLayer *layer = audio_element->layers[j];
731 92 int channel_count = layer->ch_layout.nb_channels;
732 92 av_log(NULL, AV_LOG_INFO, " Layer %d:", j);
733 92 ret = av_channel_layout_describe(&layer->ch_layout, buf, sizeof(buf));
734
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if (ret >= 0)
735 92 av_log(NULL, AV_LOG_INFO, " %s", buf);
736 92 av_log(NULL, AV_LOG_INFO, "\n");
737
3/4
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
442 for (int k = 0; channel_count > 0 && k < stg->nb_streams; k++) {
738 350 AVStream *st = stg->streams[k];
739 350 dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE);
740 350 printed[st->index] = 1;
741 350 channel_count -= st->codecpar->ch_layout.nb_channels;
742 }
743 }
744 41 break;
745 }
746 38 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: {
747 38 const AVIAMFMixPresentation *mix_presentation = stg->params.iamf_mix_presentation;
748 38 av_log(NULL, AV_LOG_INFO, " IAMF Mix Presentation:");
749 38 dump_disposition(stg->disposition, AV_LOG_INFO);
750 38 av_log(NULL, AV_LOG_INFO, "\n");
751 38 dump_metadata(NULL, stg->metadata, " ", AV_LOG_INFO);
752 38 dump_dictionary(NULL, mix_presentation->annotations, "Annotations", " ", AV_LOG_INFO);
753
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 for (int j = 0; j < mix_presentation->nb_submixes; j++) {
754 44 AVIAMFSubmix *sub_mix = mix_presentation->submixes[j];
755 44 av_log(NULL, AV_LOG_INFO, " Submix %d:\n", j);
756
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 44 times.
91 for (int k = 0; k < sub_mix->nb_elements; k++) {
757 47 const AVIAMFSubmixElement *submix_element = sub_mix->elements[k];
758 47 const AVStreamGroup *audio_element = NULL;
759
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 for (int l = 0; l < ic->nb_stream_groups; l++)
760
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if (ic->stream_groups[l]->type == AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT &&
761
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 3 times.
50 ic->stream_groups[l]->id == submix_element->audio_element_id) {
762 47 audio_element = ic->stream_groups[l];
763 47 break;
764 }
765
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if (audio_element) {
766 47 av_log(NULL, AV_LOG_INFO, " IAMF Audio Element #%d:%d",
767 47 index, audio_element->index);
768
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 14 times.
47 if (flags & AVFMT_SHOW_IDS)
769 33 av_log(NULL, AV_LOG_INFO, "[0x%"PRIx64"]", audio_element->id);
770 47 av_log(NULL, AV_LOG_INFO, "\n");
771 47 dump_dictionary(NULL, submix_element->annotations, "Annotations", " ", AV_LOG_INFO);
772 }
773 }
774
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 44 times.
142 for (int k = 0; k < sub_mix->nb_layouts; k++) {
775 98 const AVIAMFSubmixLayout *submix_layout = sub_mix->layouts[k];
776 98 av_log(NULL, AV_LOG_INFO, " Layout #%d:", k);
777
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 92 times.
98 if (submix_layout->layout_type == 2 ||
778
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 submix_layout->layout_type == 3) {
779 98 ret = av_channel_layout_describe(&submix_layout->sound_system, buf, sizeof(buf));
780
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if (ret >= 0)
781 98 av_log(NULL, AV_LOG_INFO, " %s", buf);
782 }
783 98 av_log(NULL, AV_LOG_INFO, "\n");
784 }
785 }
786 38 break;
787 }
788 6 case AV_STREAM_GROUP_PARAMS_TILE_GRID: {
789 6 const AVStreamGroupTileGrid *tile_grid = stg->params.tile_grid;
790 6 AVCodecContext *avctx = avcodec_alloc_context3(NULL);
791 6 const char *ptr = NULL;
792 6 av_log(NULL, AV_LOG_INFO, " Tile Grid:");
793
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
6 if (avctx && stg->nb_streams && !avcodec_parameters_to_context(avctx, stg->streams[0]->codecpar)) {
794 6 avctx->width = tile_grid->width;
795 6 avctx->height = tile_grid->height;
796 6 avctx->coded_width = tile_grid->coded_width;
797 6 avctx->coded_height = tile_grid->coded_height;
798
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (ic->dump_separator)
799 6 av_opt_set(avctx, "dump_separator", ic->dump_separator, 0);
800 6 buf[0] = 0;
801 6 avcodec_string(buf, sizeof(buf), avctx, is_output);
802 6 ptr = av_stristr(buf, " ");
803 }
804 6 avcodec_free_context(&avctx);
805
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (ptr)
806 6 av_log(NULL, AV_LOG_INFO, "%s", ptr);
807 6 dump_disposition(stg->disposition, AV_LOG_INFO);
808 6 av_log(NULL, AV_LOG_INFO, "\n");
809 6 dump_metadata(NULL, stg->metadata, " ", AV_LOG_INFO);
810 6 dump_sidedata(NULL, tile_grid->coded_side_data, tile_grid->nb_coded_side_data,
811 6 tile_grid->width, tile_grid->height, (AVRational) {0,1},
812 " ", AV_LOG_INFO);
813
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
22 for (int i = 0; i < tile_grid->nb_tiles; i++) {
814 16 const AVStream *st = NULL;
815
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (tile_grid->offsets[i].idx < stg->nb_streams)
816 16 st = stg->streams[tile_grid->offsets[i].idx];
817
3/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 2 times.
16 if (st && !printed[st->index]) {
818 14 dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE);
819 14 printed[st->index] = 1;
820 }
821 }
822
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 6 times.
20 for (int i = 0; i < stg->nb_streams; i++) {
823 14 const AVStream *st = stg->streams[i];
824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (!printed[st->index]) {
825 dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_INFO);
826 printed[st->index] = 1;
827 }
828 }
829 6 break;
830 }
831 case AV_STREAM_GROUP_PARAMS_LCEVC: {
832 const AVStreamGroupLCEVC *lcevc = stg->params.lcevc;
833 AVCodecContext *avctx = avcodec_alloc_context3(NULL);
834 const char *ptr = NULL;
835 av_log(NULL, AV_LOG_INFO, " LCEVC:");
836 if (avctx && stg->nb_streams && !avcodec_parameters_to_context(avctx, stg->streams[0]->codecpar)) {
837 avctx->width = lcevc->width;
838 avctx->height = lcevc->height;
839 avctx->coded_width = lcevc->width;
840 avctx->coded_height = lcevc->height;
841 if (ic->dump_separator)
842 av_opt_set(avctx, "dump_separator", ic->dump_separator, 0);
843 buf[0] = 0;
844 avcodec_string(buf, sizeof(buf), avctx, is_output);
845 ptr = av_stristr(buf, " ");
846 }
847 avcodec_free_context(&avctx);
848 if (ptr)
849 av_log(NULL, AV_LOG_INFO, "%s", ptr);
850 av_log(NULL, AV_LOG_INFO, "\n");
851 for (int i = 0; i < stg->nb_streams; i++) {
852 const AVStream *st = stg->streams[i];
853 dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE);
854 printed[st->index] = 1;
855 }
856 break;
857 }
858 default:
859 break;
860 }
861 85 }
862
863 15848 void av_dump_format(AVFormatContext *ic, int index,
864 const char *url, int is_output)
865 {
866 int i;
867
1/2
✓ Branch 0 taken 15848 times.
✗ Branch 1 not taken.
15848 uint8_t *printed = ic->nb_streams ? av_mallocz(ic->nb_streams) : NULL;
868
2/4
✓ Branch 0 taken 15848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15848 times.
15848 if (ic->nb_streams && !printed)
869 return;
870
871
6/6
✓ Branch 0 taken 8370 times.
✓ Branch 1 taken 7478 times.
✓ Branch 2 taken 8370 times.
✓ Branch 3 taken 7478 times.
✓ Branch 4 taken 8370 times.
✓ Branch 5 taken 7478 times.
31696 av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
872 is_output ? "Output" : "Input",
873 index,
874 15848 is_output ? ic->oformat->name : ic->iformat->name,
875 is_output ? "to" : "from", url);
876 15848 dump_metadata(NULL, ic->metadata, " ", AV_LOG_INFO);
877
878
2/2
✓ Branch 0 taken 7478 times.
✓ Branch 1 taken 8370 times.
15848 if (!is_output) {
879 7478 av_log(NULL, AV_LOG_INFO, " Duration: ");
880
2/2
✓ Branch 0 taken 6345 times.
✓ Branch 1 taken 1133 times.
7478 if (ic->duration != AV_NOPTS_VALUE) {
881 int64_t hours, mins, secs, us;
882
1/2
✓ Branch 0 taken 6345 times.
✗ Branch 1 not taken.
6345 int64_t duration = ic->duration + (ic->duration <= INT64_MAX - 5000 ? 5000 : 0);
883 6345 secs = duration / AV_TIME_BASE;
884 6345 us = duration % AV_TIME_BASE;
885 6345 mins = secs / 60;
886 6345 secs %= 60;
887 6345 hours = mins / 60;
888 6345 mins %= 60;
889 6345 av_log(NULL, AV_LOG_INFO, "%02"PRId64":%02"PRId64":%02"PRId64".%02"PRId64"", hours, mins, secs,
890 (100 * us) / AV_TIME_BASE);
891 } else {
892 1133 av_log(NULL, AV_LOG_INFO, "N/A");
893 }
894
2/2
✓ Branch 0 taken 5723 times.
✓ Branch 1 taken 1755 times.
7478 if (ic->start_time != AV_NOPTS_VALUE) {
895 int secs, us;
896 5723 av_log(NULL, AV_LOG_INFO, ", start: ");
897 5723 secs = llabs(ic->start_time / AV_TIME_BASE);
898 5723 us = llabs(ic->start_time % AV_TIME_BASE);
899 5723 av_log(NULL, AV_LOG_INFO, "%s%d.%06d",
900 5723 ic->start_time >= 0 ? "" : "-",
901 secs,
902
2/2
✓ Branch 0 taken 5712 times.
✓ Branch 1 taken 11 times.
5723 (int) av_rescale(us, 1000000, AV_TIME_BASE));
903 }
904 7478 av_log(NULL, AV_LOG_INFO, ", bitrate: ");
905
2/2
✓ Branch 0 taken 3274 times.
✓ Branch 1 taken 4204 times.
7478 if (ic->bit_rate)
906 3274 av_log(NULL, AV_LOG_INFO, "%"PRId64" kb/s", ic->bit_rate / 1000);
907 else
908 4204 av_log(NULL, AV_LOG_INFO, "N/A");
909 7478 av_log(NULL, AV_LOG_INFO, "\n");
910 }
911
912
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15804 times.
15848 if (ic->nb_chapters)
913 44 av_log(NULL, AV_LOG_INFO, " Chapters:\n");
914
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 15848 times.
15953 for (i = 0; i < ic->nb_chapters; i++) {
915 105 const AVChapter *ch = ic->chapters[i];
916 105 av_log(NULL, AV_LOG_INFO, " Chapter #%d:%d: ", index, i);
917 105 av_log(NULL, AV_LOG_INFO,
918 105 "start %f, ", ch->start * av_q2d(ch->time_base));
919 105 av_log(NULL, AV_LOG_INFO,
920 105 "end %f\n", ch->end * av_q2d(ch->time_base));
921
922 105 dump_metadata(NULL, ch->metadata, " ", AV_LOG_INFO);
923 }
924
925
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 15798 times.
15848 if (ic->nb_programs) {
926 50 int j, k, total = 0;
927
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 50 times.
100 for (j = 0; j < ic->nb_programs; j++) {
928 50 const AVProgram *program = ic->programs[j];
929 50 const AVDictionaryEntry *name = av_dict_get(program->metadata,
930 "name", NULL, 0);
931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 av_log(NULL, AV_LOG_INFO, " Program %d %s\n", program->id,
932 name ? name->value : "");
933 50 dump_metadata(NULL, program->metadata, " ", AV_LOG_INFO);
934
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 50 times.
152 for (k = 0; k < program->nb_stream_indexes; k++) {
935 102 dump_stream_format(ic, program->stream_index[k],
936 -1, index, is_output, AV_LOG_INFO);
937 102 printed[program->stream_index[k]] = 1;
938 }
939 50 total += program->nb_stream_indexes;
940 }
941
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 47 times.
50 if (total < ic->nb_streams)
942 3 av_log(NULL, AV_LOG_INFO, " No Program\n");
943 }
944
945
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 15848 times.
15933 for (i = 0; i < ic->nb_stream_groups; i++)
946 85 dump_stream_group(ic, printed, i, index, is_output);
947
948
2/2
✓ Branch 0 taken 17068 times.
✓ Branch 1 taken 15848 times.
32916 for (i = 0; i < ic->nb_streams; i++)
949
2/2
✓ Branch 0 taken 16767 times.
✓ Branch 1 taken 301 times.
17068 if (!printed[i])
950 16767 dump_stream_format(ic, i, -1, index, is_output, AV_LOG_INFO);
951
952 15848 av_free(printed);
953 }
954