FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffprobe.c
Date: 2025-04-25 22:50:00
Exec Total Coverage
Lines: 1336 1853 72.1%
Functions: 58 82 70.7%
Branches: 715 1180 60.6%

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