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