FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffprobe.c
Date: 2026-11-02 00:22:16
Exec Total Coverage
Lines: 1540 2143 71.9%
Functions: 73 97 75.3%
Branches: 840 1378 61.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2007-2010 Stefano Sabatini
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * simple media prober based on the FFmpeg libraries
24 */
25
26 #include "config.h"
27 #include "libavutil/ffversion.h"
28
29 #include <string.h>
30 #include <math.h>
31
32 #include "libavformat/avformat.h"
33 #include "libavformat/version.h"
34 #include "libavcodec/avcodec.h"
35 #include "libavcodec/version.h"
36 #include "libavutil/ambient_viewing_environment.h"
37 #include "libavutil/avassert.h"
38 #include "libavutil/avstring.h"
39 #include "libavutil/avutil.h"
40 #include "libavutil/bprint.h"
41 #include "libavutil/channel_layout.h"
42 #include "libavutil/downmix_info.h"
43 #include "libavutil/display.h"
44 #include "libavutil/film_grain_params.h"
45 #include "libavutil/gain_map.h"
46 #include "libavutil/hdr_dynamic_metadata.h"
47 #include "libavutil/iamf.h"
48 #include "libavutil/mastering_display_metadata.h"
49 #include "libavutil/hdr_dynamic_vivid_metadata.h"
50 #include "libavutil/dovi_meta.h"
51 #include "libavutil/mem.h"
52 #include "libavutil/opt.h"
53 #include "libavutil/pixdesc.h"
54 #include "libavutil/spherical.h"
55 #include "libavutil/stereo3d.h"
56 #include "libavutil/dict.h"
57 #include "libavutil/intreadwrite.h"
58 #include "libavutil/mathematics.h"
59 #include "libavutil/parseutils.h"
60 #include "libavutil/timecode.h"
61 #include "libavutil/timestamp.h"
62 #include "libavdevice/avdevice.h"
63 #include "libavdevice/version.h"
64 #include "libswscale/swscale.h"
65 #include "libswscale/version.h"
66 #include "libswresample/swresample.h"
67 #include "libswresample/version.h"
68 #include "libavfilter/version.h"
69 #include "textformat/avtextformat.h"
70 #include "cmdutils.h"
71 #include "opt_common.h"
72
73 #include "libavutil/thread.h"
74
75 // attached as opaque_ref to packets/frames
76 typedef struct FrameData {
77 int64_t pkt_pos;
78 int pkt_size;
79 } FrameData;
80
81 typedef struct InputStream {
82 AVStream *st;
83
84 AVCodecContext *dec_ctx;
85 } InputStream;
86
87 typedef struct InputFile {
88 AVFormatContext *fmt_ctx;
89
90 InputStream *streams;
91 int nb_streams;
92 } InputFile;
93
94 const char program_name[] = "ffprobe";
95 const int program_birth_year = 2007;
96
97 static int do_analyze_frames = 0;
98 static int do_bitexact = 0;
99 static int do_count_frames = 0;
100 static int do_count_packets = 0;
101 static int do_read_frames = 0;
102 static int do_read_packets = 0;
103 static int do_show_chapters = 0;
104 static int do_show_error = 0;
105 static int do_show_format = 0;
106 static int do_show_frames = 0;
107 static int do_show_packets = 0;
108 static int do_show_programs = 0;
109 static int do_show_stream_groups = 0;
110 static int do_show_stream_group_components = 0;
111 static int do_show_streams = 0;
112 static int do_show_stream_disposition = 0;
113 static int do_show_stream_group_disposition = 0;
114 static int do_show_data = 0;
115 static int do_show_program_version = 0;
116 static int do_show_library_versions = 0;
117 static int do_show_pixel_formats = 0;
118 static int do_show_pixel_format_flags = 0;
119 static int do_show_pixel_format_components = 0;
120 static int do_show_log = 0;
121
122 static int do_show_chapter_tags = 0;
123 static int do_show_format_tags = 0;
124 static int do_show_frame_tags = 0;
125 static int do_show_program_tags = 0;
126 static int do_show_stream_group_tags = 0;
127 static int do_show_stream_tags = 0;
128 static int do_show_packet_tags = 0;
129
130 static int show_value_unit = 0;
131 static int use_value_prefix = 0;
132 static int use_byte_value_binary_prefix = 0;
133 static int use_value_sexagesimal_format = 0;
134 static int show_private_data = 1;
135
136 static const char *audio_codec_name = NULL;
137 static const char *data_codec_name = NULL;
138 static const char *subtitle_codec_name = NULL;
139 static const char *video_codec_name = NULL;
140
141 #define SHOW_OPTIONAL_FIELDS_AUTO -1
142 #define SHOW_OPTIONAL_FIELDS_NEVER 0
143 #define SHOW_OPTIONAL_FIELDS_ALWAYS 1
144 static int show_optional_fields = SHOW_OPTIONAL_FIELDS_AUTO;
145
146 static char *output_format;
147 static char *stream_specifier;
148 static char *show_data_hash;
149 static char *data_dump_format;
150
151 typedef struct ReadInterval {
152 int id; ///< identifier
153 int64_t start, end; ///< start, end in second/AV_TIME_BASE units
154 int has_start, has_end;
155 int start_is_offset, end_is_offset;
156 int duration_frames;
157 } ReadInterval;
158
159 static ReadInterval *read_intervals;
160 static int read_intervals_nb = 0;
161
162 static int find_stream_info = 1;
163
164 /* section structure definition */
165
166 typedef enum {
167 SECTION_ID_CHAPTER,
168 SECTION_ID_CHAPTER_TAGS,
169 SECTION_ID_CHAPTERS,
170 SECTION_ID_ERROR,
171 SECTION_ID_FORMAT,
172 SECTION_ID_FORMAT_TAGS,
173 SECTION_ID_FRAME,
174 SECTION_ID_FRAMES,
175 SECTION_ID_FRAME_TAGS,
176 SECTION_ID_FRAME_SIDE_DATA_LIST,
177 SECTION_ID_FRAME_SIDE_DATA,
178 SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST,
179 SECTION_ID_FRAME_SIDE_DATA_TIMECODE,
180 SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST,
181 SECTION_ID_FRAME_SIDE_DATA_COMPONENT,
182 SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST,
183 SECTION_ID_FRAME_SIDE_DATA_PIECE,
184 SECTION_ID_FRAME_LOG,
185 SECTION_ID_FRAME_LOGS,
186 SECTION_ID_LIBRARY_VERSION,
187 SECTION_ID_LIBRARY_VERSIONS,
188 SECTION_ID_PACKET,
189 SECTION_ID_PACKET_TAGS,
190 SECTION_ID_PACKETS,
191 SECTION_ID_PACKETS_AND_FRAMES,
192 SECTION_ID_PACKET_SIDE_DATA_LIST,
193 SECTION_ID_PACKET_SIDE_DATA,
194 SECTION_ID_PACKET_SIDE_DATA_COMPONENT_LIST,
195 SECTION_ID_PACKET_SIDE_DATA_COMPONENT,
196 SECTION_ID_PIXEL_FORMAT,
197 SECTION_ID_PIXEL_FORMAT_FLAGS,
198 SECTION_ID_PIXEL_FORMAT_COMPONENT,
199 SECTION_ID_PIXEL_FORMAT_COMPONENTS,
200 SECTION_ID_PIXEL_FORMATS,
201 SECTION_ID_PROGRAM_STREAM_DISPOSITION,
202 SECTION_ID_PROGRAM_STREAM_TAGS,
203 SECTION_ID_PROGRAM_STREAM_SIDE_DATA_LIST,
204 SECTION_ID_PROGRAM_STREAM_SIDE_DATA,
205 SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT_LIST,
206 SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT,
207 SECTION_ID_PROGRAM,
208 SECTION_ID_PROGRAM_STREAMS,
209 SECTION_ID_PROGRAM_STREAM,
210 SECTION_ID_PROGRAM_TAGS,
211 SECTION_ID_PROGRAM_VERSION,
212 SECTION_ID_PROGRAMS,
213 SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION,
214 SECTION_ID_STREAM_GROUP_STREAM_TAGS,
215 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_LIST,
216 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA,
217 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT_LIST,
218 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT,
219 SECTION_ID_STREAM_GROUP_STREAM_GROUP_DISPOSITION,
220 SECTION_ID_STREAM_GROUP_STREAM_GROUP_TAGS,
221 SECTION_ID_STREAM_GROUP,
222 SECTION_ID_STREAM_GROUP_COMPONENTS,
223 SECTION_ID_STREAM_GROUP_COMPONENT,
224 SECTION_ID_STREAM_GROUP_SUBCOMPONENTS,
225 SECTION_ID_STREAM_GROUP_SUBCOMPONENT,
226 SECTION_ID_STREAM_GROUP_PIECES,
227 SECTION_ID_STREAM_GROUP_PIECE,
228 SECTION_ID_STREAM_GROUP_SUBPIECES,
229 SECTION_ID_STREAM_GROUP_SUBPIECE,
230 SECTION_ID_STREAM_GROUP_BLOCKS,
231 SECTION_ID_STREAM_GROUP_BLOCK,
232 SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST,
233 SECTION_ID_STREAM_GROUP_SIDE_DATA,
234 SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT_LIST,
235 SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT,
236 SECTION_ID_STREAM_GROUP_STREAMS,
237 SECTION_ID_STREAM_GROUP_STREAM,
238 SECTION_ID_STREAM_GROUP_STREAM_GROUPS,
239 SECTION_ID_STREAM_GROUP_STREAM_GROUP,
240 SECTION_ID_STREAM_GROUP_DISPOSITION,
241 SECTION_ID_STREAM_GROUP_TAGS,
242 SECTION_ID_STREAM_GROUPS,
243 SECTION_ID_ROOT,
244 SECTION_ID_STREAM,
245 SECTION_ID_STREAM_DISPOSITION,
246 SECTION_ID_STREAMS,
247 SECTION_ID_STREAM_TAGS,
248 SECTION_ID_STREAM_SIDE_DATA_LIST,
249 SECTION_ID_STREAM_SIDE_DATA,
250 SECTION_ID_STREAM_SIDE_DATA_COMPONENT_LIST,
251 SECTION_ID_STREAM_SIDE_DATA_COMPONENT,
252 SECTION_ID_SUBTITLE,
253 } SectionID;
254
255 921 static const char *get_packet_side_data_type(const void *data)
256 {
257 921 const AVPacketSideData *sd = (const AVPacketSideData *)data;
258 921 return av_x_if_null(av_packet_side_data_name(sd->type), "unknown");
259 }
260
261 157 static const char *get_frame_side_data_type(const void *data)
262 {
263 157 const AVFrameSideData *sd = (const AVFrameSideData *)data;
264 157 return av_x_if_null(av_frame_side_data_name(sd->type), "unknown");
265 }
266
267 30 static const char *get_raw_string_type(const void *data)
268 {
269 30 return data;
270 }
271
272 4 static const char *get_stream_group_type(const void *data)
273 {
274 4 const AVStreamGroup *stg = (const AVStreamGroup *)data;
275 4 return av_x_if_null(avformat_stream_group_name(stg->type), "unknown");
276 }
277
278 static const AVTextFormatSection sections[] = {
279 [SECTION_ID_CHAPTERS] = { SECTION_ID_CHAPTERS, "chapters", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_CHAPTER, -1 } },
280 [SECTION_ID_CHAPTER] = { SECTION_ID_CHAPTER, "chapter", 0, { SECTION_ID_CHAPTER_TAGS, -1 } },
281 [SECTION_ID_CHAPTER_TAGS] = { SECTION_ID_CHAPTER_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "chapter_tags" },
282 [SECTION_ID_ERROR] = { SECTION_ID_ERROR, "error", 0, { -1 } },
283 [SECTION_ID_FORMAT] = { SECTION_ID_FORMAT, "format", 0, { SECTION_ID_FORMAT_TAGS, -1 } },
284 [SECTION_ID_FORMAT_TAGS] = { SECTION_ID_FORMAT_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "format_tags" },
285 [SECTION_ID_FRAMES] = { SECTION_ID_FRAMES, "frames", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME, SECTION_ID_SUBTITLE, -1 } },
286 [SECTION_ID_FRAME] = { SECTION_ID_FRAME, "frame", 0, { SECTION_ID_FRAME_TAGS, SECTION_ID_FRAME_SIDE_DATA_LIST, SECTION_ID_FRAME_LOGS, -1 } },
287 [SECTION_ID_FRAME_TAGS] = { SECTION_ID_FRAME_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "frame_tags" },
288 [SECTION_ID_FRAME_SIDE_DATA_LIST] ={ SECTION_ID_FRAME_SIDE_DATA_LIST, "side_data_list", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "frame_side_data_list" },
289 [SECTION_ID_FRAME_SIDE_DATA] = { SECTION_ID_FRAME_SIDE_DATA, "side_data", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST, SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST, -1 }, .unique_name = "frame_side_data", .element_name = "side_datum", .get_type = get_frame_side_data_type },
290 [SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST] = { SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST, "timecodes", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA_TIMECODE, -1 } },
291 [SECTION_ID_FRAME_SIDE_DATA_TIMECODE] = { SECTION_ID_FRAME_SIDE_DATA_TIMECODE, "timecode", 0, { -1 } },
292 [SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST] = { SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST, "components", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA_COMPONENT, -1 }, .element_name = "component", .unique_name = "frame_side_data_components" },
293 [SECTION_ID_FRAME_SIDE_DATA_COMPONENT] = { SECTION_ID_FRAME_SIDE_DATA_COMPONENT, "component", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST, -1 }, .unique_name = "frame_side_data_component", .element_name = "component_entry", .get_type = get_raw_string_type },
294 [SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST] = { SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST, "pieces", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA_PIECE, -1 }, .element_name = "piece", .unique_name = "frame_side_data_pieces" },
295 [SECTION_ID_FRAME_SIDE_DATA_PIECE] = { SECTION_ID_FRAME_SIDE_DATA_PIECE, "piece", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { -1 }, .element_name = "piece_entry", .unique_name = "frame_side_data_piece", .get_type = get_raw_string_type },
296 [SECTION_ID_FRAME_LOGS] = { SECTION_ID_FRAME_LOGS, "logs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_LOG, -1 } },
297 [SECTION_ID_FRAME_LOG] = { SECTION_ID_FRAME_LOG, "log", 0, { -1 }, },
298 [SECTION_ID_LIBRARY_VERSIONS] = { SECTION_ID_LIBRARY_VERSIONS, "library_versions", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_LIBRARY_VERSION, -1 } },
299 [SECTION_ID_LIBRARY_VERSION] = { SECTION_ID_LIBRARY_VERSION, "library_version", 0, { -1 } },
300 [SECTION_ID_PACKETS] = { SECTION_ID_PACKETS, "packets", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET, -1} },
301 [SECTION_ID_PACKETS_AND_FRAMES] = { SECTION_ID_PACKETS_AND_FRAMES, "packets_and_frames", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY | AV_TEXTFORMAT_SECTION_FLAG_NUMBERING_BY_TYPE, { SECTION_ID_PACKET, -1} },
302 [SECTION_ID_PACKET] = { SECTION_ID_PACKET, "packet", 0, { SECTION_ID_PACKET_TAGS, SECTION_ID_PACKET_SIDE_DATA_LIST, -1 } },
303 [SECTION_ID_PACKET_TAGS] = { SECTION_ID_PACKET_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "packet_tags" },
304 [SECTION_ID_PACKET_SIDE_DATA_LIST] ={ SECTION_ID_PACKET_SIDE_DATA_LIST, "side_data_list", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "packet_side_data_list" },
305 [SECTION_ID_PACKET_SIDE_DATA] = { SECTION_ID_PACKET_SIDE_DATA, "side_data", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_PACKET_SIDE_DATA_COMPONENT_LIST, -1 }, .unique_name = "packet_side_data", .element_name = "side_datum", .get_type = get_packet_side_data_type },
306 [SECTION_ID_PACKET_SIDE_DATA_COMPONENT_LIST] = { SECTION_ID_PACKET_SIDE_DATA_COMPONENT_LIST, "components", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET_SIDE_DATA_COMPONENT, -1 }, .element_name = "component", .unique_name = "packet_side_data_components" },
307 [SECTION_ID_PACKET_SIDE_DATA_COMPONENT] = { SECTION_ID_PACKET_SIDE_DATA_COMPONENT, "component", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { -1 }, .unique_name = "packet_side_data_component", .element_name = "component_entry", .get_type = get_raw_string_type },
308 [SECTION_ID_PIXEL_FORMATS] = { SECTION_ID_PIXEL_FORMATS, "pixel_formats", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_PIXEL_FORMAT, -1 } },
309 [SECTION_ID_PIXEL_FORMAT] = { SECTION_ID_PIXEL_FORMAT, "pixel_format", 0, { SECTION_ID_PIXEL_FORMAT_FLAGS, SECTION_ID_PIXEL_FORMAT_COMPONENTS, -1 } },
310 [SECTION_ID_PIXEL_FORMAT_FLAGS] = { SECTION_ID_PIXEL_FORMAT_FLAGS, "flags", 0, { -1 }, .unique_name = "pixel_format_flags" },
311 [SECTION_ID_PIXEL_FORMAT_COMPONENTS] = { SECTION_ID_PIXEL_FORMAT_COMPONENTS, "components", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, {SECTION_ID_PIXEL_FORMAT_COMPONENT, -1 }, .unique_name = "pixel_format_components" },
312 [SECTION_ID_PIXEL_FORMAT_COMPONENT] = { SECTION_ID_PIXEL_FORMAT_COMPONENT, "component", 0, { -1 } },
313 [SECTION_ID_PROGRAM_STREAM_DISPOSITION] = { SECTION_ID_PROGRAM_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "program_stream_disposition" },
314 [SECTION_ID_PROGRAM_STREAM_TAGS] = { SECTION_ID_PROGRAM_STREAM_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "program_stream_tags" },
315 [SECTION_ID_PROGRAM_STREAM_SIDE_DATA_LIST] = { SECTION_ID_PROGRAM_STREAM_SIDE_DATA_LIST, "side_data_list", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_PROGRAM_STREAM_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "program_stream_side_data_list" },
316 [SECTION_ID_PROGRAM_STREAM_SIDE_DATA] = { SECTION_ID_PROGRAM_STREAM_SIDE_DATA, "side_data", AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE|AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT_LIST, -1 }, .unique_name = "program_stream_side_data", .element_name = "side_datum", .get_type = get_packet_side_data_type },
317 [SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT_LIST] = { SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT_LIST, "components", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT, -1 }, .element_name = "component", .unique_name = "program_stream_side_data_components" },
318 [SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT] = { SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT, "component", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { -1 }, .unique_name = "program_stream_side_data_component", .element_name = "component_entry", .get_type = get_raw_string_type },
319 [SECTION_ID_PROGRAM] = { SECTION_ID_PROGRAM, "program", 0, { SECTION_ID_PROGRAM_TAGS, SECTION_ID_PROGRAM_STREAMS, -1 } },
320 [SECTION_ID_PROGRAM_STREAMS] = { SECTION_ID_PROGRAM_STREAMS, "streams", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_PROGRAM_STREAM, -1 }, .unique_name = "program_streams" },
321 [SECTION_ID_PROGRAM_STREAM] = { SECTION_ID_PROGRAM_STREAM, "stream", 0, { SECTION_ID_PROGRAM_STREAM_DISPOSITION, SECTION_ID_PROGRAM_STREAM_TAGS, SECTION_ID_PROGRAM_STREAM_SIDE_DATA_LIST, -1 }, .unique_name = "program_stream" },
322 [SECTION_ID_PROGRAM_TAGS] = { SECTION_ID_PROGRAM_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "program_tags" },
323 [SECTION_ID_PROGRAM_VERSION] = { SECTION_ID_PROGRAM_VERSION, "program_version", 0, { -1 } },
324 [SECTION_ID_PROGRAMS] = { SECTION_ID_PROGRAMS, "programs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_PROGRAM, -1 } },
325 [SECTION_ID_STREAM_GROUP_STREAM_GROUP_DISPOSITION] = { SECTION_ID_STREAM_GROUP_STREAM_GROUP_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "stream_group_stream_group_disposition" },
326 [SECTION_ID_STREAM_GROUP_STREAM_GROUP_TAGS] = { SECTION_ID_STREAM_GROUP_STREAM_GROUP_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "stream_group_stream_group_tags" },
327 [SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION] = { SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "stream_group_stream_disposition" },
328 [SECTION_ID_STREAM_GROUP_STREAM_TAGS] = { SECTION_ID_STREAM_GROUP_STREAM_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "stream_group_stream_tags" },
329 [SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_LIST] = { SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_LIST, "side_data_list", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "stream_group_stream_side_data_list" },
330 [SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA] = { SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA, "side_data", AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE|AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT_LIST, -1 }, .unique_name = "stream_group_stream_side_data", .element_name = "side_datum", .get_type = get_packet_side_data_type },
331 [SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT_LIST] = { SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT_LIST, "components", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT, -1 }, .element_name = "component", .unique_name = "stream_group_stream_side_data_components" },
332 [SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT] = { SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT, "component", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { -1 }, .unique_name = "stream_group_stream_side_data_component", .element_name = "component_entry", .get_type = get_raw_string_type },
333 [SECTION_ID_STREAM_GROUP] = { SECTION_ID_STREAM_GROUP, "stream_group", 0, { SECTION_ID_STREAM_GROUP_TAGS, SECTION_ID_STREAM_GROUP_DISPOSITION, SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST, SECTION_ID_STREAM_GROUP_COMPONENTS, SECTION_ID_STREAM_GROUP_STREAMS, SECTION_ID_STREAM_GROUP_STREAM_GROUPS, -1 } },
334 [SECTION_ID_STREAM_GROUP_COMPONENTS] = { SECTION_ID_STREAM_GROUP_COMPONENTS, "components", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_COMPONENT, -1 }, .element_name = "component", .unique_name = "stream_group_components" },
335 [SECTION_ID_STREAM_GROUP_COMPONENT] = { SECTION_ID_STREAM_GROUP_COMPONENT, "component", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_SUBCOMPONENTS, -1 }, .unique_name = "stream_group_component", .element_name = "component_entry", .get_type = get_stream_group_type },
336 [SECTION_ID_STREAM_GROUP_SUBCOMPONENTS] = { SECTION_ID_STREAM_GROUP_SUBCOMPONENTS, "subcomponents", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_SUBCOMPONENT, -1 }, .element_name = "component" },
337 [SECTION_ID_STREAM_GROUP_SUBCOMPONENT] = { SECTION_ID_STREAM_GROUP_SUBCOMPONENT, "subcomponent", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_PIECES, -1 }, .element_name = "subcomponent_entry", .get_type = get_raw_string_type },
338 [SECTION_ID_STREAM_GROUP_PIECES] = { SECTION_ID_STREAM_GROUP_PIECES, "pieces", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_PIECE, -1 }, .element_name = "piece", .unique_name = "stream_group_pieces" },
339 [SECTION_ID_STREAM_GROUP_PIECE] = { SECTION_ID_STREAM_GROUP_PIECE, "piece", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_SUBPIECES, -1 }, .unique_name = "stream_group_piece", .element_name = "piece_entry", .get_type = get_raw_string_type },
340 [SECTION_ID_STREAM_GROUP_SUBPIECES] = { SECTION_ID_STREAM_GROUP_SUBPIECES, "subpieces", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_SUBPIECE, -1 }, .element_name = "subpiece" },
341 [SECTION_ID_STREAM_GROUP_SUBPIECE] = { SECTION_ID_STREAM_GROUP_SUBPIECE, "subpiece", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { SECTION_ID_STREAM_GROUP_BLOCKS, -1 }, .element_name = "subpiece_entry", .get_type = get_raw_string_type },
342 [SECTION_ID_STREAM_GROUP_BLOCKS] = { SECTION_ID_STREAM_GROUP_BLOCKS, "blocks", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_BLOCK, -1 }, .element_name = "block" },
343 [SECTION_ID_STREAM_GROUP_BLOCK] = { SECTION_ID_STREAM_GROUP_BLOCK, "block", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { -1 }, .element_name = "block_entry", .get_type = get_raw_string_type },
344 [SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST] = { SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST, "side_data_list", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "stream_group_side_data_list" },
345 [SECTION_ID_STREAM_GROUP_SIDE_DATA] = { SECTION_ID_STREAM_GROUP_SIDE_DATA, "side_data", AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE|AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT_LIST, -1 }, .unique_name = "stream_group_side_data", .element_name = "side_datum", .get_type = get_packet_side_data_type },
346 [SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT_LIST] = { SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT_LIST, "components", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT, -1 }, .element_name = "component", .unique_name = "stream_group_side_data_components" },
347 [SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT] = { SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT, "component", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { -1 }, .unique_name = "stream_group_side_data_component", .element_name = "component_entry", .get_type = get_raw_string_type },
348 [SECTION_ID_STREAM_GROUP_STREAMS] = { SECTION_ID_STREAM_GROUP_STREAMS, "streams", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_STREAM, -1 }, .unique_name = "stream_group_streams" },
349 [SECTION_ID_STREAM_GROUP_STREAM] = { SECTION_ID_STREAM_GROUP_STREAM, "stream", 0, { SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION, SECTION_ID_STREAM_GROUP_STREAM_TAGS, SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_LIST, -1 }, .unique_name = "stream_group_stream" },
350 [SECTION_ID_STREAM_GROUP_STREAM_GROUPS] = { SECTION_ID_STREAM_GROUP_STREAM_GROUPS, "stream_groups", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP_STREAM_GROUP, -1 }, .unique_name = "stream_group_stream_groups" },
351 [SECTION_ID_STREAM_GROUP_STREAM_GROUP] = { SECTION_ID_STREAM_GROUP_STREAM_GROUP, "stream_group", 0, { SECTION_ID_STREAM_GROUP_STREAM_GROUP_DISPOSITION, SECTION_ID_STREAM_GROUP_STREAM_GROUP_TAGS, -1 }, .unique_name = "stream_group_stream_group" },
352 [SECTION_ID_STREAM_GROUP_DISPOSITION] = { SECTION_ID_STREAM_GROUP_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "stream_group_disposition" },
353 [SECTION_ID_STREAM_GROUP_TAGS] = { SECTION_ID_STREAM_GROUP_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "stream_group_tags" },
354 [SECTION_ID_STREAM_GROUPS] = { SECTION_ID_STREAM_GROUPS, "stream_groups", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_GROUP, -1 } },
355 [SECTION_ID_ROOT] = { SECTION_ID_ROOT, "root", AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER,
356 { SECTION_ID_CHAPTERS, SECTION_ID_FORMAT, SECTION_ID_FRAMES, SECTION_ID_PROGRAMS, SECTION_ID_STREAM_GROUPS, SECTION_ID_STREAMS,
357 SECTION_ID_PACKETS, SECTION_ID_ERROR, SECTION_ID_PROGRAM_VERSION, SECTION_ID_LIBRARY_VERSIONS,
358 SECTION_ID_PIXEL_FORMATS, -1} },
359 [SECTION_ID_STREAMS] = { SECTION_ID_STREAMS, "streams", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM, -1 } },
360 [SECTION_ID_STREAM] = { SECTION_ID_STREAM, "stream", 0, { SECTION_ID_STREAM_DISPOSITION, SECTION_ID_STREAM_TAGS, SECTION_ID_STREAM_SIDE_DATA_LIST, -1 } },
361 [SECTION_ID_STREAM_DISPOSITION] = { SECTION_ID_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "stream_disposition" },
362 [SECTION_ID_STREAM_TAGS] = { SECTION_ID_STREAM_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "stream_tags" },
363 [SECTION_ID_STREAM_SIDE_DATA_LIST] ={ SECTION_ID_STREAM_SIDE_DATA_LIST, "side_data_list", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "stream_side_data_list" },
364 [SECTION_ID_STREAM_SIDE_DATA] = { SECTION_ID_STREAM_SIDE_DATA, "side_data", AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE|AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { SECTION_ID_STREAM_SIDE_DATA_COMPONENT_LIST, -1 }, .unique_name = "stream_side_data", .element_name = "side_datum", .get_type = get_packet_side_data_type },
365 [SECTION_ID_STREAM_SIDE_DATA_COMPONENT_LIST] = { SECTION_ID_STREAM_SIDE_DATA_COMPONENT_LIST, "components", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_SIDE_DATA_COMPONENT, -1 }, .element_name = "component", .unique_name = "stream_side_data_components" },
366 [SECTION_ID_STREAM_SIDE_DATA_COMPONENT] = { SECTION_ID_STREAM_SIDE_DATA_COMPONENT, "component", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS|AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE, { -1 }, .unique_name = "stream_side_data_component", .element_name = "component_entry", .get_type = get_raw_string_type },
367 [SECTION_ID_SUBTITLE] = { SECTION_ID_SUBTITLE, "subtitle", 0, { -1 } },
368 };
369
370 typedef struct EntrySelection {
371 int show_all_entries;
372 int explicitly_selected; ///< Selected by unique name or through a selected parent.
373 AVDictionary *entries_to_show;
374 } EntrySelection;
375
376 static EntrySelection selected_entries[FF_ARRAY_ELEMS(sections)] = { 0 };
377
378 static const OptionDef *options;
379
380 /* FFprobe context */
381 static const char *input_filename;
382 static const char *print_input_filename;
383 static const AVInputFormat *iformat = NULL;
384 static const char *output_filename = NULL;
385
386 static const char unit_hertz_str[] = "Hz" ;
387 static const char unit_byte_str[] = "byte" ;
388 static const char unit_bit_per_second_str[] = "bit/s";
389
390 static unsigned int nb_streams;
391 static uint64_t *nb_streams_packets;
392 static uint64_t *nb_streams_frames;
393 static int *selected_streams;
394 static int *streams_with_closed_captions;
395 static int *streams_with_film_grain;
396
397 static AVMutex log_mutex = AV_MUTEX_INITIALIZER;
398
399 typedef struct LogBuffer {
400 char *context_name;
401 int log_level;
402 char *log_message;
403 AVClassCategory category;
404 char *parent_name;
405 AVClassCategory parent_category;
406 }LogBuffer;
407
408 static LogBuffer *log_buffer;
409 static int log_buffer_size;
410
411 189382 static int is_key_selected_callback(AVTextFormatContext *tctx, const char *key)
412 {
413 189382 const AVTextFormatSection *section = tctx->section[tctx->level];
414 189382 const EntrySelection *selection = &selected_entries[section - sections];
415
416
4/4
✓ Branch 0 taken 114991 times.
✓ Branch 1 taken 74391 times.
✓ Branch 3 taken 20381 times.
✓ Branch 4 taken 94610 times.
189382 return selection->show_all_entries || av_dict_get(selection->entries_to_show, key, NULL, 0);
417 }
418
419 ✗ static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
420 {
421 ✗ AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
422 va_list vl2;
423 char line[1024];
424 static int print_prefix = 1;
425 void *new_log_buffer;
426
427 ✗ va_copy(vl2, vl);
428 ✗ av_log_default_callback(ptr, level, fmt, vl);
429 ✗ av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix);
430 ✗ va_end(vl2);
431
432 #if HAVE_THREADS
433 ✗ ff_mutex_lock(&log_mutex);
434
435 ✗ new_log_buffer = av_realloc_array(log_buffer, log_buffer_size + 1, sizeof(*log_buffer));
436 ✗ if (new_log_buffer) {
437 char *msg;
438 int i;
439
440 ✗ log_buffer = new_log_buffer;
441 ✗ memset(&log_buffer[log_buffer_size], 0, sizeof(log_buffer[log_buffer_size]));
442 ✗ log_buffer[log_buffer_size].context_name= avc ? av_strdup(avc->item_name(ptr)) : NULL;
443 ✗ if (avc) {
444 ✗ if (avc->get_category) log_buffer[log_buffer_size].category = avc->get_category(ptr);
445 ✗ else log_buffer[log_buffer_size].category = avc->category;
446 }
447 ✗ log_buffer[log_buffer_size].log_level = level;
448 ✗ msg = log_buffer[log_buffer_size].log_message = av_strdup(line);
449 ✗ for (i=strlen(msg) - 1; i>=0 && msg[i] == '\n'; i--) {
450 ✗ msg[i] = 0;
451 }
452 ✗ if (avc && avc->parent_log_context_offset) {
453 ✗ AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) +
454 ✗ avc->parent_log_context_offset);
455 ✗ if (parent && *parent) {
456 ✗ log_buffer[log_buffer_size].parent_name = av_strdup((*parent)->item_name(parent));
457 ✗ log_buffer[log_buffer_size].parent_category =
458 ✗ (*parent)->get_category ? (*parent)->get_category(parent) :(*parent)->category;
459 }
460 }
461 ✗ log_buffer_size ++;
462 }
463
464 ✗ ff_mutex_unlock(&log_mutex);
465 #endif
466 ✗ }
467
468
469 #define print_fmt(k, f, ...) do { \
470 av_bprint_clear(&pbuf); \
471 av_bprintf(&pbuf, f, __VA_ARGS__); \
472 avtext_print_string(tfc, k, pbuf.str, 0); \
473 } while (0)
474
475 #define print_list_fmt(k, f, n, m, ...) do { \
476 av_bprint_clear(&pbuf); \
477 for (unsigned int idx = 0; idx < n; idx++) { \
478 for (unsigned int idx2 = 0; idx2 < m; idx2++) { \
479 if (idx > 0 || idx2 > 0) \
480 av_bprint_chars(&pbuf, ' ', 1); \
481 av_bprintf(&pbuf, f, __VA_ARGS__); \
482 } \
483 } \
484 avtext_print_string(tfc, k, pbuf.str, 0); \
485 } while (0)
486
487 #define print_int(k, v) avtext_print_integer(tfc, k, v, 0)
488 #define print_int_opt(k, v) avtext_print_integer(tfc, k, v, AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
489 #define print_q(k, v, s) avtext_print_rational(tfc, k, v, s)
490 #define print_str(k, v) avtext_print_string(tfc, k, v, 0)
491 #define print_str_opt(k, v) avtext_print_string(tfc, k, v, AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
492 #define print_str_validate(k, v) avtext_print_string(tfc, k, v, AV_TEXTFORMAT_PRINT_STRING_VALIDATE)
493 #define print_time(k, v, tb) avtext_print_time(tfc, k, v, tb, 0)
494 #define print_ts(k, v) avtext_print_ts(tfc, k, v, 0)
495 #define print_duration_time(k, v, tb) avtext_print_time(tfc, k, v, tb, 1)
496 #define print_duration_ts(k, v) avtext_print_ts(tfc, k, v, 1)
497 #define print_val(k, v, u) avtext_print_unit_integer(tfc, k, v, AV_TEXTFORMAT_VALUE_FMT_INT, u)
498 #define print_int_fmt(k, v, f, u) avtext_print_unit_integer(tfc, k, v, f, u)
499 #define print_decibel(k, v) avtext_print_unit_double(tfc, k, v, AV_TEXTFORMAT_VALUE_FMT_DECIBEL, 0)
500
501 102 static void print_integers(AVTextFormatContext *tfc, const char *key,
502 const void *data, int size, const char *format,
503 int columns, int bytes, int offset_add)
504 {
505 AVBPrint bp;
506 102 unsigned offset = 0;
507
508 102 av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
509 102 av_bprint_chars(&bp, '\n', 1);
510
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 102 times.
408 while (size) {
511 306 av_bprintf(&bp, "%08x: ", offset);
512
2/2
✓ Branch 0 taken 918 times.
✓ Branch 1 taken 306 times.
1224 for (int i = 0, l = FFMIN(size, columns); i < l; i++) {
513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 918 times.
918 if (bytes == 1) av_bprintf(&bp, format, *(const uint8_t*)data);
514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 918 times.
918 else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
515
1/2
✓ Branch 0 taken 918 times.
✗ Branch 1 not taken.
918 else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
516 918 data = (const char*)data + bytes;
517 918 size--;
518 }
519 306 av_bprint_chars(&bp, '\n', 1);
520 306 offset += offset_add;
521 }
522 102 avtext_print_string(tfc, key, bp.str, 0);
523 102 }
524
525 #define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n) \
526 { \
527 ret = av_reallocp_array(&(ptr), (new_n), sizeof(*(ptr))); \
528 if (ret < 0) \
529 goto end; \
530 memset( (ptr) + (cur_n), 0, ((new_n) - (cur_n)) * sizeof(*(ptr)) ); \
531 }
532
533 1923 static inline int show_tags(AVTextFormatContext *tfc, AVDictionary *tags, int section_id)
534 {
535 1923 const AVDictionaryEntry *tag = NULL;
536 1923 int ret = 0;
537
538
2/2
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 795 times.
1923 if (!tags)
539 1128 return 0;
540 795 avtext_print_section_header(tfc, NULL, section_id);
541
542
2/2
✓ Branch 1 taken 4515 times.
✓ Branch 2 taken 795 times.
5310 while ((tag = av_dict_iterate(tags, tag))) {
543
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4515 times.
4515 if ((ret = print_str_validate(tag->key, tag->value)) < 0)
544 ✗ break;
545 }
546 795 avtext_print_section_footer(tfc);
547
548 795 return ret;
549 }
550
551 ✗ static void print_downmix_info(AVTextFormatContext *tfc,
552 const AVDownmixInfo *downmix_info)
553 {
554 ✗ switch (downmix_info->preferred_downmix_type) {
555 ✗ case AV_DOWNMIX_TYPE_LORO:
556 ✗ print_str("preferred_downmix_type", "loro");
557 ✗ break;
558 ✗ case AV_DOWNMIX_TYPE_LTRT:
559 ✗ print_str("preferred_downmix_type", "ltrt");
560 ✗ break;
561 ✗ case AV_DOWNMIX_TYPE_DPLII:
562 ✗ print_str("preferred_downmix_type", "dplII");
563 ✗ break;
564 ✗ default:
565 ✗ print_str("preferred_downmix_type", "unknown");
566 ✗ break;
567 }
568 ✗ print_decibel("center_mix_level_db", downmix_info->center_mix_level);
569 ✗ print_decibel("center_mix_level_ltrt_db", downmix_info->center_mix_level_ltrt);
570 ✗ print_decibel("surround_mix_level_db", downmix_info->surround_mix_level);
571 ✗ print_decibel("surround_mix_level_ltrt_db", downmix_info->surround_mix_level_ltrt);
572 ✗ print_decibel("lfe_mix_level_db", downmix_info->lfe_mix_level);
573 ✗ }
574
575 102 static void print_displaymatrix(AVTextFormatContext *tfc, const int32_t matrix[9])
576 {
577 102 double rotation = av_display_rotation_get(matrix);
578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if (isnan(rotation))
579 ✗ rotation = 0;
580 102 print_integers(tfc, "displaymatrix", matrix, 9, " %11d", 3, 4, 1);
581 102 print_int("rotation", rotation);
582 102 }
583
584 30 static void print_mastering_display_metadata(AVTextFormatContext *tfc,
585 const AVMasteringDisplayMetadata *metadata)
586 {
587
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (metadata->has_primaries) {
588 30 print_q("red_x", metadata->display_primaries[0][0], '/');
589 30 print_q("red_y", metadata->display_primaries[0][1], '/');
590 30 print_q("green_x", metadata->display_primaries[1][0], '/');
591 30 print_q("green_y", metadata->display_primaries[1][1], '/');
592 30 print_q("blue_x", metadata->display_primaries[2][0], '/');
593 30 print_q("blue_y", metadata->display_primaries[2][1], '/');
594
595 30 print_q("white_point_x", metadata->white_point[0], '/');
596 30 print_q("white_point_y", metadata->white_point[1], '/');
597 }
598
599
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (metadata->has_luminance) {
600 30 print_q("min_luminance", metadata->min_luminance, '/');
601 30 print_q("max_luminance", metadata->max_luminance, '/');
602 }
603 30 }
604
605 29 static void print_context_light_level(AVTextFormatContext *tfc,
606 const AVContentLightMetadata *metadata)
607 {
608 29 print_int("max_content", metadata->MaxCLL);
609 29 print_int("max_average", metadata->MaxFALL);
610 29 }
611
612 2 static void print_dovi_metadata(AVTextFormatContext *tfc, const AVDOVIMetadata *dovi)
613 {
614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (!dovi)
615 ✗ return;
616
617 {
618 2 const AVDOVIRpuDataHeader *hdr = av_dovi_get_header(dovi);
619 2 const AVDOVIDataMapping *mapping = av_dovi_get_mapping(dovi);
620 2 const AVDOVIColorMetadata *color = av_dovi_get_color(dovi);
621 AVBPrint pbuf;
622
623 2 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
624
625 // header
626 2 print_int("rpu_type", hdr->rpu_type);
627 2 print_int("rpu_format", hdr->rpu_format);
628 2 print_int("vdr_rpu_profile", hdr->vdr_rpu_profile);
629 2 print_int("vdr_rpu_level", hdr->vdr_rpu_level);
630 2 print_int("chroma_resampling_explicit_filter_flag",
631 hdr->chroma_resampling_explicit_filter_flag);
632 2 print_int("coef_data_type", hdr->coef_data_type);
633 2 print_int("coef_log2_denom", hdr->coef_log2_denom);
634 2 print_int("vdr_rpu_normalized_idc", hdr->vdr_rpu_normalized_idc);
635 2 print_int("bl_video_full_range_flag", hdr->bl_video_full_range_flag);
636 2 print_int("bl_bit_depth", hdr->bl_bit_depth);
637 2 print_int("el_bit_depth", hdr->el_bit_depth);
638 2 print_int("vdr_bit_depth", hdr->vdr_bit_depth);
639 2 print_int("spatial_resampling_filter_flag",
640 hdr->spatial_resampling_filter_flag);
641 2 print_int("el_spatial_resampling_filter_flag",
642 hdr->el_spatial_resampling_filter_flag);
643 2 print_int("disable_residual_flag", hdr->disable_residual_flag);
644
645 // data mapping values
646 2 print_int("vdr_rpu_id", mapping->vdr_rpu_id);
647 2 print_int("mapping_color_space", mapping->mapping_color_space);
648 2 print_int("mapping_chroma_format_idc",
649 mapping->mapping_chroma_format_idc);
650
651 2 print_int("nlq_method_idc", mapping->nlq_method_idc);
652
1/3
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2 switch (mapping->nlq_method_idc) {
653 2 case AV_DOVI_NLQ_NONE:
654 2 print_str("nlq_method_idc_name", "none");
655 2 break;
656 ✗ case AV_DOVI_NLQ_LINEAR_DZ:
657 ✗ print_str("nlq_method_idc_name", "linear_dz");
658 ✗ break;
659 ✗ default:
660 ✗ print_str("nlq_method_idc_name", "unknown");
661 ✗ break;
662 }
663
664 2 print_int("num_x_partitions", mapping->num_x_partitions);
665 2 print_int("num_y_partitions", mapping->num_y_partitions);
666
667 2 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST);
668
669
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for (int c = 0; c < 3; c++) {
670 6 const AVDOVIReshapingCurve *curve = &mapping->curves[c];
671 6 avtext_print_section_header(tfc, "Reshaping curve", SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
672
673
7/8
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 26 times.
✓ Branch 8 taken 26 times.
✓ Branch 9 taken 26 times.
✓ Branch 10 taken 6 times.
58 print_list_fmt("pivots", "%"PRIu16, curve->num_pivots, 1, curve->pivots[idx]);
674
675 6 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST);
676
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 6 times.
26 for (int i = 0; i < curve->num_pivots - 1; i++) {
677 AVBPrint piece_buf;
678
679 20 av_bprint_init(&piece_buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
680
2/3
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
20 switch (curve->mapping_idc[i]) {
681 16 case AV_DOVI_MAPPING_POLYNOMIAL:
682 16 av_bprintf(&piece_buf, "Polynomial");
683 16 break;
684 4 case AV_DOVI_MAPPING_MMR:
685 4 av_bprintf(&piece_buf, "MMR");
686 4 break;
687 ✗ default:
688 ✗ av_bprintf(&piece_buf, "Unknown");
689 ✗ break;
690 }
691 20 av_bprintf(&piece_buf, " mapping");
692
693 20 avtext_print_section_header(tfc, piece_buf.str, SECTION_ID_FRAME_SIDE_DATA_PIECE);
694 20 print_int("mapping_idc", curve->mapping_idc[i]);
695
2/3
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
20 switch (curve->mapping_idc[i]) {
696 16 case AV_DOVI_MAPPING_POLYNOMIAL:
697 16 print_str("mapping_idc_name", "polynomial");
698 16 print_int("poly_order", curve->poly_order[i]);
699
7/8
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 48 times.
✓ Branch 8 taken 48 times.
✓ Branch 9 taken 48 times.
✓ Branch 10 taken 16 times.
112 print_list_fmt("poly_coef", "%"PRIi64,
700 curve->poly_order[i] + 1, 1,
701 curve->poly_coef[i][idx]);
702 16 break;
703 4 case AV_DOVI_MAPPING_MMR:
704 4 print_str("mapping_idc_name", "mmr");
705 4 print_int("mmr_order", curve->mmr_order[i]);
706 4 print_int("mmr_constant", curve->mmr_constant[i]);
707
8/8
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 84 times.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 4 times.
100 print_list_fmt("mmr_coef", "%"PRIi64,
708 curve->mmr_order[i], 7,
709 curve->mmr_coef[i][idx][idx2]);
710 4 break;
711 ✗ default:
712 ✗ print_str("mapping_idc_name", "unknown");
713 ✗ break;
714 }
715
716 // SECTION_ID_FRAME_SIDE_DATA_PIECE
717 20 avtext_print_section_footer(tfc);
718 }
719
720 // SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST
721 6 avtext_print_section_footer(tfc);
722
723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (mapping->nlq_method_idc != AV_DOVI_NLQ_NONE) {
724 ✗ const AVDOVINLQParams *nlq = &mapping->nlq[c];
725 ✗ print_int("nlq_offset", nlq->nlq_offset);
726 ✗ print_int("vdr_in_max", nlq->vdr_in_max);
727
728 ✗ switch (mapping->nlq_method_idc) {
729 ✗ case AV_DOVI_NLQ_LINEAR_DZ:
730 ✗ print_int("linear_deadzone_slope", nlq->linear_deadzone_slope);
731 ✗ print_int("linear_deadzone_threshold", nlq->linear_deadzone_threshold);
732 ✗ break;
733 }
734 }
735
736 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
737 6 avtext_print_section_footer(tfc);
738 }
739
740 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
741 2 avtext_print_section_footer(tfc);
742
743 // color metadata
744 2 print_int("dm_metadata_id", color->dm_metadata_id);
745 2 print_int("scene_refresh_flag", color->scene_refresh_flag);
746
7/8
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 18 times.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 18 times.
✓ Branch 10 taken 2 times.
38 print_list_fmt("ycc_to_rgb_matrix", "%d/%d",
747 FF_ARRAY_ELEMS(color->ycc_to_rgb_matrix), 1,
748 color->ycc_to_rgb_matrix[idx].num,
749 color->ycc_to_rgb_matrix[idx].den);
750
7/8
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 2 times.
14 print_list_fmt("ycc_to_rgb_offset", "%d/%d",
751 FF_ARRAY_ELEMS(color->ycc_to_rgb_offset), 1,
752 color->ycc_to_rgb_offset[idx].num,
753 color->ycc_to_rgb_offset[idx].den);
754
7/8
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 18 times.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 18 times.
✓ Branch 10 taken 2 times.
38 print_list_fmt("rgb_to_lms_matrix", "%d/%d",
755 FF_ARRAY_ELEMS(color->rgb_to_lms_matrix), 1,
756 color->rgb_to_lms_matrix[idx].num,
757 color->rgb_to_lms_matrix[idx].den);
758 2 print_int("signal_eotf", color->signal_eotf);
759 2 print_int("signal_eotf_param0", color->signal_eotf_param0);
760 2 print_int("signal_eotf_param1", color->signal_eotf_param1);
761 2 print_int("signal_eotf_param2", color->signal_eotf_param2);
762 2 print_int("signal_bit_depth", color->signal_bit_depth);
763 2 print_int("signal_color_space", color->signal_color_space);
764 2 print_int("signal_chroma_format", color->signal_chroma_format);
765 2 print_int("signal_full_range_flag", color->signal_full_range_flag);
766 2 print_int("source_min_pq", color->source_min_pq);
767 2 print_int("source_max_pq", color->source_max_pq);
768 2 print_int("source_diagonal", color->source_diagonal);
769
770 2 av_bprint_finalize(&pbuf, NULL);
771 }
772 }
773
774 4 static void print_dynamic_hdr10_plus(AVTextFormatContext *tfc, const AVDynamicHDRPlus *metadata)
775 {
776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!metadata)
777 ✗ return;
778 4 print_int("application version", metadata->application_version);
779 4 print_int("num_windows", metadata->num_windows);
780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 for (int n = 1; n < metadata->num_windows; n++) {
781 ✗ const AVHDRPlusColorTransformParams *params = &metadata->params[n];
782 ✗ print_q("window_upper_left_corner_x",
783 params->window_upper_left_corner_x,'/');
784 ✗ print_q("window_upper_left_corner_y",
785 params->window_upper_left_corner_y,'/');
786 ✗ print_q("window_lower_right_corner_x",
787 params->window_lower_right_corner_x,'/');
788 ✗ print_q("window_lower_right_corner_y",
789 params->window_lower_right_corner_y,'/');
790 ✗ print_int("center_of_ellipse_x",
791 params->center_of_ellipse_x ) ;
792 ✗ print_int("center_of_ellipse_y",
793 params->center_of_ellipse_y );
794 ✗ print_int("rotation_angle",
795 params->rotation_angle);
796 ✗ print_int("semimajor_axis_internal_ellipse",
797 params->semimajor_axis_internal_ellipse);
798 ✗ print_int("semimajor_axis_external_ellipse",
799 params->semimajor_axis_external_ellipse);
800 ✗ print_int("semiminor_axis_external_ellipse",
801 params->semiminor_axis_external_ellipse);
802 ✗ print_int("overlap_process_option",
803 params->overlap_process_option);
804 }
805 4 print_q("targeted_system_display_maximum_luminance",
806 metadata->targeted_system_display_maximum_luminance,'/');
807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (metadata->targeted_system_display_actual_peak_luminance_flag) {
808 ✗ print_int("num_rows_targeted_system_display_actual_peak_luminance",
809 metadata->num_rows_targeted_system_display_actual_peak_luminance);
810 ✗ print_int("num_cols_targeted_system_display_actual_peak_luminance",
811 metadata->num_cols_targeted_system_display_actual_peak_luminance);
812 ✗ for (int i = 0; i < metadata->num_rows_targeted_system_display_actual_peak_luminance; i++) {
813 ✗ for (int j = 0; j < metadata->num_cols_targeted_system_display_actual_peak_luminance; j++) {
814 ✗ print_q("targeted_system_display_actual_peak_luminance",
815 metadata->targeted_system_display_actual_peak_luminance[i][j],'/');
816 }
817 }
818 }
819
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 for (int n = 0; n < metadata->num_windows; n++) {
820 4 const AVHDRPlusColorTransformParams *params = &metadata->params[n];
821
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 for (int i = 0; i < 3; i++) {
822 12 print_q("maxscl",params->maxscl[i],'/');
823 }
824 4 print_q("average_maxrgb",
825 params->average_maxrgb,'/');
826 4 print_int("num_distribution_maxrgb_percentiles",
827 params->num_distribution_maxrgb_percentiles);
828
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 4 times.
40 for (int i = 0; i < params->num_distribution_maxrgb_percentiles; i++) {
829 36 print_int("distribution_maxrgb_percentage",
830 params->distribution_maxrgb[i].percentage);
831 36 print_q("distribution_maxrgb_percentile",
832 params->distribution_maxrgb[i].percentile,'/');
833 }
834 4 print_q("fraction_bright_pixels",
835 params->fraction_bright_pixels,'/');
836 }
837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (metadata->mastering_display_actual_peak_luminance_flag) {
838 ✗ print_int("num_rows_mastering_display_actual_peak_luminance",
839 metadata->num_rows_mastering_display_actual_peak_luminance);
840 ✗ print_int("num_cols_mastering_display_actual_peak_luminance",
841 metadata->num_cols_mastering_display_actual_peak_luminance);
842 ✗ for (int i = 0; i < metadata->num_rows_mastering_display_actual_peak_luminance; i++) {
843 ✗ for (int j = 0; j < metadata->num_cols_mastering_display_actual_peak_luminance; j++) {
844 ✗ print_q("mastering_display_actual_peak_luminance",
845 metadata->mastering_display_actual_peak_luminance[i][j],'/');
846 }
847 }
848 }
849
850
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 for (int n = 0; n < metadata->num_windows; n++) {
851 4 const AVHDRPlusColorTransformParams *params = &metadata->params[n];
852
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (params->tone_mapping_flag) {
853 4 print_q("knee_point_x", params->knee_point_x,'/');
854 4 print_q("knee_point_y", params->knee_point_y,'/');
855 4 print_int("num_bezier_curve_anchors",
856 params->num_bezier_curve_anchors );
857
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 4 times.
40 for (int i = 0; i < params->num_bezier_curve_anchors; i++) {
858 36 print_q("bezier_curve_anchors",
859 params->bezier_curve_anchors[i],'/');
860 }
861 }
862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (params->color_saturation_mapping_flag) {
863 ✗ print_q("color_saturation_weight",
864 params->color_saturation_weight,'/');
865 }
866 }
867 }
868
869 ✗ static void print_dynamic_hdr_smpte2094_app5(AVTextFormatContext *tfc, const AVDynamicHDRSmpte2094App5 *metadata)
870 {
871 ✗ if (!metadata)
872 ✗ return;
873 ✗ print_int("application_version", metadata->application_version);
874 ✗ print_int("minimum_application_version", metadata->minimum_application_version);
875 ✗ print_int("has_custom_hdr_reference_white_flag", metadata->has_custom_hdr_reference_white_flag);
876 ✗ print_int("has_adaptive_tone_map_flag", metadata->has_adaptive_tone_map_flag);
877
878 ✗ if (metadata->has_custom_hdr_reference_white_flag)
879 ✗ print_int("hdr_reference_white", metadata->hdr_reference_white);
880
881 ✗ if (!metadata->has_adaptive_tone_map_flag)
882 ✗ return;
883
884 ✗ print_int("baseline_hdr_headroom", metadata->baseline_hdr_headroom);
885 ✗ print_int("use_reference_white_tone_mapping_flag", metadata->use_reference_white_tone_mapping_flag);
886
887 ✗ if (metadata->use_reference_white_tone_mapping_flag)
888 ✗ return;
889
890 ✗ print_int("num_alternate_images", metadata->num_alternate_images);
891 ✗ print_int("gain_application_space_chromaticities_flag", metadata->gain_application_space_chromaticities_flag);
892 ✗ print_int("has_common_component_mix_params_flag", metadata->has_common_component_mix_params_flag);
893 ✗ print_int("has_common_curve_params_flag", metadata->has_common_curve_params_flag);
894
895 ✗ if (metadata->gain_application_space_chromaticities_flag == 3) {
896 ✗ for (int i = 0; i < 8; i++)
897 ✗ print_int("gain_application_space_chromaticities", metadata->gain_application_space_chromaticities[i]);
898 }
899
900 ✗ for (int a = 0; a < metadata->num_alternate_images; a++) {
901 ✗ print_int("alternate_hdr_headroom", metadata->alternate_hdr_headrooms[a]);
902
903 ✗ print_int("component_mixing_type", metadata->component_mixing_type[a]);
904 ✗ if (metadata->component_mixing_type[a] == 3) {
905 ✗ for (int k = 0; k < 6; k++) {
906 ✗ print_int("has_component_mixing_coefficient_flag", metadata->has_component_mixing_coefficient_flag[a][k]);
907 ✗ if (metadata->has_component_mixing_coefficient_flag[a][k])
908 ✗ print_int("component_mixing_coefficient", metadata->component_mixing_coefficient[a][k]);
909 }
910 }
911
912 ✗ print_int("gain_curve_num_control_points_minus_1", metadata->gain_curve_num_control_points_minus_1[a]);
913 ✗ print_int("gain_curve_use_pchip_slope_flag", metadata->gain_curve_use_pchip_slope_flag[a]);
914 ✗ for (int c = 0; c <= metadata->gain_curve_num_control_points_minus_1[a]; c++)
915 ✗ print_int("gain_curve_control_point_x", metadata->gain_curve_control_points_x[a][c]);
916 ✗ for (int c = 0; c <= metadata->gain_curve_num_control_points_minus_1[a]; c++)
917 ✗ print_int("gain_curve_control_point_y", metadata->gain_curve_control_points_y[a][c]);
918 ✗ if (!metadata->gain_curve_use_pchip_slope_flag[a]) {
919 ✗ for (int c = 0; c <= metadata->gain_curve_num_control_points_minus_1[a]; c++)
920 ✗ print_int("gain_curve_control_point_theta", metadata->gain_curve_control_points_theta[a][c]);
921 }
922 }
923 }
924
925 1 static void print_dynamic_hdr_vivid(AVTextFormatContext *tfc, const AVDynamicHDRVivid *metadata)
926 {
927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!metadata)
928 ✗ return;
929 1 print_int("system_start_code", metadata->system_start_code);
930 1 print_int("num_windows", metadata->num_windows);
931
932
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for (int n = 0; n < metadata->num_windows; n++) {
933 1 const AVHDRVividColorTransformParams *params = &metadata->params[n];
934
935 1 print_q("minimum_maxrgb", params->minimum_maxrgb, '/');
936 1 print_q("average_maxrgb", params->average_maxrgb, '/');
937 1 print_q("variance_maxrgb", params->variance_maxrgb, '/');
938 1 print_q("maximum_maxrgb", params->maximum_maxrgb, '/');
939 }
940
941
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for (int n = 0; n < metadata->num_windows; n++) {
942 1 const AVHDRVividColorTransformParams *params = &metadata->params[n];
943
944 1 print_int("tone_mapping_mode_flag", params->tone_mapping_mode_flag);
945
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (params->tone_mapping_mode_flag) {
946 1 print_int("tone_mapping_param_num", params->tone_mapping_param_num);
947
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (int i = 0; i < params->tone_mapping_param_num; i++) {
948 2 const AVHDRVividColorToneMappingParams *tm_params = &params->tm_params[i];
949
950 2 print_q("targeted_system_display_maximum_luminance",
951 tm_params->targeted_system_display_maximum_luminance, '/');
952 2 print_int("base_enable_flag", tm_params->base_enable_flag);
953
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (tm_params->base_enable_flag) {
954 2 print_q("base_param_m_p", tm_params->base_param_m_p, '/');
955 2 print_q("base_param_m_m", tm_params->base_param_m_m, '/');
956 2 print_q("base_param_m_a", tm_params->base_param_m_a, '/');
957 2 print_q("base_param_m_b", tm_params->base_param_m_b, '/');
958 2 print_q("base_param_m_n", tm_params->base_param_m_n, '/');
959
960 2 print_int("base_param_k1", tm_params->base_param_k1);
961 2 print_int("base_param_k2", tm_params->base_param_k2);
962 2 print_int("base_param_k3", tm_params->base_param_k3);
963 2 print_int("base_param_Delta_enable_mode",
964 tm_params->base_param_Delta_enable_mode);
965 2 print_q("base_param_Delta", tm_params->base_param_Delta, '/');
966 }
967 2 print_int("3Spline_enable_flag", tm_params->three_Spline_enable_flag);
968
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (tm_params->three_Spline_enable_flag) {
969 2 print_int("3Spline_num", tm_params->three_Spline_num);
970
971
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for (int j = 0; j < tm_params->three_Spline_num; j++) {
972 2 const AVHDRVivid3SplineParams *three_spline = &tm_params->three_spline[j];
973 2 print_int("3Spline_TH_mode", three_spline->th_mode);
974
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if (three_spline->th_mode == 0 || three_spline->th_mode == 2)
975 2 print_q("3Spline_TH_enable_MB", three_spline->th_enable_mb, '/');
976 2 print_q("3Spline_TH_enable", three_spline->th_enable, '/');
977 2 print_q("3Spline_TH_Delta1", three_spline->th_delta1, '/');
978 2 print_q("3Spline_TH_Delta2", three_spline->th_delta2, '/');
979 2 print_q("3Spline_enable_Strength", three_spline->enable_strength, '/');
980 }
981 }
982 }
983 }
984
985 1 print_int("color_saturation_mapping_flag", params->color_saturation_mapping_flag);
986
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (params->color_saturation_mapping_flag) {
987 1 print_int("color_saturation_num", params->color_saturation_num);
988
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (int i = 0; i < params->color_saturation_num; i++) {
989 2 print_q("color_saturation_gain", params->color_saturation_gain[i], '/');
990 }
991 }
992 }
993 }
994
995 4 static void print_ambient_viewing_environment(AVTextFormatContext *tfc,
996 const AVAmbientViewingEnvironment *env)
997 {
998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!env)
999 ✗ return;
1000
1001 4 print_q("ambient_illuminance", env->ambient_illuminance, '/');
1002 4 print_q("ambient_light_x", env->ambient_light_x, '/');
1003 4 print_q("ambient_light_y", env->ambient_light_y, '/');
1004 }
1005
1006 1 static void print_gain_map_params(AVTextFormatContext *tfc,
1007 const AVGainMapParams *p)
1008 {
1009 1 const char *const channel_names[] = { "R", "G", "B" };
1010
1011 1 print_int("version", p->version);
1012 1 print_int("use_base_color_space", p->use_base_color_space);
1013 1 print_q("base_hdr_headroom", p->base_hdr_headroom, '/');
1014 1 print_q("alternate_hdr_headroom", p->alternate_hdr_headroom, '/');
1015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if (!(p->nb_channels == 1 || p->nb_channels == 3))
1016 ✗ return;
1017
1018 1 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST);
1019
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for (int c = 0; c < p->nb_channels; c++) {
1020 1 const struct AVGainMapChannel *ch = &p->channels[c];
1021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 const char *comp_name = p->nb_channels == 1 ? "RGB" : channel_names[c];
1022 1 avtext_print_section_header(tfc, comp_name, SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
1023 1 print_q("gain_map_min", ch->gain_map_min, '/');
1024 1 print_q("gain_map_max", ch->gain_map_max, '/');
1025 1 print_q("gamma", ch->gamma, '/');
1026 1 print_q("base_offset", ch->base_offset, '/');
1027 1 print_q("alternate_offset", ch->alternate_offset, '/');
1028 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
1029 1 avtext_print_section_footer(tfc);
1030 }
1031 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
1032 1 avtext_print_section_footer(tfc);
1033 }
1034
1035 ✗ static void print_film_grain_params(AVTextFormatContext *tfc,
1036 const AVFilmGrainParams *fgp)
1037 {
1038 const char *color_range, *color_primaries, *color_trc, *color_space;
1039 ✗ const char *const film_grain_type_names[] = {
1040 [AV_FILM_GRAIN_PARAMS_NONE] = "none",
1041 [AV_FILM_GRAIN_PARAMS_AV1] = "av1",
1042 [AV_FILM_GRAIN_PARAMS_H274] = "h274",
1043 };
1044 ✗ const char *const component_names[] = { "Y", "Cb", "Cr" };
1045
1046 AVBPrint pbuf;
1047 ✗ if (!fgp || fgp->type >= FF_ARRAY_ELEMS(film_grain_type_names))
1048 ✗ return;
1049
1050 ✗ color_range = av_color_range_name(fgp->color_range);
1051 ✗ color_primaries = av_color_primaries_name(fgp->color_primaries);
1052 ✗ color_trc = av_color_transfer_name(fgp->color_trc);
1053 ✗ color_space = av_color_space_name(fgp->color_space);
1054
1055 ✗ av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
1056 ✗ print_str("type", film_grain_type_names[fgp->type]);
1057 ✗ print_fmt("seed", "%"PRIu64, fgp->seed);
1058 ✗ print_int("width", fgp->width);
1059 ✗ print_int("height", fgp->height);
1060 ✗ print_int("subsampling_x", fgp->subsampling_x);
1061 ✗ print_int("subsampling_y", fgp->subsampling_y);
1062 ✗ print_str("color_range", color_range ? color_range : "unknown");
1063 ✗ print_str("color_primaries", color_primaries ? color_primaries : "unknown");
1064 ✗ print_str("color_trc", color_trc ? color_trc : "unknown");
1065 ✗ print_str("color_space", color_space ? color_space : "unknown");
1066
1067 ✗ switch (fgp->type) {
1068 ✗ case AV_FILM_GRAIN_PARAMS_NONE:
1069 ✗ break;
1070 ✗ case AV_FILM_GRAIN_PARAMS_AV1: {
1071 ✗ const AVFilmGrainAOMParams *aom = &fgp->codec.aom;
1072 ✗ const int num_ar_coeffs_y = 2 * aom->ar_coeff_lag * (aom->ar_coeff_lag + 1);
1073 ✗ const int num_ar_coeffs_uv = num_ar_coeffs_y + !!aom->num_y_points;
1074 ✗ print_int("chroma_scaling_from_luma", aom->chroma_scaling_from_luma);
1075 ✗ print_int("scaling_shift", aom->scaling_shift);
1076 ✗ print_int("ar_coeff_lag", aom->ar_coeff_lag);
1077 ✗ print_int("ar_coeff_shift", aom->ar_coeff_shift);
1078 ✗ print_int("grain_scale_shift", aom->grain_scale_shift);
1079 ✗ print_int("overlap_flag", aom->overlap_flag);
1080 ✗ print_int("limit_output_range", aom->limit_output_range);
1081
1082 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST);
1083
1084 ✗ if (aom->num_y_points) {
1085 ✗ avtext_print_section_header(tfc, component_names[0], SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
1086
1087 ✗ print_int("bit_depth_luma", fgp->bit_depth_luma);
1088 ✗ print_list_fmt("y_points_value", "%"PRIu8, aom->num_y_points, 1, aom->y_points[idx][0]);
1089 ✗ print_list_fmt("y_points_scaling", "%"PRIu8, aom->num_y_points, 1, aom->y_points[idx][1]);
1090 ✗ print_list_fmt("ar_coeffs_y", "%"PRId8, num_ar_coeffs_y, 1, aom->ar_coeffs_y[idx]);
1091
1092 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
1093 ✗ avtext_print_section_footer(tfc);
1094 }
1095
1096 ✗ for (unsigned uv = 0; uv < 2; uv++) {
1097 ✗ if (!aom->num_uv_points[uv] && !aom->chroma_scaling_from_luma)
1098 ✗ continue;
1099
1100 ✗ avtext_print_section_header(tfc, component_names[1 + uv], SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
1101
1102 ✗ print_int("bit_depth_chroma", fgp->bit_depth_chroma);
1103 ✗ print_list_fmt("uv_points_value", "%"PRIu8, aom->num_uv_points[uv], 1, aom->uv_points[uv][idx][0]);
1104 ✗ print_list_fmt("uv_points_scaling", "%"PRIu8, aom->num_uv_points[uv], 1, aom->uv_points[uv][idx][1]);
1105 ✗ print_list_fmt("ar_coeffs_uv", "%"PRId8, num_ar_coeffs_uv, 1, aom->ar_coeffs_uv[uv][idx]);
1106 ✗ print_int("uv_mult", aom->uv_mult[uv]);
1107 ✗ print_int("uv_mult_luma", aom->uv_mult_luma[uv]);
1108 ✗ print_int("uv_offset", aom->uv_offset[uv]);
1109
1110 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
1111 ✗ avtext_print_section_footer(tfc);
1112 }
1113
1114 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
1115 ✗ avtext_print_section_footer(tfc);
1116 ✗ break;
1117 }
1118 ✗ case AV_FILM_GRAIN_PARAMS_H274: {
1119 ✗ const AVFilmGrainH274Params *h274 = &fgp->codec.h274;
1120 ✗ print_int("model_id", h274->model_id);
1121 ✗ print_int("blending_mode_id", h274->blending_mode_id);
1122 ✗ print_int("log2_scale_factor", h274->log2_scale_factor);
1123
1124 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST);
1125
1126 ✗ for (int c = 0; c < 3; c++) {
1127 ✗ if (!h274->component_model_present[c])
1128 ✗ continue;
1129
1130 ✗ avtext_print_section_header(tfc, component_names[c], SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
1131 ✗ print_int(c ? "bit_depth_chroma" : "bit_depth_luma", c ? fgp->bit_depth_chroma : fgp->bit_depth_luma);
1132
1133 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST);
1134 ✗ for (int i = 0; i < h274->num_intensity_intervals[c]; i++) {
1135
1136 ✗ avtext_print_section_header(tfc, "Intensity interval", SECTION_ID_FRAME_SIDE_DATA_PIECE);
1137 ✗ print_int("intensity_interval_lower_bound", h274->intensity_interval_lower_bound[c][i]);
1138 ✗ print_int("intensity_interval_upper_bound", h274->intensity_interval_upper_bound[c][i]);
1139 ✗ print_list_fmt("comp_model_value", "%"PRId16, h274->num_model_values[c], 1, h274->comp_model_value[c][i][idx]);
1140
1141 // SECTION_ID_FRAME_SIDE_DATA_PIECE
1142 ✗ avtext_print_section_footer(tfc);
1143 }
1144
1145 // SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST
1146 ✗ avtext_print_section_footer(tfc);
1147
1148 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
1149 ✗ avtext_print_section_footer(tfc);
1150 }
1151
1152 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
1153 ✗ avtext_print_section_footer(tfc);
1154 ✗ break;
1155 }
1156 }
1157
1158 ✗ av_bprint_finalize(&pbuf, NULL);
1159 }
1160
1161 #define PKT_SIDE_DATA_IN_STREAM 1
1162 #define PKT_SIDE_DATA_IN_STREAM_GROUP 2
1163 #define PKT_SIDE_DATA_IN_STREAM_GROUP_STREAM 3
1164 #define PKT_SIDE_DATA_IN_PROGRAM_STREAM 4
1165
1166 1160 static void print_pkt_side_data(AVTextFormatContext *tfc,
1167 int width,
1168 int height,
1169 const AVPacketSideData *sd,
1170 int container)
1171 {
1172 1160 const char *name = av_packet_side_data_name(sd->type);
1173 1160 const SectionID section_header[] = {
1174 SECTION_ID_PACKET_SIDE_DATA,
1175 SECTION_ID_STREAM_SIDE_DATA,
1176 SECTION_ID_STREAM_GROUP_SIDE_DATA,
1177 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA,
1178 SECTION_ID_PROGRAM_STREAM_SIDE_DATA,
1179 };
1180 1160 const SectionID section_component_list[] = {
1181 SECTION_ID_PACKET_SIDE_DATA_COMPONENT_LIST,
1182 SECTION_ID_STREAM_SIDE_DATA_COMPONENT_LIST,
1183 SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT_LIST,
1184 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT_LIST,
1185 SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT_LIST,
1186 };
1187 1160 const SectionID section_component[] = {
1188 SECTION_ID_PACKET_SIDE_DATA_COMPONENT,
1189 SECTION_ID_STREAM_SIDE_DATA_COMPONENT,
1190 SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT,
1191 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT,
1192 SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT,
1193 };
1194
1195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1160 times.
1160 av_assert0(container < FF_ARRAY_ELEMS(section_header));
1196
1197 1160 avtext_print_section_header(tfc, sd, section_header[container]);
1198
1/2
✓ Branch 0 taken 1160 times.
✗ Branch 1 not taken.
1160 print_str("side_data_type", name ? name : "unknown");
1199
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1150 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
1160 if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
1200 10 print_displaymatrix(tfc, (const int32_t*)sd->data);
1201
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1134 times.
1150 } else if (sd->type == AV_PKT_DATA_STEREO3D) {
1202 16 const AVStereo3D *stereo = (AVStereo3D *)sd->data;
1203 16 print_str("type", av_stereo3d_type_name(stereo->type));
1204 16 print_int("inverted", !!(stereo->flags & AV_STEREO3D_FLAG_INVERT));
1205 16 print_str("view", av_stereo3d_view_name(stereo->view));
1206 16 print_str("primary_eye", av_stereo3d_primary_eye_name(stereo->primary_eye));
1207 16 print_int("baseline", stereo->baseline);
1208 16 print_q("horizontal_disparity_adjustment", stereo->horizontal_disparity_adjustment, '/');
1209 16 print_q("horizontal_field_of_view", stereo->horizontal_field_of_view, '/');
1210
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1130 times.
1134 } else if (sd->type == AV_PKT_DATA_SPHERICAL) {
1211 4 const AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data;
1212 4 print_str("projection", av_spherical_projection_name(spherical->projection));
1213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
1214 ✗ print_int("padding", spherical->padding);
1215
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 } else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
1216 size_t l, t, r, b;
1217 4 av_spherical_tile_bounds(spherical, width, height,
1218 &l, &t, &r, &b);
1219 4 print_int("bound_left", l);
1220 4 print_int("bound_top", t);
1221 4 print_int("bound_right", r);
1222 4 print_int("bound_bottom", b);
1223 }
1224
1225 4 print_int("yaw", (double) spherical->yaw / (1 << 16));
1226 4 print_int("pitch", (double) spherical->pitch / (1 << 16));
1227 4 print_int("roll", (double) spherical->roll / (1 << 16));
1228
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1066 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
1130 } else if (sd->type == AV_PKT_DATA_SKIP_SAMPLES && sd->size == 10) {
1229 64 print_int("skip_samples", AV_RL32(sd->data));
1230 64 print_int("discard_padding", AV_RL32(sd->data + 4));
1231 64 print_int("skip_reason", AV_RL8(sd->data + 8));
1232 64 print_int("discard_reason", AV_RL8(sd->data + 9));
1233
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1060 times.
1066 } else if (sd->type == AV_PKT_DATA_MASTERING_DISPLAY_METADATA) {
1234 6 print_mastering_display_metadata(tfc, (AVMasteringDisplayMetadata *)sd->data);
1235
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1055 times.
1060 } else if (sd->type == AV_PKT_DATA_CONTENT_LIGHT_LEVEL) {
1236 5 print_context_light_level(tfc, (AVContentLightMetadata *)sd->data);
1237
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1053 times.
1055 } else if (sd->type == AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
1238 2 print_ambient_viewing_environment(
1239 2 tfc, (const AVAmbientViewingEnvironment *)sd->data);
1240
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1051 times.
1053 } else if (sd->type == AV_PKT_DATA_DYNAMIC_HDR10_PLUS) {
1241 2 AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
1242 2 print_dynamic_hdr10_plus(tfc, metadata);
1243
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1043 times.
1051 } else if (sd->type == AV_PKT_DATA_DOVI_CONF) {
1244 8 AVDOVIDecoderConfigurationRecord *dovi = (AVDOVIDecoderConfigurationRecord *)sd->data;
1245 8 const char *comp = "unknown";
1246 8 print_int("dv_version_major", dovi->dv_version_major);
1247 8 print_int("dv_version_minor", dovi->dv_version_minor);
1248 8 print_int("dv_profile", dovi->dv_profile);
1249 8 print_int("dv_level", dovi->dv_level);
1250 8 print_int("rpu_present_flag", dovi->rpu_present_flag);
1251 8 print_int("el_present_flag", dovi->el_present_flag);
1252 8 print_int("bl_present_flag", dovi->bl_present_flag);
1253 8 print_int("dv_bl_signal_compatibility_id", dovi->dv_bl_signal_compatibility_id);
1254
1/5
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8 switch (dovi->dv_md_compression)
1255 {
1256 8 case AV_DOVI_COMPRESSION_NONE: comp = "none"; break;
1257 ✗ case AV_DOVI_COMPRESSION_LIMITED: comp = "limited"; break;
1258 ✗ case AV_DOVI_COMPRESSION_RESERVED: comp = "reserved"; break;
1259 ✗ case AV_DOVI_COMPRESSION_EXTENDED: comp = "extended"; break;
1260 }
1261 8 print_str("dv_md_compression", comp);
1262
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1040 times.
1043 } else if (sd->type == AV_PKT_DATA_AUDIO_SERVICE_TYPE) {
1263 3 enum AVAudioServiceType *t = (enum AVAudioServiceType *)sd->data;
1264 3 print_int("service_type", *t);
1265
2/2
✓ Branch 0 taken 831 times.
✓ Branch 1 taken 209 times.
1040 } else if (sd->type == AV_PKT_DATA_MPEGTS_STREAM_ID) {
1266 831 print_int("id", *sd->data);
1267
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 190 times.
209 } else if (sd->type == AV_PKT_DATA_CPB_PROPERTIES) {
1268 19 const AVCPBProperties *prop = (AVCPBProperties *)sd->data;
1269 19 print_int("max_bitrate", prop->max_bitrate);
1270 19 print_int("min_bitrate", prop->min_bitrate);
1271 19 print_int("avg_bitrate", prop->avg_bitrate);
1272 19 print_int("buffer_size", prop->buffer_size);
1273 19 print_int("vbv_delay", prop->vbv_delay);
1274
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 8 times.
190 } else if (sd->type == AV_PKT_DATA_WEBVTT_IDENTIFIER ||
1275
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 166 times.
182 sd->type == AV_PKT_DATA_WEBVTT_SETTINGS) {
1276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (do_show_data)
1277 ✗ avtext_print_data(tfc, "data", sd->data, sd->size);
1278 24 avtext_print_data_hash(tfc, "data_hash", sd->data, sd->size);
1279
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
166 } else if (sd->type == AV_PKT_DATA_FRAME_CROPPING && sd->size >= sizeof(uint32_t) * 4) {
1280 11 print_int("crop_top", AV_RL32(sd->data));
1281 11 print_int("crop_bottom", AV_RL32(sd->data + 4));
1282 11 print_int("crop_left", AV_RL32(sd->data + 8));
1283 11 print_int("crop_right", AV_RL32(sd->data + 12));
1284
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
155 } else if (sd->type == AV_PKT_DATA_AFD && sd->size > 0) {
1285 ✗ print_int("active_format", *sd->data);
1286
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 153 times.
155 } else if (sd->type == AV_PKT_DATA_EXIF) {
1287 2 print_int("size", sd->size);
1288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
153 } else if (sd->type == AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL && sd->size >= 8) {
1289 ✗ print_int("block_additional_id", AV_RB64(sd->data));
1290 ✗ if (do_show_data)
1291 ✗ avtext_print_data(tfc, "block_additional_data", sd->data + 8, sd->size - 8);
1292
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
153 } else if (sd->type == AV_PKT_DATA_GAIN_MAP_PARAMS) {
1293 1 const AVGainMapParams *gain = (AVGainMapParams *)sd->data;
1294 1 print_int("version", gain->version);
1295 1 print_int("use_base_color_space", gain->use_base_color_space);
1296 1 print_q("base_hdr_headroom", gain->base_hdr_headroom, '/');
1297 1 print_q("alternate_hdr_headroom", gain->alternate_hdr_headroom, '/');
1298 1 print_int("nb_channels", gain->nb_channels);
1299
1300
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 av_assert0(container < FF_ARRAY_ELEMS(section_component_list) &&
1301 container < FF_ARRAY_ELEMS(section_component));
1302 1 avtext_print_section_header(tfc, NULL, section_component_list[container]);
1303
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for (int c = 0; c < gain->nb_channels; c++) {
1304 1 const struct AVGainMapChannel *channel = &gain->channels[c];
1305 1 avtext_print_section_header(tfc, "Gain Map Channel", section_component[container]);
1306 1 print_q("gain_map_min", channel->gain_map_min, '/');
1307 1 print_q("gain_map_max", channel->gain_map_max, '/');
1308 1 print_q("gamma", channel->gamma, '/');
1309 1 print_q("base_offset", channel->base_offset, '/');
1310 1 print_q("alternate_offset", channel->alternate_offset, '/');
1311 1 avtext_print_section_footer(tfc);
1312 }
1313 1 avtext_print_section_footer(tfc);
1314 }
1315 1160 avtext_print_section_footer(tfc);
1316 1160 }
1317
1318 706 static void print_private_data(AVTextFormatContext *tfc, void *priv_data)
1319 {
1320 706 const AVOption *opt = NULL;
1321
2/2
✓ Branch 1 taken 5900 times.
✓ Branch 2 taken 706 times.
6606 while (opt = av_opt_next(priv_data, opt)) {
1322 uint8_t *str;
1323
2/2
✓ Branch 0 taken 5634 times.
✓ Branch 1 taken 266 times.
5900 if (!(opt->flags & AV_OPT_FLAG_EXPORT)) continue;
1324
1/2
✓ Branch 1 taken 266 times.
✗ Branch 2 not taken.
266 if (av_opt_get(priv_data, opt->name, 0, &str) >= 0) {
1325 266 print_str(opt->name, str);
1326 266 av_free(str);
1327 }
1328 }
1329 706 }
1330
1331 1052 static void print_pixel_format(AVTextFormatContext *tfc, enum AVPixelFormat pix_fmt)
1332 {
1333 1052 const char *s = av_get_pix_fmt_name(pix_fmt);
1334 enum AVPixelFormat swapped_pix_fmt;
1335
1336
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1050 times.
1052 if (!s) {
1337 2 print_str_opt("pix_fmt", "unknown");
1338
4/4
✓ Branch 0 taken 1006 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 944 times.
✓ Branch 3 taken 62 times.
2056 } else if (!do_bitexact ||
1339 1006 (swapped_pix_fmt = av_pix_fmt_swap_endianness(pix_fmt)) == AV_PIX_FMT_NONE) {
1340 988 print_str ("pix_fmt", s);
1341 } else {
1342 62 const char *s2 = av_get_pix_fmt_name(swapped_pix_fmt);
1343 char buf[128];
1344 62 size_t i = 0;
1345
1346
4/6
✓ Branch 0 taken 569 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 507 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 507 times.
✗ Branch 5 not taken.
569 while (s[i] && s[i] == s2[i] && i < sizeof(buf) - 1) {
1347 507 buf[i] = s[i];
1348 507 i++;
1349 }
1350 62 buf[i] = '\0';
1351
1352 62 print_str ("pix_fmt", buf);
1353 }
1354 1052 }
1355
1356 1052 static void print_color_range(AVTextFormatContext *tfc, enum AVColorRange color_range)
1357 {
1358 1052 const char *val = av_color_range_name(color_range);
1359
3/4
✓ Branch 0 taken 1052 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 532 times.
✓ Branch 3 taken 520 times.
1052 if (!val || color_range == AVCOL_RANGE_UNSPECIFIED) {
1360 532 print_str_opt("color_range", "unknown");
1361 } else {
1362 520 print_str("color_range", val);
1363 }
1364 1052 }
1365
1366 1052 static void print_color_space(AVTextFormatContext *tfc, enum AVColorSpace color_space)
1367 {
1368 1052 const char *val = av_color_space_name(color_space);
1369
3/4
✓ Branch 0 taken 1052 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 284 times.
1052 if (!val || color_space == AVCOL_SPC_UNSPECIFIED) {
1370 768 print_str_opt("color_space", "unknown");
1371 } else {
1372 284 print_str("color_space", val);
1373 }
1374 1052 }
1375
1376 1052 static void print_primaries(AVTextFormatContext *tfc, enum AVColorPrimaries color_primaries)
1377 {
1378 1052 const char *val = av_color_primaries_name(color_primaries);
1379
3/4
✓ Branch 0 taken 1052 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 810 times.
✓ Branch 3 taken 242 times.
1052 if (!val || color_primaries == AVCOL_PRI_UNSPECIFIED) {
1380 810 print_str_opt("color_primaries", "unknown");
1381 } else {
1382 242 print_str("color_primaries", val);
1383 }
1384 1052 }
1385
1386 1052 static void print_color_trc(AVTextFormatContext *tfc, enum AVColorTransferCharacteristic color_trc)
1387 {
1388 1052 const char *val = av_color_transfer_name(color_trc);
1389
3/4
✓ Branch 0 taken 1052 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 784 times.
✓ Branch 3 taken 268 times.
1052 if (!val || color_trc == AVCOL_TRC_UNSPECIFIED) {
1390 784 print_str_opt("color_transfer", "unknown");
1391 } else {
1392 268 print_str("color_transfer", val);
1393 }
1394 1052 }
1395
1396 1052 static void print_chroma_location(AVTextFormatContext *tfc, enum AVChromaLocation chroma_location)
1397 {
1398 1052 const char *val = av_chroma_location_name(chroma_location);
1399
3/4
✓ Branch 0 taken 1052 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 527 times.
✓ Branch 3 taken 525 times.
1052 if (!val || chroma_location == AVCHROMA_LOC_UNSPECIFIED) {
1400 527 print_str_opt("chroma_location", "unspecified");
1401 } else {
1402 525 print_str("chroma_location", val);
1403 }
1404 1052 }
1405
1406 864 static void print_alpha_mode(AVTextFormatContext *tfc, enum AVAlphaMode alpha_mode)
1407 {
1408 864 const char *val = av_alpha_mode_name(alpha_mode);
1409
3/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863 times.
✓ Branch 3 taken 1 times.
864 if (!val || alpha_mode == AVALPHA_MODE_UNSPECIFIED) {
1410 863 print_str_opt("alpha_mode", "unspecified");
1411 } else {
1412 1 print_str("alpha_mode", val);
1413 }
1414 864 }
1415
1416 7464 static void clear_log(int need_lock)
1417 {
1418 int i;
1419
1420
1/2
✓ Branch 0 taken 7464 times.
✗ Branch 1 not taken.
7464 if (need_lock)
1421 7464 ff_mutex_lock(&log_mutex);
1422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7464 times.
7464 for (i=0; i<log_buffer_size; i++) {
1423 ✗ av_freep(&log_buffer[i].context_name);
1424 ✗ av_freep(&log_buffer[i].parent_name);
1425 ✗ av_freep(&log_buffer[i].log_message);
1426 }
1427 7464 log_buffer_size = 0;
1428
1/2
✓ Branch 0 taken 7464 times.
✗ Branch 1 not taken.
7464 if(need_lock)
1429 7464 ff_mutex_unlock(&log_mutex);
1430 7464 }
1431
1432 ✗ static int show_log(AVTextFormatContext *tfc, int section_ids, int section_id, int log_level)
1433 {
1434 int i;
1435 ✗ ff_mutex_lock(&log_mutex);
1436 ✗ if (!log_buffer_size) {
1437 ✗ ff_mutex_unlock(&log_mutex);
1438 ✗ return 0;
1439 }
1440 ✗ avtext_print_section_header(tfc, NULL, section_ids);
1441
1442 ✗ for (i=0; i<log_buffer_size; i++) {
1443 ✗ if (log_buffer[i].log_level <= log_level) {
1444 ✗ avtext_print_section_header(tfc, NULL, section_id);
1445 ✗ print_str("context", log_buffer[i].context_name);
1446 ✗ print_int("level", log_buffer[i].log_level);
1447 ✗ print_int("category", log_buffer[i].category);
1448 ✗ if (log_buffer[i].parent_name) {
1449 ✗ print_str("parent_context", log_buffer[i].parent_name);
1450 ✗ print_int("parent_category", log_buffer[i].parent_category);
1451 } else {
1452 ✗ print_str_opt("parent_context", "N/A");
1453 ✗ print_str_opt("parent_category", "N/A");
1454 }
1455 ✗ print_str("message", log_buffer[i].log_message);
1456 ✗ avtext_print_section_footer(tfc);
1457 }
1458 }
1459 ✗ clear_log(0);
1460 ✗ ff_mutex_unlock(&log_mutex);
1461
1462 ✗ avtext_print_section_footer(tfc);
1463
1464 ✗ return 0;
1465 }
1466
1467 6787 static void show_packet(AVTextFormatContext *tfc, InputFile *ifile, AVPacket *pkt, int packet_idx)
1468 {
1469 6787 AVStream *st = ifile->streams[pkt->stream_index].st;
1470 AVBPrint pbuf;
1471 const char *s;
1472
1473 6787 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
1474
1475 6787 avtext_print_section_header(tfc, NULL, SECTION_ID_PACKET);
1476
1477 6787 s = av_get_media_type_string(st->codecpar->codec_type);
1478
1/2
✓ Branch 0 taken 6787 times.
✗ Branch 1 not taken.
6787 if (s) print_str ("codec_type", s);
1479 ✗ else print_str_opt("codec_type", "unknown");
1480 6787 print_int("stream_index", pkt->stream_index);
1481 6787 print_ts ("pts", pkt->pts);
1482 6787 print_time("pts_time", pkt->pts, &st->time_base);
1483 6787 print_ts ("dts", pkt->dts);
1484 6787 print_time("dts_time", pkt->dts, &st->time_base);
1485 6787 print_duration_ts("duration", pkt->duration);
1486 6787 print_duration_time("duration_time", pkt->duration, &st->time_base);
1487 6787 print_int_fmt("size", pkt->size, AV_TEXTFORMAT_VALUE_FMT_BYTE, unit_byte_str);
1488
2/2
✓ Branch 0 taken 6671 times.
✓ Branch 1 taken 116 times.
6787 if (pkt->pos != -1) print_fmt ("pos", "%"PRId64, pkt->pos);
1489 116 else print_str_opt("pos", "N/A");
1490
6/6
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 6782 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6781 times.
✓ Branch 5 taken 5683 times.
✓ Branch 6 taken 1104 times.
6787 print_fmt("flags", "%c%c%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_',
1491 pkt->flags & AV_PKT_FLAG_DISCARD ? 'D' : '_',
1492 pkt->flags & AV_PKT_FLAG_CORRUPT ? 'C' : '_');
1493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
6787 if (do_show_data)
1494 ✗ avtext_print_data(tfc, "data", pkt->data, pkt->size);
1495 6787 avtext_print_data_hash(tfc, "data_hash", pkt->data, pkt->size);
1496
1497
2/2
✓ Branch 0 taken 1059 times.
✓ Branch 1 taken 5728 times.
6787 if (pkt->side_data_elems) {
1498 size_t size;
1499 const uint8_t *side_metadata;
1500
1501 1059 side_metadata = av_packet_get_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, &size);
1502
4/6
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 923 times.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 136 times.
✗ Branch 5 not taken.
1059 if (side_metadata && size && do_show_packet_tags) {
1503 136 AVDictionary *dict = NULL;
1504
1/2
✓ Branch 1 taken 136 times.
✗ Branch 2 not taken.
136 if (av_packet_unpack_dictionary(side_metadata, size, &dict) >= 0)
1505 136 show_tags(tfc, dict, SECTION_ID_PACKET_TAGS);
1506 136 av_dict_free(&dict);
1507 }
1508
1509 1059 avtext_print_section_header(tfc, NULL, SECTION_ID_PACKET_SIDE_DATA_LIST);
1510
2/2
✓ Branch 0 taken 1061 times.
✓ Branch 1 taken 1059 times.
2120 for (int i = 0; i < pkt->side_data_elems; i++) {
1511 1061 print_pkt_side_data(tfc, st->codecpar->width, st->codecpar->height, &pkt->side_data[i], 0);
1512 }
1513 1059 avtext_print_section_footer(tfc);
1514 }
1515
1516 6787 avtext_print_section_footer(tfc);
1517
1518 6787 av_bprint_finalize(&pbuf, NULL);
1519 6787 fflush(stdout);
1520 6787 }
1521
1522 ✗ static void show_subtitle(AVTextFormatContext *tfc, AVSubtitle *sub, AVStream *stream,
1523 AVFormatContext *fmt_ctx)
1524 {
1525 AVBPrint pbuf;
1526
1527 ✗ av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
1528
1529 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_SUBTITLE);
1530
1531 ✗ print_str ("media_type", "subtitle");
1532 ✗ print_ts ("pts", sub->pts);
1533 ✗ print_time("pts_time", sub->pts, &AV_TIME_BASE_Q);
1534 ✗ print_int ("format", sub->format);
1535 ✗ print_int ("start_display_time", sub->start_display_time);
1536 ✗ print_int ("end_display_time", sub->end_display_time);
1537 ✗ print_int ("num_rects", sub->num_rects);
1538
1539 ✗ avtext_print_section_footer(tfc);
1540
1541 ✗ av_bprint_finalize(&pbuf, NULL);
1542 ✗ fflush(stdout);
1543 ✗ }
1544
1545 static void print_iamf_param_definition(AVTextFormatContext *tfc, const char *name,
1546 const AVIAMFParamDefinition *param, SectionID section_id);
1547
1548 311 static void print_frame_side_data(AVTextFormatContext *tfc,
1549 const AVFrame *frame,
1550 const AVStream *stream)
1551 {
1552 311 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_LIST);
1553
1554
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 311 times.
775 for (int i = 0; i < frame->nb_side_data; i++) {
1555 464 const AVFrameSideData *sd = frame->side_data[i];
1556 const char *name;
1557
1558 464 avtext_print_section_header(tfc, sd, SECTION_ID_FRAME_SIDE_DATA);
1559 464 name = av_frame_side_data_name(sd->type);
1560
1/2
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
464 print_str("side_data_type", name ? name : "unknown");
1561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 464 times.
464 if (sd->type == AV_FRAME_DATA_DOWNMIX_INFO) {
1562 ✗ print_downmix_info(tfc, (AVDownmixInfo *)sd->data);
1563
3/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
464 } else if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
1564 92 print_displaymatrix(tfc, (const int32_t*)sd->data);
1565
3/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 305 times.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
372 } else if (sd->type == AV_FRAME_DATA_AFD && sd->size > 0) {
1566 67 print_int("active_format", *sd->data);
1567
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
305 } else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) {
1568 char tcbuf[AV_TIMECODE_STR_SIZE];
1569 ✗ av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));
1570 ✗ print_str("timecode", tcbuf);
1571
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
328 } else if (sd->type == AV_FRAME_DATA_S12M_TIMECODE && sd->size == 16) {
1572 23 uint32_t *tc = (uint32_t*)sd->data;
1573 23 int m = FFMIN(tc[0],3);
1574 23 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST);
1575
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 23 times.
48 for (int j = 1; j <= m ; j++) {
1576 char tcbuf[AV_TIMECODE_STR_SIZE];
1577 25 av_timecode_make_smpte_tc_string2(tcbuf, stream->avg_frame_rate, tc[j], 0, 0);
1578 25 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_TIMECODE);
1579 25 print_str("value", tcbuf);
1580 25 avtext_print_section_footer(tfc);
1581 }
1582 23 avtext_print_section_footer(tfc);
1583
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 258 times.
282 } else if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) {
1584 24 print_mastering_display_metadata(tfc, (AVMasteringDisplayMetadata *)sd->data);
1585
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 256 times.
258 } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_PLUS) {
1586 2 AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
1587 2 print_dynamic_hdr10_plus(tfc, metadata);
1588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
256 } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_SMPTE_2094_APP5) {
1589 ✗ AVDynamicHDRSmpte2094App5 *metadata = (AVDynamicHDRSmpte2094App5 *)sd->data;
1590 ✗ print_dynamic_hdr_smpte2094_app5(tfc, metadata);
1591
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 232 times.
256 } else if (sd->type == AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) {
1592 24 print_context_light_level(tfc, (AVContentLightMetadata *)sd->data);
1593
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 228 times.
232 } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
1594 4 const AVDictionaryEntry *tag = av_dict_get(sd->metadata, "name", NULL, AV_DICT_MATCH_CASE);
1595
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if (tag)
1596 2 print_str(tag->key, tag->value);
1597 4 print_int("size", sd->size);
1598
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 226 times.
228 } else if (sd->type == AV_FRAME_DATA_DOVI_METADATA) {
1599 2 print_dovi_metadata(tfc, (const AVDOVIMetadata *)sd->data);
1600
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 225 times.
226 } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) {
1601 1 AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data;
1602 1 print_dynamic_hdr_vivid(tfc, metadata);
1603
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 223 times.
225 } else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
1604 2 print_ambient_viewing_environment(tfc, (const AVAmbientViewingEnvironment *)sd->data);
1605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223 times.
223 } else if (sd->type == AV_FRAME_DATA_FILM_GRAIN_PARAMS) {
1606 ✗ AVFilmGrainParams *fgp = (AVFilmGrainParams *)sd->data;
1607 ✗ print_film_grain_params(tfc, fgp);
1608
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 222 times.
223 } else if (sd->type == AV_FRAME_DATA_GAIN_MAP_PARAMS &&
1609
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 sd->size >= sizeof(AVGainMapParams)) {
1610 1 print_gain_map_params(tfc, (const AVGainMapParams *)sd->data);
1611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 } else if (sd->type == AV_FRAME_DATA_VIEW_ID) {
1612 ✗ print_int("view_id", *(int*)sd->data);
1613
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 213 times.
222 } else if (sd->type == AV_FRAME_DATA_EXIF) {
1614 9 print_int("size", sd->size);
1615
1/2
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
213 } else if (sd->type == AV_FRAME_DATA_IAMF_MIX_GAIN_PARAM ||
1616
1/2
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
213 sd->type == AV_FRAME_DATA_IAMF_DEMIXING_INFO_PARAM ||
1617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 213 times.
213 sd->type == AV_FRAME_DATA_IAMF_RECON_GAIN_INFO_PARAM) {
1618 ✗ const AVIAMFParamDefinition *param = (AVIAMFParamDefinition *)sd->data;
1619 ✗ print_iamf_param_definition(tfc, NULL, param, SECTION_ID_FRAME_SIDE_DATA);
1620 }
1621 464 avtext_print_section_footer(tfc);
1622 }
1623 311 avtext_print_section_footer(tfc);
1624 311 }
1625
1626 3683 static void show_frame(AVTextFormatContext *tfc, AVFrame *frame, AVStream *stream,
1627 AVFormatContext *fmt_ctx)
1628 {
1629
1/2
✓ Branch 0 taken 3683 times.
✗ Branch 1 not taken.
3683 FrameData *fd = frame->opaque_ref ? (FrameData*)frame->opaque_ref->data : NULL;
1630 AVBPrint pbuf;
1631 char val_str[128];
1632 const char *s;
1633
1634 3683 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
1635
1636 3683 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME);
1637
1638 3683 s = av_get_media_type_string(stream->codecpar->codec_type);
1639
1/2
✓ Branch 0 taken 3683 times.
✗ Branch 1 not taken.
3683 if (s) print_str ("media_type", s);
1640 ✗ else print_str_opt("media_type", "unknown");
1641 3683 print_int("stream_index", stream->index);
1642 3683 print_int("key_frame", !!(frame->flags & AV_FRAME_FLAG_KEY));
1643 3683 print_ts ("pts", frame->pts);
1644 3683 print_time("pts_time", frame->pts, &stream->time_base);
1645 3683 print_ts ("pkt_dts", frame->pkt_dts);
1646 3683 print_time("pkt_dts_time", frame->pkt_dts, &stream->time_base);
1647 3683 print_ts ("best_effort_timestamp", frame->best_effort_timestamp);
1648 3683 print_time("best_effort_timestamp_time", frame->best_effort_timestamp, &stream->time_base);
1649 3683 print_duration_ts ("duration", frame->duration);
1650 3683 print_duration_time("duration_time", frame->duration, &stream->time_base);
1651
3/4
✓ Branch 0 taken 3683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2986 times.
✓ Branch 3 taken 697 times.
3683 if (fd && fd->pkt_pos != -1) print_fmt ("pkt_pos", "%"PRId64, fd->pkt_pos);
1652 697 else print_str_opt("pkt_pos", "N/A");
1653
2/4
✓ Branch 0 taken 3683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3683 times.
✗ Branch 3 not taken.
3683 if (fd && fd->pkt_size != -1) print_int_fmt("pkt_size", fd->pkt_size, AV_TEXTFORMAT_VALUE_FMT_BYTE, unit_byte_str);
1654 ✗ else print_str_opt("pkt_size", "N/A");
1655
1656
2/3
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 2819 times.
✗ Branch 2 not taken.
3683 switch (stream->codecpar->codec_type) {
1657 AVRational sar;
1658
1659 864 case AVMEDIA_TYPE_VIDEO:
1660 864 print_int("width", frame->width);
1661 864 print_int("height", frame->height);
1662 864 print_int("crop_top", frame->crop_top);
1663 864 print_int("crop_bottom", frame->crop_bottom);
1664 864 print_int("crop_left", frame->crop_left);
1665 864 print_int("crop_right", frame->crop_right);
1666 864 print_pixel_format(tfc, frame->format);
1667 864 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, frame);
1668
2/2
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 203 times.
864 if (sar.num) {
1669 661 print_q("sample_aspect_ratio", sar, ':');
1670 } else {
1671 203 print_str_opt("sample_aspect_ratio", "N/A");
1672 }
1673 864 print_fmt("pict_type", "%c", av_get_picture_type_char(frame->pict_type));
1674 864 print_int("interlaced_frame", !!(frame->flags & AV_FRAME_FLAG_INTERLACED));
1675 864 print_int("top_field_first", !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
1676 864 print_int("lossless", !!(frame->flags & AV_FRAME_FLAG_LOSSLESS));
1677 864 print_int("repeat_pict", frame->repeat_pict);
1678
1679 864 print_color_range(tfc, frame->color_range);
1680 864 print_color_space(tfc, frame->colorspace);
1681 864 print_primaries(tfc, frame->color_primaries);
1682 864 print_color_trc(tfc, frame->color_trc);
1683 864 print_chroma_location(tfc, frame->chroma_location);
1684 864 print_alpha_mode(tfc, frame->alpha_mode);
1685 864 break;
1686
1687 2819 case AVMEDIA_TYPE_AUDIO:
1688 2819 s = av_get_sample_fmt_name(frame->format);
1689
1/2
✓ Branch 0 taken 2819 times.
✗ Branch 1 not taken.
2819 if (s) print_str ("sample_fmt", s);
1690 ✗ else print_str_opt("sample_fmt", "unknown");
1691 2819 print_int("nb_samples", frame->nb_samples);
1692 2819 print_int("channels", frame->ch_layout.nb_channels);
1693
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 223 times.
2819 if (frame->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
1694 2596 av_channel_layout_describe(&frame->ch_layout, val_str, sizeof(val_str));
1695 2596 print_str ("channel_layout", val_str);
1696 } else
1697 223 print_str_opt("channel_layout", "unknown");
1698 2819 break;
1699 }
1700
2/2
✓ Branch 0 taken 1532 times.
✓ Branch 1 taken 2151 times.
3683 if (do_show_frame_tags)
1701 1532 show_tags(tfc, frame->metadata, SECTION_ID_FRAME_TAGS);
1702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3683 times.
3683 if (do_show_log)
1703 ✗ show_log(tfc, SECTION_ID_FRAME_LOGS, SECTION_ID_FRAME_LOG, do_show_log);
1704
2/2
✓ Branch 0 taken 311 times.
✓ Branch 1 taken 3372 times.
3683 if (frame->nb_side_data)
1705 311 print_frame_side_data(tfc, frame, stream);
1706
1707 3683 avtext_print_section_footer(tfc);
1708
1709 3683 av_bprint_finalize(&pbuf, NULL);
1710 3683 fflush(stdout);
1711 3683 }
1712
1713 7464 static av_always_inline int process_frame(AVTextFormatContext *tfc,
1714 InputFile *ifile,
1715 AVFrame *frame, const AVPacket *pkt,
1716 int *packet_new)
1717 {
1718 7464 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
1719 7464 AVCodecContext *dec_ctx = ifile->streams[pkt->stream_index].dec_ctx;
1720 7464 AVCodecParameters *par = ifile->streams[pkt->stream_index].st->codecpar;
1721 AVSubtitle sub;
1722 7464 int ret = 0, got_frame = 0;
1723
1724 7464 clear_log(1);
1725
2/2
✓ Branch 0 taken 7458 times.
✓ Branch 1 taken 6 times.
7464 if (dec_ctx) {
1726
1/3
✓ Branch 0 taken 7458 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7458 switch (par->codec_type) {
1727 7458 case AVMEDIA_TYPE_VIDEO:
1728 case AVMEDIA_TYPE_AUDIO:
1729
2/2
✓ Branch 0 taken 3825 times.
✓ Branch 1 taken 3633 times.
7458 if (*packet_new) {
1730 3825 ret = avcodec_send_packet(dec_ctx, pkt);
1731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3825 times.
3825 if (ret == AVERROR(EAGAIN)) {
1732 ✗ ret = 0;
1733
4/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 3773 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 2 times.
3825 } else if (ret >= 0 || ret == AVERROR_EOF) {
1734 3823 ret = 0;
1735 3823 *packet_new = 0;
1736 }
1737 }
1738
2/2
✓ Branch 0 taken 7456 times.
✓ Branch 1 taken 2 times.
7458 if (ret >= 0) {
1739 7456 ret = avcodec_receive_frame(dec_ctx, frame);
1740
2/2
✓ Branch 0 taken 3683 times.
✓ Branch 1 taken 3773 times.
7456 if (ret >= 0) {
1741 3683 got_frame = 1;
1742
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 3675 times.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
3773 } else if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
1743 3773 ret = 0;
1744 }
1745 }
1746 7458 break;
1747
1748 ✗ case AVMEDIA_TYPE_SUBTITLE:
1749 ✗ if (*packet_new)
1750 ✗ ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_frame, pkt);
1751 ✗ *packet_new = 0;
1752 ✗ break;
1753 ✗ default:
1754 ✗ *packet_new = 0;
1755 }
1756 } else {
1757 6 *packet_new = 0;
1758 }
1759
1760
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7462 times.
7464 if (ret < 0)
1761 2 return ret;
1762
2/2
✓ Branch 0 taken 3683 times.
✓ Branch 1 taken 3779 times.
7462 if (got_frame) {
1763 3683 int is_sub = (par->codec_type == AVMEDIA_TYPE_SUBTITLE);
1764 3683 nb_streams_frames[pkt->stream_index]++;
1765
1/2
✓ Branch 0 taken 3683 times.
✗ Branch 1 not taken.
3683 if (do_show_frames)
1766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3683 times.
3683 if (is_sub)
1767 ✗ show_subtitle(tfc, &sub, ifile->streams[pkt->stream_index].st, fmt_ctx);
1768 else
1769 3683 show_frame(tfc, frame, ifile->streams[pkt->stream_index].st, fmt_ctx);
1770
1771
2/4
✓ Branch 0 taken 3683 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3683 times.
3683 if (!is_sub && do_analyze_frames) {
1772 ✗ for (int i = 0; i < frame->nb_side_data; i++) {
1773 ✗ if (frame->side_data[i]->type == AV_FRAME_DATA_A53_CC)
1774 ✗ streams_with_closed_captions[pkt->stream_index] = 1;
1775 ✗ else if (frame->side_data[i]->type == AV_FRAME_DATA_FILM_GRAIN_PARAMS)
1776 ✗ streams_with_film_grain[pkt->stream_index] = 1;
1777 }
1778 }
1779
1780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3683 times.
3683 if (is_sub)
1781 ✗ avsubtitle_free(&sub);
1782 }
1783
3/4
✓ Branch 0 taken 3779 times.
✓ Branch 1 taken 3683 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3779 times.
7462 return got_frame || *packet_new;
1784 }
1785
1786 201 static void log_read_interval(const ReadInterval *interval, void *log_ctx, int log_level)
1787 {
1788 201 av_log(log_ctx, log_level, "id:%d", interval->id);
1789
1790
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 161 times.
201 if (interval->has_start) {
1791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 av_log(log_ctx, log_level, " start:%s%s", interval->start_is_offset ? "+" : "",
1792 40 av_ts2timestr(interval->start, &AV_TIME_BASE_Q));
1793 } else {
1794 161 av_log(log_ctx, log_level, " start:N/A");
1795 }
1796
1797
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 147 times.
201 if (interval->has_end) {
1798
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
54 av_log(log_ctx, log_level, " end:%s", interval->end_is_offset ? "+" : "");
1799
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
54 if (interval->duration_frames)
1800 48 av_log(log_ctx, log_level, "#%"PRId64, interval->end);
1801 else
1802 6 av_log(log_ctx, log_level, "%s", av_ts2timestr(interval->end, &AV_TIME_BASE_Q));
1803 } else {
1804 147 av_log(log_ctx, log_level, " end:N/A");
1805 }
1806
1807 201 av_log(log_ctx, log_level, "\n");
1808 201 }
1809
1810 174 static int read_interval_packets(AVTextFormatContext *tfc, InputFile *ifile,
1811 const ReadInterval *interval, int64_t *cur_ts)
1812 {
1813 174 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
1814 174 AVPacket *pkt = NULL;
1815 174 AVFrame *frame = NULL;
1816 174 int ret = 0, i = 0, frame_count = 0;
1817 174 int64_t start = -INT64_MAX, end = interval->end;
1818
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 24 times.
174 int has_start = 0, has_end = interval->has_end && !interval->end_is_offset;
1819
1820 174 av_log(NULL, AV_LOG_VERBOSE, "Processing read interval ");
1821 174 log_read_interval(interval, NULL, AV_LOG_VERBOSE);
1822
1823
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 154 times.
174 if (interval->has_start) {
1824 int64_t target;
1825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (interval->start_is_offset) {
1826 ✗ if (*cur_ts == AV_NOPTS_VALUE) {
1827 ✗ av_log(NULL, AV_LOG_ERROR,
1828 "Could not seek to relative position since current "
1829 "timestamp is not defined\n");
1830 ✗ ret = AVERROR(EINVAL);
1831 ✗ goto end;
1832 }
1833 ✗ target = *cur_ts + interval->start;
1834 } else {
1835 20 target = interval->start;
1836 }
1837
1838 20 av_log(NULL, AV_LOG_VERBOSE, "Seeking to read interval start point %s\n",
1839 20 av_ts2timestr(target, &AV_TIME_BASE_Q));
1840
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
20 if ((ret = avformat_seek_file(fmt_ctx, -1, -INT64_MAX, target, INT64_MAX, 0)) < 0) {
1841 ✗ av_log(NULL, AV_LOG_ERROR, "Could not seek to position %"PRId64": %s\n",
1842 ✗ interval->start, av_err2str(ret));
1843 ✗ goto end;
1844 }
1845 }
1846
1847 174 frame = av_frame_alloc();
1848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if (!frame) {
1849 ✗ ret = AVERROR(ENOMEM);
1850 ✗ goto end;
1851 }
1852 174 pkt = av_packet_alloc();
1853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if (!pkt) {
1854 ✗ ret = AVERROR(ENOMEM);
1855 ✗ goto end;
1856 }
1857
2/2
✓ Branch 1 taken 10301 times.
✓ Branch 2 taken 149 times.
10450 while (!av_read_frame(fmt_ctx, pkt)) {
1858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10301 times.
10301 if (fmt_ctx->nb_streams > nb_streams) {
1859 ✗ REALLOCZ_ARRAY_STREAM(nb_streams_frames, nb_streams, fmt_ctx->nb_streams);
1860 ✗ REALLOCZ_ARRAY_STREAM(nb_streams_packets, nb_streams, fmt_ctx->nb_streams);
1861 ✗ REALLOCZ_ARRAY_STREAM(selected_streams, nb_streams, fmt_ctx->nb_streams);
1862 ✗ REALLOCZ_ARRAY_STREAM(streams_with_closed_captions, nb_streams, fmt_ctx->nb_streams);
1863 ✗ REALLOCZ_ARRAY_STREAM(streams_with_film_grain, nb_streams, fmt_ctx->nb_streams);
1864 ✗ nb_streams = fmt_ctx->nb_streams;
1865 }
1866
2/2
✓ Branch 0 taken 10214 times.
✓ Branch 1 taken 87 times.
10301 if (selected_streams[pkt->stream_index]) {
1867 10214 AVRational tb = ifile->streams[pkt->stream_index].st->time_base;
1868
2/2
✓ Branch 0 taken 9951 times.
✓ Branch 1 taken 263 times.
10214 int64_t pts = pkt->pts != AV_NOPTS_VALUE ? pkt->pts : pkt->dts;
1869
1870
2/2
✓ Branch 0 taken 9951 times.
✓ Branch 1 taken 263 times.
10214 if (pts != AV_NOPTS_VALUE)
1871 9951 *cur_ts = av_rescale_q(pts, tb, AV_TIME_BASE_Q);
1872
1873
4/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 9790 times.
✓ Branch 2 taken 162 times.
✓ Branch 3 taken 262 times.
10214 if (!has_start && *cur_ts != AV_NOPTS_VALUE) {
1874 162 start = *cur_ts;
1875 162 has_start = 1;
1876 }
1877
1878
6/6
✓ Branch 0 taken 9952 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 86 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 9843 times.
10214 if (has_start && !has_end && interval->end_is_offset) {
1879 23 end = start + interval->end;
1880 23 has_end = 1;
1881 }
1882
1883
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 10116 times.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
10214 if (interval->end_is_offset && interval->duration_frames) {
1884
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 76 times.
98 if (frame_count >= interval->end)
1885 25 break;
1886
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 10102 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 11 times.
10116 } else if (has_end && *cur_ts != AV_NOPTS_VALUE && *cur_ts >= end) {
1887 3 break;
1888 }
1889
1890 10189 frame_count++;
1891
2/2
✓ Branch 0 taken 6787 times.
✓ Branch 1 taken 3402 times.
10189 if (do_read_packets) {
1892
1/2
✓ Branch 0 taken 6787 times.
✗ Branch 1 not taken.
6787 if (do_show_packets)
1893 6787 show_packet(tfc, ifile, pkt, i++);
1894 6787 nb_streams_packets[pkt->stream_index]++;
1895 }
1896
2/2
✓ Branch 0 taken 3677 times.
✓ Branch 1 taken 6512 times.
10189 if (do_read_frames) {
1897 3677 int packet_new = 1;
1898 FrameData *fd;
1899
1900 3677 pkt->opaque_ref = av_buffer_allocz(sizeof(*fd));
1901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3677 times.
3677 if (!pkt->opaque_ref) {
1902 ✗ ret = AVERROR(ENOMEM);
1903 ✗ goto end;
1904 }
1905 3677 fd = (FrameData*)pkt->opaque_ref->data;
1906 3677 fd->pkt_pos = pkt->pos;
1907 3677 fd->pkt_size = pkt->size;
1908
1909
2/2
✓ Branch 1 taken 3633 times.
✓ Branch 2 taken 3677 times.
7310 while (process_frame(tfc, ifile, frame, pkt, &packet_new) > 0);
1910 }
1911 }
1912 10276 av_packet_unref(pkt);
1913 }
1914 174 av_packet_unref(pkt);
1915 //Flush remaining frames that are cached in the decoder
1916
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 174 times.
402 for (int i = 0; i < ifile->nb_streams; i++) {
1917 228 pkt->stream_index = i;
1918
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 124 times.
228 if (do_read_frames) {
1919
2/2
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 104 times.
154 while (process_frame(tfc, ifile, frame, pkt, &(int){1}) > 0);
1920 }
1921 }
1922
1923 174 end:
1924 174 av_frame_free(&frame);
1925 174 av_packet_free(&pkt);
1926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if (ret < 0) {
1927 ✗ av_log(NULL, AV_LOG_ERROR, "Could not read packets in interval ");
1928 ✗ log_read_interval(interval, NULL, AV_LOG_ERROR);
1929 }
1930 174 return ret;
1931 }
1932
1933 ✗ static void flush_buffers(InputFile *ifile)
1934 {
1935 int i;
1936
1937 ✗ if (!do_read_frames)
1938 ✗ return;
1939 ✗ for (i = 0; i < ifile->nb_streams; i++) {
1940 ✗ if (ifile->streams[i].dec_ctx)
1941 ✗ avcodec_flush_buffers(ifile->streams[i].dec_ctx);
1942 }
1943 }
1944
1945 174 static int read_packets(AVTextFormatContext *tfc, InputFile *ifile)
1946 {
1947 174 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
1948 174 int ret = 0;
1949 174 int64_t cur_ts = fmt_ctx->start_time;
1950
1951
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 27 times.
174 if (read_intervals_nb == 0) {
1952 147 ReadInterval interval = (ReadInterval) { .has_start = 0, .has_end = 0 };
1953 147 ret = read_interval_packets(tfc, ifile, &interval, &cur_ts);
1954 } else {
1955
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 for (int i = 0; i < read_intervals_nb; i++) {
1956 /* flushing buffers can reset parts of the private context which may be
1957 * read by show_streams(), so only flush between each read_interval */
1958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (i)
1959 ✗ flush_buffers(ifile);
1960 27 ret = read_interval_packets(tfc, ifile, &read_intervals[i], &cur_ts);
1961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (ret < 0)
1962 ✗ break;
1963 }
1964 }
1965
1966 174 return ret;
1967 }
1968
1969 349 static void print_dispositions(AVTextFormatContext *tfc, uint32_t disposition, SectionID section_id)
1970 {
1971 349 avtext_print_section_header(tfc, NULL, section_id);
1972
2/2
✓ Branch 0 taken 11168 times.
✓ Branch 1 taken 349 times.
11517 for (unsigned i = 0; i < sizeof(disposition) * CHAR_BIT; i++) {
1973 11168 const char *disposition_str = av_disposition_to_string(1U << i);
1974
1975
2/2
✓ Branch 0 taken 6631 times.
✓ Branch 1 taken 4537 times.
11168 if (disposition_str)
1976 6631 print_int(disposition_str, !!(disposition & (1U << i)));
1977 }
1978 349 avtext_print_section_footer(tfc);
1979 349 }
1980
1981 #define IN_PROGRAM 1
1982 #define IN_STREAM_GROUP 2
1983
1984 610 static int show_stream(AVTextFormatContext *tfc, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int container)
1985 {
1986 610 AVStream *stream = ist->st;
1987 AVCodecParameters *par;
1988 AVCodecContext *dec_ctx;
1989 char val_str[128];
1990 const char *s;
1991 AVRational sar, dar;
1992 AVBPrint pbuf;
1993 const AVCodecDescriptor *cd;
1994 610 const SectionID section_header[] = {
1995 SECTION_ID_STREAM,
1996 SECTION_ID_PROGRAM_STREAM,
1997 SECTION_ID_STREAM_GROUP_STREAM,
1998 };
1999 610 const SectionID section_disposition[] = {
2000 SECTION_ID_STREAM_DISPOSITION,
2001 SECTION_ID_PROGRAM_STREAM_DISPOSITION,
2002 SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION,
2003 };
2004 610 const SectionID section_tags[] = {
2005 SECTION_ID_STREAM_TAGS,
2006 SECTION_ID_PROGRAM_STREAM_TAGS,
2007 SECTION_ID_STREAM_GROUP_STREAM_TAGS,
2008 };
2009 610 const SectionID section_side_data[] = {
2010 SECTION_ID_STREAM_SIDE_DATA_LIST,
2011 SECTION_ID_PROGRAM_STREAM_SIDE_DATA_LIST,
2012 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_LIST,
2013 };
2014 610 const SectionID container_side_data[] = {
2015 PKT_SIDE_DATA_IN_STREAM,
2016 PKT_SIDE_DATA_IN_PROGRAM_STREAM,
2017 PKT_SIDE_DATA_IN_STREAM_GROUP_STREAM,
2018 };
2019 610 int ret = 0;
2020 610 const char *profile = NULL;
2021
2022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 av_assert0(container < FF_ARRAY_ELEMS(section_header));
2023
2024 610 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
2025
2026 610 avtext_print_section_header(tfc, NULL, section_header[container]);
2027
2028 610 print_int("index", stream->index);
2029
2030 610 par = stream->codecpar;
2031 610 dec_ctx = ist->dec_ctx;
2032
2/2
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 3 times.
610 if (cd = avcodec_descriptor_get(par->codec_id)) {
2033 607 print_str("codec_name", cd->name);
2034
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 555 times.
607 if (!do_bitexact) {
2035
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 print_str("codec_long_name",
2036 cd->long_name ? cd->long_name : "unknown");
2037 }
2038 } else {
2039 3 print_str_opt("codec_name", "unknown");
2040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!do_bitexact) {
2041 ✗ print_str_opt("codec_long_name", "unknown");
2042 }
2043 }
2044
2045
4/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 558 times.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 25 times.
610 if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile)))
2046 27 print_str("profile", profile);
2047 else {
2048
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 398 times.
583 if (par->profile != AV_PROFILE_UNKNOWN) {
2049 char profile_num[12];
2050 185 snprintf(profile_num, sizeof(profile_num), "%d", par->profile);
2051 185 print_str("profile", profile_num);
2052 } else
2053 398 print_str_opt("profile", "unknown");
2054 }
2055
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 485 times.
610 if (par->level != AV_LEVEL_UNKNOWN)
2056 125 print_int("level", par->level);
2057 else
2058 485 print_int_opt("level", par->level);
2059
2060 610 s = av_get_media_type_string(par->codec_type);
2061
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if (s) print_str ("codec_type", s);
2062 ✗ else print_str_opt("codec_type", "unknown");
2063
2064 /* print AVI/FourCC tag */
2065 610 print_str("codec_tag_string", av_fourcc2str(par->codec_tag));
2066 610 print_fmt("codec_tag", "0x%04"PRIx32, par->codec_tag);
2067
2068 610 av_bprint_clear(&pbuf);
2069
2/2
✓ Branch 1 taken 316 times.
✓ Branch 2 taken 294 times.
610 if (!av_mime_codec_str(par, stream->avg_frame_rate, &pbuf))
2070 316 print_str("mime_codec_string", pbuf.str);
2071
2072
4/4
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 10 times.
610 switch (par->codec_type) {
2073 188 case AVMEDIA_TYPE_VIDEO:
2074 188 print_int("width", par->width);
2075 188 print_int("height", par->height);
2076
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 7 times.
188 if (dec_ctx) {
2077 181 print_int("coded_width", dec_ctx->coded_width);
2078 181 print_int("coded_height", dec_ctx->coded_height);
2079
2080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 181 times.
181 if (do_analyze_frames) {
2081 ✗ print_int("closed_captions", streams_with_closed_captions[stream->index]);
2082 ✗ print_int("film_grain", streams_with_film_grain[stream->index]);
2083 }
2084 }
2085 188 print_int("has_b_frames", par->video_delay);
2086 188 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
2087
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 75 times.
188 if (sar.num) {
2088 113 print_q("sample_aspect_ratio", sar, ':');
2089 113 av_reduce(&dar.num, &dar.den,
2090 113 (int64_t) par->width * sar.num,
2091 113 (int64_t) par->height * sar.den,
2092 1024*1024);
2093 113 print_q("display_aspect_ratio", dar, ':');
2094 } else {
2095 75 print_str_opt("sample_aspect_ratio", "N/A");
2096 75 print_str_opt("display_aspect_ratio", "N/A");
2097 }
2098 188 print_pixel_format(tfc, par->format);
2099
2100 188 print_color_range(tfc, par->color_range);
2101 188 print_color_space(tfc, par->color_space);
2102 188 print_color_trc(tfc, par->color_trc);
2103 188 print_primaries(tfc, par->color_primaries);
2104 188 print_chroma_location(tfc, par->chroma_location);
2105
2106
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 148 times.
188 if (par->field_order == AV_FIELD_PROGRESSIVE)
2107 40 print_str("field_order", "progressive");
2108
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 139 times.
148 else if (par->field_order == AV_FIELD_TT)
2109 9 print_str("field_order", "tt");
2110
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 138 times.
139 else if (par->field_order == AV_FIELD_BB)
2111 1 print_str("field_order", "bb");
2112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 else if (par->field_order == AV_FIELD_TB)
2113 ✗ print_str("field_order", "tb");
2114
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 130 times.
138 else if (par->field_order == AV_FIELD_BT)
2115 8 print_str("field_order", "bt");
2116 else
2117 130 print_str_opt("field_order", "unknown");
2118
2119
4/4
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 155 times.
188 if (dec_ctx && do_read_frames)
2120 26 print_int("refs", dec_ctx->refs);
2121 188 break;
2122
2123 400 case AVMEDIA_TYPE_AUDIO:
2124 400 s = av_get_sample_fmt_name(par->format);
2125
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 6 times.
400 if (s) print_str ("sample_fmt", s);
2126 6 else print_str_opt("sample_fmt", "unknown");
2127 400 print_val("sample_rate", par->sample_rate, unit_hertz_str);
2128 400 print_int("channels", par->ch_layout.nb_channels);
2129
2130
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 39 times.
400 if (par->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
2131 361 av_channel_layout_describe(&par->ch_layout, val_str, sizeof(val_str));
2132 361 print_str ("channel_layout", val_str);
2133 } else {
2134 39 print_str_opt("channel_layout", "unknown");
2135 }
2136
2137 400 print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id));
2138
2139 400 print_int("initial_padding", par->initial_padding);
2140 400 print_int("seek_preroll", par->seek_preroll);
2141 400 break;
2142
2143 12 case AVMEDIA_TYPE_SUBTITLE:
2144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (par->width)
2145 ✗ print_int("width", par->width);
2146 else
2147 12 print_str_opt("width", "N/A");
2148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (par->height)
2149 ✗ print_int("height", par->height);
2150 else
2151 12 print_str_opt("height", "N/A");
2152 12 break;
2153 }
2154
2155
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 3 times.
610 if (show_private_data) {
2156
4/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 400 times.
✓ Branch 3 taken 186 times.
607 if (dec_ctx && dec_ctx->codec->priv_class)
2157 400 print_private_data(tfc, dec_ctx->priv_data);
2158
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 301 times.
607 if (fmt_ctx->iformat->priv_class)
2159 306 print_private_data(tfc, fmt_ctx->priv_data);
2160 }
2161
2162
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 220 times.
610 if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%x", stream->id);
2163 220 else print_str_opt("id", "N/A");
2164 610 print_q("r_frame_rate", stream->r_frame_rate, '/');
2165 610 print_q("avg_frame_rate", stream->avg_frame_rate, '/');
2166 610 print_q("time_base", stream->time_base, '/');
2167 610 print_ts ("start_pts", stream->start_time);
2168 610 print_time("start_time", stream->start_time, &stream->time_base);
2169 610 print_ts ("duration_ts", stream->duration);
2170 610 print_time("duration", stream->duration, &stream->time_base);
2171
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 383 times.
610 if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str);
2172 383 else print_str_opt("bit_rate", "N/A");
2173
3/4
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 589 times.
610 if (dec_ctx && dec_ctx->rc_max_rate > 0)
2174 ✗ print_val ("max_bit_rate", dec_ctx->rc_max_rate, unit_bit_per_second_str);
2175 else
2176 610 print_str_opt("max_bit_rate", "N/A");
2177
4/4
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 217 times.
✓ Branch 3 taken 372 times.
610 if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample);
2178 393 else print_str_opt("bits_per_raw_sample", "N/A");
2179
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 502 times.
610 if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames);
2180 502 else print_str_opt("nb_frames", "N/A");
2181
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 571 times.
610 if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]);
2182 571 else print_str_opt("nb_read_frames", "N/A");
2183
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 501 times.
610 if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]);
2184 501 else print_str_opt("nb_read_packets", "N/A");
2185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if (do_show_data)
2186 ✗ avtext_print_data(tfc, "extradata", par->extradata,
2187 par->extradata_size);
2188
2189
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 250 times.
610 if (par->extradata_size > 0) {
2190 360 print_int("extradata_size", par->extradata_size);
2191 360 avtext_print_data_hash(tfc, "extradata_hash", par->extradata,
2192 par->extradata_size);
2193 }
2194
2195 /* Print disposition information */
2196
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 279 times.
610 if (do_show_stream_disposition) {
2197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331 times.
331 av_assert0(container < FF_ARRAY_ELEMS(section_disposition));
2198 331 print_dispositions(tfc, stream->disposition, section_disposition[container]);
2199 }
2200
2201
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 473 times.
610 if (do_show_stream_tags) {
2202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
137 av_assert0(container < FF_ARRAY_ELEMS(section_tags));
2203 137 ret = show_tags(tfc, stream->metadata, section_tags[container]);
2204 }
2205
2206
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 535 times.
610 if (stream->codecpar->nb_coded_side_data) {
2207
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75 times.
75 av_assert0(container < FF_ARRAY_ELEMS(section_tags) &&
2208 container < FF_ARRAY_ELEMS(container_side_data));
2209 75 avtext_print_section_header(tfc, NULL, section_side_data[container]);
2210
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 75 times.
171 for (int i = 0; i < stream->codecpar->nb_coded_side_data; i++) {
2211 96 print_pkt_side_data(tfc, stream->codecpar->width, stream->codecpar->height, &stream->codecpar->coded_side_data[i],
2212 96 container_side_data[container]);
2213 }
2214 75 avtext_print_section_footer(tfc);
2215 }
2216
2217 610 avtext_print_section_footer(tfc);
2218 610 av_bprint_finalize(&pbuf, NULL);
2219 610 fflush(stdout);
2220
2221 610 return ret;
2222 }
2223
2224 224 static int show_streams(AVTextFormatContext *tfc, InputFile *ifile)
2225 {
2226 224 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2227 224 int ret = 0;
2228
2229 224 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAMS);
2230
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 224 times.
581 for (int i = 0; i < ifile->nb_streams; i++)
2231
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 26 times.
357 if (selected_streams[i]) {
2232 331 ret = show_stream(tfc, fmt_ctx, i, &ifile->streams[i], 0);
2233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331 times.
331 if (ret < 0)
2234 ✗ break;
2235 }
2236 224 avtext_print_section_footer(tfc);
2237
2238 224 return ret;
2239 }
2240
2241 5 static int show_program(AVTextFormatContext *tfc, InputFile *ifile, AVProgram *program)
2242 {
2243 5 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2244 5 int ret = 0;
2245
2246 5 avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAM);
2247 5 print_int("program_id", program->id);
2248 5 print_int("program_num", program->program_num);
2249 5 print_int("nb_streams", program->nb_stream_indexes);
2250 5 print_int("pmt_pid", program->pmt_pid);
2251 5 print_int("pcr_pid", program->pcr_pid);
2252
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
5 if (do_show_program_tags)
2253 2 ret = show_tags(tfc, program->metadata, SECTION_ID_PROGRAM_TAGS);
2254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (ret < 0)
2255 ✗ goto end;
2256
2257 5 avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAM_STREAMS);
2258
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 5 times.
15 for (unsigned i = 0; i < program->nb_stream_indexes; i++) {
2259
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
10 if (selected_streams[program->stream_index[i]]) {
2260 9 ret = show_stream(tfc, fmt_ctx, program->stream_index[i], &ifile->streams[program->stream_index[i]], IN_PROGRAM);
2261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (ret < 0)
2262 ✗ break;
2263 }
2264 }
2265 5 avtext_print_section_footer(tfc);
2266
2267 5 end:
2268 5 avtext_print_section_footer(tfc);
2269 5 return ret;
2270 }
2271
2272 4 static int show_programs(AVTextFormatContext *tfc, InputFile *ifile)
2273 {
2274 4 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2275 4 int ret = 0;
2276
2277 4 avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAMS);
2278
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 for (unsigned i = 0; i < fmt_ctx->nb_programs; i++) {
2279 5 AVProgram *program = fmt_ctx->programs[i];
2280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!program)
2281 ✗ continue;
2282 5 ret = show_program(tfc, ifile, program);
2283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (ret < 0)
2284 ✗ break;
2285 }
2286 4 avtext_print_section_footer(tfc);
2287 4 return ret;
2288 }
2289
2290 6 static void print_tile_grid_params(AVTextFormatContext *tfc, const AVStreamGroup *stg,
2291 const AVStreamGroupTileGrid *tile_grid)
2292 {
2293 6 avtext_print_section_header(tfc, stg, SECTION_ID_STREAM_GROUP_COMPONENT);
2294 6 print_int("nb_tiles", tile_grid->nb_tiles);
2295 6 print_int("coded_width", tile_grid->coded_width);
2296 6 print_int("coded_height", tile_grid->coded_height);
2297 6 print_int("horizontal_offset", tile_grid->horizontal_offset);
2298 6 print_int("vertical_offset", tile_grid->vertical_offset);
2299 6 print_int("width", tile_grid->width);
2300 6 print_int("height", tile_grid->height);
2301 6 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SUBCOMPONENTS);
2302
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6 times.
42 for (unsigned i = 0; i < tile_grid->nb_tiles; i++) {
2303 36 avtext_print_section_header(tfc, "tile_offset", SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2304 36 print_int("stream_index", tile_grid->offsets[i].idx);
2305 36 print_int("tile_horizontal_offset", tile_grid->offsets[i].horizontal);
2306 36 print_int("tile_vertical_offset", tile_grid->offsets[i].vertical);
2307 36 avtext_print_section_footer(tfc);
2308 }
2309 6 avtext_print_section_footer(tfc);
2310 6 avtext_print_section_footer(tfc);
2311 6 }
2312
2313 50 static void print_iamf_param_definition(AVTextFormatContext *tfc, const char *name,
2314 const AVIAMFParamDefinition *param, SectionID section_id)
2315 {
2316 SectionID subsection_id, parameter_section_id;
2317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if (section_id == SECTION_ID_FRAME_SIDE_DATA)
2318 ✗ subsection_id = SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST;
2319 else {
2320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 av_assert0(sections[section_id].children_ids[0] != -1);
2321 50 subsection_id = sections[section_id].children_ids[0];
2322 }
2323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 av_assert0(sections[subsection_id].children_ids[0] != -1);
2324 50 parameter_section_id = sections[subsection_id].children_ids[0];
2325
2326 // When printing as part of side-data, skip opening a section
2327
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if (section_id != SECTION_ID_FRAME_SIDE_DATA)
2328 50 avtext_print_section_header(tfc, "IAMF Param Definition", section_id);
2329
2330
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if (name)
2331 50 print_str("name", name);
2332 50 print_int("nb_subblocks", param->nb_subblocks);
2333 50 print_int("type", param->type);
2334 50 print_int("parameter_id", param->parameter_id);
2335 50 print_int("parameter_rate", param->parameter_rate);
2336 50 print_int("duration", param->duration);
2337 50 print_int("constant_subblock_duration", param->constant_subblock_duration);
2338
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 41 times.
50 if (param->nb_subblocks > 0)
2339 9 avtext_print_section_header(tfc, NULL, subsection_id);
2340
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 50 times.
59 for (unsigned i = 0; i < param->nb_subblocks; i++) {
2341 9 const void *subblock = av_iamf_param_definition_get_subblock(param, i);
2342
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
9 switch(param->type) {
2343 ✗ case AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN: {
2344 ✗ const AVIAMFMixGain *mix = subblock;
2345 ✗ avtext_print_section_header(tfc, "IAMF Mix Gain Parameters", parameter_section_id);
2346 ✗ print_int("subblock_duration", mix->subblock_duration);
2347 ✗ print_int("animation_type", mix->animation_type);
2348 ✗ print_q("start_point_value", mix->start_point_value, '/');
2349 ✗ print_q("end_point_value", mix->end_point_value, '/');
2350 ✗ print_q("control_point_value", mix->control_point_value, '/');
2351 ✗ print_q("control_point_relative_time", mix->control_point_relative_time, '/');
2352 ✗ avtext_print_section_footer(tfc); // parameter_section_id
2353 ✗ break;
2354 }
2355 7 case AV_IAMF_PARAMETER_DEFINITION_DEMIXING: {
2356 7 const AVIAMFDemixingInfo *demix = subblock;
2357 7 avtext_print_section_header(tfc, "IAMF Demixing Info", parameter_section_id);
2358 7 print_int("subblock_duration", demix->subblock_duration);
2359 7 print_int("dmixp_mode", demix->dmixp_mode);
2360 7 avtext_print_section_footer(tfc); // parameter_section_id
2361 7 break;
2362 }
2363 2 case AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN: {
2364 2 const AVIAMFReconGain *recon = subblock;
2365 2 avtext_print_section_header(tfc, "IAMF Recon Gain", parameter_section_id);
2366 2 print_int("subblock_duration", recon->subblock_duration);
2367 2 avtext_print_section_footer(tfc); // parameter_section_id
2368 2 break;
2369 }
2370 }
2371 }
2372
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 41 times.
50 if (param->nb_subblocks > 0)
2373 9 avtext_print_section_footer(tfc); // subsection_id
2374
2375
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if (section_id != SECTION_ID_FRAME_SIDE_DATA)
2376 50 avtext_print_section_footer(tfc); // section_id
2377 50 }
2378
2379 19 static void print_iamf_audio_element_params(AVTextFormatContext *tfc, const AVStreamGroup *stg,
2380 const AVIAMFAudioElement *audio_element)
2381 {
2382 AVBPrint pbuf;
2383
2384 19 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
2385
2386 19 avtext_print_section_header(tfc, stg, SECTION_ID_STREAM_GROUP_COMPONENT);
2387 19 print_int("nb_layers", audio_element->nb_layers);
2388 19 print_int("audio_element_type", audio_element->audio_element_type);
2389 19 print_int("default_w", audio_element->default_w);
2390 19 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SUBCOMPONENTS);
2391
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 19 times.
55 for (unsigned i = 0; i < audio_element->nb_layers; i++) {
2392 36 const AVIAMFLayer *layer = audio_element->layers[i];
2393 char val_str[128];
2394 36 avtext_print_section_header(tfc, "IAMF Audio Layer", SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2395 36 av_channel_layout_describe(&layer->ch_layout, val_str, sizeof(val_str));
2396 36 print_str("channel_layout", val_str);
2397
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 7 times.
36 if (audio_element->audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL) {
2398 29 print_int("output_gain_flags", layer->output_gain_flags);
2399 29 print_q("output_gain", layer->output_gain, '/');
2400
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 } else if (audio_element->audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE) {
2401 7 print_int("ambisonics_mode", layer->ambisonics_mode);
2402
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
7 if (layer->ambisonics_mode == AV_IAMF_AMBISONICS_MODE_PROJECTION)
2403
7/8
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 48 times.
✓ Branch 8 taken 48 times.
✓ Branch 9 taken 48 times.
✓ Branch 10 taken 3 times.
99 print_list_fmt("demixing_matrix", "%d/%d", layer->nb_demixing_matrix, 1, layer->demixing_matrix[idx].num,
2404 layer->demixing_matrix[idx].den);
2405 }
2406 36 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENT
2407 }
2408
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 12 times.
19 if (audio_element->demixing_info)
2409 7 print_iamf_param_definition(tfc, "demixing_info", audio_element->demixing_info,
2410 SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2411
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 17 times.
19 if (audio_element->recon_gain_info)
2412 2 print_iamf_param_definition(tfc, "recon_gain_info", audio_element->recon_gain_info,
2413 SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2414 19 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENTS
2415 19 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENT
2416
2417 19 av_bprint_finalize(&pbuf, NULL);
2418 19 }
2419
2420 20 static void print_iamf_submix_params(AVTextFormatContext *tfc, const AVIAMFSubmix *submix)
2421 {
2422 20 avtext_print_section_header(tfc, "IAMF Submix", SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2423 20 print_int("nb_elements", submix->nb_elements);
2424 20 print_int("nb_layouts", submix->nb_layouts);
2425 20 print_q("default_mix_gain", submix->default_mix_gain, '/');
2426 20 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_PIECES);
2427
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 20 times.
41 for (unsigned i = 0; i < submix->nb_elements; i++) {
2428 21 const AVIAMFSubmixElement *element = submix->elements[i];
2429 21 avtext_print_section_header(tfc, "IAMF Submix Element", SECTION_ID_STREAM_GROUP_PIECE);
2430 21 print_int("stream_id", element->audio_element_id);
2431 21 print_q("default_mix_gain", element->default_mix_gain, '/');
2432 21 print_int("headphones_rendering_mode", element->headphones_rendering_mode);
2433 21 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SUBPIECES);
2434
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if (element->annotations) {
2435 21 const AVDictionaryEntry *annotation = NULL;
2436 21 avtext_print_section_header(tfc, "IAMF Annotations", SECTION_ID_STREAM_GROUP_SUBPIECE);
2437
2/2
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
42 while (annotation = av_dict_iterate(element->annotations, annotation))
2438 21 print_str(annotation->key, annotation->value);
2439 21 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBPIECE
2440 }
2441
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if (element->element_mix_config)
2442 21 print_iamf_param_definition(tfc, "element_mix_config", element->element_mix_config,
2443 SECTION_ID_STREAM_GROUP_SUBPIECE);
2444 21 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBPIECES
2445 21 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_PIECE
2446 }
2447
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if (submix->output_mix_config)
2448 20 print_iamf_param_definition(tfc, "output_mix_config", submix->output_mix_config,
2449 SECTION_ID_STREAM_GROUP_PIECE);
2450
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 20 times.
60 for (unsigned i = 0; i < submix->nb_layouts; i++) {
2451 40 const AVIAMFSubmixLayout *layout = submix->layouts[i];
2452 char val_str[128];
2453 40 avtext_print_section_header(tfc, "IAMF Submix Layout", SECTION_ID_STREAM_GROUP_PIECE);
2454 40 av_channel_layout_describe(&layout->sound_system, val_str, sizeof(val_str));
2455 40 print_str("sound_system", val_str);
2456 40 print_q("integrated_loudness", layout->integrated_loudness, '/');
2457 40 print_q("digital_peak", layout->digital_peak, '/');
2458 40 print_q("true_peak", layout->true_peak, '/');
2459 40 print_q("dialogue_anchored_loudness", layout->dialogue_anchored_loudness, '/');
2460 40 print_q("album_anchored_loudness", layout->album_anchored_loudness, '/');
2461 40 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_PIECE
2462 }
2463 20 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_PIECES
2464 20 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENT
2465 20 }
2466
2467 18 static void print_iamf_mix_presentation_params(AVTextFormatContext *tfc, const AVStreamGroup *stg,
2468 const AVIAMFMixPresentation *mix_presentation)
2469 {
2470 18 avtext_print_section_header(tfc, stg, SECTION_ID_STREAM_GROUP_COMPONENT);
2471 18 print_int("nb_submixes", mix_presentation->nb_submixes);
2472 18 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SUBCOMPONENTS);
2473
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (mix_presentation->annotations) {
2474 18 const AVDictionaryEntry *annotation = NULL;
2475 18 avtext_print_section_header(tfc, "IAMF Annotations", SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2476
2/2
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
36 while (annotation = av_dict_iterate(mix_presentation->annotations, annotation))
2477 18 print_str(annotation->key, annotation->value);
2478 18 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENT
2479 }
2480
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 18 times.
38 for (unsigned i = 0; i < mix_presentation->nb_submixes; i++)
2481 20 print_iamf_submix_params(tfc, mix_presentation->submixes[i]);
2482 18 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENTS
2483 18 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENT
2484 18 }
2485
2486 1 static void print_layered_video_params(AVTextFormatContext *tfc, const AVStreamGroup *stg,
2487 const AVStreamGroupLayeredVideo *layered_video)
2488 {
2489 1 avtext_print_section_header(tfc, stg, SECTION_ID_STREAM_GROUP_COMPONENT);
2490 1 print_int("el_index", layered_video->el_index);
2491 1 print_int("width", layered_video->width);
2492 1 print_int("height", layered_video->height);
2493 1 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENT
2494 1 }
2495
2496 48 static void print_stream_group_params(AVTextFormatContext *tfc, AVStreamGroup *stg)
2497 {
2498 48 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_COMPONENTS);
2499
5/5
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 4 times.
48 switch (stg->type) {
2500 6 case AV_STREAM_GROUP_PARAMS_TILE_GRID:
2501 6 print_tile_grid_params(tfc, stg, stg->params.tile_grid); break;
2502 19 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT:
2503 19 print_iamf_audio_element_params(tfc, stg, stg->params.iamf_audio_element); break;
2504 18 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION:
2505 18 print_iamf_mix_presentation_params(tfc, stg, stg->params.iamf_mix_presentation); break;
2506 1 case AV_STREAM_GROUP_PARAMS_LCEVC:
2507 case AV_STREAM_GROUP_PARAMS_DOLBY_VISION:
2508 case AV_STREAM_GROUP_PARAMS_GAIN_MAP:
2509 1 print_layered_video_params(tfc, stg, stg->params.layered_video); break;
2510 }
2511 48 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENTS
2512 48 }
2513
2514 63 static int show_stream_group(AVTextFormatContext *tfc, InputFile *ifile, AVStreamGroup *stg, int container)
2515 {
2516 63 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2517 AVBPrint pbuf;
2518 63 const SectionID section_header[] = {
2519 SECTION_ID_STREAM_GROUP,
2520 SECTION_ID_STREAM_GROUP_STREAM_GROUP,
2521 SECTION_ID_STREAM_GROUP_STREAM_GROUP,
2522 };
2523 63 const SectionID section_disposition[] = {
2524 SECTION_ID_STREAM_GROUP_DISPOSITION,
2525 SECTION_ID_STREAM_GROUP_STREAM_GROUP_DISPOSITION,
2526 SECTION_ID_STREAM_GROUP_STREAM_GROUP_DISPOSITION,
2527 };
2528 63 const SectionID section_tags[] = {
2529 SECTION_ID_STREAM_GROUP_TAGS,
2530 SECTION_ID_STREAM_GROUP_STREAM_GROUP_TAGS,
2531 SECTION_ID_STREAM_GROUP_STREAM_GROUP_TAGS,
2532 };
2533 63 int ret = 0;
2534
2535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 av_assert0(container < FF_ARRAY_ELEMS(section_header));
2536
2537 63 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
2538 63 avtext_print_section_header(tfc, NULL, section_header[container]);
2539 63 print_int("index", stg->index);
2540
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 1 times.
63 if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%"PRIx64, stg->id);
2541 1 else print_str_opt("id", "N/A");
2542 63 print_int("nb_streams", stg->nb_entries);
2543
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if (stg->type != AV_STREAM_GROUP_PARAMS_NONE)
2544 63 print_str("type", av_x_if_null(avformat_stream_group_name(stg->type), "unknown"));
2545 else
2546 ✗ print_str_opt("type", "unknown");
2547
2548
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 60 times.
63 if (container)
2549 3 goto end;
2550
2551
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 if (do_show_stream_group_components)
2552 48 print_stream_group_params(tfc, stg);
2553
2554 /* Print disposition information */
2555
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 42 times.
60 if (do_show_stream_group_disposition) {
2556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 av_assert0(container < FF_ARRAY_ELEMS(section_disposition));
2557 18 print_dispositions(tfc, stg->disposition, section_disposition[container]);
2558 }
2559
2560
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 42 times.
60 if (do_show_stream_group_tags) {
2561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 av_assert0(container < FF_ARRAY_ELEMS(section_tags));
2562 18 ret = show_tags(tfc, stg->metadata, section_tags[container]);
2563 }
2564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if (ret < 0)
2565 ✗ goto end;
2566
2567
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 58 times.
60 if (stg->nb_coded_side_data) {
2568 2 int width = 0, height = 0;
2569 2 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST);
2570
2571
2/3
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 switch (stg->type) {
2572 1 case AV_STREAM_GROUP_PARAMS_TILE_GRID: {
2573 1 const AVStreamGroupTileGrid *tile_grid = stg->params.tile_grid;
2574 1 width = tile_grid->width;
2575 1 height = tile_grid->height;
2576 1 break;
2577 }
2578 1 case AV_STREAM_GROUP_PARAMS_GAIN_MAP: {
2579 1 const AVStreamGroupLayeredVideo *layered_video = stg->params.layered_video;
2580 1 width = layered_video->width;
2581 1 height = layered_video->height;
2582 1 break;
2583 }
2584 ✗ default:
2585 ✗ break;
2586 }
2587
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 for (int i = 0; i < stg->nb_coded_side_data; i++) {
2588 3 print_pkt_side_data(tfc, width, height, &stg->coded_side_data[i],
2589 PKT_SIDE_DATA_IN_STREAM_GROUP);
2590 }
2591 2 avtext_print_section_footer(tfc);
2592 }
2593
2594 60 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_STREAM_GROUPS);
2595
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 60 times.
339 for (unsigned i = 0; i < stg->nb_entries; i++) {
2596 279 AVStreamGroupEntry *entry = stg->entries[i];
2597
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 3 times.
279 if (entry->type != AV_STREAM_GROUP_ENTRY_STREAM_GROUP)
2598 276 continue;
2599 3 ret = show_stream_group(tfc, ifile, entry->stream_group, IN_STREAM_GROUP);
2600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (ret < 0)
2601 ✗ break;
2602 }
2603 60 avtext_print_section_footer(tfc);
2604
2605 60 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_STREAMS);
2606
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 60 times.
339 for (unsigned i = 0; i < stg->nb_entries; i++) {
2607 279 AVStreamGroupEntry *entry = stg->entries[i];
2608
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 276 times.
279 if (entry->type != AV_STREAM_GROUP_ENTRY_STREAM)
2609 3 continue;
2610
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
276 if (selected_streams[stg->entries[i]->stream->index]) {
2611 270 ret = show_stream(tfc, fmt_ctx, entry->stream->index, &ifile->streams[entry->stream->index], IN_STREAM_GROUP);
2612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 270 times.
270 if (ret < 0)
2613 ✗ break;
2614 }
2615 }
2616 60 avtext_print_section_footer(tfc);
2617
2618 63 end:
2619 63 av_bprint_finalize(&pbuf, NULL);
2620 63 avtext_print_section_footer(tfc);
2621 63 return ret;
2622 }
2623
2624 34 static int show_stream_groups(AVTextFormatContext *tfc, InputFile *ifile)
2625 {
2626 34 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2627 34 int ret = 0;
2628
2629 34 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUPS);
2630
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 34 times.
94 for (unsigned i = 0; i < fmt_ctx->nb_stream_groups; i++) {
2631 60 AVStreamGroup *stg = fmt_ctx->stream_groups[i];
2632
2633 60 ret = show_stream_group(tfc, ifile, stg, 0);
2634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if (ret < 0)
2635 ✗ break;
2636 }
2637 34 avtext_print_section_footer(tfc);
2638 34 return ret;
2639 }
2640
2641 7 static int show_chapters(AVTextFormatContext *tfc, InputFile *ifile)
2642 {
2643 7 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2644 7 int ret = 0;
2645
2646 7 avtext_print_section_header(tfc, NULL, SECTION_ID_CHAPTERS);
2647
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 for (unsigned i = 0; i < fmt_ctx->nb_chapters; i++) {
2648 27 AVChapter *chapter = fmt_ctx->chapters[i];
2649
2650 27 avtext_print_section_header(tfc, NULL, SECTION_ID_CHAPTER);
2651 27 print_int("id", chapter->id);
2652 27 print_q ("time_base", chapter->time_base, '/');
2653 27 print_int("start", chapter->start);
2654 27 print_time("start_time", chapter->start, &chapter->time_base);
2655 27 print_int("end", chapter->end);
2656 27 print_time("end_time", chapter->end, &chapter->time_base);
2657
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if (do_show_chapter_tags)
2658 27 ret = show_tags(tfc, chapter->metadata, SECTION_ID_CHAPTER_TAGS);
2659 27 avtext_print_section_footer(tfc);
2660 }
2661 7 avtext_print_section_footer(tfc);
2662
2663 7 return ret;
2664 }
2665
2666 86 static int show_format(AVTextFormatContext *tfc, InputFile *ifile)
2667 {
2668 86 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2669
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
2670 86 int ret = 0;
2671
2672 86 avtext_print_section_header(tfc, NULL, SECTION_ID_FORMAT);
2673 86 print_str_validate("filename", fmt_ctx->url);
2674 86 print_int("nb_streams", fmt_ctx->nb_streams);
2675 86 print_int("nb_programs", fmt_ctx->nb_programs);
2676 86 print_int("nb_stream_groups", fmt_ctx->nb_stream_groups);
2677 86 print_str("format_name", fmt_ctx->iformat->name);
2678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if (!do_bitexact) {
2679 ✗ if (fmt_ctx->iformat->long_name) print_str ("format_long_name", fmt_ctx->iformat->long_name);
2680 ✗ else print_str_opt("format_long_name", "unknown");
2681 }
2682 86 print_time("start_time", fmt_ctx->start_time, &AV_TIME_BASE_Q);
2683 86 print_time("duration", fmt_ctx->duration, &AV_TIME_BASE_Q);
2684
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if (size >= 0) print_int_fmt("size", size, AV_TEXTFORMAT_VALUE_FMT_BYTE, unit_byte_str);
2685 ✗ else print_str_opt("size", "N/A");
2686
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 6 times.
86 if (fmt_ctx->bit_rate > 0) print_val ("bit_rate", fmt_ctx->bit_rate, unit_bit_per_second_str);
2687 6 else print_str_opt("bit_rate", "N/A");
2688 86 print_int("probe_score", fmt_ctx->probe_score);
2689
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 15 times.
86 if (do_show_format_tags)
2690 71 ret = show_tags(tfc, fmt_ctx->metadata, SECTION_ID_FORMAT_TAGS);
2691
2692 86 avtext_print_section_footer(tfc);
2693 86 fflush(stdout);
2694 86 return ret;
2695 }
2696
2697 ✗ static void show_error(AVTextFormatContext *tfc, int err)
2698 {
2699 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_ERROR);
2700 ✗ print_int("code", err);
2701 ✗ print_str("string", av_err2str(err));
2702 ✗ avtext_print_section_footer(tfc);
2703 ✗ }
2704
2705 1508 static int get_decoder_by_name(const char *codec_name, const AVCodec **codec)
2706 {
2707
1/2
✓ Branch 0 taken 1508 times.
✗ Branch 1 not taken.
1508 if (codec_name == NULL)
2708 1508 return 0;
2709
2710 ✗ *codec = avcodec_find_decoder_by_name(codec_name);
2711 ✗ if (*codec == NULL) {
2712 ✗ av_log(NULL, AV_LOG_ERROR,
2713 "No codec could be found with name '%s'\n", codec_name);
2714 ✗ return AVERROR(EINVAL);
2715 }
2716 ✗ return 0;
2717 }
2718
2719 377 static int set_decoders(AVFormatContext *fmt_ctx)
2720 {
2721 int ret;
2722
2723 #define GET_DECODER(type_) \
2724 ret = get_decoder_by_name(type_##_codec_name, &fmt_ctx->type_##_codec); \
2725 if (ret < 0) return ret;
2726
2727
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 GET_DECODER(audio);
2728
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 GET_DECODER(data);
2729
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 GET_DECODER(subtitle);
2730
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 GET_DECODER(video);
2731 377 return 0;
2732 }
2733
2734 658 static const AVCodec *get_decoder_for_stream(AVFormatContext *fmt_ctx, AVStream *stream)
2735 {
2736 658 const AVCodec *codec = NULL;
2737
5/5
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 349 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 2 times.
658 switch (stream->codecpar->codec_type) {
2738 265 case AVMEDIA_TYPE_VIDEO: codec = fmt_ctx->video_codec; break;
2739 349 case AVMEDIA_TYPE_AUDIO: codec = fmt_ctx->audio_codec; break;
2740 12 case AVMEDIA_TYPE_SUBTITLE: codec = fmt_ctx->subtitle_codec; break;
2741 30 case AVMEDIA_TYPE_DATA: codec = fmt_ctx->data_codec; break;
2742 }
2743
2744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658 times.
658 if (codec != NULL)
2745 ✗ return codec;
2746
2747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658 times.
658 if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) {
2748 ✗ av_log(NULL, AV_LOG_WARNING,
2749 "Failed to probe codec for input stream %d\n", stream->index);
2750 ✗ return NULL;
2751 }
2752
2753 658 codec = avcodec_find_decoder(stream->codecpar->codec_id);
2754
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 616 times.
658 if (codec == NULL) {
2755 42 av_log(NULL, AV_LOG_WARNING,
2756 "Unsupported codec with id %d for input stream %d\n",
2757 42 stream->codecpar->codec_id, stream->index);
2758 42 return NULL;
2759 }
2760
2761 616 return codec;
2762 }
2763
2764 377 static int open_input_file(InputFile *ifile, const char *filename,
2765 const char *print_filename)
2766 {
2767 int err;
2768 377 AVFormatContext *fmt_ctx = NULL;
2769 377 const AVDictionaryEntry *t = NULL;
2770 377 int scan_all_pmts_set = 0;
2771
2772 377 fmt_ctx = avformat_alloc_context();
2773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (!fmt_ctx)
2774 ✗ return AVERROR(ENOMEM);
2775
2776 377 err = set_decoders(fmt_ctx);
2777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (err < 0)
2778 ✗ return err;
2779
1/2
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
377 if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
2780 377 av_dict_set(&format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
2781 377 scan_all_pmts_set = 1;
2782 }
2783
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 374 times.
377 if ((err = avformat_open_input(&fmt_ctx, filename,
2784 iformat, &format_opts)) < 0) {
2785 3 print_error(filename, err);
2786 3 return err;
2787 }
2788
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 345 times.
374 if (print_filename) {
2789 29 av_freep(&fmt_ctx->url);
2790 29 fmt_ctx->url = av_strdup(print_filename);
2791 }
2792 374 ifile->fmt_ctx = fmt_ctx;
2793
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if (scan_all_pmts_set)
2794 374 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
2795
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
374 while ((t = av_dict_iterate(format_opts, t)))
2796 ✗ av_log(NULL, AV_LOG_WARNING, "Option %s skipped - not known to demuxer.\n", t->key);
2797
2798
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if (find_stream_info) {
2799 AVDictionary **opts;
2800 374 int orig_nb_streams = fmt_ctx->nb_streams;
2801
2802 374 err = setup_find_stream_info_opts(fmt_ctx, codec_opts, &opts);
2803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if (err < 0)
2804 ✗ return err;
2805
2806 374 err = avformat_find_stream_info(fmt_ctx, opts);
2807
2808
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 374 times.
1003 for (int i = 0; i < orig_nb_streams; i++)
2809 629 av_dict_free(&opts[i]);
2810 374 av_freep(&opts);
2811
2812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if (err < 0) {
2813 ✗ print_error(filename, err);
2814 ✗ return err;
2815 }
2816 }
2817
2818 374 av_dump_format(fmt_ctx, 0, filename, 0);
2819
2820 374 ifile->streams = av_calloc(fmt_ctx->nb_streams, sizeof(*ifile->streams));
2821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if (!ifile->streams)
2822 ✗ exit(1);
2823 374 ifile->nb_streams = fmt_ctx->nb_streams;
2824
2825 /* bind a decoder to each input stream */
2826
2/2
✓ Branch 0 taken 658 times.
✓ Branch 1 taken 374 times.
1032 for (unsigned i = 0; i < fmt_ctx->nb_streams; i++) {
2827 658 InputStream *ist = &ifile->streams[i];
2828 658 AVStream *stream = fmt_ctx->streams[i];
2829 const AVCodec *codec;
2830
2831 658 ist->st = stream;
2832
2833 658 codec = get_decoder_for_stream(fmt_ctx, stream);
2834
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 616 times.
658 if (!codec)
2835 42 continue;
2836
2837 {
2838 AVDictionary *opts;
2839
2840 616 err = filter_codec_opts(codec_opts, stream->codecpar->codec_id,
2841 fmt_ctx, stream, codec, &opts, NULL);
2842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616 times.
616 if (err < 0)
2843 ✗ exit(1);
2844
2845 616 ist->dec_ctx = avcodec_alloc_context3(codec);
2846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616 times.
616 if (!ist->dec_ctx)
2847 ✗ exit(1);
2848
2849 616 err = avcodec_parameters_to_context(ist->dec_ctx, stream->codecpar);
2850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616 times.
616 if (err < 0)
2851 ✗ exit(1);
2852
2853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616 times.
616 if (do_show_log) {
2854 // For logging it is needed to disable at least frame threads as otherwise
2855 // the log information would need to be reordered and matches up to contexts and frames
2856 // That is in fact possible but not trivial
2857 ✗ av_dict_set(&codec_opts, "threads", "1", 0);
2858 }
2859
2860 616 av_dict_set(&opts, "flags", "+copy_opaque", AV_DICT_MULTIKEY);
2861
2862 616 ist->dec_ctx->pkt_timebase = stream->time_base;
2863
2864
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 616 times.
616 if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {
2865 ✗ av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n",
2866 stream->index);
2867 ✗ exit(1);
2868 }
2869
2870
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 616 times.
616 if ((t = av_dict_iterate(opts, NULL))) {
2871 ✗ av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not found\n",
2872 ✗ t->key, stream->index);
2873 ✗ return AVERROR_OPTION_NOT_FOUND;
2874 }
2875 }
2876 }
2877
2878 374 ifile->fmt_ctx = fmt_ctx;
2879 374 return 0;
2880 }
2881
2882 374 static void close_input_file(InputFile *ifile)
2883 {
2884
2885 /* close decoder for each stream */
2886
2/2
✓ Branch 0 taken 658 times.
✓ Branch 1 taken 374 times.
1032 for (int i = 0; i < ifile->nb_streams; i++)
2887 658 avcodec_free_context(&ifile->streams[i].dec_ctx);
2888
2889 374 av_freep(&ifile->streams);
2890 374 ifile->nb_streams = 0;
2891
2892 374 avformat_close_input(&ifile->fmt_ctx);
2893 374 }
2894
2895 377 static int probe_file(AVTextFormatContext *tfc, const char *filename,
2896 const char *print_filename)
2897 {
2898 377 InputFile ifile = { 0 };
2899 int ret;
2900 int section_id;
2901
2902
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 do_analyze_frames = do_analyze_frames && do_show_streams;
2903
4/6
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 302 times.
377 do_read_frames = do_show_frames || do_count_frames || do_analyze_frames;
2904
3/4
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266 times.
377 do_read_packets = do_show_packets || do_count_packets;
2905
2906 377 ret = open_input_file(&ifile, filename, print_filename);
2907
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 374 times.
377 if (ret < 0)
2908 3 goto end;
2909
2910 #define CHECK_END if (ret < 0) goto end
2911
2912 374 nb_streams = ifile.fmt_ctx->nb_streams;
2913
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
374 REALLOCZ_ARRAY_STREAM(nb_streams_frames,0,ifile.fmt_ctx->nb_streams);
2914
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
374 REALLOCZ_ARRAY_STREAM(nb_streams_packets,0,ifile.fmt_ctx->nb_streams);
2915
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
374 REALLOCZ_ARRAY_STREAM(selected_streams,0,ifile.fmt_ctx->nb_streams);
2916
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
374 REALLOCZ_ARRAY_STREAM(streams_with_closed_captions,0,ifile.fmt_ctx->nb_streams);
2917
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
374 REALLOCZ_ARRAY_STREAM(streams_with_film_grain,0,ifile.fmt_ctx->nb_streams);
2918
2919
2/2
✓ Branch 0 taken 658 times.
✓ Branch 1 taken 374 times.
1032 for (unsigned i = 0; i < ifile.fmt_ctx->nb_streams; i++) {
2920
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 535 times.
658 if (stream_specifier) {
2921 123 ret = avformat_match_stream_specifier(ifile.fmt_ctx,
2922 123 ifile.fmt_ctx->streams[i],
2923 stream_specifier);
2924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 CHECK_END;
2925 else
2926 123 selected_streams[i] = ret;
2927 123 ret = 0;
2928 } else {
2929 535 selected_streams[i] = 1;
2930 }
2931
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 615 times.
658 if (!selected_streams[i])
2932 43 ifile.fmt_ctx->streams[i]->discard = AVDISCARD_ALL;
2933 }
2934
2935
4/4
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 200 times.
374 if (do_read_frames || do_read_packets) {
2936
4/4
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 63 times.
174 if (do_show_frames && do_show_packets &&
2937
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 7 times.
12 tfc->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_MIXED_ARRAY_CONTENT)
2938 5 section_id = SECTION_ID_PACKETS_AND_FRAMES;
2939
4/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 7 times.
169 else if (do_show_packets && !do_show_frames)
2940 99 section_id = SECTION_ID_PACKETS;
2941 else // (!do_show_packets && do_show_frames)
2942 70 section_id = SECTION_ID_FRAMES;
2943
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
174 if (do_show_frames || do_show_packets)
2944 174 avtext_print_section_header(tfc, NULL, section_id);
2945 174 ret = read_packets(tfc, &ifile);
2946
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
174 if (do_show_frames || do_show_packets)
2947 174 avtext_print_section_footer(tfc);
2948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 CHECK_END;
2949 }
2950
2951
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 370 times.
374 if (do_show_programs) {
2952 4 ret = show_programs(tfc, &ifile);
2953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 CHECK_END;
2954 }
2955
2956
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 340 times.
374 if (do_show_stream_groups) {
2957 34 ret = show_stream_groups(tfc, &ifile);
2958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 CHECK_END;
2959 }
2960
2961
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 150 times.
374 if (do_show_streams) {
2962 224 ret = show_streams(tfc, &ifile);
2963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 224 times.
224 CHECK_END;
2964 }
2965
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 367 times.
374 if (do_show_chapters) {
2966 7 ret = show_chapters(tfc, &ifile);
2967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 CHECK_END;
2968 }
2969
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 86 times.
374 if (do_show_format) {
2970 86 ret = show_format(tfc, &ifile);
2971
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 CHECK_END;
2972 }
2973
2974 374 end:
2975
2/2
✓ Branch 0 taken 374 times.
✓ Branch 1 taken 3 times.
377 if (ifile.fmt_ctx)
2976 374 close_input_file(&ifile);
2977 377 av_freep(&nb_streams_frames);
2978 377 av_freep(&nb_streams_packets);
2979 377 av_freep(&selected_streams);
2980 377 av_freep(&streams_with_closed_captions);
2981 377 av_freep(&streams_with_film_grain);
2982 377 av_freep(&audio_codec_name);
2983 377 av_freep(&data_codec_name);
2984 377 av_freep(&subtitle_codec_name);
2985 377 av_freep(&video_codec_name);
2986
2987 377 return ret;
2988 }
2989
2990 ✗ static void show_usage(void)
2991 {
2992 ✗ av_log(NULL, AV_LOG_INFO, "Simple multimedia streams analyzer\n");
2993 ✗ av_log(NULL, AV_LOG_INFO, "usage: %s [OPTIONS] INPUT_FILE\n", program_name);
2994 ✗ av_log(NULL, AV_LOG_INFO, "\n");
2995 ✗ }
2996
2997 ✗ static void ffprobe_show_program_version(AVTextFormatContext *tfc)
2998 {
2999 AVBPrint pbuf;
3000 ✗ av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
3001
3002 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAM_VERSION);
3003 ✗ print_str("version", FFMPEG_VERSION);
3004 ✗ print_fmt("copyright", "Copyright (c) %d-%d the FFmpeg developers",
3005 program_birth_year, CONFIG_THIS_YEAR);
3006 ✗ print_str("compiler_ident", CC_IDENT);
3007 ✗ print_str("configuration", FFMPEG_CONFIGURATION);
3008 ✗ avtext_print_section_footer(tfc);
3009
3010 ✗ av_bprint_finalize(&pbuf, NULL);
3011 ✗ }
3012
3013 #define SHOW_LIB_VERSION(libname, LIBNAME) \
3014 do { \
3015 if (CONFIG_##LIBNAME) { \
3016 unsigned int version = libname##_version(); \
3017 avtext_print_section_header(tfc, NULL, SECTION_ID_LIBRARY_VERSION); \
3018 print_str("name", "lib" #libname); \
3019 print_int("major", LIB##LIBNAME##_VERSION_MAJOR); \
3020 print_int("minor", LIB##LIBNAME##_VERSION_MINOR); \
3021 print_int("micro", LIB##LIBNAME##_VERSION_MICRO); \
3022 print_int("version", version); \
3023 print_str("ident", LIB##LIBNAME##_IDENT); \
3024 avtext_print_section_footer(tfc); \
3025 } \
3026 } while (0)
3027
3028 ✗ static void ffprobe_show_library_versions(AVTextFormatContext *tfc)
3029 {
3030 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_LIBRARY_VERSIONS);
3031 ✗ SHOW_LIB_VERSION(avutil, AVUTIL);
3032 ✗ SHOW_LIB_VERSION(avcodec, AVCODEC);
3033 ✗ SHOW_LIB_VERSION(avformat, AVFORMAT);
3034 ✗ SHOW_LIB_VERSION(avdevice, AVDEVICE);
3035 ✗ SHOW_LIB_VERSION(avfilter, AVFILTER);
3036 ✗ SHOW_LIB_VERSION(swscale, SWSCALE);
3037 ✗ SHOW_LIB_VERSION(swresample, SWRESAMPLE);
3038 ✗ avtext_print_section_footer(tfc);
3039 ✗ }
3040
3041 #define PRINT_PIX_FMT_FLAG(flagname, name) \
3042 do { \
3043 print_int(name, !!(pixdesc->flags & AV_PIX_FMT_FLAG_##flagname)); \
3044 } while (0)
3045
3046 ✗ static void ffprobe_show_pixel_formats(AVTextFormatContext *tfc)
3047 {
3048 ✗ const AVPixFmtDescriptor *pixdesc = NULL;
3049 int i, n;
3050
3051 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PIXEL_FORMATS);
3052 ✗ while (pixdesc = av_pix_fmt_desc_next(pixdesc)) {
3053 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PIXEL_FORMAT);
3054 ✗ print_str("name", pixdesc->name);
3055 ✗ print_int("nb_components", pixdesc->nb_components);
3056 ✗ if ((pixdesc->nb_components >= 3) && !(pixdesc->flags & AV_PIX_FMT_FLAG_RGB)) {
3057 ✗ print_int ("log2_chroma_w", pixdesc->log2_chroma_w);
3058 ✗ print_int ("log2_chroma_h", pixdesc->log2_chroma_h);
3059 } else {
3060 ✗ print_str_opt("log2_chroma_w", "N/A");
3061 ✗ print_str_opt("log2_chroma_h", "N/A");
3062 }
3063 ✗ n = av_get_bits_per_pixel(pixdesc);
3064 ✗ if (n) print_int ("bits_per_pixel", n);
3065 ✗ else print_str_opt("bits_per_pixel", "N/A");
3066 ✗ if (do_show_pixel_format_flags) {
3067 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PIXEL_FORMAT_FLAGS);
3068 ✗ PRINT_PIX_FMT_FLAG(BE, "big_endian");
3069 ✗ PRINT_PIX_FMT_FLAG(PAL, "palette");
3070 ✗ PRINT_PIX_FMT_FLAG(BITSTREAM, "bitstream");
3071 ✗ PRINT_PIX_FMT_FLAG(HWACCEL, "hwaccel");
3072 ✗ PRINT_PIX_FMT_FLAG(PLANAR, "planar");
3073 ✗ PRINT_PIX_FMT_FLAG(RGB, "rgb");
3074 ✗ PRINT_PIX_FMT_FLAG(ALPHA, "alpha");
3075 ✗ avtext_print_section_footer(tfc);
3076 }
3077 ✗ if (do_show_pixel_format_components && (pixdesc->nb_components > 0)) {
3078 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PIXEL_FORMAT_COMPONENTS);
3079 ✗ for (i = 0; i < pixdesc->nb_components; i++) {
3080 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PIXEL_FORMAT_COMPONENT);
3081 ✗ print_int("index", i + 1);
3082 ✗ print_int("bit_depth", pixdesc->comp[i].depth);
3083 ✗ avtext_print_section_footer(tfc);
3084 }
3085 ✗ avtext_print_section_footer(tfc);
3086 }
3087 ✗ avtext_print_section_footer(tfc);
3088 }
3089 ✗ avtext_print_section_footer(tfc);
3090 ✗ }
3091
3092 ✗ static int opt_show_optional_fields(void *optctx, const char *opt, const char *arg)
3093 {
3094 ✗ if (!av_strcasecmp(arg, "always")) show_optional_fields = SHOW_OPTIONAL_FIELDS_ALWAYS;
3095 ✗ else if (!av_strcasecmp(arg, "never")) show_optional_fields = SHOW_OPTIONAL_FIELDS_NEVER;
3096 ✗ else if (!av_strcasecmp(arg, "auto")) show_optional_fields = SHOW_OPTIONAL_FIELDS_AUTO;
3097
3098 ✗ if (show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO && av_strcasecmp(arg, "auto")) {
3099 double num;
3100 ✗ int ret = parse_number("show_optional_fields", arg, OPT_TYPE_INT,
3101 SHOW_OPTIONAL_FIELDS_AUTO, SHOW_OPTIONAL_FIELDS_ALWAYS, &num);
3102 ✗ if (ret < 0)
3103 ✗ return ret;
3104 ✗ show_optional_fields = num;
3105 }
3106 ✗ return 0;
3107 }
3108
3109 21 static int opt_format(void *optctx, const char *opt, const char *arg)
3110 {
3111 21 iformat = av_find_input_format(arg);
3112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (!iformat) {
3113 ✗ av_log(NULL, AV_LOG_ERROR, "Unknown input format: %s\n", arg);
3114 ✗ return AVERROR(EINVAL);
3115 }
3116 21 return 0;
3117 }
3118
3119 2998 static inline void mark_section_show_entries(SectionID section_id,
3120 int show_all_entries, AVDictionary *entries,
3121 int explicitly_selected)
3122 {
3123 2998 EntrySelection *selection = &selected_entries[section_id];
3124
3125 2998 selection->show_all_entries = show_all_entries;
3126 2998 selection->explicitly_selected |= explicitly_selected;
3127
2/2
✓ Branch 0 taken 2284 times.
✓ Branch 1 taken 714 times.
2998 if (show_all_entries) {
3128 2284 const AVTextFormatSection *section = &sections[section_id];
3129
2/2
✓ Branch 0 taken 1847 times.
✓ Branch 1 taken 2284 times.
4131 for (const int *id = section->children_ids; *id != -1; id++)
3130 1847 mark_section_show_entries(*id, show_all_entries, entries, explicitly_selected);
3131 } else {
3132 714 av_dict_copy(&selection->entries_to_show, entries, 0);
3133 }
3134 2998 }
3135
3136 621 static int match_section(const char *section_name,
3137 int show_all_entries, AVDictionary *entries)
3138 {
3139 621 int ret = 0;
3140
3141
2/2
✓ Branch 0 taken 53406 times.
✓ Branch 1 taken 621 times.
54027 for (unsigned i = 0; i < FF_ARRAY_ELEMS(sections); i++) {
3142 53406 const struct AVTextFormatSection *section = &sections[i];
3143
2/2
✓ Branch 0 taken 52728 times.
✓ Branch 1 taken 678 times.
53406 if (!strcmp(section_name, section->name) ||
3144
4/4
✓ Branch 0 taken 32559 times.
✓ Branch 1 taken 20169 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 32263 times.
52728 (section->unique_name && !strcmp(section_name, section->unique_name))) {
3145 974 av_log(NULL, AV_LOG_DEBUG,
3146 "'%s' matches section with unique name '%s'\n", section_name,
3147 974 (char *)av_x_if_null(section->unique_name, section->name));
3148 974 ret++;
3149 974 mark_section_show_entries(section->id, show_all_entries, entries,
3150
2/2
✓ Branch 0 taken 650 times.
✓ Branch 1 taken 324 times.
974 !section->unique_name ||
3151
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 354 times.
650 !strcmp(section_name, section->unique_name));
3152 }
3153 }
3154 621 return ret;
3155 }
3156
3157 322 static int opt_show_entries(void *optctx, const char *opt, const char *arg)
3158 {
3159 322 const char *p = arg;
3160 322 int ret = 0;
3161
3162
2/2
✓ Branch 0 taken 621 times.
✓ Branch 1 taken 322 times.
943 while (*p) {
3163 621 AVDictionary *entries = NULL;
3164 621 char *section_name = av_get_token(&p, "=:");
3165 621 int show_all_entries = 0;
3166
3167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 621 times.
621 if (!section_name) {
3168 ✗ av_log(NULL, AV_LOG_ERROR,
3169 "Missing section name for option '%s'\n", opt);
3170 ✗ return AVERROR(EINVAL);
3171 }
3172
3173
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 245 times.
621 if (*p == '=') {
3174 376 p++;
3175
4/4
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 841 times.
✓ Branch 3 taken 197 times.
1593 while (*p && *p != ':') {
3176 841 char *entry = av_get_token(&p, ",:");
3177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 841 times.
841 if (!entry)
3178 ✗ break;
3179 841 av_log(NULL, AV_LOG_VERBOSE,
3180 "Adding '%s' to the entries to show in section '%s'\n",
3181 entry, section_name);
3182 841 av_dict_set(&entries, entry, "", AV_DICT_DONT_STRDUP_KEY);
3183
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 477 times.
841 if (*p == ',')
3184 477 p++;
3185 }
3186 } else {
3187 245 show_all_entries = 1;
3188 }
3189
3190 621 ret = match_section(section_name, show_all_entries, entries);
3191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 621 times.
621 if (ret == 0) {
3192 ✗ av_log(NULL, AV_LOG_ERROR, "No match for section '%s'\n", section_name);
3193 ✗ ret = AVERROR(EINVAL);
3194 }
3195 621 av_dict_free(&entries);
3196 621 av_free(section_name);
3197
3198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 621 times.
621 if (ret <= 0)
3199 ✗ break;
3200
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 322 times.
621 if (*p)
3201 299 p++;
3202 }
3203
3204 322 return ret;
3205 }
3206
3207 377 static int opt_input_file(void *optctx, const char *arg)
3208 {
3209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (input_filename) {
3210 ✗ av_log(NULL, AV_LOG_ERROR,
3211 "Argument '%s' provided as input filename, but '%s' was already specified.\n",
3212 arg, input_filename);
3213 ✗ return AVERROR(EINVAL);
3214 }
3215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (!strcmp(arg, "-"))
3216 ✗ arg = "fd:";
3217 377 input_filename = av_strdup(arg);
3218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (!input_filename)
3219 ✗ return AVERROR(ENOMEM);
3220
3221 377 return 0;
3222 }
3223
3224 15 static int opt_input_file_i(void *optctx, const char *opt, const char *arg)
3225 {
3226 15 opt_input_file(optctx, arg);
3227 15 return 0;
3228 }
3229
3230 ✗ static int opt_output_file_o(void *optctx, const char *opt, const char *arg)
3231 {
3232 ✗ if (output_filename) {
3233 ✗ av_log(NULL, AV_LOG_ERROR,
3234 "Argument '%s' provided as output filename, but '%s' was already specified.\n",
3235 arg, output_filename);
3236 ✗ return AVERROR(EINVAL);
3237 }
3238 ✗ if (!strcmp(arg, "-"))
3239 ✗ arg = "fd:";
3240 ✗ output_filename = av_strdup(arg);
3241 ✗ if (!output_filename)
3242 ✗ return AVERROR(ENOMEM);
3243
3244 ✗ return 0;
3245 }
3246
3247 29 static int opt_print_filename(void *optctx, const char *opt, const char *arg)
3248 {
3249 29 av_freep(&print_input_filename);
3250 29 print_input_filename = av_strdup(arg);
3251
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 return print_input_filename ? 0 : AVERROR(ENOMEM);
3252 }
3253
3254 ✗ void show_help_default(const char *opt, const char *arg)
3255 {
3256 ✗ av_log_set_callback(log_callback_help);
3257 ✗ show_usage();
3258 ✗ show_help_options(options, "Main options:", 0, 0);
3259 ✗ printf("\n");
3260
3261 ✗ show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
3262 ✗ show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM);
3263 ✗ }
3264
3265 /**
3266 * Parse interval specification, according to the format:
3267 * INTERVAL ::= [START|+START_OFFSET][%[END|+END_OFFSET]]
3268 * INTERVALS ::= INTERVAL[,INTERVALS]
3269 */
3270 27 static int parse_read_interval(const char *interval_spec,
3271 ReadInterval *interval)
3272 {
3273 27 int ret = 0;
3274 27 char *next, *p, *spec = av_strdup(interval_spec);
3275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (!spec)
3276 ✗ return AVERROR(ENOMEM);
3277
3278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (!*spec) {
3279 ✗ av_log(NULL, AV_LOG_ERROR, "Invalid empty interval specification\n");
3280 ✗ ret = AVERROR(EINVAL);
3281 ✗ goto end;
3282 }
3283
3284 27 p = spec;
3285 27 next = strchr(spec, '%');
3286
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if (next)
3287 27 *next++ = 0;
3288
3289 /* parse first part */
3290
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 7 times.
27 if (*p) {
3291 20 interval->has_start = 1;
3292
3293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (*p == '+') {
3294 ✗ interval->start_is_offset = 1;
3295 ✗ p++;
3296 } else {
3297 20 interval->start_is_offset = 0;
3298 }
3299
3300 20 ret = av_parse_time(&interval->start, p, 1);
3301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (ret < 0) {
3302 ✗ av_log(NULL, AV_LOG_ERROR, "Invalid interval start specification '%s'\n", p);
3303 ✗ goto end;
3304 }
3305 } else {
3306 7 interval->has_start = 0;
3307 }
3308
3309 /* parse second part */
3310 27 p = next;
3311
2/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
54 if (p && *p) {
3312 int64_t us;
3313 27 interval->has_end = 1;
3314
3315
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3 times.
27 if (*p == '+') {
3316 24 interval->end_is_offset = 1;
3317 24 p++;
3318 } else {
3319 3 interval->end_is_offset = 0;
3320 }
3321
3322
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
27 if (interval->end_is_offset && *p == '#') {
3323 long long int lli;
3324 char *tail;
3325 24 interval->duration_frames = 1;
3326 24 p++;
3327 24 lli = strtoll(p, &tail, 10);
3328
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if (*tail || lli < 0) {
3329 ✗ av_log(NULL, AV_LOG_ERROR,
3330 "Invalid or negative value '%s' for duration number of frames\n", p);
3331 ✗ goto end;
3332 }
3333 24 interval->end = lli;
3334 } else {
3335 3 interval->duration_frames = 0;
3336 3 ret = av_parse_time(&us, p, 1);
3337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (ret < 0) {
3338 ✗ av_log(NULL, AV_LOG_ERROR, "Invalid interval end/duration specification '%s'\n", p);
3339 ✗ goto end;
3340 }
3341 3 interval->end = us;
3342 }
3343 } else {
3344 ✗ interval->has_end = 0;
3345 }
3346
3347 27 end:
3348 27 av_free(spec);
3349 27 return ret;
3350 }
3351
3352 27 static int parse_read_intervals(const char *intervals_spec)
3353 {
3354 int ret, n, i;
3355 27 char *p, *spec = av_strdup(intervals_spec);
3356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (!spec)
3357 ✗ return AVERROR(ENOMEM);
3358
3359 /* preparse specification, get number of intervals */
3360
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 27 times.
214 for (n = 0, p = spec; *p; p++)
3361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187 times.
187 if (*p == ',')
3362 ✗ n++;
3363 27 n++;
3364
3365 27 read_intervals = av_malloc_array(n, sizeof(*read_intervals));
3366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (!read_intervals) {
3367 ✗ ret = AVERROR(ENOMEM);
3368 ✗ goto end;
3369 }
3370 27 read_intervals_nb = n;
3371
3372 /* parse intervals */
3373 27 p = spec;
3374
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 for (i = 0; p; i++) {
3375 char *next;
3376
3377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 av_assert0(i < read_intervals_nb);
3378 27 next = strchr(p, ',');
3379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (next)
3380 ✗ *next++ = 0;
3381
3382 27 read_intervals[i].id = i;
3383 27 ret = parse_read_interval(p, &read_intervals[i]);
3384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if (ret < 0) {
3385 ✗ av_log(NULL, AV_LOG_ERROR, "Error parsing read interval #%d '%s'\n",
3386 i, p);
3387 ✗ goto end;
3388 }
3389 27 av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval ");
3390 27 log_read_interval(&read_intervals[i], NULL, AV_LOG_VERBOSE);
3391 27 p = next;
3392 }
3393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 av_assert0(i == read_intervals_nb);
3394
3395 27 end:
3396 27 av_free(spec);
3397 27 return ret;
3398 }
3399
3400 27 static int opt_read_intervals(void *optctx, const char *opt, const char *arg)
3401 {
3402 27 return parse_read_intervals(arg);
3403 }
3404
3405 ✗ static int opt_pretty(void *optctx, const char *opt, const char *arg)
3406 {
3407 ✗ show_value_unit = 1;
3408 ✗ use_value_prefix = 1;
3409 ✗ use_byte_value_binary_prefix = 1;
3410 ✗ use_value_sexagesimal_format = 1;
3411 ✗ return 0;
3412 }
3413
3414 ✗ static void print_section(SectionID id, int level)
3415 {
3416 const int *pid;
3417 ✗ const struct AVTextFormatSection *section = &sections[id];
3418 ✗ printf("%c%c%c%c",
3419 ✗ section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER ? 'W' : '.',
3420 ✗ section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY ? 'A' : '.',
3421 ✗ section->flags & AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS ? 'V' : '.',
3422 ✗ section->flags & AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE ? 'T' : '.');
3423 ✗ printf("%*c %s", level * 4, ' ', section->name);
3424 ✗ if (section->unique_name)
3425 ✗ printf("/%s", section->unique_name);
3426 ✗ printf("\n");
3427
3428 ✗ for (pid = section->children_ids; *pid != -1; pid++)
3429 ✗ print_section(*pid, level+1);
3430 ✗ }
3431
3432 ✗ static int opt_sections(void *optctx, const char *opt, const char *arg)
3433 {
3434 ✗ printf("Sections:\n"
3435 "W... = Section is a wrapper (contains other sections, no local entries)\n"
3436 ".A.. = Section contains an array of elements of the same type\n"
3437 "..V. = Section may contain a variable number of fields with variable keys\n"
3438 "...T = Section contain a unique type\n"
3439 "FLAGS NAME/UNIQUE_NAME\n"
3440 "----\n");
3441 ✗ print_section(SECTION_ID_ROOT, 0);
3442 ✗ return 0;
3443 }
3444
3445 ✗ static int opt_codec(void *optctx, const char *opt, const char *arg)
3446 {
3447 ✗ const char *spec = strchr(opt, ':');
3448 const char **name;
3449 ✗ if (!spec) {
3450 ✗ av_log(NULL, AV_LOG_ERROR,
3451 "No media specifier was specified for '%s' in option '%s'. Use -%s:<media_spec> "
3452 "where <media_spec> can be one of: 'a' (audio), 'v' (video), 's' (subtitle), 'd' (data)\n",
3453 arg, opt, opt);
3454 ✗ return AVERROR(EINVAL);
3455 }
3456 ✗ spec++;
3457
3458 ✗ switch (spec[0]) {
3459 ✗ case 'a' : name = &audio_codec_name; break;
3460 ✗ case 'd' : name = &data_codec_name; break;
3461 ✗ case 's' : name = &subtitle_codec_name; break;
3462 ✗ case 'v' : name = &video_codec_name; break;
3463 ✗ default:
3464 ✗ av_log(NULL, AV_LOG_ERROR,
3465 "Invalid media specifier '%s' in option '%s'. "
3466 "Must be one of: 'a' (audio), 'v' (video), 's' (subtitle), 'd' (data)\n", spec, opt);
3467 ✗ return AVERROR(EINVAL);
3468 }
3469
3470 ✗ av_freep(name);
3471 ✗ *name = av_strdup(arg);
3472 ✗ return *name ? 0 : AVERROR(ENOMEM);
3473 }
3474
3475 ✗ static int opt_show_versions(void *optctx, const char *opt, const char *arg)
3476 {
3477 ✗ mark_section_show_entries(SECTION_ID_PROGRAM_VERSION, 1, NULL, 1);
3478 ✗ mark_section_show_entries(SECTION_ID_LIBRARY_VERSION, 1, NULL, 1);
3479 ✗ return 0;
3480 }
3481
3482 #define DEFINE_OPT_SHOW_SECTION(section, target_section_id) \
3483 static int opt_show_##section(void *optctx, const char *opt, const char *arg) \
3484 { \
3485 mark_section_show_entries(SECTION_ID_##target_section_id, 1, NULL, 1); \
3486 return 0; \
3487 }
3488
3489 5 DEFINE_OPT_SHOW_SECTION(chapters, CHAPTERS)
3490 ✗ DEFINE_OPT_SHOW_SECTION(error, ERROR)
3491 29 DEFINE_OPT_SHOW_SECTION(format, FORMAT)
3492 43 DEFINE_OPT_SHOW_SECTION(frames, FRAMES)
3493 ✗ DEFINE_OPT_SHOW_SECTION(library_versions, LIBRARY_VERSIONS)
3494 56 DEFINE_OPT_SHOW_SECTION(packets, PACKETS)
3495 ✗ DEFINE_OPT_SHOW_SECTION(pixel_formats, PIXEL_FORMATS)
3496 ✗ DEFINE_OPT_SHOW_SECTION(program_version, PROGRAM_VERSION)
3497 41 DEFINE_OPT_SHOW_SECTION(streams, STREAMS)
3498 2 DEFINE_OPT_SHOW_SECTION(programs, PROGRAMS)
3499 1 DEFINE_OPT_SHOW_SECTION(stream_groups, STREAM_GROUPS)
3500
3501 static const OptionDef real_options[] = {
3502 CMDUTILS_COMMON_OPTIONS
3503 { "f", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_format}, "force format", "format" },
3504 { "unit", OPT_TYPE_BOOL, 0, {&show_value_unit}, "show unit of the displayed values" },
3505 { "prefix", OPT_TYPE_BOOL, 0, {&use_value_prefix}, "use SI prefixes for the displayed values" },
3506 { "byte_binary_prefix", OPT_TYPE_BOOL, 0, {&use_byte_value_binary_prefix},
3507 "use binary prefixes for byte units" },
3508 { "sexagesimal", OPT_TYPE_BOOL, 0, {&use_value_sexagesimal_format},
3509 "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
3510 { "pretty", OPT_TYPE_FUNC, 0, {.func_arg = opt_pretty},
3511 "prettify the format of displayed values, make it more human readable" },
3512 { "output_format", OPT_TYPE_STRING, 0, { &output_format },
3513 "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)", "format" },
3514 { "print_format", OPT_TYPE_STRING, 0, { &output_format }, "alias for -output_format (deprecated)" },
3515 { "of", OPT_TYPE_STRING, 0, { &output_format }, "alias for -output_format", "format" },
3516 { "select_streams", OPT_TYPE_STRING, 0, { &stream_specifier }, "select the specified streams", "stream_specifier" },
3517 { "sections", OPT_TYPE_FUNC, OPT_EXIT, {.func_arg = opt_sections}, "print sections structure and section information, and exit" },
3518 { "data_dump_format", OPT_TYPE_STRING, 0, { &data_dump_format }, "set data dump format (available formats are: xxd, base64)" },
3519 { "show_data", OPT_TYPE_BOOL, 0, { &do_show_data }, "show packets data" },
3520 { "show_data_hash", OPT_TYPE_STRING, 0, { &show_data_hash }, "show packets data hash" },
3521 { "show_error", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_error }, "show probing error" },
3522 { "show_format", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_format }, "show format/container info" },
3523 { "show_frames", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_frames }, "show frames info" },
3524 { "show_entries", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_show_entries},
3525 "show a set of specified entries", "entry_list" },
3526 #if HAVE_THREADS
3527 { "show_log", OPT_TYPE_INT, 0, { &do_show_log }, "show log" },
3528 #endif
3529 { "show_packets", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_packets }, "show packets info" },
3530 { "show_programs", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_programs }, "show programs info" },
3531 { "show_stream_groups", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_stream_groups }, "show stream groups info" },
3532 { "show_streams", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_streams }, "show streams info" },
3533 { "show_chapters", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_chapters }, "show chapters info" },
3534 { "count_frames", OPT_TYPE_BOOL, 0, { &do_count_frames }, "count the number of frames per stream" },
3535 { "count_packets", OPT_TYPE_BOOL, 0, { &do_count_packets }, "count the number of packets per stream" },
3536 { "show_program_version", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_program_version }, "show ffprobe version" },
3537 { "show_library_versions", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_library_versions }, "show library versions" },
3538 { "show_versions", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_versions }, "show program and library versions" },
3539 { "show_pixel_formats", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_pixel_formats }, "show pixel format descriptions" },
3540 { "show_optional_fields", OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = &opt_show_optional_fields }, "show optional fields" },
3541 { "show_private_data", OPT_TYPE_BOOL, 0, { &show_private_data }, "show private data" },
3542 { "private", OPT_TYPE_BOOL, 0, { &show_private_data }, "same as show_private_data" },
3543 { "analyze_frames", OPT_TYPE_BOOL, 0, { &do_analyze_frames }, "analyze frames to provide additional stream-level information" },
3544 { "bitexact", OPT_TYPE_BOOL, 0, {&do_bitexact}, "force bitexact output" },
3545 { "read_intervals", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_read_intervals}, "set read intervals", "read_intervals" },
3546 { "i", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_input_file_i}, "read specified file", "input_file"},
3547 { "o", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_output_file_o}, "write to specified output", "output_file"},
3548 { "print_filename", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
3549 { "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT, { &find_stream_info },
3550 "read and decode the streams to fill missing information with heuristics" },
3551 { "c", OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = opt_codec}, "force decoder", "decoder_name" },
3552 { "codec", OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = opt_codec}, "alias for -c (force decoder)", "decoder_name" },
3553 { NULL, },
3554 };
3555
3556 37363 static inline int check_section_show_entries(int section_id, int require_explicit)
3557 {
3558 37363 const EntrySelection *selection = &selected_entries[section_id];
3559
3560 /* A shared stream section must not implicitly enable programs or groups. */
3561
4/4
✓ Branch 0 taken 36989 times.
✓ Branch 1 taken 374 times.
✓ Branch 2 taken 344 times.
✓ Branch 3 taken 36645 times.
37363 if (section_id == SECTION_ID_PROGRAM_STREAMS ||
3562 section_id == SECTION_ID_STREAM_GROUP_STREAMS)
3563 718 require_explicit = 1;
3564
3565
4/4
✓ Branch 0 taken 5732 times.
✓ Branch 1 taken 31631 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 5730 times.
37363 if ((!require_explicit || selection->explicitly_selected) &&
3566
4/4
✓ Branch 0 taken 30974 times.
✓ Branch 1 taken 659 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 30672 times.
31633 (selection->show_all_entries || selection->entries_to_show))
3567 961 return 1;
3568
3569 36402 const AVTextFormatSection *section = &sections[section_id];
3570
2/2
✓ Branch 0 taken 27184 times.
✓ Branch 1 taken 36002 times.
63186 for (const int *id = section->children_ids; *id != -1; id++)
3571
2/2
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 26784 times.
27184 if (check_section_show_entries(*id, require_explicit))
3572 400 return 1;
3573 36002 return 0;
3574 }
3575
3576 #define SET_DO_SHOW(id, varname) do { \
3577 if (check_section_show_entries(SECTION_ID_##id, 0)) \
3578 do_show_##varname = 1; \
3579 } while (0)
3580
3581 377 int main(int argc, char **argv)
3582 {
3583 const AVTextFormatter *f;
3584 AVTextFormatContext *tctx;
3585 AVTextWriterContext *wctx;
3586 char *buf;
3587 377 char *f_name = NULL, *f_args = NULL;
3588 int ret, input_ret;
3589 377 AVTextFormatDataDump data_dump_format_id = AV_TEXTFORMAT_DATADUMP_XXD;
3590
3591 377 init_dynload();
3592
3593 377 setvbuf(stderr, NULL, _IONBF, 0); /* win32 runtime needs this */
3594
3595 377 av_log_set_flags(AV_LOG_SKIP_REPEATED);
3596
3597 377 options = real_options;
3598 377 parse_loglevel(argc, argv, options);
3599 377 avformat_network_init();
3600 #if CONFIG_AVDEVICE
3601 377 avdevice_register_all();
3602 #endif
3603
3604 377 show_banner(argc, argv, options);
3605 377 ret = parse_options(NULL, argc, argv, options, opt_input_file);
3606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (ret < 0) {
3607 ✗ ret = (ret == AVERROR_EXIT) ? 0 : ret;
3608 ✗ goto end;
3609 }
3610
3611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (do_show_log)
3612 ✗ av_log_set_callback(log_callback);
3613
3614 /* mark things to show, based on -show_entries */
3615
2/2
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 370 times.
377 SET_DO_SHOW(CHAPTERS, chapters);
3616
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 SET_DO_SHOW(ERROR, error);
3617
2/2
✓ Branch 1 taken 86 times.
✓ Branch 2 taken 291 times.
377 SET_DO_SHOW(FORMAT, format);
3618
2/2
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 302 times.
377 SET_DO_SHOW(FRAMES, frames);
3619
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 SET_DO_SHOW(LIBRARY_VERSIONS, library_versions);
3620
2/2
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 266 times.
377 SET_DO_SHOW(PACKETS, packets);
3621
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 SET_DO_SHOW(PIXEL_FORMATS, pixel_formats);
3622
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 SET_DO_SHOW(PIXEL_FORMAT_FLAGS, pixel_format_flags);
3623
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 SET_DO_SHOW(PIXEL_FORMAT_COMPONENTS, pixel_format_components);
3624
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 SET_DO_SHOW(PROGRAM_VERSION, program_version);
3625
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 373 times.
377 SET_DO_SHOW(PROGRAMS, programs);
3626
2/2
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 367 times.
377 SET_DO_SHOW(STREAM_GROUP_DISPOSITION, stream_group_disposition);
3627
2/2
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 343 times.
377 SET_DO_SHOW(STREAM_GROUPS, stream_groups);
3628
2/2
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 352 times.
377 SET_DO_SHOW(STREAM_GROUP_COMPONENTS, stream_group_components);
3629
2/2
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 150 times.
377 SET_DO_SHOW(STREAMS, streams);
3630
2/2
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 315 times.
377 SET_DO_SHOW(STREAM_DISPOSITION, stream_disposition);
3631
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 371 times.
377 SET_DO_SHOW(PROGRAM_STREAM_DISPOSITION, stream_disposition);
3632
2/2
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 351 times.
377 SET_DO_SHOW(STREAM_GROUP_STREAM_DISPOSITION, stream_disposition);
3633
3634
2/2
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 370 times.
377 SET_DO_SHOW(CHAPTER_TAGS, chapter_tags);
3635
2/2
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 306 times.
377 SET_DO_SHOW(FORMAT_TAGS, format_tags);
3636
2/2
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 317 times.
377 SET_DO_SHOW(FRAME_TAGS, frame_tags);
3637
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 376 times.
377 SET_DO_SHOW(PROGRAM_TAGS, program_tags);
3638
2/2
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 367 times.
377 SET_DO_SHOW(STREAM_GROUP_TAGS, stream_group_tags);
3639
2/2
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 305 times.
377 SET_DO_SHOW(STREAM_TAGS, stream_tags);
3640
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 371 times.
377 SET_DO_SHOW(PROGRAM_STREAM_TAGS, stream_tags);
3641
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 372 times.
377 SET_DO_SHOW(STREAM_GROUP_STREAM_TAGS, stream_tags);
3642
2/2
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 321 times.
377 SET_DO_SHOW(PACKET_TAGS, packet_tags);
3643
3644
4/6
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 301 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 301 times.
377 if (do_bitexact && (do_show_program_version || do_show_library_versions)) {
3645 ✗ av_log(NULL, AV_LOG_ERROR,
3646 "-bitexact and -show_program_version or -show_library_versions "
3647 "options are incompatible\n");
3648 ✗ ret = AVERROR(EINVAL);
3649 ✗ goto end;
3650 }
3651
3652
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 177 times.
377 if (!output_format)
3653 200 output_format = av_strdup("default");
3654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (!output_format) {
3655 ✗ ret = AVERROR(ENOMEM);
3656 ✗ goto end;
3657 }
3658 377 f_name = av_strtok(output_format, "=", &buf);
3659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (!f_name) {
3660 ✗ av_log(NULL, AV_LOG_ERROR,
3661 "No name specified for the output format\n");
3662 ✗ ret = AVERROR(EINVAL);
3663 ✗ goto end;
3664 }
3665 377 f_args = buf;
3666
3667 377 f = avtext_get_formatter_by_name(f_name);
3668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (!f) {
3669 ✗ av_log(NULL, AV_LOG_ERROR, "Unknown output format with name '%s'\n", f_name);
3670 ✗ ret = AVERROR(EINVAL);
3671 ✗ goto end;
3672 }
3673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (f->flags & AV_TEXTFORMAT_FLAG_IS_DIAGRAM_FORMATTER) {
3674 ✗ av_log(NULL, AV_LOG_ERROR, "Output format '%s' can only draw filter graphs\n", f_name);
3675 ✗ ret = AVERROR(EINVAL);
3676 ✗ goto end;
3677 }
3678
3679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (data_dump_format) {
3680 ✗ if (!strcmp(data_dump_format, "xxd")) {
3681 ✗ data_dump_format_id = AV_TEXTFORMAT_DATADUMP_XXD;
3682 ✗ } else if (!strcmp(data_dump_format, "base64")) {
3683 ✗ data_dump_format_id = AV_TEXTFORMAT_DATADUMP_BASE64;
3684 } else {
3685 ✗ av_log(NULL, AV_LOG_ERROR, "Unknown data dump format with name '%s'\n", data_dump_format);
3686 ✗ ret = AVERROR(EINVAL);
3687 ✗ goto end;
3688 }
3689 }
3690
3691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (output_filename) {
3692 ✗ ret = avtextwriter_create_file(&wctx, output_filename);
3693 } else
3694 377 ret = avtextwriter_create_stdout(&wctx);
3695
3696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (ret < 0)
3697 ✗ goto end;
3698
3699 377 AVTextFormatOptions tf_options = {
3700 .is_key_selected = is_key_selected_callback,
3701 .show_optional_fields = show_optional_fields,
3702 .show_value_unit = show_value_unit,
3703 .use_value_prefix = use_value_prefix,
3704 .use_byte_value_binary_prefix = use_byte_value_binary_prefix,
3705 .use_value_sexagesimal_format = use_value_sexagesimal_format,
3706 .data_dump_format = data_dump_format_id,
3707 };
3708
3709
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
377 if ((ret = avtext_context_open(&tctx, f, wctx, f_args, sections, FF_ARRAY_ELEMS(sections), tf_options, show_data_hash)) >= 0) {
3710
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 375 times.
377 if (f == &avtextformatter_xml)
3711 2 tctx->string_validation_utf8_flags |= AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES;
3712
3713 377 avtext_print_section_header(tctx, NULL, SECTION_ID_ROOT);
3714
3715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (do_show_program_version)
3716 ✗ ffprobe_show_program_version(tctx);
3717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (do_show_library_versions)
3718 ✗ ffprobe_show_library_versions(tctx);
3719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (do_show_pixel_formats)
3720 ✗ ffprobe_show_pixel_formats(tctx);
3721
3722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (!input_filename &&
3723 ✗ ((do_show_format || do_show_programs || do_show_stream_groups || do_show_streams || do_show_chapters || do_show_packets || do_show_error) ||
3724 ✗ (!do_show_program_version && !do_show_library_versions && !do_show_pixel_formats))) {
3725 ✗ show_usage();
3726 ✗ av_log(NULL, AV_LOG_ERROR, "You have to specify one input file.\n");
3727 ✗ av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
3728 ✗ ret = AVERROR(EINVAL);
3729
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 } else if (input_filename) {
3730 377 ret = probe_file(tctx, input_filename, print_input_filename);
3731
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
377 if (ret < 0 && do_show_error)
3732 ✗ show_error(tctx, ret);
3733 }
3734
3735 377 input_ret = ret;
3736
3737 377 avtext_print_section_footer(tctx);
3738
3739 377 ret = avtextwriter_context_close(&wctx);
3740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (ret < 0)
3741 ✗ av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing writer): %s\n", av_err2str(ret));
3742
3743 377 ret = avtext_context_close(&tctx);
3744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if (ret < 0)
3745 ✗ av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing formatter): %s\n", av_err2str(ret));
3746
3747 377 ret = FFMIN(ret, input_ret);
3748 }
3749
3750 ✗ end:
3751 377 av_freep(&output_format);
3752 377 av_freep(&output_filename);
3753 377 av_freep(&input_filename);
3754 377 av_freep(&print_input_filename);
3755 377 av_freep(&read_intervals);
3756
3757 377 uninit_opts();
3758
2/2
✓ Branch 0 taken 32422 times.
✓ Branch 1 taken 377 times.
32799 for (size_t i = 0; i < FF_ARRAY_ELEMS(selected_entries); ++i)
3759 32422 av_dict_free(&selected_entries[i].entries_to_show);
3760
3761 377 avformat_network_deinit();
3762
3763 377 return ret < 0;
3764 }
3765