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