FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/dump.c
Date: 2022-12-05 03:11:11
Exec Total Coverage
Lines: 280 450 62.2%
Functions: 14 23 60.9%
Branches: 170 287 59.2%

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/channel_layout.h"
26 #include "libavutil/display.h"
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/log.h"
29 #include "libavutil/mastering_display_metadata.h"
30 #include "libavutil/dovi_meta.h"
31 #include "libavutil/mathematics.h"
32 #include "libavutil/opt.h"
33 #include "libavutil/replaygain.h"
34 #include "libavutil/spherical.h"
35 #include "libavutil/stereo3d.h"
36 #include "libavutil/timecode.h"
37
38 #include "libavcodec/avcodec.h"
39
40 #include "avformat.h"
41 #include "internal.h"
42
43 #define HEXDUMP_PRINT(...) \
44 do { \
45 if (!f) \
46 av_log(avcl, level, __VA_ARGS__); \
47 else \
48 fprintf(f, __VA_ARGS__); \
49 } while (0)
50
51 1 static void hex_dump_internal(void *avcl, FILE *f, int level,
52 const uint8_t *buf, int size)
53 {
54 int len, i, j, c;
55
56
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (i = 0; i < size; i += 16) {
57 2 len = size - i;
58
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (len > 16)
59 1 len = 16;
60
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 HEXDUMP_PRINT("%08x ", i);
61
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 2 times.
34 for (j = 0; j < 16; j++) {
62
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
32 if (j < len)
63
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 HEXDUMP_PRINT(" %02x", buf[i + j]);
64 else
65
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 HEXDUMP_PRINT(" ");
66 }
67
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 HEXDUMP_PRINT(" ");
68
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2 times.
26 for (j = 0; j < len; j++) {
69 24 c = buf[i + j];
70
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 > '~')
71 15 c = '.';
72
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 HEXDUMP_PRINT("%c", c);
73 }
74
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 HEXDUMP_PRINT("\n");
75 }
76 1 }
77
78 void av_hex_dump(FILE *f, const uint8_t *buf, int size)
79 {
80 hex_dump_internal(NULL, f, 0, buf, size);
81 }
82
83 1 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
84 {
85 1 hex_dump_internal(avcl, NULL, level, buf, size);
86 1 }
87
88 static void pkt_dump_internal(void *avcl, FILE *f, int level, const AVPacket *pkt,
89 int dump_payload, AVRational time_base)
90 {
91 HEXDUMP_PRINT("stream #%d:\n", pkt->stream_index);
92 HEXDUMP_PRINT(" keyframe=%d\n", (pkt->flags & AV_PKT_FLAG_KEY) != 0);
93 HEXDUMP_PRINT(" duration=%0.3f\n", pkt->duration * av_q2d(time_base));
94 /* DTS is _always_ valid after av_read_frame() */
95 HEXDUMP_PRINT(" dts=");
96 if (pkt->dts == AV_NOPTS_VALUE)
97 HEXDUMP_PRINT("N/A");
98 else
99 HEXDUMP_PRINT("%0.3f", pkt->dts * av_q2d(time_base));
100 /* PTS may not be known if B-frames are present. */
101 HEXDUMP_PRINT(" pts=");
102 if (pkt->pts == AV_NOPTS_VALUE)
103 HEXDUMP_PRINT("N/A");
104 else
105 HEXDUMP_PRINT("%0.3f", pkt->pts * av_q2d(time_base));
106 HEXDUMP_PRINT("\n");
107 HEXDUMP_PRINT(" size=%d\n", pkt->size);
108 if (dump_payload)
109 hex_dump_internal(avcl, f, level, pkt->data, pkt->size);
110 }
111
112 void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st)
113 {
114 pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base);
115 }
116
117 void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload,
118 const AVStream *st)
119 {
120 pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base);
121 }
122
123
124 26026 static void print_fps(double d, const char *postfix)
125 {
126 26026 uint64_t v = lrintf(d * 100);
127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26026 times.
26026 if (!v)
128 av_log(NULL, AV_LOG_INFO, "%1.4f %s", d, postfix);
129
2/2
✓ Branch 0 taken 1969 times.
✓ Branch 1 taken 24057 times.
26026 else if (v % 100)
130 1969 av_log(NULL, AV_LOG_INFO, "%3.2f %s", d, postfix);
131
2/2
✓ Branch 0 taken 22691 times.
✓ Branch 1 taken 1366 times.
24057 else if (v % (100 * 1000))
132 22691 av_log(NULL, AV_LOG_INFO, "%1.0f %s", d, postfix);
133 else
134 1366 av_log(NULL, AV_LOG_INFO, "%1.0fk %s", d / 1000, postfix);
135 26026 }
136
137 27060 static void dump_metadata(void *ctx, const AVDictionary *m, const char *indent)
138 {
139
6/6
✓ Branch 0 taken 10386 times.
✓ Branch 1 taken 16674 times.
✓ Branch 3 taken 7739 times.
✓ Branch 4 taken 2647 times.
✓ Branch 6 taken 7381 times.
✓ Branch 7 taken 358 times.
27060 if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))) {
140 10028 const AVDictionaryEntry *tag = NULL;
141
142 10028 av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
143
2/2
✓ Branch 1 taken 18105 times.
✓ Branch 2 taken 10028 times.
28133 while ((tag = av_dict_iterate(m, tag)))
144
2/2
✓ Branch 0 taken 17136 times.
✓ Branch 1 taken 969 times.
18105 if (strcmp("language", tag->key)) {
145 17136 const char *p = tag->value;
146 17136 av_log(ctx, AV_LOG_INFO,
147 17136 "%s %-16s: ", indent, tag->key);
148
2/2
✓ Branch 0 taken 17656 times.
✓ Branch 1 taken 17136 times.
34792 while (*p) {
149 17656 size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
150
1/2
✓ Branch 0 taken 17656 times.
✗ Branch 1 not taken.
17656 av_log(ctx, AV_LOG_INFO, "%.*s", (int)(FFMIN(255, len)), p);
151 17656 p += len;
152
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 17376 times.
17656 if (*p == 0xd) av_log(ctx, AV_LOG_INFO, " ");
153
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 17297 times.
17656 if (*p == 0xa) av_log(ctx, AV_LOG_INFO, "\n%s %-16s: ", indent, "");
154
2/2
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 16995 times.
17656 if (*p) p++;
155 }
156 17136 av_log(ctx, AV_LOG_INFO, "\n");
157 }
158 }
159 27060 }
160
161 /* param change side data*/
162 static void dump_paramchange(void *ctx, const AVPacketSideData *sd)
163 {
164 int size = sd->size;
165 const uint8_t *data = sd->data;
166 uint32_t flags, sample_rate, width, height;
167 #if FF_API_OLD_CHANNEL_LAYOUT
168 uint32_t channels;
169 uint64_t layout;
170 #endif
171
172 if (!data || sd->size < 4)
173 goto fail;
174
175 flags = AV_RL32(data);
176 data += 4;
177 size -= 4;
178
179 #if FF_API_OLD_CHANNEL_LAYOUT
180 FF_DISABLE_DEPRECATION_WARNINGS
181 if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
182 if (size < 4)
183 goto fail;
184 channels = AV_RL32(data);
185 data += 4;
186 size -= 4;
187 av_log(ctx, AV_LOG_INFO, "channel count %"PRIu32", ", channels);
188 }
189 if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) {
190 if (size < 8)
191 goto fail;
192 layout = AV_RL64(data);
193 data += 8;
194 size -= 8;
195 av_log(ctx, AV_LOG_INFO,
196 "channel layout: %s, ", av_get_channel_name(layout));
197 }
198 FF_ENABLE_DEPRECATION_WARNINGS
199 #endif /* FF_API_OLD_CHANNEL_LAYOUT */
200 if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
201 if (size < 4)
202 goto fail;
203 sample_rate = AV_RL32(data);
204 data += 4;
205 size -= 4;
206 av_log(ctx, AV_LOG_INFO, "sample_rate %"PRIu32", ", sample_rate);
207 }
208 if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) {
209 if (size < 8)
210 goto fail;
211 width = AV_RL32(data);
212 data += 4;
213 size -= 4;
214 height = AV_RL32(data);
215 data += 4;
216 size -= 4;
217 av_log(ctx, AV_LOG_INFO, "width %"PRIu32" height %"PRIu32, width, height);
218 }
219
220 return;
221 fail:
222 av_log(ctx, AV_LOG_ERROR, "unknown param\n");
223 }
224
225 /* replaygain side data*/
226 static void print_gain(void *ctx, const char *str, int32_t gain)
227 {
228 av_log(ctx, AV_LOG_INFO, "%s - ", str);
229 if (gain == INT32_MIN)
230 av_log(ctx, AV_LOG_INFO, "unknown");
231 else
232 av_log(ctx, AV_LOG_INFO, "%f", gain / 100000.0f);
233 av_log(ctx, AV_LOG_INFO, ", ");
234 }
235
236 static void print_peak(void *ctx, const char *str, uint32_t peak)
237 {
238 av_log(ctx, AV_LOG_INFO, "%s - ", str);
239 if (!peak)
240 av_log(ctx, AV_LOG_INFO, "unknown");
241 else
242 av_log(ctx, AV_LOG_INFO, "%f", (float) peak / UINT32_MAX);
243 av_log(ctx, AV_LOG_INFO, ", ");
244 }
245
246 static void dump_replaygain(void *ctx, const AVPacketSideData *sd)
247 {
248 const AVReplayGain *rg;
249
250 if (sd->size < sizeof(*rg)) {
251 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
252 return;
253 }
254 rg = (const AVReplayGain *)sd->data;
255
256 print_gain(ctx, "track gain", rg->track_gain);
257 print_peak(ctx, "track peak", rg->track_peak);
258 print_gain(ctx, "album gain", rg->album_gain);
259 print_peak(ctx, "album peak", rg->album_peak);
260 }
261
262 450 static void dump_stereo3d(void *ctx, const AVPacketSideData *sd)
263 {
264 const AVStereo3D *stereo;
265
266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if (sd->size < sizeof(*stereo)) {
267 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
268 return;
269 }
270
271 450 stereo = (const AVStereo3D *)sd->data;
272
273 450 av_log(ctx, AV_LOG_INFO, "%s", av_stereo3d_type_name(stereo->type));
274
275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
276 av_log(ctx, AV_LOG_INFO, " (inverted)");
277 }
278
279 12 static void dump_audioservicetype(void *ctx, const AVPacketSideData *sd)
280 {
281 12 const enum AVAudioServiceType *ast = (const enum AVAudioServiceType *)sd->data;
282
283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 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 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) {
289 12 case AV_AUDIO_SERVICE_TYPE_MAIN:
290 12 av_log(ctx, AV_LOG_INFO, "main");
291 12 break;
292 case AV_AUDIO_SERVICE_TYPE_EFFECTS:
293 av_log(ctx, AV_LOG_INFO, "effects");
294 break;
295 case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:
296 av_log(ctx, AV_LOG_INFO, "visually impaired");
297 break;
298 case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:
299 av_log(ctx, AV_LOG_INFO, "hearing impaired");
300 break;
301 case AV_AUDIO_SERVICE_TYPE_DIALOGUE:
302 av_log(ctx, AV_LOG_INFO, "dialogue");
303 break;
304 case AV_AUDIO_SERVICE_TYPE_COMMENTARY:
305 av_log(ctx, AV_LOG_INFO, "commentary");
306 break;
307 case AV_AUDIO_SERVICE_TYPE_EMERGENCY:
308 av_log(ctx, AV_LOG_INFO, "emergency");
309 break;
310 case AV_AUDIO_SERVICE_TYPE_VOICE_OVER:
311 av_log(ctx, AV_LOG_INFO, "voice over");
312 break;
313 case AV_AUDIO_SERVICE_TYPE_KARAOKE:
314 av_log(ctx, AV_LOG_INFO, "karaoke");
315 break;
316 default:
317 av_log(ctx, AV_LOG_WARNING, "unknown");
318 break;
319 }
320 }
321
322 297 static void dump_cpb(void *ctx, const AVPacketSideData *sd)
323 {
324 297 const AVCPBProperties *cpb = (const AVCPBProperties *)sd->data;
325
326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if (sd->size < sizeof(*cpb)) {
327 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
328 return;
329 }
330
331 297 av_log(ctx, AV_LOG_INFO,
332 "bitrate max/min/avg: %"PRId64"/%"PRId64"/%"PRId64" buffer size: %"PRId64" ",
333 297 cpb->max_bitrate, cpb->min_bitrate, cpb->avg_bitrate,
334 297 cpb->buffer_size);
335
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 if (cpb->vbv_delay == UINT64_MAX)
336 297 av_log(ctx, AV_LOG_INFO, "vbv_delay: N/A");
337 else
338 av_log(ctx, AV_LOG_INFO, "vbv_delay: %"PRIu64"", cpb->vbv_delay);
339 }
340
341 15 static void dump_mastering_display_metadata(void *ctx, const AVPacketSideData *sd)
342 {
343 15 const AVMasteringDisplayMetadata *metadata =
344 (const AVMasteringDisplayMetadata *)sd->data;
345 15 av_log(ctx, AV_LOG_INFO, "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 15 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 15 }
359
360 12 static void dump_content_light_metadata(void *ctx, const AVPacketSideData *sd)
361 {
362 12 const AVContentLightMetadata *metadata =
363 (const AVContentLightMetadata *)sd->data;
364 12 av_log(ctx, AV_LOG_INFO, "Content Light Level Metadata, "
365 "MaxCLL=%d, MaxFALL=%d",
366 12 metadata->MaxCLL, metadata->MaxFALL);
367 12 }
368
369 11 static void dump_spherical(void *ctx, const AVCodecParameters *par,
370 const AVPacketSideData *sd)
371 {
372 11 const AVSphericalMapping *spherical = (const AVSphericalMapping *)sd->data;
373 double yaw, pitch, roll;
374
375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (sd->size < sizeof(*spherical)) {
376 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
377 return;
378 }
379
380 11 av_log(ctx, AV_LOG_INFO, "%s ", av_spherical_projection_name(spherical->projection));
381
382 11 yaw = ((double)spherical->yaw) / (1 << 16);
383 11 pitch = ((double)spherical->pitch) / (1 << 16);
384 11 roll = ((double)spherical->roll) / (1 << 16);
385 11 av_log(ctx, AV_LOG_INFO, "(%f/%f/%f) ", yaw, pitch, roll);
386
387
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
388 size_t l, t, r, b;
389 11 av_spherical_tile_bounds(spherical, par->width, par->height,
390 &l, &t, &r, &b);
391 11 av_log(ctx, AV_LOG_INFO,
392 "[%"SIZE_SPECIFIER", %"SIZE_SPECIFIER", %"SIZE_SPECIFIER", %"SIZE_SPECIFIER"] ",
393 l, t, r, b);
394 } else if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
395 av_log(ctx, AV_LOG_INFO, "[pad %"PRIu32"] ", spherical->padding);
396 }
397 }
398
399 11 static void dump_dovi_conf(void *ctx, const AVPacketSideData *sd)
400 {
401 11 const AVDOVIDecoderConfigurationRecord *dovi =
402 (const AVDOVIDecoderConfigurationRecord *)sd->data;
403
404 11 av_log(ctx, AV_LOG_INFO, "version: %d.%d, profile: %d, level: %d, "
405 "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d",
406 11 dovi->dv_version_major, dovi->dv_version_minor,
407 11 dovi->dv_profile, dovi->dv_level,
408 11 dovi->rpu_present_flag,
409 11 dovi->el_present_flag,
410 11 dovi->bl_present_flag,
411 11 dovi->dv_bl_signal_compatibility_id);
412 11 }
413
414 static void dump_s12m_timecode(void *ctx, const AVStream *st, const AVPacketSideData *sd)
415 {
416 const uint32_t *tc = (const uint32_t *)sd->data;
417
418 if ((sd->size != sizeof(uint32_t) * 4) || (tc[0] > 3)) {
419 av_log(ctx, AV_LOG_ERROR, "invalid data\n");
420 return;
421 }
422
423 for (int j = 1; j <= tc[0]; j++) {
424 char tcbuf[AV_TIMECODE_STR_SIZE];
425 av_timecode_make_smpte_tc_string2(tcbuf, st->avg_frame_rate, tc[j], 0, 0);
426 av_log(ctx, AV_LOG_INFO, "timecode - %s%s", tcbuf, j != tc[0] ? ", " : "");
427 }
428 }
429
430 13849 static void dump_sidedata(void *ctx, const AVStream *st, const char *indent)
431 {
432 int i;
433
434
2/2
✓ Branch 0 taken 794 times.
✓ Branch 1 taken 13055 times.
13849 if (st->nb_side_data)
435 794 av_log(ctx, AV_LOG_INFO, "%sSide data:\n", indent);
436
437
2/2
✓ Branch 0 taken 821 times.
✓ Branch 1 taken 13849 times.
14670 for (i = 0; i < st->nb_side_data; i++) {
438 821 const AVPacketSideData *sd = &st->side_data[i];
439 821 av_log(ctx, AV_LOG_INFO, "%s ", indent);
440
441
9/17
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 450 times.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 297 times.
✓ Branch 10 taken 15 times.
✓ Branch 11 taken 11 times.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 4 times.
821 switch (sd->type) {
442 case AV_PKT_DATA_PALETTE:
443 av_log(ctx, AV_LOG_INFO, "palette");
444 break;
445 case AV_PKT_DATA_NEW_EXTRADATA:
446 av_log(ctx, AV_LOG_INFO, "new extradata");
447 break;
448 case AV_PKT_DATA_PARAM_CHANGE:
449 av_log(ctx, AV_LOG_INFO, "paramchange: ");
450 dump_paramchange(ctx, sd);
451 break;
452 case AV_PKT_DATA_H263_MB_INFO:
453 av_log(ctx, AV_LOG_INFO, "H.263 macroblock info");
454 break;
455 case AV_PKT_DATA_REPLAYGAIN:
456 av_log(ctx, AV_LOG_INFO, "replaygain: ");
457 dump_replaygain(ctx, sd);
458 break;
459 9 case AV_PKT_DATA_DISPLAYMATRIX:
460 9 av_log(ctx, AV_LOG_INFO, "displaymatrix: rotation of %.2f degrees",
461 9 av_display_rotation_get((const int32_t *)sd->data));
462 9 break;
463 450 case AV_PKT_DATA_STEREO3D:
464 450 av_log(ctx, AV_LOG_INFO, "stereo3d: ");
465 450 dump_stereo3d(ctx, sd);
466 450 break;
467 12 case AV_PKT_DATA_AUDIO_SERVICE_TYPE:
468 12 av_log(ctx, AV_LOG_INFO, "audio service type: ");
469 12 dump_audioservicetype(ctx, sd);
470 12 break;
471 case AV_PKT_DATA_QUALITY_STATS:
472 av_log(ctx, AV_LOG_INFO, "quality factor: %"PRId32", pict_type: %c",
473 AV_RL32(sd->data), av_get_picture_type_char(sd->data[4]));
474 break;
475 297 case AV_PKT_DATA_CPB_PROPERTIES:
476 297 av_log(ctx, AV_LOG_INFO, "cpb: ");
477 297 dump_cpb(ctx, sd);
478 297 break;
479 15 case AV_PKT_DATA_MASTERING_DISPLAY_METADATA:
480 15 dump_mastering_display_metadata(ctx, sd);
481 15 break;
482 11 case AV_PKT_DATA_SPHERICAL:
483 11 av_log(ctx, AV_LOG_INFO, "spherical: ");
484 11 dump_spherical(ctx, st->codecpar, sd);
485 11 break;
486 12 case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:
487 12 dump_content_light_metadata(ctx, sd);
488 12 break;
489 case AV_PKT_DATA_ICC_PROFILE:
490 av_log(ctx, AV_LOG_INFO, "ICC Profile");
491 break;
492 11 case AV_PKT_DATA_DOVI_CONF:
493 11 av_log(ctx, AV_LOG_INFO, "DOVI configuration record: ");
494 11 dump_dovi_conf(ctx, sd);
495 11 break;
496 case AV_PKT_DATA_S12M_TIMECODE:
497 av_log(ctx, AV_LOG_INFO, "SMPTE ST 12-1:2014: ");
498 dump_s12m_timecode(ctx, st, sd);
499 break;
500 4 default:
501 4 av_log(ctx, AV_LOG_INFO, "unknown side data type %d "
502 4 "(%"SIZE_SPECIFIER" bytes)", sd->type, sd->size);
503 4 break;
504 }
505
506 821 av_log(ctx, AV_LOG_INFO, "\n");
507 }
508 13849 }
509
510 /* "user interface" functions */
511 13849 static void dump_stream_format(const AVFormatContext *ic, int i,
512 int index, int is_output)
513 {
514 char buf[256];
515
2/2
✓ Branch 0 taken 6702 times.
✓ Branch 1 taken 7147 times.
13849 int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
516 13849 const AVStream *st = ic->streams[i];
517 13849 const FFStream *const sti = cffstream(st);
518 13849 const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
519 13849 const char *separator = ic->dump_separator;
520 AVCodecContext *avctx;
521 int ret;
522
523 13849 avctx = avcodec_alloc_context3(NULL);
524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13849 times.
13849 if (!avctx)
525 return;
526
527 13849 ret = avcodec_parameters_to_context(avctx, st->codecpar);
528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13849 times.
13849 if (ret < 0) {
529 avcodec_free_context(&avctx);
530 return;
531 }
532
533 // Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext
534 13849 avctx->properties = sti->avctx->properties;
535 13849 avctx->codec = sti->avctx->codec;
536 13849 avctx->qmin = sti->avctx->qmin;
537 13849 avctx->qmax = sti->avctx->qmax;
538 13849 avctx->coded_width = sti->avctx->coded_width;
539 13849 avctx->coded_height = sti->avctx->coded_height;
540
541
1/2
✓ Branch 0 taken 13849 times.
✗ Branch 1 not taken.
13849 if (separator)
542 13849 av_opt_set(avctx, "dump_separator", separator, 0);
543 13849 avcodec_string(buf, sizeof(buf), avctx, is_output);
544 13849 avcodec_free_context(&avctx);
545
546 13849 av_log(NULL, AV_LOG_INFO, " Stream #%d:%d", index, i);
547
548 /* the pid is an important information, so we display it */
549 /* XXX: add a generic system */
550
2/2
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 13195 times.
13849 if (flags & AVFMT_SHOW_IDS)
551 654 av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
552
2/2
✓ Branch 0 taken 1327 times.
✓ Branch 1 taken 12522 times.
13849 if (lang)
553 1327 av_log(NULL, AV_LOG_INFO, "(%s)", lang->value);
554 13849 av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", sti->codec_info_nb_frames,
555 13849 st->time_base.num, st->time_base.den);
556 13849 av_log(NULL, AV_LOG_INFO, ": %s", buf);
557
558
4/4
✓ Branch 0 taken 1285 times.
✓ Branch 1 taken 12564 times.
✓ Branch 2 taken 345 times.
✓ Branch 3 taken 940 times.
15134 if (st->sample_aspect_ratio.num &&
559 1285 av_cmp_q(st->sample_aspect_ratio, st->codecpar->sample_aspect_ratio)) {
560 AVRational display_aspect_ratio;
561 345 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
562 345 st->codecpar->width * (int64_t)st->sample_aspect_ratio.num,
563 345 st->codecpar->height * (int64_t)st->sample_aspect_ratio.den,
564 1024 * 1024);
565 345 av_log(NULL, AV_LOG_INFO, ", SAR %d:%d DAR %d:%d",
566 345 st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
567 display_aspect_ratio.num, display_aspect_ratio.den);
568 }
569
570
2/2
✓ Branch 0 taken 10607 times.
✓ Branch 1 taken 3242 times.
13849 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
571
3/4
✓ Branch 0 taken 9820 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 9820 times.
✗ Branch 3 not taken.
10607 int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
572
3/4
✓ Branch 0 taken 5599 times.
✓ Branch 1 taken 5008 times.
✓ Branch 2 taken 5599 times.
✗ Branch 3 not taken.
10607 int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
573
2/4
✓ Branch 0 taken 10607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10607 times.
✗ Branch 3 not taken.
10607 int tbn = st->time_base.den && st->time_base.num;
574
575
5/6
✓ Branch 0 taken 787 times.
✓ Branch 1 taken 9820 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 782 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10607 if (fps || tbr || tbn)
576 10607 av_log(NULL, AV_LOG_INFO, "%s", separator);
577
578
2/2
✓ Branch 0 taken 9820 times.
✓ Branch 1 taken 787 times.
10607 if (fps)
579
3/4
✓ Branch 0 taken 5003 times.
✓ Branch 1 taken 4817 times.
✓ Branch 2 taken 5003 times.
✗ Branch 3 not taken.
9820 print_fps(av_q2d(st->avg_frame_rate), tbr || tbn ? "fps, " : "fps");
580
2/2
✓ Branch 0 taken 5599 times.
✓ Branch 1 taken 5008 times.
10607 if (tbr)
581
1/2
✓ Branch 0 taken 5599 times.
✗ Branch 1 not taken.
5599 print_fps(av_q2d(st->r_frame_rate), tbn ? "tbr, " : "tbr");
582
1/2
✓ Branch 0 taken 10607 times.
✗ Branch 1 not taken.
10607 if (tbn)
583 10607 print_fps(1 / av_q2d(st->time_base), "tbn");
584 }
585
586
2/2
✓ Branch 0 taken 1546 times.
✓ Branch 1 taken 12303 times.
13849 if (st->disposition & AV_DISPOSITION_DEFAULT)
587 1546 av_log(NULL, AV_LOG_INFO, " (default)");
588
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 13845 times.
13849 if (st->disposition & AV_DISPOSITION_DUB)
589 4 av_log(NULL, AV_LOG_INFO, " (dub)");
590
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 13845 times.
13849 if (st->disposition & AV_DISPOSITION_ORIGINAL)
591 4 av_log(NULL, AV_LOG_INFO, " (original)");
592
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13848 times.
13849 if (st->disposition & AV_DISPOSITION_COMMENT)
593 1 av_log(NULL, AV_LOG_INFO, " (comment)");
594
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13848 times.
13849 if (st->disposition & AV_DISPOSITION_LYRICS)
595 1 av_log(NULL, AV_LOG_INFO, " (lyrics)");
596
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13848 times.
13849 if (st->disposition & AV_DISPOSITION_KARAOKE)
597 1 av_log(NULL, AV_LOG_INFO, " (karaoke)");
598
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13842 times.
13849 if (st->disposition & AV_DISPOSITION_FORCED)
599 7 av_log(NULL, AV_LOG_INFO, " (forced)");
600
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13827 times.
13849 if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
601 22 av_log(NULL, AV_LOG_INFO, " (hearing impaired)");
602
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13836 times.
13849 if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
603 13 av_log(NULL, AV_LOG_INFO, " (visual impaired)");
604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13849 times.
13849 if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
605 av_log(NULL, AV_LOG_INFO, " (clean effects)");
606
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 13753 times.
13849 if (st->disposition & AV_DISPOSITION_ATTACHED_PIC)
607 96 av_log(NULL, AV_LOG_INFO, " (attached pic)");
608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13849 times.
13849 if (st->disposition & AV_DISPOSITION_TIMED_THUMBNAILS)
609 av_log(NULL, AV_LOG_INFO, " (timed thumbnails)");
610
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 13843 times.
13849 if (st->disposition & AV_DISPOSITION_CAPTIONS)
611 6 av_log(NULL, AV_LOG_INFO, " (captions)");
612
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13834 times.
13849 if (st->disposition & AV_DISPOSITION_DESCRIPTIONS)
613 15 av_log(NULL, AV_LOG_INFO, " (descriptions)");
614
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 13845 times.
13849 if (st->disposition & AV_DISPOSITION_METADATA)
615 4 av_log(NULL, AV_LOG_INFO, " (metadata)");
616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13849 times.
13849 if (st->disposition & AV_DISPOSITION_DEPENDENT)
617 av_log(NULL, AV_LOG_INFO, " (dependent)");
618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13849 times.
13849 if (st->disposition & AV_DISPOSITION_STILL_IMAGE)
619 av_log(NULL, AV_LOG_INFO, " (still image)");
620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13849 times.
13849 if (st->disposition & AV_DISPOSITION_NON_DIEGETIC)
621 av_log(NULL, AV_LOG_INFO, " (non-diegetic)");
622 13849 av_log(NULL, AV_LOG_INFO, "\n");
623
624 13849 dump_metadata(NULL, st->metadata, " ");
625
626 13849 dump_sidedata(NULL, st, " ");
627 }
628
629 13071 void av_dump_format(AVFormatContext *ic, int index,
630 const char *url, int is_output)
631 {
632 int i;
633
1/2
✓ Branch 0 taken 13071 times.
✗ Branch 1 not taken.
13071 uint8_t *printed = ic->nb_streams ? av_mallocz(ic->nb_streams) : NULL;
634
2/4
✓ Branch 0 taken 13071 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13071 times.
13071 if (ic->nb_streams && !printed)
635 return;
636
637
6/6
✓ Branch 0 taken 6457 times.
✓ Branch 1 taken 6614 times.
✓ Branch 2 taken 6457 times.
✓ Branch 3 taken 6614 times.
✓ Branch 4 taken 6457 times.
✓ Branch 5 taken 6614 times.
26142 av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
638 is_output ? "Output" : "Input",
639 index,
640 13071 is_output ? ic->oformat->name : ic->iformat->name,
641 is_output ? "to" : "from", url);
642 13071 dump_metadata(NULL, ic->metadata, " ");
643
644
2/2
✓ Branch 0 taken 6614 times.
✓ Branch 1 taken 6457 times.
13071 if (!is_output) {
645 6614 av_log(NULL, AV_LOG_INFO, " Duration: ");
646
2/2
✓ Branch 0 taken 5630 times.
✓ Branch 1 taken 984 times.
6614 if (ic->duration != AV_NOPTS_VALUE) {
647 int64_t hours, mins, secs, us;
648
1/2
✓ Branch 0 taken 5630 times.
✗ Branch 1 not taken.
5630 int64_t duration = ic->duration + (ic->duration <= INT64_MAX - 5000 ? 5000 : 0);
649 5630 secs = duration / AV_TIME_BASE;
650 5630 us = duration % AV_TIME_BASE;
651 5630 mins = secs / 60;
652 5630 secs %= 60;
653 5630 hours = mins / 60;
654 5630 mins %= 60;
655 5630 av_log(NULL, AV_LOG_INFO, "%02"PRId64":%02"PRId64":%02"PRId64".%02"PRId64"", hours, mins, secs,
656 (100 * us) / AV_TIME_BASE);
657 } else {
658 984 av_log(NULL, AV_LOG_INFO, "N/A");
659 }
660
2/2
✓ Branch 0 taken 5037 times.
✓ Branch 1 taken 1577 times.
6614 if (ic->start_time != AV_NOPTS_VALUE) {
661 int secs, us;
662 5037 av_log(NULL, AV_LOG_INFO, ", start: ");
663 5037 secs = llabs(ic->start_time / AV_TIME_BASE);
664 5037 us = llabs(ic->start_time % AV_TIME_BASE);
665 5037 av_log(NULL, AV_LOG_INFO, "%s%d.%06d",
666 5037 ic->start_time >= 0 ? "" : "-",
667 secs,
668
2/2
✓ Branch 0 taken 5026 times.
✓ Branch 1 taken 11 times.
5037 (int) av_rescale(us, 1000000, AV_TIME_BASE));
669 }
670 6614 av_log(NULL, AV_LOG_INFO, ", bitrate: ");
671
2/2
✓ Branch 0 taken 3051 times.
✓ Branch 1 taken 3563 times.
6614 if (ic->bit_rate)
672 3051 av_log(NULL, AV_LOG_INFO, "%"PRId64" kb/s", ic->bit_rate / 1000);
673 else
674 3563 av_log(NULL, AV_LOG_INFO, "N/A");
675 6614 av_log(NULL, AV_LOG_INFO, "\n");
676 }
677
678
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 13031 times.
13071 if (ic->nb_chapters)
679 40 av_log(NULL, AV_LOG_INFO, " Chapters:\n");
680
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 13071 times.
13168 for (i = 0; i < ic->nb_chapters; i++) {
681 97 const AVChapter *ch = ic->chapters[i];
682 97 av_log(NULL, AV_LOG_INFO, " Chapter #%d:%d: ", index, i);
683 97 av_log(NULL, AV_LOG_INFO,
684 97 "start %f, ", ch->start * av_q2d(ch->time_base));
685 97 av_log(NULL, AV_LOG_INFO,
686 97 "end %f\n", ch->end * av_q2d(ch->time_base));
687
688 97 dump_metadata(NULL, ch->metadata, " ");
689 }
690
691
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 13028 times.
13071 if (ic->nb_programs) {
692 43 int j, k, total = 0;
693
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 43 times.
86 for (j = 0; j < ic->nb_programs; j++) {
694 43 const AVProgram *program = ic->programs[j];
695 43 const AVDictionaryEntry *name = av_dict_get(program->metadata,
696 "name", NULL, 0);
697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 av_log(NULL, AV_LOG_INFO, " Program %d %s\n", program->id,
698 name ? name->value : "");
699 43 dump_metadata(NULL, program->metadata, " ");
700
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 43 times.
129 for (k = 0; k < program->nb_stream_indexes; k++) {
701 86 dump_stream_format(ic, program->stream_index[k],
702 index, is_output);
703 86 printed[program->stream_index[k]] = 1;
704 }
705 43 total += program->nb_stream_indexes;
706 }
707
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 40 times.
43 if (total < ic->nb_streams)
708 3 av_log(NULL, AV_LOG_INFO, " No Program\n");
709 }
710
711
2/2
✓ Branch 0 taken 13849 times.
✓ Branch 1 taken 13071 times.
26920 for (i = 0; i < ic->nb_streams; i++)
712
2/2
✓ Branch 0 taken 13763 times.
✓ Branch 1 taken 86 times.
13849 if (!printed[i])
713 13763 dump_stream_format(ic, i, index, is_output);
714
715 13071 av_free(printed);
716 }
717