FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffprobe.c
Date: 2026-01-16 07:34:38
Exec Total Coverage
Lines: 1399 1940 72.1%
Functions: 67 92 72.8%
Branches: 757 1244 60.9%

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