FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffprobe.c
Date: 2026-10-19 01:23:10
Exec Total Coverage
Lines: 1513 2119 71.4%
Functions: 72 96 75.0%
Branches: 827 1366 60.5%

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 867 static const char *get_packet_side_data_type(const void *data)
256 {
257 867 const AVPacketSideData *sd = (const AVPacketSideData *)data;
258 867 return av_x_if_null(av_packet_side_data_name(sd->type), "unknown");
259 }
260
261 156 static const char *get_frame_side_data_type(const void *data)
262 {
263 156 const AVFrameSideData *sd = (const AVFrameSideData *)data;
264 156 return av_x_if_null(av_frame_side_data_name(sd->type), "unknown");
265 }
266
267 5 static const char *get_raw_string_type(const void *data)
268 {
269 5 return data;
270 }
271
272 2 static const char *get_stream_group_type(const void *data)
273 {
274 2 const AVStreamGroup *stg = (const AVStreamGroup *)data;
275 2 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 181340 static int is_key_selected_callback(AVTextFormatContext *tctx, const char *key)
412 {
413 181340 const AVTextFormatSection *section = tctx->section[tctx->level];
414 181340 const EntrySelection *selection = &selected_entries[section - sections];
415
416
4/4
✓ Branch 0 taken 108398 times.
✓ Branch 1 taken 72942 times.
✓ Branch 3 taken 19743 times.
✓ Branch 4 taken 88655 times.
181340 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 101 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 101 unsigned offset = 0;
507
508 101 av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
509 101 av_bprint_chars(&bp, '\n', 1);
510
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 101 times.
404 while (size) {
511 303 av_bprintf(&bp, "%08x: ", offset);
512
2/2
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 303 times.
1212 for (int i = 0, l = FFMIN(size, columns); i < l; i++) {
513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
909 if (bytes == 1) av_bprintf(&bp, format, *(const uint8_t*)data);
514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
909 else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
515
1/2
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
909 else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
516 909 data = (const char*)data + bytes;
517 909 size--;
518 }
519 303 av_bprint_chars(&bp, '\n', 1);
520 303 offset += offset_add;
521 }
522 101 avtext_print_string(tfc, key, bp.str, 0);
523 101 }
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 1901 static inline int show_tags(AVTextFormatContext *tfc, AVDictionary *tags, int section_id)
534 {
535 1901 const AVDictionaryEntry *tag = NULL;
536 1901 int ret = 0;
537
538
2/2
✓ Branch 0 taken 1118 times.
✓ Branch 1 taken 783 times.
1901 if (!tags)
539 1118 return 0;
540 783 avtext_print_section_header(tfc, NULL, section_id);
541
542
2/2
✓ Branch 1 taken 4512 times.
✓ Branch 2 taken 783 times.
5295 while ((tag = av_dict_iterate(tags, tag))) {
543
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4512 times.
4512 if ((ret = print_str_validate(tag->key, tag->value)) < 0)
544 ✗ break;
545 }
546 783 avtext_print_section_footer(tfc);
547
548 783 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 101 static void print_displaymatrix(AVTextFormatContext *tfc, const int32_t matrix[9])
576 {
577 101 double rotation = av_display_rotation_get(matrix);
578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if (isnan(rotation))
579 ✗ rotation = 0;
580 101 print_integers(tfc, "displaymatrix", matrix, 9, " %11d", 3, 4, 1);
581 101 print_int("rotation", rotation);
582 101 }
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 ✗ static void print_film_grain_params(AVTextFormatContext *tfc,
1007 const AVFilmGrainParams *fgp)
1008 {
1009 const char *color_range, *color_primaries, *color_trc, *color_space;
1010 ✗ const char *const film_grain_type_names[] = {
1011 [AV_FILM_GRAIN_PARAMS_NONE] = "none",
1012 [AV_FILM_GRAIN_PARAMS_AV1] = "av1",
1013 [AV_FILM_GRAIN_PARAMS_H274] = "h274",
1014 };
1015 ✗ const char *const component_names[] = { "Y", "Cb", "Cr" };
1016
1017 AVBPrint pbuf;
1018 ✗ if (!fgp || fgp->type >= FF_ARRAY_ELEMS(film_grain_type_names))
1019 ✗ return;
1020
1021 ✗ color_range = av_color_range_name(fgp->color_range);
1022 ✗ color_primaries = av_color_primaries_name(fgp->color_primaries);
1023 ✗ color_trc = av_color_transfer_name(fgp->color_trc);
1024 ✗ color_space = av_color_space_name(fgp->color_space);
1025
1026 ✗ av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
1027 ✗ print_str("type", film_grain_type_names[fgp->type]);
1028 ✗ print_fmt("seed", "%"PRIu64, fgp->seed);
1029 ✗ print_int("width", fgp->width);
1030 ✗ print_int("height", fgp->height);
1031 ✗ print_int("subsampling_x", fgp->subsampling_x);
1032 ✗ print_int("subsampling_y", fgp->subsampling_y);
1033 ✗ print_str("color_range", color_range ? color_range : "unknown");
1034 ✗ print_str("color_primaries", color_primaries ? color_primaries : "unknown");
1035 ✗ print_str("color_trc", color_trc ? color_trc : "unknown");
1036 ✗ print_str("color_space", color_space ? color_space : "unknown");
1037
1038 ✗ switch (fgp->type) {
1039 ✗ case AV_FILM_GRAIN_PARAMS_NONE:
1040 ✗ break;
1041 ✗ case AV_FILM_GRAIN_PARAMS_AV1: {
1042 ✗ const AVFilmGrainAOMParams *aom = &fgp->codec.aom;
1043 ✗ const int num_ar_coeffs_y = 2 * aom->ar_coeff_lag * (aom->ar_coeff_lag + 1);
1044 ✗ const int num_ar_coeffs_uv = num_ar_coeffs_y + !!aom->num_y_points;
1045 ✗ print_int("chroma_scaling_from_luma", aom->chroma_scaling_from_luma);
1046 ✗ print_int("scaling_shift", aom->scaling_shift);
1047 ✗ print_int("ar_coeff_lag", aom->ar_coeff_lag);
1048 ✗ print_int("ar_coeff_shift", aom->ar_coeff_shift);
1049 ✗ print_int("grain_scale_shift", aom->grain_scale_shift);
1050 ✗ print_int("overlap_flag", aom->overlap_flag);
1051 ✗ print_int("limit_output_range", aom->limit_output_range);
1052
1053 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST);
1054
1055 ✗ if (aom->num_y_points) {
1056 ✗ avtext_print_section_header(tfc, component_names[0], SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
1057
1058 ✗ print_int("bit_depth_luma", fgp->bit_depth_luma);
1059 ✗ print_list_fmt("y_points_value", "%"PRIu8, aom->num_y_points, 1, aom->y_points[idx][0]);
1060 ✗ print_list_fmt("y_points_scaling", "%"PRIu8, aom->num_y_points, 1, aom->y_points[idx][1]);
1061 ✗ print_list_fmt("ar_coeffs_y", "%"PRId8, num_ar_coeffs_y, 1, aom->ar_coeffs_y[idx]);
1062
1063 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
1064 ✗ avtext_print_section_footer(tfc);
1065 }
1066
1067 ✗ for (unsigned uv = 0; uv < 2; uv++) {
1068 ✗ if (!aom->num_uv_points[uv] && !aom->chroma_scaling_from_luma)
1069 ✗ continue;
1070
1071 ✗ avtext_print_section_header(tfc, component_names[1 + uv], SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
1072
1073 ✗ print_int("bit_depth_chroma", fgp->bit_depth_chroma);
1074 ✗ print_list_fmt("uv_points_value", "%"PRIu8, aom->num_uv_points[uv], 1, aom->uv_points[uv][idx][0]);
1075 ✗ print_list_fmt("uv_points_scaling", "%"PRIu8, aom->num_uv_points[uv], 1, aom->uv_points[uv][idx][1]);
1076 ✗ print_list_fmt("ar_coeffs_uv", "%"PRId8, num_ar_coeffs_uv, 1, aom->ar_coeffs_uv[uv][idx]);
1077 ✗ print_int("uv_mult", aom->uv_mult[uv]);
1078 ✗ print_int("uv_mult_luma", aom->uv_mult_luma[uv]);
1079 ✗ print_int("uv_offset", aom->uv_offset[uv]);
1080
1081 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
1082 ✗ avtext_print_section_footer(tfc);
1083 }
1084
1085 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
1086 ✗ avtext_print_section_footer(tfc);
1087 ✗ break;
1088 }
1089 ✗ case AV_FILM_GRAIN_PARAMS_H274: {
1090 ✗ const AVFilmGrainH274Params *h274 = &fgp->codec.h274;
1091 ✗ print_int("model_id", h274->model_id);
1092 ✗ print_int("blending_mode_id", h274->blending_mode_id);
1093 ✗ print_int("log2_scale_factor", h274->log2_scale_factor);
1094
1095 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST);
1096
1097 ✗ for (int c = 0; c < 3; c++) {
1098 ✗ if (!h274->component_model_present[c])
1099 ✗ continue;
1100
1101 ✗ avtext_print_section_header(tfc, component_names[c], SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
1102 ✗ print_int(c ? "bit_depth_chroma" : "bit_depth_luma", c ? fgp->bit_depth_chroma : fgp->bit_depth_luma);
1103
1104 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST);
1105 ✗ for (int i = 0; i < h274->num_intensity_intervals[c]; i++) {
1106
1107 ✗ avtext_print_section_header(tfc, "Intensity interval", SECTION_ID_FRAME_SIDE_DATA_PIECE);
1108 ✗ print_int("intensity_interval_lower_bound", h274->intensity_interval_lower_bound[c][i]);
1109 ✗ print_int("intensity_interval_upper_bound", h274->intensity_interval_upper_bound[c][i]);
1110 ✗ print_list_fmt("comp_model_value", "%"PRId16, h274->num_model_values[c], 1, h274->comp_model_value[c][i][idx]);
1111
1112 // SECTION_ID_FRAME_SIDE_DATA_PIECE
1113 ✗ avtext_print_section_footer(tfc);
1114 }
1115
1116 // SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST
1117 ✗ avtext_print_section_footer(tfc);
1118
1119 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
1120 ✗ avtext_print_section_footer(tfc);
1121 }
1122
1123 // SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
1124 ✗ avtext_print_section_footer(tfc);
1125 ✗ break;
1126 }
1127 }
1128
1129 ✗ av_bprint_finalize(&pbuf, NULL);
1130 }
1131
1132 #define PKT_SIDE_DATA_IN_STREAM 1
1133 #define PKT_SIDE_DATA_IN_STREAM_GROUP 2
1134 #define PKT_SIDE_DATA_IN_STREAM_GROUP_STREAM 3
1135 #define PKT_SIDE_DATA_IN_PROGRAM_STREAM 4
1136
1137 1105 static void print_pkt_side_data(AVTextFormatContext *tfc,
1138 int width,
1139 int height,
1140 const AVPacketSideData *sd,
1141 int container)
1142 {
1143 1105 const char *name = av_packet_side_data_name(sd->type);
1144 1105 const SectionID section_header[] = {
1145 SECTION_ID_PACKET_SIDE_DATA,
1146 SECTION_ID_STREAM_SIDE_DATA,
1147 SECTION_ID_STREAM_GROUP_SIDE_DATA,
1148 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA,
1149 SECTION_ID_PROGRAM_STREAM_SIDE_DATA,
1150 };
1151 1105 const SectionID section_component_list[] = {
1152 SECTION_ID_PACKET_SIDE_DATA_COMPONENT_LIST,
1153 SECTION_ID_STREAM_SIDE_DATA_COMPONENT_LIST,
1154 SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT_LIST,
1155 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT_LIST,
1156 SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT_LIST,
1157 };
1158 1105 const SectionID section_component[] = {
1159 SECTION_ID_PACKET_SIDE_DATA_COMPONENT,
1160 SECTION_ID_STREAM_SIDE_DATA_COMPONENT,
1161 SECTION_ID_STREAM_GROUP_SIDE_DATA_COMPONENT,
1162 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_COMPONENT,
1163 SECTION_ID_PROGRAM_STREAM_SIDE_DATA_COMPONENT,
1164 };
1165
1166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1105 times.
1105 av_assert0(container < FF_ARRAY_ELEMS(section_header));
1167
1168 1105 avtext_print_section_header(tfc, sd, section_header[container]);
1169
1/2
✓ Branch 0 taken 1105 times.
✗ Branch 1 not taken.
1105 print_str("side_data_type", name ? name : "unknown");
1170
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1096 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
1105 if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
1171 9 print_displaymatrix(tfc, (const int32_t*)sd->data);
1172
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1080 times.
1096 } else if (sd->type == AV_PKT_DATA_STEREO3D) {
1173 16 const AVStereo3D *stereo = (AVStereo3D *)sd->data;
1174 16 print_str("type", av_stereo3d_type_name(stereo->type));
1175 16 print_int("inverted", !!(stereo->flags & AV_STEREO3D_FLAG_INVERT));
1176 16 print_str("view", av_stereo3d_view_name(stereo->view));
1177 16 print_str("primary_eye", av_stereo3d_primary_eye_name(stereo->primary_eye));
1178 16 print_int("baseline", stereo->baseline);
1179 16 print_q("horizontal_disparity_adjustment", stereo->horizontal_disparity_adjustment, '/');
1180 16 print_q("horizontal_field_of_view", stereo->horizontal_field_of_view, '/');
1181
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1076 times.
1080 } else if (sd->type == AV_PKT_DATA_SPHERICAL) {
1182 4 const AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data;
1183 4 print_str("projection", av_spherical_projection_name(spherical->projection));
1184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
1185 ✗ print_int("padding", spherical->padding);
1186
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 } else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
1187 size_t l, t, r, b;
1188 4 av_spherical_tile_bounds(spherical, width, height,
1189 &l, &t, &r, &b);
1190 4 print_int("bound_left", l);
1191 4 print_int("bound_top", t);
1192 4 print_int("bound_right", r);
1193 4 print_int("bound_bottom", b);
1194 }
1195
1196 4 print_int("yaw", (double) spherical->yaw / (1 << 16));
1197 4 print_int("pitch", (double) spherical->pitch / (1 << 16));
1198 4 print_int("roll", (double) spherical->roll / (1 << 16));
1199
3/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 1026 times.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
1076 } else if (sd->type == AV_PKT_DATA_SKIP_SAMPLES && sd->size == 10) {
1200 50 print_int("skip_samples", AV_RL32(sd->data));
1201 50 print_int("discard_padding", AV_RL32(sd->data + 4));
1202 50 print_int("skip_reason", AV_RL8(sd->data + 8));
1203 50 print_int("discard_reason", AV_RL8(sd->data + 9));
1204
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1020 times.
1026 } else if (sd->type == AV_PKT_DATA_MASTERING_DISPLAY_METADATA) {
1205 6 print_mastering_display_metadata(tfc, (AVMasteringDisplayMetadata *)sd->data);
1206
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1015 times.
1020 } else if (sd->type == AV_PKT_DATA_CONTENT_LIGHT_LEVEL) {
1207 5 print_context_light_level(tfc, (AVContentLightMetadata *)sd->data);
1208
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1013 times.
1015 } else if (sd->type == AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
1209 2 print_ambient_viewing_environment(
1210 2 tfc, (const AVAmbientViewingEnvironment *)sd->data);
1211
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1011 times.
1013 } else if (sd->type == AV_PKT_DATA_DYNAMIC_HDR10_PLUS) {
1212 2 AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
1213 2 print_dynamic_hdr10_plus(tfc, metadata);
1214
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1003 times.
1011 } else if (sd->type == AV_PKT_DATA_DOVI_CONF) {
1215 8 AVDOVIDecoderConfigurationRecord *dovi = (AVDOVIDecoderConfigurationRecord *)sd->data;
1216 8 const char *comp = "unknown";
1217 8 print_int("dv_version_major", dovi->dv_version_major);
1218 8 print_int("dv_version_minor", dovi->dv_version_minor);
1219 8 print_int("dv_profile", dovi->dv_profile);
1220 8 print_int("dv_level", dovi->dv_level);
1221 8 print_int("rpu_present_flag", dovi->rpu_present_flag);
1222 8 print_int("el_present_flag", dovi->el_present_flag);
1223 8 print_int("bl_present_flag", dovi->bl_present_flag);
1224 8 print_int("dv_bl_signal_compatibility_id", dovi->dv_bl_signal_compatibility_id);
1225
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)
1226 {
1227 8 case AV_DOVI_COMPRESSION_NONE: comp = "none"; break;
1228 ✗ case AV_DOVI_COMPRESSION_LIMITED: comp = "limited"; break;
1229 ✗ case AV_DOVI_COMPRESSION_RESERVED: comp = "reserved"; break;
1230 ✗ case AV_DOVI_COMPRESSION_EXTENDED: comp = "extended"; break;
1231 }
1232 8 print_str("dv_md_compression", comp);
1233
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1000 times.
1003 } else if (sd->type == AV_PKT_DATA_AUDIO_SERVICE_TYPE) {
1234 3 enum AVAudioServiceType *t = (enum AVAudioServiceType *)sd->data;
1235 3 print_int("service_type", *t);
1236
2/2
✓ Branch 0 taken 794 times.
✓ Branch 1 taken 206 times.
1000 } else if (sd->type == AV_PKT_DATA_MPEGTS_STREAM_ID) {
1237 794 print_int("id", *sd->data);
1238
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 187 times.
206 } else if (sd->type == AV_PKT_DATA_CPB_PROPERTIES) {
1239 19 const AVCPBProperties *prop = (AVCPBProperties *)sd->data;
1240 19 print_int("max_bitrate", prop->max_bitrate);
1241 19 print_int("min_bitrate", prop->min_bitrate);
1242 19 print_int("avg_bitrate", prop->avg_bitrate);
1243 19 print_int("buffer_size", prop->buffer_size);
1244 19 print_int("vbv_delay", prop->vbv_delay);
1245
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 8 times.
187 } else if (sd->type == AV_PKT_DATA_WEBVTT_IDENTIFIER ||
1246
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 163 times.
179 sd->type == AV_PKT_DATA_WEBVTT_SETTINGS) {
1247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (do_show_data)
1248 ✗ avtext_print_data(tfc, "data", sd->data, sd->size);
1249 24 avtext_print_data_hash(tfc, "data_hash", sd->data, sd->size);
1250
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 152 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
163 } else if (sd->type == AV_PKT_DATA_FRAME_CROPPING && sd->size >= sizeof(uint32_t) * 4) {
1251 11 print_int("crop_top", AV_RL32(sd->data));
1252 11 print_int("crop_bottom", AV_RL32(sd->data + 4));
1253 11 print_int("crop_left", AV_RL32(sd->data + 8));
1254 11 print_int("crop_right", AV_RL32(sd->data + 12));
1255
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
152 } else if (sd->type == AV_PKT_DATA_AFD && sd->size > 0) {
1256 ✗ print_int("active_format", *sd->data);
1257
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 150 times.
152 } else if (sd->type == AV_PKT_DATA_EXIF) {
1258 2 print_int("size", sd->size);
1259
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 } else if (sd->type == AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL && sd->size >= 8) {
1260 ✗ print_int("block_additional_id", AV_RB64(sd->data));
1261 ✗ if (do_show_data)
1262 ✗ avtext_print_data(tfc, "block_additional_data", sd->data + 8, sd->size - 8);
1263
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 149 times.
150 } else if (sd->type == AV_PKT_DATA_GAIN_MAP_PARAMS) {
1264 1 const AVGainMapParams *gain = (AVGainMapParams *)sd->data;
1265 1 print_int("version", gain->version);
1266 1 print_int("use_base_color_space", gain->use_base_color_space);
1267 1 print_q("base_hdr_headroom", gain->base_hdr_headroom, '/');
1268 1 print_q("alternate_hdr_headroom", gain->alternate_hdr_headroom, '/');
1269 1 print_int("nb_channels", gain->nb_channels);
1270
1271
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) &&
1272 container < FF_ARRAY_ELEMS(section_component));
1273 1 avtext_print_section_header(tfc, NULL, section_component_list[container]);
1274
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for (int c = 0; c < gain->nb_channels; c++) {
1275 1 const struct AVGainMapChannel *channel = &gain->channels[c];
1276 1 avtext_print_section_header(tfc, "Gain Map Channel", section_component[container]);
1277 1 print_q("gain_map_min", channel->gain_map_min, '/');
1278 1 print_q("gain_map_max", channel->gain_map_max, '/');
1279 1 print_q("gamma", channel->gamma, '/');
1280 1 print_q("base_offset", channel->base_offset, '/');
1281 1 print_q("alternate_offset", channel->alternate_offset, '/');
1282 1 avtext_print_section_footer(tfc);
1283 }
1284 1 avtext_print_section_footer(tfc);
1285 }
1286 1105 avtext_print_section_footer(tfc);
1287 1105 }
1288
1289 591 static void print_private_data(AVTextFormatContext *tfc, void *priv_data)
1290 {
1291 591 const AVOption *opt = NULL;
1292
2/2
✓ Branch 1 taken 4685 times.
✓ Branch 2 taken 591 times.
5276 while (opt = av_opt_next(priv_data, opt)) {
1293 uint8_t *str;
1294
2/2
✓ Branch 0 taken 4429 times.
✓ Branch 1 taken 256 times.
4685 if (!(opt->flags & AV_OPT_FLAG_EXPORT)) continue;
1295
1/2
✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
256 if (av_opt_get(priv_data, opt->name, 0, &str) >= 0) {
1296 256 print_str(opt->name, str);
1297 256 av_free(str);
1298 }
1299 }
1300 591 }
1301
1302 1016 static void print_pixel_format(AVTextFormatContext *tfc, enum AVPixelFormat pix_fmt)
1303 {
1304 1016 const char *s = av_get_pix_fmt_name(pix_fmt);
1305 enum AVPixelFormat swapped_pix_fmt;
1306
1307
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1014 times.
1016 if (!s) {
1308 2 print_str_opt("pix_fmt", "unknown");
1309
4/4
✓ Branch 0 taken 970 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 937 times.
✓ Branch 3 taken 33 times.
1984 } else if (!do_bitexact ||
1310 970 (swapped_pix_fmt = av_pix_fmt_swap_endianness(pix_fmt)) == AV_PIX_FMT_NONE) {
1311 981 print_str ("pix_fmt", s);
1312 } else {
1313 33 const char *s2 = av_get_pix_fmt_name(swapped_pix_fmt);
1314 char buf[128];
1315 33 size_t i = 0;
1316
1317
4/6
✓ Branch 0 taken 323 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 290 times.
✗ Branch 5 not taken.
323 while (s[i] && s[i] == s2[i] && i < sizeof(buf) - 1) {
1318 290 buf[i] = s[i];
1319 290 i++;
1320 }
1321 33 buf[i] = '\0';
1322
1323 33 print_str ("pix_fmt", buf);
1324 }
1325 1016 }
1326
1327 1016 static void print_color_range(AVTextFormatContext *tfc, enum AVColorRange color_range)
1328 {
1329 1016 const char *val = av_color_range_name(color_range);
1330
3/4
✓ Branch 0 taken 1016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 517 times.
✓ Branch 3 taken 499 times.
1016 if (!val || color_range == AVCOL_RANGE_UNSPECIFIED) {
1331 517 print_str_opt("color_range", "unknown");
1332 } else {
1333 499 print_str("color_range", val);
1334 }
1335 1016 }
1336
1337 1016 static void print_color_space(AVTextFormatContext *tfc, enum AVColorSpace color_space)
1338 {
1339 1016 const char *val = av_color_space_name(color_space);
1340
3/4
✓ Branch 0 taken 1016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 741 times.
✓ Branch 3 taken 275 times.
1016 if (!val || color_space == AVCOL_SPC_UNSPECIFIED) {
1341 741 print_str_opt("color_space", "unknown");
1342 } else {
1343 275 print_str("color_space", val);
1344 }
1345 1016 }
1346
1347 1016 static void print_primaries(AVTextFormatContext *tfc, enum AVColorPrimaries color_primaries)
1348 {
1349 1016 const char *val = av_color_primaries_name(color_primaries);
1350
3/4
✓ Branch 0 taken 1016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 237 times.
1016 if (!val || color_primaries == AVCOL_PRI_UNSPECIFIED) {
1351 779 print_str_opt("color_primaries", "unknown");
1352 } else {
1353 237 print_str("color_primaries", val);
1354 }
1355 1016 }
1356
1357 1016 static void print_color_trc(AVTextFormatContext *tfc, enum AVColorTransferCharacteristic color_trc)
1358 {
1359 1016 const char *val = av_color_transfer_name(color_trc);
1360
3/4
✓ Branch 0 taken 1016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 251 times.
1016 if (!val || color_trc == AVCOL_TRC_UNSPECIFIED) {
1361 765 print_str_opt("color_transfer", "unknown");
1362 } else {
1363 251 print_str("color_transfer", val);
1364 }
1365 1016 }
1366
1367 1016 static void print_chroma_location(AVTextFormatContext *tfc, enum AVChromaLocation chroma_location)
1368 {
1369 1016 const char *val = av_chroma_location_name(chroma_location);
1370
3/4
✓ Branch 0 taken 1016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 500 times.
✓ Branch 3 taken 516 times.
1016 if (!val || chroma_location == AVCHROMA_LOC_UNSPECIFIED) {
1371 500 print_str_opt("chroma_location", "unspecified");
1372 } else {
1373 516 print_str("chroma_location", val);
1374 }
1375 1016 }
1376
1377 857 static void print_alpha_mode(AVTextFormatContext *tfc, enum AVAlphaMode alpha_mode)
1378 {
1379 857 const char *val = av_alpha_mode_name(alpha_mode);
1380
3/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 856 times.
✓ Branch 3 taken 1 times.
857 if (!val || alpha_mode == AVALPHA_MODE_UNSPECIFIED) {
1381 856 print_str_opt("alpha_mode", "unspecified");
1382 } else {
1383 1 print_str("alpha_mode", val);
1384 }
1385 857 }
1386
1387 7446 static void clear_log(int need_lock)
1388 {
1389 int i;
1390
1391
1/2
✓ Branch 0 taken 7446 times.
✗ Branch 1 not taken.
7446 if (need_lock)
1392 7446 ff_mutex_lock(&log_mutex);
1393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7446 times.
7446 for (i=0; i<log_buffer_size; i++) {
1394 ✗ av_freep(&log_buffer[i].context_name);
1395 ✗ av_freep(&log_buffer[i].parent_name);
1396 ✗ av_freep(&log_buffer[i].log_message);
1397 }
1398 7446 log_buffer_size = 0;
1399
1/2
✓ Branch 0 taken 7446 times.
✗ Branch 1 not taken.
7446 if(need_lock)
1400 7446 ff_mutex_unlock(&log_mutex);
1401 7446 }
1402
1403 ✗ static int show_log(AVTextFormatContext *tfc, int section_ids, int section_id, int log_level)
1404 {
1405 int i;
1406 ✗ ff_mutex_lock(&log_mutex);
1407 ✗ if (!log_buffer_size) {
1408 ✗ ff_mutex_unlock(&log_mutex);
1409 ✗ return 0;
1410 }
1411 ✗ avtext_print_section_header(tfc, NULL, section_ids);
1412
1413 ✗ for (i=0; i<log_buffer_size; i++) {
1414 ✗ if (log_buffer[i].log_level <= log_level) {
1415 ✗ avtext_print_section_header(tfc, NULL, section_id);
1416 ✗ print_str("context", log_buffer[i].context_name);
1417 ✗ print_int("level", log_buffer[i].log_level);
1418 ✗ print_int("category", log_buffer[i].category);
1419 ✗ if (log_buffer[i].parent_name) {
1420 ✗ print_str("parent_context", log_buffer[i].parent_name);
1421 ✗ print_int("parent_category", log_buffer[i].parent_category);
1422 } else {
1423 ✗ print_str_opt("parent_context", "N/A");
1424 ✗ print_str_opt("parent_category", "N/A");
1425 }
1426 ✗ print_str("message", log_buffer[i].log_message);
1427 ✗ avtext_print_section_footer(tfc);
1428 }
1429 }
1430 ✗ clear_log(0);
1431 ✗ ff_mutex_unlock(&log_mutex);
1432
1433 ✗ avtext_print_section_footer(tfc);
1434
1435 ✗ return 0;
1436 }
1437
1438 6411 static void show_packet(AVTextFormatContext *tfc, InputFile *ifile, AVPacket *pkt, int packet_idx)
1439 {
1440 6411 AVStream *st = ifile->streams[pkt->stream_index].st;
1441 AVBPrint pbuf;
1442 const char *s;
1443
1444 6411 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
1445
1446 6411 avtext_print_section_header(tfc, NULL, SECTION_ID_PACKET);
1447
1448 6411 s = av_get_media_type_string(st->codecpar->codec_type);
1449
1/2
✓ Branch 0 taken 6411 times.
✗ Branch 1 not taken.
6411 if (s) print_str ("codec_type", s);
1450 ✗ else print_str_opt("codec_type", "unknown");
1451 6411 print_int("stream_index", pkt->stream_index);
1452 6411 print_ts ("pts", pkt->pts);
1453 6411 print_time("pts_time", pkt->pts, &st->time_base);
1454 6411 print_ts ("dts", pkt->dts);
1455 6411 print_time("dts_time", pkt->dts, &st->time_base);
1456 6411 print_duration_ts("duration", pkt->duration);
1457 6411 print_duration_time("duration_time", pkt->duration, &st->time_base);
1458 6411 print_int_fmt("size", pkt->size, AV_TEXTFORMAT_VALUE_FMT_BYTE, unit_byte_str);
1459
2/2
✓ Branch 0 taken 6295 times.
✓ Branch 1 taken 116 times.
6411 if (pkt->pos != -1) print_fmt ("pos", "%"PRId64, pkt->pos);
1460 116 else print_str_opt("pos", "N/A");
1461
6/6
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 6406 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6405 times.
✓ Branch 5 taken 5307 times.
✓ Branch 6 taken 1104 times.
6411 print_fmt("flags", "%c%c%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_',
1462 pkt->flags & AV_PKT_FLAG_DISCARD ? 'D' : '_',
1463 pkt->flags & AV_PKT_FLAG_CORRUPT ? 'C' : '_');
1464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6411 times.
6411 if (do_show_data)
1465 ✗ avtext_print_data(tfc, "data", pkt->data, pkt->size);
1466 6411 avtext_print_data_hash(tfc, "data_hash", pkt->data, pkt->size);
1467
1468
2/2
✓ Branch 0 taken 1006 times.
✓ Branch 1 taken 5405 times.
6411 if (pkt->side_data_elems) {
1469 size_t size;
1470 const uint8_t *side_metadata;
1471
1472 1006 side_metadata = av_packet_get_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, &size);
1473
4/6
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 872 times.
✓ Branch 2 taken 134 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 134 times.
✗ Branch 5 not taken.
1006 if (side_metadata && size && do_show_packet_tags) {
1474 134 AVDictionary *dict = NULL;
1475
1/2
✓ Branch 1 taken 134 times.
✗ Branch 2 not taken.
134 if (av_packet_unpack_dictionary(side_metadata, size, &dict) >= 0)
1476 134 show_tags(tfc, dict, SECTION_ID_PACKET_TAGS);
1477 134 av_dict_free(&dict);
1478 }
1479
1480 1006 avtext_print_section_header(tfc, NULL, SECTION_ID_PACKET_SIDE_DATA_LIST);
1481
2/2
✓ Branch 0 taken 1007 times.
✓ Branch 1 taken 1006 times.
2013 for (int i = 0; i < pkt->side_data_elems; i++) {
1482 1007 print_pkt_side_data(tfc, st->codecpar->width, st->codecpar->height, &pkt->side_data[i], 0);
1483 }
1484 1006 avtext_print_section_footer(tfc);
1485 }
1486
1487 6411 avtext_print_section_footer(tfc);
1488
1489 6411 av_bprint_finalize(&pbuf, NULL);
1490 6411 fflush(stdout);
1491 6411 }
1492
1493 ✗ static void show_subtitle(AVTextFormatContext *tfc, AVSubtitle *sub, AVStream *stream,
1494 AVFormatContext *fmt_ctx)
1495 {
1496 AVBPrint pbuf;
1497
1498 ✗ av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
1499
1500 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_SUBTITLE);
1501
1502 ✗ print_str ("media_type", "subtitle");
1503 ✗ print_ts ("pts", sub->pts);
1504 ✗ print_time("pts_time", sub->pts, &AV_TIME_BASE_Q);
1505 ✗ print_int ("format", sub->format);
1506 ✗ print_int ("start_display_time", sub->start_display_time);
1507 ✗ print_int ("end_display_time", sub->end_display_time);
1508 ✗ print_int ("num_rects", sub->num_rects);
1509
1510 ✗ avtext_print_section_footer(tfc);
1511
1512 ✗ av_bprint_finalize(&pbuf, NULL);
1513 ✗ fflush(stdout);
1514 ✗ }
1515
1516 static void print_iamf_param_definition(AVTextFormatContext *tfc, const char *name,
1517 const AVIAMFParamDefinition *param, SectionID section_id);
1518
1519 310 static void print_frame_side_data(AVTextFormatContext *tfc,
1520 const AVFrame *frame,
1521 const AVStream *stream)
1522 {
1523 310 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_LIST);
1524
1525
2/2
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 310 times.
773 for (int i = 0; i < frame->nb_side_data; i++) {
1526 463 const AVFrameSideData *sd = frame->side_data[i];
1527 const char *name;
1528
1529 463 avtext_print_section_header(tfc, sd, SECTION_ID_FRAME_SIDE_DATA);
1530 463 name = av_frame_side_data_name(sd->type);
1531
1/2
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
463 print_str("side_data_type", name ? name : "unknown");
1532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if (sd->type == AV_FRAME_DATA_DOWNMIX_INFO) {
1533 ✗ print_downmix_info(tfc, (AVDownmixInfo *)sd->data);
1534
3/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 371 times.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
463 } else if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
1535 92 print_displaymatrix(tfc, (const int32_t*)sd->data);
1536
3/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
371 } else if (sd->type == AV_FRAME_DATA_AFD && sd->size > 0) {
1537 67 print_int("active_format", *sd->data);
1538
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
304 } else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) {
1539 char tcbuf[AV_TIMECODE_STR_SIZE];
1540 ✗ av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));
1541 ✗ print_str("timecode", tcbuf);
1542
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
327 } else if (sd->type == AV_FRAME_DATA_S12M_TIMECODE && sd->size == 16) {
1543 23 uint32_t *tc = (uint32_t*)sd->data;
1544 23 int m = FFMIN(tc[0],3);
1545 23 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST);
1546
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 23 times.
48 for (int j = 1; j <= m ; j++) {
1547 char tcbuf[AV_TIMECODE_STR_SIZE];
1548 25 av_timecode_make_smpte_tc_string2(tcbuf, stream->avg_frame_rate, tc[j], 0, 0);
1549 25 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME_SIDE_DATA_TIMECODE);
1550 25 print_str("value", tcbuf);
1551 25 avtext_print_section_footer(tfc);
1552 }
1553 23 avtext_print_section_footer(tfc);
1554
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 257 times.
281 } else if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) {
1555 24 print_mastering_display_metadata(tfc, (AVMasteringDisplayMetadata *)sd->data);
1556
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 255 times.
257 } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_PLUS) {
1557 2 AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
1558 2 print_dynamic_hdr10_plus(tfc, metadata);
1559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_SMPTE_2094_APP5) {
1560 ✗ AVDynamicHDRSmpte2094App5 *metadata = (AVDynamicHDRSmpte2094App5 *)sd->data;
1561 ✗ print_dynamic_hdr_smpte2094_app5(tfc, metadata);
1562
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 231 times.
255 } else if (sd->type == AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) {
1563 24 print_context_light_level(tfc, (AVContentLightMetadata *)sd->data);
1564
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 227 times.
231 } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
1565 4 const AVDictionaryEntry *tag = av_dict_get(sd->metadata, "name", NULL, AV_DICT_MATCH_CASE);
1566
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if (tag)
1567 2 print_str(tag->key, tag->value);
1568 4 print_int("size", sd->size);
1569
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 225 times.
227 } else if (sd->type == AV_FRAME_DATA_DOVI_METADATA) {
1570 2 print_dovi_metadata(tfc, (const AVDOVIMetadata *)sd->data);
1571
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 224 times.
225 } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) {
1572 1 AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data;
1573 1 print_dynamic_hdr_vivid(tfc, metadata);
1574
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 222 times.
224 } else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
1575 2 print_ambient_viewing_environment(tfc, (const AVAmbientViewingEnvironment *)sd->data);
1576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 } else if (sd->type == AV_FRAME_DATA_FILM_GRAIN_PARAMS) {
1577 ✗ AVFilmGrainParams *fgp = (AVFilmGrainParams *)sd->data;
1578 ✗ print_film_grain_params(tfc, fgp);
1579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 } else if (sd->type == AV_FRAME_DATA_VIEW_ID) {
1580 ✗ print_int("view_id", *(int*)sd->data);
1581
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 213 times.
222 } else if (sd->type == AV_FRAME_DATA_EXIF) {
1582 9 print_int("size", sd->size);
1583
1/2
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
213 } else if (sd->type == AV_FRAME_DATA_IAMF_MIX_GAIN_PARAM ||
1584
1/2
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
213 sd->type == AV_FRAME_DATA_IAMF_DEMIXING_INFO_PARAM ||
1585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 213 times.
213 sd->type == AV_FRAME_DATA_IAMF_RECON_GAIN_INFO_PARAM) {
1586 ✗ const AVIAMFParamDefinition *param = (AVIAMFParamDefinition *)sd->data;
1587 ✗ print_iamf_param_definition(tfc, NULL, param, SECTION_ID_FRAME_SIDE_DATA);
1588 }
1589 463 avtext_print_section_footer(tfc);
1590 }
1591 310 avtext_print_section_footer(tfc);
1592 310 }
1593
1594 3676 static void show_frame(AVTextFormatContext *tfc, AVFrame *frame, AVStream *stream,
1595 AVFormatContext *fmt_ctx)
1596 {
1597
1/2
✓ Branch 0 taken 3676 times.
✗ Branch 1 not taken.
3676 FrameData *fd = frame->opaque_ref ? (FrameData*)frame->opaque_ref->data : NULL;
1598 AVBPrint pbuf;
1599 char val_str[128];
1600 const char *s;
1601
1602 3676 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
1603
1604 3676 avtext_print_section_header(tfc, NULL, SECTION_ID_FRAME);
1605
1606 3676 s = av_get_media_type_string(stream->codecpar->codec_type);
1607
1/2
✓ Branch 0 taken 3676 times.
✗ Branch 1 not taken.
3676 if (s) print_str ("media_type", s);
1608 ✗ else print_str_opt("media_type", "unknown");
1609 3676 print_int("stream_index", stream->index);
1610 3676 print_int("key_frame", !!(frame->flags & AV_FRAME_FLAG_KEY));
1611 3676 print_ts ("pts", frame->pts);
1612 3676 print_time("pts_time", frame->pts, &stream->time_base);
1613 3676 print_ts ("pkt_dts", frame->pkt_dts);
1614 3676 print_time("pkt_dts_time", frame->pkt_dts, &stream->time_base);
1615 3676 print_ts ("best_effort_timestamp", frame->best_effort_timestamp);
1616 3676 print_time("best_effort_timestamp_time", frame->best_effort_timestamp, &stream->time_base);
1617 3676 print_duration_ts ("duration", frame->duration);
1618 3676 print_duration_time("duration_time", frame->duration, &stream->time_base);
1619
3/4
✓ Branch 0 taken 3676 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2979 times.
✓ Branch 3 taken 697 times.
3676 if (fd && fd->pkt_pos != -1) print_fmt ("pkt_pos", "%"PRId64, fd->pkt_pos);
1620 697 else print_str_opt("pkt_pos", "N/A");
1621
2/4
✓ Branch 0 taken 3676 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3676 times.
✗ Branch 3 not taken.
3676 if (fd && fd->pkt_size != -1) print_int_fmt("pkt_size", fd->pkt_size, AV_TEXTFORMAT_VALUE_FMT_BYTE, unit_byte_str);
1622 ✗ else print_str_opt("pkt_size", "N/A");
1623
1624
2/3
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 2819 times.
✗ Branch 2 not taken.
3676 switch (stream->codecpar->codec_type) {
1625 AVRational sar;
1626
1627 857 case AVMEDIA_TYPE_VIDEO:
1628 857 print_int("width", frame->width);
1629 857 print_int("height", frame->height);
1630 857 print_int("crop_top", frame->crop_top);
1631 857 print_int("crop_bottom", frame->crop_bottom);
1632 857 print_int("crop_left", frame->crop_left);
1633 857 print_int("crop_right", frame->crop_right);
1634 857 print_pixel_format(tfc, frame->format);
1635 857 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, frame);
1636
2/2
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 203 times.
857 if (sar.num) {
1637 654 print_q("sample_aspect_ratio", sar, ':');
1638 } else {
1639 203 print_str_opt("sample_aspect_ratio", "N/A");
1640 }
1641 857 print_fmt("pict_type", "%c", av_get_picture_type_char(frame->pict_type));
1642 857 print_int("interlaced_frame", !!(frame->flags & AV_FRAME_FLAG_INTERLACED));
1643 857 print_int("top_field_first", !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
1644 857 print_int("lossless", !!(frame->flags & AV_FRAME_FLAG_LOSSLESS));
1645 857 print_int("repeat_pict", frame->repeat_pict);
1646
1647 857 print_color_range(tfc, frame->color_range);
1648 857 print_color_space(tfc, frame->colorspace);
1649 857 print_primaries(tfc, frame->color_primaries);
1650 857 print_color_trc(tfc, frame->color_trc);
1651 857 print_chroma_location(tfc, frame->chroma_location);
1652 857 print_alpha_mode(tfc, frame->alpha_mode);
1653 857 break;
1654
1655 2819 case AVMEDIA_TYPE_AUDIO:
1656 2819 s = av_get_sample_fmt_name(frame->format);
1657
1/2
✓ Branch 0 taken 2819 times.
✗ Branch 1 not taken.
2819 if (s) print_str ("sample_fmt", s);
1658 ✗ else print_str_opt("sample_fmt", "unknown");
1659 2819 print_int("nb_samples", frame->nb_samples);
1660 2819 print_int("channels", frame->ch_layout.nb_channels);
1661
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 223 times.
2819 if (frame->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
1662 2596 av_channel_layout_describe(&frame->ch_layout, val_str, sizeof(val_str));
1663 2596 print_str ("channel_layout", val_str);
1664 } else
1665 223 print_str_opt("channel_layout", "unknown");
1666 2819 break;
1667 }
1668
2/2
✓ Branch 0 taken 1527 times.
✓ Branch 1 taken 2149 times.
3676 if (do_show_frame_tags)
1669 1527 show_tags(tfc, frame->metadata, SECTION_ID_FRAME_TAGS);
1670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3676 times.
3676 if (do_show_log)
1671 ✗ show_log(tfc, SECTION_ID_FRAME_LOGS, SECTION_ID_FRAME_LOG, do_show_log);
1672
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 3366 times.
3676 if (frame->nb_side_data)
1673 310 print_frame_side_data(tfc, frame, stream);
1674
1675 3676 avtext_print_section_footer(tfc);
1676
1677 3676 av_bprint_finalize(&pbuf, NULL);
1678 3676 fflush(stdout);
1679 3676 }
1680
1681 7446 static av_always_inline int process_frame(AVTextFormatContext *tfc,
1682 InputFile *ifile,
1683 AVFrame *frame, const AVPacket *pkt,
1684 int *packet_new)
1685 {
1686 7446 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
1687 7446 AVCodecContext *dec_ctx = ifile->streams[pkt->stream_index].dec_ctx;
1688 7446 AVCodecParameters *par = ifile->streams[pkt->stream_index].st->codecpar;
1689 AVSubtitle sub;
1690 7446 int ret = 0, got_frame = 0;
1691
1692 7446 clear_log(1);
1693
2/2
✓ Branch 0 taken 7440 times.
✓ Branch 1 taken 6 times.
7446 if (dec_ctx) {
1694
1/3
✓ Branch 0 taken 7440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7440 switch (par->codec_type) {
1695 7440 case AVMEDIA_TYPE_VIDEO:
1696 case AVMEDIA_TYPE_AUDIO:
1697
2/2
✓ Branch 0 taken 3814 times.
✓ Branch 1 taken 3626 times.
7440 if (*packet_new) {
1698 3814 ret = avcodec_send_packet(dec_ctx, pkt);
1699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3814 times.
3814 if (ret == AVERROR(EAGAIN)) {
1700 ✗ ret = 0;
1701
4/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 3762 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 2 times.
3814 } else if (ret >= 0 || ret == AVERROR_EOF) {
1702 3812 ret = 0;
1703 3812 *packet_new = 0;
1704 }
1705 }
1706
2/2
✓ Branch 0 taken 7438 times.
✓ Branch 1 taken 2 times.
7440 if (ret >= 0) {
1707 7438 ret = avcodec_receive_frame(dec_ctx, frame);
1708
2/2
✓ Branch 0 taken 3676 times.
✓ Branch 1 taken 3762 times.
7438 if (ret >= 0) {
1709 3676 got_frame = 1;
1710
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 3668 times.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
3762 } else if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
1711 3762 ret = 0;
1712 }
1713 }
1714 7440 break;
1715
1716 ✗ case AVMEDIA_TYPE_SUBTITLE:
1717 ✗ if (*packet_new)
1718 ✗ ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_frame, pkt);
1719 ✗ *packet_new = 0;
1720 ✗ break;
1721 ✗ default:
1722 ✗ *packet_new = 0;
1723 }
1724 } else {
1725 6 *packet_new = 0;
1726 }
1727
1728
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7444 times.
7446 if (ret < 0)
1729 2 return ret;
1730
2/2
✓ Branch 0 taken 3676 times.
✓ Branch 1 taken 3768 times.
7444 if (got_frame) {
1731 3676 int is_sub = (par->codec_type == AVMEDIA_TYPE_SUBTITLE);
1732 3676 nb_streams_frames[pkt->stream_index]++;
1733
1/2
✓ Branch 0 taken 3676 times.
✗ Branch 1 not taken.
3676 if (do_show_frames)
1734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3676 times.
3676 if (is_sub)
1735 ✗ show_subtitle(tfc, &sub, ifile->streams[pkt->stream_index].st, fmt_ctx);
1736 else
1737 3676 show_frame(tfc, frame, ifile->streams[pkt->stream_index].st, fmt_ctx);
1738
1739
2/4
✓ Branch 0 taken 3676 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3676 times.
3676 if (!is_sub && do_analyze_frames) {
1740 ✗ for (int i = 0; i < frame->nb_side_data; i++) {
1741 ✗ if (frame->side_data[i]->type == AV_FRAME_DATA_A53_CC)
1742 ✗ streams_with_closed_captions[pkt->stream_index] = 1;
1743 ✗ else if (frame->side_data[i]->type == AV_FRAME_DATA_FILM_GRAIN_PARAMS)
1744 ✗ streams_with_film_grain[pkt->stream_index] = 1;
1745 }
1746 }
1747
1748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3676 times.
3676 if (is_sub)
1749 ✗ avsubtitle_free(&sub);
1750 }
1751
3/4
✓ Branch 0 taken 3768 times.
✓ Branch 1 taken 3676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3768 times.
7444 return got_frame || *packet_new;
1752 }
1753
1754 157 static void log_read_interval(const ReadInterval *interval, void *log_ctx, int log_level)
1755 {
1756 157 av_log(log_ctx, log_level, "id:%d", interval->id);
1757
1758
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 153 times.
157 if (interval->has_start) {
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 av_log(log_ctx, log_level, " start:%s%s", interval->start_is_offset ? "+" : "",
1760 4 av_ts2timestr(interval->start, &AV_TIME_BASE_Q));
1761 } else {
1762 153 av_log(log_ctx, log_level, " start:N/A");
1763 }
1764
1765
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 139 times.
157 if (interval->has_end) {
1766
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 av_log(log_ctx, log_level, " end:%s", interval->end_is_offset ? "+" : "");
1767
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if (interval->duration_frames)
1768 12 av_log(log_ctx, log_level, "#%"PRId64, interval->end);
1769 else
1770 6 av_log(log_ctx, log_level, "%s", av_ts2timestr(interval->end, &AV_TIME_BASE_Q));
1771 } else {
1772 139 av_log(log_ctx, log_level, " end:N/A");
1773 }
1774
1775 157 av_log(log_ctx, log_level, "\n");
1776 157 }
1777
1778 148 static int read_interval_packets(AVTextFormatContext *tfc, InputFile *ifile,
1779 const ReadInterval *interval, int64_t *cur_ts)
1780 {
1781 148 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
1782 148 AVPacket *pkt = NULL;
1783 148 AVFrame *frame = NULL;
1784 148 int ret = 0, i = 0, frame_count = 0;
1785 148 int64_t start = -INT64_MAX, end = interval->end;
1786
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 6 times.
148 int has_start = 0, has_end = interval->has_end && !interval->end_is_offset;
1787
1788 148 av_log(NULL, AV_LOG_VERBOSE, "Processing read interval ");
1789 148 log_read_interval(interval, NULL, AV_LOG_VERBOSE);
1790
1791
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 146 times.
148 if (interval->has_start) {
1792 int64_t target;
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (interval->start_is_offset) {
1794 ✗ if (*cur_ts == AV_NOPTS_VALUE) {
1795 ✗ av_log(NULL, AV_LOG_ERROR,
1796 "Could not seek to relative position since current "
1797 "timestamp is not defined\n");
1798 ✗ ret = AVERROR(EINVAL);
1799 ✗ goto end;
1800 }
1801 ✗ target = *cur_ts + interval->start;
1802 } else {
1803 2 target = interval->start;
1804 }
1805
1806 2 av_log(NULL, AV_LOG_VERBOSE, "Seeking to read interval start point %s\n",
1807 2 av_ts2timestr(target, &AV_TIME_BASE_Q));
1808
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if ((ret = avformat_seek_file(fmt_ctx, -1, -INT64_MAX, target, INT64_MAX, 0)) < 0) {
1809 ✗ av_log(NULL, AV_LOG_ERROR, "Could not seek to position %"PRId64": %s\n",
1810 ✗ interval->start, av_err2str(ret));
1811 ✗ goto end;
1812 }
1813 }
1814
1815 148 frame = av_frame_alloc();
1816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if (!frame) {
1817 ✗ ret = AVERROR(ENOMEM);
1818 ✗ goto end;
1819 }
1820 148 pkt = av_packet_alloc();
1821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if (!pkt) {
1822 ✗ ret = AVERROR(ENOMEM);
1823 ✗ goto end;
1824 }
1825
2/2
✓ Branch 1 taken 9902 times.
✓ Branch 2 taken 139 times.
10041 while (!av_read_frame(fmt_ctx, pkt)) {
1826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9902 times.
9902 if (fmt_ctx->nb_streams > nb_streams) {
1827 ✗ REALLOCZ_ARRAY_STREAM(nb_streams_frames, nb_streams, fmt_ctx->nb_streams);
1828 ✗ REALLOCZ_ARRAY_STREAM(nb_streams_packets, nb_streams, fmt_ctx->nb_streams);
1829 ✗ REALLOCZ_ARRAY_STREAM(selected_streams, nb_streams, fmt_ctx->nb_streams);
1830 ✗ REALLOCZ_ARRAY_STREAM(streams_with_closed_captions, nb_streams, fmt_ctx->nb_streams);
1831 ✗ REALLOCZ_ARRAY_STREAM(streams_with_film_grain, nb_streams, fmt_ctx->nb_streams);
1832 ✗ nb_streams = fmt_ctx->nb_streams;
1833 }
1834
2/2
✓ Branch 0 taken 9815 times.
✓ Branch 1 taken 87 times.
9902 if (selected_streams[pkt->stream_index]) {
1835 9815 AVRational tb = ifile->streams[pkt->stream_index].st->time_base;
1836
2/2
✓ Branch 0 taken 9552 times.
✓ Branch 1 taken 263 times.
9815 int64_t pts = pkt->pts != AV_NOPTS_VALUE ? pkt->pts : pkt->dts;
1837
1838
2/2
✓ Branch 0 taken 9552 times.
✓ Branch 1 taken 263 times.
9815 if (pts != AV_NOPTS_VALUE)
1839 9552 *cur_ts = av_rescale_q(pts, tb, AV_TIME_BASE_Q);
1840
1841
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 9417 times.
✓ Branch 2 taken 136 times.
✓ Branch 3 taken 262 times.
9815 if (!has_start && *cur_ts != AV_NOPTS_VALUE) {
1842 136 start = *cur_ts;
1843 136 has_start = 1;
1844 }
1845
1846
6/6
✓ Branch 0 taken 9553 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 9515 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 9510 times.
9815 if (has_start && !has_end && interval->end_is_offset) {
1847 5 end = start + interval->end;
1848 5 has_end = 1;
1849 }
1850
1851
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 9783 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
9815 if (interval->end_is_offset && interval->duration_frames) {
1852
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 26 times.
32 if (frame_count >= interval->end)
1853 9 break;
1854
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9769 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 11 times.
9783 } else if (has_end && *cur_ts != AV_NOPTS_VALUE && *cur_ts >= end) {
1855 3 break;
1856 }
1857
1858 9806 frame_count++;
1859
2/2
✓ Branch 0 taken 6411 times.
✓ Branch 1 taken 3395 times.
9806 if (do_read_packets) {
1860
1/2
✓ Branch 0 taken 6411 times.
✗ Branch 1 not taken.
6411 if (do_show_packets)
1861 6411 show_packet(tfc, ifile, pkt, i++);
1862 6411 nb_streams_packets[pkt->stream_index]++;
1863 }
1864
2/2
✓ Branch 0 taken 3670 times.
✓ Branch 1 taken 6136 times.
9806 if (do_read_frames) {
1865 3670 int packet_new = 1;
1866 FrameData *fd;
1867
1868 3670 pkt->opaque_ref = av_buffer_allocz(sizeof(*fd));
1869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3670 times.
3670 if (!pkt->opaque_ref) {
1870 ✗ ret = AVERROR(ENOMEM);
1871 ✗ goto end;
1872 }
1873 3670 fd = (FrameData*)pkt->opaque_ref->data;
1874 3670 fd->pkt_pos = pkt->pos;
1875 3670 fd->pkt_size = pkt->size;
1876
1877
2/2
✓ Branch 1 taken 3626 times.
✓ Branch 2 taken 3670 times.
7296 while (process_frame(tfc, ifile, frame, pkt, &packet_new) > 0);
1878 }
1879 }
1880 9893 av_packet_unref(pkt);
1881 }
1882 148 av_packet_unref(pkt);
1883 //Flush remaining frames that are cached in the decoder
1884
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 148 times.
345 for (int i = 0; i < ifile->nb_streams; i++) {
1885 197 pkt->stream_index = i;
1886
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 97 times.
197 if (do_read_frames) {
1887
2/2
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 100 times.
150 while (process_frame(tfc, ifile, frame, pkt, &(int){1}) > 0);
1888 }
1889 }
1890
1891 148 end:
1892 148 av_frame_free(&frame);
1893 148 av_packet_free(&pkt);
1894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if (ret < 0) {
1895 ✗ av_log(NULL, AV_LOG_ERROR, "Could not read packets in interval ");
1896 ✗ log_read_interval(interval, NULL, AV_LOG_ERROR);
1897 }
1898 148 return ret;
1899 }
1900
1901 ✗ static void flush_buffers(InputFile *ifile)
1902 {
1903 int i;
1904
1905 ✗ if (!do_read_frames)
1906 ✗ return;
1907 ✗ for (i = 0; i < ifile->nb_streams; i++) {
1908 ✗ if (ifile->streams[i].dec_ctx)
1909 ✗ avcodec_flush_buffers(ifile->streams[i].dec_ctx);
1910 }
1911 }
1912
1913 148 static int read_packets(AVTextFormatContext *tfc, InputFile *ifile)
1914 {
1915 148 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
1916 148 int ret = 0;
1917 148 int64_t cur_ts = fmt_ctx->start_time;
1918
1919
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 9 times.
148 if (read_intervals_nb == 0) {
1920 139 ReadInterval interval = (ReadInterval) { .has_start = 0, .has_end = 0 };
1921 139 ret = read_interval_packets(tfc, ifile, &interval, &cur_ts);
1922 } else {
1923
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 for (int i = 0; i < read_intervals_nb; i++) {
1924 /* flushing buffers can reset parts of the private context which may be
1925 * read by show_streams(), so only flush between each read_interval */
1926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (i)
1927 ✗ flush_buffers(ifile);
1928 9 ret = read_interval_packets(tfc, ifile, &read_intervals[i], &cur_ts);
1929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (ret < 0)
1930 ✗ break;
1931 }
1932 }
1933
1934 148 return ret;
1935 }
1936
1937 314 static void print_dispositions(AVTextFormatContext *tfc, uint32_t disposition, SectionID section_id)
1938 {
1939 314 avtext_print_section_header(tfc, NULL, section_id);
1940
2/2
✓ Branch 0 taken 10048 times.
✓ Branch 1 taken 314 times.
10362 for (unsigned i = 0; i < sizeof(disposition) * CHAR_BIT; i++) {
1941 10048 const char *disposition_str = av_disposition_to_string(1U << i);
1942
1943
2/2
✓ Branch 0 taken 5966 times.
✓ Branch 1 taken 4082 times.
10048 if (disposition_str)
1944 5966 print_int(disposition_str, !!(disposition & (1U << i)));
1945 }
1946 314 avtext_print_section_footer(tfc);
1947 314 }
1948
1949 #define IN_PROGRAM 1
1950 #define IN_STREAM_GROUP 2
1951
1952 540 static int show_stream(AVTextFormatContext *tfc, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int container)
1953 {
1954 540 AVStream *stream = ist->st;
1955 AVCodecParameters *par;
1956 AVCodecContext *dec_ctx;
1957 char val_str[128];
1958 const char *s;
1959 AVRational sar, dar;
1960 AVBPrint pbuf;
1961 const AVCodecDescriptor *cd;
1962 540 const SectionID section_header[] = {
1963 SECTION_ID_STREAM,
1964 SECTION_ID_PROGRAM_STREAM,
1965 SECTION_ID_STREAM_GROUP_STREAM,
1966 };
1967 540 const SectionID section_disposition[] = {
1968 SECTION_ID_STREAM_DISPOSITION,
1969 SECTION_ID_PROGRAM_STREAM_DISPOSITION,
1970 SECTION_ID_STREAM_GROUP_STREAM_DISPOSITION,
1971 };
1972 540 const SectionID section_tags[] = {
1973 SECTION_ID_STREAM_TAGS,
1974 SECTION_ID_PROGRAM_STREAM_TAGS,
1975 SECTION_ID_STREAM_GROUP_STREAM_TAGS,
1976 };
1977 540 const SectionID section_side_data[] = {
1978 SECTION_ID_STREAM_SIDE_DATA_LIST,
1979 SECTION_ID_PROGRAM_STREAM_SIDE_DATA_LIST,
1980 SECTION_ID_STREAM_GROUP_STREAM_SIDE_DATA_LIST,
1981 };
1982 540 const SectionID container_side_data[] = {
1983 PKT_SIDE_DATA_IN_STREAM,
1984 PKT_SIDE_DATA_IN_PROGRAM_STREAM,
1985 PKT_SIDE_DATA_IN_STREAM_GROUP_STREAM,
1986 };
1987 540 int ret = 0;
1988 540 const char *profile = NULL;
1989
1990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540 times.
540 av_assert0(container < FF_ARRAY_ELEMS(section_header));
1991
1992 540 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
1993
1994 540 avtext_print_section_header(tfc, NULL, section_header[container]);
1995
1996 540 print_int("index", stream->index);
1997
1998 540 par = stream->codecpar;
1999 540 dec_ctx = ist->dec_ctx;
2000
2/2
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 3 times.
540 if (cd = avcodec_descriptor_get(par->codec_id)) {
2001 537 print_str("codec_name", cd->name);
2002
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 511 times.
537 if (!do_bitexact) {
2003
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 print_str("codec_long_name",
2004 cd->long_name ? cd->long_name : "unknown");
2005 }
2006 } else {
2007 3 print_str_opt("codec_name", "unknown");
2008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!do_bitexact) {
2009 ✗ print_str_opt("codec_long_name", "unknown");
2010 }
2011 }
2012
2013
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 514 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 11 times.
540 if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile)))
2014 15 print_str("profile", profile);
2015 else {
2016
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 368 times.
525 if (par->profile != AV_PROFILE_UNKNOWN) {
2017 char profile_num[12];
2018 157 snprintf(profile_num, sizeof(profile_num), "%d", par->profile);
2019 157 print_str("profile", profile_num);
2020 } else
2021 368 print_str_opt("profile", "unknown");
2022 }
2023
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 441 times.
540 if (par->level != AV_LEVEL_UNKNOWN)
2024 99 print_int("level", par->level);
2025 else
2026 441 print_int_opt("level", par->level);
2027
2028 540 s = av_get_media_type_string(par->codec_type);
2029
1/2
✓ Branch 0 taken 540 times.
✗ Branch 1 not taken.
540 if (s) print_str ("codec_type", s);
2030 ✗ else print_str_opt("codec_type", "unknown");
2031
2032 /* print AVI/FourCC tag */
2033 540 print_str("codec_tag_string", av_fourcc2str(par->codec_tag));
2034 540 print_fmt("codec_tag", "0x%04"PRIx32, par->codec_tag);
2035
2036 540 av_bprint_clear(&pbuf);
2037
2/2
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 280 times.
540 if (!av_mime_codec_str(par, stream->avg_frame_rate, &pbuf))
2038 260 print_str("mime_codec_string", pbuf.str);
2039
2040
4/4
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 361 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 10 times.
540 switch (par->codec_type) {
2041 159 case AVMEDIA_TYPE_VIDEO:
2042 159 print_int("width", par->width);
2043 159 print_int("height", par->height);
2044
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 7 times.
159 if (dec_ctx) {
2045 152 print_int("coded_width", dec_ctx->coded_width);
2046 152 print_int("coded_height", dec_ctx->coded_height);
2047
2048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if (do_analyze_frames) {
2049 ✗ print_int("closed_captions", streams_with_closed_captions[stream->index]);
2050 ✗ print_int("film_grain", streams_with_film_grain[stream->index]);
2051 }
2052 }
2053 159 print_int("has_b_frames", par->video_delay);
2054 159 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
2055
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 48 times.
159 if (sar.num) {
2056 111 print_q("sample_aspect_ratio", sar, ':');
2057 111 av_reduce(&dar.num, &dar.den,
2058 111 (int64_t) par->width * sar.num,
2059 111 (int64_t) par->height * sar.den,
2060 1024*1024);
2061 111 print_q("display_aspect_ratio", dar, ':');
2062 } else {
2063 48 print_str_opt("sample_aspect_ratio", "N/A");
2064 48 print_str_opt("display_aspect_ratio", "N/A");
2065 }
2066 159 print_pixel_format(tfc, par->format);
2067
2068 159 print_color_range(tfc, par->color_range);
2069 159 print_color_space(tfc, par->color_space);
2070 159 print_color_trc(tfc, par->color_trc);
2071 159 print_primaries(tfc, par->color_primaries);
2072 159 print_chroma_location(tfc, par->chroma_location);
2073
2074
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 121 times.
159 if (par->field_order == AV_FIELD_PROGRESSIVE)
2075 38 print_str("field_order", "progressive");
2076
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 112 times.
121 else if (par->field_order == AV_FIELD_TT)
2077 9 print_str("field_order", "tt");
2078
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 111 times.
112 else if (par->field_order == AV_FIELD_BB)
2079 1 print_str("field_order", "bb");
2080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 else if (par->field_order == AV_FIELD_TB)
2081 ✗ print_str("field_order", "tb");
2082
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 103 times.
111 else if (par->field_order == AV_FIELD_BT)
2083 8 print_str("field_order", "bt");
2084 else
2085 103 print_str_opt("field_order", "unknown");
2086
2087
4/4
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 128 times.
159 if (dec_ctx && do_read_frames)
2088 24 print_int("refs", dec_ctx->refs);
2089 159 break;
2090
2091 361 case AVMEDIA_TYPE_AUDIO:
2092 361 s = av_get_sample_fmt_name(par->format);
2093
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 2 times.
361 if (s) print_str ("sample_fmt", s);
2094 2 else print_str_opt("sample_fmt", "unknown");
2095 361 print_val("sample_rate", par->sample_rate, unit_hertz_str);
2096 361 print_int("channels", par->ch_layout.nb_channels);
2097
2098
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 38 times.
361 if (par->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
2099 323 av_channel_layout_describe(&par->ch_layout, val_str, sizeof(val_str));
2100 323 print_str ("channel_layout", val_str);
2101 } else {
2102 38 print_str_opt("channel_layout", "unknown");
2103 }
2104
2105 361 print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id));
2106
2107 361 print_int("initial_padding", par->initial_padding);
2108 361 break;
2109
2110 10 case AVMEDIA_TYPE_SUBTITLE:
2111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (par->width)
2112 ✗ print_int("width", par->width);
2113 else
2114 10 print_str_opt("width", "N/A");
2115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (par->height)
2116 ✗ print_int("height", par->height);
2117 else
2118 10 print_str_opt("height", "N/A");
2119 10 break;
2120 }
2121
2122
2/2
✓ Branch 0 taken 537 times.
✓ Branch 1 taken 3 times.
540 if (show_private_data) {
2123
4/4
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 348 times.
✓ Branch 3 taken 168 times.
537 if (dec_ctx && dec_ctx->codec->priv_class)
2124 348 print_private_data(tfc, dec_ctx->priv_data);
2125
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 294 times.
537 if (fmt_ctx->iformat->priv_class)
2126 243 print_private_data(tfc, fmt_ctx->priv_data);
2127 }
2128
2129
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 199 times.
540 if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%x", stream->id);
2130 199 else print_str_opt("id", "N/A");
2131 540 print_q("r_frame_rate", stream->r_frame_rate, '/');
2132 540 print_q("avg_frame_rate", stream->avg_frame_rate, '/');
2133 540 print_q("time_base", stream->time_base, '/');
2134 540 print_ts ("start_pts", stream->start_time);
2135 540 print_time("start_time", stream->start_time, &stream->time_base);
2136 540 print_ts ("duration_ts", stream->duration);
2137 540 print_time("duration", stream->duration, &stream->time_base);
2138
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 343 times.
540 if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str);
2139 343 else print_str_opt("bit_rate", "N/A");
2140
3/4
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 519 times.
540 if (dec_ctx && dec_ctx->rc_max_rate > 0)
2141 ✗ print_val ("max_bit_rate", dec_ctx->rc_max_rate, unit_bit_per_second_str);
2142 else
2143 540 print_str_opt("max_bit_rate", "N/A");
2144
4/4
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 312 times.
540 if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample);
2145 333 else print_str_opt("bits_per_raw_sample", "N/A");
2146
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 467 times.
540 if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames);
2147 467 else print_str_opt("nb_frames", "N/A");
2148
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 503 times.
540 if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]);
2149 503 else print_str_opt("nb_read_frames", "N/A");
2150
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 437 times.
540 if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]);
2151 437 else print_str_opt("nb_read_packets", "N/A");
2152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540 times.
540 if (do_show_data)
2153 ✗ avtext_print_data(tfc, "extradata", par->extradata,
2154 par->extradata_size);
2155
2156
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 230 times.
540 if (par->extradata_size > 0) {
2157 310 print_int("extradata_size", par->extradata_size);
2158 310 avtext_print_data_hash(tfc, "extradata_hash", par->extradata,
2159 par->extradata_size);
2160 }
2161
2162 /* Print disposition information */
2163
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 241 times.
540 if (do_show_stream_disposition) {
2164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 av_assert0(container < FF_ARRAY_ELEMS(section_disposition));
2165 299 print_dispositions(tfc, stream->disposition, section_disposition[container]);
2166 }
2167
2168
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 411 times.
540 if (do_show_stream_tags) {
2169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 av_assert0(container < FF_ARRAY_ELEMS(section_tags));
2170 129 ret = show_tags(tfc, stream->metadata, section_tags[container]);
2171 }
2172
2173
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 466 times.
540 if (stream->codecpar->nb_coded_side_data) {
2174
2/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
74 av_assert0(container < FF_ARRAY_ELEMS(section_tags) &&
2175 container < FF_ARRAY_ELEMS(container_side_data));
2176 74 avtext_print_section_header(tfc, NULL, section_side_data[container]);
2177
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 74 times.
169 for (int i = 0; i < stream->codecpar->nb_coded_side_data; i++) {
2178 95 print_pkt_side_data(tfc, stream->codecpar->width, stream->codecpar->height, &stream->codecpar->coded_side_data[i],
2179 95 container_side_data[container]);
2180 }
2181 74 avtext_print_section_footer(tfc);
2182 }
2183
2184 540 avtext_print_section_footer(tfc);
2185 540 av_bprint_finalize(&pbuf, NULL);
2186 540 fflush(stdout);
2187
2188 540 return ret;
2189 }
2190
2191 188 static int show_streams(AVTextFormatContext *tfc, InputFile *ifile)
2192 {
2193 188 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2194 188 int ret = 0;
2195
2196 188 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAMS);
2197
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 188 times.
503 for (int i = 0; i < ifile->nb_streams; i++)
2198
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 24 times.
315 if (selected_streams[i]) {
2199 291 ret = show_stream(tfc, fmt_ctx, i, &ifile->streams[i], 0);
2200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291 times.
291 if (ret < 0)
2201 ✗ break;
2202 }
2203 188 avtext_print_section_footer(tfc);
2204
2205 188 return ret;
2206 }
2207
2208 5 static int show_program(AVTextFormatContext *tfc, InputFile *ifile, AVProgram *program)
2209 {
2210 5 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2211 5 int ret = 0;
2212
2213 5 avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAM);
2214 5 print_int("program_id", program->id);
2215 5 print_int("program_num", program->program_num);
2216 5 print_int("nb_streams", program->nb_stream_indexes);
2217 5 print_int("pmt_pid", program->pmt_pid);
2218 5 print_int("pcr_pid", program->pcr_pid);
2219
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
5 if (do_show_program_tags)
2220 2 ret = show_tags(tfc, program->metadata, SECTION_ID_PROGRAM_TAGS);
2221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (ret < 0)
2222 ✗ goto end;
2223
2224 5 avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAM_STREAMS);
2225
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 5 times.
15 for (unsigned i = 0; i < program->nb_stream_indexes; i++) {
2226
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
10 if (selected_streams[program->stream_index[i]]) {
2227 9 ret = show_stream(tfc, fmt_ctx, program->stream_index[i], &ifile->streams[program->stream_index[i]], IN_PROGRAM);
2228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (ret < 0)
2229 ✗ break;
2230 }
2231 }
2232 5 avtext_print_section_footer(tfc);
2233
2234 5 end:
2235 5 avtext_print_section_footer(tfc);
2236 5 return ret;
2237 }
2238
2239 4 static int show_programs(AVTextFormatContext *tfc, InputFile *ifile)
2240 {
2241 4 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2242 4 int ret = 0;
2243
2244 4 avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAMS);
2245
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 for (unsigned i = 0; i < fmt_ctx->nb_programs; i++) {
2246 5 AVProgram *program = fmt_ctx->programs[i];
2247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!program)
2248 ✗ continue;
2249 5 ret = show_program(tfc, ifile, program);
2250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (ret < 0)
2251 ✗ break;
2252 }
2253 4 avtext_print_section_footer(tfc);
2254 4 return ret;
2255 }
2256
2257 4 static void print_tile_grid_params(AVTextFormatContext *tfc, const AVStreamGroup *stg,
2258 const AVStreamGroupTileGrid *tile_grid)
2259 {
2260 4 avtext_print_section_header(tfc, stg, SECTION_ID_STREAM_GROUP_COMPONENT);
2261 4 print_int("nb_tiles", tile_grid->nb_tiles);
2262 4 print_int("coded_width", tile_grid->coded_width);
2263 4 print_int("coded_height", tile_grid->coded_height);
2264 4 print_int("horizontal_offset", tile_grid->horizontal_offset);
2265 4 print_int("vertical_offset", tile_grid->vertical_offset);
2266 4 print_int("width", tile_grid->width);
2267 4 print_int("height", tile_grid->height);
2268 4 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SUBCOMPONENTS);
2269
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 for (unsigned i = 0; i < tile_grid->nb_tiles; i++) {
2270 12 avtext_print_section_header(tfc, "tile_offset", SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2271 12 print_int("stream_index", tile_grid->offsets[i].idx);
2272 12 print_int("tile_horizontal_offset", tile_grid->offsets[i].horizontal);
2273 12 print_int("tile_vertical_offset", tile_grid->offsets[i].vertical);
2274 12 avtext_print_section_footer(tfc);
2275 }
2276 4 avtext_print_section_footer(tfc);
2277 4 avtext_print_section_footer(tfc);
2278 4 }
2279
2280 50 static void print_iamf_param_definition(AVTextFormatContext *tfc, const char *name,
2281 const AVIAMFParamDefinition *param, SectionID section_id)
2282 {
2283 SectionID subsection_id, parameter_section_id;
2284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if (section_id == SECTION_ID_FRAME_SIDE_DATA)
2285 ✗ subsection_id = SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST;
2286 else {
2287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 av_assert0(sections[section_id].children_ids[0] != -1);
2288 50 subsection_id = sections[section_id].children_ids[0];
2289 }
2290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 av_assert0(sections[subsection_id].children_ids[0] != -1);
2291 50 parameter_section_id = sections[subsection_id].children_ids[0];
2292
2293 // When printing as part of side-data, skip opening a section
2294
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if (section_id != SECTION_ID_FRAME_SIDE_DATA)
2295 50 avtext_print_section_header(tfc, "IAMF Param Definition", section_id);
2296
2297
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if (name)
2298 50 print_str("name", name);
2299 50 print_int("nb_subblocks", param->nb_subblocks);
2300 50 print_int("type", param->type);
2301 50 print_int("parameter_id", param->parameter_id);
2302 50 print_int("parameter_rate", param->parameter_rate);
2303 50 print_int("duration", param->duration);
2304 50 print_int("constant_subblock_duration", param->constant_subblock_duration);
2305
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 41 times.
50 if (param->nb_subblocks > 0)
2306 9 avtext_print_section_header(tfc, NULL, subsection_id);
2307
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 50 times.
59 for (unsigned i = 0; i < param->nb_subblocks; i++) {
2308 9 const void *subblock = av_iamf_param_definition_get_subblock(param, i);
2309
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
9 switch(param->type) {
2310 ✗ case AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN: {
2311 ✗ const AVIAMFMixGain *mix = subblock;
2312 ✗ avtext_print_section_header(tfc, "IAMF Mix Gain Parameters", parameter_section_id);
2313 ✗ print_int("subblock_duration", mix->subblock_duration);
2314 ✗ print_int("animation_type", mix->animation_type);
2315 ✗ print_q("start_point_value", mix->start_point_value, '/');
2316 ✗ print_q("end_point_value", mix->end_point_value, '/');
2317 ✗ print_q("control_point_value", mix->control_point_value, '/');
2318 ✗ print_q("control_point_relative_time", mix->control_point_relative_time, '/');
2319 ✗ avtext_print_section_footer(tfc); // parameter_section_id
2320 ✗ break;
2321 }
2322 7 case AV_IAMF_PARAMETER_DEFINITION_DEMIXING: {
2323 7 const AVIAMFDemixingInfo *demix = subblock;
2324 7 avtext_print_section_header(tfc, "IAMF Demixing Info", parameter_section_id);
2325 7 print_int("subblock_duration", demix->subblock_duration);
2326 7 print_int("dmixp_mode", demix->dmixp_mode);
2327 7 avtext_print_section_footer(tfc); // parameter_section_id
2328 7 break;
2329 }
2330 2 case AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN: {
2331 2 const AVIAMFReconGain *recon = subblock;
2332 2 avtext_print_section_header(tfc, "IAMF Recon Gain", parameter_section_id);
2333 2 print_int("subblock_duration", recon->subblock_duration);
2334 2 avtext_print_section_footer(tfc); // parameter_section_id
2335 2 break;
2336 }
2337 }
2338 }
2339
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 41 times.
50 if (param->nb_subblocks > 0)
2340 9 avtext_print_section_footer(tfc); // subsection_id
2341
2342
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if (section_id != SECTION_ID_FRAME_SIDE_DATA)
2343 50 avtext_print_section_footer(tfc); // section_id
2344 50 }
2345
2346 19 static void print_iamf_audio_element_params(AVTextFormatContext *tfc, const AVStreamGroup *stg,
2347 const AVIAMFAudioElement *audio_element)
2348 {
2349 AVBPrint pbuf;
2350
2351 19 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
2352
2353 19 avtext_print_section_header(tfc, stg, SECTION_ID_STREAM_GROUP_COMPONENT);
2354 19 print_int("nb_layers", audio_element->nb_layers);
2355 19 print_int("audio_element_type", audio_element->audio_element_type);
2356 19 print_int("default_w", audio_element->default_w);
2357 19 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SUBCOMPONENTS);
2358
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 19 times.
55 for (unsigned i = 0; i < audio_element->nb_layers; i++) {
2359 36 const AVIAMFLayer *layer = audio_element->layers[i];
2360 char val_str[128];
2361 36 avtext_print_section_header(tfc, "IAMF Audio Layer", SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2362 36 av_channel_layout_describe(&layer->ch_layout, val_str, sizeof(val_str));
2363 36 print_str("channel_layout", val_str);
2364
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) {
2365 29 print_int("output_gain_flags", layer->output_gain_flags);
2366 29 print_q("output_gain", layer->output_gain, '/');
2367
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) {
2368 7 print_int("ambisonics_mode", layer->ambisonics_mode);
2369
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
7 if (layer->ambisonics_mode == AV_IAMF_AMBISONICS_MODE_PROJECTION)
2370
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,
2371 layer->demixing_matrix[idx].den);
2372 }
2373 36 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENT
2374 }
2375
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 12 times.
19 if (audio_element->demixing_info)
2376 7 print_iamf_param_definition(tfc, "demixing_info", audio_element->demixing_info,
2377 SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2378
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 17 times.
19 if (audio_element->recon_gain_info)
2379 2 print_iamf_param_definition(tfc, "recon_gain_info", audio_element->recon_gain_info,
2380 SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2381 19 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENTS
2382 19 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENT
2383
2384 19 av_bprint_finalize(&pbuf, NULL);
2385 19 }
2386
2387 20 static void print_iamf_submix_params(AVTextFormatContext *tfc, const AVIAMFSubmix *submix)
2388 {
2389 20 avtext_print_section_header(tfc, "IAMF Submix", SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2390 20 print_int("nb_elements", submix->nb_elements);
2391 20 print_int("nb_layouts", submix->nb_layouts);
2392 20 print_q("default_mix_gain", submix->default_mix_gain, '/');
2393 20 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_PIECES);
2394
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 20 times.
41 for (unsigned i = 0; i < submix->nb_elements; i++) {
2395 21 const AVIAMFSubmixElement *element = submix->elements[i];
2396 21 avtext_print_section_header(tfc, "IAMF Submix Element", SECTION_ID_STREAM_GROUP_PIECE);
2397 21 print_int("stream_id", element->audio_element_id);
2398 21 print_q("default_mix_gain", element->default_mix_gain, '/');
2399 21 print_int("headphones_rendering_mode", element->headphones_rendering_mode);
2400 21 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SUBPIECES);
2401
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if (element->annotations) {
2402 21 const AVDictionaryEntry *annotation = NULL;
2403 21 avtext_print_section_header(tfc, "IAMF Annotations", SECTION_ID_STREAM_GROUP_SUBPIECE);
2404
2/2
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
42 while (annotation = av_dict_iterate(element->annotations, annotation))
2405 21 print_str(annotation->key, annotation->value);
2406 21 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBPIECE
2407 }
2408
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if (element->element_mix_config)
2409 21 print_iamf_param_definition(tfc, "element_mix_config", element->element_mix_config,
2410 SECTION_ID_STREAM_GROUP_SUBPIECE);
2411 21 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBPIECES
2412 21 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_PIECE
2413 }
2414
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if (submix->output_mix_config)
2415 20 print_iamf_param_definition(tfc, "output_mix_config", submix->output_mix_config,
2416 SECTION_ID_STREAM_GROUP_PIECE);
2417
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 20 times.
60 for (unsigned i = 0; i < submix->nb_layouts; i++) {
2418 40 const AVIAMFSubmixLayout *layout = submix->layouts[i];
2419 char val_str[128];
2420 40 avtext_print_section_header(tfc, "IAMF Submix Layout", SECTION_ID_STREAM_GROUP_PIECE);
2421 40 av_channel_layout_describe(&layout->sound_system, val_str, sizeof(val_str));
2422 40 print_str("sound_system", val_str);
2423 40 print_q("integrated_loudness", layout->integrated_loudness, '/');
2424 40 print_q("digital_peak", layout->digital_peak, '/');
2425 40 print_q("true_peak", layout->true_peak, '/');
2426 40 print_q("dialogue_anchored_loudness", layout->dialogue_anchored_loudness, '/');
2427 40 print_q("album_anchored_loudness", layout->album_anchored_loudness, '/');
2428 40 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_PIECE
2429 }
2430 20 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_PIECES
2431 20 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENT
2432 20 }
2433
2434 18 static void print_iamf_mix_presentation_params(AVTextFormatContext *tfc, const AVStreamGroup *stg,
2435 const AVIAMFMixPresentation *mix_presentation)
2436 {
2437 18 avtext_print_section_header(tfc, stg, SECTION_ID_STREAM_GROUP_COMPONENT);
2438 18 print_int("nb_submixes", mix_presentation->nb_submixes);
2439 18 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SUBCOMPONENTS);
2440
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (mix_presentation->annotations) {
2441 18 const AVDictionaryEntry *annotation = NULL;
2442 18 avtext_print_section_header(tfc, "IAMF Annotations", SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
2443
2/2
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
36 while (annotation = av_dict_iterate(mix_presentation->annotations, annotation))
2444 18 print_str(annotation->key, annotation->value);
2445 18 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENT
2446 }
2447
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 18 times.
38 for (unsigned i = 0; i < mix_presentation->nb_submixes; i++)
2448 20 print_iamf_submix_params(tfc, mix_presentation->submixes[i]);
2449 18 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENTS
2450 18 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENT
2451 18 }
2452
2453 1 static void print_layered_video_params(AVTextFormatContext *tfc, const AVStreamGroup *stg,
2454 const AVStreamGroupLayeredVideo *layered_video)
2455 {
2456 1 avtext_print_section_header(tfc, stg, SECTION_ID_STREAM_GROUP_COMPONENT);
2457 1 print_int("el_index", layered_video->el_index);
2458 1 print_int("width", layered_video->width);
2459 1 print_int("height", layered_video->height);
2460 1 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENT
2461 1 }
2462
2463 45 static void print_stream_group_params(AVTextFormatContext *tfc, AVStreamGroup *stg)
2464 {
2465 45 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_COMPONENTS);
2466
5/5
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 3 times.
45 switch (stg->type) {
2467 4 case AV_STREAM_GROUP_PARAMS_TILE_GRID:
2468 4 print_tile_grid_params(tfc, stg, stg->params.tile_grid); break;
2469 19 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT:
2470 19 print_iamf_audio_element_params(tfc, stg, stg->params.iamf_audio_element); break;
2471 18 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION:
2472 18 print_iamf_mix_presentation_params(tfc, stg, stg->params.iamf_mix_presentation); break;
2473 1 case AV_STREAM_GROUP_PARAMS_LCEVC:
2474 case AV_STREAM_GROUP_PARAMS_DOLBY_VISION:
2475 case AV_STREAM_GROUP_PARAMS_GAIN_MAP:
2476 1 print_layered_video_params(tfc, stg, stg->params.layered_video); break;
2477 }
2478 45 avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENTS
2479 45 }
2480
2481 54 static int show_stream_group(AVTextFormatContext *tfc, InputFile *ifile, AVStreamGroup *stg, int container)
2482 {
2483 54 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2484 AVBPrint pbuf;
2485 54 const SectionID section_header[] = {
2486 SECTION_ID_STREAM_GROUP,
2487 SECTION_ID_STREAM_GROUP_STREAM_GROUP,
2488 SECTION_ID_STREAM_GROUP_STREAM_GROUP,
2489 };
2490 54 const SectionID section_disposition[] = {
2491 SECTION_ID_STREAM_GROUP_DISPOSITION,
2492 SECTION_ID_STREAM_GROUP_STREAM_GROUP_DISPOSITION,
2493 SECTION_ID_STREAM_GROUP_STREAM_GROUP_DISPOSITION,
2494 };
2495 54 const SectionID section_tags[] = {
2496 SECTION_ID_STREAM_GROUP_TAGS,
2497 SECTION_ID_STREAM_GROUP_STREAM_GROUP_TAGS,
2498 SECTION_ID_STREAM_GROUP_STREAM_GROUP_TAGS,
2499 };
2500 54 int ret = 0;
2501
2502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 av_assert0(container < FF_ARRAY_ELEMS(section_header));
2503
2504 54 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
2505 54 avtext_print_section_header(tfc, NULL, section_header[container]);
2506 54 print_int("index", stg->index);
2507
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%"PRIx64, stg->id);
2508 ✗ else print_str_opt("id", "N/A");
2509 54 print_int("nb_streams", stg->nb_entries);
2510
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if (stg->type != AV_STREAM_GROUP_PARAMS_NONE)
2511 54 print_str("type", av_x_if_null(avformat_stream_group_name(stg->type), "unknown"));
2512 else
2513 ✗ print_str_opt("type", "unknown");
2514
2515
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 53 times.
54 if (container)
2516 1 goto end;
2517
2518
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 8 times.
53 if (do_show_stream_group_components)
2519 45 print_stream_group_params(tfc, stg);
2520
2521 /* Print disposition information */
2522
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 38 times.
53 if (do_show_stream_group_disposition) {
2523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 av_assert0(container < FF_ARRAY_ELEMS(section_disposition));
2524 15 print_dispositions(tfc, stg->disposition, section_disposition[container]);
2525 }
2526
2527
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 38 times.
53 if (do_show_stream_group_tags) {
2528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 av_assert0(container < FF_ARRAY_ELEMS(section_tags));
2529 15 ret = show_tags(tfc, stg->metadata, section_tags[container]);
2530 }
2531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (ret < 0)
2532 ✗ goto end;
2533
2534
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 51 times.
53 if (stg->nb_coded_side_data) {
2535 2 int width = 0, height = 0;
2536 2 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_SIDE_DATA_LIST);
2537
2538
2/3
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 switch (stg->type) {
2539 1 case AV_STREAM_GROUP_PARAMS_TILE_GRID: {
2540 1 const AVStreamGroupTileGrid *tile_grid = stg->params.tile_grid;
2541 1 width = tile_grid->width;
2542 1 height = tile_grid->height;
2543 1 break;
2544 }
2545 1 case AV_STREAM_GROUP_PARAMS_GAIN_MAP: {
2546 1 const AVStreamGroupLayeredVideo *layered_video = stg->params.layered_video;
2547 1 width = layered_video->width;
2548 1 height = layered_video->height;
2549 1 break;
2550 }
2551 ✗ default:
2552 ✗ break;
2553 }
2554
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 for (int i = 0; i < stg->nb_coded_side_data; i++) {
2555 3 print_pkt_side_data(tfc, width, height, &stg->coded_side_data[i],
2556 PKT_SIDE_DATA_IN_STREAM_GROUP);
2557 }
2558 2 avtext_print_section_footer(tfc);
2559 }
2560
2561 53 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_STREAM_GROUPS);
2562
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 53 times.
300 for (unsigned i = 0; i < stg->nb_entries; i++) {
2563 247 AVStreamGroupEntry *entry = stg->entries[i];
2564
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 1 times.
247 if (entry->type != AV_STREAM_GROUP_ENTRY_STREAM_GROUP)
2565 246 continue;
2566 1 ret = show_stream_group(tfc, ifile, entry->stream_group, IN_STREAM_GROUP);
2567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret < 0)
2568 ✗ break;
2569 }
2570 53 avtext_print_section_footer(tfc);
2571
2572 53 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUP_STREAMS);
2573
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 53 times.
300 for (unsigned i = 0; i < stg->nb_entries; i++) {
2574 247 AVStreamGroupEntry *entry = stg->entries[i];
2575
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 246 times.
247 if (entry->type != AV_STREAM_GROUP_ENTRY_STREAM)
2576 1 continue;
2577
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 6 times.
246 if (selected_streams[stg->entries[i]->stream->index]) {
2578 240 ret = show_stream(tfc, fmt_ctx, entry->stream->index, &ifile->streams[entry->stream->index], IN_STREAM_GROUP);
2579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
240 if (ret < 0)
2580 ✗ break;
2581 }
2582 }
2583 53 avtext_print_section_footer(tfc);
2584
2585 54 end:
2586 54 av_bprint_finalize(&pbuf, NULL);
2587 54 avtext_print_section_footer(tfc);
2588 54 return ret;
2589 }
2590
2591 31 static int show_stream_groups(AVTextFormatContext *tfc, InputFile *ifile)
2592 {
2593 31 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2594 31 int ret = 0;
2595
2596 31 avtext_print_section_header(tfc, NULL, SECTION_ID_STREAM_GROUPS);
2597
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 31 times.
84 for (unsigned i = 0; i < fmt_ctx->nb_stream_groups; i++) {
2598 53 AVStreamGroup *stg = fmt_ctx->stream_groups[i];
2599
2600 53 ret = show_stream_group(tfc, ifile, stg, 0);
2601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (ret < 0)
2602 ✗ break;
2603 }
2604 31 avtext_print_section_footer(tfc);
2605 31 return ret;
2606 }
2607
2608 7 static int show_chapters(AVTextFormatContext *tfc, InputFile *ifile)
2609 {
2610 7 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2611 7 int ret = 0;
2612
2613 7 avtext_print_section_header(tfc, NULL, SECTION_ID_CHAPTERS);
2614
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 for (unsigned i = 0; i < fmt_ctx->nb_chapters; i++) {
2615 27 AVChapter *chapter = fmt_ctx->chapters[i];
2616
2617 27 avtext_print_section_header(tfc, NULL, SECTION_ID_CHAPTER);
2618 27 print_int("id", chapter->id);
2619 27 print_q ("time_base", chapter->time_base, '/');
2620 27 print_int("start", chapter->start);
2621 27 print_time("start_time", chapter->start, &chapter->time_base);
2622 27 print_int("end", chapter->end);
2623 27 print_time("end_time", chapter->end, &chapter->time_base);
2624
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if (do_show_chapter_tags)
2625 27 ret = show_tags(tfc, chapter->metadata, SECTION_ID_CHAPTER_TAGS);
2626 27 avtext_print_section_footer(tfc);
2627 }
2628 7 avtext_print_section_footer(tfc);
2629
2630 7 return ret;
2631 }
2632
2633 82 static int show_format(AVTextFormatContext *tfc, InputFile *ifile)
2634 {
2635 82 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2636
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
2637 82 int ret = 0;
2638
2639 82 avtext_print_section_header(tfc, NULL, SECTION_ID_FORMAT);
2640 82 print_str_validate("filename", fmt_ctx->url);
2641 82 print_int("nb_streams", fmt_ctx->nb_streams);
2642 82 print_int("nb_programs", fmt_ctx->nb_programs);
2643 82 print_int("nb_stream_groups", fmt_ctx->nb_stream_groups);
2644 82 print_str("format_name", fmt_ctx->iformat->name);
2645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (!do_bitexact) {
2646 ✗ if (fmt_ctx->iformat->long_name) print_str ("format_long_name", fmt_ctx->iformat->long_name);
2647 ✗ else print_str_opt("format_long_name", "unknown");
2648 }
2649 82 print_time("start_time", fmt_ctx->start_time, &AV_TIME_BASE_Q);
2650 82 print_time("duration", fmt_ctx->duration, &AV_TIME_BASE_Q);
2651
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (size >= 0) print_int_fmt("size", size, AV_TEXTFORMAT_VALUE_FMT_BYTE, unit_byte_str);
2652 ✗ else print_str_opt("size", "N/A");
2653
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 6 times.
82 if (fmt_ctx->bit_rate > 0) print_val ("bit_rate", fmt_ctx->bit_rate, unit_bit_per_second_str);
2654 6 else print_str_opt("bit_rate", "N/A");
2655 82 print_int("probe_score", fmt_ctx->probe_score);
2656
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 15 times.
82 if (do_show_format_tags)
2657 67 ret = show_tags(tfc, fmt_ctx->metadata, SECTION_ID_FORMAT_TAGS);
2658
2659 82 avtext_print_section_footer(tfc);
2660 82 fflush(stdout);
2661 82 return ret;
2662 }
2663
2664 ✗ static void show_error(AVTextFormatContext *tfc, int err)
2665 {
2666 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_ERROR);
2667 ✗ print_int("code", err);
2668 ✗ print_str("string", av_err2str(err));
2669 ✗ avtext_print_section_footer(tfc);
2670 ✗ }
2671
2672 1264 static int get_decoder_by_name(const char *codec_name, const AVCodec **codec)
2673 {
2674
1/2
✓ Branch 0 taken 1264 times.
✗ Branch 1 not taken.
1264 if (codec_name == NULL)
2675 1264 return 0;
2676
2677 ✗ *codec = avcodec_find_decoder_by_name(codec_name);
2678 ✗ if (*codec == NULL) {
2679 ✗ av_log(NULL, AV_LOG_ERROR,
2680 "No codec could be found with name '%s'\n", codec_name);
2681 ✗ return AVERROR(EINVAL);
2682 }
2683 ✗ return 0;
2684 }
2685
2686 316 static int set_decoders(AVFormatContext *fmt_ctx)
2687 {
2688 int ret;
2689
2690 #define GET_DECODER(type_) \
2691 ret = get_decoder_by_name(type_##_codec_name, &fmt_ctx->type_##_codec); \
2692 if (ret < 0) return ret;
2693
2694
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 GET_DECODER(audio);
2695
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 GET_DECODER(data);
2696
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 GET_DECODER(subtitle);
2697
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 GET_DECODER(video);
2698 316 return 0;
2699 }
2700
2701 568 static const AVCodec *get_decoder_for_stream(AVFormatContext *fmt_ctx, AVStream *stream)
2702 {
2703 568 const AVCodec *codec = NULL;
2704
5/5
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 296 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 2 times.
568 switch (stream->codecpar->codec_type) {
2705 230 case AVMEDIA_TYPE_VIDEO: codec = fmt_ctx->video_codec; break;
2706 296 case AVMEDIA_TYPE_AUDIO: codec = fmt_ctx->audio_codec; break;
2707 10 case AVMEDIA_TYPE_SUBTITLE: codec = fmt_ctx->subtitle_codec; break;
2708 30 case AVMEDIA_TYPE_DATA: codec = fmt_ctx->data_codec; break;
2709 }
2710
2711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 568 times.
568 if (codec != NULL)
2712 ✗ return codec;
2713
2714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 568 times.
568 if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) {
2715 ✗ av_log(NULL, AV_LOG_WARNING,
2716 "Failed to probe codec for input stream %d\n", stream->index);
2717 ✗ return NULL;
2718 }
2719
2720 568 codec = avcodec_find_decoder(stream->codecpar->codec_id);
2721
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 526 times.
568 if (codec == NULL) {
2722 42 av_log(NULL, AV_LOG_WARNING,
2723 "Unsupported codec with id %d for input stream %d\n",
2724 42 stream->codecpar->codec_id, stream->index);
2725 42 return NULL;
2726 }
2727
2728 526 return codec;
2729 }
2730
2731 316 static int open_input_file(InputFile *ifile, const char *filename,
2732 const char *print_filename)
2733 {
2734 int err;
2735 316 AVFormatContext *fmt_ctx = NULL;
2736 316 const AVDictionaryEntry *t = NULL;
2737 316 int scan_all_pmts_set = 0;
2738
2739 316 fmt_ctx = avformat_alloc_context();
2740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (!fmt_ctx)
2741 ✗ return AVERROR(ENOMEM);
2742
2743 316 err = set_decoders(fmt_ctx);
2744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (err < 0)
2745 ✗ return err;
2746
1/2
✓ Branch 1 taken 316 times.
✗ Branch 2 not taken.
316 if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
2747 316 av_dict_set(&format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
2748 316 scan_all_pmts_set = 1;
2749 }
2750
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 if ((err = avformat_open_input(&fmt_ctx, filename,
2751 iformat, &format_opts)) < 0) {
2752 ✗ print_error(filename, err);
2753 ✗ return err;
2754 }
2755
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 291 times.
316 if (print_filename) {
2756 25 av_freep(&fmt_ctx->url);
2757 25 fmt_ctx->url = av_strdup(print_filename);
2758 }
2759 316 ifile->fmt_ctx = fmt_ctx;
2760
1/2
✓ Branch 0 taken 316 times.
✗ Branch 1 not taken.
316 if (scan_all_pmts_set)
2761 316 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
2762
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 while ((t = av_dict_iterate(format_opts, t)))
2763 ✗ av_log(NULL, AV_LOG_WARNING, "Option %s skipped - not known to demuxer.\n", t->key);
2764
2765
1/2
✓ Branch 0 taken 316 times.
✗ Branch 1 not taken.
316 if (find_stream_info) {
2766 AVDictionary **opts;
2767 316 int orig_nb_streams = fmt_ctx->nb_streams;
2768
2769 316 err = setup_find_stream_info_opts(fmt_ctx, codec_opts, &opts);
2770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (err < 0)
2771 ✗ return err;
2772
2773 316 err = avformat_find_stream_info(fmt_ctx, opts);
2774
2775
2/2
✓ Branch 0 taken 543 times.
✓ Branch 1 taken 316 times.
859 for (int i = 0; i < orig_nb_streams; i++)
2776 543 av_dict_free(&opts[i]);
2777 316 av_freep(&opts);
2778
2779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (err < 0) {
2780 ✗ print_error(filename, err);
2781 ✗ return err;
2782 }
2783 }
2784
2785 316 av_dump_format(fmt_ctx, 0, filename, 0);
2786
2787 316 ifile->streams = av_calloc(fmt_ctx->nb_streams, sizeof(*ifile->streams));
2788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (!ifile->streams)
2789 ✗ exit(1);
2790 316 ifile->nb_streams = fmt_ctx->nb_streams;
2791
2792 /* bind a decoder to each input stream */
2793
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 316 times.
884 for (unsigned i = 0; i < fmt_ctx->nb_streams; i++) {
2794 568 InputStream *ist = &ifile->streams[i];
2795 568 AVStream *stream = fmt_ctx->streams[i];
2796 const AVCodec *codec;
2797
2798 568 ist->st = stream;
2799
2800 568 codec = get_decoder_for_stream(fmt_ctx, stream);
2801
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 526 times.
568 if (!codec)
2802 42 continue;
2803
2804 {
2805 AVDictionary *opts;
2806
2807 526 err = filter_codec_opts(codec_opts, stream->codecpar->codec_id,
2808 fmt_ctx, stream, codec, &opts, NULL);
2809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if (err < 0)
2810 ✗ exit(1);
2811
2812 526 ist->dec_ctx = avcodec_alloc_context3(codec);
2813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if (!ist->dec_ctx)
2814 ✗ exit(1);
2815
2816 526 err = avcodec_parameters_to_context(ist->dec_ctx, stream->codecpar);
2817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if (err < 0)
2818 ✗ exit(1);
2819
2820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if (do_show_log) {
2821 // For logging it is needed to disable at least frame threads as otherwise
2822 // the log information would need to be reordered and matches up to contexts and frames
2823 // That is in fact possible but not trivial
2824 ✗ av_dict_set(&codec_opts, "threads", "1", 0);
2825 }
2826
2827 526 av_dict_set(&opts, "flags", "+copy_opaque", AV_DICT_MULTIKEY);
2828
2829 526 ist->dec_ctx->pkt_timebase = stream->time_base;
2830
2831
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 526 times.
526 if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {
2832 ✗ av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n",
2833 stream->index);
2834 ✗ exit(1);
2835 }
2836
2837
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 526 times.
526 if ((t = av_dict_iterate(opts, NULL))) {
2838 ✗ av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not found\n",
2839 ✗ t->key, stream->index);
2840 ✗ return AVERROR_OPTION_NOT_FOUND;
2841 }
2842 }
2843 }
2844
2845 316 ifile->fmt_ctx = fmt_ctx;
2846 316 return 0;
2847 }
2848
2849 316 static void close_input_file(InputFile *ifile)
2850 {
2851
2852 /* close decoder for each stream */
2853
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 316 times.
884 for (int i = 0; i < ifile->nb_streams; i++)
2854 568 avcodec_free_context(&ifile->streams[i].dec_ctx);
2855
2856 316 av_freep(&ifile->streams);
2857 316 ifile->nb_streams = 0;
2858
2859 316 avformat_close_input(&ifile->fmt_ctx);
2860 316 }
2861
2862 316 static int probe_file(AVTextFormatContext *tfc, const char *filename,
2863 const char *print_filename)
2864 {
2865 316 InputFile ifile = { 0 };
2866 int ret;
2867 int section_id;
2868
2869
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
316 do_analyze_frames = do_analyze_frames && do_show_streams;
2870
4/6
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 244 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
316 do_read_frames = do_show_frames || do_count_frames || do_analyze_frames;
2871
3/4
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 228 times.
316 do_read_packets = do_show_packets || do_count_packets;
2872
2873 316 ret = open_input_file(&ifile, filename, print_filename);
2874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (ret < 0)
2875 ✗ goto end;
2876
2877 #define CHECK_END if (ret < 0) goto end
2878
2879 316 nb_streams = ifile.fmt_ctx->nb_streams;
2880
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 REALLOCZ_ARRAY_STREAM(nb_streams_frames,0,ifile.fmt_ctx->nb_streams);
2881
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 REALLOCZ_ARRAY_STREAM(nb_streams_packets,0,ifile.fmt_ctx->nb_streams);
2882
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 REALLOCZ_ARRAY_STREAM(selected_streams,0,ifile.fmt_ctx->nb_streams);
2883
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 REALLOCZ_ARRAY_STREAM(streams_with_closed_captions,0,ifile.fmt_ctx->nb_streams);
2884
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 REALLOCZ_ARRAY_STREAM(streams_with_film_grain,0,ifile.fmt_ctx->nb_streams);
2885
2886
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 316 times.
884 for (unsigned i = 0; i < ifile.fmt_ctx->nb_streams; i++) {
2887
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 479 times.
568 if (stream_specifier) {
2888 89 ret = avformat_match_stream_specifier(ifile.fmt_ctx,
2889 89 ifile.fmt_ctx->streams[i],
2890 stream_specifier);
2891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 CHECK_END;
2892 else
2893 89 selected_streams[i] = ret;
2894 89 ret = 0;
2895 } else {
2896 479 selected_streams[i] = 1;
2897 }
2898
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 529 times.
568 if (!selected_streams[i])
2899 39 ifile.fmt_ctx->streams[i]->discard = AVDISCARD_ALL;
2900 }
2901
2902
4/4
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 168 times.
316 if (do_read_frames || do_read_packets) {
2903
4/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 60 times.
148 if (do_show_frames && do_show_packets &&
2904
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 7 times.
12 tfc->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_MIXED_ARRAY_CONTENT)
2905 5 section_id = SECTION_ID_PACKETS_AND_FRAMES;
2906
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 7 times.
143 else if (do_show_packets && !do_show_frames)
2907 76 section_id = SECTION_ID_PACKETS;
2908 else // (!do_show_packets && do_show_frames)
2909 67 section_id = SECTION_ID_FRAMES;
2910
3/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
148 if (do_show_frames || do_show_packets)
2911 148 avtext_print_section_header(tfc, NULL, section_id);
2912 148 ret = read_packets(tfc, &ifile);
2913
3/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
148 if (do_show_frames || do_show_packets)
2914 148 avtext_print_section_footer(tfc);
2915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 CHECK_END;
2916 }
2917
2918
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 312 times.
316 if (do_show_programs) {
2919 4 ret = show_programs(tfc, &ifile);
2920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 CHECK_END;
2921 }
2922
2923
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 285 times.
316 if (do_show_stream_groups) {
2924 31 ret = show_stream_groups(tfc, &ifile);
2925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 CHECK_END;
2926 }
2927
2928
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 128 times.
316 if (do_show_streams) {
2929 188 ret = show_streams(tfc, &ifile);
2930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
188 CHECK_END;
2931 }
2932
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 309 times.
316 if (do_show_chapters) {
2933 7 ret = show_chapters(tfc, &ifile);
2934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 CHECK_END;
2935 }
2936
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 82 times.
316 if (do_show_format) {
2937 82 ret = show_format(tfc, &ifile);
2938
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 CHECK_END;
2939 }
2940
2941 316 end:
2942
1/2
✓ Branch 0 taken 316 times.
✗ Branch 1 not taken.
316 if (ifile.fmt_ctx)
2943 316 close_input_file(&ifile);
2944 316 av_freep(&nb_streams_frames);
2945 316 av_freep(&nb_streams_packets);
2946 316 av_freep(&selected_streams);
2947 316 av_freep(&streams_with_closed_captions);
2948 316 av_freep(&streams_with_film_grain);
2949 316 av_freep(&audio_codec_name);
2950 316 av_freep(&data_codec_name);
2951 316 av_freep(&subtitle_codec_name);
2952 316 av_freep(&video_codec_name);
2953
2954 316 return ret;
2955 }
2956
2957 ✗ static void show_usage(void)
2958 {
2959 ✗ av_log(NULL, AV_LOG_INFO, "Simple multimedia streams analyzer\n");
2960 ✗ av_log(NULL, AV_LOG_INFO, "usage: %s [OPTIONS] INPUT_FILE\n", program_name);
2961 ✗ av_log(NULL, AV_LOG_INFO, "\n");
2962 ✗ }
2963
2964 ✗ static void ffprobe_show_program_version(AVTextFormatContext *tfc)
2965 {
2966 AVBPrint pbuf;
2967 ✗ av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
2968
2969 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PROGRAM_VERSION);
2970 ✗ print_str("version", FFMPEG_VERSION);
2971 ✗ print_fmt("copyright", "Copyright (c) %d-%d the FFmpeg developers",
2972 program_birth_year, CONFIG_THIS_YEAR);
2973 ✗ print_str("compiler_ident", CC_IDENT);
2974 ✗ print_str("configuration", FFMPEG_CONFIGURATION);
2975 ✗ avtext_print_section_footer(tfc);
2976
2977 ✗ av_bprint_finalize(&pbuf, NULL);
2978 ✗ }
2979
2980 #define SHOW_LIB_VERSION(libname, LIBNAME) \
2981 do { \
2982 if (CONFIG_##LIBNAME) { \
2983 unsigned int version = libname##_version(); \
2984 avtext_print_section_header(tfc, NULL, SECTION_ID_LIBRARY_VERSION); \
2985 print_str("name", "lib" #libname); \
2986 print_int("major", LIB##LIBNAME##_VERSION_MAJOR); \
2987 print_int("minor", LIB##LIBNAME##_VERSION_MINOR); \
2988 print_int("micro", LIB##LIBNAME##_VERSION_MICRO); \
2989 print_int("version", version); \
2990 print_str("ident", LIB##LIBNAME##_IDENT); \
2991 avtext_print_section_footer(tfc); \
2992 } \
2993 } while (0)
2994
2995 ✗ static void ffprobe_show_library_versions(AVTextFormatContext *tfc)
2996 {
2997 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_LIBRARY_VERSIONS);
2998 ✗ SHOW_LIB_VERSION(avutil, AVUTIL);
2999 ✗ SHOW_LIB_VERSION(avcodec, AVCODEC);
3000 ✗ SHOW_LIB_VERSION(avformat, AVFORMAT);
3001 ✗ SHOW_LIB_VERSION(avdevice, AVDEVICE);
3002 ✗ SHOW_LIB_VERSION(avfilter, AVFILTER);
3003 ✗ SHOW_LIB_VERSION(swscale, SWSCALE);
3004 ✗ SHOW_LIB_VERSION(swresample, SWRESAMPLE);
3005 ✗ avtext_print_section_footer(tfc);
3006 ✗ }
3007
3008 #define PRINT_PIX_FMT_FLAG(flagname, name) \
3009 do { \
3010 print_int(name, !!(pixdesc->flags & AV_PIX_FMT_FLAG_##flagname)); \
3011 } while (0)
3012
3013 ✗ static void ffprobe_show_pixel_formats(AVTextFormatContext *tfc)
3014 {
3015 ✗ const AVPixFmtDescriptor *pixdesc = NULL;
3016 int i, n;
3017
3018 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PIXEL_FORMATS);
3019 ✗ while (pixdesc = av_pix_fmt_desc_next(pixdesc)) {
3020 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PIXEL_FORMAT);
3021 ✗ print_str("name", pixdesc->name);
3022 ✗ print_int("nb_components", pixdesc->nb_components);
3023 ✗ if ((pixdesc->nb_components >= 3) && !(pixdesc->flags & AV_PIX_FMT_FLAG_RGB)) {
3024 ✗ print_int ("log2_chroma_w", pixdesc->log2_chroma_w);
3025 ✗ print_int ("log2_chroma_h", pixdesc->log2_chroma_h);
3026 } else {
3027 ✗ print_str_opt("log2_chroma_w", "N/A");
3028 ✗ print_str_opt("log2_chroma_h", "N/A");
3029 }
3030 ✗ n = av_get_bits_per_pixel(pixdesc);
3031 ✗ if (n) print_int ("bits_per_pixel", n);
3032 ✗ else print_str_opt("bits_per_pixel", "N/A");
3033 ✗ if (do_show_pixel_format_flags) {
3034 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PIXEL_FORMAT_FLAGS);
3035 ✗ PRINT_PIX_FMT_FLAG(BE, "big_endian");
3036 ✗ PRINT_PIX_FMT_FLAG(PAL, "palette");
3037 ✗ PRINT_PIX_FMT_FLAG(BITSTREAM, "bitstream");
3038 ✗ PRINT_PIX_FMT_FLAG(HWACCEL, "hwaccel");
3039 ✗ PRINT_PIX_FMT_FLAG(PLANAR, "planar");
3040 ✗ PRINT_PIX_FMT_FLAG(RGB, "rgb");
3041 ✗ PRINT_PIX_FMT_FLAG(ALPHA, "alpha");
3042 ✗ avtext_print_section_footer(tfc);
3043 }
3044 ✗ if (do_show_pixel_format_components && (pixdesc->nb_components > 0)) {
3045 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PIXEL_FORMAT_COMPONENTS);
3046 ✗ for (i = 0; i < pixdesc->nb_components; i++) {
3047 ✗ avtext_print_section_header(tfc, NULL, SECTION_ID_PIXEL_FORMAT_COMPONENT);
3048 ✗ print_int("index", i + 1);
3049 ✗ print_int("bit_depth", pixdesc->comp[i].depth);
3050 ✗ avtext_print_section_footer(tfc);
3051 }
3052 ✗ avtext_print_section_footer(tfc);
3053 }
3054 ✗ avtext_print_section_footer(tfc);
3055 }
3056 ✗ avtext_print_section_footer(tfc);
3057 ✗ }
3058
3059 ✗ static int opt_show_optional_fields(void *optctx, const char *opt, const char *arg)
3060 {
3061 ✗ if (!av_strcasecmp(arg, "always")) show_optional_fields = SHOW_OPTIONAL_FIELDS_ALWAYS;
3062 ✗ else if (!av_strcasecmp(arg, "never")) show_optional_fields = SHOW_OPTIONAL_FIELDS_NEVER;
3063 ✗ else if (!av_strcasecmp(arg, "auto")) show_optional_fields = SHOW_OPTIONAL_FIELDS_AUTO;
3064
3065 ✗ if (show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO && av_strcasecmp(arg, "auto")) {
3066 double num;
3067 ✗ int ret = parse_number("show_optional_fields", arg, OPT_TYPE_INT,
3068 SHOW_OPTIONAL_FIELDS_AUTO, SHOW_OPTIONAL_FIELDS_ALWAYS, &num);
3069 ✗ if (ret < 0)
3070 ✗ return ret;
3071 ✗ show_optional_fields = num;
3072 }
3073 ✗ return 0;
3074 }
3075
3076 22 static int opt_format(void *optctx, const char *opt, const char *arg)
3077 {
3078 22 iformat = av_find_input_format(arg);
3079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (!iformat) {
3080 ✗ av_log(NULL, AV_LOG_ERROR, "Unknown input format: %s\n", arg);
3081 ✗ return AVERROR(EINVAL);
3082 }
3083 22 return 0;
3084 }
3085
3086 2738 static inline void mark_section_show_entries(SectionID section_id,
3087 int show_all_entries, AVDictionary *entries,
3088 int explicitly_selected)
3089 {
3090 2738 EntrySelection *selection = &selected_entries[section_id];
3091
3092 2738 selection->show_all_entries = show_all_entries;
3093 2738 selection->explicitly_selected |= explicitly_selected;
3094
2/2
✓ Branch 0 taken 2150 times.
✓ Branch 1 taken 588 times.
2738 if (show_all_entries) {
3095 2150 const AVTextFormatSection *section = &sections[section_id];
3096
2/2
✓ Branch 0 taken 1738 times.
✓ Branch 1 taken 2150 times.
3888 for (const int *id = section->children_ids; *id != -1; id++)
3097 1738 mark_section_show_entries(*id, show_all_entries, entries, explicitly_selected);
3098 } else {
3099 588 av_dict_copy(&selection->entries_to_show, entries, 0);
3100 }
3101 2738 }
3102
3103 547 static int match_section(const char *section_name,
3104 int show_all_entries, AVDictionary *entries)
3105 {
3106 547 int ret = 0;
3107
3108
2/2
✓ Branch 0 taken 47042 times.
✓ Branch 1 taken 547 times.
47589 for (unsigned i = 0; i < FF_ARRAY_ELEMS(sections); i++) {
3109 47042 const struct AVTextFormatSection *section = &sections[i];
3110
2/2
✓ Branch 0 taken 46482 times.
✓ Branch 1 taken 560 times.
47042 if (!strcmp(section_name, section->name) ||
3111
4/4
✓ Branch 0 taken 28700 times.
✓ Branch 1 taken 17782 times.
✓ Branch 2 taken 277 times.
✓ Branch 3 taken 28423 times.
46482 (section->unique_name && !strcmp(section_name, section->unique_name))) {
3112 837 av_log(NULL, AV_LOG_DEBUG,
3113 "'%s' matches section with unique name '%s'\n", section_name,
3114 837 (char *)av_x_if_null(section->unique_name, section->name));
3115 837 ret++;
3116 837 mark_section_show_entries(section->id, show_all_entries, entries,
3117
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 269 times.
837 !section->unique_name ||
3118
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 291 times.
568 !strcmp(section_name, section->unique_name));
3119 }
3120 }
3121 547 return ret;
3122 }
3123
3124 265 static int opt_show_entries(void *optctx, const char *opt, const char *arg)
3125 {
3126 265 const char *p = arg;
3127 265 int ret = 0;
3128
3129
2/2
✓ Branch 0 taken 547 times.
✓ Branch 1 taken 265 times.
812 while (*p) {
3130 547 AVDictionary *entries = NULL;
3131 547 char *section_name = av_get_token(&p, "=:");
3132 547 int show_all_entries = 0;
3133
3134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 547 times.
547 if (!section_name) {
3135 ✗ av_log(NULL, AV_LOG_ERROR,
3136 "Missing section name for option '%s'\n", opt);
3137 ✗ return AVERROR(EINVAL);
3138 }
3139
3140
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 234 times.
547 if (*p == '=') {
3141 313 p++;
3142
4/4
✓ Branch 0 taken 867 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 680 times.
✓ Branch 3 taken 187 times.
1306 while (*p && *p != ':') {
3143 680 char *entry = av_get_token(&p, ",:");
3144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 680 times.
680 if (!entry)
3145 ✗ break;
3146 680 av_log(NULL, AV_LOG_VERBOSE,
3147 "Adding '%s' to the entries to show in section '%s'\n",
3148 entry, section_name);
3149 680 av_dict_set(&entries, entry, "", AV_DICT_DONT_STRDUP_KEY);
3150
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 379 times.
680 if (*p == ',')
3151 379 p++;
3152 }
3153 } else {
3154 234 show_all_entries = 1;
3155 }
3156
3157 547 ret = match_section(section_name, show_all_entries, entries);
3158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 547 times.
547 if (ret == 0) {
3159 ✗ av_log(NULL, AV_LOG_ERROR, "No match for section '%s'\n", section_name);
3160 ✗ ret = AVERROR(EINVAL);
3161 }
3162 547 av_dict_free(&entries);
3163 547 av_free(section_name);
3164
3165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 547 times.
547 if (ret <= 0)
3166 ✗ break;
3167
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 265 times.
547 if (*p)
3168 282 p++;
3169 }
3170
3171 265 return ret;
3172 }
3173
3174 316 static int opt_input_file(void *optctx, const char *arg)
3175 {
3176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (input_filename) {
3177 ✗ av_log(NULL, AV_LOG_ERROR,
3178 "Argument '%s' provided as input filename, but '%s' was already specified.\n",
3179 arg, input_filename);
3180 ✗ return AVERROR(EINVAL);
3181 }
3182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (!strcmp(arg, "-"))
3183 ✗ arg = "fd:";
3184 316 input_filename = av_strdup(arg);
3185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (!input_filename)
3186 ✗ return AVERROR(ENOMEM);
3187
3188 316 return 0;
3189 }
3190
3191 15 static int opt_input_file_i(void *optctx, const char *opt, const char *arg)
3192 {
3193 15 opt_input_file(optctx, arg);
3194 15 return 0;
3195 }
3196
3197 ✗ static int opt_output_file_o(void *optctx, const char *opt, const char *arg)
3198 {
3199 ✗ if (output_filename) {
3200 ✗ av_log(NULL, AV_LOG_ERROR,
3201 "Argument '%s' provided as output filename, but '%s' was already specified.\n",
3202 arg, output_filename);
3203 ✗ return AVERROR(EINVAL);
3204 }
3205 ✗ if (!strcmp(arg, "-"))
3206 ✗ arg = "fd:";
3207 ✗ output_filename = av_strdup(arg);
3208 ✗ if (!output_filename)
3209 ✗ return AVERROR(ENOMEM);
3210
3211 ✗ return 0;
3212 }
3213
3214 25 static int opt_print_filename(void *optctx, const char *opt, const char *arg)
3215 {
3216 25 av_freep(&print_input_filename);
3217 25 print_input_filename = av_strdup(arg);
3218
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 return print_input_filename ? 0 : AVERROR(ENOMEM);
3219 }
3220
3221 ✗ void show_help_default(const char *opt, const char *arg)
3222 {
3223 ✗ av_log_set_callback(log_callback_help);
3224 ✗ show_usage();
3225 ✗ show_help_options(options, "Main options:", 0, 0);
3226 ✗ printf("\n");
3227
3228 ✗ show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
3229 ✗ show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM);
3230 ✗ }
3231
3232 /**
3233 * Parse interval specification, according to the format:
3234 * INTERVAL ::= [START|+START_OFFSET][%[END|+END_OFFSET]]
3235 * INTERVALS ::= INTERVAL[,INTERVALS]
3236 */
3237 9 static int parse_read_interval(const char *interval_spec,
3238 ReadInterval *interval)
3239 {
3240 9 int ret = 0;
3241 9 char *next, *p, *spec = av_strdup(interval_spec);
3242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (!spec)
3243 ✗ return AVERROR(ENOMEM);
3244
3245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (!*spec) {
3246 ✗ av_log(NULL, AV_LOG_ERROR, "Invalid empty interval specification\n");
3247 ✗ ret = AVERROR(EINVAL);
3248 ✗ goto end;
3249 }
3250
3251 9 p = spec;
3252 9 next = strchr(spec, '%');
3253
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (next)
3254 9 *next++ = 0;
3255
3256 /* parse first part */
3257
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
9 if (*p) {
3258 2 interval->has_start = 1;
3259
3260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (*p == '+') {
3261 ✗ interval->start_is_offset = 1;
3262 ✗ p++;
3263 } else {
3264 2 interval->start_is_offset = 0;
3265 }
3266
3267 2 ret = av_parse_time(&interval->start, p, 1);
3268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (ret < 0) {
3269 ✗ av_log(NULL, AV_LOG_ERROR, "Invalid interval start specification '%s'\n", p);
3270 ✗ goto end;
3271 }
3272 } else {
3273 7 interval->has_start = 0;
3274 }
3275
3276 /* parse second part */
3277 9 p = next;
3278
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 if (p && *p) {
3279 int64_t us;
3280 9 interval->has_end = 1;
3281
3282
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if (*p == '+') {
3283 6 interval->end_is_offset = 1;
3284 6 p++;
3285 } else {
3286 3 interval->end_is_offset = 0;
3287 }
3288
3289
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
9 if (interval->end_is_offset && *p == '#') {
3290 long long int lli;
3291 char *tail;
3292 6 interval->duration_frames = 1;
3293 6 p++;
3294 6 lli = strtoll(p, &tail, 10);
3295
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if (*tail || lli < 0) {
3296 ✗ av_log(NULL, AV_LOG_ERROR,
3297 "Invalid or negative value '%s' for duration number of frames\n", p);
3298 ✗ goto end;
3299 }
3300 6 interval->end = lli;
3301 } else {
3302 3 interval->duration_frames = 0;
3303 3 ret = av_parse_time(&us, p, 1);
3304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (ret < 0) {
3305 ✗ av_log(NULL, AV_LOG_ERROR, "Invalid interval end/duration specification '%s'\n", p);
3306 ✗ goto end;
3307 }
3308 3 interval->end = us;
3309 }
3310 } else {
3311 ✗ interval->has_end = 0;
3312 }
3313
3314 9 end:
3315 9 av_free(spec);
3316 9 return ret;
3317 }
3318
3319 9 static int parse_read_intervals(const char *intervals_spec)
3320 {
3321 int ret, n, i;
3322 9 char *p, *spec = av_strdup(intervals_spec);
3323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (!spec)
3324 ✗ return AVERROR(ENOMEM);
3325
3326 /* preparse specification, get number of intervals */
3327
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 9 times.
55 for (n = 0, p = spec; *p; p++)
3328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if (*p == ',')
3329 ✗ n++;
3330 9 n++;
3331
3332 9 read_intervals = av_malloc_array(n, sizeof(*read_intervals));
3333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (!read_intervals) {
3334 ✗ ret = AVERROR(ENOMEM);
3335 ✗ goto end;
3336 }
3337 9 read_intervals_nb = n;
3338
3339 /* parse intervals */
3340 9 p = spec;
3341
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 for (i = 0; p; i++) {
3342 char *next;
3343
3344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 av_assert0(i < read_intervals_nb);
3345 9 next = strchr(p, ',');
3346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (next)
3347 ✗ *next++ = 0;
3348
3349 9 read_intervals[i].id = i;
3350 9 ret = parse_read_interval(p, &read_intervals[i]);
3351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (ret < 0) {
3352 ✗ av_log(NULL, AV_LOG_ERROR, "Error parsing read interval #%d '%s'\n",
3353 i, p);
3354 ✗ goto end;
3355 }
3356 9 av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval ");
3357 9 log_read_interval(&read_intervals[i], NULL, AV_LOG_VERBOSE);
3358 9 p = next;
3359 }
3360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 av_assert0(i == read_intervals_nb);
3361
3362 9 end:
3363 9 av_free(spec);
3364 9 return ret;
3365 }
3366
3367 9 static int opt_read_intervals(void *optctx, const char *opt, const char *arg)
3368 {
3369 9 return parse_read_intervals(arg);
3370 }
3371
3372 ✗ static int opt_pretty(void *optctx, const char *opt, const char *arg)
3373 {
3374 ✗ show_value_unit = 1;
3375 ✗ use_value_prefix = 1;
3376 ✗ use_byte_value_binary_prefix = 1;
3377 ✗ use_value_sexagesimal_format = 1;
3378 ✗ return 0;
3379 }
3380
3381 ✗ static void print_section(SectionID id, int level)
3382 {
3383 const int *pid;
3384 ✗ const struct AVTextFormatSection *section = &sections[id];
3385 ✗ printf("%c%c%c%c",
3386 ✗ section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER ? 'W' : '.',
3387 ✗ section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY ? 'A' : '.',
3388 ✗ section->flags & AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS ? 'V' : '.',
3389 ✗ section->flags & AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE ? 'T' : '.');
3390 ✗ printf("%*c %s", level * 4, ' ', section->name);
3391 ✗ if (section->unique_name)
3392 ✗ printf("/%s", section->unique_name);
3393 ✗ printf("\n");
3394
3395 ✗ for (pid = section->children_ids; *pid != -1; pid++)
3396 ✗ print_section(*pid, level+1);
3397 ✗ }
3398
3399 ✗ static int opt_sections(void *optctx, const char *opt, const char *arg)
3400 {
3401 ✗ printf("Sections:\n"
3402 "W... = Section is a wrapper (contains other sections, no local entries)\n"
3403 ".A.. = Section contains an array of elements of the same type\n"
3404 "..V. = Section may contain a variable number of fields with variable keys\n"
3405 "...T = Section contain a unique type\n"
3406 "FLAGS NAME/UNIQUE_NAME\n"
3407 "----\n");
3408 ✗ print_section(SECTION_ID_ROOT, 0);
3409 ✗ return 0;
3410 }
3411
3412 ✗ static int opt_codec(void *optctx, const char *opt, const char *arg)
3413 {
3414 ✗ const char *spec = strchr(opt, ':');
3415 const char **name;
3416 ✗ if (!spec) {
3417 ✗ av_log(NULL, AV_LOG_ERROR,
3418 "No media specifier was specified for '%s' in option '%s'. Use -%s:<media_spec> "
3419 "where <media_spec> can be one of: 'a' (audio), 'v' (video), 's' (subtitle), 'd' (data)\n",
3420 arg, opt, opt);
3421 ✗ return AVERROR(EINVAL);
3422 }
3423 ✗ spec++;
3424
3425 ✗ switch (spec[0]) {
3426 ✗ case 'a' : name = &audio_codec_name; break;
3427 ✗ case 'd' : name = &data_codec_name; break;
3428 ✗ case 's' : name = &subtitle_codec_name; break;
3429 ✗ case 'v' : name = &video_codec_name; break;
3430 ✗ default:
3431 ✗ av_log(NULL, AV_LOG_ERROR,
3432 "Invalid media specifier '%s' in option '%s'. "
3433 "Must be one of: 'a' (audio), 'v' (video), 's' (subtitle), 'd' (data)\n", spec, opt);
3434 ✗ return AVERROR(EINVAL);
3435 }
3436
3437 ✗ av_freep(name);
3438 ✗ *name = av_strdup(arg);
3439 ✗ return *name ? 0 : AVERROR(ENOMEM);
3440 }
3441
3442 ✗ static int opt_show_versions(void *optctx, const char *opt, const char *arg)
3443 {
3444 ✗ mark_section_show_entries(SECTION_ID_PROGRAM_VERSION, 1, NULL, 1);
3445 ✗ mark_section_show_entries(SECTION_ID_LIBRARY_VERSION, 1, NULL, 1);
3446 ✗ return 0;
3447 }
3448
3449 #define DEFINE_OPT_SHOW_SECTION(section, target_section_id) \
3450 static int opt_show_##section(void *optctx, const char *opt, const char *arg) \
3451 { \
3452 mark_section_show_entries(SECTION_ID_##target_section_id, 1, NULL, 1); \
3453 return 0; \
3454 }
3455
3456 5 DEFINE_OPT_SHOW_SECTION(chapters, CHAPTERS)
3457 ✗ DEFINE_OPT_SHOW_SECTION(error, ERROR)
3458 25 DEFINE_OPT_SHOW_SECTION(format, FORMAT)
3459 41 DEFINE_OPT_SHOW_SECTION(frames, FRAMES)
3460 ✗ DEFINE_OPT_SHOW_SECTION(library_versions, LIBRARY_VERSIONS)
3461 52 DEFINE_OPT_SHOW_SECTION(packets, PACKETS)
3462 ✗ DEFINE_OPT_SHOW_SECTION(pixel_formats, PIXEL_FORMATS)
3463 ✗ DEFINE_OPT_SHOW_SECTION(program_version, PROGRAM_VERSION)
3464 37 DEFINE_OPT_SHOW_SECTION(streams, STREAMS)
3465 2 DEFINE_OPT_SHOW_SECTION(programs, PROGRAMS)
3466 1 DEFINE_OPT_SHOW_SECTION(stream_groups, STREAM_GROUPS)
3467
3468 static const OptionDef real_options[] = {
3469 CMDUTILS_COMMON_OPTIONS
3470 { "f", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_format}, "force format", "format" },
3471 { "unit", OPT_TYPE_BOOL, 0, {&show_value_unit}, "show unit of the displayed values" },
3472 { "prefix", OPT_TYPE_BOOL, 0, {&use_value_prefix}, "use SI prefixes for the displayed values" },
3473 { "byte_binary_prefix", OPT_TYPE_BOOL, 0, {&use_byte_value_binary_prefix},
3474 "use binary prefixes for byte units" },
3475 { "sexagesimal", OPT_TYPE_BOOL, 0, {&use_value_sexagesimal_format},
3476 "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
3477 { "pretty", OPT_TYPE_FUNC, 0, {.func_arg = opt_pretty},
3478 "prettify the format of displayed values, make it more human readable" },
3479 { "output_format", OPT_TYPE_STRING, 0, { &output_format },
3480 "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)", "format" },
3481 { "print_format", OPT_TYPE_STRING, 0, { &output_format }, "alias for -output_format (deprecated)" },
3482 { "of", OPT_TYPE_STRING, 0, { &output_format }, "alias for -output_format", "format" },
3483 { "select_streams", OPT_TYPE_STRING, 0, { &stream_specifier }, "select the specified streams", "stream_specifier" },
3484 { "sections", OPT_TYPE_FUNC, OPT_EXIT, {.func_arg = opt_sections}, "print sections structure and section information, and exit" },
3485 { "data_dump_format", OPT_TYPE_STRING, 0, { &data_dump_format }, "set data dump format (available formats are: xxd, base64)" },
3486 { "show_data", OPT_TYPE_BOOL, 0, { &do_show_data }, "show packets data" },
3487 { "show_data_hash", OPT_TYPE_STRING, 0, { &show_data_hash }, "show packets data hash" },
3488 { "show_error", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_error }, "show probing error" },
3489 { "show_format", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_format }, "show format/container info" },
3490 { "show_frames", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_frames }, "show frames info" },
3491 { "show_entries", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_show_entries},
3492 "show a set of specified entries", "entry_list" },
3493 #if HAVE_THREADS
3494 { "show_log", OPT_TYPE_INT, 0, { &do_show_log }, "show log" },
3495 #endif
3496 { "show_packets", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_packets }, "show packets info" },
3497 { "show_programs", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_programs }, "show programs info" },
3498 { "show_stream_groups", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_stream_groups }, "show stream groups info" },
3499 { "show_streams", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_streams }, "show streams info" },
3500 { "show_chapters", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_chapters }, "show chapters info" },
3501 { "count_frames", OPT_TYPE_BOOL, 0, { &do_count_frames }, "count the number of frames per stream" },
3502 { "count_packets", OPT_TYPE_BOOL, 0, { &do_count_packets }, "count the number of packets per stream" },
3503 { "show_program_version", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_program_version }, "show ffprobe version" },
3504 { "show_library_versions", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_library_versions }, "show library versions" },
3505 { "show_versions", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_versions }, "show program and library versions" },
3506 { "show_pixel_formats", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_pixel_formats }, "show pixel format descriptions" },
3507 { "show_optional_fields", OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = &opt_show_optional_fields }, "show optional fields" },
3508 { "show_private_data", OPT_TYPE_BOOL, 0, { &show_private_data }, "show private data" },
3509 { "private", OPT_TYPE_BOOL, 0, { &show_private_data }, "same as show_private_data" },
3510 { "analyze_frames", OPT_TYPE_BOOL, 0, { &do_analyze_frames }, "analyze frames to provide additional stream-level information" },
3511 { "bitexact", OPT_TYPE_BOOL, 0, {&do_bitexact}, "force bitexact output" },
3512 { "read_intervals", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_read_intervals}, "set read intervals", "read_intervals" },
3513 { "i", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_input_file_i}, "read specified file", "input_file"},
3514 { "o", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_output_file_o}, "write to specified output", "output_file"},
3515 { "print_filename", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
3516 { "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT, { &find_stream_info },
3517 "read and decode the streams to fill missing information with heuristics" },
3518 { "c", OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = opt_codec}, "force decoder", "decoder_name" },
3519 { "codec", OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = opt_codec}, "alias for -c (force decoder)", "decoder_name" },
3520 { NULL, },
3521 };
3522
3523 31135 static inline int check_section_show_entries(int section_id, int require_explicit)
3524 {
3525 31135 const EntrySelection *selection = &selected_entries[section_id];
3526
3527 /* A shared stream section must not implicitly enable programs or groups. */
3528
4/4
✓ Branch 0 taken 30822 times.
✓ Branch 1 taken 313 times.
✓ Branch 2 taken 286 times.
✓ Branch 3 taken 30536 times.
31135 if (section_id == SECTION_ID_PROGRAM_STREAMS ||
3529 section_id == SECTION_ID_STREAM_GROUP_STREAMS)
3530 599 require_explicit = 1;
3531
3532
4/4
✓ Branch 0 taken 4780 times.
✓ Branch 1 taken 26355 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4778 times.
31135 if ((!require_explicit || selection->explicitly_selected) &&
3533
4/4
✓ Branch 0 taken 25739 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 245 times.
✓ Branch 3 taken 25494 times.
26357 (selection->show_all_entries || selection->entries_to_show))
3534 863 return 1;
3535
3536 30272 const AVTextFormatSection *section = &sections[section_id];
3537
2/2
✓ Branch 0 taken 22603 times.
✓ Branch 1 taken 29935 times.
52538 for (const int *id = section->children_ids; *id != -1; id++)
3538
2/2
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 22266 times.
22603 if (check_section_show_entries(*id, require_explicit))
3539 337 return 1;
3540 29935 return 0;
3541 }
3542
3543 #define SET_DO_SHOW(id, varname) do { \
3544 if (check_section_show_entries(SECTION_ID_##id, 0)) \
3545 do_show_##varname = 1; \
3546 } while (0)
3547
3548 316 int main(int argc, char **argv)
3549 {
3550 const AVTextFormatter *f;
3551 AVTextFormatContext *tctx;
3552 AVTextWriterContext *wctx;
3553 char *buf;
3554 316 char *f_name = NULL, *f_args = NULL;
3555 int ret, input_ret;
3556 316 AVTextFormatDataDump data_dump_format_id = AV_TEXTFORMAT_DATADUMP_XXD;
3557
3558 316 init_dynload();
3559
3560 316 setvbuf(stderr, NULL, _IONBF, 0); /* win32 runtime needs this */
3561
3562 316 av_log_set_flags(AV_LOG_SKIP_REPEATED);
3563
3564 316 options = real_options;
3565 316 parse_loglevel(argc, argv, options);
3566 316 avformat_network_init();
3567 #if CONFIG_AVDEVICE
3568 316 avdevice_register_all();
3569 #endif
3570
3571 316 show_banner(argc, argv, options);
3572 316 ret = parse_options(NULL, argc, argv, options, opt_input_file);
3573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (ret < 0) {
3574 ✗ ret = (ret == AVERROR_EXIT) ? 0 : ret;
3575 ✗ goto end;
3576 }
3577
3578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (do_show_log)
3579 ✗ av_log_set_callback(log_callback);
3580
3581 /* mark things to show, based on -show_entries */
3582
2/2
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 309 times.
316 SET_DO_SHOW(CHAPTERS, chapters);
3583
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 SET_DO_SHOW(ERROR, error);
3584
2/2
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 234 times.
316 SET_DO_SHOW(FORMAT, format);
3585
2/2
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 244 times.
316 SET_DO_SHOW(FRAMES, frames);
3586
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 SET_DO_SHOW(LIBRARY_VERSIONS, library_versions);
3587
2/2
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 228 times.
316 SET_DO_SHOW(PACKETS, packets);
3588
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 SET_DO_SHOW(PIXEL_FORMATS, pixel_formats);
3589
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 SET_DO_SHOW(PIXEL_FORMAT_FLAGS, pixel_format_flags);
3590
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 SET_DO_SHOW(PIXEL_FORMAT_COMPONENTS, pixel_format_components);
3591
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 SET_DO_SHOW(PROGRAM_VERSION, program_version);
3592
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 312 times.
316 SET_DO_SHOW(PROGRAMS, programs);
3593
2/2
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 307 times.
316 SET_DO_SHOW(STREAM_GROUP_DISPOSITION, stream_group_disposition);
3594
2/2
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 285 times.
316 SET_DO_SHOW(STREAM_GROUPS, stream_groups);
3595
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 292 times.
316 SET_DO_SHOW(STREAM_GROUP_COMPONENTS, stream_group_components);
3596
2/2
✓ Branch 1 taken 188 times.
✓ Branch 2 taken 128 times.
316 SET_DO_SHOW(STREAMS, streams);
3597
2/2
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 260 times.
316 SET_DO_SHOW(STREAM_DISPOSITION, stream_disposition);
3598
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 310 times.
316 SET_DO_SHOW(PROGRAM_STREAM_DISPOSITION, stream_disposition);
3599
2/2
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 291 times.
316 SET_DO_SHOW(STREAM_GROUP_STREAM_DISPOSITION, stream_disposition);
3600
3601
2/2
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 309 times.
316 SET_DO_SHOW(CHAPTER_TAGS, chapter_tags);
3602
2/2
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 249 times.
316 SET_DO_SHOW(FORMAT_TAGS, format_tags);
3603
2/2
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 258 times.
316 SET_DO_SHOW(FRAME_TAGS, frame_tags);
3604
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 315 times.
316 SET_DO_SHOW(PROGRAM_TAGS, program_tags);
3605
2/2
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 307 times.
316 SET_DO_SHOW(STREAM_GROUP_TAGS, stream_group_tags);
3606
2/2
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 249 times.
316 SET_DO_SHOW(STREAM_TAGS, stream_tags);
3607
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 310 times.
316 SET_DO_SHOW(PROGRAM_STREAM_TAGS, stream_tags);
3608
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 311 times.
316 SET_DO_SHOW(STREAM_GROUP_STREAM_TAGS, stream_tags);
3609
2/2
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 265 times.
316 SET_DO_SHOW(PACKET_TAGS, packet_tags);
3610
3611
4/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 287 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 287 times.
316 if (do_bitexact && (do_show_program_version || do_show_library_versions)) {
3612 ✗ av_log(NULL, AV_LOG_ERROR,
3613 "-bitexact and -show_program_version or -show_library_versions "
3614 "options are incompatible\n");
3615 ✗ ret = AVERROR(EINVAL);
3616 ✗ goto end;
3617 }
3618
3619
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 119 times.
316 if (!output_format)
3620 197 output_format = av_strdup("default");
3621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (!output_format) {
3622 ✗ ret = AVERROR(ENOMEM);
3623 ✗ goto end;
3624 }
3625 316 f_name = av_strtok(output_format, "=", &buf);
3626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (!f_name) {
3627 ✗ av_log(NULL, AV_LOG_ERROR,
3628 "No name specified for the output format\n");
3629 ✗ ret = AVERROR(EINVAL);
3630 ✗ goto end;
3631 }
3632 316 f_args = buf;
3633
3634 316 f = avtext_get_formatter_by_name(f_name);
3635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (!f) {
3636 ✗ av_log(NULL, AV_LOG_ERROR, "Unknown output format with name '%s'\n", f_name);
3637 ✗ ret = AVERROR(EINVAL);
3638 ✗ goto end;
3639 }
3640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (f->flags & AV_TEXTFORMAT_FLAG_IS_DIAGRAM_FORMATTER) {
3641 ✗ av_log(NULL, AV_LOG_ERROR, "Output format '%s' can only draw filter graphs\n", f_name);
3642 ✗ ret = AVERROR(EINVAL);
3643 ✗ goto end;
3644 }
3645
3646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (data_dump_format) {
3647 ✗ if (!strcmp(data_dump_format, "xxd")) {
3648 ✗ data_dump_format_id = AV_TEXTFORMAT_DATADUMP_XXD;
3649 ✗ } else if (!strcmp(data_dump_format, "base64")) {
3650 ✗ data_dump_format_id = AV_TEXTFORMAT_DATADUMP_BASE64;
3651 } else {
3652 ✗ av_log(NULL, AV_LOG_ERROR, "Unknown data dump format with name '%s'\n", data_dump_format);
3653 ✗ ret = AVERROR(EINVAL);
3654 ✗ goto end;
3655 }
3656 }
3657
3658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (output_filename) {
3659 ✗ ret = avtextwriter_create_file(&wctx, output_filename);
3660 } else
3661 316 ret = avtextwriter_create_stdout(&wctx);
3662
3663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (ret < 0)
3664 ✗ goto end;
3665
3666 316 AVTextFormatOptions tf_options = {
3667 .is_key_selected = is_key_selected_callback,
3668 .show_optional_fields = show_optional_fields,
3669 .show_value_unit = show_value_unit,
3670 .use_value_prefix = use_value_prefix,
3671 .use_byte_value_binary_prefix = use_byte_value_binary_prefix,
3672 .use_value_sexagesimal_format = use_value_sexagesimal_format,
3673 .data_dump_format = data_dump_format_id,
3674 };
3675
3676
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 316 times.
316 if ((ret = avtext_context_open(&tctx, f, wctx, f_args, sections, FF_ARRAY_ELEMS(sections), tf_options, show_data_hash)) >= 0) {
3677
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 314 times.
316 if (f == &avtextformatter_xml)
3678 2 tctx->string_validation_utf8_flags |= AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES;
3679
3680 316 avtext_print_section_header(tctx, NULL, SECTION_ID_ROOT);
3681
3682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (do_show_program_version)
3683 ✗ ffprobe_show_program_version(tctx);
3684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (do_show_library_versions)
3685 ✗ ffprobe_show_library_versions(tctx);
3686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (do_show_pixel_formats)
3687 ✗ ffprobe_show_pixel_formats(tctx);
3688
3689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (!input_filename &&
3690 ✗ ((do_show_format || do_show_programs || do_show_stream_groups || do_show_streams || do_show_chapters || do_show_packets || do_show_error) ||
3691 ✗ (!do_show_program_version && !do_show_library_versions && !do_show_pixel_formats))) {
3692 ✗ show_usage();
3693 ✗ av_log(NULL, AV_LOG_ERROR, "You have to specify one input file.\n");
3694 ✗ av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
3695 ✗ ret = AVERROR(EINVAL);
3696
1/2
✓ Branch 0 taken 316 times.
✗ Branch 1 not taken.
316 } else if (input_filename) {
3697 316 ret = probe_file(tctx, input_filename, print_input_filename);
3698
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
316 if (ret < 0 && do_show_error)
3699 ✗ show_error(tctx, ret);
3700 }
3701
3702 316 input_ret = ret;
3703
3704 316 avtext_print_section_footer(tctx);
3705
3706 316 ret = avtextwriter_context_close(&wctx);
3707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (ret < 0)
3708 ✗ av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing writer): %s\n", av_err2str(ret));
3709
3710 316 ret = avtext_context_close(&tctx);
3711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
316 if (ret < 0)
3712 ✗ av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing formatter): %s\n", av_err2str(ret));
3713
3714 316 ret = FFMIN(ret, input_ret);
3715 }
3716
3717 ✗ end:
3718 316 av_freep(&output_format);
3719 316 av_freep(&output_filename);
3720 316 av_freep(&input_filename);
3721 316 av_freep(&print_input_filename);
3722 316 av_freep(&read_intervals);
3723
3724 316 uninit_opts();
3725
2/2
✓ Branch 0 taken 27176 times.
✓ Branch 1 taken 316 times.
27492 for (size_t i = 0; i < FF_ARRAY_ELEMS(selected_entries); ++i)
3726 27176 av_dict_free(&selected_entries[i].entries_to_show);
3727
3728 316 avformat_network_deinit();
3729
3730 316 return ret < 0;
3731 }
3732