FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffprobe.c
Date: 2026-09-28 04:46:15
Exec Total Coverage
Lines: 1436 2050 70.0%
Functions: 69 95 72.6%
Branches: 800 1334 60.0%

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