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