FFmpeg
ffprobe.c
Go to the documentation of this file.
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"
37 #include "libavutil/avassert.h"
38 #include "libavutil/avstring.h"
39 #include "libavutil/bprint.h"
41 #include "libavutil/display.h"
42 #include "libavutil/hash.h"
46 #include "libavutil/dovi_meta.h"
47 #include "libavutil/opt.h"
48 #include "libavutil/pixdesc.h"
49 #include "libavutil/spherical.h"
50 #include "libavutil/stereo3d.h"
51 #include "libavutil/dict.h"
52 #include "libavutil/intreadwrite.h"
53 #include "libavutil/libm.h"
54 #include "libavutil/parseutils.h"
55 #include "libavutil/timecode.h"
56 #include "libavutil/timestamp.h"
57 #include "libavdevice/avdevice.h"
58 #include "libavdevice/version.h"
59 #include "libswscale/swscale.h"
60 #include "libswscale/version.h"
62 #include "libswresample/version.h"
64 #include "libpostproc/version.h"
65 #include "libavfilter/version.h"
66 #include "cmdutils.h"
67 #include "opt_common.h"
68 
69 #include "libavutil/thread.h"
70 
71 #if !HAVE_THREADS
72 # ifdef pthread_mutex_lock
73 # undef pthread_mutex_lock
74 # endif
75 # define pthread_mutex_lock(a) do{}while(0)
76 # ifdef pthread_mutex_unlock
77 # undef pthread_mutex_unlock
78 # endif
79 # define pthread_mutex_unlock(a) do{}while(0)
80 #endif
81 
82 // attached as opaque_ref to packets/frames
83 typedef struct FrameData {
84  int64_t pkt_pos;
85  int pkt_size;
86 } FrameData;
87 
88 typedef struct InputStream {
89  AVStream *st;
90 
92 } InputStream;
93 
94 typedef struct InputFile {
96 
98  int nb_streams;
99 } InputFile;
100 
101 const char program_name[] = "ffprobe";
102 const int program_birth_year = 2007;
103 
104 static int do_bitexact = 0;
105 static int do_count_frames = 0;
106 static int do_count_packets = 0;
107 static int do_read_frames = 0;
108 static int do_read_packets = 0;
109 static int do_show_chapters = 0;
110 static int do_show_error = 0;
111 static int do_show_format = 0;
112 static int do_show_frames = 0;
113 static int do_show_packets = 0;
114 static int do_show_programs = 0;
115 static int do_show_streams = 0;
117 static int do_show_data = 0;
118 static int do_show_program_version = 0;
120 static int do_show_pixel_formats = 0;
123 static int do_show_log = 0;
124 
125 static int do_show_chapter_tags = 0;
126 static int do_show_format_tags = 0;
127 static int do_show_frame_tags = 0;
128 static int do_show_program_tags = 0;
129 static int do_show_stream_tags = 0;
130 static int do_show_packet_tags = 0;
131 
132 static int show_value_unit = 0;
133 static int use_value_prefix = 0;
136 static int show_private_data = 1;
137 
138 #define SHOW_OPTIONAL_FIELDS_AUTO -1
139 #define SHOW_OPTIONAL_FIELDS_NEVER 0
140 #define SHOW_OPTIONAL_FIELDS_ALWAYS 1
142 
143 static char *output_format;
144 static char *stream_specifier;
145 static char *show_data_hash;
146 
147 typedef struct ReadInterval {
148  int id; ///< identifier
149  int64_t start, end; ///< start, end in second/AV_TIME_BASE units
153 } ReadInterval;
154 
156 static int read_intervals_nb = 0;
157 
158 static int find_stream_info = 1;
159 
160 /* section structure definition */
161 
162 #define SECTION_MAX_NB_CHILDREN 10
163 
164 typedef enum {
214 } SectionID;
215 
216 struct section {
217  int id; ///< unique id identifying a section
218  const char *name;
219 
220 #define SECTION_FLAG_IS_WRAPPER 1 ///< the section only contains other sections, but has no data at its own level
221 #define SECTION_FLAG_IS_ARRAY 2 ///< the section contains an array of elements of the same type
222 #define SECTION_FLAG_HAS_VARIABLE_FIELDS 4 ///< the section may contain a variable number of fields with variable keys.
223  /// For these sections the element_name field is mandatory.
224 #define SECTION_FLAG_HAS_TYPE 8 ///< the section contains a type to distinguish multiple nested elements
225 
226  int flags;
227  const SectionID children_ids[SECTION_MAX_NB_CHILDREN+1]; ///< list of children section IDS, terminated by -1
228  const char *element_name; ///< name of the contained element, if provided
229  const char *unique_name; ///< unique section name, in case the name is ambiguous
231  const char *(* get_type)(void *data); ///< function returning a type if defined, must be defined when SECTION_FLAG_HAS_TYPE is defined
233 };
234 
235 static const char *get_packet_side_data_type(void *data) {
236  const AVPacketSideData *sd = (const AVPacketSideData *)data;
237  return av_x_if_null(av_packet_side_data_name(sd->type), "unknown");
238 }
239 
240 static const char *get_frame_side_data_type(void *data) {
241  const AVFrameSideData *sd = (const AVFrameSideData *)data;
242  return av_x_if_null(av_frame_side_data_name(sd->type), "unknown");
243 }
244 
245 static struct section sections[] = {
247  [SECTION_ID_CHAPTER] = { SECTION_ID_CHAPTER, "chapter", 0, { SECTION_ID_CHAPTER_TAGS, -1 } },
248  [SECTION_ID_CHAPTER_TAGS] = { SECTION_ID_CHAPTER_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "chapter_tags" },
249  [SECTION_ID_ERROR] = { SECTION_ID_ERROR, "error", 0, { -1 } },
250  [SECTION_ID_FORMAT] = { SECTION_ID_FORMAT, "format", 0, { SECTION_ID_FORMAT_TAGS, -1 } },
251  [SECTION_ID_FORMAT_TAGS] = { SECTION_ID_FORMAT_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "format_tags" },
254  [SECTION_ID_FRAME_TAGS] = { SECTION_ID_FRAME_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "frame_tags" },
255  [SECTION_ID_FRAME_SIDE_DATA_LIST] ={ SECTION_ID_FRAME_SIDE_DATA_LIST, "side_data_list", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "frame_side_data_list" },
264  [SECTION_ID_FRAME_LOG] = { SECTION_ID_FRAME_LOG, "log", 0, { -1 }, },
266  [SECTION_ID_LIBRARY_VERSION] = { SECTION_ID_LIBRARY_VERSION, "library_version", 0, { -1 } },
270  [SECTION_ID_PACKET_TAGS] = { SECTION_ID_PACKET_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "packet_tags" },
271  [SECTION_ID_PACKET_SIDE_DATA_LIST] ={ SECTION_ID_PACKET_SIDE_DATA_LIST, "side_data_list", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "packet_side_data_list" },
272  [SECTION_ID_PACKET_SIDE_DATA] = { SECTION_ID_PACKET_SIDE_DATA, "side_data", SECTION_FLAG_HAS_VARIABLE_FIELDS|SECTION_FLAG_HAS_TYPE, { -1 }, .unique_name = "packet_side_data", .element_name = "side_datum", .get_type = get_packet_side_data_type },
275  [SECTION_ID_PIXEL_FORMAT_FLAGS] = { SECTION_ID_PIXEL_FORMAT_FLAGS, "flags", 0, { -1 }, .unique_name = "pixel_format_flags" },
276  [SECTION_ID_PIXEL_FORMAT_COMPONENTS] = { SECTION_ID_PIXEL_FORMAT_COMPONENTS, "components", SECTION_FLAG_IS_ARRAY, {SECTION_ID_PIXEL_FORMAT_COMPONENT, -1 }, .unique_name = "pixel_format_components" },
278  [SECTION_ID_PROGRAM_STREAM_DISPOSITION] = { SECTION_ID_PROGRAM_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "program_stream_disposition" },
279  [SECTION_ID_PROGRAM_STREAM_TAGS] = { SECTION_ID_PROGRAM_STREAM_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "program_stream_tags" },
281  [SECTION_ID_PROGRAM_STREAMS] = { SECTION_ID_PROGRAM_STREAMS, "streams", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PROGRAM_STREAM, -1 }, .unique_name = "program_streams" },
283  [SECTION_ID_PROGRAM_TAGS] = { SECTION_ID_PROGRAM_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "program_tags" },
284  [SECTION_ID_PROGRAM_VERSION] = { SECTION_ID_PROGRAM_VERSION, "program_version", 0, { -1 } },
292  [SECTION_ID_STREAM_DISPOSITION] = { SECTION_ID_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "stream_disposition" },
293  [SECTION_ID_STREAM_TAGS] = { SECTION_ID_STREAM_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "stream_tags" },
294  [SECTION_ID_STREAM_SIDE_DATA_LIST] ={ SECTION_ID_STREAM_SIDE_DATA_LIST, "side_data_list", SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "stream_side_data_list" },
295  [SECTION_ID_STREAM_SIDE_DATA] = { SECTION_ID_STREAM_SIDE_DATA, "side_data", SECTION_FLAG_HAS_TYPE|SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .unique_name = "stream_side_data", .element_name = "side_datum", .get_type = get_packet_side_data_type },
296  [SECTION_ID_SUBTITLE] = { SECTION_ID_SUBTITLE, "subtitle", 0, { -1 } },
297 };
298 
299 static const OptionDef *options;
300 
301 /* FFprobe context */
302 static const char *input_filename;
303 static const char *print_input_filename;
304 static const AVInputFormat *iformat = NULL;
305 static const char *output_filename = NULL;
306 
307 static struct AVHashContext *hash;
308 
309 static const struct {
310  double bin_val;
311  double dec_val;
312  const char *bin_str;
313  const char *dec_str;
314 } si_prefixes[] = {
315  { 1.0, 1.0, "", "" },
316  { 1.024e3, 1e3, "Ki", "K" },
317  { 1.048576e6, 1e6, "Mi", "M" },
318  { 1.073741824e9, 1e9, "Gi", "G" },
319  { 1.099511627776e12, 1e12, "Ti", "T" },
320  { 1.125899906842624e15, 1e15, "Pi", "P" },
321 };
322 
323 static const char unit_second_str[] = "s" ;
324 static const char unit_hertz_str[] = "Hz" ;
325 static const char unit_byte_str[] = "byte" ;
326 static const char unit_bit_per_second_str[] = "bit/s";
327 
328 static int nb_streams;
329 static uint64_t *nb_streams_packets;
330 static uint64_t *nb_streams_frames;
331 static int *selected_streams;
332 
333 #if HAVE_THREADS
334 pthread_mutex_t log_mutex;
335 #endif
336 typedef struct LogBuffer {
339  char *log_message;
341  char *parent_name;
343 }LogBuffer;
344 
346 static int log_buffer_size;
347 
348 static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
349 {
350  AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
351  va_list vl2;
352  char line[1024];
353  static int print_prefix = 1;
354  void *new_log_buffer;
355 
356  va_copy(vl2, vl);
357  av_log_default_callback(ptr, level, fmt, vl);
358  av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix);
359  va_end(vl2);
360 
361 #if HAVE_THREADS
362  pthread_mutex_lock(&log_mutex);
363 
364  new_log_buffer = av_realloc_array(log_buffer, log_buffer_size + 1, sizeof(*log_buffer));
365  if (new_log_buffer) {
366  char *msg;
367  int i;
368 
369  log_buffer = new_log_buffer;
370  memset(&log_buffer[log_buffer_size], 0, sizeof(log_buffer[log_buffer_size]));
372  if (avc) {
375  }
378  for (i=strlen(msg) - 1; i>=0 && msg[i] == '\n'; i--) {
379  msg[i] = 0;
380  }
381  if (avc && avc->parent_log_context_offset) {
382  AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) +
384  if (parent && *parent) {
385  log_buffer[log_buffer_size].parent_name = av_strdup((*parent)->item_name(parent));
387  (*parent)->get_category ? (*parent)->get_category(parent) :(*parent)->category;
388  }
389  }
390  log_buffer_size ++;
391  }
392 
393  pthread_mutex_unlock(&log_mutex);
394 #endif
395 }
396 
397 struct unit_value {
398  union { double d; long long int i; } val;
399  const char *unit;
400 };
401 
402 static char *value_string(char *buf, int buf_size, struct unit_value uv)
403 {
404  double vald;
405  long long int vali;
406  int show_float = 0;
407 
408  if (uv.unit == unit_second_str) {
409  vald = uv.val.d;
410  show_float = 1;
411  } else {
412  vald = vali = uv.val.i;
413  }
414 
416  double secs;
417  int hours, mins;
418  secs = vald;
419  mins = (int)secs / 60;
420  secs = secs - mins * 60;
421  hours = mins / 60;
422  mins %= 60;
423  snprintf(buf, buf_size, "%d:%02d:%09.6f", hours, mins, secs);
424  } else {
425  const char *prefix_string = "";
426 
427  if (use_value_prefix && vald > 1) {
428  long long int index;
429 
431  index = (long long int) (log2(vald)) / 10;
433  vald /= si_prefixes[index].bin_val;
434  prefix_string = si_prefixes[index].bin_str;
435  } else {
436  index = (long long int) (log10(vald)) / 3;
438  vald /= si_prefixes[index].dec_val;
439  prefix_string = si_prefixes[index].dec_str;
440  }
441  vali = vald;
442  }
443 
444  if (show_float || (use_value_prefix && vald != (long long int)vald))
445  snprintf(buf, buf_size, "%f", vald);
446  else
447  snprintf(buf, buf_size, "%lld", vali);
448  av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || show_value_unit ? " " : "",
449  prefix_string, show_value_unit ? uv.unit : "");
450  }
451 
452  return buf;
453 }
454 
455 /* WRITERS API */
456 
457 typedef struct WriterContext WriterContext;
458 
459 #define WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS 1
460 #define WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER 2
461 
462 typedef enum {
468 
469 typedef struct Writer {
470  const AVClass *priv_class; ///< private class of the writer, if any
471  int priv_size; ///< private size for the writer context
472  const char *name;
473 
474  int (*init) (WriterContext *wctx);
475  void (*uninit)(WriterContext *wctx);
476 
477  void (*print_section_header)(WriterContext *wctx, void *data);
479  void (*print_integer) (WriterContext *wctx, const char *, long long int);
480  void (*print_rational) (WriterContext *wctx, AVRational *q, char *sep);
481  void (*print_string) (WriterContext *wctx, const char *, const char *);
482  int flags; ///< a combination or WRITER_FLAG_*
483 } Writer;
484 
485 #define SECTION_MAX_NB_LEVELS 10
486 
488  const AVClass *class; ///< class of the writer
489  const Writer *writer; ///< the Writer of which this is an instance
490  AVIOContext *avio; ///< the I/O context used to write
491 
492  void (* writer_w8)(WriterContext *wctx, int b);
493  void (* writer_put_str)(WriterContext *wctx, const char *str);
494  void (* writer_printf)(WriterContext *wctx, const char *fmt, ...);
495 
496  char *name; ///< name of this writer instance
497  void *priv; ///< private data for use by the filter
498 
499  const struct section *sections; ///< array containing all sections
500  int nb_sections; ///< number of sections
501 
502  int level; ///< current level, starting from 0
503 
504  /** number of the item printed in the given section, starting from 0 */
506 
507  /** section per each level */
509  AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]; ///< generic print buffer dedicated to each section,
510  /// used by various writers
511 
512  unsigned int nb_section_packet; ///< number of the packet section in case we are in "packets_and_frames" section
513  unsigned int nb_section_frame; ///< number of the frame section in case we are in "packets_and_frames" section
514  unsigned int nb_section_packet_frame; ///< nb_section_packet or nb_section_frame according if is_packets_and_frames
515 
519 };
520 
521 static const char *writer_get_name(void *p)
522 {
523  WriterContext *wctx = p;
524  return wctx->writer->name;
525 }
526 
527 #define OFFSET(x) offsetof(WriterContext, x)
528 
529 static const AVOption writer_options[] = {
530  { "string_validation", "set string validation mode",
531  OFFSET(string_validation), AV_OPT_TYPE_INT, {.i64=WRITER_STRING_VALIDATION_REPLACE}, 0, WRITER_STRING_VALIDATION_NB-1, .unit = "sv" },
532  { "sv", "set string validation mode",
533  OFFSET(string_validation), AV_OPT_TYPE_INT, {.i64=WRITER_STRING_VALIDATION_REPLACE}, 0, WRITER_STRING_VALIDATION_NB-1, .unit = "sv" },
534  { "ignore", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = WRITER_STRING_VALIDATION_IGNORE}, .unit = "sv" },
535  { "replace", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = WRITER_STRING_VALIDATION_REPLACE}, .unit = "sv" },
536  { "fail", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = WRITER_STRING_VALIDATION_FAIL}, .unit = "sv" },
537  { "string_validation_replacement", "set string validation replacement string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, {.str=""}},
538  { "svr", "set string validation replacement string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, {.str="\xEF\xBF\xBD"}},
539  { NULL }
540 };
541 
542 static void *writer_child_next(void *obj, void *prev)
543 {
544  WriterContext *ctx = obj;
545  if (!prev && ctx->writer && ctx->writer->priv_class && ctx->priv)
546  return ctx->priv;
547  return NULL;
548 }
549 
550 static const AVClass writer_class = {
551  .class_name = "Writer",
552  .item_name = writer_get_name,
553  .option = writer_options,
554  .version = LIBAVUTIL_VERSION_INT,
555  .child_next = writer_child_next,
556 };
557 
558 static int writer_close(WriterContext **wctx)
559 {
560  int i;
561  int ret = 0;
562 
563  if (!*wctx)
564  return -1;
565 
566  if ((*wctx)->writer->uninit)
567  (*wctx)->writer->uninit(*wctx);
568  for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
569  av_bprint_finalize(&(*wctx)->section_pbuf[i], NULL);
570  if ((*wctx)->writer->priv_class)
571  av_opt_free((*wctx)->priv);
572  av_freep(&((*wctx)->priv));
573  av_opt_free(*wctx);
574  if ((*wctx)->avio) {
575  avio_flush((*wctx)->avio);
576  ret = avio_close((*wctx)->avio);
577  }
578  av_freep(wctx);
579  return ret;
580 }
581 
582 static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
583 {
584  int i;
585  av_bprintf(bp, "0X");
586  for (i = 0; i < ubuf_size; i++)
587  av_bprintf(bp, "%02X", ubuf[i]);
588 }
589 
590 static inline void writer_w8_avio(WriterContext *wctx, int b)
591 {
592  avio_w8(wctx->avio, b);
593 }
594 
595 static inline void writer_put_str_avio(WriterContext *wctx, const char *str)
596 {
597  avio_write(wctx->avio, str, strlen(str));
598 }
599 
600 static inline void writer_printf_avio(WriterContext *wctx, const char *fmt, ...)
601 {
602  va_list ap;
603 
604  va_start(ap, fmt);
605  avio_vprintf(wctx->avio, fmt, ap);
606  va_end(ap);
607 }
608 
609 static inline void writer_w8_printf(WriterContext *wctx, int b)
610 {
611  printf("%c", b);
612 }
613 
614 static inline void writer_put_str_printf(WriterContext *wctx, const char *str)
615 {
616  printf("%s", str);
617 }
618 
619 static inline void writer_printf_printf(WriterContext *wctx, const char *fmt, ...)
620 {
621  va_list ap;
622 
623  va_start(ap, fmt);
624  vprintf(fmt, ap);
625  va_end(ap);
626 }
627 
628 static int writer_open(WriterContext **wctx, const Writer *writer, const char *args,
629  const struct section *sections, int nb_sections, const char *output)
630 {
631  int i, ret = 0;
632 
633  if (!(*wctx = av_mallocz(sizeof(WriterContext)))) {
634  ret = AVERROR(ENOMEM);
635  goto fail;
636  }
637 
638  if (!((*wctx)->priv = av_mallocz(writer->priv_size))) {
639  ret = AVERROR(ENOMEM);
640  goto fail;
641  }
642 
643  (*wctx)->class = &writer_class;
644  (*wctx)->writer = writer;
645  (*wctx)->level = -1;
646  (*wctx)->sections = sections;
647  (*wctx)->nb_sections = nb_sections;
648 
649  av_opt_set_defaults(*wctx);
650 
651  if (writer->priv_class) {
652  void *priv_ctx = (*wctx)->priv;
653  *((const AVClass **)priv_ctx) = writer->priv_class;
654  av_opt_set_defaults(priv_ctx);
655  }
656 
657  /* convert options to dictionary */
658  if (args) {
660  const AVDictionaryEntry *opt = NULL;
661 
662  if ((ret = av_dict_parse_string(&opts, args, "=", ":", 0)) < 0) {
663  av_log(*wctx, AV_LOG_ERROR, "Failed to parse option string '%s' provided to writer context\n", args);
664  av_dict_free(&opts);
665  goto fail;
666  }
667 
668  while ((opt = av_dict_iterate(opts, opt))) {
669  if ((ret = av_opt_set(*wctx, opt->key, opt->value, AV_OPT_SEARCH_CHILDREN)) < 0) {
670  av_log(*wctx, AV_LOG_ERROR, "Failed to set option '%s' with value '%s' provided to writer context\n",
671  opt->key, opt->value);
672  av_dict_free(&opts);
673  goto fail;
674  }
675  }
676 
677  av_dict_free(&opts);
678  }
679 
680  /* validate replace string */
681  {
682  const uint8_t *p = (*wctx)->string_validation_replacement;
683  const uint8_t *endp = p + strlen(p);
684  while (*p) {
685  const uint8_t *p0 = p;
686  int32_t code;
687  ret = av_utf8_decode(&code, &p, endp, (*wctx)->string_validation_utf8_flags);
688  if (ret < 0) {
689  AVBPrint bp;
691  bprint_bytes(&bp, p0, p-p0),
692  av_log(wctx, AV_LOG_ERROR,
693  "Invalid UTF8 sequence %s found in string validation replace '%s'\n",
694  bp.str, (*wctx)->string_validation_replacement);
695  return ret;
696  }
697  }
698  }
699 
700  if (!output_filename) {
701  (*wctx)->writer_w8 = writer_w8_printf;
702  (*wctx)->writer_put_str = writer_put_str_printf;
703  (*wctx)->writer_printf = writer_printf_printf;
704  } else {
705  if ((ret = avio_open(&(*wctx)->avio, output, AVIO_FLAG_WRITE)) < 0) {
706  av_log(*wctx, AV_LOG_ERROR,
707  "Failed to open output '%s' with error: %s\n", output, av_err2str(ret));
708  goto fail;
709  }
710  (*wctx)->writer_w8 = writer_w8_avio;
711  (*wctx)->writer_put_str = writer_put_str_avio;
712  (*wctx)->writer_printf = writer_printf_avio;
713  }
714 
715  for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
716  av_bprint_init(&(*wctx)->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED);
717 
718  if ((*wctx)->writer->init)
719  ret = (*wctx)->writer->init(*wctx);
720  if (ret < 0)
721  goto fail;
722 
723  return 0;
724 
725 fail:
726  writer_close(wctx);
727  return ret;
728 }
729 
731  void *data,
732  int section_id)
733 {
734  int parent_section_id;
735  wctx->level++;
737  parent_section_id = wctx->level ?
738  (wctx->section[wctx->level-1])->id : SECTION_ID_NONE;
739 
740  wctx->nb_item[wctx->level] = 0;
741  wctx->section[wctx->level] = &wctx->sections[section_id];
742 
743  if (section_id == SECTION_ID_PACKETS_AND_FRAMES) {
744  wctx->nb_section_packet = wctx->nb_section_frame =
745  wctx->nb_section_packet_frame = 0;
746  } else if (parent_section_id == SECTION_ID_PACKETS_AND_FRAMES) {
747  wctx->nb_section_packet_frame = section_id == SECTION_ID_PACKET ?
748  wctx->nb_section_packet : wctx->nb_section_frame;
749  }
750 
751  if (wctx->writer->print_section_header)
752  wctx->writer->print_section_header(wctx, data);
753 }
754 
756 {
757  int section_id = wctx->section[wctx->level]->id;
758  int parent_section_id = wctx->level ?
759  wctx->section[wctx->level-1]->id : SECTION_ID_NONE;
760 
761  if (parent_section_id != SECTION_ID_NONE)
762  wctx->nb_item[wctx->level-1]++;
763  if (parent_section_id == SECTION_ID_PACKETS_AND_FRAMES) {
764  if (section_id == SECTION_ID_PACKET) wctx->nb_section_packet++;
765  else wctx->nb_section_frame++;
766  }
767  if (wctx->writer->print_section_footer)
768  wctx->writer->print_section_footer(wctx);
769  wctx->level--;
770 }
771 
772 static inline void writer_print_integer(WriterContext *wctx,
773  const char *key, long long int val)
774 {
775  const struct section *section = wctx->section[wctx->level];
776 
778  wctx->writer->print_integer(wctx, key, val);
779  wctx->nb_item[wctx->level]++;
780  }
781 }
782 
783 static inline int validate_string(WriterContext *wctx, char **dstp, const char *src)
784 {
785  const uint8_t *p, *endp;
786  AVBPrint dstbuf;
787  int invalid_chars_nb = 0, ret = 0;
788 
790 
791  endp = src + strlen(src);
792  for (p = (uint8_t *)src; *p;) {
793  uint32_t code;
794  int invalid = 0;
795  const uint8_t *p0 = p;
796 
797  if (av_utf8_decode(&code, &p, endp, wctx->string_validation_utf8_flags) < 0) {
798  AVBPrint bp;
800  bprint_bytes(&bp, p0, p-p0);
801  av_log(wctx, AV_LOG_DEBUG,
802  "Invalid UTF-8 sequence %s found in string '%s'\n", bp.str, src);
803  invalid = 1;
804  }
805 
806  if (invalid) {
807  invalid_chars_nb++;
808 
809  switch (wctx->string_validation) {
811  av_log(wctx, AV_LOG_ERROR,
812  "Invalid UTF-8 sequence found in string '%s'\n", src);
814  goto end;
815  break;
816 
818  av_bprintf(&dstbuf, "%s", wctx->string_validation_replacement);
819  break;
820  }
821  }
822 
823  if (!invalid || wctx->string_validation == WRITER_STRING_VALIDATION_IGNORE)
824  av_bprint_append_data(&dstbuf, p0, p-p0);
825  }
826 
827  if (invalid_chars_nb && wctx->string_validation == WRITER_STRING_VALIDATION_REPLACE) {
828  av_log(wctx, AV_LOG_WARNING,
829  "%d invalid UTF-8 sequence(s) found in string '%s', replaced with '%s'\n",
830  invalid_chars_nb, src, wctx->string_validation_replacement);
831  }
832 
833 end:
834  av_bprint_finalize(&dstbuf, dstp);
835  return ret;
836 }
837 
838 #define PRINT_STRING_OPT 1
839 #define PRINT_STRING_VALIDATE 2
840 
841 static inline int writer_print_string(WriterContext *wctx,
842  const char *key, const char *val, int flags)
843 {
844  const struct section *section = wctx->section[wctx->level];
845  int ret = 0;
846 
849  && (flags & PRINT_STRING_OPT)
851  return 0;
852 
855  char *key1 = NULL, *val1 = NULL;
856  ret = validate_string(wctx, &key1, key);
857  if (ret < 0) goto end;
858  ret = validate_string(wctx, &val1, val);
859  if (ret < 0) goto end;
860  wctx->writer->print_string(wctx, key1, val1);
861  end:
862  if (ret < 0) {
863  av_log(wctx, AV_LOG_ERROR,
864  "Invalid key=value string combination %s=%s in section %s\n",
866  }
867  av_free(key1);
868  av_free(val1);
869  } else {
870  wctx->writer->print_string(wctx, key, val);
871  }
872 
873  wctx->nb_item[wctx->level]++;
874  }
875 
876  return ret;
877 }
878 
879 static inline void writer_print_rational(WriterContext *wctx,
880  const char *key, AVRational q, char sep)
881 {
882  AVBPrint buf;
884  av_bprintf(&buf, "%d%c%d", q.num, sep, q.den);
885  writer_print_string(wctx, key, buf.str, 0);
886 }
887 
888 static void writer_print_time(WriterContext *wctx, const char *key,
889  int64_t ts, const AVRational *time_base, int is_duration)
890 {
891  char buf[128];
892 
893  if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
895  } else {
896  double d = ts * av_q2d(*time_base);
897  struct unit_value uv;
898  uv.val.d = d;
899  uv.unit = unit_second_str;
900  value_string(buf, sizeof(buf), uv);
901  writer_print_string(wctx, key, buf, 0);
902  }
903 }
904 
905 static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, int is_duration)
906 {
907  if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
909  } else {
910  writer_print_integer(wctx, key, ts);
911  }
912 }
913 
914 static void writer_print_data(WriterContext *wctx, const char *name,
915  const uint8_t *data, int size)
916 {
917  AVBPrint bp;
918  int offset = 0, l, i;
919 
921  av_bprintf(&bp, "\n");
922  while (size) {
923  av_bprintf(&bp, "%08x: ", offset);
924  l = FFMIN(size, 16);
925  for (i = 0; i < l; i++) {
926  av_bprintf(&bp, "%02x", data[i]);
927  if (i & 1)
928  av_bprintf(&bp, " ");
929  }
930  av_bprint_chars(&bp, ' ', 41 - 2 * i - i / 2);
931  for (i = 0; i < l; i++)
932  av_bprint_chars(&bp, data[i] - 32U < 95 ? data[i] : '.', 1);
933  av_bprintf(&bp, "\n");
934  offset += l;
935  data += l;
936  size -= l;
937  }
938  writer_print_string(wctx, name, bp.str, 0);
939  av_bprint_finalize(&bp, NULL);
940 }
941 
942 static void writer_print_data_hash(WriterContext *wctx, const char *name,
943  const uint8_t *data, int size)
944 {
945  char *p, buf[AV_HASH_MAX_SIZE * 2 + 64] = { 0 };
946 
947  if (!hash)
948  return;
951  snprintf(buf, sizeof(buf), "%s:", av_hash_get_name(hash));
952  p = buf + strlen(buf);
953  av_hash_final_hex(hash, p, buf + sizeof(buf) - p);
954  writer_print_string(wctx, name, buf, 0);
955 }
956 
957 static void writer_print_integers(WriterContext *wctx, const char *name,
958  uint8_t *data, int size, const char *format,
959  int columns, int bytes, int offset_add)
960 {
961  AVBPrint bp;
962  int offset = 0, l, i;
963 
965  av_bprintf(&bp, "\n");
966  while (size) {
967  av_bprintf(&bp, "%08x: ", offset);
968  l = FFMIN(size, columns);
969  for (i = 0; i < l; i++) {
970  if (bytes == 1) av_bprintf(&bp, format, *data);
971  else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
972  else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
973  data += bytes;
974  size --;
975  }
976  av_bprintf(&bp, "\n");
977  offset += offset_add;
978  }
979  writer_print_string(wctx, name, bp.str, 0);
980  av_bprint_finalize(&bp, NULL);
981 }
982 
983 #define writer_w8(wctx_, b_) (wctx_)->writer_w8(wctx_, b_)
984 #define writer_put_str(wctx_, str_) (wctx_)->writer_put_str(wctx_, str_)
985 #define writer_printf(wctx_, fmt_, ...) (wctx_)->writer_printf(wctx_, fmt_, __VA_ARGS__)
986 
987 #define MAX_REGISTERED_WRITERS_NB 64
988 
990 
991 static int writer_register(const Writer *writer)
992 {
993  static int next_registered_writer_idx = 0;
994 
995  if (next_registered_writer_idx == MAX_REGISTERED_WRITERS_NB)
996  return AVERROR(ENOMEM);
997 
998  registered_writers[next_registered_writer_idx++] = writer;
999  return 0;
1000 }
1001 
1002 static const Writer *writer_get_by_name(const char *name)
1003 {
1004  int i;
1005 
1006  for (i = 0; registered_writers[i]; i++)
1007  if (!strcmp(registered_writers[i]->name, name))
1008  return registered_writers[i];
1009 
1010  return NULL;
1011 }
1012 
1013 
1014 /* WRITERS */
1015 
1016 #define DEFINE_WRITER_CLASS(name) \
1017 static const char *name##_get_name(void *ctx) \
1018 { \
1019  return #name ; \
1020 } \
1021 static const AVClass name##_class = { \
1022  .class_name = #name, \
1023  .item_name = name##_get_name, \
1024  .option = name##_options \
1025 }
1026 
1027 /* Default output */
1028 
1029 typedef struct DefaultContext {
1030  const AVClass *class;
1031  int nokey;
1034 } DefaultContext;
1035 
1036 #undef OFFSET
1037 #define OFFSET(x) offsetof(DefaultContext, x)
1038 
1039 static const AVOption default_options[] = {
1040  { "noprint_wrappers", "do not print headers and footers", OFFSET(noprint_wrappers), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1041  { "nw", "do not print headers and footers", OFFSET(noprint_wrappers), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1042  { "nokey", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1043  { "nk", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1044  {NULL},
1045 };
1046 
1047 DEFINE_WRITER_CLASS(default);
1048 
1049 /* lame uppercasing routine, assumes the string is lower case ASCII */
1050 static inline char *upcase_string(char *dst, size_t dst_size, const char *src)
1051 {
1052  int i;
1053  for (i = 0; src[i] && i < dst_size-1; i++)
1054  dst[i] = av_toupper(src[i]);
1055  dst[i] = 0;
1056  return dst;
1057 }
1058 
1060 {
1061  DefaultContext *def = wctx->priv;
1062  char buf[32];
1063  const struct section *section = wctx->section[wctx->level];
1064  const struct section *parent_section = wctx->level ?
1065  wctx->section[wctx->level-1] : NULL;
1066 
1067  av_bprint_clear(&wctx->section_pbuf[wctx->level]);
1068  if (parent_section &&
1069  !(parent_section->flags & (SECTION_FLAG_IS_WRAPPER|SECTION_FLAG_IS_ARRAY))) {
1070  def->nested_section[wctx->level] = 1;
1071  av_bprintf(&wctx->section_pbuf[wctx->level], "%s%s:",
1072  wctx->section_pbuf[wctx->level-1].str,
1073  upcase_string(buf, sizeof(buf),
1075  }
1076 
1077  if (def->noprint_wrappers || def->nested_section[wctx->level])
1078  return;
1079 
1081  writer_printf(wctx, "[%s]\n", upcase_string(buf, sizeof(buf), section->name));
1082 }
1083 
1085 {
1086  DefaultContext *def = wctx->priv;
1087  const struct section *section = wctx->section[wctx->level];
1088  char buf[32];
1089 
1090  if (def->noprint_wrappers || def->nested_section[wctx->level])
1091  return;
1092 
1094  writer_printf(wctx, "[/%s]\n", upcase_string(buf, sizeof(buf), section->name));
1095 }
1096 
1097 static void default_print_str(WriterContext *wctx, const char *key, const char *value)
1098 {
1099  DefaultContext *def = wctx->priv;
1100 
1101  if (!def->nokey)
1102  writer_printf(wctx, "%s%s=", wctx->section_pbuf[wctx->level].str, key);
1103  writer_printf(wctx, "%s\n", value);
1104 }
1105 
1106 static void default_print_int(WriterContext *wctx, const char *key, long long int value)
1107 {
1108  DefaultContext *def = wctx->priv;
1109 
1110  if (!def->nokey)
1111  writer_printf(wctx, "%s%s=", wctx->section_pbuf[wctx->level].str, key);
1112  writer_printf(wctx, "%lld\n", value);
1113 }
1114 
1115 static const Writer default_writer = {
1116  .name = "default",
1117  .priv_size = sizeof(DefaultContext),
1120  .print_integer = default_print_int,
1121  .print_string = default_print_str,
1123  .priv_class = &default_class,
1124 };
1125 
1126 /* Compact output */
1127 
1128 /**
1129  * Apply C-language-like string escaping.
1130  */
1131 static const char *c_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
1132 {
1133  const char *p;
1134 
1135  for (p = src; *p; p++) {
1136  switch (*p) {
1137  case '\b': av_bprintf(dst, "%s", "\\b"); break;
1138  case '\f': av_bprintf(dst, "%s", "\\f"); break;
1139  case '\n': av_bprintf(dst, "%s", "\\n"); break;
1140  case '\r': av_bprintf(dst, "%s", "\\r"); break;
1141  case '\\': av_bprintf(dst, "%s", "\\\\"); break;
1142  default:
1143  if (*p == sep)
1144  av_bprint_chars(dst, '\\', 1);
1145  av_bprint_chars(dst, *p, 1);
1146  }
1147  }
1148  return dst->str;
1149 }
1150 
1151 /**
1152  * Quote fields containing special characters, check RFC4180.
1153  */
1154 static const char *csv_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
1155 {
1156  char meta_chars[] = { sep, '"', '\n', '\r', '\0' };
1157  int needs_quoting = !!src[strcspn(src, meta_chars)];
1158 
1159  if (needs_quoting)
1160  av_bprint_chars(dst, '"', 1);
1161 
1162  for (; *src; src++) {
1163  if (*src == '"')
1164  av_bprint_chars(dst, '"', 1);
1165  av_bprint_chars(dst, *src, 1);
1166  }
1167  if (needs_quoting)
1168  av_bprint_chars(dst, '"', 1);
1169  return dst->str;
1170 }
1171 
1172 static const char *none_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
1173 {
1174  return src;
1175 }
1176 
1177 typedef struct CompactContext {
1178  const AVClass *class;
1180  char item_sep;
1181  int nokey;
1184  const char * (*escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx);
1188 } CompactContext;
1189 
1190 #undef OFFSET
1191 #define OFFSET(x) offsetof(CompactContext, x)
1192 
1193 static const AVOption compact_options[]= {
1194  {"item_sep", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str="|"}, 0, 0 },
1195  {"s", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str="|"}, 0, 0 },
1196  {"nokey", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1197  {"nk", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1198  {"escape", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="c"}, 0, 0 },
1199  {"e", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="c"}, 0, 0 },
1200  {"print_section", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1201  {"p", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1202  {NULL},
1203 };
1204 
1205 DEFINE_WRITER_CLASS(compact);
1206 
1208 {
1209  CompactContext *compact = wctx->priv;
1210 
1211  if (strlen(compact->item_sep_str) != 1) {
1212  av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n",
1213  compact->item_sep_str);
1214  return AVERROR(EINVAL);
1215  }
1216  compact->item_sep = compact->item_sep_str[0];
1217 
1218  if (!strcmp(compact->escape_mode_str, "none")) compact->escape_str = none_escape_str;
1219  else if (!strcmp(compact->escape_mode_str, "c" )) compact->escape_str = c_escape_str;
1220  else if (!strcmp(compact->escape_mode_str, "csv" )) compact->escape_str = csv_escape_str;
1221  else {
1222  av_log(wctx, AV_LOG_ERROR, "Unknown escape mode '%s'\n", compact->escape_mode_str);
1223  return AVERROR(EINVAL);
1224  }
1225 
1226  return 0;
1227 }
1228 
1230 {
1231  CompactContext *compact = wctx->priv;
1232  const struct section *section = wctx->section[wctx->level];
1233  const struct section *parent_section = wctx->level ?
1234  wctx->section[wctx->level-1] : NULL;
1235  compact->terminate_line[wctx->level] = 1;
1236  compact->has_nested_elems[wctx->level] = 0;
1237 
1238  av_bprint_clear(&wctx->section_pbuf[wctx->level]);
1239  if (parent_section &&
1242  !(parent_section->flags & (SECTION_FLAG_IS_WRAPPER|SECTION_FLAG_IS_ARRAY))))) {
1243 
1244  /* define a prefix for elements not contained in an array or
1245  in a wrapper, or for array elements with a type */
1246  const char *element_name = (char *)av_x_if_null(section->element_name, section->name);
1247  AVBPrint *section_pbuf = &wctx->section_pbuf[wctx->level];
1248 
1249  compact->nested_section[wctx->level] = 1;
1250  compact->has_nested_elems[wctx->level-1] = 1;
1251 
1252  av_bprintf(section_pbuf, "%s%s",
1253  wctx->section_pbuf[wctx->level-1].str, element_name);
1254 
1256  // add /TYPE to prefix
1257  av_bprint_chars(section_pbuf, '/', 1);
1258 
1259  // normalize section type, replace special characters and lower case
1260  for (const char *p = section->get_type(data); *p; p++) {
1261  char c =
1262  (*p >= '0' && *p <= '9') ||
1263  (*p >= 'a' && *p <= 'z') ||
1264  (*p >= 'A' && *p <= 'Z') ? av_tolower(*p) : '_';
1265  av_bprint_chars(section_pbuf, c, 1);
1266  }
1267  }
1268  av_bprint_chars(section_pbuf, ':', 1);
1269 
1270  wctx->nb_item[wctx->level] = wctx->nb_item[wctx->level-1];
1271  } else {
1272  if (parent_section && !(parent_section->flags & (SECTION_FLAG_IS_WRAPPER|SECTION_FLAG_IS_ARRAY)) &&
1273  wctx->level && wctx->nb_item[wctx->level-1])
1274  writer_w8(wctx, compact->item_sep);
1275  if (compact->print_section &&
1277  writer_printf(wctx, "%s%c", section->name, compact->item_sep);
1278  }
1279 }
1280 
1282 {
1283  CompactContext *compact = wctx->priv;
1284 
1285  if (!compact->nested_section[wctx->level] &&
1286  compact->terminate_line[wctx->level] &&
1288  writer_w8(wctx, '\n');
1289 }
1290 
1291 static void compact_print_str(WriterContext *wctx, const char *key, const char *value)
1292 {
1293  CompactContext *compact = wctx->priv;
1294  AVBPrint buf;
1295 
1296  if (wctx->nb_item[wctx->level]) writer_w8(wctx, compact->item_sep);
1297  if (!compact->nokey)
1298  writer_printf(wctx, "%s%s=", wctx->section_pbuf[wctx->level].str, key);
1300  writer_put_str(wctx, compact->escape_str(&buf, value, compact->item_sep, wctx));
1301  av_bprint_finalize(&buf, NULL);
1302 }
1303 
1304 static void compact_print_int(WriterContext *wctx, const char *key, long long int value)
1305 {
1306  CompactContext *compact = wctx->priv;
1307 
1308  if (wctx->nb_item[wctx->level]) writer_w8(wctx, compact->item_sep);
1309  if (!compact->nokey)
1310  writer_printf(wctx, "%s%s=", wctx->section_pbuf[wctx->level].str, key);
1311  writer_printf(wctx, "%lld", value);
1312 }
1313 
1314 static const Writer compact_writer = {
1315  .name = "compact",
1316  .priv_size = sizeof(CompactContext),
1317  .init = compact_init,
1320  .print_integer = compact_print_int,
1321  .print_string = compact_print_str,
1323  .priv_class = &compact_class,
1324 };
1325 
1326 /* CSV output */
1327 
1328 #undef OFFSET
1329 #define OFFSET(x) offsetof(CompactContext, x)
1330 
1331 static const AVOption csv_options[] = {
1332  {"item_sep", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str=","}, 0, 0 },
1333  {"s", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str=","}, 0, 0 },
1334  {"nokey", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1335  {"nk", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1336  {"escape", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="csv"}, 0, 0 },
1337  {"e", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="csv"}, 0, 0 },
1338  {"print_section", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1339  {"p", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1340  {NULL},
1341 };
1342 
1343 DEFINE_WRITER_CLASS(csv);
1344 
1345 static const Writer csv_writer = {
1346  .name = "csv",
1347  .priv_size = sizeof(CompactContext),
1348  .init = compact_init,
1351  .print_integer = compact_print_int,
1352  .print_string = compact_print_str,
1354  .priv_class = &csv_class,
1355 };
1356 
1357 /* Flat output */
1358 
1359 typedef struct FlatContext {
1360  const AVClass *class;
1361  const char *sep_str;
1362  char sep;
1364 } FlatContext;
1365 
1366 #undef OFFSET
1367 #define OFFSET(x) offsetof(FlatContext, x)
1368 
1369 static const AVOption flat_options[]= {
1370  {"sep_char", "set separator", OFFSET(sep_str), AV_OPT_TYPE_STRING, {.str="."}, 0, 0 },
1371  {"s", "set separator", OFFSET(sep_str), AV_OPT_TYPE_STRING, {.str="."}, 0, 0 },
1372  {"hierarchical", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1373  {"h", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1374  {NULL},
1375 };
1376 
1378 
1380 {
1381  FlatContext *flat = wctx->priv;
1382 
1383  if (strlen(flat->sep_str) != 1) {
1384  av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n",
1385  flat->sep_str);
1386  return AVERROR(EINVAL);
1387  }
1388  flat->sep = flat->sep_str[0];
1389 
1390  return 0;
1391 }
1392 
1393 static const char *flat_escape_key_str(AVBPrint *dst, const char *src, const char sep)
1394 {
1395  const char *p;
1396 
1397  for (p = src; *p; p++) {
1398  if (!((*p >= '0' && *p <= '9') ||
1399  (*p >= 'a' && *p <= 'z') ||
1400  (*p >= 'A' && *p <= 'Z')))
1401  av_bprint_chars(dst, '_', 1);
1402  else
1403  av_bprint_chars(dst, *p, 1);
1404  }
1405  return dst->str;
1406 }
1407 
1408 static const char *flat_escape_value_str(AVBPrint *dst, const char *src)
1409 {
1410  const char *p;
1411 
1412  for (p = src; *p; p++) {
1413  switch (*p) {
1414  case '\n': av_bprintf(dst, "%s", "\\n"); break;
1415  case '\r': av_bprintf(dst, "%s", "\\r"); break;
1416  case '\\': av_bprintf(dst, "%s", "\\\\"); break;
1417  case '"': av_bprintf(dst, "%s", "\\\""); break;
1418  case '`': av_bprintf(dst, "%s", "\\`"); break;
1419  case '$': av_bprintf(dst, "%s", "\\$"); break;
1420  default: av_bprint_chars(dst, *p, 1); break;
1421  }
1422  }
1423  return dst->str;
1424 }
1425 
1427 {
1428  FlatContext *flat = wctx->priv;
1429  AVBPrint *buf = &wctx->section_pbuf[wctx->level];
1430  const struct section *section = wctx->section[wctx->level];
1431  const struct section *parent_section = wctx->level ?
1432  wctx->section[wctx->level-1] : NULL;
1433 
1434  /* build section header */
1435  av_bprint_clear(buf);
1436  if (!parent_section)
1437  return;
1438  av_bprintf(buf, "%s", wctx->section_pbuf[wctx->level-1].str);
1439 
1440  if (flat->hierarchical ||
1442  av_bprintf(buf, "%s%s", wctx->section[wctx->level]->name, flat->sep_str);
1443 
1444  if (parent_section->flags & SECTION_FLAG_IS_ARRAY) {
1445  int n = parent_section->id == SECTION_ID_PACKETS_AND_FRAMES ?
1446  wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1];
1447  av_bprintf(buf, "%d%s", n, flat->sep_str);
1448  }
1449  }
1450 }
1451 
1452 static void flat_print_int(WriterContext *wctx, const char *key, long long int value)
1453 {
1454  writer_printf(wctx, "%s%s=%lld\n", wctx->section_pbuf[wctx->level].str, key, value);
1455 }
1456 
1457 static void flat_print_str(WriterContext *wctx, const char *key, const char *value)
1458 {
1459  FlatContext *flat = wctx->priv;
1460  AVBPrint buf;
1461 
1462  writer_put_str(wctx, wctx->section_pbuf[wctx->level].str);
1464  writer_printf(wctx, "%s=", flat_escape_key_str(&buf, key, flat->sep));
1465  av_bprint_clear(&buf);
1466  writer_printf(wctx, "\"%s\"\n", flat_escape_value_str(&buf, value));
1467  av_bprint_finalize(&buf, NULL);
1468 }
1469 
1470 static const Writer flat_writer = {
1471  .name = "flat",
1472  .priv_size = sizeof(FlatContext),
1473  .init = flat_init,
1475  .print_integer = flat_print_int,
1476  .print_string = flat_print_str,
1478  .priv_class = &flat_class,
1479 };
1480 
1481 /* INI format output */
1482 
1483 typedef struct INIContext {
1484  const AVClass *class;
1486 } INIContext;
1487 
1488 #undef OFFSET
1489 #define OFFSET(x) offsetof(INIContext, x)
1490 
1491 static const AVOption ini_options[] = {
1492  {"hierarchical", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1493  {"h", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1494  {NULL},
1495 };
1496 
1497 DEFINE_WRITER_CLASS(ini);
1498 
1499 static char *ini_escape_str(AVBPrint *dst, const char *src)
1500 {
1501  int i = 0;
1502  char c = 0;
1503 
1504  while (c = src[i++]) {
1505  switch (c) {
1506  case '\b': av_bprintf(dst, "%s", "\\b"); break;
1507  case '\f': av_bprintf(dst, "%s", "\\f"); break;
1508  case '\n': av_bprintf(dst, "%s", "\\n"); break;
1509  case '\r': av_bprintf(dst, "%s", "\\r"); break;
1510  case '\t': av_bprintf(dst, "%s", "\\t"); break;
1511  case '\\':
1512  case '#' :
1513  case '=' :
1514  case ':' : av_bprint_chars(dst, '\\', 1);
1515  default:
1516  if ((unsigned char)c < 32)
1517  av_bprintf(dst, "\\x00%02x", c & 0xff);
1518  else
1519  av_bprint_chars(dst, c, 1);
1520  break;
1521  }
1522  }
1523  return dst->str;
1524 }
1525 
1527 {
1528  INIContext *ini = wctx->priv;
1529  AVBPrint *buf = &wctx->section_pbuf[wctx->level];
1530  const struct section *section = wctx->section[wctx->level];
1531  const struct section *parent_section = wctx->level ?
1532  wctx->section[wctx->level-1] : NULL;
1533 
1534  av_bprint_clear(buf);
1535  if (!parent_section) {
1536  writer_put_str(wctx, "# ffprobe output\n\n");
1537  return;
1538  }
1539 
1540  if (wctx->nb_item[wctx->level-1])
1541  writer_w8(wctx, '\n');
1542 
1543  av_bprintf(buf, "%s", wctx->section_pbuf[wctx->level-1].str);
1544  if (ini->hierarchical ||
1546  av_bprintf(buf, "%s%s", buf->str[0] ? "." : "", wctx->section[wctx->level]->name);
1547 
1548  if (parent_section->flags & SECTION_FLAG_IS_ARRAY) {
1549  int n = parent_section->id == SECTION_ID_PACKETS_AND_FRAMES ?
1550  wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1];
1551  av_bprintf(buf, ".%d", n);
1552  }
1553  }
1554 
1556  writer_printf(wctx, "[%s]\n", buf->str);
1557 }
1558 
1559 static void ini_print_str(WriterContext *wctx, const char *key, const char *value)
1560 {
1561  AVBPrint buf;
1562 
1564  writer_printf(wctx, "%s=", ini_escape_str(&buf, key));
1565  av_bprint_clear(&buf);
1566  writer_printf(wctx, "%s\n", ini_escape_str(&buf, value));
1567  av_bprint_finalize(&buf, NULL);
1568 }
1569 
1570 static void ini_print_int(WriterContext *wctx, const char *key, long long int value)
1571 {
1572  writer_printf(wctx, "%s=%lld\n", key, value);
1573 }
1574 
1575 static const Writer ini_writer = {
1576  .name = "ini",
1577  .priv_size = sizeof(INIContext),
1579  .print_integer = ini_print_int,
1580  .print_string = ini_print_str,
1582  .priv_class = &ini_class,
1583 };
1584 
1585 /* JSON output */
1586 
1587 typedef struct JSONContext {
1588  const AVClass *class;
1590  int compact;
1591  const char *item_sep, *item_start_end;
1592 } JSONContext;
1593 
1594 #undef OFFSET
1595 #define OFFSET(x) offsetof(JSONContext, x)
1596 
1597 static const AVOption json_options[]= {
1598  { "compact", "enable compact output", OFFSET(compact), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1599  { "c", "enable compact output", OFFSET(compact), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1600  { NULL }
1601 };
1602 
1603 DEFINE_WRITER_CLASS(json);
1604 
1606 {
1607  JSONContext *json = wctx->priv;
1608 
1609  json->item_sep = json->compact ? ", " : ",\n";
1610  json->item_start_end = json->compact ? " " : "\n";
1611 
1612  return 0;
1613 }
1614 
1615 static const char *json_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
1616 {
1617  static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};
1618  static const char json_subst[] = {'"', '\\', 'b', 'f', 'n', 'r', 't', 0};
1619  const char *p;
1620 
1621  for (p = src; *p; p++) {
1622  char *s = strchr(json_escape, *p);
1623  if (s) {
1624  av_bprint_chars(dst, '\\', 1);
1625  av_bprint_chars(dst, json_subst[s - json_escape], 1);
1626  } else if ((unsigned char)*p < 32) {
1627  av_bprintf(dst, "\\u00%02x", *p & 0xff);
1628  } else {
1629  av_bprint_chars(dst, *p, 1);
1630  }
1631  }
1632  return dst->str;
1633 }
1634 
1635 #define JSON_INDENT() writer_printf(wctx, "%*c", json->indent_level * 4, ' ')
1636 
1638 {
1639  JSONContext *json = wctx->priv;
1640  AVBPrint buf;
1641  const struct section *section = wctx->section[wctx->level];
1642  const struct section *parent_section = wctx->level ?
1643  wctx->section[wctx->level-1] : NULL;
1644 
1645  if (wctx->level && wctx->nb_item[wctx->level-1])
1646  writer_put_str(wctx, ",\n");
1647 
1649  writer_put_str(wctx, "{\n");
1650  json->indent_level++;
1651  } else {
1653  json_escape_str(&buf, section->name, wctx);
1654  JSON_INDENT();
1655 
1656  json->indent_level++;
1658  writer_printf(wctx, "\"%s\": [\n", buf.str);
1659  } else if (parent_section && !(parent_section->flags & SECTION_FLAG_IS_ARRAY)) {
1660  writer_printf(wctx, "\"%s\": {%s", buf.str, json->item_start_end);
1661  } else {
1662  writer_printf(wctx, "{%s", json->item_start_end);
1663 
1664  /* this is required so the parser can distinguish between packets and frames */
1665  if (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES) {
1666  if (!json->compact)
1667  JSON_INDENT();
1668  writer_printf(wctx, "\"type\": \"%s\"", section->name);
1669  wctx->nb_item[wctx->level]++;
1670  }
1671  }
1672  av_bprint_finalize(&buf, NULL);
1673  }
1674 }
1675 
1677 {
1678  JSONContext *json = wctx->priv;
1679  const struct section *section = wctx->section[wctx->level];
1680 
1681  if (wctx->level == 0) {
1682  json->indent_level--;
1683  writer_put_str(wctx, "\n}\n");
1684  } else if (section->flags & SECTION_FLAG_IS_ARRAY) {
1685  writer_w8(wctx, '\n');
1686  json->indent_level--;
1687  JSON_INDENT();
1688  writer_w8(wctx, ']');
1689  } else {
1690  writer_put_str(wctx, json->item_start_end);
1691  json->indent_level--;
1692  if (!json->compact)
1693  JSON_INDENT();
1694  writer_w8(wctx, '}');
1695  }
1696 }
1697 
1698 static inline void json_print_item_str(WriterContext *wctx,
1699  const char *key, const char *value)
1700 {
1701  AVBPrint buf;
1702 
1704  writer_printf(wctx, "\"%s\":", json_escape_str(&buf, key, wctx));
1705  av_bprint_clear(&buf);
1706  writer_printf(wctx, " \"%s\"", json_escape_str(&buf, value, wctx));
1707  av_bprint_finalize(&buf, NULL);
1708 }
1709 
1710 static void json_print_str(WriterContext *wctx, const char *key, const char *value)
1711 {
1712  JSONContext *json = wctx->priv;
1713  const struct section *parent_section = wctx->level ?
1714  wctx->section[wctx->level-1] : NULL;
1715 
1716  if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES))
1717  writer_put_str(wctx, json->item_sep);
1718  if (!json->compact)
1719  JSON_INDENT();
1720  json_print_item_str(wctx, key, value);
1721 }
1722 
1723 static void json_print_int(WriterContext *wctx, const char *key, long long int value)
1724 {
1725  JSONContext *json = wctx->priv;
1726  const struct section *parent_section = wctx->level ?
1727  wctx->section[wctx->level-1] : NULL;
1728  AVBPrint buf;
1729 
1730  if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES))
1731  writer_put_str(wctx, json->item_sep);
1732  if (!json->compact)
1733  JSON_INDENT();
1734 
1736  writer_printf(wctx, "\"%s\": %lld", json_escape_str(&buf, key, wctx), value);
1737  av_bprint_finalize(&buf, NULL);
1738 }
1739 
1740 static const Writer json_writer = {
1741  .name = "json",
1742  .priv_size = sizeof(JSONContext),
1743  .init = json_init,
1746  .print_integer = json_print_int,
1747  .print_string = json_print_str,
1749  .priv_class = &json_class,
1750 };
1751 
1752 /* XML output */
1753 
1754 typedef struct XMLContext {
1755  const AVClass *class;
1760 } XMLContext;
1761 
1762 #undef OFFSET
1763 #define OFFSET(x) offsetof(XMLContext, x)
1764 
1765 static const AVOption xml_options[] = {
1766  {"fully_qualified", "specify if the output should be fully qualified", OFFSET(fully_qualified), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1767  {"q", "specify if the output should be fully qualified", OFFSET(fully_qualified), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1768  {"xsd_strict", "ensure that the output is XSD compliant", OFFSET(xsd_strict), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1769  {"x", "ensure that the output is XSD compliant", OFFSET(xsd_strict), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1770  {NULL},
1771 };
1772 
1773 DEFINE_WRITER_CLASS(xml);
1774 
1775 static av_cold int xml_init(WriterContext *wctx)
1776 {
1777  XMLContext *xml = wctx->priv;
1778 
1779  if (xml->xsd_strict) {
1780  xml->fully_qualified = 1;
1781 #define CHECK_COMPLIANCE(opt, opt_name) \
1782  if (opt) { \
1783  av_log(wctx, AV_LOG_ERROR, \
1784  "XSD-compliant output selected but option '%s' was selected, XML output may be non-compliant.\n" \
1785  "You need to disable such option with '-no%s'\n", opt_name, opt_name); \
1786  return AVERROR(EINVAL); \
1787  }
1788  CHECK_COMPLIANCE(show_private_data, "private");
1791  }
1792 
1793  return 0;
1794 }
1795 
1796 #define XML_INDENT() writer_printf(wctx, "%*c", xml->indent_level * 4, ' ')
1797 
1799 {
1800  XMLContext *xml = wctx->priv;
1801  const struct section *section = wctx->section[wctx->level];
1802  const struct section *parent_section = wctx->level ?
1803  wctx->section[wctx->level-1] : NULL;
1804 
1805  if (wctx->level == 0) {
1806  const char *qual = " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
1807  "xmlns:ffprobe=\"http://www.ffmpeg.org/schema/ffprobe\" "
1808  "xsi:schemaLocation=\"http://www.ffmpeg.org/schema/ffprobe ffprobe.xsd\"";
1809 
1810  writer_put_str(wctx, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
1811  writer_printf(wctx, "<%sffprobe%s>\n",
1812  xml->fully_qualified ? "ffprobe:" : "",
1813  xml->fully_qualified ? qual : "");
1814  return;
1815  }
1816 
1817  if (xml->within_tag) {
1818  xml->within_tag = 0;
1819  writer_put_str(wctx, ">\n");
1820  }
1821 
1822  if (parent_section && (parent_section->flags & SECTION_FLAG_IS_WRAPPER) &&
1823  wctx->level && wctx->nb_item[wctx->level-1])
1824  writer_w8(wctx, '\n');
1825  xml->indent_level++;
1826 
1828  XML_INDENT(); writer_printf(wctx, "<%s", section->name);
1829 
1831  AVBPrint buf;
1835  writer_printf(wctx, " type=\"%s\"", buf.str);
1836  }
1837  writer_printf(wctx, ">\n", section->name);
1838  } else {
1839  XML_INDENT(); writer_printf(wctx, "<%s ", section->name);
1840  xml->within_tag = 1;
1841  }
1842 }
1843 
1845 {
1846  XMLContext *xml = wctx->priv;
1847  const struct section *section = wctx->section[wctx->level];
1848 
1849  if (wctx->level == 0) {
1850  writer_printf(wctx, "</%sffprobe>\n", xml->fully_qualified ? "ffprobe:" : "");
1851  } else if (xml->within_tag) {
1852  xml->within_tag = 0;
1853  writer_put_str(wctx, "/>\n");
1854  xml->indent_level--;
1855  } else {
1856  XML_INDENT(); writer_printf(wctx, "</%s>\n", section->name);
1857  xml->indent_level--;
1858  }
1859 }
1860 
1861 static void xml_print_value(WriterContext *wctx, const char *key, const void *value, const int is_int)
1862 {
1863  AVBPrint buf;
1864  XMLContext *xml = wctx->priv;
1865  const struct section *section = wctx->section[wctx->level];
1866 
1868 
1870  xml->indent_level++;
1871  XML_INDENT();
1872  av_bprint_escape(&buf, key, NULL,
1874  writer_printf(wctx, "<%s key=\"%s\"",
1875  section->element_name, buf.str);
1876  av_bprint_clear(&buf);
1877 
1878  if (is_int) {
1879  writer_printf(wctx, " value=\"%lld\"/>\n", *(long long int *)value);
1880  } else {
1881  av_bprint_escape(&buf, (const char *)value, NULL,
1883  writer_printf(wctx, " value=\"%s\"/>\n", buf.str);
1884  }
1885  xml->indent_level--;
1886  } else {
1887  if (wctx->nb_item[wctx->level])
1888  writer_w8(wctx, ' ');
1889 
1890  if (is_int) {
1891  writer_printf(wctx, "%s=\"%lld\"", key, *(long long int *)value);
1892  } else {
1893  av_bprint_escape(&buf, (const char *)value, NULL,
1895  writer_printf(wctx, "%s=\"%s\"", key, buf.str);
1896  }
1897  }
1898 
1899  av_bprint_finalize(&buf, NULL);
1900 }
1901 
1902 static inline void xml_print_str(WriterContext *wctx, const char *key, const char *value) {
1903  xml_print_value(wctx, key, (const void *)value, 0);
1904 }
1905 
1906 static inline void xml_print_int(WriterContext *wctx, const char *key, long long int value) {
1907  xml_print_value(wctx, key, (const void *)&value, 1);
1908 }
1909 
1910 static Writer xml_writer = {
1911  .name = "xml",
1912  .priv_size = sizeof(XMLContext),
1913  .init = xml_init,
1916  .print_integer = xml_print_int,
1917  .print_string = xml_print_str,
1919  .priv_class = &xml_class,
1920 };
1921 
1922 static void writer_register_all(void)
1923 {
1924  static int initialized;
1925 
1926  if (initialized)
1927  return;
1928  initialized = 1;
1929 
1937 }
1938 
1939 #define print_fmt(k, f, ...) do { \
1940  av_bprint_clear(&pbuf); \
1941  av_bprintf(&pbuf, f, __VA_ARGS__); \
1942  writer_print_string(w, k, pbuf.str, 0); \
1943 } while (0)
1944 
1945 #define print_list_fmt(k, f, n, m, ...) do { \
1946  av_bprint_clear(&pbuf); \
1947  for (int idx = 0; idx < n; idx++) { \
1948  for (int idx2 = 0; idx2 < m; idx2++) { \
1949  if (idx > 0 || idx2 > 0) \
1950  av_bprint_chars(&pbuf, ' ', 1); \
1951  av_bprintf(&pbuf, f, __VA_ARGS__); \
1952  } \
1953  } \
1954  writer_print_string(w, k, pbuf.str, 0); \
1955 } while (0)
1956 
1957 #define print_int(k, v) writer_print_integer(w, k, v)
1958 #define print_q(k, v, s) writer_print_rational(w, k, v, s)
1959 #define print_str(k, v) writer_print_string(w, k, v, 0)
1960 #define print_str_opt(k, v) writer_print_string(w, k, v, PRINT_STRING_OPT)
1961 #define print_str_validate(k, v) writer_print_string(w, k, v, PRINT_STRING_VALIDATE)
1962 #define print_time(k, v, tb) writer_print_time(w, k, v, tb, 0)
1963 #define print_ts(k, v) writer_print_ts(w, k, v, 0)
1964 #define print_duration_time(k, v, tb) writer_print_time(w, k, v, tb, 1)
1965 #define print_duration_ts(k, v) writer_print_ts(w, k, v, 1)
1966 #define print_val(k, v, u) do { \
1967  struct unit_value uv; \
1968  uv.val.i = v; \
1969  uv.unit = u; \
1970  writer_print_string(w, k, value_string(val_str, sizeof(val_str), uv), 0); \
1971 } while (0)
1972 
1973 #define print_section_header(s) writer_print_section_header(w, NULL, s)
1974 #define print_section_header_data(s, d) writer_print_section_header(w, d, s)
1975 #define print_section_footer(s) writer_print_section_footer(w, s)
1976 
1977 #define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n) \
1978 { \
1979  ret = av_reallocp_array(&(ptr), (new_n), sizeof(*(ptr))); \
1980  if (ret < 0) \
1981  goto end; \
1982  memset( (ptr) + (cur_n), 0, ((new_n) - (cur_n)) * sizeof(*(ptr)) ); \
1983 }
1984 
1985 static inline int show_tags(WriterContext *w, AVDictionary *tags, int section_id)
1986 {
1987  const AVDictionaryEntry *tag = NULL;
1988  int ret = 0;
1989 
1990  if (!tags)
1991  return 0;
1992  writer_print_section_header(w, NULL, section_id);
1993 
1994  while ((tag = av_dict_iterate(tags, tag))) {
1995  if ((ret = print_str_validate(tag->key, tag->value)) < 0)
1996  break;
1997  }
1999 
2000  return ret;
2001 }
2002 
2004 {
2005  if (!dovi)
2006  return;
2007 
2008  {
2009  const AVDOVIRpuDataHeader *hdr = av_dovi_get_header(dovi);
2010  const AVDOVIDataMapping *mapping = av_dovi_get_mapping(dovi);
2012  AVBPrint pbuf;
2013 
2015 
2016  // header
2017  print_int("rpu_type", hdr->rpu_type);
2018  print_int("rpu_format", hdr->rpu_format);
2019  print_int("vdr_rpu_profile", hdr->vdr_rpu_profile);
2020  print_int("vdr_rpu_level", hdr->vdr_rpu_level);
2021  print_int("chroma_resampling_explicit_filter_flag",
2023  print_int("coef_data_type", hdr->coef_data_type);
2024  print_int("coef_log2_denom", hdr->coef_log2_denom);
2025  print_int("vdr_rpu_normalized_idc", hdr->vdr_rpu_normalized_idc);
2026  print_int("bl_video_full_range_flag", hdr->bl_video_full_range_flag);
2027  print_int("bl_bit_depth", hdr->bl_bit_depth);
2028  print_int("el_bit_depth", hdr->el_bit_depth);
2029  print_int("vdr_bit_depth", hdr->vdr_bit_depth);
2030  print_int("spatial_resampling_filter_flag",
2032  print_int("el_spatial_resampling_filter_flag",
2034  print_int("disable_residual_flag", hdr->disable_residual_flag);
2035 
2036  // data mapping values
2037  print_int("vdr_rpu_id", mapping->vdr_rpu_id);
2038  print_int("mapping_color_space", mapping->mapping_color_space);
2039  print_int("mapping_chroma_format_idc",
2040  mapping->mapping_chroma_format_idc);
2041 
2042  print_int("nlq_method_idc", mapping->nlq_method_idc);
2043  switch (mapping->nlq_method_idc) {
2044  case AV_DOVI_NLQ_NONE:
2045  print_str("nlq_method_idc_name", "none");
2046  break;
2047  case AV_DOVI_NLQ_LINEAR_DZ:
2048  print_str("nlq_method_idc_name", "linear_dz");
2049  break;
2050  default:
2051  print_str("nlq_method_idc_name", "unknown");
2052  break;
2053  }
2054 
2055  print_int("num_x_partitions", mapping->num_x_partitions);
2056  print_int("num_y_partitions", mapping->num_y_partitions);
2057 
2059 
2060  for (int c = 0; c < 3; c++) {
2061  const AVDOVIReshapingCurve *curve = &mapping->curves[c];
2063 
2064  print_list_fmt("pivots", "%"PRIu16, curve->num_pivots, 1, curve->pivots[idx]);
2065 
2067  for (int i = 0; i < curve->num_pivots - 1; i++) {
2068 
2070  print_int("mapping_idc", curve->mapping_idc[i]);
2071  switch (curve->mapping_idc[i]) {
2073  print_str("mapping_idc_name", "polynomial");
2074  print_int("poly_order", curve->poly_order[i]);
2075  print_list_fmt("poly_coef", "%"PRIi64,
2076  curve->poly_order[i] + 1, 1,
2077  curve->poly_coef[i][idx]);
2078  break;
2079  case AV_DOVI_MAPPING_MMR:
2080  print_str("mapping_idc_name", "mmr");
2081  print_int("mmr_order", curve->mmr_order[i]);
2082  print_int("mmr_constant", curve->mmr_constant[i]);
2083  print_list_fmt("mmr_coef", "%"PRIi64,
2084  curve->mmr_order[i], 7,
2085  curve->mmr_coef[i][idx][idx2]);
2086  break;
2087  default:
2088  print_str("mapping_idc_name", "unknown");
2089  break;
2090  }
2091 
2092  // SECTION_ID_FRAME_SIDE_DATA_PIECE
2094  }
2095 
2096  // SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST
2098 
2099  if (mapping->nlq_method_idc != AV_DOVI_NLQ_NONE) {
2100  const AVDOVINLQParams *nlq = &mapping->nlq[c];
2101  print_int("nlq_offset", nlq->nlq_offset);
2102  print_int("vdr_in_max", nlq->vdr_in_max);
2103 
2104  switch (mapping->nlq_method_idc) {
2105  case AV_DOVI_NLQ_LINEAR_DZ:
2106  print_int("linear_deadzone_slope", nlq->linear_deadzone_slope);
2107  print_int("linear_deadzone_threshold", nlq->linear_deadzone_threshold);
2108  break;
2109  }
2110  }
2111 
2112  // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
2114  }
2115 
2116  // SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
2118 
2119  // color metadata
2120  print_int("dm_metadata_id", color->dm_metadata_id);
2121  print_int("scene_refresh_flag", color->scene_refresh_flag);
2122  print_list_fmt("ycc_to_rgb_matrix", "%d/%d",
2123  FF_ARRAY_ELEMS(color->ycc_to_rgb_matrix), 1,
2124  color->ycc_to_rgb_matrix[idx].num,
2125  color->ycc_to_rgb_matrix[idx].den);
2126  print_list_fmt("ycc_to_rgb_offset", "%d/%d",
2127  FF_ARRAY_ELEMS(color->ycc_to_rgb_offset), 1,
2128  color->ycc_to_rgb_offset[idx].num,
2129  color->ycc_to_rgb_offset[idx].den);
2130  print_list_fmt("rgb_to_lms_matrix", "%d/%d",
2131  FF_ARRAY_ELEMS(color->rgb_to_lms_matrix), 1,
2132  color->rgb_to_lms_matrix[idx].num,
2133  color->rgb_to_lms_matrix[idx].den);
2134  print_int("signal_eotf", color->signal_eotf);
2135  print_int("signal_eotf_param0", color->signal_eotf_param0);
2136  print_int("signal_eotf_param1", color->signal_eotf_param1);
2137  print_int("signal_eotf_param2", color->signal_eotf_param2);
2138  print_int("signal_bit_depth", color->signal_bit_depth);
2139  print_int("signal_color_space", color->signal_color_space);
2140  print_int("signal_chroma_format", color->signal_chroma_format);
2141  print_int("signal_full_range_flag", color->signal_full_range_flag);
2142  print_int("source_min_pq", color->source_min_pq);
2143  print_int("source_max_pq", color->source_max_pq);
2144  print_int("source_diagonal", color->source_diagonal);
2145 
2146  av_bprint_finalize(&pbuf, NULL);
2147  }
2148 }
2149 
2151 {
2152  if (!metadata)
2153  return;
2154  print_int("application version", metadata->application_version);
2155  print_int("num_windows", metadata->num_windows);
2156  for (int n = 1; n < metadata->num_windows; n++) {
2157  const AVHDRPlusColorTransformParams *params = &metadata->params[n];
2158  print_q("window_upper_left_corner_x",
2159  params->window_upper_left_corner_x,'/');
2160  print_q("window_upper_left_corner_y",
2161  params->window_upper_left_corner_y,'/');
2162  print_q("window_lower_right_corner_x",
2163  params->window_lower_right_corner_x,'/');
2164  print_q("window_lower_right_corner_y",
2165  params->window_lower_right_corner_y,'/');
2166  print_q("window_upper_left_corner_x",
2167  params->window_upper_left_corner_x,'/');
2168  print_q("window_upper_left_corner_y",
2169  params->window_upper_left_corner_y,'/');
2170  print_int("center_of_ellipse_x",
2171  params->center_of_ellipse_x ) ;
2172  print_int("center_of_ellipse_y",
2173  params->center_of_ellipse_y );
2174  print_int("rotation_angle",
2175  params->rotation_angle);
2176  print_int("semimajor_axis_internal_ellipse",
2178  print_int("semimajor_axis_external_ellipse",
2180  print_int("semiminor_axis_external_ellipse",
2182  print_int("overlap_process_option",
2183  params->overlap_process_option);
2184  }
2185  print_q("targeted_system_display_maximum_luminance",
2188  print_int("num_rows_targeted_system_display_actual_peak_luminance",
2190  print_int("num_cols_targeted_system_display_actual_peak_luminance",
2192  for (int i = 0; i < metadata->num_rows_targeted_system_display_actual_peak_luminance; i++) {
2193  for (int j = 0; j < metadata->num_cols_targeted_system_display_actual_peak_luminance; j++) {
2194  print_q("targeted_system_display_actual_peak_luminance",
2196  }
2197  }
2198  }
2199  for (int n = 0; n < metadata->num_windows; n++) {
2200  const AVHDRPlusColorTransformParams *params = &metadata->params[n];
2201  for (int i = 0; i < 3; i++) {
2202  print_q("maxscl",params->maxscl[i],'/');
2203  }
2204  print_q("average_maxrgb",
2205  params->average_maxrgb,'/');
2206  print_int("num_distribution_maxrgb_percentiles",
2208  for (int i = 0; i < params->num_distribution_maxrgb_percentiles; i++) {
2209  print_int("distribution_maxrgb_percentage",
2210  params->distribution_maxrgb[i].percentage);
2211  print_q("distribution_maxrgb_percentile",
2212  params->distribution_maxrgb[i].percentile,'/');
2213  }
2214  print_q("fraction_bright_pixels",
2215  params->fraction_bright_pixels,'/');
2216  }
2218  print_int("num_rows_mastering_display_actual_peak_luminance",
2220  print_int("num_cols_mastering_display_actual_peak_luminance",
2222  for (int i = 0; i < metadata->num_rows_mastering_display_actual_peak_luminance; i++) {
2223  for (int j = 0; j < metadata->num_cols_mastering_display_actual_peak_luminance; j++) {
2224  print_q("mastering_display_actual_peak_luminance",
2225  metadata->mastering_display_actual_peak_luminance[i][j],'/');
2226  }
2227  }
2228  }
2229 
2230  for (int n = 0; n < metadata->num_windows; n++) {
2231  const AVHDRPlusColorTransformParams *params = &metadata->params[n];
2232  if (params->tone_mapping_flag) {
2233  print_q("knee_point_x", params->knee_point_x,'/');
2234  print_q("knee_point_y", params->knee_point_y,'/');
2235  print_int("num_bezier_curve_anchors",
2236  params->num_bezier_curve_anchors );
2237  for (int i = 0; i < params->num_bezier_curve_anchors; i++) {
2238  print_q("bezier_curve_anchors",
2239  params->bezier_curve_anchors[i],'/');
2240  }
2241  }
2242  if (params->color_saturation_mapping_flag) {
2243  print_q("color_saturation_weight",
2244  params->color_saturation_weight,'/');
2245  }
2246  }
2247 }
2248 
2250 {
2251  if (!metadata)
2252  return;
2253  print_int("system_start_code", metadata->system_start_code);
2254  print_int("num_windows", metadata->num_windows);
2255 
2256  for (int n = 0; n < metadata->num_windows; n++) {
2257  const AVHDRVividColorTransformParams *params = &metadata->params[n];
2258 
2259  print_q("minimum_maxrgb", params->minimum_maxrgb, '/');
2260  print_q("average_maxrgb", params->average_maxrgb, '/');
2261  print_q("variance_maxrgb", params->variance_maxrgb, '/');
2262  print_q("maximum_maxrgb", params->maximum_maxrgb, '/');
2263  }
2264 
2265  for (int n = 0; n < metadata->num_windows; n++) {
2266  const AVHDRVividColorTransformParams *params = &metadata->params[n];
2267 
2268  print_int("tone_mapping_mode_flag", params->tone_mapping_mode_flag);
2269  if (params->tone_mapping_mode_flag) {
2270  print_int("tone_mapping_param_num", params->tone_mapping_param_num);
2271  for (int i = 0; i < params->tone_mapping_param_num; i++) {
2272  const AVHDRVividColorToneMappingParams *tm_params = &params->tm_params[i];
2273 
2274  print_q("targeted_system_display_maximum_luminance",
2276  print_int("base_enable_flag", tm_params->base_enable_flag);
2277  if (tm_params->base_enable_flag) {
2278  print_q("base_param_m_p", tm_params->base_param_m_p, '/');
2279  print_q("base_param_m_m", tm_params->base_param_m_m, '/');
2280  print_q("base_param_m_a", tm_params->base_param_m_a, '/');
2281  print_q("base_param_m_b", tm_params->base_param_m_b, '/');
2282  print_q("base_param_m_n", tm_params->base_param_m_n, '/');
2283 
2284  print_int("base_param_k1", tm_params->base_param_k1);
2285  print_int("base_param_k2", tm_params->base_param_k2);
2286  print_int("base_param_k3", tm_params->base_param_k3);
2287  print_int("base_param_Delta_enable_mode",
2288  tm_params->base_param_Delta_enable_mode);
2289  print_q("base_param_Delta", tm_params->base_param_Delta, '/');
2290  }
2291  print_int("3Spline_enable_flag", tm_params->three_Spline_enable_flag);
2292  if (tm_params->three_Spline_enable_flag) {
2293  print_int("3Spline_num", tm_params->three_Spline_num);
2294 
2295  for (int j = 0; j < tm_params->three_Spline_num; j++) {
2296  const AVHDRVivid3SplineParams *three_spline = &tm_params->three_spline[j];
2297  print_int("3Spline_TH_mode", three_spline->th_mode);
2298  if (three_spline->th_mode == 0 || three_spline->th_mode == 2)
2299  print_q("3Spline_TH_enable_MB", three_spline->th_enable_mb, '/');
2300  print_q("3Spline_TH_enable", three_spline->th_enable, '/');
2301  print_q("3Spline_TH_Delta1", three_spline->th_delta1, '/');
2302  print_q("3Spline_TH_Delta2", three_spline->th_delta2, '/');
2303  print_q("3Spline_enable_Strength", three_spline->enable_strength, '/');
2304  }
2305  }
2306  }
2307  }
2308 
2309  print_int("color_saturation_mapping_flag", params->color_saturation_mapping_flag);
2310  if (params->color_saturation_mapping_flag) {
2311  print_int("color_saturation_num", params->color_saturation_num);
2312  for (int i = 0; i < params->color_saturation_num; i++) {
2313  print_q("color_saturation_gain", params->color_saturation_gain[i], '/');
2314  }
2315  }
2316  }
2317 }
2318 
2320  const AVAmbientViewingEnvironment *env)
2321 {
2322  if (!env)
2323  return;
2324 
2325  print_q("ambient_illuminance", env->ambient_illuminance, '/');
2326  print_q("ambient_light_x", env->ambient_light_x, '/');
2327  print_q("ambient_light_y", env->ambient_light_y, '/');
2328 }
2329 
2331  AVCodecParameters *par,
2332  const AVPacketSideData *sd,
2333  SectionID id_data)
2334 {
2335  const char *name = av_packet_side_data_name(sd->type);
2336 
2337  writer_print_section_header(w, (void *)sd, id_data);
2338  print_str("side_data_type", name ? name : "unknown");
2339  if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
2340  double rotation = av_display_rotation_get((int32_t *)sd->data);
2341  if (isnan(rotation))
2342  rotation = 0;
2343  writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
2344  print_int("rotation", rotation);
2345  } else if (sd->type == AV_PKT_DATA_STEREO3D) {
2346  const AVStereo3D *stereo = (AVStereo3D *)sd->data;
2347  print_str("type", av_stereo3d_type_name(stereo->type));
2348  print_int("inverted", !!(stereo->flags & AV_STEREO3D_FLAG_INVERT));
2349  } else if (sd->type == AV_PKT_DATA_SPHERICAL) {
2350  const AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data;
2351  print_str("projection", av_spherical_projection_name(spherical->projection));
2352  if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
2353  print_int("padding", spherical->padding);
2354  } else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
2355  size_t l, t, r, b;
2356  av_spherical_tile_bounds(spherical, par->width, par->height,
2357  &l, &t, &r, &b);
2358  print_int("bound_left", l);
2359  print_int("bound_top", t);
2360  print_int("bound_right", r);
2361  print_int("bound_bottom", b);
2362  }
2363 
2364  print_int("yaw", (double) spherical->yaw / (1 << 16));
2365  print_int("pitch", (double) spherical->pitch / (1 << 16));
2366  print_int("roll", (double) spherical->roll / (1 << 16));
2367  } else if (sd->type == AV_PKT_DATA_SKIP_SAMPLES && sd->size == 10) {
2368  print_int("skip_samples", AV_RL32(sd->data));
2369  print_int("discard_padding", AV_RL32(sd->data + 4));
2370  print_int("skip_reason", AV_RL8(sd->data + 8));
2371  print_int("discard_reason", AV_RL8(sd->data + 9));
2372  } else if (sd->type == AV_PKT_DATA_MASTERING_DISPLAY_METADATA) {
2374 
2375  if (metadata->has_primaries) {
2376  print_q("red_x", metadata->display_primaries[0][0], '/');
2377  print_q("red_y", metadata->display_primaries[0][1], '/');
2378  print_q("green_x", metadata->display_primaries[1][0], '/');
2379  print_q("green_y", metadata->display_primaries[1][1], '/');
2380  print_q("blue_x", metadata->display_primaries[2][0], '/');
2381  print_q("blue_y", metadata->display_primaries[2][1], '/');
2382 
2383  print_q("white_point_x", metadata->white_point[0], '/');
2384  print_q("white_point_y", metadata->white_point[1], '/');
2385  }
2386 
2387  if (metadata->has_luminance) {
2388  print_q("min_luminance", metadata->min_luminance, '/');
2389  print_q("max_luminance", metadata->max_luminance, '/');
2390  }
2391  } else if (sd->type == AV_PKT_DATA_CONTENT_LIGHT_LEVEL) {
2392  AVContentLightMetadata *metadata = (AVContentLightMetadata *)sd->data;
2393  print_int("max_content", metadata->MaxCLL);
2394  print_int("max_average", metadata->MaxFALL);
2395  } else if (sd->type == AV_PKT_DATA_DYNAMIC_HDR10_PLUS) {
2396  AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
2397  print_dynamic_hdr10_plus(w, metadata);
2398  } else if (sd->type == AV_PKT_DATA_DOVI_CONF) {
2400  print_int("dv_version_major", dovi->dv_version_major);
2401  print_int("dv_version_minor", dovi->dv_version_minor);
2402  print_int("dv_profile", dovi->dv_profile);
2403  print_int("dv_level", dovi->dv_level);
2404  print_int("rpu_present_flag", dovi->rpu_present_flag);
2405  print_int("el_present_flag", dovi->el_present_flag);
2406  print_int("bl_present_flag", dovi->bl_present_flag);
2407  print_int("dv_bl_signal_compatibility_id", dovi->dv_bl_signal_compatibility_id);
2408  } else if (sd->type == AV_PKT_DATA_AUDIO_SERVICE_TYPE) {
2409  enum AVAudioServiceType *t = (enum AVAudioServiceType *)sd->data;
2410  print_int("service_type", *t);
2411  } else if (sd->type == AV_PKT_DATA_MPEGTS_STREAM_ID) {
2412  print_int("id", *sd->data);
2413  } else if (sd->type == AV_PKT_DATA_CPB_PROPERTIES) {
2414  const AVCPBProperties *prop = (AVCPBProperties *)sd->data;
2415  print_int("max_bitrate", prop->max_bitrate);
2416  print_int("min_bitrate", prop->min_bitrate);
2417  print_int("avg_bitrate", prop->avg_bitrate);
2418  print_int("buffer_size", prop->buffer_size);
2419  print_int("vbv_delay", prop->vbv_delay);
2420  } else if (sd->type == AV_PKT_DATA_WEBVTT_IDENTIFIER ||
2421  sd->type == AV_PKT_DATA_WEBVTT_SETTINGS) {
2422  if (do_show_data)
2423  writer_print_data(w, "data", sd->data, sd->size);
2424  writer_print_data_hash(w, "data_hash", sd->data, sd->size);
2425  } else if (sd->type == AV_PKT_DATA_AFD && sd->size > 0) {
2426  print_int("active_format", *sd->data);
2427  }
2428 }
2429 
2430 static void print_private_data(WriterContext *w, void *priv_data)
2431 {
2432  const AVOption *opt = NULL;
2433  while (opt = av_opt_next(priv_data, opt)) {
2434  uint8_t *str;
2435  if (!(opt->flags & AV_OPT_FLAG_EXPORT)) continue;
2436  if (av_opt_get(priv_data, opt->name, 0, &str) >= 0) {
2437  print_str(opt->name, str);
2438  av_free(str);
2439  }
2440  }
2441 }
2442 
2444 {
2445  const char *val = av_color_range_name(color_range);
2447  print_str_opt("color_range", "unknown");
2448  } else {
2449  print_str("color_range", val);
2450  }
2451 }
2452 
2453 static void print_color_space(WriterContext *w, enum AVColorSpace color_space)
2454 {
2455  const char *val = av_color_space_name(color_space);
2456  if (!val || color_space == AVCOL_SPC_UNSPECIFIED) {
2457  print_str_opt("color_space", "unknown");
2458  } else {
2459  print_str("color_space", val);
2460  }
2461 }
2462 
2464 {
2467  print_str_opt("color_primaries", "unknown");
2468  } else {
2469  print_str("color_primaries", val);
2470  }
2471 }
2472 
2474 {
2475  const char *val = av_color_transfer_name(color_trc);
2476  if (!val || color_trc == AVCOL_TRC_UNSPECIFIED) {
2477  print_str_opt("color_transfer", "unknown");
2478  } else {
2479  print_str("color_transfer", val);
2480  }
2481 }
2482 
2483 static void print_chroma_location(WriterContext *w, enum AVChromaLocation chroma_location)
2484 {
2485  const char *val = av_chroma_location_name(chroma_location);
2486  if (!val || chroma_location == AVCHROMA_LOC_UNSPECIFIED) {
2487  print_str_opt("chroma_location", "unspecified");
2488  } else {
2489  print_str("chroma_location", val);
2490  }
2491 }
2492 
2493 static void clear_log(int need_lock)
2494 {
2495  int i;
2496 
2497  if (need_lock)
2498  pthread_mutex_lock(&log_mutex);
2499  for (i=0; i<log_buffer_size; i++) {
2500  av_freep(&log_buffer[i].context_name);
2501  av_freep(&log_buffer[i].parent_name);
2502  av_freep(&log_buffer[i].log_message);
2503  }
2504  log_buffer_size = 0;
2505  if(need_lock)
2506  pthread_mutex_unlock(&log_mutex);
2507 }
2508 
2509 static int show_log(WriterContext *w, int section_ids, int section_id, int log_level)
2510 {
2511  int i;
2512  pthread_mutex_lock(&log_mutex);
2513  if (!log_buffer_size) {
2514  pthread_mutex_unlock(&log_mutex);
2515  return 0;
2516  }
2517  writer_print_section_header(w, NULL, section_ids);
2518 
2519  for (i=0; i<log_buffer_size; i++) {
2520  if (log_buffer[i].log_level <= log_level) {
2521  writer_print_section_header(w, NULL, section_id);
2522  print_str("context", log_buffer[i].context_name);
2523  print_int("level", log_buffer[i].log_level);
2524  print_int("category", log_buffer[i].category);
2525  if (log_buffer[i].parent_name) {
2526  print_str("parent_context", log_buffer[i].parent_name);
2527  print_int("parent_category", log_buffer[i].parent_category);
2528  } else {
2529  print_str_opt("parent_context", "N/A");
2530  print_str_opt("parent_category", "N/A");
2531  }
2532  print_str("message", log_buffer[i].log_message);
2534  }
2535  }
2536  clear_log(0);
2537  pthread_mutex_unlock(&log_mutex);
2538 
2540 
2541  return 0;
2542 }
2543 
2544 static void show_packet(WriterContext *w, InputFile *ifile, AVPacket *pkt, int packet_idx)
2545 {
2546  char val_str[128];
2547  AVStream *st = ifile->streams[pkt->stream_index].st;
2548  AVBPrint pbuf;
2549  const char *s;
2550 
2552 
2554 
2556  if (s) print_str ("codec_type", s);
2557  else print_str_opt("codec_type", "unknown");
2558  print_int("stream_index", pkt->stream_index);
2559  print_ts ("pts", pkt->pts);
2560  print_time("pts_time", pkt->pts, &st->time_base);
2561  print_ts ("dts", pkt->dts);
2562  print_time("dts_time", pkt->dts, &st->time_base);
2563  print_duration_ts("duration", pkt->duration);
2564  print_duration_time("duration_time", pkt->duration, &st->time_base);
2565  print_val("size", pkt->size, unit_byte_str);
2566  if (pkt->pos != -1) print_fmt ("pos", "%"PRId64, pkt->pos);
2567  else print_str_opt("pos", "N/A");
2568  print_fmt("flags", "%c%c%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_',
2569  pkt->flags & AV_PKT_FLAG_DISCARD ? 'D' : '_',
2570  pkt->flags & AV_PKT_FLAG_CORRUPT ? 'C' : '_');
2571  if (do_show_data)
2572  writer_print_data(w, "data", pkt->data, pkt->size);
2573  writer_print_data_hash(w, "data_hash", pkt->data, pkt->size);
2574 
2575  if (pkt->side_data_elems) {
2576  size_t size;
2577  const uint8_t *side_metadata;
2578 
2580  if (side_metadata && size && do_show_packet_tags) {
2581  AVDictionary *dict = NULL;
2582  if (av_packet_unpack_dictionary(side_metadata, size, &dict) >= 0)
2584  av_dict_free(&dict);
2585  }
2586 
2588  for (int i = 0; i < pkt->side_data_elems; i++) {
2592  }
2594  }
2595 
2597 
2598  av_bprint_finalize(&pbuf, NULL);
2599  fflush(stdout);
2600 }
2601 
2602 static void show_subtitle(WriterContext *w, AVSubtitle *sub, AVStream *stream,
2604 {
2605  AVBPrint pbuf;
2606 
2608 
2610 
2611  print_str ("media_type", "subtitle");
2612  print_ts ("pts", sub->pts);
2613  print_time("pts_time", sub->pts, &AV_TIME_BASE_Q);
2614  print_int ("format", sub->format);
2615  print_int ("start_display_time", sub->start_display_time);
2616  print_int ("end_display_time", sub->end_display_time);
2617  print_int ("num_rects", sub->num_rects);
2618 
2620 
2621  av_bprint_finalize(&pbuf, NULL);
2622  fflush(stdout);
2623 }
2624 
2626  const AVFrame *frame,
2627  const AVStream *stream)
2628 {
2630 
2631  for (int i = 0; i < frame->nb_side_data; i++) {
2632  const AVFrameSideData *sd = frame->side_data[i];
2633  const char *name;
2634 
2636  name = av_frame_side_data_name(sd->type);
2637  print_str("side_data_type", name ? name : "unknown");
2638  if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
2639  double rotation = av_display_rotation_get((int32_t *)sd->data);
2640  if (isnan(rotation))
2641  rotation = 0;
2642  writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
2643  print_int("rotation", rotation);
2644  } else if (sd->type == AV_FRAME_DATA_AFD && sd->size > 0) {
2645  print_int("active_format", *sd->data);
2646  } else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) {
2647  char tcbuf[AV_TIMECODE_STR_SIZE];
2648  av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));
2649  print_str("timecode", tcbuf);
2650  } else if (sd->type == AV_FRAME_DATA_S12M_TIMECODE && sd->size == 16) {
2651  uint32_t *tc = (uint32_t*)sd->data;
2652  int m = FFMIN(tc[0],3);
2654  for (int j = 1; j <= m ; j++) {
2655  char tcbuf[AV_TIMECODE_STR_SIZE];
2656  av_timecode_make_smpte_tc_string2(tcbuf, stream->avg_frame_rate, tc[j], 0, 0);
2658  print_str("value", tcbuf);
2660  }
2662  } else if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) {
2664 
2665  if (metadata->has_primaries) {
2666  print_q("red_x", metadata->display_primaries[0][0], '/');
2667  print_q("red_y", metadata->display_primaries[0][1], '/');
2668  print_q("green_x", metadata->display_primaries[1][0], '/');
2669  print_q("green_y", metadata->display_primaries[1][1], '/');
2670  print_q("blue_x", metadata->display_primaries[2][0], '/');
2671  print_q("blue_y", metadata->display_primaries[2][1], '/');
2672 
2673  print_q("white_point_x", metadata->white_point[0], '/');
2674  print_q("white_point_y", metadata->white_point[1], '/');
2675  }
2676 
2677  if (metadata->has_luminance) {
2678  print_q("min_luminance", metadata->min_luminance, '/');
2679  print_q("max_luminance", metadata->max_luminance, '/');
2680  }
2681  } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_PLUS) {
2682  AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
2683  print_dynamic_hdr10_plus(w, metadata);
2684  } else if (sd->type == AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) {
2685  AVContentLightMetadata *metadata = (AVContentLightMetadata *)sd->data;
2686  print_int("max_content", metadata->MaxCLL);
2687  print_int("max_average", metadata->MaxFALL);
2688  } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
2689  const AVDictionaryEntry *tag = av_dict_get(sd->metadata, "name", NULL, AV_DICT_MATCH_CASE);
2690  if (tag)
2691  print_str(tag->key, tag->value);
2692  print_int("size", sd->size);
2693  } else if (sd->type == AV_FRAME_DATA_DOVI_METADATA) {
2694  print_dovi_metadata(w, (const AVDOVIMetadata *)sd->data);
2695  } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) {
2696  AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data;
2697  print_dynamic_hdr_vivid(w, metadata);
2698  } else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
2700  }
2702  }
2704 }
2705 
2708 {
2710  AVBPrint pbuf;
2711  char val_str[128];
2712  const char *s;
2713 
2715 
2717 
2719  if (s) print_str ("media_type", s);
2720  else print_str_opt("media_type", "unknown");
2721  print_int("stream_index", stream->index);
2722  print_int("key_frame", !!(frame->flags & AV_FRAME_FLAG_KEY));
2723  print_ts ("pts", frame->pts);
2724  print_time("pts_time", frame->pts, &stream->time_base);
2725  print_ts ("pkt_dts", frame->pkt_dts);
2726  print_time("pkt_dts_time", frame->pkt_dts, &stream->time_base);
2727  print_ts ("best_effort_timestamp", frame->best_effort_timestamp);
2728  print_time("best_effort_timestamp_time", frame->best_effort_timestamp, &stream->time_base);
2729 #if LIBAVUTIL_VERSION_MAJOR < 59
2731  print_duration_ts ("pkt_duration", frame->pkt_duration);
2732  print_duration_time("pkt_duration_time", frame->pkt_duration, &stream->time_base);
2733  )
2734 #endif
2735  print_duration_ts ("duration", frame->duration);
2736  print_duration_time("duration_time", frame->duration, &stream->time_base);
2737  if (fd && fd->pkt_pos != -1) print_fmt ("pkt_pos", "%"PRId64, fd->pkt_pos);
2738  else print_str_opt("pkt_pos", "N/A");
2739  if (fd && fd->pkt_size != -1) print_val ("pkt_size", fd->pkt_size, unit_byte_str);
2740  else print_str_opt("pkt_size", "N/A");
2741 
2742  switch (stream->codecpar->codec_type) {
2743  AVRational sar;
2744 
2745  case AVMEDIA_TYPE_VIDEO:
2746  print_int("width", frame->width);
2747  print_int("height", frame->height);
2748  print_int("crop_top", frame->crop_top);
2749  print_int("crop_bottom", frame->crop_bottom);
2750  print_int("crop_left", frame->crop_left);
2751  print_int("crop_right", frame->crop_right);
2753  if (s) print_str ("pix_fmt", s);
2754  else print_str_opt("pix_fmt", "unknown");
2755  sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, frame);
2756  if (sar.num) {
2757  print_q("sample_aspect_ratio", sar, ':');
2758  } else {
2759  print_str_opt("sample_aspect_ratio", "N/A");
2760  }
2761  print_fmt("pict_type", "%c", av_get_picture_type_char(frame->pict_type));
2762 #if LIBAVUTIL_VERSION_MAJOR < 59
2764  print_int("coded_picture_number", frame->coded_picture_number);
2765  print_int("display_picture_number", frame->display_picture_number);
2766  )
2767 #endif
2768  print_int("interlaced_frame", !!(frame->flags & AV_FRAME_FLAG_INTERLACED));
2769  print_int("top_field_first", !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
2770  print_int("repeat_pict", frame->repeat_pict);
2771 
2777  break;
2778 
2779  case AVMEDIA_TYPE_AUDIO:
2781  if (s) print_str ("sample_fmt", s);
2782  else print_str_opt("sample_fmt", "unknown");
2783  print_int("nb_samples", frame->nb_samples);
2784  print_int("channels", frame->ch_layout.nb_channels);
2786  av_channel_layout_describe(&frame->ch_layout, val_str, sizeof(val_str));
2787  print_str ("channel_layout", val_str);
2788  } else
2789  print_str_opt("channel_layout", "unknown");
2790  break;
2791  }
2792  if (do_show_frame_tags)
2794  if (do_show_log)
2796  if (frame->nb_side_data)
2797  print_frame_side_data(w, frame, stream);
2798 
2800 
2801  av_bprint_finalize(&pbuf, NULL);
2802  fflush(stdout);
2803 }
2804 
2806  InputFile *ifile,
2807  AVFrame *frame, const AVPacket *pkt,
2808  int *packet_new)
2809 {
2810  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2813  AVSubtitle sub;
2814  int ret = 0, got_frame = 0;
2815 
2816  clear_log(1);
2817  if (dec_ctx) {
2818  switch (par->codec_type) {
2819  case AVMEDIA_TYPE_VIDEO:
2820  case AVMEDIA_TYPE_AUDIO:
2821  if (*packet_new) {
2823  if (ret == AVERROR(EAGAIN)) {
2824  ret = 0;
2825  } else if (ret >= 0 || ret == AVERROR_EOF) {
2826  ret = 0;
2827  *packet_new = 0;
2828  }
2829  }
2830  if (ret >= 0) {
2832  if (ret >= 0) {
2833  got_frame = 1;
2834  } else if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
2835  ret = 0;
2836  }
2837  }
2838  break;
2839 
2840  case AVMEDIA_TYPE_SUBTITLE:
2841  if (*packet_new)
2842  ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_frame, pkt);
2843  *packet_new = 0;
2844  break;
2845  default:
2846  *packet_new = 0;
2847  }
2848  } else {
2849  *packet_new = 0;
2850  }
2851 
2852  if (ret < 0)
2853  return ret;
2854  if (got_frame) {
2855  int is_sub = (par->codec_type == AVMEDIA_TYPE_SUBTITLE);
2857  if (do_show_frames)
2858  if (is_sub)
2859  show_subtitle(w, &sub, ifile->streams[pkt->stream_index].st, fmt_ctx);
2860  else
2862  if (is_sub)
2863  avsubtitle_free(&sub);
2864  }
2865  return got_frame || *packet_new;
2866 }
2867 
2868 static void log_read_interval(const ReadInterval *interval, void *log_ctx, int log_level)
2869 {
2870  av_log(log_ctx, log_level, "id:%d", interval->id);
2871 
2872  if (interval->has_start) {
2873  av_log(log_ctx, log_level, " start:%s%s", interval->start_is_offset ? "+" : "",
2874  av_ts2timestr(interval->start, &AV_TIME_BASE_Q));
2875  } else {
2876  av_log(log_ctx, log_level, " start:N/A");
2877  }
2878 
2879  if (interval->has_end) {
2880  av_log(log_ctx, log_level, " end:%s", interval->end_is_offset ? "+" : "");
2881  if (interval->duration_frames)
2882  av_log(log_ctx, log_level, "#%"PRId64, interval->end);
2883  else
2884  av_log(log_ctx, log_level, "%s", av_ts2timestr(interval->end, &AV_TIME_BASE_Q));
2885  } else {
2886  av_log(log_ctx, log_level, " end:N/A");
2887  }
2888 
2889  av_log(log_ctx, log_level, "\n");
2890 }
2891 
2893  const ReadInterval *interval, int64_t *cur_ts)
2894 {
2895  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2896  AVPacket *pkt = NULL;
2897  AVFrame *frame = NULL;
2898  int ret = 0, i = 0, frame_count = 0;
2899  int64_t start = -INT64_MAX, end = interval->end;
2900  int has_start = 0, has_end = interval->has_end && !interval->end_is_offset;
2901 
2902  av_log(NULL, AV_LOG_VERBOSE, "Processing read interval ");
2904 
2905  if (interval->has_start) {
2906  int64_t target;
2907  if (interval->start_is_offset) {
2908  if (*cur_ts == AV_NOPTS_VALUE) {
2910  "Could not seek to relative position since current "
2911  "timestamp is not defined\n");
2912  ret = AVERROR(EINVAL);
2913  goto end;
2914  }
2915  target = *cur_ts + interval->start;
2916  } else {
2917  target = interval->start;
2918  }
2919 
2920  av_log(NULL, AV_LOG_VERBOSE, "Seeking to read interval start point %s\n",
2921  av_ts2timestr(target, &AV_TIME_BASE_Q));
2922  if ((ret = avformat_seek_file(fmt_ctx, -1, -INT64_MAX, target, INT64_MAX, 0)) < 0) {
2923  av_log(NULL, AV_LOG_ERROR, "Could not seek to position %"PRId64": %s\n",
2924  interval->start, av_err2str(ret));
2925  goto end;
2926  }
2927  }
2928 
2929  frame = av_frame_alloc();
2930  if (!frame) {
2931  ret = AVERROR(ENOMEM);
2932  goto end;
2933  }
2934  pkt = av_packet_alloc();
2935  if (!pkt) {
2936  ret = AVERROR(ENOMEM);
2937  goto end;
2938  }
2939  while (!av_read_frame(fmt_ctx, pkt)) {
2940  if (fmt_ctx->nb_streams > nb_streams) {
2945  }
2948  int64_t pts = pkt->pts != AV_NOPTS_VALUE ? pkt->pts : pkt->dts;
2949 
2950  if (pts != AV_NOPTS_VALUE)
2951  *cur_ts = av_rescale_q(pts, tb, AV_TIME_BASE_Q);
2952 
2953  if (!has_start && *cur_ts != AV_NOPTS_VALUE) {
2954  start = *cur_ts;
2955  has_start = 1;
2956  }
2957 
2958  if (has_start && !has_end && interval->end_is_offset) {
2959  end = start + interval->end;
2960  has_end = 1;
2961  }
2962 
2963  if (interval->end_is_offset && interval->duration_frames) {
2964  if (frame_count >= interval->end)
2965  break;
2966  } else if (has_end && *cur_ts != AV_NOPTS_VALUE && *cur_ts >= end) {
2967  break;
2968  }
2969 
2970  frame_count++;
2971  if (do_read_packets) {
2972  if (do_show_packets)
2973  show_packet(w, ifile, pkt, i++);
2975  }
2976  if (do_read_frames) {
2977  int packet_new = 1;
2978  FrameData *fd;
2979 
2980  pkt->opaque_ref = av_buffer_allocz(sizeof(*fd));
2981  if (!pkt->opaque_ref) {
2982  ret = AVERROR(ENOMEM);
2983  goto end;
2984  }
2985  fd = (FrameData*)pkt->opaque_ref->data;
2986  fd->pkt_pos = pkt->pos;
2987  fd->pkt_size = pkt->size;
2988 
2989  while (process_frame(w, ifile, frame, pkt, &packet_new) > 0);
2990  }
2991  }
2993  }
2995  //Flush remaining frames that are cached in the decoder
2996  for (i = 0; i < ifile->nb_streams; i++) {
2997  pkt->stream_index = i;
2998  if (do_read_frames) {
2999  while (process_frame(w, ifile, frame, pkt, &(int){1}) > 0);
3000  if (ifile->streams[i].dec_ctx)
3002  }
3003  }
3004 
3005 end:
3006  av_frame_free(&frame);
3007  av_packet_free(&pkt);
3008  if (ret < 0) {
3009  av_log(NULL, AV_LOG_ERROR, "Could not read packets in interval ");
3010  log_read_interval(interval, NULL, AV_LOG_ERROR);
3011  }
3012  return ret;
3013 }
3014 
3016 {
3017  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
3018  int i, ret = 0;
3019  int64_t cur_ts = fmt_ctx->start_time;
3020 
3021  if (read_intervals_nb == 0) {
3022  ReadInterval interval = (ReadInterval) { .has_start = 0, .has_end = 0 };
3023  ret = read_interval_packets(w, ifile, &interval, &cur_ts);
3024  } else {
3025  for (i = 0; i < read_intervals_nb; i++) {
3026  ret = read_interval_packets(w, ifile, &read_intervals[i], &cur_ts);
3027  if (ret < 0)
3028  break;
3029  }
3030  }
3031 
3032  return ret;
3033 }
3034 
3035 static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program)
3036 {
3037  AVStream *stream = ist->st;
3038  AVCodecParameters *par;
3040  char val_str[128];
3041  const char *s;
3042  AVRational sar, dar;
3043  AVBPrint pbuf;
3044  const AVCodecDescriptor *cd;
3045  int ret = 0;
3046  const char *profile = NULL;
3047 
3049 
3051 
3052  print_int("index", stream->index);
3053 
3054  par = stream->codecpar;
3055  dec_ctx = ist->dec_ctx;
3056  if (cd = avcodec_descriptor_get(par->codec_id)) {
3057  print_str("codec_name", cd->name);
3058  if (!do_bitexact) {
3059  print_str("codec_long_name",
3060  cd->long_name ? cd->long_name : "unknown");
3061  }
3062  } else {
3063  print_str_opt("codec_name", "unknown");
3064  if (!do_bitexact) {
3065  print_str_opt("codec_long_name", "unknown");
3066  }
3067  }
3068 
3069  if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile)))
3070  print_str("profile", profile);
3071  else {
3072  if (par->profile != AV_PROFILE_UNKNOWN) {
3073  char profile_num[12];
3074  snprintf(profile_num, sizeof(profile_num), "%d", par->profile);
3075  print_str("profile", profile_num);
3076  } else
3077  print_str_opt("profile", "unknown");
3078  }
3079 
3081  if (s) print_str ("codec_type", s);
3082  else print_str_opt("codec_type", "unknown");
3083 
3084  /* print AVI/FourCC tag */
3085  print_str("codec_tag_string", av_fourcc2str(par->codec_tag));
3086  print_fmt("codec_tag", "0x%04"PRIx32, par->codec_tag);
3087 
3088  switch (par->codec_type) {
3089  case AVMEDIA_TYPE_VIDEO:
3090  print_int("width", par->width);
3091  print_int("height", par->height);
3092  if (dec_ctx) {
3093  print_int("coded_width", dec_ctx->coded_width);
3094  print_int("coded_height", dec_ctx->coded_height);
3097  }
3098  print_int("has_b_frames", par->video_delay);
3099  sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
3100  if (sar.num) {
3101  print_q("sample_aspect_ratio", sar, ':');
3102  av_reduce(&dar.num, &dar.den,
3103  par->width * sar.num,
3104  par->height * sar.den,
3105  1024*1024);
3106  print_q("display_aspect_ratio", dar, ':');
3107  } else {
3108  print_str_opt("sample_aspect_ratio", "N/A");
3109  print_str_opt("display_aspect_ratio", "N/A");
3110  }
3111  s = av_get_pix_fmt_name(par->format);
3112  if (s) print_str ("pix_fmt", s);
3113  else print_str_opt("pix_fmt", "unknown");
3114  print_int("level", par->level);
3115 
3118  print_color_trc(w, par->color_trc);
3121 
3122  if (par->field_order == AV_FIELD_PROGRESSIVE)
3123  print_str("field_order", "progressive");
3124  else if (par->field_order == AV_FIELD_TT)
3125  print_str("field_order", "tt");
3126  else if (par->field_order == AV_FIELD_BB)
3127  print_str("field_order", "bb");
3128  else if (par->field_order == AV_FIELD_TB)
3129  print_str("field_order", "tb");
3130  else if (par->field_order == AV_FIELD_BT)
3131  print_str("field_order", "bt");
3132  else
3133  print_str_opt("field_order", "unknown");
3134 
3135  if (dec_ctx)
3136  print_int("refs", dec_ctx->refs);
3137  break;
3138 
3139  case AVMEDIA_TYPE_AUDIO:
3141  if (s) print_str ("sample_fmt", s);
3142  else print_str_opt("sample_fmt", "unknown");
3143  print_val("sample_rate", par->sample_rate, unit_hertz_str);
3144  print_int("channels", par->ch_layout.nb_channels);
3145 
3146  if (par->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
3147  av_channel_layout_describe(&par->ch_layout, val_str, sizeof(val_str));
3148  print_str ("channel_layout", val_str);
3149  } else {
3150  print_str_opt("channel_layout", "unknown");
3151  }
3152 
3153  print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id));
3154 
3155  print_int("initial_padding", par->initial_padding);
3156  break;
3157 
3158  case AVMEDIA_TYPE_SUBTITLE:
3159  if (par->width)
3160  print_int("width", par->width);
3161  else
3162  print_str_opt("width", "N/A");
3163  if (par->height)
3164  print_int("height", par->height);
3165  else
3166  print_str_opt("height", "N/A");
3167  break;
3168  }
3169 
3170  if (show_private_data) {
3171  if (dec_ctx && dec_ctx->codec->priv_class)
3173  if (fmt_ctx->iformat->priv_class)
3175  }
3176 
3177  if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%x", stream->id);
3178  else print_str_opt("id", "N/A");
3179  print_q("r_frame_rate", stream->r_frame_rate, '/');
3180  print_q("avg_frame_rate", stream->avg_frame_rate, '/');
3181  print_q("time_base", stream->time_base, '/');
3182  print_ts ("start_pts", stream->start_time);
3183  print_time("start_time", stream->start_time, &stream->time_base);
3184  print_ts ("duration_ts", stream->duration);
3185  print_time("duration", stream->duration, &stream->time_base);
3186  if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str);
3187  else print_str_opt("bit_rate", "N/A");
3188  if (dec_ctx && dec_ctx->rc_max_rate > 0)
3190  else
3191  print_str_opt("max_bit_rate", "N/A");
3192  if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample);
3193  else print_str_opt("bits_per_raw_sample", "N/A");
3194  if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames);
3195  else print_str_opt("nb_frames", "N/A");
3196  if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]);
3197  else print_str_opt("nb_read_frames", "N/A");
3198  if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]);
3199  else print_str_opt("nb_read_packets", "N/A");
3200  if (do_show_data)
3201  writer_print_data(w, "extradata", par->extradata,
3202  par->extradata_size);
3203 
3204  if (par->extradata_size > 0) {
3205  print_int("extradata_size", par->extradata_size);
3206  writer_print_data_hash(w, "extradata_hash", par->extradata,
3207  par->extradata_size);
3208  }
3209 
3210  /* Print disposition information */
3211 #define PRINT_DISPOSITION(flagname, name) do { \
3212  print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \
3213  } while (0)
3214 
3217  PRINT_DISPOSITION(DEFAULT, "default");
3218  PRINT_DISPOSITION(DUB, "dub");
3219  PRINT_DISPOSITION(ORIGINAL, "original");
3220  PRINT_DISPOSITION(COMMENT, "comment");
3221  PRINT_DISPOSITION(LYRICS, "lyrics");
3222  PRINT_DISPOSITION(KARAOKE, "karaoke");
3223  PRINT_DISPOSITION(FORCED, "forced");
3224  PRINT_DISPOSITION(HEARING_IMPAIRED, "hearing_impaired");
3225  PRINT_DISPOSITION(VISUAL_IMPAIRED, "visual_impaired");
3226  PRINT_DISPOSITION(CLEAN_EFFECTS, "clean_effects");
3227  PRINT_DISPOSITION(ATTACHED_PIC, "attached_pic");
3228  PRINT_DISPOSITION(TIMED_THUMBNAILS, "timed_thumbnails");
3229  PRINT_DISPOSITION(NON_DIEGETIC, "non_diegetic");
3230  PRINT_DISPOSITION(CAPTIONS, "captions");
3231  PRINT_DISPOSITION(DESCRIPTIONS, "descriptions");
3232  PRINT_DISPOSITION(METADATA, "metadata");
3233  PRINT_DISPOSITION(DEPENDENT, "dependent");
3234  PRINT_DISPOSITION(STILL_IMAGE, "still_image");
3236  }
3237 
3238  if (do_show_stream_tags)
3240 
3241  if (stream->codecpar->nb_coded_side_data) {
3243  for (int i = 0; i < stream->codecpar->nb_coded_side_data; i++) {
3244  print_pkt_side_data(w, stream->codecpar, &stream->codecpar->coded_side_data[i],
3247  }
3249  }
3250 
3252  av_bprint_finalize(&pbuf, NULL);
3253  fflush(stdout);
3254 
3255  return ret;
3256 }
3257 
3259 {
3260  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
3261  int i, ret = 0;
3262 
3264  for (i = 0; i < ifile->nb_streams; i++)
3265  if (selected_streams[i]) {
3266  ret = show_stream(w, fmt_ctx, i, &ifile->streams[i], 0);
3267  if (ret < 0)
3268  break;
3269  }
3271 
3272  return ret;
3273 }
3274 
3276 {
3277  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
3278  int i, ret = 0;
3279 
3281  print_int("program_id", program->id);
3282  print_int("program_num", program->program_num);
3283  print_int("nb_streams", program->nb_stream_indexes);
3284  print_int("pmt_pid", program->pmt_pid);
3285  print_int("pcr_pid", program->pcr_pid);
3288  if (ret < 0)
3289  goto end;
3290 
3292  for (i = 0; i < program->nb_stream_indexes; i++) {
3293  if (selected_streams[program->stream_index[i]]) {
3294  ret = show_stream(w, fmt_ctx, program->stream_index[i], &ifile->streams[program->stream_index[i]], 1);
3295  if (ret < 0)
3296  break;
3297  }
3298  }
3300 
3301 end:
3303  return ret;
3304 }
3305 
3307 {
3308  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
3309  int i, ret = 0;
3310 
3312  for (i = 0; i < fmt_ctx->nb_programs; i++) {
3314  if (!program)
3315  continue;
3316  ret = show_program(w, ifile, program);
3317  if (ret < 0)
3318  break;
3319  }
3321  return ret;
3322 }
3323 
3325 {
3326  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
3327  int i, ret = 0;
3328 
3330  for (i = 0; i < fmt_ctx->nb_chapters; i++) {
3331  AVChapter *chapter = fmt_ctx->chapters[i];
3332 
3334  print_int("id", chapter->id);
3335  print_q ("time_base", chapter->time_base, '/');
3336  print_int("start", chapter->start);
3337  print_time("start_time", chapter->start, &chapter->time_base);
3338  print_int("end", chapter->end);
3339  print_time("end_time", chapter->end, &chapter->time_base);
3343  }
3345 
3346  return ret;
3347 }
3348 
3349 static int show_format(WriterContext *w, InputFile *ifile)
3350 {
3351  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
3352  char val_str[128];
3353  int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
3354  int ret = 0;
3355 
3357  print_str_validate("filename", fmt_ctx->url);
3358  print_int("nb_streams", fmt_ctx->nb_streams);
3359  print_int("nb_programs", fmt_ctx->nb_programs);
3360  print_str("format_name", fmt_ctx->iformat->name);
3361  if (!do_bitexact) {
3362  if (fmt_ctx->iformat->long_name) print_str ("format_long_name", fmt_ctx->iformat->long_name);
3363  else print_str_opt("format_long_name", "unknown");
3364  }
3365  print_time("start_time", fmt_ctx->start_time, &AV_TIME_BASE_Q);
3366  print_time("duration", fmt_ctx->duration, &AV_TIME_BASE_Q);
3367  if (size >= 0) print_val ("size", size, unit_byte_str);
3368  else print_str_opt("size", "N/A");
3370  else print_str_opt("bit_rate", "N/A");
3371  print_int("probe_score", fmt_ctx->probe_score);
3372  if (do_show_format_tags)
3374 
3376  fflush(stdout);
3377  return ret;
3378 }
3379 
3380 static void show_error(WriterContext *w, int err)
3381 {
3383  print_int("code", err);
3384  print_str("string", av_err2str(err));
3386 }
3387 
3388 static int open_input_file(InputFile *ifile, const char *filename,
3389  const char *print_filename)
3390 {
3391  int err, i;
3393  const AVDictionaryEntry *t = NULL;
3394  int scan_all_pmts_set = 0;
3395 
3397  if (!fmt_ctx)
3398  return AVERROR(ENOMEM);
3399 
3400  if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
3401  av_dict_set(&format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
3402  scan_all_pmts_set = 1;
3403  }
3404  if ((err = avformat_open_input(&fmt_ctx, filename,
3405  iformat, &format_opts)) < 0) {
3406  print_error(filename, err);
3407  return err;
3408  }
3409  if (print_filename) {
3410  av_freep(&fmt_ctx->url);
3411  fmt_ctx->url = av_strdup(print_filename);
3412  }
3413  ifile->fmt_ctx = fmt_ctx;
3414  if (scan_all_pmts_set)
3415  av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
3416  while ((t = av_dict_iterate(format_opts, t)))
3417  av_log(NULL, AV_LOG_WARNING, "Option %s skipped - not known to demuxer.\n", t->key);
3418 
3419  if (find_stream_info) {
3420  AVDictionary **opts;
3421  int orig_nb_streams = fmt_ctx->nb_streams;
3422 
3424  if (err < 0)
3425  return err;
3426 
3428 
3429  for (i = 0; i < orig_nb_streams; i++)
3430  av_dict_free(&opts[i]);
3431  av_freep(&opts);
3432 
3433  if (err < 0) {
3434  print_error(filename, err);
3435  return err;
3436  }
3437  }
3438 
3439  av_dump_format(fmt_ctx, 0, filename, 0);
3440 
3441  ifile->streams = av_calloc(fmt_ctx->nb_streams, sizeof(*ifile->streams));
3442  if (!ifile->streams)
3443  exit(1);
3444  ifile->nb_streams = fmt_ctx->nb_streams;
3445 
3446  /* bind a decoder to each input stream */
3447  for (i = 0; i < fmt_ctx->nb_streams; i++) {
3448  InputStream *ist = &ifile->streams[i];
3449  AVStream *stream = fmt_ctx->streams[i];
3450  const AVCodec *codec;
3451 
3452  ist->st = stream;
3453 
3454  if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) {
3456  "Failed to probe codec for input stream %d\n",
3457  stream->index);
3458  continue;
3459  }
3460 
3461  codec = avcodec_find_decoder(stream->codecpar->codec_id);
3462  if (!codec) {
3464  "Unsupported codec with id %d for input stream %d\n",
3465  stream->codecpar->codec_id, stream->index);
3466  continue;
3467  }
3468  {
3469  AVDictionary *opts;
3470 
3472  fmt_ctx, stream, codec, &opts);
3473  if (err < 0)
3474  exit(1);
3475 
3476  ist->dec_ctx = avcodec_alloc_context3(codec);
3477  if (!ist->dec_ctx)
3478  exit(1);
3479 
3480  err = avcodec_parameters_to_context(ist->dec_ctx, stream->codecpar);
3481  if (err < 0)
3482  exit(1);
3483 
3484  if (do_show_log) {
3485  // For loging it is needed to disable at least frame threads as otherwise
3486  // the log information would need to be reordered and matches up to contexts and frames
3487  // That is in fact possible but not trivial
3488  av_dict_set(&codec_opts, "threads", "1", 0);
3489  }
3490 
3491  av_dict_set(&opts, "flags", "+copy_opaque", AV_DICT_MULTIKEY);
3492 
3493  ist->dec_ctx->pkt_timebase = stream->time_base;
3494 
3495  if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {
3496  av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n",
3497  stream->index);
3498  exit(1);
3499  }
3500 
3501  if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
3502  av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not found\n",
3503  t->key, stream->index);
3504  return AVERROR_OPTION_NOT_FOUND;
3505  }
3506  }
3507  }
3508 
3509  ifile->fmt_ctx = fmt_ctx;
3510  return 0;
3511 }
3512 
3513 static void close_input_file(InputFile *ifile)
3514 {
3515  int i;
3516 
3517  /* close decoder for each stream */
3518  for (i = 0; i < ifile->nb_streams; i++)
3520 
3521  av_freep(&ifile->streams);
3522  ifile->nb_streams = 0;
3523 
3524  avformat_close_input(&ifile->fmt_ctx);
3525 }
3526 
3527 static int probe_file(WriterContext *wctx, const char *filename,
3528  const char *print_filename)
3529 {
3530  InputFile ifile = { 0 };
3531  int ret, i;
3532  int section_id;
3533 
3536 
3537  ret = open_input_file(&ifile, filename, print_filename);
3538  if (ret < 0)
3539  goto end;
3540 
3541 #define CHECK_END if (ret < 0) goto end
3542 
3543  nb_streams = ifile.fmt_ctx->nb_streams;
3547 
3548  for (i = 0; i < ifile.fmt_ctx->nb_streams; i++) {
3549  if (stream_specifier) {
3551  ifile.fmt_ctx->streams[i],
3553  CHECK_END;
3554  else
3555  selected_streams[i] = ret;
3556  ret = 0;
3557  } else {
3558  selected_streams[i] = 1;
3559  }
3560  if (!selected_streams[i])
3561  ifile.fmt_ctx->streams[i]->discard = AVDISCARD_ALL;
3562  }
3563 
3567  section_id = SECTION_ID_PACKETS_AND_FRAMES;
3568  else if (do_show_packets && !do_show_frames)
3569  section_id = SECTION_ID_PACKETS;
3570  else // (!do_show_packets && do_show_frames)
3571  section_id = SECTION_ID_FRAMES;
3573  writer_print_section_header(wctx, NULL, section_id);
3574  ret = read_packets(wctx, &ifile);
3577  CHECK_END;
3578  }
3579 
3580  if (do_show_programs) {
3581  ret = show_programs(wctx, &ifile);
3582  CHECK_END;
3583  }
3584 
3585  if (do_show_streams) {
3586  ret = show_streams(wctx, &ifile);
3587  CHECK_END;
3588  }
3589  if (do_show_chapters) {
3590  ret = show_chapters(wctx, &ifile);
3591  CHECK_END;
3592  }
3593  if (do_show_format) {
3594  ret = show_format(wctx, &ifile);
3595  CHECK_END;
3596  }
3597 
3598 end:
3599  if (ifile.fmt_ctx)
3600  close_input_file(&ifile);
3604 
3605  return ret;
3606 }
3607 
3608 static void show_usage(void)
3609 {
3610  av_log(NULL, AV_LOG_INFO, "Simple multimedia streams analyzer\n");
3611  av_log(NULL, AV_LOG_INFO, "usage: %s [OPTIONS] INPUT_FILE\n", program_name);
3612  av_log(NULL, AV_LOG_INFO, "\n");
3613 }
3614 
3616 {
3617  AVBPrint pbuf;
3619 
3621  print_str("version", FFMPEG_VERSION);
3622  print_fmt("copyright", "Copyright (c) %d-%d the FFmpeg developers",
3623  program_birth_year, CONFIG_THIS_YEAR);
3624  print_str("compiler_ident", CC_IDENT);
3625  print_str("configuration", FFMPEG_CONFIGURATION);
3627 
3628  av_bprint_finalize(&pbuf, NULL);
3629 }
3630 
3631 #define SHOW_LIB_VERSION(libname, LIBNAME) \
3632  do { \
3633  if (CONFIG_##LIBNAME) { \
3634  unsigned int version = libname##_version(); \
3635  writer_print_section_header(w, NULL, SECTION_ID_LIBRARY_VERSION); \
3636  print_str("name", "lib" #libname); \
3637  print_int("major", LIB##LIBNAME##_VERSION_MAJOR); \
3638  print_int("minor", LIB##LIBNAME##_VERSION_MINOR); \
3639  print_int("micro", LIB##LIBNAME##_VERSION_MICRO); \
3640  print_int("version", version); \
3641  print_str("ident", LIB##LIBNAME##_IDENT); \
3642  writer_print_section_footer(w); \
3643  } \
3644  } while (0)
3645 
3647 {
3649  SHOW_LIB_VERSION(avutil, AVUTIL);
3650  SHOW_LIB_VERSION(avcodec, AVCODEC);
3651  SHOW_LIB_VERSION(avformat, AVFORMAT);
3652  SHOW_LIB_VERSION(avdevice, AVDEVICE);
3653  SHOW_LIB_VERSION(avfilter, AVFILTER);
3654  SHOW_LIB_VERSION(swscale, SWSCALE);
3655  SHOW_LIB_VERSION(swresample, SWRESAMPLE);
3656  SHOW_LIB_VERSION(postproc, POSTPROC);
3658 }
3659 
3660 #define PRINT_PIX_FMT_FLAG(flagname, name) \
3661  do { \
3662  print_int(name, !!(pixdesc->flags & AV_PIX_FMT_FLAG_##flagname)); \
3663  } while (0)
3664 
3666 {
3667  const AVPixFmtDescriptor *pixdesc = NULL;
3668  int i, n;
3669 
3671  while (pixdesc = av_pix_fmt_desc_next(pixdesc)) {
3673  print_str("name", pixdesc->name);
3674  print_int("nb_components", pixdesc->nb_components);
3675  if ((pixdesc->nb_components >= 3) && !(pixdesc->flags & AV_PIX_FMT_FLAG_RGB)) {
3676  print_int ("log2_chroma_w", pixdesc->log2_chroma_w);
3677  print_int ("log2_chroma_h", pixdesc->log2_chroma_h);
3678  } else {
3679  print_str_opt("log2_chroma_w", "N/A");
3680  print_str_opt("log2_chroma_h", "N/A");
3681  }
3682  n = av_get_bits_per_pixel(pixdesc);
3683  if (n) print_int ("bits_per_pixel", n);
3684  else print_str_opt("bits_per_pixel", "N/A");
3687  PRINT_PIX_FMT_FLAG(BE, "big_endian");
3688  PRINT_PIX_FMT_FLAG(PAL, "palette");
3689  PRINT_PIX_FMT_FLAG(BITSTREAM, "bitstream");
3690  PRINT_PIX_FMT_FLAG(HWACCEL, "hwaccel");
3691  PRINT_PIX_FMT_FLAG(PLANAR, "planar");
3692  PRINT_PIX_FMT_FLAG(RGB, "rgb");
3693  PRINT_PIX_FMT_FLAG(ALPHA, "alpha");
3695  }
3696  if (do_show_pixel_format_components && (pixdesc->nb_components > 0)) {
3698  for (i = 0; i < pixdesc->nb_components; i++) {
3700  print_int("index", i + 1);
3701  print_int("bit_depth", pixdesc->comp[i].depth);
3703  }
3705  }
3707  }
3709 }
3710 
3711 static int opt_show_optional_fields(void *optctx, const char *opt, const char *arg)
3712 {
3716 
3718  double num;
3719  int ret = parse_number("show_optional_fields", arg, OPT_INT,
3721  if (ret < 0)
3722  return ret;
3723  show_optional_fields = num;
3724  }
3725  return 0;
3726 }
3727 
3728 static int opt_format(void *optctx, const char *opt, const char *arg)
3729 {
3731  if (!iformat) {
3732  av_log(NULL, AV_LOG_ERROR, "Unknown input format: %s\n", arg);
3733  return AVERROR(EINVAL);
3734  }
3735  return 0;
3736 }
3737 
3738 static inline void mark_section_show_entries(SectionID section_id,
3739  int show_all_entries, AVDictionary *entries)
3740 {
3741  struct section *section = &sections[section_id];
3742 
3744  if (show_all_entries) {
3745  for (const SectionID *id = section->children_ids; *id != -1; id++)
3747  } else {
3748  av_dict_copy(&section->entries_to_show, entries, 0);
3749  }
3750 }
3751 
3752 static int match_section(const char *section_name,
3753  int show_all_entries, AVDictionary *entries)
3754 {
3755  int i, ret = 0;
3756 
3757  for (i = 0; i < FF_ARRAY_ELEMS(sections); i++) {
3758  const struct section *section = &sections[i];
3759  if (!strcmp(section_name, section->name) ||
3760  (section->unique_name && !strcmp(section_name, section->unique_name))) {
3762  "'%s' matches section with unique name '%s'\n", section_name,
3764  ret++;
3766  }
3767  }
3768  return ret;
3769 }
3770 
3771 static int opt_show_entries(void *optctx, const char *opt, const char *arg)
3772 {
3773  const char *p = arg;
3774  int ret = 0;
3775 
3776  while (*p) {
3777  AVDictionary *entries = NULL;
3778  char *section_name = av_get_token(&p, "=:");
3779  int show_all_entries = 0;
3780 
3781  if (!section_name) {
3783  "Missing section name for option '%s'\n", opt);
3784  return AVERROR(EINVAL);
3785  }
3786 
3787  if (*p == '=') {
3788  p++;
3789  while (*p && *p != ':') {
3790  char *entry = av_get_token(&p, ",:");
3791  if (!entry)
3792  break;
3794  "Adding '%s' to the entries to show in section '%s'\n",
3795  entry, section_name);
3796  av_dict_set(&entries, entry, "", AV_DICT_DONT_STRDUP_KEY);
3797  if (*p == ',')
3798  p++;
3799  }
3800  } else {
3801  show_all_entries = 1;
3802  }
3803 
3804  ret = match_section(section_name, show_all_entries, entries);
3805  if (ret == 0) {
3806  av_log(NULL, AV_LOG_ERROR, "No match for section '%s'\n", section_name);
3807  ret = AVERROR(EINVAL);
3808  }
3809  av_dict_free(&entries);
3810  av_free(section_name);
3811 
3812  if (ret <= 0)
3813  break;
3814  if (*p)
3815  p++;
3816  }
3817 
3818  return ret;
3819 }
3820 
3821 static int opt_input_file(void *optctx, const char *arg)
3822 {
3823  if (input_filename) {
3825  "Argument '%s' provided as input filename, but '%s' was already specified.\n",
3826  arg, input_filename);
3827  return AVERROR(EINVAL);
3828  }
3829  if (!strcmp(arg, "-"))
3830  arg = "fd:";
3831  input_filename = arg;
3832 
3833  return 0;
3834 }
3835 
3836 static int opt_input_file_i(void *optctx, const char *opt, const char *arg)
3837 {
3838  opt_input_file(optctx, arg);
3839  return 0;
3840 }
3841 
3842 static int opt_output_file_o(void *optctx, const char *opt, const char *arg)
3843 {
3844  if (output_filename) {
3846  "Argument '%s' provided as output filename, but '%s' was already specified.\n",
3847  arg, output_filename);
3848  return AVERROR(EINVAL);
3849  }
3850  if (!strcmp(arg, "-"))
3851  arg = "fd:";
3852  output_filename = arg;
3853 
3854  return 0;
3855 }
3856 
3857 static int opt_print_filename(void *optctx, const char *opt, const char *arg)
3858 {
3860  return 0;
3861 }
3862 
3863 void show_help_default(const char *opt, const char *arg)
3864 {
3866  show_usage();
3867  show_help_options(options, "Main options:", 0, 0, 0);
3868  printf("\n");
3869 
3872 }
3873 
3874 /**
3875  * Parse interval specification, according to the format:
3876  * INTERVAL ::= [START|+START_OFFSET][%[END|+END_OFFSET]]
3877  * INTERVALS ::= INTERVAL[,INTERVALS]
3878 */
3879 static int parse_read_interval(const char *interval_spec,
3880  ReadInterval *interval)
3881 {
3882  int ret = 0;
3883  char *next, *p, *spec = av_strdup(interval_spec);
3884  if (!spec)
3885  return AVERROR(ENOMEM);
3886 
3887  if (!*spec) {
3888  av_log(NULL, AV_LOG_ERROR, "Invalid empty interval specification\n");
3889  ret = AVERROR(EINVAL);
3890  goto end;
3891  }
3892 
3893  p = spec;
3894  next = strchr(spec, '%');
3895  if (next)
3896  *next++ = 0;
3897 
3898  /* parse first part */
3899  if (*p) {
3900  interval->has_start = 1;
3901 
3902  if (*p == '+') {
3903  interval->start_is_offset = 1;
3904  p++;
3905  } else {
3906  interval->start_is_offset = 0;
3907  }
3908 
3909  ret = av_parse_time(&interval->start, p, 1);
3910  if (ret < 0) {
3911  av_log(NULL, AV_LOG_ERROR, "Invalid interval start specification '%s'\n", p);
3912  goto end;
3913  }
3914  } else {
3915  interval->has_start = 0;
3916  }
3917 
3918  /* parse second part */
3919  p = next;
3920  if (p && *p) {
3921  int64_t us;
3922  interval->has_end = 1;
3923 
3924  if (*p == '+') {
3925  interval->end_is_offset = 1;
3926  p++;
3927  } else {
3928  interval->end_is_offset = 0;
3929  }
3930 
3931  if (interval->end_is_offset && *p == '#') {
3932  long long int lli;
3933  char *tail;
3934  interval->duration_frames = 1;
3935  p++;
3936  lli = strtoll(p, &tail, 10);
3937  if (*tail || lli < 0) {
3939  "Invalid or negative value '%s' for duration number of frames\n", p);
3940  goto end;
3941  }
3942  interval->end = lli;
3943  } else {
3944  interval->duration_frames = 0;
3945  ret = av_parse_time(&us, p, 1);
3946  if (ret < 0) {
3947  av_log(NULL, AV_LOG_ERROR, "Invalid interval end/duration specification '%s'\n", p);
3948  goto end;
3949  }
3950  interval->end = us;
3951  }
3952  } else {
3953  interval->has_end = 0;
3954  }
3955 
3956 end:
3957  av_free(spec);
3958  return ret;
3959 }
3960 
3961 static int parse_read_intervals(const char *intervals_spec)
3962 {
3963  int ret, n, i;
3964  char *p, *spec = av_strdup(intervals_spec);
3965  if (!spec)
3966  return AVERROR(ENOMEM);
3967 
3968  /* preparse specification, get number of intervals */
3969  for (n = 0, p = spec; *p; p++)
3970  if (*p == ',')
3971  n++;
3972  n++;
3973 
3975  if (!read_intervals) {
3976  ret = AVERROR(ENOMEM);
3977  goto end;
3978  }
3979  read_intervals_nb = n;
3980 
3981  /* parse intervals */
3982  p = spec;
3983  for (i = 0; p; i++) {
3984  char *next;
3985 
3987  next = strchr(p, ',');
3988  if (next)
3989  *next++ = 0;
3990 
3991  read_intervals[i].id = i;
3993  if (ret < 0) {
3994  av_log(NULL, AV_LOG_ERROR, "Error parsing read interval #%d '%s'\n",
3995  i, p);
3996  goto end;
3997  }
3998  av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval ");
4000  p = next;
4001  }
4003 
4004 end:
4005  av_free(spec);
4006  return ret;
4007 }
4008 
4009 static int opt_read_intervals(void *optctx, const char *opt, const char *arg)
4010 {
4011  return parse_read_intervals(arg);
4012 }
4013 
4014 static int opt_pretty(void *optctx, const char *opt, const char *arg)
4015 {
4016  show_value_unit = 1;
4017  use_value_prefix = 1;
4020  return 0;
4021 }
4022 
4023 static void print_section(SectionID id, int level)
4024 {
4025  const SectionID *pid;
4026  const struct section *section = &sections[id];
4027  printf("%c%c%c%c",
4028  section->flags & SECTION_FLAG_IS_WRAPPER ? 'W' : '.',
4029  section->flags & SECTION_FLAG_IS_ARRAY ? 'A' : '.',
4031  section->flags & SECTION_FLAG_HAS_TYPE ? 'T' : '.');
4032  printf("%*c %s", level * 4, ' ', section->name);
4033  if (section->unique_name)
4034  printf("/%s", section->unique_name);
4035  printf("\n");
4036 
4037  for (pid = section->children_ids; *pid != -1; pid++)
4038  print_section(*pid, level+1);
4039 }
4040 
4041 static int opt_sections(void *optctx, const char *opt, const char *arg)
4042 {
4043  printf("Sections:\n"
4044  "W... = Section is a wrapper (contains other sections, no local entries)\n"
4045  ".A.. = Section contains an array of elements of the same type\n"
4046  "..V. = Section may contain a variable number of fields with variable keys\n"
4047  "...T = Section contain a unique type\n"
4048  "FLAGS NAME/UNIQUE_NAME\n"
4049  "----\n");
4051  return 0;
4052 }
4053 
4054 static int opt_show_versions(void *optctx, const char *opt, const char *arg)
4055 {
4058  return 0;
4059 }
4060 
4061 #define DEFINE_OPT_SHOW_SECTION(section, target_section_id) \
4062  static int opt_show_##section(void *optctx, const char *opt, const char *arg) \
4063  { \
4064  mark_section_show_entries(SECTION_ID_##target_section_id, 1, NULL); \
4065  return 0; \
4066  }
4067 
4068 DEFINE_OPT_SHOW_SECTION(chapters, CHAPTERS)
4072 DEFINE_OPT_SHOW_SECTION(library_versions, LIBRARY_VERSIONS)
4073 DEFINE_OPT_SHOW_SECTION(packets, PACKETS)
4074 DEFINE_OPT_SHOW_SECTION(pixel_formats, PIXEL_FORMATS)
4075 DEFINE_OPT_SHOW_SECTION(program_version, PROGRAM_VERSION)
4076 DEFINE_OPT_SHOW_SECTION(streams, STREAMS)
4077 DEFINE_OPT_SHOW_SECTION(programs, PROGRAMS)
4078 
4079 static const OptionDef real_options[] = {
4081  { "f", HAS_ARG, {.func_arg = opt_format}, "force format", "format" },
4082  { "unit", OPT_BOOL, {&show_value_unit}, "show unit of the displayed values" },
4083  { "prefix", OPT_BOOL, {&use_value_prefix}, "use SI prefixes for the displayed values" },
4084  { "byte_binary_prefix", OPT_BOOL, {&use_byte_value_binary_prefix},
4085  "use binary prefixes for byte units" },
4086  { "sexagesimal", OPT_BOOL, {&use_value_sexagesimal_format},
4087  "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
4088  { "pretty", 0, {.func_arg = opt_pretty},
4089  "prettify the format of displayed values, make it more human readable" },
4090  { "output_format", OPT_STRING | HAS_ARG, { &output_format },
4091  "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)", "format" },
4092  { "print_format", OPT_STRING | HAS_ARG, { &output_format }, "alias for -output_format (deprecated)" },
4093  { "of", OPT_STRING | HAS_ARG, { &output_format }, "alias for -output_format", "format" },
4094  { "select_streams", OPT_STRING | HAS_ARG, { &stream_specifier }, "select the specified streams", "stream_specifier" },
4095  { "sections", OPT_EXIT, {.func_arg = opt_sections}, "print sections structure and section information, and exit" },
4096  { "show_data", OPT_BOOL, { &do_show_data }, "show packets data" },
4097  { "show_data_hash", OPT_STRING | HAS_ARG, { &show_data_hash }, "show packets data hash" },
4098  { "show_error", 0, { .func_arg = &opt_show_error }, "show probing error" },
4099  { "show_format", 0, { .func_arg = &opt_show_format }, "show format/container info" },
4100  { "show_frames", 0, { .func_arg = &opt_show_frames }, "show frames info" },
4101  { "show_entries", HAS_ARG, {.func_arg = opt_show_entries},
4102  "show a set of specified entries", "entry_list" },
4103 #if HAVE_THREADS
4104  { "show_log", OPT_INT|HAS_ARG, { &do_show_log }, "show log" },
4105 #endif
4106  { "show_packets", 0, { .func_arg = &opt_show_packets }, "show packets info" },
4107  { "show_programs", 0, { .func_arg = &opt_show_programs }, "show programs info" },
4108  { "show_streams", 0, { .func_arg = &opt_show_streams }, "show streams info" },
4109  { "show_chapters", 0, { .func_arg = &opt_show_chapters }, "show chapters info" },
4110  { "count_frames", OPT_BOOL, { &do_count_frames }, "count the number of frames per stream" },
4111  { "count_packets", OPT_BOOL, { &do_count_packets }, "count the number of packets per stream" },
4112  { "show_program_version", 0, { .func_arg = &opt_show_program_version }, "show ffprobe version" },
4113  { "show_library_versions", 0, { .func_arg = &opt_show_library_versions }, "show library versions" },
4114  { "show_versions", 0, { .func_arg = &opt_show_versions }, "show program and library versions" },
4115  { "show_pixel_formats", 0, { .func_arg = &opt_show_pixel_formats }, "show pixel format descriptions" },
4116  { "show_optional_fields", HAS_ARG, { .func_arg = &opt_show_optional_fields }, "show optional fields" },
4117  { "show_private_data", OPT_BOOL, { &show_private_data }, "show private data" },
4118  { "private", OPT_BOOL, { &show_private_data }, "same as show_private_data" },
4119  { "bitexact", OPT_BOOL, {&do_bitexact}, "force bitexact output" },
4120  { "read_intervals", HAS_ARG, {.func_arg = opt_read_intervals}, "set read intervals", "read_intervals" },
4121  { "i", HAS_ARG, {.func_arg = opt_input_file_i}, "read specified file", "input_file"},
4122  { "o", HAS_ARG, {.func_arg = opt_output_file_o}, "write to specified output", "output_file"},
4123  { "print_filename", HAS_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
4124  { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info },
4125  "read and decode the streams to fill missing information with heuristics" },
4126  { NULL, },
4127 };
4128 
4129 static inline int check_section_show_entries(int section_id)
4130 {
4131  struct section *section = &sections[section_id];
4132  if (sections[section_id].show_all_entries || sections[section_id].entries_to_show)
4133  return 1;
4134  for (const SectionID *id = section->children_ids; *id != -1; id++)
4135  if (check_section_show_entries(*id))
4136  return 1;
4137  return 0;
4138 }
4139 
4140 #define SET_DO_SHOW(id, varname) do { \
4141  if (check_section_show_entries(SECTION_ID_##id)) \
4142  do_show_##varname = 1; \
4143  } while (0)
4144 
4145 int main(int argc, char **argv)
4146 {
4147  const Writer *w;
4148  WriterContext *wctx;
4149  char *buf;
4150  char *w_name = NULL, *w_args = NULL;
4151  int ret, input_ret, i;
4152 
4153  init_dynload();
4154 
4155 #if HAVE_THREADS
4156  ret = pthread_mutex_init(&log_mutex, NULL);
4157  if (ret != 0) {
4158  goto end;
4159  }
4160 #endif
4162 
4164  parse_loglevel(argc, argv, options);
4166 #if CONFIG_AVDEVICE
4168 #endif
4169 
4170  show_banner(argc, argv, options);
4171  ret = parse_options(NULL, argc, argv, options, opt_input_file);
4172  if (ret < 0) {
4173  ret = (ret == AVERROR_EXIT) ? 0 : ret;
4174  goto end;
4175  }
4176 
4177  if (do_show_log)
4179 
4180  /* mark things to show, based on -show_entries */
4181  SET_DO_SHOW(CHAPTERS, chapters);
4183  SET_DO_SHOW(FORMAT, format);
4184  SET_DO_SHOW(FRAMES, frames);
4185  SET_DO_SHOW(LIBRARY_VERSIONS, library_versions);
4186  SET_DO_SHOW(PACKETS, packets);
4187  SET_DO_SHOW(PIXEL_FORMATS, pixel_formats);
4188  SET_DO_SHOW(PIXEL_FORMAT_FLAGS, pixel_format_flags);
4189  SET_DO_SHOW(PIXEL_FORMAT_COMPONENTS, pixel_format_components);
4190  SET_DO_SHOW(PROGRAM_VERSION, program_version);
4191  SET_DO_SHOW(PROGRAMS, programs);
4192  SET_DO_SHOW(STREAMS, streams);
4193  SET_DO_SHOW(STREAM_DISPOSITION, stream_disposition);
4194  SET_DO_SHOW(PROGRAM_STREAM_DISPOSITION, stream_disposition);
4195 
4196  SET_DO_SHOW(CHAPTER_TAGS, chapter_tags);
4197  SET_DO_SHOW(FORMAT_TAGS, format_tags);
4198  SET_DO_SHOW(FRAME_TAGS, frame_tags);
4199  SET_DO_SHOW(PROGRAM_TAGS, program_tags);
4200  SET_DO_SHOW(STREAM_TAGS, stream_tags);
4201  SET_DO_SHOW(PROGRAM_STREAM_TAGS, stream_tags);
4202  SET_DO_SHOW(PACKET_TAGS, packet_tags);
4203 
4206  "-bitexact and -show_program_version or -show_library_versions "
4207  "options are incompatible\n");
4208  ret = AVERROR(EINVAL);
4209  goto end;
4210  }
4211 
4213 
4214  if (!output_format)
4215  output_format = av_strdup("default");
4216  if (!output_format) {
4217  ret = AVERROR(ENOMEM);
4218  goto end;
4219  }
4220  w_name = av_strtok(output_format, "=", &buf);
4221  if (!w_name) {
4223  "No name specified for the output format\n");
4224  ret = AVERROR(EINVAL);
4225  goto end;
4226  }
4227  w_args = buf;
4228 
4229  if (show_data_hash) {
4230  if ((ret = av_hash_alloc(&hash, show_data_hash)) < 0) {
4231  if (ret == AVERROR(EINVAL)) {
4232  const char *n;
4234  "Unknown hash algorithm '%s'\nKnown algorithms:",
4235  show_data_hash);
4236  for (i = 0; (n = av_hash_names(i)); i++)
4237  av_log(NULL, AV_LOG_ERROR, " %s", n);
4238  av_log(NULL, AV_LOG_ERROR, "\n");
4239  }
4240  goto end;
4241  }
4242  }
4243 
4244  w = writer_get_by_name(w_name);
4245  if (!w) {
4246  av_log(NULL, AV_LOG_ERROR, "Unknown output format with name '%s'\n", w_name);
4247  ret = AVERROR(EINVAL);
4248  goto end;
4249  }
4250 
4251  if ((ret = writer_open(&wctx, w, w_args,
4253  if (w == &xml_writer)
4255 
4257 
4264 
4265  if (!input_filename &&
4268  show_usage();
4269  av_log(NULL, AV_LOG_ERROR, "You have to specify one input file.\n");
4270  av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
4271  ret = AVERROR(EINVAL);
4272  } else if (input_filename) {
4274  if (ret < 0 && do_show_error)
4275  show_error(wctx, ret);
4276  }
4277 
4278  input_ret = ret;
4279 
4281  ret = writer_close(&wctx);
4282  if (ret < 0)
4283  av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", av_err2str(ret));
4284 
4285  ret = FFMIN(ret, input_ret);
4286  }
4287 
4288 end:
4291  av_hash_freep(&hash);
4292 
4293  uninit_opts();
4294  for (i = 0; i < FF_ARRAY_ELEMS(sections); i++)
4296 
4298 
4299 #if HAVE_THREADS
4300  pthread_mutex_destroy(&log_mutex);
4301 #endif
4302 
4303  return ret < 0;
4304 }
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:31
flat_escape_key_str
static const char * flat_escape_key_str(AVBPrint *dst, const char *src, const char sep)
Definition: ffprobe.c:1393
main
int main(int argc, char **argv)
Definition: ffprobe.c:4145
AVSubtitle
Definition: avcodec.h:2269
SECTION_ID_STREAM_SIDE_DATA_LIST
@ SECTION_ID_STREAM_SIDE_DATA_LIST
Definition: ffprobe.c:211
opt_format
static int opt_format(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3728
AVHDRVividColorTransformParams::maximum_maxrgb
AVRational maximum_maxrgb
Indicates the maximum brightness of the displayed content.
Definition: hdr_dynamic_vivid_metadata.h:260
pthread_mutex_t
_fmutex pthread_mutex_t
Definition: os2threads.h:53
AVFrame::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: frame.h:660
clear_log
static void clear_log(int need_lock)
Definition: ffprobe.c:2493
AVMasteringDisplayMetadata::has_primaries
int has_primaries
Flag indicating whether the display primaries (and white point) are set.
Definition: mastering_display_metadata.h:62
AVHDRPlusColorTransformParams::average_maxrgb
AVRational average_maxrgb
The average of linearized maxRGB values in the processing window in the scene.
Definition: hdr_dynamic_metadata.h:164
mark_section_show_entries
static void mark_section_show_entries(SectionID section_id, int show_all_entries, AVDictionary *entries)
Definition: ffprobe.c:3738
AV_PKT_DATA_DISPLAYMATRIX
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: packet.h:109
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:423
OPT_EXIT
#define OPT_EXIT
Definition: cmdutils.h:119
AVCodec
AVCodec.
Definition: codec.h:187
writer_get_by_name
static const Writer * writer_get_by_name(const char *name)
Definition: ffprobe.c:1002
av_utf8_decode
int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end, unsigned int flags)
Read and decode a single UTF-8 code point (character) from the buffer in *buf, and update *buf to poi...
Definition: avstring.c:368
AVDynamicHDRPlus::params
AVHDRPlusColorTransformParams params[3]
The color transform parameters for every processing window.
Definition: hdr_dynamic_metadata.h:264
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
flat_options
static const AVOption flat_options[]
Definition: ffprobe.c:1369
WriterContext::section_pbuf
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]
generic print buffer dedicated to each section, used by various writers
Definition: ffprobe.c:509
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVFrame::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:656
AV_BPRINT_SIZE_UNLIMITED
#define AV_BPRINT_SIZE_UNLIMITED
AV_TIMECODE_STR_SIZE
#define AV_TIMECODE_STR_SIZE
Definition: timecode.h:33
AVDOVIDataMapping::nlq_method_idc
enum AVDOVINLQMethod nlq_method_idc
Definition: dovi_meta.h:146
use_byte_value_binary_prefix
static int use_byte_value_binary_prefix
Definition: ffprobe.c:134
WriterContext::level
int level
current level, starting from 0
Definition: ffprobe.c:502
WriterContext::string_validation
int string_validation
Definition: ffprobe.c:516
AVMasteringDisplayMetadata::max_luminance
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:57
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:69
MAX_REGISTERED_WRITERS_NB
#define MAX_REGISTERED_WRITERS_NB
Definition: ffprobe.c:987
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
AVHDRVividColorToneMappingParams::base_param_k2
int base_param_k2
indicates k2_0 in the base parameter, base_param_k2 <= 1: k2_0 = base_param_k2 base_param_k2 > 1: res...
Definition: hdr_dynamic_vivid_metadata.h:137
level
uint8_t level
Definition: svq3.c:204
do_show_log
static int do_show_log
Definition: ffprobe.c:123
program
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C program
Definition: undefined.txt:6
av_clip
#define av_clip
Definition: common.h:96
InputFile::fmt_ctx
AVFormatContext * fmt_ctx
Definition: ffprobe.c:95
dec_ctx
static AVCodecContext * dec_ctx
Definition: decode_filter_audio.c:46
SECTION_MAX_NB_LEVELS
#define SECTION_MAX_NB_LEVELS
Definition: ffprobe.c:485
SECTION_ID_STREAM_SIDE_DATA
@ SECTION_ID_STREAM_SIDE_DATA
Definition: ffprobe.c:212
do_show_frame_tags
static int do_show_frame_tags
Definition: ffprobe.c:127
PLANAR
#define PLANAR
Definition: flacdsp.c:42
AVChapter::metadata
AVDictionary * metadata
Definition: avformat.h:1078
r
const char * r
Definition: vf_curves.c:126
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt_show_optional_fields
static int opt_show_optional_fields(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3711
SECTION_ID_NONE
@ SECTION_ID_NONE
Definition: ffprobe.c:165
opt.h
FrameData::pkt_pos
int64_t pkt_pos
Definition: ffplay.c:150
read_intervals_nb
static int read_intervals_nb
Definition: ffprobe.c:156
opt_output_file_o
static int opt_output_file_o(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3842
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
AVFMT_SHOW_IDS
#define AVFMT_SHOW_IDS
Show format stream IDs numbers.
Definition: avformat.h:478
AVSphericalMapping::projection
enum AVSphericalProjection projection
Projection type.
Definition: spherical.h:82
xml_print_value
static void xml_print_value(WriterContext *wctx, const char *key, const void *value, const int is_int)
Definition: ffprobe.c:1861
av_opt_set_defaults
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1459
ReadInterval::end_is_offset
int end_is_offset
Definition: ffprobe.c:151
LogBuffer::log_message
char * log_message
Definition: ffprobe.c:339
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:570
libm.h
FrameData
Definition: ffmpeg.h:636
AVHDRVividColorToneMappingParams::base_param_Delta
AVRational base_param_Delta
base_param_Delta in the base parameter, in multiples of 1.0/127.
Definition: hdr_dynamic_vivid_metadata.h:157
show_streams
static int show_streams(WriterContext *w, InputFile *ifile)
Definition: ffprobe.c:3258
avio_close
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
Definition: aviobuf.c:1271
Writer::name
const char * name
Definition: ffprobe.c:472
writer_put_str_printf
static void writer_put_str_printf(WriterContext *wctx, const char *str)
Definition: ffprobe.c:614
AVHDRVividColorToneMappingParams::base_enable_flag
int base_enable_flag
This flag indicates that transfer the base paramter(for value of 1)
Definition: hdr_dynamic_vivid_metadata.h:88
print_str
#define print_str(k, v)
Definition: ffprobe.c:1959
LogBuffer::context_name
char * context_name
Definition: ffprobe.c:337
color
Definition: vf_paletteuse.c:511
av_bprint_init
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:69
AV_HASH_MAX_SIZE
#define AV_HASH_MAX_SIZE
Maximum value that av_hash_get_size() will currently return.
Definition: hash.h:156
AVHDRPlusColorTransformParams::rotation_angle
uint8_t rotation_angle
The clockwise rotation angle in degree of arc with respect to the positive direction of the x-axis of...
Definition: hdr_dynamic_metadata.h:118
print_val
#define print_val(k, v, u)
Definition: ffprobe.c:1966
compact_print_section_footer
static void compact_print_section_footer(WriterContext *wctx)
Definition: ffprobe.c:1281
SECTION_ID_PACKET_SIDE_DATA_LIST
@ SECTION_ID_PACKET_SIDE_DATA_LIST
Definition: ffprobe.c:191
AVFormatContext::nb_chapters
unsigned int nb_chapters
Number of chapters in AVChapter array.
Definition: avformat.h:1332
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:47
AVHDRPlusPercentile::percentile
AVRational percentile
The linearized maxRGB value at a specific percentile in the processing window in the scene.
Definition: hdr_dynamic_metadata.h:52
AVCodec::priv_class
const AVClass * priv_class
AVClass for the private context.
Definition: codec.h:219
AVAmbientViewingEnvironment
Ambient viewing environment metadata as defined by H.274.
Definition: ambient_viewing_environment.h:36
show_stream
static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program)
Definition: ffprobe.c:3035
AVCodecParameters::color_space
enum AVColorSpace color_space
Definition: codec_par.h:144
AVFrame::duration
int64_t duration
Duration of the frame, in the same units as pts.
Definition: frame.h:807
Writer::init
int(* init)(WriterContext *wctx)
Definition: ffprobe.c:474
thread.h
value_string
static char * value_string(char *buf, int buf_size, struct unit_value uv)
Definition: ffprobe.c:402
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
read_packets
static int read_packets(WriterContext *w, InputFile *ifile)
Definition: ffprobe.c:3015
AVStream::discard
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:912
AV_FIELD_PROGRESSIVE
@ AV_FIELD_PROGRESSIVE
Definition: defs.h:200
pthread_mutex_init
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Definition: os2threads.h:104
AVFrame::nb_side_data
int nb_side_data
Definition: frame.h:611
AV_PKT_DATA_MASTERING_DISPLAY_METADATA
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition: packet.h:223
AVCodecDescriptor::long_name
const char * long_name
A more descriptive name for this codec.
Definition: codec_desc.h:50
AVMasteringDisplayMetadata::display_primaries
AVRational display_primaries[3][2]
CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
Definition: mastering_display_metadata.h:42
show_packet
static void show_packet(WriterContext *w, InputFile *ifile, AVPacket *pkt, int packet_idx)
Definition: ffprobe.c:2544
AV_PKT_FLAG_DISCARD
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
Definition: packet.h:553
CompactContext::print_section
int print_section
Definition: ffprobe.c:1182
AVMasteringDisplayMetadata::has_luminance
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
Definition: mastering_display_metadata.h:67
version.h
AVHDRVividColorToneMappingParams::three_Spline_num
int three_Spline_num
The number of three Spline.
Definition: hdr_dynamic_vivid_metadata.h:169
AV_FRAME_DATA_DOVI_METADATA
@ AV_FRAME_DATA_DOVI_METADATA
Parsed Dolby Vision metadata, suitable for passing to a software implementation.
Definition: frame.h:204
InputStream::dec_ctx
AVCodecContext * dec_ctx
Definition: ffmpeg.h:344
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:264
Writer::print_section_footer
void(* print_section_footer)(WriterContext *wctx)
Definition: ffprobe.c:478
AVCodecDescriptor::name
const char * name
Name of the codec described by this descriptor.
Definition: codec_desc.h:46
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
selected_streams
static int * selected_streams
Definition: ffprobe.c:331
SECTION_ID_PROGRAM_TAGS
@ SECTION_ID_PROGRAM_TAGS
Definition: ffprobe.c:203
AVSubtitle::num_rects
unsigned num_rects
Definition: avcodec.h:2273
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:207
AVHDRPlusColorTransformParams::semimajor_axis_external_ellipse
uint16_t semimajor_axis_external_ellipse
The semi-major axis value of the external ellipse of the elliptical pixel selector in amount of pixel...
Definition: hdr_dynamic_metadata.h:134
avformat_get_class
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:205
AVFrame::color_primaries
enum AVColorPrimaries color_primaries
Definition: frame.h:658
AV_FRAME_DATA_S12M_TIMECODE
@ AV_FRAME_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1.
Definition: frame.h:152
DefaultContext
Definition: ffprobe.c:1029
AVHDRVividColorTransformParams::tone_mapping_param_num
int tone_mapping_param_num
The number of tone mapping param.
Definition: hdr_dynamic_vivid_metadata.h:272
Writer::priv_class
const AVClass * priv_class
private class of the writer, if any
Definition: ffprobe.c:470
AVHDRPlusColorTransformParams
Color transform parameters at a processing window in a dynamic metadata for SMPTE 2094-40.
Definition: hdr_dynamic_metadata.h:59
AV_RN16
#define AV_RN16(p)
Definition: intreadwrite.h:358
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:100
AVContentLightMetadata::MaxCLL
unsigned MaxCLL
Max content light level (cd/m^2).
Definition: mastering_display_metadata.h:102
WriterContext::section
const struct section * section[SECTION_MAX_NB_LEVELS]
section per each level
Definition: ffprobe.c:508
json_escape_str
static const char * json_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
Definition: ffprobe.c:1615
print_ts
#define print_ts(k, v)
Definition: ffprobe.c:1963
AVFrame::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:667
opt_input_file_i
static int opt_input_file_i(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3836
WriterContext::nb_section_packet_frame
unsigned int nb_section_packet_frame
nb_section_packet or nb_section_frame according if is_packets_and_frames
Definition: ffprobe.c:514
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
pixdesc.h
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1183
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:452
AVFrame::width
int width
Definition: frame.h:412
writer_put_str
#define writer_put_str(wctx_, str_)
Definition: ffprobe.c:984
AVPacketSideData
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition: packet.h:342
w
uint8_t w
Definition: llviddspenc.c:38
validate_string
static int validate_string(WriterContext *wctx, char **dstp, const char *src)
Definition: ffprobe.c:783
OPT_INPUT
#define OPT_INPUT
Definition: cmdutils.h:126
AVHDRVividColorTransformParams::variance_maxrgb
AVRational variance_maxrgb
Indicates the variance brightness of the displayed content.
Definition: hdr_dynamic_vivid_metadata.h:253
AVDOVIReshapingCurve::mmr_coef
int64_t mmr_coef[AV_DOVI_MAX_PIECES][3][7]
Definition: dovi_meta.h:114
SECTION_ID_FRAME_SIDE_DATA_COMPONENT
@ SECTION_ID_FRAME_SIDE_DATA_COMPONENT
Definition: ffprobe.c:180
SECTION_ID_PIXEL_FORMAT_COMPONENTS
@ SECTION_ID_PIXEL_FORMAT_COMPONENTS
Definition: ffprobe.c:196
AVDynamicHDRPlus::num_cols_targeted_system_display_actual_peak_luminance
uint8_t num_cols_targeted_system_display_actual_peak_luminance
The number of columns in the targeted_system_display_actual_peak_luminance array.
Definition: hdr_dynamic_metadata.h:290
AVPacket::data
uint8_t * data
Definition: packet.h:491
ReadInterval::duration_frames
int duration_frames
Definition: ffprobe.c:152
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:57
av_spherical_tile_bounds
void av_spherical_tile_bounds(const AVSphericalMapping *map, size_t width, size_t height, size_t *left, size_t *top, size_t *right, size_t *bottom)
Convert the bounding fields from an AVSphericalVideo from 0.32 fixed point to pixels.
Definition: spherical.c:38
AVPixFmtDescriptor::name
const char * name
Definition: pixdesc.h:70
AVAmbientViewingEnvironment::ambient_light_x
AVRational ambient_light_x
Normalized x chromaticity coordinate of the environmental ambient light in the nominal viewing enviro...
Definition: ambient_viewing_environment.h:47
AVHDRVivid3SplineParams::enable_strength
AVRational enable_strength
3Spline_enable_Strength of three Spline.
Definition: hdr_dynamic_vivid_metadata.h:70
AVOption
AVOption.
Definition: opt.h:251
HAS_ARG
#define HAS_ARG
Definition: cmdutils.h:109
b
#define b
Definition: input.c:41
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:573
SECTION_ID_STREAM
@ SECTION_ID_STREAM
Definition: ffprobe.c:207
section::element_name
const char * element_name
name of the contained element, if provided
Definition: ffprobe.c:228
SECTION_ID_PIXEL_FORMAT_FLAGS
@ SECTION_ID_PIXEL_FORMAT_FLAGS
Definition: ffprobe.c:194
LogBuffer
Definition: ffprobe.c:336
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:930
spherical.h
AVChapter::start
int64_t start
Definition: avformat.h:1077
data
const char data[16]
Definition: mxf.c:148
av_pix_fmt_desc_next
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
Definition: pixdesc.c:2971
print_dovi_metadata
static void print_dovi_metadata(WriterContext *w, const AVDOVIMetadata *dovi)
Definition: ffprobe.c:2003
format_opts
AVDictionary * format_opts
Definition: cmdutils.c:60
AV_DOVI_NLQ_NONE
@ AV_DOVI_NLQ_NONE
Definition: dovi_meta.h:118
writer_print_integer
static void writer_print_integer(WriterContext *wctx, const char *key, long long int val)
Definition: ffprobe.c:772
PRINT_DISPOSITION
#define PRINT_DISPOSITION(flagname, name)
XMLContext::within_tag
int within_tag
Definition: ffprobe.c:1756
SECTION_MAX_NB_CHILDREN
#define SECTION_MAX_NB_CHILDREN
Definition: ffprobe.c:162
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:75
do_show_stream_tags
static int do_show_stream_tags
Definition: ffprobe.c:129
ini_escape_str
static char * ini_escape_str(AVBPrint *dst, const char *src)
Definition: ffprobe.c:1499
AVDOVIReshapingCurve::mapping_idc
enum AVDOVIMappingMethod mapping_idc[AV_DOVI_MAX_PIECES]
Definition: dovi_meta.h:107
print_section_header
#define print_section_header(s)
Definition: ffprobe.c:1973
SECTION_ID_PIXEL_FORMAT
@ SECTION_ID_PIXEL_FORMAT
Definition: ffprobe.c:193
writer_printf_printf
static void writer_printf_printf(WriterContext *wctx, const char *fmt,...)
Definition: ffprobe.c:619
version.h
AVHDRPlusColorTransformParams::tone_mapping_flag
uint8_t tone_mapping_flag
This flag indicates that the metadata for the tone mapping function in the processing window is prese...
Definition: hdr_dynamic_metadata.h:189
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
SECTION_ID_PROGRAM_STREAM
@ SECTION_ID_PROGRAM_STREAM
Definition: ffprobe.c:202
AV_NOWARN_DEPRECATED
#define AV_NOWARN_DEPRECATED(code)
Disable warnings about deprecated features This is useful for sections of code kept for backward comp...
Definition: attributes.h:126
category
category
Definition: openal-dec.c:248
AVFormatContext::programs
AVProgram ** programs
Definition: avformat.h:1283
OFFSET
#define OFFSET(x)
Definition: ffprobe.c:1763
SECTION_ID_FORMAT
@ SECTION_ID_FORMAT
Definition: ffprobe.c:170
show_help_children
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
Definition: cmdutils.c:138
AVOption::flags
int flags
Definition: opt.h:280
AV_FRAME_DATA_DISPLAYMATRIX
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: frame.h:85
av_get_bits_per_pixel
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
Definition: pixdesc.c:2916
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:509
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:59
AV_SPHERICAL_EQUIRECTANGULAR_TILE
@ AV_SPHERICAL_EQUIRECTANGULAR_TILE
Video represents a portion of a sphere mapped on a flat surface using equirectangular projection.
Definition: spherical.h:68
check_section_show_entries
static int check_section_show_entries(int section_id)
Definition: ffprobe.c:4129
print_section
static void print_section(SectionID id, int level)
Definition: ffprobe.c:4023
AVHDRVivid3SplineParams::th_mode
int th_mode
The mode of three Spline.
Definition: hdr_dynamic_vivid_metadata.h:35
section::id
int id
unique id identifying a section
Definition: ffprobe.c:217
AVHDRPlusColorTransformParams::distribution_maxrgb
AVHDRPlusPercentile distribution_maxrgb[15]
The linearized maxRGB values at given percentiles in the processing window in the scene.
Definition: hdr_dynamic_metadata.h:176
AVDictionary
Definition: dict.c:34
writer_options
static const AVOption writer_options[]
Definition: ffprobe.c:529
AVFrame::flags
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:649
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:312
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:545
AVDOVIRpuDataHeader::rpu_format
uint16_t rpu_format
Definition: dovi_meta.h:78
DefaultContext::nokey
int nokey
Definition: ffprobe.c:1031
avcodec_profile_name
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
Definition: utils.c:450
av_read_frame
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: demux.c:1462
writer_register_all
static void writer_register_all(void)
Definition: ffprobe.c:1922
AVDOVIDataMapping::mapping_color_space
uint8_t mapping_color_space
Definition: dovi_meta.h:141
ALPHA
@ ALPHA
Definition: drawutils.c:33
CompactContext
Definition: ffprobe.c:1177
AVDOVIRpuDataHeader
Dolby Vision RPU data header.
Definition: dovi_meta.h:76
AVHDRPlusColorTransformParams::knee_point_x
AVRational knee_point_x
The x coordinate of the separation point between the linear part and the curved part of the tone mapp...
Definition: hdr_dynamic_metadata.h:196
output_filename
static const char * output_filename
Definition: ffprobe.c:305
AVHDRVividColorTransformParams::color_saturation_num
int color_saturation_num
The number of color saturation param.
Definition: hdr_dynamic_vivid_metadata.h:289
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:317
dec_val
double dec_val
Definition: ffprobe.c:311
show_tags
static int show_tags(WriterContext *w, AVDictionary *tags, int section_id)
Definition: ffprobe.c:1985
AV_RL8
#define AV_RL8(x)
Definition: intreadwrite.h:396
avio_size
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:370
av_strlcatf
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:103
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:546
do_show_format_tags
static int do_show_format_tags
Definition: ffprobe.c:126
av_packet_free
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:74
av_chroma_location_name
const char * av_chroma_location_name(enum AVChromaLocation location)
Definition: pixdesc.c:3361
hdr_dynamic_vivid_metadata.h
section::unique_name
const char * unique_name
unique section name, in case the name is ambiguous
Definition: ffprobe.c:229
Writer::print_string
void(* print_string)(WriterContext *wctx, const char *, const char *)
Definition: ffprobe.c:481
do_show_frames
static int do_show_frames
Definition: ffprobe.c:112
json_print_int
static void json_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1723
OptionDef
Definition: cmdutils.h:106
AV_FIELD_BT
@ AV_FIELD_BT
Bottom coded first, top displayed first.
Definition: defs.h:204
compact_init
static av_cold int compact_init(WriterContext *wctx)
Definition: ffprobe.c:1207
AVInputFormat::long_name
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:561
AV_FRAME_FLAG_TOP_FIELD_FIRST
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
Definition: frame.h:641
xml_print_section_footer
static void xml_print_section_footer(WriterContext *wctx)
Definition: ffprobe.c:1844
SECTION_ID_FRAME_TAGS
@ SECTION_ID_FRAME_TAGS
Definition: ffprobe.c:174
ReadInterval::id
int id
identifier
Definition: ffprobe.c:148
AVFrame::opaque_ref
AVBufferRef * opaque_ref
Frame owner's private data.
Definition: frame.h:768
AVContentLightMetadata
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
Definition: mastering_display_metadata.h:98
AV_PKT_DATA_DOVI_CONF
@ AV_PKT_DATA_DOVI_CONF
DOVI configuration ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2....
Definition: packet.h:284
AVDOVIRpuDataHeader::coef_data_type
uint8_t coef_data_type
Definition: dovi_meta.h:82
do_show_library_versions
static int do_show_library_versions
Definition: ffprobe.c:119
process_frame
static av_always_inline int process_frame(WriterContext *w, InputFile *ifile, AVFrame *frame, const AVPacket *pkt, int *packet_new)
Definition: ffprobe.c:2805
AVCodecParameters::color_primaries
enum AVColorPrimaries color_primaries
Definition: codec_par.h:142
InputStream
Definition: ffmpeg.h:324
writer_print_data
static void writer_print_data(WriterContext *wctx, const char *name, const uint8_t *data, int size)
Definition: ffprobe.c:914
avformat_close_input
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: demux.c:374
AVFrame::chroma_location
enum AVChromaLocation chroma_location
Definition: frame.h:669
match_section
static int match_section(const char *section_name, int show_all_entries, AVDictionary *entries)
Definition: ffprobe.c:3752
SECTION_FLAG_HAS_TYPE
#define SECTION_FLAG_HAS_TYPE
For these sections the element_name field is mandatory.
Definition: ffprobe.c:224
AVHDRPlusColorTransformParams::color_saturation_mapping_flag
uint8_t color_saturation_mapping_flag
This flag shall be equal to 0 in bitstreams conforming to this version of this Specification.
Definition: hdr_dynamic_metadata.h:222
INIContext
Definition: ffprobe.c:1483
unit_hertz_str
static const char unit_hertz_str[]
Definition: ffprobe.c:324
AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES
#define AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES
exclude control codes not accepted by XML
Definition: avstring.h:374
AV_FIELD_TT
@ AV_FIELD_TT
Top coded_first, top displayed first.
Definition: defs.h:201
writer_close
static int writer_close(WriterContext **wctx)
Definition: ffprobe.c:558
SHOW_OPTIONAL_FIELDS_NEVER
#define SHOW_OPTIONAL_FIELDS_NEVER
Definition: ffprobe.c:139
SECTION_ID_STREAMS
@ SECTION_ID_STREAMS
Definition: ffprobe.c:209
print_error
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
Definition: cmdutils.c:829
AVHDRVividColorToneMappingParams::three_Spline_enable_flag
int three_Spline_enable_flag
indicates 3Spline_enable_flag in the base parameter, This flag indicates that transfer three Spline o...
Definition: hdr_dynamic_vivid_metadata.h:163
writer_print_data_hash
static void writer_print_data_hash(WriterContext *wctx, const char *name, const uint8_t *data, int size)
Definition: ffprobe.c:942
show_optional_fields
static int show_optional_fields
Definition: ffprobe.c:141
json_print_section_footer
static void json_print_section_footer(WriterContext *wctx)
Definition: ffprobe.c:1676
av_color_space_name
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:3340
AVHDRPlusColorTransformParams::center_of_ellipse_x
uint16_t center_of_ellipse_x
The x coordinate of the center position of the concentric internal and external ellipses of the ellip...
Definition: hdr_dynamic_metadata.h:102
opt_pretty
static int opt_pretty(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:4014
AVCodecContext::codec
const struct AVCodec * codec
Definition: avcodec.h:450
AVPacket::opaque_ref
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
Definition: packet.h:527
json_options
static const AVOption json_options[]
Definition: ffprobe.c:1597
default_options
static const AVOption default_options[]
Definition: ffprobe.c:1039
fail
#define fail()
Definition: checkasm.h:138
writer_get_name
static const char * writer_get_name(void *p)
Definition: ffprobe.c:521
AVHDRVividColorTransformParams::tm_params
AVHDRVividColorToneMappingParams tm_params[2]
The color tone mapping parameters.
Definition: hdr_dynamic_vivid_metadata.h:277
av_hash_get_name
const char * av_hash_get_name(const AVHashContext *ctx)
Definition: hash.c:94
LogBuffer::log_level
int log_level
Definition: ffprobe.c:338
print_chroma_location
static void print_chroma_location(WriterContext *w, enum AVChromaLocation chroma_location)
Definition: ffprobe.c:2483
AVDOVIRpuDataHeader::el_bit_depth
uint8_t el_bit_depth
Definition: dovi_meta.h:87
AVHDRVivid3SplineParams::th_delta1
AVRational th_delta1
3Spline_TH_Delta1 of three Spline.
Definition: hdr_dynamic_vivid_metadata.h:56
Writer::uninit
void(* uninit)(WriterContext *wctx)
Definition: ffprobe.c:475
frames
if it could not because there are no more frames
Definition: filter_design.txt:266
timecode.h
SECTION_FLAG_HAS_VARIABLE_FIELDS
#define SECTION_FLAG_HAS_VARIABLE_FIELDS
the section may contain a variable number of fields with variable keys.
Definition: ffprobe.c:222
json_writer
static const Writer json_writer
Definition: ffprobe.c:1740
AVCodecContext::refs
int refs
number of reference frames
Definition: avcodec.h:1001
AVERROR_OPTION_NOT_FOUND
#define AVERROR_OPTION_NOT_FOUND
Option not found.
Definition: error.h:63
AVDynamicHDRVivid::num_windows
uint8_t num_windows
The number of processing windows.
Definition: hdr_dynamic_vivid_metadata.h:320
AV_BPRINT_SIZE_AUTOMATIC
#define AV_BPRINT_SIZE_AUTOMATIC
AVChapter
Definition: avformat.h:1074
default_print_int
static void default_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1106
val
static double val(void *priv, double ch)
Definition: aeval.c:78
AVFrame::ch_layout
AVChannelLayout ch_layout
Channel layout of the audio data.
Definition: frame.h:802
json_init
static av_cold int json_init(WriterContext *wctx)
Definition: ffprobe.c:1605
show_help_default
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
Definition: ffprobe.c:3863
c_escape_str
static const char * c_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
Apply C-language-like string escaping.
Definition: ffprobe.c:1131
pts
static int64_t pts
Definition: transcode_aac.c:643
SECTION_ID_FRAME_SIDE_DATA_PIECE
@ SECTION_ID_FRAME_SIDE_DATA_PIECE
Definition: ffprobe.c:182
AVCodecContext::coded_height
int coded_height
Definition: avcodec.h:636
us
#define us(width, name, range_min, range_max, subs,...)
Definition: cbs_h2645.c:262
av_opt_set
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:487
show_log
static int show_log(WriterContext *w, int section_ids, int section_id, int log_level)
Definition: ffprobe.c:2509
OPT_STRING
#define OPT_STRING
Definition: cmdutils.h:112
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:900
AVAmbientViewingEnvironment::ambient_illuminance
AVRational ambient_illuminance
Environmental illuminance of the ambient viewing environment in lux.
Definition: ambient_viewing_environment.h:40
input_filename
static const char * input_filename
Definition: ffprobe.c:302
print_duration_ts
#define print_duration_ts(k, v)
Definition: ffprobe.c:1965
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
AVRational::num
int num
Numerator.
Definition: rational.h:59
avformat_network_init
int avformat_network_init(void)
Do global initialization of network libraries.
Definition: utils.c:558
AV_FIELD_TB
@ AV_FIELD_TB
Top coded first, bottom displayed first.
Definition: defs.h:203
InputFile
Definition: ffmpeg.h:399
AVHDRPlusColorTransformParams::knee_point_y
AVRational knee_point_y
The y coordinate of the separation point between the linear part and the curved part of the tone mapp...
Definition: hdr_dynamic_metadata.h:203
AVDOVIRpuDataHeader::vdr_rpu_normalized_idc
uint8_t vdr_rpu_normalized_idc
Definition: dovi_meta.h:84
AVDOVIRpuDataHeader::el_spatial_resampling_filter_flag
uint8_t el_spatial_resampling_filter_flag
Definition: dovi_meta.h:90
do_read_packets
static int do_read_packets
Definition: ffprobe.c:108
AVHDRPlusColorTransformParams::num_bezier_curve_anchors
uint8_t num_bezier_curve_anchors
The number of the intermediate anchor parameters of the tone mapping function in the processing windo...
Definition: hdr_dynamic_metadata.h:209
opt_read_intervals
static int opt_read_intervals(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:4009
avsubtitle_free
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: avcodec.c:413
AV_PKT_DATA_WEBVTT_SETTINGS
@ AV_PKT_DATA_WEBVTT_SETTINGS
The optional settings (rendering instructions) that immediately follow the timestamp specifier of a W...
Definition: packet.h:203
close_input_file
static void close_input_file(InputFile *ifile)
Definition: ffprobe.c:3513
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:88
parse_read_intervals
static int parse_read_intervals(const char *intervals_spec)
Definition: ffprobe.c:3961
AVFormatContext::bit_rate
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:1224
av_get_bits_per_sample
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:558
AVCodecParameters::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: codec_par.h:143
avcodec_decode_subtitle2
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
Decode a subtitle message.
Definition: decode.c:969
json_print_item_str
static void json_print_item_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1698
default_writer
static const Writer default_writer
Definition: ffprobe.c:1115
avassert.h
writer_print_time
static void writer_print_time(WriterContext *wctx, const char *key, int64_t ts, const AVRational *time_base, int is_duration)
Definition: ffprobe.c:888
show_frame
static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, AVFormatContext *fmt_ctx)
Definition: ffprobe.c:2706
do_show_error
static int do_show_error
Definition: ffprobe.c:110
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
CHECK_END
#define CHECK_END
AVFormatContext::metadata
AVDictionary * metadata
Metadata that applies to the whole file.
Definition: avformat.h:1343
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
AVInputFormat
Definition: avformat.h:549
av_cold
#define av_cold
Definition: attributes.h:90
AVDOVIRpuDataHeader::chroma_resampling_explicit_filter_flag
uint8_t chroma_resampling_explicit_filter_flag
Definition: dovi_meta.h:81
AV_PKT_FLAG_CORRUPT
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
Definition: packet.h:547
av_dump_format
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate,...
Definition: dump.c:629
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
nb_streams_frames
static uint64_t * nb_streams_frames
Definition: ffprobe.c:330
AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES
#define AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES
Within AV_ESCAPE_MODE_XML, additionally escape double quotes for double quoted attributes.
Definition: avstring.h:348
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:628
avformat_open_input
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: demux.c:226
si_prefixes
static const struct @7 si_prefixes[]
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:62
postprocess.h
av_channel_layout_describe
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
Definition: channel_layout.c:786
av_log_format_line
void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix)
Format a line of log the same way as the default callback.
Definition: log.c:330
SECTION_ID_FORMAT_TAGS
@ SECTION_ID_FORMAT_TAGS
Definition: ffprobe.c:171
AVDOVIRpuDataHeader::vdr_bit_depth
uint8_t vdr_bit_depth
Definition: dovi_meta.h:88
Writer::print_rational
void(* print_rational)(WriterContext *wctx, AVRational *q, char *sep)
Definition: ffprobe.c:480
OPT_INT
#define OPT_INT
Definition: cmdutils.h:115
AVDOVIRpuDataHeader::rpu_type
uint8_t rpu_type
Definition: dovi_meta.h:77
initialized
static int initialized
Definition: vaapi_transcode.c:43
avcodec_alloc_context3
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
Definition: options.c:153
av_packet_side_data_name
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition: avpacket.c:269
do_count_frames
static int do_count_frames
Definition: ffprobe.c:105
AVChapter::end
int64_t end
chapter start/end time in time_base units
Definition: avformat.h:1077
writer_child_next
static void * writer_child_next(void *obj, void *prev)
Definition: ffprobe.c:542
print_section_footer
#define print_section_footer(s)
Definition: ffprobe.c:1975
AVDOVIMetadata
Combined struct representing a combination of header, mapping and color metadata, for attaching to fr...
Definition: dovi_meta.h:197
ReadInterval::end
int64_t end
start, end in second/AV_TIME_BASE units
Definition: ffprobe.c:149
AVCodecDescriptor
This struct describes the properties of a single codec described by an AVCodecID.
Definition: codec_desc.h:38
stereo3d.h
AVMasteringDisplayMetadata::white_point
AVRational white_point[2]
CIE 1931 xy chromaticity coords of white point.
Definition: mastering_display_metadata.h:47
log_read_interval
static void log_read_interval(const ReadInterval *interval, void *log_ctx, int log_level)
Definition: ffprobe.c:2868
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVDOVIReshapingCurve::mmr_order
uint8_t mmr_order[AV_DOVI_MAX_PIECES]
Definition: dovi_meta.h:112
AVHDRPlusColorTransformParams::semiminor_axis_external_ellipse
uint16_t semiminor_axis_external_ellipse
The semi-minor axis value of the external ellipse of the elliptical pixel selector in amount of pixel...
Definition: hdr_dynamic_metadata.h:141
unit_bit_per_second_str
static const char unit_bit_per_second_str[]
Definition: ffprobe.c:326
show_program
static int show_program(WriterContext *w, InputFile *ifile, AVProgram *program)
Definition: ffprobe.c:3275
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:215
xml_options
static const AVOption xml_options[]
Definition: ffprobe.c:1765
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
AVFormatContext::nb_programs
unsigned int nb_programs
Definition: avformat.h:1282
AVHDRPlusColorTransformParams::window_upper_left_corner_y
AVRational window_upper_left_corner_y
The relative y coordinate of the top left pixel of the processing window.
Definition: hdr_dynamic_metadata.h:76
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:554
AVFormatContext::iformat
const struct AVInputFormat * iformat
The input container format.
Definition: avformat.h:1127
AVFormatContext::chapters
AVChapter ** chapters
Definition: avformat.h:1333
AVHDRPlusColorTransformParams::window_lower_right_corner_x
AVRational window_lower_right_corner_x
The relative x coordinate of the bottom right pixel of the processing window.
Definition: hdr_dynamic_metadata.h:85
SECTION_ID_SUBTITLE
@ SECTION_ID_SUBTITLE
Definition: ffprobe.c:213
AVDictionaryEntry::key
char * key
Definition: dict.h:90
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVDOVIRpuDataHeader::spatial_resampling_filter_flag
uint8_t spatial_resampling_filter_flag
Definition: dovi_meta.h:89
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:121
AV_CHANNEL_ORDER_UNSPEC
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
Definition: channel_layout.h:112
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
av_hash_alloc
int av_hash_alloc(AVHashContext **ctx, const char *name)
Allocate a hash context for the algorithm specified by name.
Definition: hash.c:104
av_strtok
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
Definition: avstring.c:178
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
AVDynamicHDRPlus::targeted_system_display_maximum_luminance
AVRational targeted_system_display_maximum_luminance
The nominal maximum display luminance of the targeted system display, in units of 0....
Definition: hdr_dynamic_metadata.h:271
CompactContext::item_sep
char item_sep
Definition: ffprobe.c:1180
print_fmt
#define print_fmt(k, f,...)
Definition: ffprobe.c:1939
FlatContext
Definition: ffprobe.c:1359
avcodec_receive_frame
int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder or encoder (when the AV_CODEC_FLAG_RECON_FRAME flag is used...
Definition: avcodec.c:713
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
xml_print_str
static void xml_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1902
AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:637
setup_find_stream_info_opts
int setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts, AVDictionary ***dst)
Setup AVCodecContext options for avformat_find_stream_info().
Definition: cmdutils.c:990
probe_file
static int probe_file(WriterContext *wctx, const char *filename, const char *print_filename)
Definition: ffprobe.c:3527
AVDynamicHDRPlus::mastering_display_actual_peak_luminance_flag
uint8_t mastering_display_actual_peak_luminance_flag
This flag shall be equal to 0 in bitstreams conforming to this version of this Specification.
Definition: hdr_dynamic_metadata.h:303
JSON_INDENT
#define JSON_INDENT()
Definition: ffprobe.c:1635
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1517
WriterContext::writer_w8
void(* writer_w8)(WriterContext *wctx, int b)
Definition: ffprobe.c:492
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
section::show_all_entries
int show_all_entries
Definition: ffprobe.c:232
AVDOVIDecoderConfigurationRecord::dv_profile
uint8_t dv_profile
Definition: dovi_meta.h:55
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_guess_sample_aspect_ratio
AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame)
Guess the sample aspect ratio of a frame, based on both the stream and the frame aspect ratio.
Definition: avformat.c:632
flat_print_str
static void flat_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1457
SECTION_ID_ROOT
@ SECTION_ID_ROOT
Definition: ffprobe.c:206
AV_PKT_DATA_STEREO3D
@ AV_PKT_DATA_STEREO3D
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition: packet.h:115
nb_streams
static int nb_streams
Definition: ffprobe.c:328
ffprobe_show_program_version
static void ffprobe_show_program_version(WriterContext *w)
Definition: ffprobe.c:3615
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AVSubtitle::pts
int64_t pts
Same as packet pts, in AV_TIME_BASE.
Definition: avcodec.h:2275
pixel_formats
static enum AVPixelFormat pixel_formats[]
Definition: vf_sr.c:67
do_show_chapter_tags
static int do_show_chapter_tags
Definition: ffprobe.c:125
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
do_show_pixel_format_components
static int do_show_pixel_format_components
Definition: ffprobe.c:122
AV_DOVI_MAPPING_POLYNOMIAL
@ AV_DOVI_MAPPING_POLYNOMIAL
Definition: dovi_meta.h:95
AVFrame::crop_right
size_t crop_right
Definition: frame.h:781
xml_print_section_header
static void xml_print_section_header(WriterContext *wctx, void *data)
Definition: ffprobe.c:1798
CompactContext::nested_section
int nested_section[SECTION_MAX_NB_LEVELS]
Definition: ffprobe.c:1185
AVCodecContext::rc_max_rate
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:1284
flat_writer
static const Writer flat_writer
Definition: ffprobe.c:1470
av_get_sample_fmt_name
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Definition: samplefmt.c:51
filter_codec_opts
int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec, AVDictionary **dst)
Filter out options for given codec.
Definition: cmdutils.c:925
key
const char * key
Definition: hwcontext_opencl.c:174
AVCodecParameters::nb_coded_side_data
int nb_coded_side_data
Amount of entries in coded_side_data.
Definition: codec_par.h:228
color_range
color_range
Definition: vf_selectivecolor.c:43
flat_escape_value_str
static const char * flat_escape_value_str(AVBPrint *dst, const char *src)
Definition: ffprobe.c:1408
do_show_chapters
static int do_show_chapters
Definition: ffprobe.c:109
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:548
AVCPBProperties
This structure describes the bitrate properties of an encoded bitstream.
Definition: defs.h:269
AVFormatContext::probe_score
int probe_score
format probing score.
Definition: avformat.h:1540
show_chapters
static int show_chapters(WriterContext *w, InputFile *ifile)
Definition: ffprobe.c:3324
AVDOVIDecoderConfigurationRecord::dv_version_major
uint8_t dv_version_major
Definition: dovi_meta.h:53
av_dovi_get_header
static av_always_inline AVDOVIRpuDataHeader * av_dovi_get_header(const AVDOVIMetadata *data)
Definition: dovi_meta.h:208
AVDOVIReshapingCurve::poly_order
uint8_t poly_order[AV_DOVI_MAX_PIECES]
Definition: dovi_meta.h:109
AV_FRAME_DATA_DYNAMIC_HDR_VIVID
@ AV_FRAME_DATA_DYNAMIC_HDR_VIVID
HDR Vivid dynamic metadata associated with a video frame.
Definition: frame.h:211
find_stream_info
static int find_stream_info
Definition: ffprobe.c:158
frame
static AVFrame * frame
Definition: demux_decode.c:54
SECTION_ID_FRAME_LOGS
@ SECTION_ID_FRAME_LOGS
Definition: ffprobe.c:184
FF_CODEC_PROPERTY_FILM_GRAIN
#define FF_CODEC_PROPERTY_FILM_GRAIN
Definition: avcodec.h:1907
arg
const char * arg
Definition: jacosubdec.c:67
AVStereo3D::flags
int flags
Additional information about the frame packing.
Definition: stereo3d.h:182
do_show_pixel_format_flags
static int do_show_pixel_format_flags
Definition: ffprobe.c:121
AVHDRPlusPercentile::percentage
uint8_t percentage
The percentage value corresponding to a specific percentile linearized RGB value in the processing wi...
Definition: hdr_dynamic_metadata.h:45
if
if(ret)
Definition: filter_design.txt:179
SECTION_FLAG_IS_WRAPPER
#define SECTION_FLAG_IS_WRAPPER
the section only contains other sections, but has no data at its own level
Definition: ffprobe.c:220
section::name
const char * name
Definition: ffprobe.c:218
avio_flush
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
Definition: aviobuf.c:270
open_input_file
static int open_input_file(InputFile *ifile, const char *filename, const char *print_filename)
Definition: ffprobe.c:3388
AVDOVINLQParams::linear_deadzone_threshold
uint64_t linear_deadzone_threshold
Definition: dovi_meta.h:131
InputFile::streams
InputStream * streams
Definition: ffprobe.c:97
av_color_range_name
const char * av_color_range_name(enum AVColorRange range)
Definition: pixdesc.c:3280
ReadInterval::start
int64_t start
Definition: ffprobe.c:149
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:219
AVFormatContext
Format I/O context.
Definition: avformat.h:1115
print_int
#define print_int(k, v)
Definition: ffprobe.c:1957
init_dynload
void init_dynload(void)
Initialize dynamic library loading.
Definition: cmdutils.c:77
opts
AVDictionary * opts
Definition: movenc.c:50
read_intervals
static ReadInterval * read_intervals
Definition: ffprobe.c:155
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:864
avcodec_parameters_to_context
int avcodec_parameters_to_context(AVCodecContext *codec, const struct AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
WriterContext::avio
AVIOContext * avio
the I/O context used to write
Definition: ffprobe.c:490
AVDynamicHDRPlus::application_version
uint8_t application_version
Application version in the application defining document in ST-2094 suite.
Definition: hdr_dynamic_metadata.h:253
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
ReadInterval::has_end
int has_end
Definition: ffprobe.c:150
avcodec_get_class
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
Definition: options.c:187
SECTION_ID_FRAME_LOG
@ SECTION_ID_FRAME_LOG
Definition: ffprobe.c:183
AVStream::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avformat.h:880
NULL
#define NULL
Definition: coverity.c:32
compact_print_str
static void compact_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1291
av_hash_names
const char * av_hash_names(int i)
Get the names of available hash algorithms.
Definition: hash.c:88
print_ambient_viewing_environment
static void print_ambient_viewing_environment(WriterContext *w, const AVAmbientViewingEnvironment *env)
Definition: ffprobe.c:2319
SET_DO_SHOW
#define SET_DO_SHOW(id, varname)
Definition: ffprobe.c:4140
print_color_range
static void print_color_range(WriterContext *w, enum AVColorRange color_range)
Definition: ffprobe.c:2443
AVDOVIDecoderConfigurationRecord::dv_level
uint8_t dv_level
Definition: dovi_meta.h:56
program_name
const char program_name[]
program name, defined by the program for show_version().
Definition: ffprobe.c:101
compact_writer
static const Writer compact_writer
Definition: ffprobe.c:1314
StringValidation
StringValidation
Definition: ffprobe.c:462
AVDOVIDecoderConfigurationRecord::dv_bl_signal_compatibility_id
uint8_t dv_bl_signal_compatibility_id
Definition: dovi_meta.h:60
FlatContext::hierarchical
int hierarchical
Definition: ffprobe.c:1363
InputStream::st
AVStream * st
Definition: ffmpeg.h:330
AV_DICT_MULTIKEY
#define AV_DICT_MULTIKEY
Allow to store several equal keys in the dictionary.
Definition: dict.h:84
AVHDRVividColorTransformParams::color_saturation_gain
AVRational color_saturation_gain[8]
Indicates the color correction strength parameter.
Definition: hdr_dynamic_vivid_metadata.h:296
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
av_hash_init
void av_hash_init(AVHashContext *ctx)
Initialize or reset a hash context.
Definition: hash.c:141
AV_DOVI_MAPPING_MMR
@ AV_DOVI_MAPPING_MMR
Definition: dovi_meta.h:96
compact_print_int
static void compact_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1304
OPT_EXPERT
#define OPT_EXPERT
Definition: cmdutils.h:111
ERROR
static void ERROR(const char *str)
Definition: audio_fifo.c:58
do_read_frames
static int do_read_frames
Definition: ffprobe.c:107
av_bprint_escape
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars, enum AVEscapeMode mode, int flags)
Escape the content in src and append it to dstbuf.
Definition: bprint.c:268
SECTION_ID_LIBRARY_VERSION
@ SECTION_ID_LIBRARY_VERSION
Definition: ffprobe.c:185
avcodec_free_context
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
Definition: options.c:168
hash
static struct AVHashContext * hash
Definition: ffprobe.c:307
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
version.h
SECTION_ID_STREAM_TAGS
@ SECTION_ID_STREAM_TAGS
Definition: ffprobe.c:210
isnan
#define isnan(x)
Definition: libm.h:340
writer_printf
#define writer_printf(wctx_, fmt_,...)
Definition: ffprobe.c:985
SHOW_OPTIONAL_FIELDS_ALWAYS
#define SHOW_OPTIONAL_FIELDS_ALWAYS
Definition: ffprobe.c:140
AVPacketSideData::type
enum AVPacketSideDataType type
Definition: packet.h:345
print_q
#define print_q(k, v, s)
Definition: ffprobe.c:1958
AVFrame::coded_picture_number
attribute_deprecated int coded_picture_number
picture number in bitstream order
Definition: frame.h:474
AVFormatContext::pb
AVIOContext * pb
I/O context.
Definition: avformat.h:1157
av_log_set_flags
void av_log_set_flags(int arg)
Definition: log.c:447
AV_RN32
#define AV_RN32(p)
Definition: intreadwrite.h:362
parseutils.h
unit_value::val
union unit_value::@8 val
AV_FRAME_DATA_ICC_PROFILE
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
Definition: frame.h:144
AVDynamicHDRVivid
This struct represents dynamic metadata for color volume transform - CUVA 005.1:2021 standard.
Definition: hdr_dynamic_vivid_metadata.h:310
WriterContext::name
char * name
name of this writer instance
Definition: ffprobe.c:496
AVHDRVividColorTransformParams::color_saturation_mapping_flag
int color_saturation_mapping_flag
This flag indicates that the metadata for the color saturation mapping in the processing window is pr...
Definition: hdr_dynamic_vivid_metadata.h:283
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:120
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:921
av_color_primaries_name
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition: pixdesc.c:3298
AVHDRPlusColorTransformParams::fraction_bright_pixels
AVRational fraction_bright_pixels
The fraction of selected pixels in the image that contains the brightest pixel in the scene.
Definition: hdr_dynamic_metadata.h:183
av_opt_free
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1719
av_parse_time
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
Definition: parseutils.c:589
print_pkt_side_data
static void print_pkt_side_data(WriterContext *w, AVCodecParameters *par, const AVPacketSideData *sd, SectionID id_data)
Definition: ffprobe.c:2330
AV_DICT_DONT_OVERWRITE
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
Definition: dict.h:81
AVFrame::pkt_dts
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
Definition: frame.h:459
avcodec_open2
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition: avcodec.c:128
xml_init
static av_cold int xml_init(WriterContext *wctx)
Definition: ffprobe.c:1775
WriterContext::sections
const struct section * sections
array containing all sections
Definition: ffprobe.c:499
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:226
av_hash_update
void av_hash_update(AVHashContext *ctx, const uint8_t *src, size_t len)
Update a hash context with additional data.
Definition: hash.c:162
csv_writer
static const Writer csv_writer
Definition: ffprobe.c:1345
print_color_trc
static void print_color_trc(WriterContext *w, enum AVColorTransferCharacteristic color_trc)
Definition: ffprobe.c:2473
Writer::print_integer
void(* print_integer)(WriterContext *wctx, const char *, long long int)
Definition: ffprobe.c:479
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:206
AVDOVIReshapingCurve::mmr_constant
int64_t mmr_constant[AV_DOVI_MAX_PIECES]
Definition: dovi_meta.h:113
do_show_programs
static int do_show_programs
Definition: ffprobe.c:114
AVHDRPlusColorTransformParams::color_saturation_weight
AVRational color_saturation_weight
The color saturation gain in the processing window in the scene.
Definition: hdr_dynamic_metadata.h:229
AVHDRVividColorTransformParams::tone_mapping_mode_flag
int tone_mapping_mode_flag
This flag indicates that the metadata for the tone mapping function in the processing window is prese...
Definition: hdr_dynamic_vivid_metadata.h:266
bin_str
const char * bin_str
Definition: ffprobe.c:312
AV_FRAME_DATA_AFD
@ AV_FRAME_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
Definition: frame.h:90
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
read_interval_packets
static int read_interval_packets(WriterContext *w, InputFile *ifile, const ReadInterval *interval, int64_t *cur_ts)
Definition: ffprobe.c:2892
real_options
static const OptionDef real_options[]
Definition: ffprobe.c:4079
AV_PKT_DATA_CONTENT_LIGHT_LEVEL
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: packet.h:236
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:639
WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER
#define WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER
Definition: ffprobe.c:460
AVCodecParameters::level
int level
Definition: codec_par.h:116
WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
#define WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
Definition: ffprobe.c:459
swresample.h
index
int index
Definition: gxfenc.c:89
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
unit_byte_str
static const char unit_byte_str[]
Definition: ffprobe.c:325
program_birth_year
const int program_birth_year
program birth year, defined by the program for show_banner()
Definition: ffprobe.c:102
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:171
pthread_mutex_unlock
#define pthread_mutex_unlock(a)
Definition: ffprobe.c:79
AVAudioServiceType
AVAudioServiceType
Definition: defs.h:222
av_hash_freep
void av_hash_freep(AVHashContext **ctx)
Free hash context and set hash context pointer to NULL.
Definition: hash.c:238
AVFrame::crop_bottom
size_t crop_bottom
Definition: frame.h:779
show_format
static int show_format(WriterContext *w, InputFile *ifile)
Definition: ffprobe.c:3349
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:902
SECTION_ID_CHAPTER
@ SECTION_ID_CHAPTER
Definition: ffprobe.c:166
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:975
print_duration_time
#define print_duration_time(k, v, tb)
Definition: ffprobe.c:1964
AV_PKT_DATA_SPHERICAL
@ AV_PKT_DATA_SPHERICAL
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
Definition: packet.h:229
AVFrame::best_effort_timestamp
int64_t best_effort_timestamp
frame timestamp estimated using various heuristics, in stream time base
Definition: frame.h:676
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:73
show_value_unit
static int show_value_unit
Definition: ffprobe.c:132
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1171
color_primaries
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
Definition: csp.c:76
print_input_filename
static const char * print_input_filename
Definition: ffprobe.c:303
SECTION_ID_FRAMES
@ SECTION_ID_FRAMES
Definition: ffprobe.c:173
codec_opts
AVDictionary * codec_opts
Definition: cmdutils.c:60
AVFrame::crop_left
size_t crop_left
Definition: frame.h:780
FrameData::pkt_size
int pkt_size
Definition: ffprobe.c:85
csv_escape_str
static const char * csv_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
Quote fields containing special characters, check RFC4180.
Definition: ffprobe.c:1154
avformat_find_stream_info
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: demux.c:2436
writer_open
static int writer_open(WriterContext **wctx, const Writer *writer, const char *args, const struct section *sections, int nb_sections, const char *output)
Definition: ffprobe.c:628
fmt_ctx
static AVFormatContext * fmt_ctx
Definition: decode_filter_audio.c:45
WRITER_STRING_VALIDATION_IGNORE
@ WRITER_STRING_VALIDATION_IGNORE
Definition: ffprobe.c:465
writer_w8
#define writer_w8(wctx_, b_)
Definition: ffprobe.c:983
av_spherical_projection_name
const char * av_spherical_projection_name(enum AVSphericalProjection projection)
Provide a human-readable name of a given AVSphericalProjection.
Definition: spherical.c:62
AVIOContext
Bytestream IO Context.
Definition: avio.h:166
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:442
AV_SPHERICAL_CUBEMAP
@ AV_SPHERICAL_CUBEMAP
Video frame is split into 6 faces of a cube, and arranged on a 3x2 layout.
Definition: spherical.h:61
av_ts2timestr
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:76
WriterContext::string_validation_utf8_flags
unsigned int string_validation_utf8_flags
Definition: ffprobe.c:518
DefaultContext::noprint_wrappers
int noprint_wrappers
Definition: ffprobe.c:1032
av_log_set_callback
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
Definition: log.c:457
AVDynamicHDRPlus::num_rows_mastering_display_actual_peak_luminance
uint8_t num_rows_mastering_display_actual_peak_luminance
The number of rows in the mastering_display_actual_peak_luminance array.
Definition: hdr_dynamic_metadata.h:309
AVPacket::size
int size
Definition: packet.h:492
ReadInterval::start_is_offset
int start_is_offset
Definition: ffprobe.c:151
do_show_packet_tags
static int do_show_packet_tags
Definition: ffprobe.c:130
avformat_match_stream_specifier
int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the stream st contained in s is matched by the stream specifier spec.
Definition: avformat.c:588
SECTION_ID_STREAM_DISPOSITION
@ SECTION_ID_STREAM_DISPOSITION
Definition: ffprobe.c:208
avformat_alloc_context
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:166
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
@ AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
Ambient viewing environment metadata, as defined by H.274.
Definition: frame.h:216
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:240
PRINT_PIX_FMT_FLAG
#define PRINT_PIX_FMT_FLAG(flagname, name)
Definition: ffprobe.c:3660
writer_w8_avio
static void writer_w8_avio(WriterContext *wctx, int b)
Definition: ffprobe.c:590
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
AVClass::category
AVClassCategory category
Category used for visualization (like color) This is only set if the category is equal for all object...
Definition: log.h:114
AV_DOVI_NLQ_LINEAR_DZ
@ AV_DOVI_NLQ_LINEAR_DZ
Definition: dovi_meta.h:119
AV_PKT_DATA_DYNAMIC_HDR10_PLUS
@ AV_PKT_DATA_DYNAMIC_HDR10_PLUS
HDR10+ dynamic metadata associated with a video frame.
Definition: packet.h:300
AVDOVIRpuDataHeader::vdr_rpu_profile
uint8_t vdr_rpu_profile
Definition: dovi_meta.h:79
AVFrame::display_picture_number
attribute_deprecated int display_picture_number
picture number in display order
Definition: frame.h:479
AVDynamicHDRPlus::num_windows
uint8_t num_windows
The number of processing windows.
Definition: hdr_dynamic_metadata.h:259
av_err2str
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:121
ini_print_section_header
static void ini_print_section_header(WriterContext *wctx, void *data)
Definition: ffprobe.c:1526
XMLContext::fully_qualified
int fully_qualified
Definition: ffprobe.c:1758
AVFormatContext::url
char * url
input or output URL.
Definition: avformat.h:1198
SECTION_FLAG_IS_ARRAY
#define SECTION_FLAG_IS_ARRAY
the section contains an array of elements of the same type
Definition: ffprobe.c:221
AVCodecContext::pkt_timebase
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
Definition: avcodec.h:1817
SectionID
SectionID
Definition: ffprobe.c:164
REALLOCZ_ARRAY_STREAM
#define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n)
Definition: ffprobe.c:1977
uninit_opts
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents.
Definition: cmdutils.c:64
AVClass::get_category
AVClassCategory(* get_category)(void *ctx)
Callback to return the category.
Definition: log.h:120
size
int size
Definition: twinvq_data.h:10344
SECTION_ID_CHAPTER_TAGS
@ SECTION_ID_CHAPTER_TAGS
Definition: ffprobe.c:167
AV_ESCAPE_MODE_XML
@ AV_ESCAPE_MODE_XML
Use XML non-markup character data escaping.
Definition: avstring.h:318
AVHDRVividColorTransformParams::average_maxrgb
AVRational average_maxrgb
Indicates the average brightness of the displayed content.
Definition: hdr_dynamic_vivid_metadata.h:246
show_private_data
static int show_private_data
Definition: ffprobe.c:136
avformat_seek_file
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
Definition: seek.c:662
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
section::get_type
const char *(* get_type)(void *data)
function returning a type if defined, must be defined when SECTION_FLAG_HAS_TYPE is defined
Definition: ffprobe.c:231
AVDynamicHDRPlus::mastering_display_actual_peak_luminance
AVRational mastering_display_actual_peak_luminance[25][25]
The normalized actual peak luminance of the mastering display used for mastering the image essence.
Definition: hdr_dynamic_metadata.h:322
section
Definition: ffprobe.c:216
xml_print_int
static void xml_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1906
opt_show_versions
static int opt_show_versions(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:4054
opt_input_file
static int opt_input_file(void *optctx, const char *arg)
Definition: ffprobe.c:3821
AVCodecParameters::profile
int profile
Codec-specific bitstream restrictions that the stream conforms to.
Definition: codec_par.h:115
PAL
#define PAL
Definition: bktr.c:66
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:693
ffprobe_show_library_versions
static void ffprobe_show_library_versions(WriterContext *w)
Definition: ffprobe.c:3646
printf
printf("static const uint8_t my_array[100] = {\n")
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:427
SECTION_ID_PACKETS_AND_FRAMES
@ SECTION_ID_PACKETS_AND_FRAMES
Definition: ffprobe.c:190
AVOption::name
const char * name
Definition: opt.h:252
use_value_prefix
static int use_value_prefix
Definition: ffprobe.c:133
SECTION_ID_ERROR
@ SECTION_ID_ERROR
Definition: ffprobe.c:169
DefaultContext::nested_section
int nested_section[SECTION_MAX_NB_LEVELS]
Definition: ffprobe.c:1033
AVCPBProperties::min_bitrate
int64_t min_bitrate
Minimum bitrate of the stream, in bits per second.
Definition: defs.h:279
unit_value
Definition: ffprobe.c:397
AVSubtitle::end_display_time
uint32_t end_display_time
Definition: avcodec.h:2272
flat_print_int
static void flat_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1452
avdevice.h
show_error
static void show_error(WriterContext *w, int err)
Definition: ffprobe.c:3380
Writer::flags
int flags
a combination or WRITER_FLAG_*
Definition: ffprobe.c:482
av_packet_unpack_dictionary
int av_packet_unpack_dictionary(const uint8_t *data, size_t size, AVDictionary **dict)
Unpack a dictionary from side_data.
Definition: avpacket.c:343
show_banner
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
Definition: opt_common.c:237
ini_print_str
static void ini_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1559
AVHDRPlusColorTransformParams::window_lower_right_corner_y
AVRational window_lower_right_corner_y
The relative y coordinate of the bottom right pixel of the processing window.
Definition: hdr_dynamic_metadata.h:94
writer_put_str_avio
static void writer_put_str_avio(WriterContext *wctx, const char *str)
Definition: ffprobe.c:595
AV_OPT_SEARCH_CHILDREN
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition: opt.h:563
AVDOVIRpuDataHeader::coef_log2_denom
uint8_t coef_log2_denom
Definition: dovi_meta.h:83
AVDOVIRpuDataHeader::bl_video_full_range_flag
uint8_t bl_video_full_range_flag
Definition: dovi_meta.h:85
print_frame_side_data
static void print_frame_side_data(WriterContext *w, const AVFrame *frame, const AVStream *stream)
Definition: ffprobe.c:2625
AVHDRVividColorToneMappingParams::base_param_k1
int base_param_k1
indicates k1_0 in the base parameter, base_param_k1 <= 1: k1_0 = base_param_k1 base_param_k1 > 1: res...
Definition: hdr_dynamic_vivid_metadata.h:130
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:490
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:248
AVSphericalMapping::padding
uint32_t padding
Number of pixels to pad from the edge of each cube face.
Definition: spherical.h:178
WriterContext::nb_section_frame
unsigned int nb_section_frame
number of the frame section in case we are in "packets_and_frames" section
Definition: ffprobe.c:513
section::children_ids
const SectionID children_ids[SECTION_MAX_NB_CHILDREN+1]
list of children section IDS, terminated by -1
Definition: ffprobe.c:227
AVDOVIReshapingCurve::poly_coef
int64_t poly_coef[AV_DOVI_MAX_PIECES][3]
Definition: dovi_meta.h:110
SECTION_ID_FRAME_SIDE_DATA_LIST
@ SECTION_ID_FRAME_SIDE_DATA_LIST
Definition: ffprobe.c:175
writer_print_section_header
static void writer_print_section_header(WriterContext *wctx, void *data, int section_id)
Definition: ffprobe.c:730
SECTION_ID_PACKET_TAGS
@ SECTION_ID_PACKET_TAGS
Definition: ffprobe.c:188
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
AVHashContext
Definition: hash.c:60
line
Definition: graph2dot.c:48
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:497
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:63
av_dict_free
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:225
do_show_format
static int do_show_format
Definition: ffprobe.c:111
AVCPBProperties::avg_bitrate
int64_t avg_bitrate
Average bitrate of the stream, in bits per second.
Definition: defs.h:284
ReadInterval
Definition: ffprobe.c:147
va_copy
#define va_copy(dst, src)
Definition: va_copy.h:31
writer_print_string
static int writer_print_string(WriterContext *wctx, const char *key, const char *val, int flags)
Definition: ffprobe.c:841
AV_STEREO3D_FLAG_INVERT
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
Definition: stereo3d.h:164
Writer
Definition: ffprobe.c:469
section::entries_to_show
AVDictionary * entries_to_show
Definition: ffprobe.c:230
do_show_stream_disposition
static int do_show_stream_disposition
Definition: ffprobe.c:116
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
AVDynamicHDRPlus::num_rows_targeted_system_display_actual_peak_luminance
uint8_t num_rows_targeted_system_display_actual_peak_luminance
The number of rows in the targeted system_display_actual_peak_luminance array.
Definition: hdr_dynamic_metadata.h:283
Writer::priv_size
int priv_size
private size for the writer context
Definition: ffprobe.c:471
AVChromaLocation
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:692
registered_writers
static const Writer * registered_writers[MAX_REGISTERED_WRITERS_NB+1]
Definition: ffprobe.c:989
AVHDRPlusColorTransformParams::window_upper_left_corner_x
AVRational window_upper_left_corner_x
The relative x coordinate of the top left pixel of the processing window.
Definition: hdr_dynamic_metadata.h:67
WriterContext::writer_printf
void(* writer_printf)(WriterContext *wctx, const char *fmt,...)
Definition: ffprobe.c:494
do_count_packets
static int do_count_packets
Definition: ffprobe.c:106
iformat
static const AVInputFormat * iformat
Definition: ffprobe.c:304
SHOW_OPTIONAL_FIELDS_AUTO
#define SHOW_OPTIONAL_FIELDS_AUTO
Definition: ffprobe.c:138
pthread_mutex_destroy
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
Definition: os2threads.h:112
AV_PKT_DATA_STRINGS_METADATA
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
Definition: packet.h:173
ReadInterval::has_start
int has_start
Definition: ffprobe.c:150
sections
static struct section sections[]
Definition: ffprobe.c:245
av_get_picture_type_char
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
Definition: utils.c:40
AVCPBProperties::vbv_delay
uint64_t vbv_delay
The delay between the time the packet this structure is associated with is received and the time when...
Definition: defs.h:299
unit_value::unit
const char * unit
Definition: ffprobe.c:399
WriterContext::writer_put_str
void(* writer_put_str)(WriterContext *wctx, const char *str)
Definition: ffprobe.c:493
SECTION_ID_PROGRAM_STREAM_TAGS
@ SECTION_ID_PROGRAM_STREAM_TAGS
Definition: ffprobe.c:199
JSONContext::indent_level
int indent_level
Definition: ffprobe.c:1589
section::flags
int flags
Definition: ffprobe.c:226
avcodec_send_packet
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
Definition: decode.c:709
AV_PKT_DATA_CPB_PROPERTIES
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
Definition: packet.h:146
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:420
bprint.h
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: frame.h:137
AVHDRPlusColorTransformParams::semimajor_axis_internal_ellipse
uint16_t semimajor_axis_internal_ellipse
The semi-major axis value of the internal ellipse of the elliptical pixel selector in amount of pixel...
Definition: hdr_dynamic_metadata.h:125
AVSphericalMapping::roll
int32_t roll
Rotation around the forward vector [-180, 180].
Definition: spherical.h:124
AVSubtitle::format
uint16_t format
Definition: avcodec.h:2270
AVClassCategory
AVClassCategory
Definition: log.h:28
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:484
av_timecode_make_smpte_tc_string2
char * av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field)
Get the timecode string from the SMPTE timecode format.
Definition: timecode.c:138
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
AVCodecContext::properties
unsigned properties
Properties of the stream that gets decoded.
Definition: avcodec.h:1904
SECTION_ID_PROGRAM
@ SECTION_ID_PROGRAM
Definition: ffprobe.c:200
AVChapter::id
int64_t id
unique ID to identify the chapter
Definition: avformat.h:1075
print_color_space
static void print_color_space(WriterContext *w, enum AVColorSpace color_space)
Definition: ffprobe.c:2453
ffprobe_show_pixel_formats
static void ffprobe_show_pixel_formats(WriterContext *w)
Definition: ffprobe.c:3665
WRITER_STRING_VALIDATION_NB
@ WRITER_STRING_VALIDATION_NB
Definition: ffprobe.c:466
av_packet_get_side_data
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
Definition: avpacket.c:252
show_usage
static void show_usage(void)
Definition: ffprobe.c:3608
WriterContext::nb_item
unsigned int nb_item[SECTION_MAX_NB_LEVELS]
number of the item printed in the given section, starting from 0
Definition: ffprobe.c:505
csv_options
static const AVOption csv_options[]
Definition: ffprobe.c:1331
AVHDRVividColorToneMappingParams::targeted_system_display_maximum_luminance
AVRational targeted_system_display_maximum_luminance
The nominal maximum display luminance of the targeted system display, in multiples of 1....
Definition: hdr_dynamic_vivid_metadata.h:83
show_subtitle
static void show_subtitle(WriterContext *w, AVSubtitle *sub, AVStream *stream, AVFormatContext *fmt_ctx)
Definition: ffprobe.c:2602
AVCodecParameters::height
int height
Definition: codec_par.h:122
print_private_data
static void print_private_data(WriterContext *w, void *priv_data)
Definition: ffprobe.c:2430
XMLContext::xsd_strict
int xsd_strict
Definition: ffprobe.c:1759
do_bitexact
static int do_bitexact
Definition: ffprobe.c:104
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:31
get_packet_side_data_type
static const char * get_packet_side_data_type(void *data)
Definition: ffprobe.c:235
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:599
display.h
SECTION_ID_PACKETS
@ SECTION_ID_PACKETS
Definition: ffprobe.c:189
AV_FIELD_BB
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
Definition: defs.h:202
xml_writer
static Writer xml_writer
Definition: ffprobe.c:1910
AVCPBProperties::max_bitrate
int64_t max_bitrate
Maximum bitrate of the stream, in bits per second.
Definition: defs.h:274
AVDOVIDataMapping::num_y_partitions
uint32_t num_y_partitions
Definition: dovi_meta.h:148
LogBuffer::category
AVClassCategory category
Definition: ffprobe.c:340
writer_print_ts
static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, int is_duration)
Definition: ffprobe.c:905
parse_options
int parse_options(void *optctx, int argc, char **argv, const OptionDef *options, int(*parse_arg_function)(void *, const char *))
Definition: cmdutils.c:346
opt_show_entries
static int opt_show_entries(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3771
default_print_section_header
static void default_print_section_header(WriterContext *wctx, void *data)
Definition: ffprobe.c:1059
av_always_inline
#define av_always_inline
Definition: attributes.h:49
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
av_toupper
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
Definition: avstring.h:227
AV_OPT_FLAG_DECODING_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:282
SECTION_ID_FRAME_SIDE_DATA
@ SECTION_ID_FRAME_SIDE_DATA
Definition: ffprobe.c:176
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
@ SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
Definition: ffprobe.c:179
opt_sections
static int opt_sections(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:4041
CompactContext::escape_str
const char *(* escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
Definition: ffprobe.c:1184
WriterContext::priv
void * priv
private data for use by the filter
Definition: ffprobe.c:497
AVHDRPlusColorTransformParams::overlap_process_option
enum AVHDRPlusOverlapProcessOption overlap_process_option
Overlap process option indicates one of the two methods of combining rendered pixels in the processin...
Definition: hdr_dynamic_metadata.h:149
tb
#define tb
Definition: regdef.h:68
AVFrame::pkt_duration
attribute_deprecated int64_t pkt_duration
duration of the corresponding packet, expressed in AVStream->time_base units, 0 if unknown.
Definition: frame.h:700
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
AVHDRVividColorTransformParams
Color transform parameters at a processing window in a dynamic metadata for CUVA 005....
Definition: hdr_dynamic_vivid_metadata.h:233
AV_PKT_DATA_MPEGTS_STREAM_ID
@ AV_PKT_DATA_MPEGTS_STREAM_ID
MPEGTS stream ID as uint8_t, this is required to pass the stream ID information from the demuxer to t...
Definition: packet.h:216
AVProgram
New fields can be added to the end with minor version bumps.
Definition: avformat.h:1039
AVCodecParameters::color_range
enum AVColorRange color_range
Video only.
Definition: codec_par.h:141
AVMasteringDisplayMetadata
Mastering display metadata capable of representing the color volume of the display used to master the...
Definition: mastering_display_metadata.h:38
AVFrame::side_data
AVFrameSideData ** side_data
Definition: frame.h:610
upcase_string
static char * upcase_string(char *dst, size_t dst_size, const char *src)
Definition: ffprobe.c:1050
profile
int profile
Definition: mxfenc.c:2115
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:602
AVDOVINLQParams
Coefficients of the non-linear inverse quantization.
Definition: dovi_meta.h:126
dec_str
const char * dec_str
Definition: ffprobe.c:313
AVHDRVividColorToneMappingParams::base_param_Delta_enable_mode
int base_param_Delta_enable_mode
This flag indicates that delta mode of base paramter(for value of 1)
Definition: hdr_dynamic_vivid_metadata.h:150
AVCodecParameters::coded_side_data
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
Definition: codec_par.h:223
SECTION_ID_PACKET_SIDE_DATA
@ SECTION_ID_PACKET_SIDE_DATA
Definition: ffprobe.c:192
ambient_viewing_environment.h
av_opt_next
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
Definition: opt.c:46
use_value_sexagesimal_format
static int use_value_sexagesimal_format
Definition: ffprobe.c:135
SECTION_ID_LIBRARY_VERSIONS
@ SECTION_ID_LIBRARY_VERSIONS
Definition: ffprobe.c:186
AV_FRAME_FLAG_INTERLACED
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition: frame.h:636
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
SECTION_ID_FRAME_SIDE_DATA_TIMECODE
@ SECTION_ID_FRAME_SIDE_DATA_TIMECODE
Definition: ffprobe.c:178
LogBuffer::parent_name
char * parent_name
Definition: ffprobe.c:341
log2
#define log2(x)
Definition: libm.h:404
AVCodecParameters::field_order
enum AVFieldOrder field_order
Video only.
Definition: codec_par.h:136
SECTION_ID_PROGRAM_VERSION
@ SECTION_ID_PROGRAM_VERSION
Definition: ffprobe.c:204
AVDynamicHDRPlus
This struct represents dynamic metadata for color volume transform - application 4 of SMPTE 2094-40:2...
Definition: hdr_dynamic_metadata.h:243
none_escape_str
static const char * none_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
Definition: ffprobe.c:1172
AVDOVIDataMapping::curves
AVDOVIReshapingCurve curves[3]
Definition: dovi_meta.h:143
ini_writer
static const Writer ini_writer
Definition: ffprobe.c:1575
avcodec.h
parse_loglevel
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
Definition: cmdutils.c:474
PRINT_STRING_OPT
#define PRINT_STRING_OPT
Definition: ffprobe.c:838
AVDOVINLQParams::linear_deadzone_slope
uint64_t linear_deadzone_slope
Definition: dovi_meta.h:130
SECTION_ID_PROGRAMS
@ SECTION_ID_PROGRAMS
Definition: ffprobe.c:205
version.h
json_print_str
static void json_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1710
ini_print_int
static void ini_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1570
WriterContext::string_validation_replacement
char * string_validation_replacement
Definition: ffprobe.c:517
AVDOVIReshapingCurve
Definition: dovi_meta.h:104
version.h
av_buffer_allocz
AVBufferRef * av_buffer_allocz(size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
Definition: buffer.c:93
tag
uint32_t tag
Definition: movenc.c:1737
AVStream::id
int id
Format-specific stream ID.
Definition: avformat.h:853
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:841
AV_FRAME_DATA_GOP_TIMECODE
@ AV_FRAME_DATA_GOP_TIMECODE
The GOP timecode in 25 bit timecode format.
Definition: frame.h:125
log_buffer
static LogBuffer * log_buffer
Definition: ffprobe.c:345
avcodec_flush_buffers
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
Definition: avcodec.c:384
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
AVCPBProperties::buffer_size
int64_t buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
Definition: defs.h:290
AVSphericalMapping::pitch
int32_t pitch
Rotation around the right vector [-90, 90].
Definition: spherical.h:123
AVDOVINLQParams::vdr_in_max
uint64_t vdr_in_max
Definition: dovi_meta.h:128
log_callback_help
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
Definition: cmdutils.c:72
AVStereo3D::type
enum AVStereo3DType type
How views are packed within the video.
Definition: stereo3d.h:177
InputFile::streams
InputStream ** streams
Definition: ffmpeg.h:423
parse_read_interval
static int parse_read_interval(const char *interval_spec, ReadInterval *interval)
Parse interval specification, according to the format: INTERVAL ::= [START|+START_OFFSET][%[END|+END_...
Definition: ffprobe.c:3879
AVHDRVivid3SplineParams
HDR Vivid three spline params.
Definition: hdr_dynamic_vivid_metadata.h:30
avformat.h
dovi_meta.h
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:99
AVHDRVividColorTransformParams::minimum_maxrgb
AVRational minimum_maxrgb
Indicates the minimum brightness of the displayed content.
Definition: hdr_dynamic_vivid_metadata.h:239
dict.h
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: packet.h:502
flat_init
static av_cold int flat_init(WriterContext *wctx)
Definition: ffprobe.c:1379
AV_LOG_SKIP_REPEATED
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
Definition: log.h:370
CMDUTILS_COMMON_OPTIONS
#define CMDUTILS_COMMON_OPTIONS
Definition: opt_common.h:199
AV_DICT_MATCH_CASE
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
Definition: dict.h:74
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
avio_vprintf
int avio_vprintf(AVIOContext *s, const char *fmt, va_list ap)
Writes a formatted string to the context taking a va_list.
Definition: aviobuf.c:1311
log_buffer_size
static int log_buffer_size
Definition: ffprobe.c:346
U
#define U(x)
Definition: vpx_arith.h:37
AVCodecParameters::chroma_location
enum AVChromaLocation chroma_location
Definition: codec_par.h:145
AVDOVIReshapingCurve::num_pivots
uint8_t num_pivots
Definition: dovi_meta.h:105
id
enum AVCodecID id
Definition: dts2pts_bsf.c:364
AV_PKT_DATA_WEBVTT_IDENTIFIER
@ AV_PKT_DATA_WEBVTT_IDENTIFIER
The optional first identifier line of a WebVTT cue.
Definition: packet.h:197
avformat_network_deinit
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:570
AVDOVIRpuDataHeader::vdr_rpu_level
uint8_t vdr_rpu_level
Definition: dovi_meta.h:80
json_print_section_header
static void json_print_section_header(WriterContext *wctx, void *data)
Definition: ffprobe.c:1637
WriterContext::writer
const Writer * writer
the Writer of which this is an instance
Definition: ffprobe.c:489
SECTION_ID_FRAME
@ SECTION_ID_FRAME
Definition: ffprobe.c:172
av_dovi_get_color
static av_always_inline AVDOVIColorMetadata * av_dovi_get_color(const AVDOVIMetadata *data)
Definition: dovi_meta.h:220
AVHDRVividColorToneMappingParams::base_param_m_n
AVRational base_param_m_n
base_param_m_n in the base parameter, in multiples of 1.0/10.
Definition: hdr_dynamic_vivid_metadata.h:123
XML_INDENT
#define XML_INDENT()
Definition: ffprobe.c:1796
av_get_media_type_string
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
Definition: utils.c:28
AV_FRAME_DATA_DYNAMIC_HDR_PLUS
@ AV_FRAME_DATA_DYNAMIC_HDR_PLUS
HDR dynamic metadata associated with a video frame.
Definition: frame.h:159
AVHDRVividColorToneMappingParams::base_param_m_a
AVRational base_param_m_a
base_param_m_a in the base parameter, in multiples of 1.0/1023.
Definition: hdr_dynamic_vivid_metadata.h:109
AVCodecContext
main external API structure.
Definition: avcodec.h:441
AVFrame::height
int height
Definition: frame.h:412
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:847
av_timecode_make_mpeg_tc_string
char * av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit)
Get the timecode string from the 25-bit timecode format (MPEG GOP format).
Definition: timecode.c:167
hash.h
CompactContext::nokey
int nokey
Definition: ffprobe.c:1181
WriterContext
Definition: ffprobe.c:487
AVDOVIDataMapping::mapping_chroma_format_idc
uint8_t mapping_chroma_format_idc
Definition: dovi_meta.h:142
channel_layout.h
AV_OPT_FLAG_EXPORT
#define AV_OPT_FLAG_EXPORT
The option is intended for exporting values to the caller.
Definition: opt.h:289
JSONContext::item_sep
const char * item_sep
Definition: ffprobe.c:1591
nb_streams_packets
static uint64_t * nb_streams_packets
Definition: ffprobe.c:329
AVDynamicHDRPlus::targeted_system_display_actual_peak_luminance_flag
uint8_t targeted_system_display_actual_peak_luminance_flag
This flag shall be equal to 0 in bit streams conforming to this version of this Specification.
Definition: hdr_dynamic_metadata.h:277
do_show_program_version
static int do_show_program_version
Definition: ffprobe.c:118
Writer::print_section_header
void(* print_section_header)(WriterContext *wctx, void *data)
Definition: ffprobe.c:477
opt_common.h
DEFINE_OPT_SHOW_SECTION
#define DEFINE_OPT_SHOW_SECTION(section, target_section_id)
Definition: ffprobe.c:4061
AVInputFormat::flags
int flags
Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, AVFMT_NOTIMESTAMPS,...
Definition: avformat.h:568
AVRational::den
int den
Denominator.
Definition: rational.h:60
PRINT_STRING_VALIDATE
#define PRINT_STRING_VALIDATE
Definition: ffprobe.c:839
AVDOVIDecoderConfigurationRecord::bl_present_flag
uint8_t bl_present_flag
Definition: dovi_meta.h:59
AVDOVIRpuDataHeader::bl_bit_depth
uint8_t bl_bit_depth
Definition: dovi_meta.h:86
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
av_get_token
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
Definition: avstring.c:143
AVFrame::metadata
AVDictionary * metadata
metadata.
Definition: frame.h:708
AVHDRVivid3SplineParams::th_enable
AVRational th_enable
3Spline_TH_enable of three Spline.
Definition: hdr_dynamic_vivid_metadata.h:49
av_bprint_clear
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
Definition: bprint.c:232
version.h
AVHDRPlusColorTransformParams::num_distribution_maxrgb_percentiles
uint8_t num_distribution_maxrgb_percentiles
The number of linearized maxRGB values at given percentiles in the processing window in the scene.
Definition: hdr_dynamic_metadata.h:170
AVHDRPlusColorTransformParams::maxscl
AVRational maxscl[3]
The maximum of the color components of linearized RGB values in the processing window in the scene.
Definition: hdr_dynamic_metadata.h:157
SECTION_ID_PIXEL_FORMATS
@ SECTION_ID_PIXEL_FORMATS
Definition: ffprobe.c:197
av_dict_parse_string
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
Definition: dict.c:202
print_str_validate
#define print_str_validate(k, v)
Definition: ffprobe.c:1961
AVFrameSideData::type
enum AVFrameSideDataType type
Definition: frame.h:247
AVDOVIColorMetadata
Dolby Vision RPU colorspace metadata parameters.
Definition: dovi_meta.h:157
swscale
static int swscale(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[], int dstSliceY, int dstSliceH)
Definition: swscale.c:235
output_format
static char * output_format
Definition: ffprobe.c:143
hdr_dynamic_metadata.h
AV_PKT_DATA_AFD
@ AV_PKT_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
Definition: packet.h:262
compact_print_section_header
static void compact_print_section_header(WriterContext *wctx, void *data)
Definition: ffprobe.c:1229
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
ini_options
static const AVOption ini_options[]
Definition: ffprobe.c:1491
AVStream::r_frame_rate
AVRational r_frame_rate
Real base framerate of the stream.
Definition: avformat.h:1007
print_dynamic_hdr10_plus
static void print_dynamic_hdr10_plus(WriterContext *w, const AVDynamicHDRPlus *metadata)
Definition: ffprobe.c:2150
AV_PKT_DATA_SKIP_SAMPLES
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: packet.h:157
CHECK_COMPLIANCE
#define CHECK_COMPLIANCE(opt, opt_name)
AVDOVIDecoderConfigurationRecord::rpu_present_flag
uint8_t rpu_present_flag
Definition: dovi_meta.h:57
options
static const OptionDef * options
Definition: ffprobe.c:299
do_show_pixel_formats
static int do_show_pixel_formats
Definition: ffprobe.c:120
AVDOVIDecoderConfigurationRecord::el_present_flag
uint8_t el_present_flag
Definition: dovi_meta.h:58
AV_CODEC_ID_PROBE
@ AV_CODEC_ID_PROBE
codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
Definition: codec_id.h:594
av_find_input_format
const AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: format.c:144
AVMasteringDisplayMetadata::min_luminance
AVRational min_luminance
Min luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:52
FF_CODEC_PROPERTY_CLOSED_CAPTIONS
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS
Definition: avcodec.h:1906
avio_open
int avio_open(AVIOContext **s, const char *url, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
Definition: aviobuf.c:1239
AVFormatContext::duration
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1217
AVHDRVividColorToneMappingParams
Color tone mapping parameters at a processing window in a dynamic metadata for CUVA 005....
Definition: hdr_dynamic_vivid_metadata.h:77
AVPacket::stream_index
int stream_index
Definition: packet.h:493
FlatContext::sep_str
const char * sep_str
Definition: ffprobe.c:1361
DEFINE_WRITER_CLASS
#define DEFINE_WRITER_CLASS(name)
Definition: ffprobe.c:1016
opt_print_filename
static int opt_print_filename(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3857
AVCodecContext::coded_width
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:636
tc
#define tc
Definition: regdef.h:69
AV_PKT_DATA_AUDIO_SERVICE_TYPE
@ AV_PKT_DATA_AUDIO_SERVICE_TYPE
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
Definition: packet.h:121
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:270
XMLContext
Definition: ffprobe.c:1754
AVDOVIDecoderConfigurationRecord::dv_version_minor
uint8_t dv_version_minor
Definition: dovi_meta.h:54
do_show_program_tags
static int do_show_program_tags
Definition: ffprobe.c:128
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
WRITER_STRING_VALIDATION_REPLACE
@ WRITER_STRING_VALIDATION_REPLACE
Definition: ffprobe.c:464
AVHDRPlusColorTransformParams::center_of_ellipse_y
uint16_t center_of_ellipse_y
The y coordinate of the center position of the concentric internal and external ellipses of the ellip...
Definition: hdr_dynamic_metadata.h:110
av_log_default_callback
void av_log_default_callback(void *ptr, int level, const char *fmt, va_list vl)
Default logging callback.
Definition: log.c:348
unit_value::i
long long int i
Definition: ffprobe.c:398
writer_printf_avio
static void writer_printf_avio(WriterContext *wctx, const char *fmt,...)
Definition: ffprobe.c:600
CompactContext::item_sep_str
char * item_sep_str
Definition: ffprobe.c:1179
CompactContext::escape_mode_str
char * escape_mode_str
Definition: ffprobe.c:1183
mastering_display_metadata.h
av_dovi_get_mapping
static av_always_inline AVDOVIDataMapping * av_dovi_get_mapping(const AVDOVIMetadata *data)
Definition: dovi_meta.h:214
av_hash_final_hex
void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size)
Finalize a hash context and store the hexadecimal representation of the actual hash value as a string...
Definition: hash.c:215
AVCodecParameters::video_delay
int video_delay
Video only.
Definition: codec_par.h:150
FlatContext::sep
char sep
Definition: ffprobe.c:1362
JSONContext::item_start_end
const char * item_start_end
Definition: ffprobe.c:1591
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:246
AVCodecParameters::format
int format
Definition: codec_par.h:79
AVDynamicHDRVivid::params
AVHDRVividColorTransformParams params[3]
The color transform parameters for every processing window.
Definition: hdr_dynamic_vivid_metadata.h:325
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
bin_val
double bin_val
Definition: ffprobe.c:310
SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST
@ SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST
Definition: ffprobe.c:177
WRITER_STRING_VALIDATION_FAIL
@ WRITER_STRING_VALIDATION_FAIL
Definition: ffprobe.c:463
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVDictionaryEntry
Definition: dict.h:89
compact_options
static const AVOption compact_options[]
Definition: ffprobe.c:1193
CompactContext::has_nested_elems
int has_nested_elems[SECTION_MAX_NB_LEVELS]
Definition: ffprobe.c:1186
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
DEFAULT
#define DEFAULT
Definition: avdct.c:28
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:468
AVPacket
This structure stores compressed data.
Definition: packet.h:468
AVContentLightMetadata::MaxFALL
unsigned MaxFALL
Max average light level per frame (cd/m^2).
Definition: mastering_display_metadata.h:107
AVDOVIReshapingCurve::pivots
uint16_t pivots[AV_DOVI_MAX_PIECES+1]
Definition: dovi_meta.h:106
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
AVFrame::crop_top
size_t crop_top
Definition: frame.h:778
WriterContext::nb_sections
int nb_sections
number of sections
Definition: ffprobe.c:500
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:88
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
av_dict_copy
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
Definition: dict.c:239
cmdutils.h
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:511
AVDynamicHDRPlus::targeted_system_display_actual_peak_luminance
AVRational targeted_system_display_actual_peak_luminance[25][25]
The normalized actual peak luminance of the targeted system display.
Definition: hdr_dynamic_metadata.h:297
print_dynamic_hdr_vivid
static void print_dynamic_hdr_vivid(WriterContext *w, const AVDynamicHDRVivid *metadata)
Definition: ffprobe.c:2249
av_frame_side_data_name
const char * av_frame_side_data_name(enum AVFrameSideDataType type)
Definition: frame.c:931
SHOW_LIB_VERSION
#define SHOW_LIB_VERSION(libname, LIBNAME)
Definition: ffprobe.c:3631
OPT_BOOL
#define OPT_BOOL
Definition: cmdutils.h:110
writer_print_rational
static void writer_print_rational(WriterContext *wctx, const char *key, AVRational q, char sep)
Definition: ffprobe.c:879
d
d
Definition: ffmpeg_filter.c:368
XMLContext::indent_level
int indent_level
Definition: ffprobe.c:1757
int32_t
int32_t
Definition: audioconvert.c:56
AVDOVINLQParams::nlq_offset
uint16_t nlq_offset
Definition: dovi_meta.h:127
timestamp.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
flat_print_section_header
static void flat_print_section_header(WriterContext *wctx, void *data)
Definition: ffprobe.c:1426
AVCodecParameters::bit_rate
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:84
av_opt_get
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
Definition: opt.c:837
AVDOVIDataMapping::vdr_rpu_id
uint8_t vdr_rpu_id
Definition: dovi_meta.h:140
AVDynamicHDRVivid::system_start_code
uint8_t system_start_code
The system start code.
Definition: hdr_dynamic_vivid_metadata.h:314
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVFormatContext::start_time
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1207
writer_print_section_footer
static void writer_print_section_footer(WriterContext *wctx)
Definition: ffprobe.c:755
flat
static av_always_inline void flat(WaveformContext *s, AVFrame *in, AVFrame *out, int component, int intensity, int offset_y, int offset_x, int column, int mirror, int jobnr, int nb_jobs)
Definition: vf_waveform.c:1104
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST
@ SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST
Definition: ffprobe.c:181
AVHDRVividColorToneMappingParams::base_param_k3
int base_param_k3
indicates k3_0 in the base parameter, base_param_k3 == 1: k3_0 = base_param_k3 base_param_k3 == 2: k3...
Definition: hdr_dynamic_vivid_metadata.h:145
SECTION_ID_PROGRAM_STREAMS
@ SECTION_ID_PROGRAM_STREAMS
Definition: ffprobe.c:201
av_stereo3d_type_name
const char * av_stereo3d_type_name(unsigned int type)
Provide a human-readable name of a given stereo3d type.
Definition: stereo3d.c:58
get_frame_side_data_type
static const char * get_frame_side_data_type(void *data)
Definition: ffprobe.c:240
do_show_data
static int do_show_data
Definition: ffprobe.c:117
AVDOVIRpuDataHeader::disable_residual_flag
uint8_t disable_residual_flag
Definition: dovi_meta.h:91
AVClass::parent_log_context_offset
int parent_log_context_offset
Offset in the structure where a pointer to the parent context for logging is stored.
Definition: log.h:107
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
av_bprint_chars
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
Definition: bprint.c:145
LogBuffer::parent_category
AVClassCategory parent_category
Definition: ffprobe.c:342
SECTION_ID_PROGRAM_STREAM_DISPOSITION
@ SECTION_ID_PROGRAM_STREAM_DISPOSITION
Definition: ffprobe.c:198
avcodec_descriptor_get
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3722
AVHDRVivid3SplineParams::th_delta2
AVRational th_delta2
3Spline_TH_Delta2 of three Spline.
Definition: hdr_dynamic_vivid_metadata.h:63
AVStereo3D
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
Definition: stereo3d.h:173
AVDictionaryEntry::value
char * value
Definition: dict.h:91
AVStream::start_time
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Definition: avformat.h:890
show_data_hash
static char * show_data_hash
Definition: ffprobe.c:145
avstring.h
AVHDRVivid3SplineParams::th_enable_mb
AVRational th_enable_mb
three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive and in multiples of 1....
Definition: hdr_dynamic_vivid_metadata.h:42
AVClass::item_name
const char *(* item_name)(void *ctx)
A pointer to a function which returns the name of a context instance ctx associated with the class.
Definition: log.h:77
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
print_primaries
static void print_primaries(WriterContext *w, enum AVColorPrimaries color_primaries)
Definition: ffprobe.c:2463
AVAmbientViewingEnvironment::ambient_light_y
AVRational ambient_light_y
Normalized y chromaticity coordinate of the environmental ambient light in the nominal viewing enviro...
Definition: ambient_viewing_environment.h:54
show_help_options
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags)
Print help for all options matching specified flags.
Definition: cmdutils.c:109
do_show_streams
static int do_show_streams
Definition: ffprobe.c:115
unit_value::d
double d
Definition: ffprobe.c:398
InputFile::nb_streams
int nb_streams
Definition: ffmpeg.h:424
AVColorRange
AVColorRange
Visual content value range.
Definition: pixfmt.h:638
AVChapter::time_base
AVRational time_base
time base in which the start/end timestamps are specified
Definition: avformat.h:1076
int
int
Definition: ffmpeg_filter.c:368
AVHDRVividColorToneMappingParams::three_spline
AVHDRVivid3SplineParams three_spline[2]
Definition: hdr_dynamic_vivid_metadata.h:225
av_bprint_append_data
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
Definition: bprint.c:163
AVHDRVividColorToneMappingParams::base_param_m_p
AVRational base_param_m_p
base_param_m_p in the base parameter, in multiples of 1.0/16383.
Definition: hdr_dynamic_vivid_metadata.h:95
AVDOVIDataMapping::nlq
AVDOVINLQParams nlq[3]
Definition: dovi_meta.h:149
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
snprintf
#define snprintf
Definition: snprintf.h:34
stream_specifier
static char * stream_specifier
Definition: ffprobe.c:144
writer_print_integers
static void writer_print_integers(WriterContext *wctx, const char *name, uint8_t *data, int size, const char *format, int columns, int bytes, int offset_add)
Definition: ffprobe.c:957
log_callback
static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
Definition: ffprobe.c:348
AVCodecParameters::initial_padding
int initial_padding
Audio only.
Definition: codec_par.h:190
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1143
AVDOVIDataMapping
Dolby Vision RPU data mapping parameters.
Definition: dovi_meta.h:139
SECTION_ID_CHAPTERS
@ SECTION_ID_CHAPTERS
Definition: ffprobe.c:168
print_time
#define print_time(k, v, tb)
Definition: ffprobe.c:1962
default_print_str
static void default_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1097
AVSphericalMapping
This structure describes how to handle spherical videos, outlining information about projection,...
Definition: spherical.h:78
av_color_transfer_name
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition: pixdesc.c:3319
print_str_opt
#define print_str_opt(k, v)
Definition: ffprobe.c:1960
av_tolower
static av_const int av_tolower(int c)
Locale-independent conversion of ASCII characters to lowercase.
Definition: avstring.h:237
WriterContext::nb_section_packet
unsigned int nb_section_packet
number of the packet section in case we are in "packets_and_frames" section
Definition: ffprobe.c:512
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:44
parse_number
int parse_number(const char *context, const char *numstr, int type, double min, double max, double *dst)
Parse a string and return its corresponding value as a double.
Definition: cmdutils.c:86
AVSubtitle::start_display_time
uint32_t start_display_time
Definition: avcodec.h:2271
CompactContext::terminate_line
int terminate_line[SECTION_MAX_NB_LEVELS]
Definition: ffprobe.c:1187
default_print_section_footer
static void default_print_section_footer(WriterContext *wctx)
Definition: ffprobe.c:1084
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
SECTION_ID_PIXEL_FORMAT_COMPONENT
@ SECTION_ID_PIXEL_FORMAT_COMPONENT
Definition: ffprobe.c:195
INIContext::hierarchical
int hierarchical
Definition: ffprobe.c:1485
AVFrame::repeat_pict
int repeat_pict
Number of fields in this frame which should be repeated, i.e.
Definition: frame.h:521
AVSphericalMapping::yaw
int32_t yaw
Rotation around the up vector [-180, 180].
Definition: spherical.h:122
AVHDRVividColorToneMappingParams::base_param_m_b
AVRational base_param_m_b
base_param_m_b in the base parameter, in multiples of 1/1023.
Definition: hdr_dynamic_vivid_metadata.h:116
SECTION_ID_PACKET
@ SECTION_ID_PACKET
Definition: ffprobe.c:187
swscale.h
AV_DICT_DONT_STRDUP_KEY
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
Definition: dict.h:77
AVInputFormat::priv_class
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:579
JSONContext::compact
int compact
Definition: ffprobe.c:1590
AVHDRVividColorToneMappingParams::base_param_m_m
AVRational base_param_m_m
base_param_m_m in the base parameter, in multiples of 1.0/10.
Definition: hdr_dynamic_vivid_metadata.h:102
unit_second_str
static const char unit_second_str[]
Definition: ffprobe.c:323
AVHDRPlusColorTransformParams::bezier_curve_anchors
AVRational bezier_curve_anchors[15]
The intermediate anchor parameters of the tone mapping function in the processing window in the scene...
Definition: hdr_dynamic_metadata.h:216
av_x_if_null
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
Definition: avutil.h:312
AVDynamicHDRPlus::num_cols_mastering_display_actual_peak_luminance
uint8_t num_cols_mastering_display_actual_peak_luminance
The number of columns in the mastering_display_actual_peak_luminance array.
Definition: hdr_dynamic_metadata.h:315
AVDOVIDataMapping::num_x_partitions
uint32_t num_x_partitions
Definition: dovi_meta.h:147
AVPacket::side_data_elems
int side_data_elems
Definition: packet.h:503
av_display_rotation_get
double av_display_rotation_get(const int32_t matrix[9])
Extract the rotation component of the transformation matrix.
Definition: display.c:35
version.h
writer_class
static const AVClass writer_class
Definition: ffprobe.c:550
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2884
do_show_packets
static int do_show_packets
Definition: ffprobe.c:113
show_programs
static int show_programs(WriterContext *w, InputFile *ifile)
Definition: ffprobe.c:3306
JSONContext
Definition: ffprobe.c:1587
av_fourcc2str
#define av_fourcc2str(fourcc)
Definition: avutil.h:358
pthread_mutex_lock
#define pthread_mutex_lock(a)
Definition: ffprobe.c:75
print_list_fmt
#define print_list_fmt(k, f, n, m,...)
Definition: ffprobe.c:1945
writer_w8_printf
static void writer_w8_printf(WriterContext *wctx, int b)
Definition: ffprobe.c:609
bprint_bytes
static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
Definition: ffprobe.c:582
avdevice_register_all
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
Definition: alldevices.c:65
AVDOVIDecoderConfigurationRecord
Definition: dovi_meta.h:52
writer_register
static int writer_register(const Writer *writer)
Definition: ffprobe.c:991