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 
31 #include "libavformat/avformat.h"
32 #include "libavcodec/avcodec.h"
33 #include "libavutil/avassert.h"
34 #include "libavutil/avstring.h"
35 #include "libavutil/bprint.h"
37 #include "libavutil/display.h"
38 #include "libavutil/hash.h"
41 #include "libavutil/dovi_meta.h"
42 #include "libavutil/opt.h"
43 #include "libavutil/pixdesc.h"
44 #include "libavutil/spherical.h"
45 #include "libavutil/stereo3d.h"
46 #include "libavutil/dict.h"
47 #include "libavutil/intreadwrite.h"
48 #include "libavutil/libm.h"
49 #include "libavutil/parseutils.h"
50 #include "libavutil/timecode.h"
51 #include "libavutil/timestamp.h"
52 #include "libavdevice/avdevice.h"
53 #include "libswscale/swscale.h"
56 #include "cmdutils.h"
57 
58 #include "libavutil/thread.h"
59 
60 #if !HAVE_THREADS
61 # ifdef pthread_mutex_lock
62 # undef pthread_mutex_lock
63 # endif
64 # define pthread_mutex_lock(a) do{}while(0)
65 # ifdef pthread_mutex_unlock
66 # undef pthread_mutex_unlock
67 # endif
68 # define pthread_mutex_unlock(a) do{}while(0)
69 #endif
70 
71 typedef struct InputStream {
72  AVStream *st;
73 
75 } InputStream;
76 
77 typedef struct InputFile {
79 
81  int nb_streams;
82 } InputFile;
83 
84 const char program_name[] = "ffprobe";
85 const int program_birth_year = 2007;
86 
87 static int do_bitexact = 0;
88 static int do_count_frames = 0;
89 static int do_count_packets = 0;
90 static int do_read_frames = 0;
91 static int do_read_packets = 0;
92 static int do_show_chapters = 0;
93 static int do_show_error = 0;
94 static int do_show_format = 0;
95 static int do_show_frames = 0;
96 static int do_show_packets = 0;
97 static int do_show_programs = 0;
98 static int do_show_streams = 0;
100 static int do_show_data = 0;
101 static int do_show_program_version = 0;
103 static int do_show_pixel_formats = 0;
106 static int do_show_log = 0;
107 
108 static int do_show_chapter_tags = 0;
109 static int do_show_format_tags = 0;
110 static int do_show_frame_tags = 0;
111 static int do_show_program_tags = 0;
112 static int do_show_stream_tags = 0;
113 static int do_show_packet_tags = 0;
114 
115 static int show_value_unit = 0;
116 static int use_value_prefix = 0;
119 static int show_private_data = 1;
120 
121 #define SHOW_OPTIONAL_FIELDS_AUTO -1
122 #define SHOW_OPTIONAL_FIELDS_NEVER 0
123 #define SHOW_OPTIONAL_FIELDS_ALWAYS 1
125 
126 static char *print_format;
127 static char *stream_specifier;
128 static char *show_data_hash;
129 
130 typedef struct ReadInterval {
131  int id; ///< identifier
132  int64_t start, end; ///< start, end in second/AV_TIME_BASE units
136 } ReadInterval;
137 
139 static int read_intervals_nb = 0;
140 
141 static int find_stream_info = 1;
142 
143 /* section structure definition */
144 
145 #define SECTION_MAX_NB_CHILDREN 10
146 
147 struct section {
148  int id; ///< unique id identifying a section
149  const char *name;
150 
151 #define SECTION_FLAG_IS_WRAPPER 1 ///< the section only contains other sections, but has no data at its own level
152 #define SECTION_FLAG_IS_ARRAY 2 ///< the section contains an array of elements of the same type
153 #define SECTION_FLAG_HAS_VARIABLE_FIELDS 4 ///< the section may contain a variable number of fields with variable keys.
154  /// For these sections the element_name field is mandatory.
155  int flags;
156  int children_ids[SECTION_MAX_NB_CHILDREN+1]; ///< list of children section IDS, terminated by -1
157  const char *element_name; ///< name of the contained element, if provided
158  const char *unique_name; ///< unique section name, in case the name is ambiguous
161 };
162 
163 typedef enum {
213 } SectionID;
214 
215 static struct section sections[] = {
217  [SECTION_ID_CHAPTER] = { SECTION_ID_CHAPTER, "chapter", 0, { SECTION_ID_CHAPTER_TAGS, -1 } },
218  [SECTION_ID_CHAPTER_TAGS] = { SECTION_ID_CHAPTER_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "chapter_tags" },
219  [SECTION_ID_ERROR] = { SECTION_ID_ERROR, "error", 0, { -1 } },
220  [SECTION_ID_FORMAT] = { SECTION_ID_FORMAT, "format", 0, { SECTION_ID_FORMAT_TAGS, -1 } },
221  [SECTION_ID_FORMAT_TAGS] = { SECTION_ID_FORMAT_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "format_tags" },
224  [SECTION_ID_FRAME_TAGS] = { SECTION_ID_FRAME_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "frame_tags" },
225  [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" },
234  [SECTION_ID_FRAME_LOG] = { SECTION_ID_FRAME_LOG, "log", 0, { -1 }, },
236  [SECTION_ID_LIBRARY_VERSION] = { SECTION_ID_LIBRARY_VERSION, "library_version", 0, { -1 } },
240  [SECTION_ID_PACKET_TAGS] = { SECTION_ID_PACKET_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "packet_tags" },
241  [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" },
242  [SECTION_ID_PACKET_SIDE_DATA] = { SECTION_ID_PACKET_SIDE_DATA, "side_data", 0, { -1 } },
245  [SECTION_ID_PIXEL_FORMAT_FLAGS] = { SECTION_ID_PIXEL_FORMAT_FLAGS, "flags", 0, { -1 }, .unique_name = "pixel_format_flags" },
246  [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" },
248  [SECTION_ID_PROGRAM_STREAM_DISPOSITION] = { SECTION_ID_PROGRAM_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "program_stream_disposition" },
249  [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" },
251  [SECTION_ID_PROGRAM_STREAMS] = { SECTION_ID_PROGRAM_STREAMS, "streams", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PROGRAM_STREAM, -1 }, .unique_name = "program_streams" },
253  [SECTION_ID_PROGRAM_TAGS] = { SECTION_ID_PROGRAM_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "program_tags" },
254  [SECTION_ID_PROGRAM_VERSION] = { SECTION_ID_PROGRAM_VERSION, "program_version", 0, { -1 } },
262  [SECTION_ID_STREAM_DISPOSITION] = { SECTION_ID_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "stream_disposition" },
263  [SECTION_ID_STREAM_TAGS] = { SECTION_ID_STREAM_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "stream_tags" },
264  [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" },
265  [SECTION_ID_STREAM_SIDE_DATA] = { SECTION_ID_STREAM_SIDE_DATA, "side_data", 0, { -1 } },
266  [SECTION_ID_SUBTITLE] = { SECTION_ID_SUBTITLE, "subtitle", 0, { -1 } },
267 };
268 
269 static const OptionDef *options;
270 
271 /* FFprobe context */
272 static const char *input_filename;
273 static const char *print_input_filename;
274 static const AVInputFormat *iformat = NULL;
275 
276 static struct AVHashContext *hash;
277 
278 static const struct {
279  double bin_val;
280  double dec_val;
281  const char *bin_str;
282  const char *dec_str;
283 } si_prefixes[] = {
284  { 1.0, 1.0, "", "" },
285  { 1.024e3, 1e3, "Ki", "K" },
286  { 1.048576e6, 1e6, "Mi", "M" },
287  { 1.073741824e9, 1e9, "Gi", "G" },
288  { 1.099511627776e12, 1e12, "Ti", "T" },
289  { 1.125899906842624e15, 1e15, "Pi", "P" },
290 };
291 
292 static const char unit_second_str[] = "s" ;
293 static const char unit_hertz_str[] = "Hz" ;
294 static const char unit_byte_str[] = "byte" ;
295 static const char unit_bit_per_second_str[] = "bit/s";
296 
297 static int nb_streams;
298 static uint64_t *nb_streams_packets;
299 static uint64_t *nb_streams_frames;
300 static int *selected_streams;
301 
302 #if HAVE_THREADS
303 pthread_mutex_t log_mutex;
304 #endif
305 typedef struct LogBuffer {
308  char *log_message;
310  char *parent_name;
312 }LogBuffer;
313 
315 static int log_buffer_size;
316 
317 static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
318 {
319  AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
320  va_list vl2;
321  char line[1024];
322  static int print_prefix = 1;
323  void *new_log_buffer;
324 
325  va_copy(vl2, vl);
326  av_log_default_callback(ptr, level, fmt, vl);
327  av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix);
328  va_end(vl2);
329 
330 #if HAVE_THREADS
331  pthread_mutex_lock(&log_mutex);
332 
333  new_log_buffer = av_realloc_array(log_buffer, log_buffer_size + 1, sizeof(*log_buffer));
334  if (new_log_buffer) {
335  char *msg;
336  int i;
337 
338  log_buffer = new_log_buffer;
339  memset(&log_buffer[log_buffer_size], 0, sizeof(log_buffer[log_buffer_size]));
341  if (avc) {
344  }
347  for (i=strlen(msg) - 1; i>=0 && msg[i] == '\n'; i--) {
348  msg[i] = 0;
349  }
350  if (avc && avc->parent_log_context_offset) {
351  AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) +
353  if (parent && *parent) {
354  log_buffer[log_buffer_size].parent_name = av_strdup((*parent)->item_name(parent));
356  (*parent)->get_category ? (*parent)->get_category(parent) :(*parent)->category;
357  }
358  }
359  log_buffer_size ++;
360  }
361 
362  pthread_mutex_unlock(&log_mutex);
363 #endif
364 }
365 
366 static void ffprobe_cleanup(int ret)
367 {
368  int i;
369  for (i = 0; i < FF_ARRAY_ELEMS(sections); i++)
370  av_dict_free(&(sections[i].entries_to_show));
371 
372 #if HAVE_THREADS
373  pthread_mutex_destroy(&log_mutex);
374 #endif
375 }
376 
377 struct unit_value {
378  union { double d; long long int i; } val;
379  const char *unit;
380 };
381 
382 static char *value_string(char *buf, int buf_size, struct unit_value uv)
383 {
384  double vald;
385  long long int vali;
386  int show_float = 0;
387 
388  if (uv.unit == unit_second_str) {
389  vald = uv.val.d;
390  show_float = 1;
391  } else {
392  vald = vali = uv.val.i;
393  }
394 
396  double secs;
397  int hours, mins;
398  secs = vald;
399  mins = (int)secs / 60;
400  secs = secs - mins * 60;
401  hours = mins / 60;
402  mins %= 60;
403  snprintf(buf, buf_size, "%d:%02d:%09.6f", hours, mins, secs);
404  } else {
405  const char *prefix_string = "";
406 
407  if (use_value_prefix && vald > 1) {
408  long long int index;
409 
411  index = (long long int) (log2(vald)) / 10;
413  vald /= si_prefixes[index].bin_val;
414  prefix_string = si_prefixes[index].bin_str;
415  } else {
416  index = (long long int) (log10(vald)) / 3;
418  vald /= si_prefixes[index].dec_val;
419  prefix_string = si_prefixes[index].dec_str;
420  }
421  vali = vald;
422  }
423 
424  if (show_float || (use_value_prefix && vald != (long long int)vald))
425  snprintf(buf, buf_size, "%f", vald);
426  else
427  snprintf(buf, buf_size, "%lld", vali);
428  av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || show_value_unit ? " " : "",
429  prefix_string, show_value_unit ? uv.unit : "");
430  }
431 
432  return buf;
433 }
434 
435 /* WRITERS API */
436 
437 typedef struct WriterContext WriterContext;
438 
439 #define WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS 1
440 #define WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER 2
441 
442 typedef enum {
448 
449 typedef struct Writer {
450  const AVClass *priv_class; ///< private class of the writer, if any
451  int priv_size; ///< private size for the writer context
452  const char *name;
453 
454  int (*init) (WriterContext *wctx);
455  void (*uninit)(WriterContext *wctx);
456 
459  void (*print_integer) (WriterContext *wctx, const char *, long long int);
460  void (*print_rational) (WriterContext *wctx, AVRational *q, char *sep);
461  void (*print_string) (WriterContext *wctx, const char *, const char *);
462  int flags; ///< a combination or WRITER_FLAG_*
463 } Writer;
464 
465 #define SECTION_MAX_NB_LEVELS 10
466 
468  const AVClass *class; ///< class of the writer
469  const Writer *writer; ///< the Writer of which this is an instance
470  char *name; ///< name of this writer instance
471  void *priv; ///< private data for use by the filter
472 
473  const struct section *sections; ///< array containing all sections
474  int nb_sections; ///< number of sections
475 
476  int level; ///< current level, starting from 0
477 
478  /** number of the item printed in the given section, starting from 0 */
480 
481  /** section per each level */
483  AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]; ///< generic print buffer dedicated to each section,
484  /// used by various writers
485 
486  unsigned int nb_section_packet; ///< number of the packet section in case we are in "packets_and_frames" section
487  unsigned int nb_section_frame; ///< number of the frame section in case we are in "packets_and_frames" section
488  unsigned int nb_section_packet_frame; ///< nb_section_packet or nb_section_frame according if is_packets_and_frames
489 
493 };
494 
495 static const char *writer_get_name(void *p)
496 {
497  WriterContext *wctx = p;
498  return wctx->writer->name;
499 }
500 
501 #define OFFSET(x) offsetof(WriterContext, x)
502 
503 static const AVOption writer_options[] = {
504  { "string_validation", "set string validation mode",
505  OFFSET(string_validation), AV_OPT_TYPE_INT, {.i64=WRITER_STRING_VALIDATION_REPLACE}, 0, WRITER_STRING_VALIDATION_NB-1, .unit = "sv" },
506  { "sv", "set string validation mode",
507  OFFSET(string_validation), AV_OPT_TYPE_INT, {.i64=WRITER_STRING_VALIDATION_REPLACE}, 0, WRITER_STRING_VALIDATION_NB-1, .unit = "sv" },
508  { "ignore", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = WRITER_STRING_VALIDATION_IGNORE}, .unit = "sv" },
509  { "replace", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = WRITER_STRING_VALIDATION_REPLACE}, .unit = "sv" },
510  { "fail", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = WRITER_STRING_VALIDATION_FAIL}, .unit = "sv" },
511  { "string_validation_replacement", "set string validation replacement string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, {.str=""}},
512  { "svr", "set string validation replacement string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, {.str="\xEF\xBF\xBD"}},
513  { NULL }
514 };
515 
516 static void *writer_child_next(void *obj, void *prev)
517 {
518  WriterContext *ctx = obj;
519  if (!prev && ctx->writer && ctx->writer->priv_class && ctx->priv)
520  return ctx->priv;
521  return NULL;
522 }
523 
524 static const AVClass writer_class = {
525  .class_name = "Writer",
526  .item_name = writer_get_name,
527  .option = writer_options,
528  .version = LIBAVUTIL_VERSION_INT,
529  .child_next = writer_child_next,
530 };
531 
532 static void writer_close(WriterContext **wctx)
533 {
534  int i;
535 
536  if (!*wctx)
537  return;
538 
539  if ((*wctx)->writer->uninit)
540  (*wctx)->writer->uninit(*wctx);
541  for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
542  av_bprint_finalize(&(*wctx)->section_pbuf[i], NULL);
543  if ((*wctx)->writer->priv_class)
544  av_opt_free((*wctx)->priv);
545  av_freep(&((*wctx)->priv));
546  av_opt_free(*wctx);
547  av_freep(wctx);
548 }
549 
550 static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
551 {
552  int i;
553  av_bprintf(bp, "0X");
554  for (i = 0; i < ubuf_size; i++)
555  av_bprintf(bp, "%02X", ubuf[i]);
556 }
557 
558 
559 static int writer_open(WriterContext **wctx, const Writer *writer, const char *args,
560  const struct section *sections, int nb_sections)
561 {
562  int i, ret = 0;
563 
564  if (!(*wctx = av_mallocz(sizeof(WriterContext)))) {
565  ret = AVERROR(ENOMEM);
566  goto fail;
567  }
568 
569  if (!((*wctx)->priv = av_mallocz(writer->priv_size))) {
570  ret = AVERROR(ENOMEM);
571  goto fail;
572  }
573 
574  (*wctx)->class = &writer_class;
575  (*wctx)->writer = writer;
576  (*wctx)->level = -1;
577  (*wctx)->sections = sections;
578  (*wctx)->nb_sections = nb_sections;
579 
580  av_opt_set_defaults(*wctx);
581 
582  if (writer->priv_class) {
583  void *priv_ctx = (*wctx)->priv;
584  *((const AVClass **)priv_ctx) = writer->priv_class;
585  av_opt_set_defaults(priv_ctx);
586  }
587 
588  /* convert options to dictionary */
589  if (args) {
591  const AVDictionaryEntry *opt = NULL;
592 
593  if ((ret = av_dict_parse_string(&opts, args, "=", ":", 0)) < 0) {
594  av_log(*wctx, AV_LOG_ERROR, "Failed to parse option string '%s' provided to writer context\n", args);
595  av_dict_free(&opts);
596  goto fail;
597  }
598 
599  while ((opt = av_dict_get(opts, "", opt, AV_DICT_IGNORE_SUFFIX))) {
600  if ((ret = av_opt_set(*wctx, opt->key, opt->value, AV_OPT_SEARCH_CHILDREN)) < 0) {
601  av_log(*wctx, AV_LOG_ERROR, "Failed to set option '%s' with value '%s' provided to writer context\n",
602  opt->key, opt->value);
603  av_dict_free(&opts);
604  goto fail;
605  }
606  }
607 
608  av_dict_free(&opts);
609  }
610 
611  /* validate replace string */
612  {
613  const uint8_t *p = (*wctx)->string_validation_replacement;
614  const uint8_t *endp = p + strlen(p);
615  while (*p) {
616  const uint8_t *p0 = p;
617  int32_t code;
618  ret = av_utf8_decode(&code, &p, endp, (*wctx)->string_validation_utf8_flags);
619  if (ret < 0) {
620  AVBPrint bp;
622  bprint_bytes(&bp, p0, p-p0),
623  av_log(wctx, AV_LOG_ERROR,
624  "Invalid UTF8 sequence %s found in string validation replace '%s'\n",
625  bp.str, (*wctx)->string_validation_replacement);
626  return ret;
627  }
628  }
629  }
630 
631  for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
632  av_bprint_init(&(*wctx)->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED);
633 
634  if ((*wctx)->writer->init)
635  ret = (*wctx)->writer->init(*wctx);
636  if (ret < 0)
637  goto fail;
638 
639  return 0;
640 
641 fail:
642  writer_close(wctx);
643  return ret;
644 }
645 
647  int section_id)
648 {
649  int parent_section_id;
650  wctx->level++;
652  parent_section_id = wctx->level ?
653  (wctx->section[wctx->level-1])->id : SECTION_ID_NONE;
654 
655  wctx->nb_item[wctx->level] = 0;
656  wctx->section[wctx->level] = &wctx->sections[section_id];
657 
658  if (section_id == SECTION_ID_PACKETS_AND_FRAMES) {
659  wctx->nb_section_packet = wctx->nb_section_frame =
660  wctx->nb_section_packet_frame = 0;
661  } else if (parent_section_id == SECTION_ID_PACKETS_AND_FRAMES) {
662  wctx->nb_section_packet_frame = section_id == SECTION_ID_PACKET ?
663  wctx->nb_section_packet : wctx->nb_section_frame;
664  }
665 
666  if (wctx->writer->print_section_header)
667  wctx->writer->print_section_header(wctx);
668 }
669 
671 {
672  int section_id = wctx->section[wctx->level]->id;
673  int parent_section_id = wctx->level ?
674  wctx->section[wctx->level-1]->id : SECTION_ID_NONE;
675 
676  if (parent_section_id != SECTION_ID_NONE)
677  wctx->nb_item[wctx->level-1]++;
678  if (parent_section_id == SECTION_ID_PACKETS_AND_FRAMES) {
679  if (section_id == SECTION_ID_PACKET) wctx->nb_section_packet++;
680  else wctx->nb_section_frame++;
681  }
682  if (wctx->writer->print_section_footer)
683  wctx->writer->print_section_footer(wctx);
684  wctx->level--;
685 }
686 
687 static inline void writer_print_integer(WriterContext *wctx,
688  const char *key, long long int val)
689 {
690  const struct section *section = wctx->section[wctx->level];
691 
693  wctx->writer->print_integer(wctx, key, val);
694  wctx->nb_item[wctx->level]++;
695  }
696 }
697 
698 static inline int validate_string(WriterContext *wctx, char **dstp, const char *src)
699 {
700  const uint8_t *p, *endp;
701  AVBPrint dstbuf;
702  int invalid_chars_nb = 0, ret = 0;
703 
705 
706  endp = src + strlen(src);
707  for (p = (uint8_t *)src; *p;) {
708  uint32_t code;
709  int invalid = 0;
710  const uint8_t *p0 = p;
711 
712  if (av_utf8_decode(&code, &p, endp, wctx->string_validation_utf8_flags) < 0) {
713  AVBPrint bp;
715  bprint_bytes(&bp, p0, p-p0);
716  av_log(wctx, AV_LOG_DEBUG,
717  "Invalid UTF-8 sequence %s found in string '%s'\n", bp.str, src);
718  invalid = 1;
719  }
720 
721  if (invalid) {
722  invalid_chars_nb++;
723 
724  switch (wctx->string_validation) {
726  av_log(wctx, AV_LOG_ERROR,
727  "Invalid UTF-8 sequence found in string '%s'\n", src);
729  goto end;
730  break;
731 
733  av_bprintf(&dstbuf, "%s", wctx->string_validation_replacement);
734  break;
735  }
736  }
737 
738  if (!invalid || wctx->string_validation == WRITER_STRING_VALIDATION_IGNORE)
739  av_bprint_append_data(&dstbuf, p0, p-p0);
740  }
741 
742  if (invalid_chars_nb && wctx->string_validation == WRITER_STRING_VALIDATION_REPLACE) {
743  av_log(wctx, AV_LOG_WARNING,
744  "%d invalid UTF-8 sequence(s) found in string '%s', replaced with '%s'\n",
745  invalid_chars_nb, src, wctx->string_validation_replacement);
746  }
747 
748 end:
749  av_bprint_finalize(&dstbuf, dstp);
750  return ret;
751 }
752 
753 #define PRINT_STRING_OPT 1
754 #define PRINT_STRING_VALIDATE 2
755 
756 static inline int writer_print_string(WriterContext *wctx,
757  const char *key, const char *val, int flags)
758 {
759  const struct section *section = wctx->section[wctx->level];
760  int ret = 0;
761 
764  && (flags & PRINT_STRING_OPT)
766  return 0;
767 
770  char *key1 = NULL, *val1 = NULL;
771  ret = validate_string(wctx, &key1, key);
772  if (ret < 0) goto end;
773  ret = validate_string(wctx, &val1, val);
774  if (ret < 0) goto end;
775  wctx->writer->print_string(wctx, key1, val1);
776  end:
777  if (ret < 0) {
778  av_log(wctx, AV_LOG_ERROR,
779  "Invalid key=value string combination %s=%s in section %s\n",
781  }
782  av_free(key1);
783  av_free(val1);
784  } else {
785  wctx->writer->print_string(wctx, key, val);
786  }
787 
788  wctx->nb_item[wctx->level]++;
789  }
790 
791  return ret;
792 }
793 
794 static inline void writer_print_rational(WriterContext *wctx,
795  const char *key, AVRational q, char sep)
796 {
797  AVBPrint buf;
799  av_bprintf(&buf, "%d%c%d", q.num, sep, q.den);
800  writer_print_string(wctx, key, buf.str, 0);
801 }
802 
803 static void writer_print_time(WriterContext *wctx, const char *key,
804  int64_t ts, const AVRational *time_base, int is_duration)
805 {
806  char buf[128];
807 
808  if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
810  } else {
811  double d = ts * av_q2d(*time_base);
812  struct unit_value uv;
813  uv.val.d = d;
814  uv.unit = unit_second_str;
815  value_string(buf, sizeof(buf), uv);
816  writer_print_string(wctx, key, buf, 0);
817  }
818 }
819 
820 static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, int is_duration)
821 {
822  if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
824  } else {
825  writer_print_integer(wctx, key, ts);
826  }
827 }
828 
829 static void writer_print_data(WriterContext *wctx, const char *name,
830  uint8_t *data, int size)
831 {
832  AVBPrint bp;
833  int offset = 0, l, i;
834 
836  av_bprintf(&bp, "\n");
837  while (size) {
838  av_bprintf(&bp, "%08x: ", offset);
839  l = FFMIN(size, 16);
840  for (i = 0; i < l; i++) {
841  av_bprintf(&bp, "%02x", data[i]);
842  if (i & 1)
843  av_bprintf(&bp, " ");
844  }
845  av_bprint_chars(&bp, ' ', 41 - 2 * i - i / 2);
846  for (i = 0; i < l; i++)
847  av_bprint_chars(&bp, data[i] - 32U < 95 ? data[i] : '.', 1);
848  av_bprintf(&bp, "\n");
849  offset += l;
850  data += l;
851  size -= l;
852  }
853  writer_print_string(wctx, name, bp.str, 0);
854  av_bprint_finalize(&bp, NULL);
855 }
856 
857 static void writer_print_data_hash(WriterContext *wctx, const char *name,
858  uint8_t *data, int size)
859 {
860  char *p, buf[AV_HASH_MAX_SIZE * 2 + 64] = { 0 };
861 
862  if (!hash)
863  return;
866  snprintf(buf, sizeof(buf), "%s:", av_hash_get_name(hash));
867  p = buf + strlen(buf);
868  av_hash_final_hex(hash, p, buf + sizeof(buf) - p);
869  writer_print_string(wctx, name, buf, 0);
870 }
871 
872 static void writer_print_integers(WriterContext *wctx, const char *name,
873  uint8_t *data, int size, const char *format,
874  int columns, int bytes, int offset_add)
875 {
876  AVBPrint bp;
877  int offset = 0, l, i;
878 
880  av_bprintf(&bp, "\n");
881  while (size) {
882  av_bprintf(&bp, "%08x: ", offset);
883  l = FFMIN(size, columns);
884  for (i = 0; i < l; i++) {
885  if (bytes == 1) av_bprintf(&bp, format, *data);
886  else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
887  else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
888  data += bytes;
889  size --;
890  }
891  av_bprintf(&bp, "\n");
892  offset += offset_add;
893  }
894  writer_print_string(wctx, name, bp.str, 0);
895  av_bprint_finalize(&bp, NULL);
896 }
897 
898 #define MAX_REGISTERED_WRITERS_NB 64
899 
901 
902 static int writer_register(const Writer *writer)
903 {
904  static int next_registered_writer_idx = 0;
905 
906  if (next_registered_writer_idx == MAX_REGISTERED_WRITERS_NB)
907  return AVERROR(ENOMEM);
908 
909  registered_writers[next_registered_writer_idx++] = writer;
910  return 0;
911 }
912 
913 static const Writer *writer_get_by_name(const char *name)
914 {
915  int i;
916 
917  for (i = 0; registered_writers[i]; i++)
918  if (!strcmp(registered_writers[i]->name, name))
919  return registered_writers[i];
920 
921  return NULL;
922 }
923 
924 
925 /* WRITERS */
926 
927 #define DEFINE_WRITER_CLASS(name) \
928 static const char *name##_get_name(void *ctx) \
929 { \
930  return #name ; \
931 } \
932 static const AVClass name##_class = { \
933  .class_name = #name, \
934  .item_name = name##_get_name, \
935  .option = name##_options \
936 }
937 
938 /* Default output */
939 
940 typedef struct DefaultContext {
941  const AVClass *class;
942  int nokey;
946 
947 #undef OFFSET
948 #define OFFSET(x) offsetof(DefaultContext, x)
949 
950 static const AVOption default_options[] = {
951  { "noprint_wrappers", "do not print headers and footers", OFFSET(noprint_wrappers), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
952  { "nw", "do not print headers and footers", OFFSET(noprint_wrappers), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
953  { "nokey", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
954  { "nk", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
955  {NULL},
956 };
957 
958 DEFINE_WRITER_CLASS(default);
959 
960 /* lame uppercasing routine, assumes the string is lower case ASCII */
961 static inline char *upcase_string(char *dst, size_t dst_size, const char *src)
962 {
963  int i;
964  for (i = 0; src[i] && i < dst_size-1; i++)
965  dst[i] = av_toupper(src[i]);
966  dst[i] = 0;
967  return dst;
968 }
969 
971 {
972  DefaultContext *def = wctx->priv;
973  char buf[32];
974  const struct section *section = wctx->section[wctx->level];
975  const struct section *parent_section = wctx->level ?
976  wctx->section[wctx->level-1] : NULL;
977 
978  av_bprint_clear(&wctx->section_pbuf[wctx->level]);
979  if (parent_section &&
980  !(parent_section->flags & (SECTION_FLAG_IS_WRAPPER|SECTION_FLAG_IS_ARRAY))) {
981  def->nested_section[wctx->level] = 1;
982  av_bprintf(&wctx->section_pbuf[wctx->level], "%s%s:",
983  wctx->section_pbuf[wctx->level-1].str,
984  upcase_string(buf, sizeof(buf),
986  }
987 
988  if (def->noprint_wrappers || def->nested_section[wctx->level])
989  return;
990 
992  printf("[%s]\n", upcase_string(buf, sizeof(buf), section->name));
993 }
994 
996 {
997  DefaultContext *def = wctx->priv;
998  const struct section *section = wctx->section[wctx->level];
999  char buf[32];
1000 
1001  if (def->noprint_wrappers || def->nested_section[wctx->level])
1002  return;
1003 
1005  printf("[/%s]\n", upcase_string(buf, sizeof(buf), section->name));
1006 }
1007 
1008 static void default_print_str(WriterContext *wctx, const char *key, const char *value)
1009 {
1010  DefaultContext *def = wctx->priv;
1011 
1012  if (!def->nokey)
1013  printf("%s%s=", wctx->section_pbuf[wctx->level].str, key);
1014  printf("%s\n", value);
1015 }
1016 
1017 static void default_print_int(WriterContext *wctx, const char *key, long long int value)
1018 {
1019  DefaultContext *def = wctx->priv;
1020 
1021  if (!def->nokey)
1022  printf("%s%s=", wctx->section_pbuf[wctx->level].str, key);
1023  printf("%lld\n", value);
1024 }
1025 
1026 static const Writer default_writer = {
1027  .name = "default",
1028  .priv_size = sizeof(DefaultContext),
1031  .print_integer = default_print_int,
1032  .print_string = default_print_str,
1034  .priv_class = &default_class,
1035 };
1036 
1037 /* Compact output */
1038 
1039 /**
1040  * Apply C-language-like string escaping.
1041  */
1042 static const char *c_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
1043 {
1044  const char *p;
1045 
1046  for (p = src; *p; p++) {
1047  switch (*p) {
1048  case '\b': av_bprintf(dst, "%s", "\\b"); break;
1049  case '\f': av_bprintf(dst, "%s", "\\f"); break;
1050  case '\n': av_bprintf(dst, "%s", "\\n"); break;
1051  case '\r': av_bprintf(dst, "%s", "\\r"); break;
1052  case '\\': av_bprintf(dst, "%s", "\\\\"); break;
1053  default:
1054  if (*p == sep)
1055  av_bprint_chars(dst, '\\', 1);
1056  av_bprint_chars(dst, *p, 1);
1057  }
1058  }
1059  return dst->str;
1060 }
1061 
1062 /**
1063  * Quote fields containing special characters, check RFC4180.
1064  */
1065 static const char *csv_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
1066 {
1067  char meta_chars[] = { sep, '"', '\n', '\r', '\0' };
1068  int needs_quoting = !!src[strcspn(src, meta_chars)];
1069 
1070  if (needs_quoting)
1071  av_bprint_chars(dst, '"', 1);
1072 
1073  for (; *src; src++) {
1074  if (*src == '"')
1075  av_bprint_chars(dst, '"', 1);
1076  av_bprint_chars(dst, *src, 1);
1077  }
1078  if (needs_quoting)
1079  av_bprint_chars(dst, '"', 1);
1080  return dst->str;
1081 }
1082 
1083 static const char *none_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
1084 {
1085  return src;
1086 }
1087 
1088 typedef struct CompactContext {
1089  const AVClass *class;
1091  char item_sep;
1092  int nokey;
1095  const char * (*escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx);
1099 } CompactContext;
1100 
1101 #undef OFFSET
1102 #define OFFSET(x) offsetof(CompactContext, x)
1103 
1104 static const AVOption compact_options[]= {
1105  {"item_sep", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str="|"}, 0, 0 },
1106  {"s", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str="|"}, 0, 0 },
1107  {"nokey", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1108  {"nk", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1109  {"escape", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="c"}, 0, 0 },
1110  {"e", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="c"}, 0, 0 },
1111  {"print_section", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1112  {"p", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1113  {NULL},
1114 };
1115 
1116 DEFINE_WRITER_CLASS(compact);
1117 
1119 {
1120  CompactContext *compact = wctx->priv;
1121 
1122  if (strlen(compact->item_sep_str) != 1) {
1123  av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n",
1124  compact->item_sep_str);
1125  return AVERROR(EINVAL);
1126  }
1127  compact->item_sep = compact->item_sep_str[0];
1128 
1129  if (!strcmp(compact->escape_mode_str, "none")) compact->escape_str = none_escape_str;
1130  else if (!strcmp(compact->escape_mode_str, "c" )) compact->escape_str = c_escape_str;
1131  else if (!strcmp(compact->escape_mode_str, "csv" )) compact->escape_str = csv_escape_str;
1132  else {
1133  av_log(wctx, AV_LOG_ERROR, "Unknown escape mode '%s'\n", compact->escape_mode_str);
1134  return AVERROR(EINVAL);
1135  }
1136 
1137  return 0;
1138 }
1139 
1141 {
1142  CompactContext *compact = wctx->priv;
1143  const struct section *section = wctx->section[wctx->level];
1144  const struct section *parent_section = wctx->level ?
1145  wctx->section[wctx->level-1] : NULL;
1146  compact->terminate_line[wctx->level] = 1;
1147  compact->has_nested_elems[wctx->level] = 0;
1148 
1149  av_bprint_clear(&wctx->section_pbuf[wctx->level]);
1150  if (!(section->flags & SECTION_FLAG_IS_ARRAY) && parent_section &&
1151  !(parent_section->flags & (SECTION_FLAG_IS_WRAPPER|SECTION_FLAG_IS_ARRAY))) {
1152  compact->nested_section[wctx->level] = 1;
1153  compact->has_nested_elems[wctx->level-1] = 1;
1154  av_bprintf(&wctx->section_pbuf[wctx->level], "%s%s:",
1155  wctx->section_pbuf[wctx->level-1].str,
1157  wctx->nb_item[wctx->level] = wctx->nb_item[wctx->level-1];
1158  } else {
1159  if (parent_section && compact->has_nested_elems[wctx->level-1] &&
1161  compact->terminate_line[wctx->level-1] = 0;
1162  }
1163  if (parent_section && !(parent_section->flags & (SECTION_FLAG_IS_WRAPPER|SECTION_FLAG_IS_ARRAY)) &&
1164  wctx->level && wctx->nb_item[wctx->level-1])
1165  printf("%c", compact->item_sep);
1166  if (compact->print_section &&
1168  printf("%s%c", section->name, compact->item_sep);
1169  }
1170 }
1171 
1173 {
1174  CompactContext *compact = wctx->priv;
1175 
1176  if (!compact->nested_section[wctx->level] &&
1177  compact->terminate_line[wctx->level] &&
1179  printf("\n");
1180 }
1181 
1182 static void compact_print_str(WriterContext *wctx, const char *key, const char *value)
1183 {
1184  CompactContext *compact = wctx->priv;
1185  AVBPrint buf;
1186 
1187  if (wctx->nb_item[wctx->level]) printf("%c", compact->item_sep);
1188  if (!compact->nokey)
1189  printf("%s%s=", wctx->section_pbuf[wctx->level].str, key);
1191  printf("%s", compact->escape_str(&buf, value, compact->item_sep, wctx));
1192  av_bprint_finalize(&buf, NULL);
1193 }
1194 
1195 static void compact_print_int(WriterContext *wctx, const char *key, long long int value)
1196 {
1197  CompactContext *compact = wctx->priv;
1198 
1199  if (wctx->nb_item[wctx->level]) printf("%c", compact->item_sep);
1200  if (!compact->nokey)
1201  printf("%s%s=", wctx->section_pbuf[wctx->level].str, key);
1202  printf("%lld", value);
1203 }
1204 
1205 static const Writer compact_writer = {
1206  .name = "compact",
1207  .priv_size = sizeof(CompactContext),
1208  .init = compact_init,
1211  .print_integer = compact_print_int,
1212  .print_string = compact_print_str,
1214  .priv_class = &compact_class,
1215 };
1216 
1217 /* CSV output */
1218 
1219 #undef OFFSET
1220 #define OFFSET(x) offsetof(CompactContext, x)
1221 
1222 static const AVOption csv_options[] = {
1223  {"item_sep", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str=","}, 0, 0 },
1224  {"s", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str=","}, 0, 0 },
1225  {"nokey", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1226  {"nk", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1227  {"escape", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="csv"}, 0, 0 },
1228  {"e", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="csv"}, 0, 0 },
1229  {"print_section", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1230  {"p", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1231  {NULL},
1232 };
1233 
1234 DEFINE_WRITER_CLASS(csv);
1235 
1236 static const Writer csv_writer = {
1237  .name = "csv",
1238  .priv_size = sizeof(CompactContext),
1239  .init = compact_init,
1242  .print_integer = compact_print_int,
1243  .print_string = compact_print_str,
1245  .priv_class = &csv_class,
1246 };
1247 
1248 /* Flat output */
1249 
1250 typedef struct FlatContext {
1251  const AVClass *class;
1252  const char *sep_str;
1253  char sep;
1255 } FlatContext;
1256 
1257 #undef OFFSET
1258 #define OFFSET(x) offsetof(FlatContext, x)
1259 
1260 static const AVOption flat_options[]= {
1261  {"sep_char", "set separator", OFFSET(sep_str), AV_OPT_TYPE_STRING, {.str="."}, 0, 0 },
1262  {"s", "set separator", OFFSET(sep_str), AV_OPT_TYPE_STRING, {.str="."}, 0, 0 },
1263  {"hierarchical", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1264  {"h", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1265  {NULL},
1266 };
1267 
1269 
1271 {
1272  FlatContext *flat = wctx->priv;
1273 
1274  if (strlen(flat->sep_str) != 1) {
1275  av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n",
1276  flat->sep_str);
1277  return AVERROR(EINVAL);
1278  }
1279  flat->sep = flat->sep_str[0];
1280 
1281  return 0;
1282 }
1283 
1284 static const char *flat_escape_key_str(AVBPrint *dst, const char *src, const char sep)
1285 {
1286  const char *p;
1287 
1288  for (p = src; *p; p++) {
1289  if (!((*p >= '0' && *p <= '9') ||
1290  (*p >= 'a' && *p <= 'z') ||
1291  (*p >= 'A' && *p <= 'Z')))
1292  av_bprint_chars(dst, '_', 1);
1293  else
1294  av_bprint_chars(dst, *p, 1);
1295  }
1296  return dst->str;
1297 }
1298 
1299 static const char *flat_escape_value_str(AVBPrint *dst, const char *src)
1300 {
1301  const char *p;
1302 
1303  for (p = src; *p; p++) {
1304  switch (*p) {
1305  case '\n': av_bprintf(dst, "%s", "\\n"); break;
1306  case '\r': av_bprintf(dst, "%s", "\\r"); break;
1307  case '\\': av_bprintf(dst, "%s", "\\\\"); break;
1308  case '"': av_bprintf(dst, "%s", "\\\""); break;
1309  case '`': av_bprintf(dst, "%s", "\\`"); break;
1310  case '$': av_bprintf(dst, "%s", "\\$"); break;
1311  default: av_bprint_chars(dst, *p, 1); break;
1312  }
1313  }
1314  return dst->str;
1315 }
1316 
1318 {
1319  FlatContext *flat = wctx->priv;
1320  AVBPrint *buf = &wctx->section_pbuf[wctx->level];
1321  const struct section *section = wctx->section[wctx->level];
1322  const struct section *parent_section = wctx->level ?
1323  wctx->section[wctx->level-1] : NULL;
1324 
1325  /* build section header */
1326  av_bprint_clear(buf);
1327  if (!parent_section)
1328  return;
1329  av_bprintf(buf, "%s", wctx->section_pbuf[wctx->level-1].str);
1330 
1331  if (flat->hierarchical ||
1333  av_bprintf(buf, "%s%s", wctx->section[wctx->level]->name, flat->sep_str);
1334 
1335  if (parent_section->flags & SECTION_FLAG_IS_ARRAY) {
1336  int n = parent_section->id == SECTION_ID_PACKETS_AND_FRAMES ?
1337  wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1];
1338  av_bprintf(buf, "%d%s", n, flat->sep_str);
1339  }
1340  }
1341 }
1342 
1343 static void flat_print_int(WriterContext *wctx, const char *key, long long int value)
1344 {
1345  printf("%s%s=%lld\n", wctx->section_pbuf[wctx->level].str, key, value);
1346 }
1347 
1348 static void flat_print_str(WriterContext *wctx, const char *key, const char *value)
1349 {
1350  FlatContext *flat = wctx->priv;
1351  AVBPrint buf;
1352 
1353  printf("%s", wctx->section_pbuf[wctx->level].str);
1355  printf("%s=", flat_escape_key_str(&buf, key, flat->sep));
1356  av_bprint_clear(&buf);
1357  printf("\"%s\"\n", flat_escape_value_str(&buf, value));
1358  av_bprint_finalize(&buf, NULL);
1359 }
1360 
1361 static const Writer flat_writer = {
1362  .name = "flat",
1363  .priv_size = sizeof(FlatContext),
1364  .init = flat_init,
1366  .print_integer = flat_print_int,
1367  .print_string = flat_print_str,
1369  .priv_class = &flat_class,
1370 };
1371 
1372 /* INI format output */
1373 
1374 typedef struct INIContext {
1375  const AVClass *class;
1377 } INIContext;
1378 
1379 #undef OFFSET
1380 #define OFFSET(x) offsetof(INIContext, x)
1381 
1382 static const AVOption ini_options[] = {
1383  {"hierarchical", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1384  {"h", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1385  {NULL},
1386 };
1387 
1388 DEFINE_WRITER_CLASS(ini);
1389 
1390 static char *ini_escape_str(AVBPrint *dst, const char *src)
1391 {
1392  int i = 0;
1393  char c = 0;
1394 
1395  while (c = src[i++]) {
1396  switch (c) {
1397  case '\b': av_bprintf(dst, "%s", "\\b"); break;
1398  case '\f': av_bprintf(dst, "%s", "\\f"); break;
1399  case '\n': av_bprintf(dst, "%s", "\\n"); break;
1400  case '\r': av_bprintf(dst, "%s", "\\r"); break;
1401  case '\t': av_bprintf(dst, "%s", "\\t"); break;
1402  case '\\':
1403  case '#' :
1404  case '=' :
1405  case ':' : av_bprint_chars(dst, '\\', 1);
1406  default:
1407  if ((unsigned char)c < 32)
1408  av_bprintf(dst, "\\x00%02x", c & 0xff);
1409  else
1410  av_bprint_chars(dst, c, 1);
1411  break;
1412  }
1413  }
1414  return dst->str;
1415 }
1416 
1418 {
1419  INIContext *ini = wctx->priv;
1420  AVBPrint *buf = &wctx->section_pbuf[wctx->level];
1421  const struct section *section = wctx->section[wctx->level];
1422  const struct section *parent_section = wctx->level ?
1423  wctx->section[wctx->level-1] : NULL;
1424 
1425  av_bprint_clear(buf);
1426  if (!parent_section) {
1427  printf("# ffprobe output\n\n");
1428  return;
1429  }
1430 
1431  if (wctx->nb_item[wctx->level-1])
1432  printf("\n");
1433 
1434  av_bprintf(buf, "%s", wctx->section_pbuf[wctx->level-1].str);
1435  if (ini->hierarchical ||
1437  av_bprintf(buf, "%s%s", buf->str[0] ? "." : "", wctx->section[wctx->level]->name);
1438 
1439  if (parent_section->flags & SECTION_FLAG_IS_ARRAY) {
1440  int n = parent_section->id == SECTION_ID_PACKETS_AND_FRAMES ?
1441  wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1];
1442  av_bprintf(buf, ".%d", n);
1443  }
1444  }
1445 
1447  printf("[%s]\n", buf->str);
1448 }
1449 
1450 static void ini_print_str(WriterContext *wctx, const char *key, const char *value)
1451 {
1452  AVBPrint buf;
1453 
1455  printf("%s=", ini_escape_str(&buf, key));
1456  av_bprint_clear(&buf);
1457  printf("%s\n", ini_escape_str(&buf, value));
1458  av_bprint_finalize(&buf, NULL);
1459 }
1460 
1461 static void ini_print_int(WriterContext *wctx, const char *key, long long int value)
1462 {
1463  printf("%s=%lld\n", key, value);
1464 }
1465 
1466 static const Writer ini_writer = {
1467  .name = "ini",
1468  .priv_size = sizeof(INIContext),
1470  .print_integer = ini_print_int,
1471  .print_string = ini_print_str,
1473  .priv_class = &ini_class,
1474 };
1475 
1476 /* JSON output */
1477 
1478 typedef struct JSONContext {
1479  const AVClass *class;
1481  int compact;
1482  const char *item_sep, *item_start_end;
1483 } JSONContext;
1484 
1485 #undef OFFSET
1486 #define OFFSET(x) offsetof(JSONContext, x)
1487 
1488 static const AVOption json_options[]= {
1489  { "compact", "enable compact output", OFFSET(compact), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1490  { "c", "enable compact output", OFFSET(compact), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1491  { NULL }
1492 };
1493 
1494 DEFINE_WRITER_CLASS(json);
1495 
1497 {
1498  JSONContext *json = wctx->priv;
1499 
1500  json->item_sep = json->compact ? ", " : ",\n";
1501  json->item_start_end = json->compact ? " " : "\n";
1502 
1503  return 0;
1504 }
1505 
1506 static const char *json_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
1507 {
1508  static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};
1509  static const char json_subst[] = {'"', '\\', 'b', 'f', 'n', 'r', 't', 0};
1510  const char *p;
1511 
1512  for (p = src; *p; p++) {
1513  char *s = strchr(json_escape, *p);
1514  if (s) {
1515  av_bprint_chars(dst, '\\', 1);
1516  av_bprint_chars(dst, json_subst[s - json_escape], 1);
1517  } else if ((unsigned char)*p < 32) {
1518  av_bprintf(dst, "\\u00%02x", *p & 0xff);
1519  } else {
1520  av_bprint_chars(dst, *p, 1);
1521  }
1522  }
1523  return dst->str;
1524 }
1525 
1526 #define JSON_INDENT() printf("%*c", json->indent_level * 4, ' ')
1527 
1529 {
1530  JSONContext *json = wctx->priv;
1531  AVBPrint buf;
1532  const struct section *section = wctx->section[wctx->level];
1533  const struct section *parent_section = wctx->level ?
1534  wctx->section[wctx->level-1] : NULL;
1535 
1536  if (wctx->level && wctx->nb_item[wctx->level-1])
1537  printf(",\n");
1538 
1540  printf("{\n");
1541  json->indent_level++;
1542  } else {
1544  json_escape_str(&buf, section->name, wctx);
1545  JSON_INDENT();
1546 
1547  json->indent_level++;
1549  printf("\"%s\": [\n", buf.str);
1550  } else if (parent_section && !(parent_section->flags & SECTION_FLAG_IS_ARRAY)) {
1551  printf("\"%s\": {%s", buf.str, json->item_start_end);
1552  } else {
1553  printf("{%s", json->item_start_end);
1554 
1555  /* this is required so the parser can distinguish between packets and frames */
1556  if (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES) {
1557  if (!json->compact)
1558  JSON_INDENT();
1559  printf("\"type\": \"%s\"", section->name);
1560  }
1561  }
1562  av_bprint_finalize(&buf, NULL);
1563  }
1564 }
1565 
1567 {
1568  JSONContext *json = wctx->priv;
1569  const struct section *section = wctx->section[wctx->level];
1570 
1571  if (wctx->level == 0) {
1572  json->indent_level--;
1573  printf("\n}\n");
1574  } else if (section->flags & SECTION_FLAG_IS_ARRAY) {
1575  printf("\n");
1576  json->indent_level--;
1577  JSON_INDENT();
1578  printf("]");
1579  } else {
1580  printf("%s", json->item_start_end);
1581  json->indent_level--;
1582  if (!json->compact)
1583  JSON_INDENT();
1584  printf("}");
1585  }
1586 }
1587 
1588 static inline void json_print_item_str(WriterContext *wctx,
1589  const char *key, const char *value)
1590 {
1591  AVBPrint buf;
1592 
1594  printf("\"%s\":", json_escape_str(&buf, key, wctx));
1595  av_bprint_clear(&buf);
1596  printf(" \"%s\"", json_escape_str(&buf, value, wctx));
1597  av_bprint_finalize(&buf, NULL);
1598 }
1599 
1600 static void json_print_str(WriterContext *wctx, const char *key, const char *value)
1601 {
1602  JSONContext *json = wctx->priv;
1603  const struct section *parent_section = wctx->level ?
1604  wctx->section[wctx->level-1] : NULL;
1605 
1606  if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES))
1607  printf("%s", json->item_sep);
1608  if (!json->compact)
1609  JSON_INDENT();
1610  json_print_item_str(wctx, key, value);
1611 }
1612 
1613 static void json_print_int(WriterContext *wctx, const char *key, long long int value)
1614 {
1615  JSONContext *json = wctx->priv;
1616  const struct section *parent_section = wctx->level ?
1617  wctx->section[wctx->level-1] : NULL;
1618  AVBPrint buf;
1619 
1620  if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES))
1621  printf("%s", json->item_sep);
1622  if (!json->compact)
1623  JSON_INDENT();
1624 
1626  printf("\"%s\": %lld", json_escape_str(&buf, key, wctx), value);
1627  av_bprint_finalize(&buf, NULL);
1628 }
1629 
1630 static const Writer json_writer = {
1631  .name = "json",
1632  .priv_size = sizeof(JSONContext),
1633  .init = json_init,
1636  .print_integer = json_print_int,
1637  .print_string = json_print_str,
1639  .priv_class = &json_class,
1640 };
1641 
1642 /* XML output */
1643 
1644 typedef struct XMLContext {
1645  const AVClass *class;
1650 } XMLContext;
1651 
1652 #undef OFFSET
1653 #define OFFSET(x) offsetof(XMLContext, x)
1654 
1655 static const AVOption xml_options[] = {
1656  {"fully_qualified", "specify if the output should be fully qualified", OFFSET(fully_qualified), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1657  {"q", "specify if the output should be fully qualified", OFFSET(fully_qualified), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1658  {"xsd_strict", "ensure that the output is XSD compliant", OFFSET(xsd_strict), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1659  {"x", "ensure that the output is XSD compliant", OFFSET(xsd_strict), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1660  {NULL},
1661 };
1662 
1663 DEFINE_WRITER_CLASS(xml);
1664 
1665 static av_cold int xml_init(WriterContext *wctx)
1666 {
1667  XMLContext *xml = wctx->priv;
1668 
1669  if (xml->xsd_strict) {
1670  xml->fully_qualified = 1;
1671 #define CHECK_COMPLIANCE(opt, opt_name) \
1672  if (opt) { \
1673  av_log(wctx, AV_LOG_ERROR, \
1674  "XSD-compliant output selected but option '%s' was selected, XML output may be non-compliant.\n" \
1675  "You need to disable such option with '-no%s'\n", opt_name, opt_name); \
1676  return AVERROR(EINVAL); \
1677  }
1678  CHECK_COMPLIANCE(show_private_data, "private");
1681  }
1682 
1683  return 0;
1684 }
1685 
1686 #define XML_INDENT() printf("%*c", xml->indent_level * 4, ' ')
1687 
1689 {
1690  XMLContext *xml = wctx->priv;
1691  const struct section *section = wctx->section[wctx->level];
1692  const struct section *parent_section = wctx->level ?
1693  wctx->section[wctx->level-1] : NULL;
1694 
1695  if (wctx->level == 0) {
1696  const char *qual = " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
1697  "xmlns:ffprobe=\"http://www.ffmpeg.org/schema/ffprobe\" "
1698  "xsi:schemaLocation=\"http://www.ffmpeg.org/schema/ffprobe ffprobe.xsd\"";
1699 
1700  printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
1701  printf("<%sffprobe%s>\n",
1702  xml->fully_qualified ? "ffprobe:" : "",
1703  xml->fully_qualified ? qual : "");
1704  return;
1705  }
1706 
1707  if (xml->within_tag) {
1708  xml->within_tag = 0;
1709  printf(">\n");
1710  }
1712  xml->indent_level++;
1713  } else {
1714  if (parent_section && (parent_section->flags & SECTION_FLAG_IS_WRAPPER) &&
1715  wctx->level && wctx->nb_item[wctx->level-1])
1716  printf("\n");
1717  xml->indent_level++;
1718 
1720  XML_INDENT(); printf("<%s>\n", section->name);
1721  } else {
1722  XML_INDENT(); printf("<%s ", section->name);
1723  xml->within_tag = 1;
1724  }
1725  }
1726 }
1727 
1729 {
1730  XMLContext *xml = wctx->priv;
1731  const struct section *section = wctx->section[wctx->level];
1732 
1733  if (wctx->level == 0) {
1734  printf("</%sffprobe>\n", xml->fully_qualified ? "ffprobe:" : "");
1735  } else if (xml->within_tag) {
1736  xml->within_tag = 0;
1737  printf("/>\n");
1738  xml->indent_level--;
1740  xml->indent_level--;
1741  } else {
1742  XML_INDENT(); printf("</%s>\n", section->name);
1743  xml->indent_level--;
1744  }
1745 }
1746 
1747 static void xml_print_str(WriterContext *wctx, const char *key, const char *value)
1748 {
1749  AVBPrint buf;
1750  XMLContext *xml = wctx->priv;
1751  const struct section *section = wctx->section[wctx->level];
1752 
1754 
1756  XML_INDENT();
1757  av_bprint_escape(&buf, key, NULL,
1759  printf("<%s key=\"%s\"",
1760  section->element_name, buf.str);
1761  av_bprint_clear(&buf);
1762 
1763  av_bprint_escape(&buf, value, NULL,
1765  printf(" value=\"%s\"/>\n", buf.str);
1766  } else {
1767  if (wctx->nb_item[wctx->level])
1768  printf(" ");
1769 
1770  av_bprint_escape(&buf, value, NULL,
1772  printf("%s=\"%s\"", key, buf.str);
1773  }
1774 
1775  av_bprint_finalize(&buf, NULL);
1776 }
1777 
1778 static void xml_print_int(WriterContext *wctx, const char *key, long long int value)
1779 {
1780  if (wctx->nb_item[wctx->level])
1781  printf(" ");
1782  printf("%s=\"%lld\"", key, value);
1783 }
1784 
1785 static Writer xml_writer = {
1786  .name = "xml",
1787  .priv_size = sizeof(XMLContext),
1788  .init = xml_init,
1791  .print_integer = xml_print_int,
1792  .print_string = xml_print_str,
1794  .priv_class = &xml_class,
1795 };
1796 
1797 static void writer_register_all(void)
1798 {
1799  static int initialized;
1800 
1801  if (initialized)
1802  return;
1803  initialized = 1;
1804 
1812 }
1813 
1814 #define print_fmt(k, f, ...) do { \
1815  av_bprint_clear(&pbuf); \
1816  av_bprintf(&pbuf, f, __VA_ARGS__); \
1817  writer_print_string(w, k, pbuf.str, 0); \
1818 } while (0)
1819 
1820 #define print_list_fmt(k, f, n, ...) do { \
1821  av_bprint_clear(&pbuf); \
1822  for (int idx = 0; idx < n; idx++) { \
1823  if (idx > 0) \
1824  av_bprint_chars(&pbuf, ' ', 1); \
1825  av_bprintf(&pbuf, f, __VA_ARGS__); \
1826  } \
1827  writer_print_string(w, k, pbuf.str, 0); \
1828 } while (0)
1829 
1830 #define print_int(k, v) writer_print_integer(w, k, v)
1831 #define print_q(k, v, s) writer_print_rational(w, k, v, s)
1832 #define print_str(k, v) writer_print_string(w, k, v, 0)
1833 #define print_str_opt(k, v) writer_print_string(w, k, v, PRINT_STRING_OPT)
1834 #define print_str_validate(k, v) writer_print_string(w, k, v, PRINT_STRING_VALIDATE)
1835 #define print_time(k, v, tb) writer_print_time(w, k, v, tb, 0)
1836 #define print_ts(k, v) writer_print_ts(w, k, v, 0)
1837 #define print_duration_time(k, v, tb) writer_print_time(w, k, v, tb, 1)
1838 #define print_duration_ts(k, v) writer_print_ts(w, k, v, 1)
1839 #define print_val(k, v, u) do { \
1840  struct unit_value uv; \
1841  uv.val.i = v; \
1842  uv.unit = u; \
1843  writer_print_string(w, k, value_string(val_str, sizeof(val_str), uv), 0); \
1844 } while (0)
1845 
1846 #define print_section_header(s) writer_print_section_header(w, s)
1847 #define print_section_footer(s) writer_print_section_footer(w, s)
1848 
1849 #define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n) \
1850 { \
1851  ret = av_reallocp_array(&(ptr), (new_n), sizeof(*(ptr))); \
1852  if (ret < 0) \
1853  goto end; \
1854  memset( (ptr) + (cur_n), 0, ((new_n) - (cur_n)) * sizeof(*(ptr)) ); \
1855 }
1856 
1857 static inline int show_tags(WriterContext *w, AVDictionary *tags, int section_id)
1858 {
1859  const AVDictionaryEntry *tag = NULL;
1860  int ret = 0;
1861 
1862  if (!tags)
1863  return 0;
1864  writer_print_section_header(w, section_id);
1865 
1866  while ((tag = av_dict_get(tags, "", tag, AV_DICT_IGNORE_SUFFIX))) {
1867  if ((ret = print_str_validate(tag->key, tag->value)) < 0)
1868  break;
1869  }
1871 
1872  return ret;
1873 }
1874 
1876 {
1877  if (!dovi)
1878  return;
1879 
1880  {
1881  const AVDOVIRpuDataHeader *hdr = av_dovi_get_header(dovi);
1882  const AVDOVIDataMapping *mapping = av_dovi_get_mapping(dovi);
1884  AVBPrint pbuf;
1885 
1887 
1888  // header
1889  print_int("rpu_type", hdr->rpu_type);
1890  print_int("rpu_format", hdr->rpu_format);
1891  print_int("vdr_rpu_profile", hdr->vdr_rpu_profile);
1892  print_int("vdr_rpu_level", hdr->vdr_rpu_level);
1893  print_int("chroma_resampling_explicit_filter_flag",
1895  print_int("coef_data_type", hdr->coef_data_type);
1896  print_int("coef_log2_denom", hdr->coef_log2_denom);
1897  print_int("vdr_rpu_normalized_idc", hdr->vdr_rpu_normalized_idc);
1898  print_int("bl_video_full_range_flag", hdr->bl_video_full_range_flag);
1899  print_int("bl_bit_depth", hdr->bl_bit_depth);
1900  print_int("el_bit_depth", hdr->el_bit_depth);
1901  print_int("vdr_bit_depth", hdr->vdr_bit_depth);
1902  print_int("spatial_resampling_filter_flag",
1904  print_int("el_spatial_resampling_filter_flag",
1906  print_int("disable_residual_flag", hdr->disable_residual_flag);
1907 
1908  // data mapping values
1909  print_int("vdr_rpu_id", mapping->vdr_rpu_id);
1910  print_int("mapping_color_space", mapping->mapping_color_space);
1911  print_int("mapping_chroma_format_idc",
1912  mapping->mapping_chroma_format_idc);
1913 
1914  print_int("nlq_method_idc", mapping->nlq_method_idc);
1915  switch (mapping->nlq_method_idc) {
1916  case AV_DOVI_NLQ_NONE:
1917  print_str("nlq_method_idc_name", "none");
1918  break;
1919  case AV_DOVI_NLQ_LINEAR_DZ:
1920  print_str("nlq_method_idc_name", "linear_dz");
1921  break;
1922  default:
1923  print_str("nlq_method_idc_name", "unknown");
1924  break;
1925  }
1926 
1927  print_int("num_x_partitions", mapping->num_x_partitions);
1928  print_int("num_y_partitions", mapping->num_y_partitions);
1929 
1931 
1932  for (int c = 0; c < 3; c++) {
1933  const AVDOVIReshapingCurve *curve = &mapping->curves[c];
1935 
1936  print_list_fmt("pivots", "%"PRIu16, curve->num_pivots, curve->pivots[idx]);
1937 
1939  for (int i = 0; i < curve->num_pivots - 1; i++) {
1940 
1942  print_int("mapping_idc", curve->mapping_idc[i]);
1943  switch (curve->mapping_idc[i]) {
1945  print_str("mapping_idc_name", "polynomial");
1946  print_int("poly_order", curve->poly_order[i]);
1947  print_list_fmt("poly_coef", "%"PRIi64,
1948  curve->poly_order[i] + 1,
1949  curve->poly_coef[i][idx]);
1950  break;
1951  case AV_DOVI_MAPPING_MMR:
1952  print_str("mapping_idc_name", "mmr");
1953  print_int("mmr_order", curve->mmr_order[i]);
1954  print_int("mmr_constant", curve->mmr_constant[i]);
1955  print_list_fmt("mmr_coef", "%"PRIi64,
1956  curve->mmr_order[i] * 7,
1957  curve->mmr_coef[i][0][idx]);
1958  break;
1959  default:
1960  print_str("mapping_idc_name", "unknown");
1961  break;
1962  }
1963 
1964  // SECTION_ID_FRAME_SIDE_DATA_PIECE
1966  }
1967 
1968  // SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST
1970 
1971  if (mapping->nlq_method_idc != AV_DOVI_NLQ_NONE) {
1972  const AVDOVINLQParams *nlq = &mapping->nlq[c];
1973  print_int("nlq_offset", nlq->nlq_offset);
1974  print_int("vdr_in_max", nlq->vdr_in_max);
1975 
1976  switch (mapping->nlq_method_idc) {
1977  case AV_DOVI_NLQ_LINEAR_DZ:
1978  print_int("linear_deadzone_slope", nlq->linear_deadzone_slope);
1979  print_int("linear_deadzone_threshold", nlq->linear_deadzone_threshold);
1980  break;
1981  }
1982  }
1983 
1984  // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
1986  }
1987 
1988  // SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
1990 
1991  // color metadata
1992  print_int("dm_metadata_id", color->dm_metadata_id);
1993  print_int("scene_refresh_flag", color->scene_refresh_flag);
1994  print_list_fmt("ycc_to_rgb_matrix", "%d/%d",
1995  FF_ARRAY_ELEMS(color->ycc_to_rgb_matrix),
1996  color->ycc_to_rgb_matrix[idx].num,
1997  color->ycc_to_rgb_matrix[idx].den);
1998  print_list_fmt("ycc_to_rgb_offset", "%d/%d",
1999  FF_ARRAY_ELEMS(color->ycc_to_rgb_offset),
2000  color->ycc_to_rgb_offset[idx].num,
2001  color->ycc_to_rgb_offset[idx].den);
2002  print_list_fmt("rgb_to_lms_matrix", "%d/%d",
2003  FF_ARRAY_ELEMS(color->rgb_to_lms_matrix),
2004  color->rgb_to_lms_matrix[idx].num,
2005  color->rgb_to_lms_matrix[idx].den);
2006  print_int("signal_eotf", color->signal_eotf);
2007  print_int("signal_eotf_param0", color->signal_eotf_param0);
2008  print_int("signal_eotf_param1", color->signal_eotf_param1);
2009  print_int("signal_eotf_param2", color->signal_eotf_param2);
2010  print_int("signal_bit_depth", color->signal_bit_depth);
2011  print_int("signal_color_space", color->signal_color_space);
2012  print_int("signal_chroma_format", color->signal_chroma_format);
2013  print_int("signal_full_range_flag", color->signal_full_range_flag);
2014  print_int("source_min_pq", color->source_min_pq);
2015  print_int("source_max_pq", color->source_max_pq);
2016  print_int("source_diagonal", color->source_diagonal);
2017 
2018  av_bprint_finalize(&pbuf, NULL);
2019  }
2020 }
2021 
2023 {
2024  if (!metadata)
2025  return;
2026  print_int("application version", metadata->application_version);
2027  print_int("num_windows", metadata->num_windows);
2028  for (int n = 1; n < metadata->num_windows; n++) {
2029  const AVHDRPlusColorTransformParams *params = &metadata->params[n];
2030  print_q("window_upper_left_corner_x",
2031  params->window_upper_left_corner_x,'/');
2032  print_q("window_upper_left_corner_y",
2033  params->window_upper_left_corner_y,'/');
2034  print_q("window_lower_right_corner_x",
2035  params->window_lower_right_corner_x,'/');
2036  print_q("window_lower_right_corner_y",
2037  params->window_lower_right_corner_y,'/');
2038  print_q("window_upper_left_corner_x",
2039  params->window_upper_left_corner_x,'/');
2040  print_q("window_upper_left_corner_y",
2041  params->window_upper_left_corner_y,'/');
2042  print_int("center_of_ellipse_x",
2043  params->center_of_ellipse_x ) ;
2044  print_int("center_of_ellipse_y",
2045  params->center_of_ellipse_y );
2046  print_int("rotation_angle",
2047  params->rotation_angle);
2048  print_int("semimajor_axis_internal_ellipse",
2050  print_int("semimajor_axis_external_ellipse",
2052  print_int("semiminor_axis_external_ellipse",
2054  print_int("overlap_process_option",
2055  params->overlap_process_option);
2056  }
2057  print_q("targeted_system_display_maximum_luminance",
2060  print_int("num_rows_targeted_system_display_actual_peak_luminance",
2062  print_int("num_cols_targeted_system_display_actual_peak_luminance",
2064  for (int i = 0; i < metadata->num_rows_targeted_system_display_actual_peak_luminance; i++) {
2065  for (int j = 0; j < metadata->num_cols_targeted_system_display_actual_peak_luminance; j++) {
2066  print_q("targeted_system_display_actual_peak_luminance",
2068  }
2069  }
2070  }
2071  for (int n = 0; n < metadata->num_windows; n++) {
2072  const AVHDRPlusColorTransformParams *params = &metadata->params[n];
2073  for (int i = 0; i < 3; i++) {
2074  print_q("maxscl",params->maxscl[i],'/');
2075  }
2076  print_q("average_maxrgb",
2077  params->average_maxrgb,'/');
2078  print_int("num_distribution_maxrgb_percentiles",
2080  for (int i = 0; i < params->num_distribution_maxrgb_percentiles; i++) {
2081  print_int("distribution_maxrgb_percentage",
2082  params->distribution_maxrgb[i].percentage);
2083  print_q("distribution_maxrgb_percentile",
2084  params->distribution_maxrgb[i].percentile,'/');
2085  }
2086  print_q("fraction_bright_pixels",
2087  params->fraction_bright_pixels,'/');
2088  }
2090  print_int("num_rows_mastering_display_actual_peak_luminance",
2092  print_int("num_cols_mastering_display_actual_peak_luminance",
2094  for (int i = 0; i < metadata->num_rows_mastering_display_actual_peak_luminance; i++) {
2095  for (int j = 0; j < metadata->num_cols_mastering_display_actual_peak_luminance; j++) {
2096  print_q("mastering_display_actual_peak_luminance",
2097  metadata->mastering_display_actual_peak_luminance[i][j],'/');
2098  }
2099  }
2100  }
2101 
2102  for (int n = 0; n < metadata->num_windows; n++) {
2103  const AVHDRPlusColorTransformParams *params = &metadata->params[n];
2104  if (params->tone_mapping_flag) {
2105  print_q("knee_point_x", params->knee_point_x,'/');
2106  print_q("knee_point_y", params->knee_point_y,'/');
2107  print_int("num_bezier_curve_anchors",
2108  params->num_bezier_curve_anchors );
2109  for (int i = 0; i < params->num_bezier_curve_anchors; i++) {
2110  print_q("bezier_curve_anchors",
2111  params->bezier_curve_anchors[i],'/');
2112  }
2113  }
2114  if (params->color_saturation_mapping_flag) {
2115  print_q("color_saturation_weight",
2116  params->color_saturation_weight,'/');
2117  }
2118  }
2119 }
2120 
2122  AVCodecParameters *par,
2123  const AVPacketSideData *side_data,
2124  int nb_side_data,
2125  SectionID id_data_list,
2126  SectionID id_data)
2127 {
2128  int i;
2129 
2130  writer_print_section_header(w, id_data_list);
2131  for (i = 0; i < nb_side_data; i++) {
2132  const AVPacketSideData *sd = &side_data[i];
2133  const char *name = av_packet_side_data_name(sd->type);
2134 
2135  writer_print_section_header(w, id_data);
2136  print_str("side_data_type", name ? name : "unknown");
2137  if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
2138  writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
2139  print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
2140  } else if (sd->type == AV_PKT_DATA_STEREO3D) {
2141  const AVStereo3D *stereo = (AVStereo3D *)sd->data;
2142  print_str("type", av_stereo3d_type_name(stereo->type));
2143  print_int("inverted", !!(stereo->flags & AV_STEREO3D_FLAG_INVERT));
2144  } else if (sd->type == AV_PKT_DATA_SPHERICAL) {
2145  const AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data;
2146  print_str("projection", av_spherical_projection_name(spherical->projection));
2147  if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
2148  print_int("padding", spherical->padding);
2149  } else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
2150  size_t l, t, r, b;
2151  av_spherical_tile_bounds(spherical, par->width, par->height,
2152  &l, &t, &r, &b);
2153  print_int("bound_left", l);
2154  print_int("bound_top", t);
2155  print_int("bound_right", r);
2156  print_int("bound_bottom", b);
2157  }
2158 
2159  print_int("yaw", (double) spherical->yaw / (1 << 16));
2160  print_int("pitch", (double) spherical->pitch / (1 << 16));
2161  print_int("roll", (double) spherical->roll / (1 << 16));
2162  } else if (sd->type == AV_PKT_DATA_SKIP_SAMPLES && sd->size == 10) {
2163  print_int("skip_samples", AV_RL32(sd->data));
2164  print_int("discard_padding", AV_RL32(sd->data + 4));
2165  print_int("skip_reason", AV_RL8(sd->data + 8));
2166  print_int("discard_reason", AV_RL8(sd->data + 9));
2167  } else if (sd->type == AV_PKT_DATA_MASTERING_DISPLAY_METADATA) {
2169 
2170  if (metadata->has_primaries) {
2171  print_q("red_x", metadata->display_primaries[0][0], '/');
2172  print_q("red_y", metadata->display_primaries[0][1], '/');
2173  print_q("green_x", metadata->display_primaries[1][0], '/');
2174  print_q("green_y", metadata->display_primaries[1][1], '/');
2175  print_q("blue_x", metadata->display_primaries[2][0], '/');
2176  print_q("blue_y", metadata->display_primaries[2][1], '/');
2177 
2178  print_q("white_point_x", metadata->white_point[0], '/');
2179  print_q("white_point_y", metadata->white_point[1], '/');
2180  }
2181 
2182  if (metadata->has_luminance) {
2183  print_q("min_luminance", metadata->min_luminance, '/');
2184  print_q("max_luminance", metadata->max_luminance, '/');
2185  }
2186  } else if (sd->type == AV_PKT_DATA_CONTENT_LIGHT_LEVEL) {
2188  print_int("max_content", metadata->MaxCLL);
2189  print_int("max_average", metadata->MaxFALL);
2190  } else if (sd->type == AV_PKT_DATA_DOVI_CONF) {
2192  print_int("dv_version_major", dovi->dv_version_major);
2193  print_int("dv_version_minor", dovi->dv_version_minor);
2194  print_int("dv_profile", dovi->dv_profile);
2195  print_int("dv_level", dovi->dv_level);
2196  print_int("rpu_present_flag", dovi->rpu_present_flag);
2197  print_int("el_present_flag", dovi->el_present_flag);
2198  print_int("bl_present_flag", dovi->bl_present_flag);
2199  print_int("dv_bl_signal_compatibility_id", dovi->dv_bl_signal_compatibility_id);
2200  } else if (sd->type == AV_PKT_DATA_AUDIO_SERVICE_TYPE) {
2201  enum AVAudioServiceType *t = (enum AVAudioServiceType *)sd->data;
2202  print_int("service_type", *t);
2203  } else if (sd->type == AV_PKT_DATA_MPEGTS_STREAM_ID) {
2204  print_int("id", *sd->data);
2205  } else if (sd->type == AV_PKT_DATA_CPB_PROPERTIES) {
2206  const AVCPBProperties *prop = (AVCPBProperties *)sd->data;
2207  print_int("max_bitrate", prop->max_bitrate);
2208  print_int("min_bitrate", prop->min_bitrate);
2209  print_int("avg_bitrate", prop->avg_bitrate);
2210  print_int("buffer_size", prop->buffer_size);
2211  print_int("vbv_delay", prop->vbv_delay);
2212  } else if (sd->type == AV_PKT_DATA_WEBVTT_IDENTIFIER ||
2214  if (do_show_data)
2215  writer_print_data(w, "data", sd->data, sd->size);
2216  writer_print_data_hash(w, "data_hash", sd->data, sd->size);
2217  }
2219  }
2221 }
2222 
2224 {
2225  const char *val = av_color_range_name(color_range);
2227  print_str_opt("color_range", "unknown");
2228  } else {
2229  print_str("color_range", val);
2230  }
2231 }
2232 
2233 static void print_color_space(WriterContext *w, enum AVColorSpace color_space)
2234 {
2235  const char *val = av_color_space_name(color_space);
2236  if (!val || color_space == AVCOL_SPC_UNSPECIFIED) {
2237  print_str_opt("color_space", "unknown");
2238  } else {
2239  print_str("color_space", val);
2240  }
2241 }
2242 
2244 {
2247  print_str_opt("color_primaries", "unknown");
2248  } else {
2249  print_str("color_primaries", val);
2250  }
2251 }
2252 
2254 {
2255  const char *val = av_color_transfer_name(color_trc);
2256  if (!val || color_trc == AVCOL_TRC_UNSPECIFIED) {
2257  print_str_opt("color_transfer", "unknown");
2258  } else {
2259  print_str("color_transfer", val);
2260  }
2261 }
2262 
2263 static void print_chroma_location(WriterContext *w, enum AVChromaLocation chroma_location)
2264 {
2265  const char *val = av_chroma_location_name(chroma_location);
2266  if (!val || chroma_location == AVCHROMA_LOC_UNSPECIFIED) {
2267  print_str_opt("chroma_location", "unspecified");
2268  } else {
2269  print_str("chroma_location", val);
2270  }
2271 }
2272 
2273 
2274 static void clear_log(int need_lock)
2275 {
2276  int i;
2277 
2278  if (need_lock)
2279  pthread_mutex_lock(&log_mutex);
2280  for (i=0; i<log_buffer_size; i++) {
2281  av_freep(&log_buffer[i].context_name);
2282  av_freep(&log_buffer[i].parent_name);
2283  av_freep(&log_buffer[i].log_message);
2284  }
2285  log_buffer_size = 0;
2286  if(need_lock)
2287  pthread_mutex_unlock(&log_mutex);
2288 }
2289 
2290 static int show_log(WriterContext *w, int section_ids, int section_id, int log_level)
2291 {
2292  int i;
2293  pthread_mutex_lock(&log_mutex);
2294  if (!log_buffer_size) {
2295  pthread_mutex_unlock(&log_mutex);
2296  return 0;
2297  }
2298  writer_print_section_header(w, section_ids);
2299 
2300  for (i=0; i<log_buffer_size; i++) {
2301  if (log_buffer[i].log_level <= log_level) {
2302  writer_print_section_header(w, section_id);
2303  print_str("context", log_buffer[i].context_name);
2304  print_int("level", log_buffer[i].log_level);
2305  print_int("category", log_buffer[i].category);
2306  if (log_buffer[i].parent_name) {
2307  print_str("parent_context", log_buffer[i].parent_name);
2308  print_int("parent_category", log_buffer[i].parent_category);
2309  } else {
2310  print_str_opt("parent_context", "N/A");
2311  print_str_opt("parent_category", "N/A");
2312  }
2313  print_str("message", log_buffer[i].log_message);
2315  }
2316  }
2317  clear_log(0);
2318  pthread_mutex_unlock(&log_mutex);
2319 
2321 
2322  return 0;
2323 }
2324 
2325 static void show_packet(WriterContext *w, InputFile *ifile, AVPacket *pkt, int packet_idx)
2326 {
2327  char val_str[128];
2328  AVStream *st = ifile->streams[pkt->stream_index].st;
2329  AVBPrint pbuf;
2330  const char *s;
2331 
2333 
2335 
2337  if (s) print_str ("codec_type", s);
2338  else print_str_opt("codec_type", "unknown");
2339  print_int("stream_index", pkt->stream_index);
2340  print_ts ("pts", pkt->pts);
2341  print_time("pts_time", pkt->pts, &st->time_base);
2342  print_ts ("dts", pkt->dts);
2343  print_time("dts_time", pkt->dts, &st->time_base);
2344  print_duration_ts("duration", pkt->duration);
2345  print_duration_time("duration_time", pkt->duration, &st->time_base);
2346  print_val("size", pkt->size, unit_byte_str);
2347  if (pkt->pos != -1) print_fmt ("pos", "%"PRId64, pkt->pos);
2348  else print_str_opt("pos", "N/A");
2349  print_fmt("flags", "%c%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_',
2350  pkt->flags & AV_PKT_FLAG_DISCARD ? 'D' : '_');
2351 
2352  if (pkt->side_data_elems) {
2353  size_t size;
2354  const uint8_t *side_metadata;
2355 
2357  if (side_metadata && size && do_show_packet_tags) {
2358  AVDictionary *dict = NULL;
2359  if (av_packet_unpack_dictionary(side_metadata, size, &dict) >= 0)
2361  av_dict_free(&dict);
2362  }
2363 
2367  }
2368 
2369  if (do_show_data)
2370  writer_print_data(w, "data", pkt->data, pkt->size);
2371  writer_print_data_hash(w, "data_hash", pkt->data, pkt->size);
2373 
2374  av_bprint_finalize(&pbuf, NULL);
2375  fflush(stdout);
2376 }
2377 
2380 {
2381  AVBPrint pbuf;
2382 
2384 
2386 
2387  print_str ("media_type", "subtitle");
2388  print_ts ("pts", sub->pts);
2389  print_time("pts_time", sub->pts, &AV_TIME_BASE_Q);
2390  print_int ("format", sub->format);
2391  print_int ("start_display_time", sub->start_display_time);
2392  print_int ("end_display_time", sub->end_display_time);
2393  print_int ("num_rects", sub->num_rects);
2394 
2396 
2397  av_bprint_finalize(&pbuf, NULL);
2398  fflush(stdout);
2399 }
2400 
2403 {
2404  AVBPrint pbuf;
2405  char val_str[128];
2406  const char *s;
2407  int i;
2408 
2410 
2412 
2414  if (s) print_str ("media_type", s);
2415  else print_str_opt("media_type", "unknown");
2416  print_int("stream_index", stream->index);
2417  print_int("key_frame", frame->key_frame);
2418  print_ts ("pts", frame->pts);
2419  print_time("pts_time", frame->pts, &stream->time_base);
2420  print_ts ("pkt_dts", frame->pkt_dts);
2421  print_time("pkt_dts_time", frame->pkt_dts, &stream->time_base);
2422  print_ts ("best_effort_timestamp", frame->best_effort_timestamp);
2423  print_time("best_effort_timestamp_time", frame->best_effort_timestamp, &stream->time_base);
2424  print_duration_ts ("pkt_duration", frame->pkt_duration);
2425  print_duration_time("pkt_duration_time", frame->pkt_duration, &stream->time_base);
2426  if (frame->pkt_pos != -1) print_fmt ("pkt_pos", "%"PRId64, frame->pkt_pos);
2427  else print_str_opt("pkt_pos", "N/A");
2428  if (frame->pkt_size != -1) print_val ("pkt_size", frame->pkt_size, unit_byte_str);
2429  else print_str_opt("pkt_size", "N/A");
2430 
2431  switch (stream->codecpar->codec_type) {
2432  AVRational sar;
2433 
2434  case AVMEDIA_TYPE_VIDEO:
2435  print_int("width", frame->width);
2436  print_int("height", frame->height);
2437  s = av_get_pix_fmt_name(frame->format);
2438  if (s) print_str ("pix_fmt", s);
2439  else print_str_opt("pix_fmt", "unknown");
2440  sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, frame);
2441  if (sar.num) {
2442  print_q("sample_aspect_ratio", sar, ':');
2443  } else {
2444  print_str_opt("sample_aspect_ratio", "N/A");
2445  }
2446  print_fmt("pict_type", "%c", av_get_picture_type_char(frame->pict_type));
2447  print_int("coded_picture_number", frame->coded_picture_number);
2448  print_int("display_picture_number", frame->display_picture_number);
2449  print_int("interlaced_frame", frame->interlaced_frame);
2450  print_int("top_field_first", frame->top_field_first);
2451  print_int("repeat_pict", frame->repeat_pict);
2452 
2453  print_color_range(w, frame->color_range);
2454  print_color_space(w, frame->colorspace);
2455  print_primaries(w, frame->color_primaries);
2456  print_color_trc(w, frame->color_trc);
2457  print_chroma_location(w, frame->chroma_location);
2458  break;
2459 
2460  case AVMEDIA_TYPE_AUDIO:
2461  s = av_get_sample_fmt_name(frame->format);
2462  if (s) print_str ("sample_fmt", s);
2463  else print_str_opt("sample_fmt", "unknown");
2464  print_int("nb_samples", frame->nb_samples);
2465  print_int("channels", frame->channels);
2466  if (frame->channel_layout) {
2467  av_bprint_clear(&pbuf);
2468  av_bprint_channel_layout(&pbuf, frame->channels,
2469  frame->channel_layout);
2470  print_str ("channel_layout", pbuf.str);
2471  } else
2472  print_str_opt("channel_layout", "unknown");
2473  break;
2474  }
2475  if (do_show_frame_tags)
2476  show_tags(w, frame->metadata, SECTION_ID_FRAME_TAGS);
2477  if (do_show_log)
2479  if (frame->nb_side_data) {
2481  for (i = 0; i < frame->nb_side_data; i++) {
2482  AVFrameSideData *sd = frame->side_data[i];
2483  const char *name;
2484 
2487  print_str("side_data_type", name ? name : "unknown");
2488  if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
2489  writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
2490  print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
2491  } else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) {
2492  char tcbuf[AV_TIMECODE_STR_SIZE];
2493  av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));
2494  print_str("timecode", tcbuf);
2495  } else if (sd->type == AV_FRAME_DATA_S12M_TIMECODE && sd->size == 16) {
2496  uint32_t *tc = (uint32_t*)sd->data;
2497  int m = FFMIN(tc[0],3);
2499  for (int j = 1; j <= m ; j++) {
2500  char tcbuf[AV_TIMECODE_STR_SIZE];
2501  av_timecode_make_smpte_tc_string2(tcbuf, stream->avg_frame_rate, tc[j], 0, 0);
2503  print_str("value", tcbuf);
2505  }
2507  } else if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) {
2509 
2510  if (metadata->has_primaries) {
2511  print_q("red_x", metadata->display_primaries[0][0], '/');
2512  print_q("red_y", metadata->display_primaries[0][1], '/');
2513  print_q("green_x", metadata->display_primaries[1][0], '/');
2514  print_q("green_y", metadata->display_primaries[1][1], '/');
2515  print_q("blue_x", metadata->display_primaries[2][0], '/');
2516  print_q("blue_y", metadata->display_primaries[2][1], '/');
2517 
2518  print_q("white_point_x", metadata->white_point[0], '/');
2519  print_q("white_point_y", metadata->white_point[1], '/');
2520  }
2521 
2522  if (metadata->has_luminance) {
2523  print_q("min_luminance", metadata->min_luminance, '/');
2524  print_q("max_luminance", metadata->max_luminance, '/');
2525  }
2526  } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_PLUS) {
2527  AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
2528  print_dynamic_hdr10_plus(w, metadata);
2529  } else if (sd->type == AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) {
2531  print_int("max_content", metadata->MaxCLL);
2532  print_int("max_average", metadata->MaxFALL);
2533  } else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
2535  if (tag)
2536  print_str(tag->key, tag->value);
2537  print_int("size", sd->size);
2538  } else if (sd->type == AV_FRAME_DATA_DOVI_METADATA) {
2539  print_dovi_metadata(w, (const AVDOVIMetadata *)sd->data);
2540  }
2542  }
2544  }
2545 
2547 
2548  av_bprint_finalize(&pbuf, NULL);
2549  fflush(stdout);
2550 }
2551 
2553  InputFile *ifile,
2555  int *packet_new)
2556 {
2557  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2558  AVCodecContext *dec_ctx = ifile->streams[pkt->stream_index].dec_ctx;
2559  AVCodecParameters *par = ifile->streams[pkt->stream_index].st->codecpar;
2560  AVSubtitle sub;
2561  int ret = 0, got_frame = 0;
2562 
2563  clear_log(1);
2564  if (dec_ctx && dec_ctx->codec) {
2565  switch (par->codec_type) {
2566  case AVMEDIA_TYPE_VIDEO:
2567  case AVMEDIA_TYPE_AUDIO:
2568  if (*packet_new) {
2570  if (ret == AVERROR(EAGAIN)) {
2571  ret = 0;
2572  } else if (ret >= 0 || ret == AVERROR_EOF) {
2573  ret = 0;
2574  *packet_new = 0;
2575  }
2576  }
2577  if (ret >= 0) {
2579  if (ret >= 0) {
2580  got_frame = 1;
2581  } else if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
2582  ret = 0;
2583  }
2584  }
2585  break;
2586 
2587  case AVMEDIA_TYPE_SUBTITLE:
2588  if (*packet_new)
2589  ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_frame, pkt);
2590  *packet_new = 0;
2591  break;
2592  default:
2593  *packet_new = 0;
2594  }
2595  } else {
2596  *packet_new = 0;
2597  }
2598 
2599  if (ret < 0)
2600  return ret;
2601  if (got_frame) {
2602  int is_sub = (par->codec_type == AVMEDIA_TYPE_SUBTITLE);
2604  if (do_show_frames)
2605  if (is_sub)
2606  show_subtitle(w, &sub, ifile->streams[pkt->stream_index].st, fmt_ctx);
2607  else
2608  show_frame(w, frame, ifile->streams[pkt->stream_index].st, fmt_ctx);
2609  if (is_sub)
2610  avsubtitle_free(&sub);
2611  }
2612  return got_frame || *packet_new;
2613 }
2614 
2615 static void log_read_interval(const ReadInterval *interval, void *log_ctx, int log_level)
2616 {
2617  av_log(log_ctx, log_level, "id:%d", interval->id);
2618 
2619  if (interval->has_start) {
2620  av_log(log_ctx, log_level, " start:%s%s", interval->start_is_offset ? "+" : "",
2621  av_ts2timestr(interval->start, &AV_TIME_BASE_Q));
2622  } else {
2623  av_log(log_ctx, log_level, " start:N/A");
2624  }
2625 
2626  if (interval->has_end) {
2627  av_log(log_ctx, log_level, " end:%s", interval->end_is_offset ? "+" : "");
2628  if (interval->duration_frames)
2629  av_log(log_ctx, log_level, "#%"PRId64, interval->end);
2630  else
2631  av_log(log_ctx, log_level, "%s", av_ts2timestr(interval->end, &AV_TIME_BASE_Q));
2632  } else {
2633  av_log(log_ctx, log_level, " end:N/A");
2634  }
2635 
2636  av_log(log_ctx, log_level, "\n");
2637 }
2638 
2640  const ReadInterval *interval, int64_t *cur_ts)
2641 {
2642  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2643  AVPacket *pkt = NULL;
2644  AVFrame *frame = NULL;
2645  int ret = 0, i = 0, frame_count = 0;
2646  int64_t start = -INT64_MAX, end = interval->end;
2647  int has_start = 0, has_end = interval->has_end && !interval->end_is_offset;
2648 
2649  av_log(NULL, AV_LOG_VERBOSE, "Processing read interval ");
2651 
2652  if (interval->has_start) {
2653  int64_t target;
2654  if (interval->start_is_offset) {
2655  if (*cur_ts == AV_NOPTS_VALUE) {
2657  "Could not seek to relative position since current "
2658  "timestamp is not defined\n");
2659  ret = AVERROR(EINVAL);
2660  goto end;
2661  }
2662  target = *cur_ts + interval->start;
2663  } else {
2664  target = interval->start;
2665  }
2666 
2667  av_log(NULL, AV_LOG_VERBOSE, "Seeking to read interval start point %s\n",
2668  av_ts2timestr(target, &AV_TIME_BASE_Q));
2669  if ((ret = avformat_seek_file(fmt_ctx, -1, -INT64_MAX, target, INT64_MAX, 0)) < 0) {
2670  av_log(NULL, AV_LOG_ERROR, "Could not seek to position %"PRId64": %s\n",
2671  interval->start, av_err2str(ret));
2672  goto end;
2673  }
2674  }
2675 
2676  frame = av_frame_alloc();
2677  if (!frame) {
2678  ret = AVERROR(ENOMEM);
2679  goto end;
2680  }
2681  pkt = av_packet_alloc();
2682  if (!pkt) {
2683  ret = AVERROR(ENOMEM);
2684  goto end;
2685  }
2686  while (!av_read_frame(fmt_ctx, pkt)) {
2687  if (fmt_ctx->nb_streams > nb_streams) {
2692  }
2694  AVRational tb = ifile->streams[pkt->stream_index].st->time_base;
2695 
2696  if (pkt->pts != AV_NOPTS_VALUE)
2697  *cur_ts = av_rescale_q(pkt->pts, tb, AV_TIME_BASE_Q);
2698 
2699  if (!has_start && *cur_ts != AV_NOPTS_VALUE) {
2700  start = *cur_ts;
2701  has_start = 1;
2702  }
2703 
2704  if (has_start && !has_end && interval->end_is_offset) {
2705  end = start + interval->end;
2706  has_end = 1;
2707  }
2708 
2709  if (interval->end_is_offset && interval->duration_frames) {
2710  if (frame_count >= interval->end)
2711  break;
2712  } else if (has_end && *cur_ts != AV_NOPTS_VALUE && *cur_ts >= end) {
2713  break;
2714  }
2715 
2716  frame_count++;
2717  if (do_read_packets) {
2718  if (do_show_packets)
2719  show_packet(w, ifile, pkt, i++);
2721  }
2722  if (do_read_frames) {
2723  int packet_new = 1;
2724  while (process_frame(w, ifile, frame, pkt, &packet_new) > 0);
2725  }
2726  }
2728  }
2730  //Flush remaining frames that are cached in the decoder
2731  for (i = 0; i < fmt_ctx->nb_streams; i++) {
2732  pkt->stream_index = i;
2733  if (do_read_frames)
2734  while (process_frame(w, ifile, frame, pkt, &(int){1}) > 0);
2735  }
2736 
2737 end:
2738  av_frame_free(&frame);
2739  av_packet_free(&pkt);
2740  if (ret < 0) {
2741  av_log(NULL, AV_LOG_ERROR, "Could not read packets in interval ");
2742  log_read_interval(interval, NULL, AV_LOG_ERROR);
2743  }
2744  return ret;
2745 }
2746 
2748 {
2749  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2750  int i, ret = 0;
2751  int64_t cur_ts = fmt_ctx->start_time;
2752 
2753  if (read_intervals_nb == 0) {
2754  ReadInterval interval = (ReadInterval) { .has_start = 0, .has_end = 0 };
2755  ret = read_interval_packets(w, ifile, &interval, &cur_ts);
2756  } else {
2757  for (i = 0; i < read_intervals_nb; i++) {
2758  ret = read_interval_packets(w, ifile, &read_intervals[i], &cur_ts);
2759  if (ret < 0)
2760  break;
2761  }
2762  }
2763 
2764  return ret;
2765 }
2766 
2767 static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program)
2768 {
2769  AVStream *stream = ist->st;
2770  AVCodecParameters *par;
2772  char val_str[128];
2773  const char *s;
2774  AVRational sar, dar;
2775  AVBPrint pbuf;
2776  const AVCodecDescriptor *cd;
2777  int ret = 0;
2778  const char *profile = NULL;
2779 
2781 
2783 
2784  print_int("index", stream->index);
2785 
2786  par = stream->codecpar;
2787  dec_ctx = ist->dec_ctx;
2788  if (cd = avcodec_descriptor_get(par->codec_id)) {
2789  print_str("codec_name", cd->name);
2790  if (!do_bitexact) {
2791  print_str("codec_long_name",
2792  cd->long_name ? cd->long_name : "unknown");
2793  }
2794  } else {
2795  print_str_opt("codec_name", "unknown");
2796  if (!do_bitexact) {
2797  print_str_opt("codec_long_name", "unknown");
2798  }
2799  }
2800 
2801  if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile)))
2802  print_str("profile", profile);
2803  else {
2804  if (par->profile != FF_PROFILE_UNKNOWN) {
2805  char profile_num[12];
2806  snprintf(profile_num, sizeof(profile_num), "%d", par->profile);
2807  print_str("profile", profile_num);
2808  } else
2809  print_str_opt("profile", "unknown");
2810  }
2811 
2813  if (s) print_str ("codec_type", s);
2814  else print_str_opt("codec_type", "unknown");
2815 
2816  /* print AVI/FourCC tag */
2817  print_str("codec_tag_string", av_fourcc2str(par->codec_tag));
2818  print_fmt("codec_tag", "0x%04"PRIx32, par->codec_tag);
2819 
2820  switch (par->codec_type) {
2821  case AVMEDIA_TYPE_VIDEO:
2822  print_int("width", par->width);
2823  print_int("height", par->height);
2824  if (dec_ctx) {
2825  print_int("coded_width", dec_ctx->coded_width);
2826  print_int("coded_height", dec_ctx->coded_height);
2829  }
2830  print_int("has_b_frames", par->video_delay);
2831  sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
2832  if (sar.num) {
2833  print_q("sample_aspect_ratio", sar, ':');
2834  av_reduce(&dar.num, &dar.den,
2835  par->width * sar.num,
2836  par->height * sar.den,
2837  1024*1024);
2838  print_q("display_aspect_ratio", dar, ':');
2839  } else {
2840  print_str_opt("sample_aspect_ratio", "N/A");
2841  print_str_opt("display_aspect_ratio", "N/A");
2842  }
2843  s = av_get_pix_fmt_name(par->format);
2844  if (s) print_str ("pix_fmt", s);
2845  else print_str_opt("pix_fmt", "unknown");
2846  print_int("level", par->level);
2847 
2850  print_color_trc(w, par->color_trc);
2853 
2854  if (par->field_order == AV_FIELD_PROGRESSIVE)
2855  print_str("field_order", "progressive");
2856  else if (par->field_order == AV_FIELD_TT)
2857  print_str("field_order", "tt");
2858  else if (par->field_order == AV_FIELD_BB)
2859  print_str("field_order", "bb");
2860  else if (par->field_order == AV_FIELD_TB)
2861  print_str("field_order", "tb");
2862  else if (par->field_order == AV_FIELD_BT)
2863  print_str("field_order", "bt");
2864  else
2865  print_str_opt("field_order", "unknown");
2866 
2867  if (dec_ctx)
2868  print_int("refs", dec_ctx->refs);
2869  break;
2870 
2871  case AVMEDIA_TYPE_AUDIO:
2873  if (s) print_str ("sample_fmt", s);
2874  else print_str_opt("sample_fmt", "unknown");
2875  print_val("sample_rate", par->sample_rate, unit_hertz_str);
2876  print_int("channels", par->channels);
2877 
2878  if (par->channel_layout) {
2879  av_bprint_clear(&pbuf);
2881  print_str ("channel_layout", pbuf.str);
2882  } else {
2883  print_str_opt("channel_layout", "unknown");
2884  }
2885 
2886  print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id));
2887  break;
2888 
2889  case AVMEDIA_TYPE_SUBTITLE:
2890  if (par->width)
2891  print_int("width", par->width);
2892  else
2893  print_str_opt("width", "N/A");
2894  if (par->height)
2895  print_int("height", par->height);
2896  else
2897  print_str_opt("height", "N/A");
2898  break;
2899  }
2900 
2902  const AVOption *opt = NULL;
2903  while (opt = av_opt_next(dec_ctx->priv_data,opt)) {
2904  uint8_t *str;
2905  if (!(opt->flags & AV_OPT_FLAG_EXPORT)) continue;
2906  if (av_opt_get(dec_ctx->priv_data, opt->name, 0, &str) >= 0) {
2907  print_str(opt->name, str);
2908  av_free(str);
2909  }
2910  }
2911  }
2912 
2913  if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%x", stream->id);
2914  else print_str_opt("id", "N/A");
2915  print_q("r_frame_rate", stream->r_frame_rate, '/');
2916  print_q("avg_frame_rate", stream->avg_frame_rate, '/');
2917  print_q("time_base", stream->time_base, '/');
2918  print_ts ("start_pts", stream->start_time);
2919  print_time("start_time", stream->start_time, &stream->time_base);
2920  print_ts ("duration_ts", stream->duration);
2921  print_time("duration", stream->duration, &stream->time_base);
2922  if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str);
2923  else print_str_opt("bit_rate", "N/A");
2924  if (dec_ctx && dec_ctx->rc_max_rate > 0)
2926  else
2927  print_str_opt("max_bit_rate", "N/A");
2928  if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample);
2929  else print_str_opt("bits_per_raw_sample", "N/A");
2930  if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames);
2931  else print_str_opt("nb_frames", "N/A");
2932  if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]);
2933  else print_str_opt("nb_read_frames", "N/A");
2934  if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]);
2935  else print_str_opt("nb_read_packets", "N/A");
2936  if (do_show_data)
2937  writer_print_data(w, "extradata", par->extradata,
2938  par->extradata_size);
2939 
2940  if (par->extradata_size > 0) {
2941  print_int("extradata_size", par->extradata_size);
2942  writer_print_data_hash(w, "extradata_hash", par->extradata,
2943  par->extradata_size);
2944  }
2945 
2946  /* Print disposition information */
2947 #define PRINT_DISPOSITION(flagname, name) do { \
2948  print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \
2949  } while (0)
2950 
2953  PRINT_DISPOSITION(DEFAULT, "default");
2954  PRINT_DISPOSITION(DUB, "dub");
2955  PRINT_DISPOSITION(ORIGINAL, "original");
2956  PRINT_DISPOSITION(COMMENT, "comment");
2957  PRINT_DISPOSITION(LYRICS, "lyrics");
2958  PRINT_DISPOSITION(KARAOKE, "karaoke");
2959  PRINT_DISPOSITION(FORCED, "forced");
2960  PRINT_DISPOSITION(HEARING_IMPAIRED, "hearing_impaired");
2961  PRINT_DISPOSITION(VISUAL_IMPAIRED, "visual_impaired");
2962  PRINT_DISPOSITION(CLEAN_EFFECTS, "clean_effects");
2963  PRINT_DISPOSITION(ATTACHED_PIC, "attached_pic");
2964  PRINT_DISPOSITION(TIMED_THUMBNAILS, "timed_thumbnails");
2965  PRINT_DISPOSITION(CAPTIONS, "captions");
2966  PRINT_DISPOSITION(DESCRIPTIONS, "descriptions");
2967  PRINT_DISPOSITION(METADATA, "metadata");
2968  PRINT_DISPOSITION(DEPENDENT, "dependent");
2969  PRINT_DISPOSITION(STILL_IMAGE, "still_image");
2971  }
2972 
2973  if (do_show_stream_tags)
2975 
2976  if (stream->nb_side_data) {
2977  print_pkt_side_data(w, stream->codecpar, stream->side_data, stream->nb_side_data,
2980  }
2981 
2983  av_bprint_finalize(&pbuf, NULL);
2984  fflush(stdout);
2985 
2986  return ret;
2987 }
2988 
2990 {
2991  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
2992  int i, ret = 0;
2993 
2995  for (i = 0; i < ifile->nb_streams; i++)
2996  if (selected_streams[i]) {
2997  ret = show_stream(w, fmt_ctx, i, &ifile->streams[i], 0);
2998  if (ret < 0)
2999  break;
3000  }
3002 
3003  return ret;
3004 }
3005 
3007 {
3008  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
3009  int i, ret = 0;
3010 
3012  print_int("program_id", program->id);
3013  print_int("program_num", program->program_num);
3014  print_int("nb_streams", program->nb_stream_indexes);
3015  print_int("pmt_pid", program->pmt_pid);
3016  print_int("pcr_pid", program->pcr_pid);
3019  if (ret < 0)
3020  goto end;
3021 
3023  for (i = 0; i < program->nb_stream_indexes; i++) {
3024  if (selected_streams[program->stream_index[i]]) {
3025  ret = show_stream(w, fmt_ctx, program->stream_index[i], &ifile->streams[program->stream_index[i]], 1);
3026  if (ret < 0)
3027  break;
3028  }
3029  }
3031 
3032 end:
3034  return ret;
3035 }
3036 
3038 {
3039  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
3040  int i, ret = 0;
3041 
3043  for (i = 0; i < fmt_ctx->nb_programs; i++) {
3045  if (!program)
3046  continue;
3048  if (ret < 0)
3049  break;
3050  }
3052  return ret;
3053 }
3054 
3056 {
3057  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
3058  int i, ret = 0;
3059 
3061  for (i = 0; i < fmt_ctx->nb_chapters; i++) {
3062  AVChapter *chapter = fmt_ctx->chapters[i];
3063 
3065  print_int("id", chapter->id);
3066  print_q ("time_base", chapter->time_base, '/');
3067  print_int("start", chapter->start);
3068  print_time("start_time", chapter->start, &chapter->time_base);
3069  print_int("end", chapter->end);
3070  print_time("end_time", chapter->end, &chapter->time_base);
3074  }
3076 
3077  return ret;
3078 }
3079 
3081 {
3082  AVFormatContext *fmt_ctx = ifile->fmt_ctx;
3083  char val_str[128];
3084  int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
3085  int ret = 0;
3086 
3088  print_str_validate("filename", fmt_ctx->url);
3089  print_int("nb_streams", fmt_ctx->nb_streams);
3090  print_int("nb_programs", fmt_ctx->nb_programs);
3091  print_str("format_name", fmt_ctx->iformat->name);
3092  if (!do_bitexact) {
3093  if (fmt_ctx->iformat->long_name) print_str ("format_long_name", fmt_ctx->iformat->long_name);
3094  else print_str_opt("format_long_name", "unknown");
3095  }
3096  print_time("start_time", fmt_ctx->start_time, &AV_TIME_BASE_Q);
3097  print_time("duration", fmt_ctx->duration, &AV_TIME_BASE_Q);
3098  if (size >= 0) print_val ("size", size, unit_byte_str);
3099  else print_str_opt("size", "N/A");
3101  else print_str_opt("bit_rate", "N/A");
3102  print_int("probe_score", fmt_ctx->probe_score);
3103  if (do_show_format_tags)
3105 
3107  fflush(stdout);
3108  return ret;
3109 }
3110 
3111 static void show_error(WriterContext *w, int err)
3112 {
3113  char errbuf[128];
3114  const char *errbuf_ptr = errbuf;
3115 
3116  if (av_strerror(err, errbuf, sizeof(errbuf)) < 0)
3117  errbuf_ptr = strerror(AVUNERROR(err));
3118 
3120  print_int("code", err);
3121  print_str("string", errbuf_ptr);
3123 }
3124 
3125 static int open_input_file(InputFile *ifile, const char *filename,
3126  const char *print_filename)
3127 {
3128  int err, i;
3130  const AVDictionaryEntry *t = NULL;
3131  int scan_all_pmts_set = 0;
3132 
3134  if (!fmt_ctx) {
3135  print_error(filename, AVERROR(ENOMEM));
3136  exit_program(1);
3137  }
3138 
3139  if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
3140  av_dict_set(&format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
3141  scan_all_pmts_set = 1;
3142  }
3143  if ((err = avformat_open_input(&fmt_ctx, filename,
3144  iformat, &format_opts)) < 0) {
3145  print_error(filename, err);
3146  return err;
3147  }
3148  if (print_filename) {
3149  av_freep(&fmt_ctx->url);
3150  fmt_ctx->url = av_strdup(print_filename);
3151  }
3152  ifile->fmt_ctx = fmt_ctx;
3153  if (scan_all_pmts_set)
3154  av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
3155  while ((t = av_dict_get(format_opts, "", t, AV_DICT_IGNORE_SUFFIX)))
3156  av_log(NULL, AV_LOG_WARNING, "Option %s skipped - not known to demuxer.\n", t->key);
3157 
3158  if (find_stream_info) {
3160  int orig_nb_streams = fmt_ctx->nb_streams;
3161 
3163 
3164  for (i = 0; i < orig_nb_streams; i++)
3165  av_dict_free(&opts[i]);
3166  av_freep(&opts);
3167 
3168  if (err < 0) {
3169  print_error(filename, err);
3170  return err;
3171  }
3172  }
3173 
3174  av_dump_format(fmt_ctx, 0, filename, 0);
3175 
3176  ifile->streams = av_calloc(fmt_ctx->nb_streams, sizeof(*ifile->streams));
3177  if (!ifile->streams)
3178  exit(1);
3179  ifile->nb_streams = fmt_ctx->nb_streams;
3180 
3181  /* bind a decoder to each input stream */
3182  for (i = 0; i < fmt_ctx->nb_streams; i++) {
3183  InputStream *ist = &ifile->streams[i];
3184  AVStream *stream = fmt_ctx->streams[i];
3185  const AVCodec *codec;
3186 
3187  ist->st = stream;
3188 
3189  if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) {
3191  "Failed to probe codec for input stream %d\n",
3192  stream->index);
3193  continue;
3194  }
3195 
3196  codec = avcodec_find_decoder(stream->codecpar->codec_id);
3197  if (!codec) {
3199  "Unsupported codec with id %d for input stream %d\n",
3200  stream->codecpar->codec_id, stream->index);
3201  continue;
3202  }
3203  {
3205  fmt_ctx, stream, codec);
3206 
3207  ist->dec_ctx = avcodec_alloc_context3(codec);
3208  if (!ist->dec_ctx)
3209  exit(1);
3210 
3211  err = avcodec_parameters_to_context(ist->dec_ctx, stream->codecpar);
3212  if (err < 0)
3213  exit(1);
3214 
3215  if (do_show_log) {
3216  // For loging it is needed to disable at least frame threads as otherwise
3217  // the log information would need to be reordered and matches up to contexts and frames
3218  // That is in fact possible but not trivial
3219  av_dict_set(&codec_opts, "threads", "1", 0);
3220  }
3221 
3222  ist->dec_ctx->pkt_timebase = stream->time_base;
3223 
3224  if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {
3225  av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n",
3226  stream->index);
3227  exit(1);
3228  }
3229 
3230  if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
3231  av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not found\n",
3232  t->key, stream->index);
3233  return AVERROR_OPTION_NOT_FOUND;
3234  }
3235  }
3236  }
3237 
3238  ifile->fmt_ctx = fmt_ctx;
3239  return 0;
3240 }
3241 
3243 {
3244  int i;
3245 
3246  /* close decoder for each stream */
3247  for (i = 0; i < ifile->nb_streams; i++)
3248  avcodec_free_context(&ifile->streams[i].dec_ctx);
3249 
3250  av_freep(&ifile->streams);
3251  ifile->nb_streams = 0;
3252 
3253  avformat_close_input(&ifile->fmt_ctx);
3254 }
3255 
3256 static int probe_file(WriterContext *wctx, const char *filename,
3257  const char *print_filename)
3258 {
3259  InputFile ifile = { 0 };
3260  int ret, i;
3261  int section_id;
3262 
3265 
3266  ret = open_input_file(&ifile, filename, print_filename);
3267  if (ret < 0)
3268  goto end;
3269 
3270 #define CHECK_END if (ret < 0) goto end
3271 
3272  nb_streams = ifile.fmt_ctx->nb_streams;
3273  REALLOCZ_ARRAY_STREAM(nb_streams_frames,0,ifile.fmt_ctx->nb_streams);
3274  REALLOCZ_ARRAY_STREAM(nb_streams_packets,0,ifile.fmt_ctx->nb_streams);
3275  REALLOCZ_ARRAY_STREAM(selected_streams,0,ifile.fmt_ctx->nb_streams);
3276 
3277  for (i = 0; i < ifile.fmt_ctx->nb_streams; i++) {
3278  if (stream_specifier) {
3280  ifile.fmt_ctx->streams[i],
3282  CHECK_END;
3283  else
3284  selected_streams[i] = ret;
3285  ret = 0;
3286  } else {
3287  selected_streams[i] = 1;
3288  }
3289  if (!selected_streams[i])
3290  ifile.fmt_ctx->streams[i]->discard = AVDISCARD_ALL;
3291  }
3292 
3296  section_id = SECTION_ID_PACKETS_AND_FRAMES;
3297  else if (do_show_packets && !do_show_frames)
3298  section_id = SECTION_ID_PACKETS;
3299  else // (!do_show_packets && do_show_frames)
3300  section_id = SECTION_ID_FRAMES;
3302  writer_print_section_header(wctx, section_id);
3303  ret = read_packets(wctx, &ifile);
3306  CHECK_END;
3307  }
3308 
3309  if (do_show_programs) {
3310  ret = show_programs(wctx, &ifile);
3311  CHECK_END;
3312  }
3313 
3314  if (do_show_streams) {
3315  ret = show_streams(wctx, &ifile);
3316  CHECK_END;
3317  }
3318  if (do_show_chapters) {
3319  ret = show_chapters(wctx, &ifile);
3320  CHECK_END;
3321  }
3322  if (do_show_format) {
3323  ret = show_format(wctx, &ifile);
3324  CHECK_END;
3325  }
3326 
3327 end:
3328  if (ifile.fmt_ctx)
3333 
3334  return ret;
3335 }
3336 
3337 static void show_usage(void)
3338 {
3339  av_log(NULL, AV_LOG_INFO, "Simple multimedia streams analyzer\n");
3340  av_log(NULL, AV_LOG_INFO, "usage: %s [OPTIONS] [INPUT_FILE]\n", program_name);
3341  av_log(NULL, AV_LOG_INFO, "\n");
3342 }
3343 
3345 {
3346  AVBPrint pbuf;
3348 
3350  print_str("version", FFMPEG_VERSION);
3351  print_fmt("copyright", "Copyright (c) %d-%d the FFmpeg developers",
3352  program_birth_year, CONFIG_THIS_YEAR);
3353  print_str("compiler_ident", CC_IDENT);
3354  print_str("configuration", FFMPEG_CONFIGURATION);
3356 
3357  av_bprint_finalize(&pbuf, NULL);
3358 }
3359 
3360 #define SHOW_LIB_VERSION(libname, LIBNAME) \
3361  do { \
3362  if (CONFIG_##LIBNAME) { \
3363  unsigned int version = libname##_version(); \
3364  writer_print_section_header(w, SECTION_ID_LIBRARY_VERSION); \
3365  print_str("name", "lib" #libname); \
3366  print_int("major", LIB##LIBNAME##_VERSION_MAJOR); \
3367  print_int("minor", LIB##LIBNAME##_VERSION_MINOR); \
3368  print_int("micro", LIB##LIBNAME##_VERSION_MICRO); \
3369  print_int("version", version); \
3370  print_str("ident", LIB##LIBNAME##_IDENT); \
3371  writer_print_section_footer(w); \
3372  } \
3373  } while (0)
3374 
3376 {
3378  SHOW_LIB_VERSION(avutil, AVUTIL);
3379  SHOW_LIB_VERSION(avcodec, AVCODEC);
3380  SHOW_LIB_VERSION(avformat, AVFORMAT);
3381  SHOW_LIB_VERSION(avdevice, AVDEVICE);
3382  SHOW_LIB_VERSION(avfilter, AVFILTER);
3383  SHOW_LIB_VERSION(swscale, SWSCALE);
3384  SHOW_LIB_VERSION(swresample, SWRESAMPLE);
3385  SHOW_LIB_VERSION(postproc, POSTPROC);
3387 }
3388 
3389 #define PRINT_PIX_FMT_FLAG(flagname, name) \
3390  do { \
3391  print_int(name, !!(pixdesc->flags & AV_PIX_FMT_FLAG_##flagname)); \
3392  } while (0)
3393 
3395 {
3396  const AVPixFmtDescriptor *pixdesc = NULL;
3397  int i, n;
3398 
3400  while (pixdesc = av_pix_fmt_desc_next(pixdesc)) {
3402  print_str("name", pixdesc->name);
3403  print_int("nb_components", pixdesc->nb_components);
3404  if ((pixdesc->nb_components >= 3) && !(pixdesc->flags & AV_PIX_FMT_FLAG_RGB)) {
3405  print_int ("log2_chroma_w", pixdesc->log2_chroma_w);
3406  print_int ("log2_chroma_h", pixdesc->log2_chroma_h);
3407  } else {
3408  print_str_opt("log2_chroma_w", "N/A");
3409  print_str_opt("log2_chroma_h", "N/A");
3410  }
3411  n = av_get_bits_per_pixel(pixdesc);
3412  if (n) print_int ("bits_per_pixel", n);
3413  else print_str_opt("bits_per_pixel", "N/A");
3416  PRINT_PIX_FMT_FLAG(BE, "big_endian");
3417  PRINT_PIX_FMT_FLAG(PAL, "palette");
3418  PRINT_PIX_FMT_FLAG(BITSTREAM, "bitstream");
3419  PRINT_PIX_FMT_FLAG(HWACCEL, "hwaccel");
3420  PRINT_PIX_FMT_FLAG(PLANAR, "planar");
3421  PRINT_PIX_FMT_FLAG(RGB, "rgb");
3422  PRINT_PIX_FMT_FLAG(ALPHA, "alpha");
3424  }
3425  if (do_show_pixel_format_components && (pixdesc->nb_components > 0)) {
3427  for (i = 0; i < pixdesc->nb_components; i++) {
3429  print_int("index", i + 1);
3430  print_int("bit_depth", pixdesc->comp[i].depth);
3432  }
3434  }
3436  }
3438 }
3439 
3440 static int opt_show_optional_fields(void *optctx, const char *opt, const char *arg)
3441 {
3445 
3448  return 0;
3449 }
3450 
3451 static int opt_format(void *optctx, const char *opt, const char *arg)
3452 {
3454  if (!iformat) {
3455  av_log(NULL, AV_LOG_ERROR, "Unknown input format: %s\n", arg);
3456  return AVERROR(EINVAL);
3457  }
3458  return 0;
3459 }
3460 
3461 static inline void mark_section_show_entries(SectionID section_id,
3462  int show_all_entries, AVDictionary *entries)
3463 {
3464  struct section *section = &sections[section_id];
3465 
3467  if (show_all_entries) {
3468  SectionID *id;
3469  for (id = section->children_ids; *id != -1; id++)
3471  } else {
3472  av_dict_copy(&section->entries_to_show, entries, 0);
3473  }
3474 }
3475 
3476 static int match_section(const char *section_name,
3477  int show_all_entries, AVDictionary *entries)
3478 {
3479  int i, ret = 0;
3480 
3481  for (i = 0; i < FF_ARRAY_ELEMS(sections); i++) {
3482  const struct section *section = &sections[i];
3483  if (!strcmp(section_name, section->name) ||
3484  (section->unique_name && !strcmp(section_name, section->unique_name))) {
3486  "'%s' matches section with unique name '%s'\n", section_name,
3488  ret++;
3490  }
3491  }
3492  return ret;
3493 }
3494 
3495 static int opt_show_entries(void *optctx, const char *opt, const char *arg)
3496 {
3497  const char *p = arg;
3498  int ret = 0;
3499 
3500  while (*p) {
3501  AVDictionary *entries = NULL;
3502  char *section_name = av_get_token(&p, "=:");
3503  int show_all_entries = 0;
3504 
3505  if (!section_name) {
3507  "Missing section name for option '%s'\n", opt);
3508  return AVERROR(EINVAL);
3509  }
3510 
3511  if (*p == '=') {
3512  p++;
3513  while (*p && *p != ':') {
3514  char *entry = av_get_token(&p, ",:");
3515  if (!entry)
3516  break;
3518  "Adding '%s' to the entries to show in section '%s'\n",
3519  entry, section_name);
3520  av_dict_set(&entries, entry, "", AV_DICT_DONT_STRDUP_KEY);
3521  if (*p == ',')
3522  p++;
3523  }
3524  } else {
3525  show_all_entries = 1;
3526  }
3527 
3528  ret = match_section(section_name, show_all_entries, entries);
3529  if (ret == 0) {
3530  av_log(NULL, AV_LOG_ERROR, "No match for section '%s'\n", section_name);
3531  ret = AVERROR(EINVAL);
3532  }
3533  av_dict_free(&entries);
3534  av_free(section_name);
3535 
3536  if (ret <= 0)
3537  break;
3538  if (*p)
3539  p++;
3540  }
3541 
3542  return ret;
3543 }
3544 
3545 static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
3546 {
3547  char *buf = av_asprintf("format=%s", arg);
3548  int ret;
3549 
3550  if (!buf)
3551  return AVERROR(ENOMEM);
3552 
3554  "Option '%s' is deprecated, use '-show_entries format=%s' instead\n",
3555  opt, arg);
3556  ret = opt_show_entries(optctx, opt, buf);
3557  av_free(buf);
3558  return ret;
3559 }
3560 
3561 static void opt_input_file(void *optctx, const char *arg)
3562 {
3563  if (input_filename) {
3565  "Argument '%s' provided as input filename, but '%s' was already specified.\n",
3566  arg, input_filename);
3567  exit_program(1);
3568  }
3569  if (!strcmp(arg, "-"))
3570  arg = "pipe:";
3571  input_filename = arg;
3572 }
3573 
3574 static int opt_input_file_i(void *optctx, const char *opt, const char *arg)
3575 {
3576  opt_input_file(optctx, arg);
3577  return 0;
3578 }
3579 
3580 static int opt_print_filename(void *optctx, const char *opt, const char *arg)
3581 {
3583  return 0;
3584 }
3585 
3586 void show_help_default(const char *opt, const char *arg)
3587 {
3589  show_usage();
3590  show_help_options(options, "Main options:", 0, 0, 0);
3591  printf("\n");
3592 
3595 }
3596 
3597 /**
3598  * Parse interval specification, according to the format:
3599  * INTERVAL ::= [START|+START_OFFSET][%[END|+END_OFFSET]]
3600  * INTERVALS ::= INTERVAL[,INTERVALS]
3601 */
3602 static int parse_read_interval(const char *interval_spec,
3603  ReadInterval *interval)
3604 {
3605  int ret = 0;
3606  char *next, *p, *spec = av_strdup(interval_spec);
3607  if (!spec)
3608  return AVERROR(ENOMEM);
3609 
3610  if (!*spec) {
3611  av_log(NULL, AV_LOG_ERROR, "Invalid empty interval specification\n");
3612  ret = AVERROR(EINVAL);
3613  goto end;
3614  }
3615 
3616  p = spec;
3617  next = strchr(spec, '%');
3618  if (next)
3619  *next++ = 0;
3620 
3621  /* parse first part */
3622  if (*p) {
3623  interval->has_start = 1;
3624 
3625  if (*p == '+') {
3626  interval->start_is_offset = 1;
3627  p++;
3628  } else {
3629  interval->start_is_offset = 0;
3630  }
3631 
3632  ret = av_parse_time(&interval->start, p, 1);
3633  if (ret < 0) {
3634  av_log(NULL, AV_LOG_ERROR, "Invalid interval start specification '%s'\n", p);
3635  goto end;
3636  }
3637  } else {
3638  interval->has_start = 0;
3639  }
3640 
3641  /* parse second part */
3642  p = next;
3643  if (p && *p) {
3644  int64_t us;
3645  interval->has_end = 1;
3646 
3647  if (*p == '+') {
3648  interval->end_is_offset = 1;
3649  p++;
3650  } else {
3651  interval->end_is_offset = 0;
3652  }
3653 
3654  if (interval->end_is_offset && *p == '#') {
3655  long long int lli;
3656  char *tail;
3657  interval->duration_frames = 1;
3658  p++;
3659  lli = strtoll(p, &tail, 10);
3660  if (*tail || lli < 0) {
3662  "Invalid or negative value '%s' for duration number of frames\n", p);
3663  goto end;
3664  }
3665  interval->end = lli;
3666  } else {
3667  interval->duration_frames = 0;
3668  ret = av_parse_time(&us, p, 1);
3669  if (ret < 0) {
3670  av_log(NULL, AV_LOG_ERROR, "Invalid interval end/duration specification '%s'\n", p);
3671  goto end;
3672  }
3673  interval->end = us;
3674  }
3675  } else {
3676  interval->has_end = 0;
3677  }
3678 
3679 end:
3680  av_free(spec);
3681  return ret;
3682 }
3683 
3684 static int parse_read_intervals(const char *intervals_spec)
3685 {
3686  int ret, n, i;
3687  char *p, *spec = av_strdup(intervals_spec);
3688  if (!spec)
3689  return AVERROR(ENOMEM);
3690 
3691  /* preparse specification, get number of intervals */
3692  for (n = 0, p = spec; *p; p++)
3693  if (*p == ',')
3694  n++;
3695  n++;
3696 
3698  if (!read_intervals) {
3699  ret = AVERROR(ENOMEM);
3700  goto end;
3701  }
3702  read_intervals_nb = n;
3703 
3704  /* parse intervals */
3705  p = spec;
3706  for (i = 0; p; i++) {
3707  char *next;
3708 
3710  next = strchr(p, ',');
3711  if (next)
3712  *next++ = 0;
3713 
3714  read_intervals[i].id = i;
3716  if (ret < 0) {
3717  av_log(NULL, AV_LOG_ERROR, "Error parsing read interval #%d '%s'\n",
3718  i, p);
3719  goto end;
3720  }
3721  av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval ");
3723  p = next;
3724  }
3726 
3727 end:
3728  av_free(spec);
3729  return ret;
3730 }
3731 
3732 static int opt_read_intervals(void *optctx, const char *opt, const char *arg)
3733 {
3734  return parse_read_intervals(arg);
3735 }
3736 
3737 static int opt_pretty(void *optctx, const char *opt, const char *arg)
3738 {
3739  show_value_unit = 1;
3740  use_value_prefix = 1;
3743  return 0;
3744 }
3745 
3746 static void print_section(SectionID id, int level)
3747 {
3748  const SectionID *pid;
3749  const struct section *section = &sections[id];
3750  printf("%c%c%c",
3751  section->flags & SECTION_FLAG_IS_WRAPPER ? 'W' : '.',
3752  section->flags & SECTION_FLAG_IS_ARRAY ? 'A' : '.',
3754  printf("%*c %s", level * 4, ' ', section->name);
3755  if (section->unique_name)
3756  printf("/%s", section->unique_name);
3757  printf("\n");
3758 
3759  for (pid = section->children_ids; *pid != -1; pid++)
3760  print_section(*pid, level+1);
3761 }
3762 
3763 static int opt_sections(void *optctx, const char *opt, const char *arg)
3764 {
3765  printf("Sections:\n"
3766  "W.. = Section is a wrapper (contains other sections, no local entries)\n"
3767  ".A. = Section contains an array of elements of the same type\n"
3768  "..V = Section may contain a variable number of fields with variable keys\n"
3769  "FLAGS NAME/UNIQUE_NAME\n"
3770  "---\n");
3772  return 0;
3773 }
3774 
3775 static int opt_show_versions(void *optctx, const char *opt, const char *arg)
3776 {
3779  return 0;
3780 }
3781 
3782 #define DEFINE_OPT_SHOW_SECTION(section, target_section_id) \
3783  static int opt_show_##section(void *optctx, const char *opt, const char *arg) \
3784  { \
3785  mark_section_show_entries(SECTION_ID_##target_section_id, 1, NULL); \
3786  return 0; \
3787  }
3788 
3789 DEFINE_OPT_SHOW_SECTION(chapters, CHAPTERS)
3793 DEFINE_OPT_SHOW_SECTION(library_versions, LIBRARY_VERSIONS)
3794 DEFINE_OPT_SHOW_SECTION(packets, PACKETS)
3795 DEFINE_OPT_SHOW_SECTION(pixel_formats, PIXEL_FORMATS)
3796 DEFINE_OPT_SHOW_SECTION(program_version, PROGRAM_VERSION)
3797 DEFINE_OPT_SHOW_SECTION(streams, STREAMS)
3798 DEFINE_OPT_SHOW_SECTION(programs, PROGRAMS)
3799 
3800 static const OptionDef real_options[] = {
3802  { "f", HAS_ARG, {.func_arg = opt_format}, "force format", "format" },
3803  { "unit", OPT_BOOL, {&show_value_unit}, "show unit of the displayed values" },
3804  { "prefix", OPT_BOOL, {&use_value_prefix}, "use SI prefixes for the displayed values" },
3805  { "byte_binary_prefix", OPT_BOOL, {&use_byte_value_binary_prefix},
3806  "use binary prefixes for byte units" },
3807  { "sexagesimal", OPT_BOOL, {&use_value_sexagesimal_format},
3808  "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
3809  { "pretty", 0, {.func_arg = opt_pretty},
3810  "prettify the format of displayed values, make it more human readable" },
3811  { "print_format", OPT_STRING | HAS_ARG, { &print_format },
3812  "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)", "format" },
3813  { "of", OPT_STRING | HAS_ARG, { &print_format }, "alias for -print_format", "format" },
3814  { "select_streams", OPT_STRING | HAS_ARG, { &stream_specifier }, "select the specified streams", "stream_specifier" },
3815  { "sections", OPT_EXIT, {.func_arg = opt_sections}, "print sections structure and section information, and exit" },
3816  { "show_data", OPT_BOOL, { &do_show_data }, "show packets data" },
3817  { "show_data_hash", OPT_STRING | HAS_ARG, { &show_data_hash }, "show packets data hash" },
3818  { "show_error", 0, { .func_arg = &opt_show_error }, "show probing error" },
3819  { "show_format", 0, { .func_arg = &opt_show_format }, "show format/container info" },
3820  { "show_frames", 0, { .func_arg = &opt_show_frames }, "show frames info" },
3821  { "show_format_entry", HAS_ARG, {.func_arg = opt_show_format_entry},
3822  "show a particular entry from the format/container info", "entry" },
3823  { "show_entries", HAS_ARG, {.func_arg = opt_show_entries},
3824  "show a set of specified entries", "entry_list" },
3825 #if HAVE_THREADS
3826  { "show_log", OPT_INT|HAS_ARG, { &do_show_log }, "show log" },
3827 #endif
3828  { "show_packets", 0, { .func_arg = &opt_show_packets }, "show packets info" },
3829  { "show_programs", 0, { .func_arg = &opt_show_programs }, "show programs info" },
3830  { "show_streams", 0, { .func_arg = &opt_show_streams }, "show streams info" },
3831  { "show_chapters", 0, { .func_arg = &opt_show_chapters }, "show chapters info" },
3832  { "count_frames", OPT_BOOL, { &do_count_frames }, "count the number of frames per stream" },
3833  { "count_packets", OPT_BOOL, { &do_count_packets }, "count the number of packets per stream" },
3834  { "show_program_version", 0, { .func_arg = &opt_show_program_version }, "show ffprobe version" },
3835  { "show_library_versions", 0, { .func_arg = &opt_show_library_versions }, "show library versions" },
3836  { "show_versions", 0, { .func_arg = &opt_show_versions }, "show program and library versions" },
3837  { "show_pixel_formats", 0, { .func_arg = &opt_show_pixel_formats }, "show pixel format descriptions" },
3838  { "show_optional_fields", HAS_ARG, { .func_arg = &opt_show_optional_fields }, "show optional fields" },
3839  { "show_private_data", OPT_BOOL, { &show_private_data }, "show private data" },
3840  { "private", OPT_BOOL, { &show_private_data }, "same as show_private_data" },
3841  { "bitexact", OPT_BOOL, {&do_bitexact}, "force bitexact output" },
3842  { "read_intervals", HAS_ARG, {.func_arg = opt_read_intervals}, "set read intervals", "read_intervals" },
3843  { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default}, "generic catch all option", "" },
3844  { "i", HAS_ARG, {.func_arg = opt_input_file_i}, "read specified file", "input_file"},
3845  { "print_filename", HAS_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
3846  { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info },
3847  "read and decode the streams to fill missing information with heuristics" },
3848  { NULL, },
3849 };
3850 
3851 static inline int check_section_show_entries(int section_id)
3852 {
3853  int *id;
3854  struct section *section = &sections[section_id];
3855  if (sections[section_id].show_all_entries || sections[section_id].entries_to_show)
3856  return 1;
3857  for (id = section->children_ids; *id != -1; id++)
3858  if (check_section_show_entries(*id))
3859  return 1;
3860  return 0;
3861 }
3862 
3863 #define SET_DO_SHOW(id, varname) do { \
3864  if (check_section_show_entries(SECTION_ID_##id)) \
3865  do_show_##varname = 1; \
3866  } while (0)
3867 
3868 int main(int argc, char **argv)
3869 {
3870  const Writer *w;
3871  WriterContext *wctx;
3872  char *buf;
3873  char *w_name = NULL, *w_args = NULL;
3874  int ret, i;
3875 
3876  init_dynload();
3877 
3878 #if HAVE_THREADS
3879  ret = pthread_mutex_init(&log_mutex, NULL);
3880  if (ret != 0) {
3881  goto end;
3882  }
3883 #endif
3886 
3888  parse_loglevel(argc, argv, options);
3890 #if CONFIG_AVDEVICE
3892 #endif
3893 
3894  show_banner(argc, argv, options);
3895  parse_options(NULL, argc, argv, options, opt_input_file);
3896 
3897  if (do_show_log)
3899 
3900  /* mark things to show, based on -show_entries */
3901  SET_DO_SHOW(CHAPTERS, chapters);
3903  SET_DO_SHOW(FORMAT, format);
3904  SET_DO_SHOW(FRAMES, frames);
3905  SET_DO_SHOW(LIBRARY_VERSIONS, library_versions);
3906  SET_DO_SHOW(PACKETS, packets);
3907  SET_DO_SHOW(PIXEL_FORMATS, pixel_formats);
3908  SET_DO_SHOW(PIXEL_FORMAT_FLAGS, pixel_format_flags);
3909  SET_DO_SHOW(PIXEL_FORMAT_COMPONENTS, pixel_format_components);
3910  SET_DO_SHOW(PROGRAM_VERSION, program_version);
3911  SET_DO_SHOW(PROGRAMS, programs);
3912  SET_DO_SHOW(STREAMS, streams);
3913  SET_DO_SHOW(STREAM_DISPOSITION, stream_disposition);
3914  SET_DO_SHOW(PROGRAM_STREAM_DISPOSITION, stream_disposition);
3915 
3916  SET_DO_SHOW(CHAPTER_TAGS, chapter_tags);
3917  SET_DO_SHOW(FORMAT_TAGS, format_tags);
3918  SET_DO_SHOW(FRAME_TAGS, frame_tags);
3919  SET_DO_SHOW(PROGRAM_TAGS, program_tags);
3920  SET_DO_SHOW(STREAM_TAGS, stream_tags);
3921  SET_DO_SHOW(PROGRAM_STREAM_TAGS, stream_tags);
3922  SET_DO_SHOW(PACKET_TAGS, packet_tags);
3923 
3926  "-bitexact and -show_program_version or -show_library_versions "
3927  "options are incompatible\n");
3928  ret = AVERROR(EINVAL);
3929  goto end;
3930  }
3931 
3933 
3934  if (!print_format)
3935  print_format = av_strdup("default");
3936  if (!print_format) {
3937  ret = AVERROR(ENOMEM);
3938  goto end;
3939  }
3940  w_name = av_strtok(print_format, "=", &buf);
3941  if (!w_name) {
3943  "No name specified for the output format\n");
3944  ret = AVERROR(EINVAL);
3945  goto end;
3946  }
3947  w_args = buf;
3948 
3949  if (show_data_hash) {
3950  if ((ret = av_hash_alloc(&hash, show_data_hash)) < 0) {
3951  if (ret == AVERROR(EINVAL)) {
3952  const char *n;
3954  "Unknown hash algorithm '%s'\nKnown algorithms:",
3955  show_data_hash);
3956  for (i = 0; (n = av_hash_names(i)); i++)
3957  av_log(NULL, AV_LOG_ERROR, " %s", n);
3958  av_log(NULL, AV_LOG_ERROR, "\n");
3959  }
3960  goto end;
3961  }
3962  }
3963 
3964  w = writer_get_by_name(w_name);
3965  if (!w) {
3966  av_log(NULL, AV_LOG_ERROR, "Unknown output format with name '%s'\n", w_name);
3967  ret = AVERROR(EINVAL);
3968  goto end;
3969  }
3970 
3971  if ((ret = writer_open(&wctx, w, w_args,
3972  sections, FF_ARRAY_ELEMS(sections))) >= 0) {
3973  if (w == &xml_writer)
3975 
3977 
3984 
3985  if (!input_filename &&
3988  show_usage();
3989  av_log(NULL, AV_LOG_ERROR, "You have to specify one input file.\n");
3990  av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
3991  ret = AVERROR(EINVAL);
3992  } else if (input_filename) {
3994  if (ret < 0 && do_show_error)
3995  show_error(wctx, ret);
3996  }
3997 
3999  writer_close(&wctx);
4000  }
4001 
4002 end:
4005  av_hash_freep(&hash);
4006 
4007  uninit_opts();
4008  for (i = 0; i < FF_ARRAY_ELEMS(sections); i++)
4010 
4012 
4013  return ret < 0;
4014 }
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:1284
main
int main(int argc, char **argv)
Definition: ffprobe.c:3868
AVSubtitle
Definition: avcodec.h:2289
SECTION_ID_STREAM_SIDE_DATA_LIST
@ SECTION_ID_STREAM_SIDE_DATA_LIST
Definition: ffprobe.c:210
opt_format
static int opt_format(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3451
pthread_mutex_t
_fmutex pthread_mutex_t
Definition: os2threads.h:53
clear_log
static void clear_log(int need_lock)
Definition: ffprobe.c:2274
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:3461
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:424
OPT_EXIT
#define OPT_EXIT
Definition: cmdutils.h:176
AVCodec
AVCodec.
Definition: codec.h:202
writer_get_by_name
static const Writer * writer_get_by_name(const char *name)
Definition: ffprobe.c:913
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:376
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:1260
WriterContext::section_pbuf
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]
generic print buffer dedicated to each section, used by various writers
Definition: ffprobe.c:483
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
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:117
WriterContext::level
int level
current level, starting from 0
Definition: ffprobe.c:476
WriterContext::string_validation
int string_validation
Definition: ffprobe.c:490
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:74
MAX_REGISTERED_WRITERS_NB
#define MAX_REGISTERED_WRITERS_NB
Definition: ffprobe.c:898
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
level
uint8_t level
Definition: svq3.c:204
do_show_log
static int do_show_log
Definition: ffprobe.c:106
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:78
SECTION_MAX_NB_LEVELS
#define SECTION_MAX_NB_LEVELS
Definition: ffprobe.c:465
writer_close
static void writer_close(WriterContext **wctx)
Definition: ffprobe.c:532
SECTION_ID_STREAM_SIDE_DATA
@ SECTION_ID_STREAM_SIDE_DATA
Definition: ffprobe.c:211
do_show_frame_tags
static int do_show_frame_tags
Definition: ffprobe.c:110
PLANAR
#define PLANAR
Definition: flacdsp.c:43
AVChapter::metadata
AVDictionary * metadata
Definition: avformat.h:1163
r
const char * r
Definition: vf_curves.c:116
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:3440
SECTION_ID_NONE
@ SECTION_ID_NONE
Definition: ffprobe.c:164
opt.h
read_intervals_nb
static int read_intervals_nb
Definition: ffprobe.c:139
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
AVFMT_SHOW_IDS
#define AVFMT_SHOW_IDS
Show format stream IDs numbers.
Definition: avformat.h:473
AVSphericalMapping::projection
enum AVSphericalProjection projection
Projection type.
Definition: spherical.h:86
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:1364
ReadInterval::end_is_offset
int end_is_offset
Definition: ffprobe.c:134
LogBuffer::log_message
char * log_message
Definition: ffprobe.c:308
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:494
libm.h
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:234
show_streams
static int show_streams(WriterContext *w, InputFile *ifile)
Definition: ffprobe.c:2989
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:215
Writer::name
const char * name
Definition: ffprobe.c:452
print_str
#define print_str(k, v)
Definition: ffprobe.c:1832
LogBuffer::context_name
char * context_name
Definition: ffprobe.c:306
writer_print_section_header
static void writer_print_section_header(WriterContext *wctx, int section_id)
Definition: ffprobe.c:646
color
Definition: vf_paletteuse.c:599
av_bprint_init
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:68
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:151
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:1839
compact_print_section_footer
static void compact_print_section_footer(WriterContext *wctx)
Definition: ffprobe.c:1172
SECTION_ID_PACKET_SIDE_DATA_LIST
@ SECTION_ID_PACKET_SIDE_DATA_LIST
Definition: ffprobe.c:190
AVFormatContext::nb_chapters
unsigned int nb_chapters
Number of chapters in AVChapter array.
Definition: avformat.h:1418
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:52
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:228
show_stream
static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program)
Definition: ffprobe.c:2767
print_list_fmt
#define print_list_fmt(k, f, n,...)
Definition: ffprobe.c:1820
sub
static float sub(float src0, float src1)
Definition: dnn_backend_native_layer_mathbinary.c:31
AVCodecParameters::color_space
enum AVColorSpace color_space
Definition: codec_par.h:149
Writer::init
int(* init)(WriterContext *wctx)
Definition: ffprobe.c:454
thread.h
value_string
static char * value_string(char *buf, int buf_size, struct unit_value uv)
Definition: ffprobe.c:382
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
read_packets
static int read_packets(WriterContext *w, InputFile *ifile)
Definition: ffprobe.c:2747
pthread_mutex_init
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Definition: os2threads.h:104
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:2325
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:435
CompactContext::print_section
int print_section
Definition: ffprobe.c:1093
AVMasteringDisplayMetadata::has_luminance
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
Definition: mastering_display_metadata.h:67
AV_FRAME_DATA_DOVI_METADATA
@ AV_FRAME_DATA_DOVI_METADATA
Parsed Dolby Vision metadata, suitable for passing to a software implementation.
Definition: frame.h:203
InputStream::dec_ctx
AVCodecContext * dec_ctx
Definition: ffmpeg.h:311
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:260
Writer::print_section_footer
void(* print_section_footer)(WriterContext *wctx)
Definition: ffprobe.c:458
AVCodecDescriptor::name
const char * name
Name of the codec described by this descriptor.
Definition: codec_desc.h:46
writer_open
static int writer_open(WriterContext **wctx, const Writer *writer, const char *args, const struct section *sections, int nb_sections)
Definition: ffprobe.c:559
selected_streams
static int * selected_streams
Definition: ffprobe.c:300
SECTION_ID_PROGRAM_TAGS
@ SECTION_ID_PROGRAM_TAGS
Definition: ffprobe.c:202
av_asprintf
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:113
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:215
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:188
AV_FRAME_DATA_S12M_TIMECODE
@ AV_FRAME_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1.
Definition: frame.h:151
DefaultContext
Definition: ffprobe.c:940
Writer::priv_class
const AVClass * priv_class
private class of the writer, if any
Definition: ffprobe.c:450
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:360
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
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:482
json_escape_str
static const char * json_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
Definition: ffprobe.c:1506
print_ts
#define print_ts(k, v)
Definition: ffprobe.c:1836
opt_input_file_i
static int opt_input_file_i(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3574
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:488
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
pixdesc.h
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1268
index
fg index
Definition: ffmpeg_filter.c:167
AVPacketSideData
Definition: packet.h:314
w
uint8_t w
Definition: llviddspenc.c:38
validate_string
static int validate_string(WriterContext *wctx, char **dstp, const char *src)
Definition: ffprobe.c:698
OPT_INPUT
#define OPT_INPUT
Definition: cmdutils.h:183
opt_show_format_entry
static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3545
avcodec_decode_subtitle2
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
Definition: decode.c:805
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:179
SECTION_ID_PIXEL_FORMAT_COMPONENTS
@ SECTION_ID_PIXEL_FORMAT_COMPONENTS
Definition: ffprobe.c:195
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:373
ReadInterval::duration_frames
int duration_frames
Definition: ffprobe.c:135
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:37
AVPixFmtDescriptor::name
const char * name
Definition: pixdesc.h:70
AVOption
AVOption.
Definition: opt.h:247
HAS_ARG
#define HAS_ARG
Definition: cmdutils.h:166
ist
ifilter ist
Definition: ffmpeg_filter.c:177
b
#define b
Definition: input.c:40
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:497
SECTION_ID_STREAM
@ SECTION_ID_STREAM
Definition: ffprobe.c:206
section::element_name
const char * element_name
name of the contained element, if provided
Definition: ffprobe.c:157
SECTION_ID_PIXEL_FORMAT_FLAGS
@ SECTION_ID_PIXEL_FORMAT_FLAGS
Definition: ffprobe.c:193
LogBuffer
Definition: ffprobe.c:305
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:1015
spherical.h
AVChapter::start
int64_t start
Definition: avformat.h:1162
data
const char data[16]
Definition: mxf.c:143
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:2667
print_dovi_metadata
static void print_dovi_metadata(WriterContext *w, const AVDOVIMetadata *dovi)
Definition: ffprobe.c:1875
format_opts
AVDictionary * format_opts
Definition: cmdutils.c:71
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:687
PRINT_DISPOSITION
#define PRINT_DISPOSITION(flagname, name)
XMLContext::within_tag
int within_tag
Definition: ffprobe.c:1646
SECTION_MAX_NB_CHILDREN
#define SECTION_MAX_NB_CHILDREN
Definition: ffprobe.c:145
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:68
do_show_stream_tags
static int do_show_stream_tags
Definition: ffprobe.c:112
ini_escape_str
static char * ini_escape_str(AVBPrint *dst, const char *src)
Definition: ffprobe.c:1390
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:1846
SECTION_ID_PIXEL_FORMAT
@ SECTION_ID_PIXEL_FORMAT
Definition: ffprobe.c:192
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:201
print_format
static char * print_format
Definition: ffprobe.c:126
category
category
Definition: openal-dec.c:248
AVFormatContext::programs
AVProgram ** programs
Definition: avformat.h:1369
OFFSET
#define OFFSET(x)
Definition: ffprobe.c:1653
SECTION_ID_FORMAT
@ SECTION_ID_FORMAT
Definition: ffprobe.c:169
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:198
AVOption::flags
int flags
Definition: opt.h:276
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:84
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:2612
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:391
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:64
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:72
check_section_show_entries
static int check_section_show_entries(int section_id)
Definition: ffprobe.c:3851
print_section
static void print_section(SectionID id, int level)
Definition: ffprobe.c:3746
section::id
int id
unique id identifying a section
Definition: ffprobe.c:148
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:30
writer_options
static const AVOption writer_options[]
Definition: ffprobe.c:503
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:157
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:469
AVDOVIRpuDataHeader::rpu_format
uint16_t rpu_format
Definition: dovi_meta.h:78
DefaultContext::nokey
int nokey
Definition: ffprobe.c:942
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:476
av_read_frame
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: demux.c:1412
writer_register_all
static void writer_register_all(void)
Definition: ffprobe.c:1797
AVDOVIDataMapping::mapping_color_space
uint8_t mapping_color_space
Definition: dovi_meta.h:141
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:228
CompactContext
Definition: ffprobe.c:1088
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
dec_val
double dec_val
Definition: ffprobe.c:280
show_tags
static int show_tags(WriterContext *w, AVDictionary *tags, int section_id)
Definition: ffprobe.c:1857
AV_RL8
#define AV_RL8(x)
Definition: intreadwrite.h:398
avio_size
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:352
av_strlcatf
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:101
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:428
do_show_format_tags
static int do_show_format_tags
Definition: ffprobe.c:109
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:75
av_chroma_location_name
const char * av_chroma_location_name(enum AVChromaLocation location)
Definition: pixdesc.c:3069
section::unique_name
const char * unique_name
unique section name, in case the name is ambiguous
Definition: ffprobe.c:158
Writer::print_string
void(* print_string)(WriterContext *wctx, const char *, const char *)
Definition: ffprobe.c:461
do_show_frames
static int do_show_frames
Definition: ffprobe.c:95
json_print_int
static void json_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1613
OptionDef
Definition: cmdutils.h:163
AVUNERROR
#define AVUNERROR(e)
Definition: error.h:46
compact_init
static av_cold int compact_init(WriterContext *wctx)
Definition: ffprobe.c:1118
AVInputFormat::long_name
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:662
xml_print_section_footer
static void xml_print_section_footer(WriterContext *wctx)
Definition: ffprobe.c:1728
SECTION_ID_FRAME_TAGS
@ SECTION_ID_FRAME_TAGS
Definition: ffprobe.c:173
init
static int init
Definition: av_tx.c:47
ReadInterval::id
int id
identifier
Definition: ffprobe.c:131
AVContentLightMetadata
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
Definition: mastering_display_metadata.h:98
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:102
exit_program
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
Definition: cmdutils.c:128
AVCodecParameters::color_primaries
enum AVColorPrimaries color_primaries
Definition: codec_par.h:147
InputStream
Definition: ffmpeg.h:302
avformat_close_input
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: demux.c:355
AVPacketSideData::size
size_t size
Definition: packet.h:316
parse_number_or_die
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
Parse a string and return its corresponding value as a double.
Definition: cmdutils.c:136
match_section
static int match_section(const char *section_name, int show_all_entries, AVDictionary *entries)
Definition: ffprobe.c:3476
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:1374
unit_hertz_str
static const char unit_hertz_str[]
Definition: ffprobe.c:293
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:383
SHOW_OPTIONAL_FIELDS_NEVER
#define SHOW_OPTIONAL_FIELDS_NEVER
Definition: ffprobe.c:122
SECTION_ID_STREAMS
@ SECTION_ID_STREAMS
Definition: ffprobe.c:208
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:1087
AVCodecParameters::channels
int channels
Audio only.
Definition: codec_par.h:166
AV_FIELD_TT
@ AV_FIELD_TT
Definition: codec_par.h:39
show_optional_fields
static int show_optional_fields
Definition: ffprobe.c:124
json_print_section_footer
static void json_print_section_footer(WriterContext *wctx)
Definition: ffprobe.c:1566
av_color_space_name
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:3048
unit_value::val
union unit_value::@5 val
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:3737
AVCodecContext::codec
const struct AVCodec * codec
Definition: avcodec.h:392
U
#define U(x)
Definition: vp56_arith.h:37
json_options
static const AVOption json_options[]
Definition: ffprobe.c:1488
default_options
static const AVOption default_options[]
Definition: ffprobe.c:950
fail
#define fail()
Definition: checkasm.h:127
writer_get_name
static const char * writer_get_name(void *p)
Definition: ffprobe.c:495
av_hash_get_name
const char * av_hash_get_name(const AVHashContext *ctx)
Definition: hash.c:92
process_frame
static av_always_inline int process_frame(WriterContext *w, InputFile *ifile, AVFrame *frame, AVPacket *pkt, int *packet_new)
Definition: ffprobe.c:2552
LogBuffer::log_level
int log_level
Definition: ffprobe.c:307
print_chroma_location
static void print_chroma_location(WriterContext *w, enum AVChromaLocation chroma_location)
Definition: ffprobe.c:2263
av_strerror
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
Definition: error.c:105
AVDOVIRpuDataHeader::el_bit_depth
uint8_t el_bit_depth
Definition: dovi_meta.h:87
Writer::uninit
void(* uninit)(WriterContext *wctx)
Definition: ffprobe.c:455
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:153
json_writer
static const Writer json_writer
Definition: ffprobe.c:1630
AVCodecContext::refs
int refs
number of reference frames
Definition: avcodec.h:932
AVERROR_OPTION_NOT_FOUND
#define AVERROR_OPTION_NOT_FOUND
Option not found.
Definition: error.h:63
AV_BPRINT_SIZE_AUTOMATIC
#define AV_BPRINT_SIZE_AUTOMATIC
AVChapter
Definition: avformat.h:1159
default_print_int
static void default_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1017
val
static double val(void *priv, double ch)
Definition: aeval.c:76
json_init
static av_cold int json_init(WriterContext *wctx)
Definition: ffprobe.c:1496
show_help_default
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
Definition: ffprobe.c:3586
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:1042
SECTION_ID_FRAME_SIDE_DATA_PIECE
@ SECTION_ID_FRAME_SIDE_DATA_PIECE
Definition: ffprobe.c:181
AVCodecContext::coded_height
int coded_height
Definition: avcodec.h:571
us
#define us(width, name, range_min, range_max, subs,...)
Definition: cbs_h2645.c:278
ini_print_section_header
static void ini_print_section_header(WriterContext *wctx)
Definition: ffprobe.c:1417
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:108
av_opt_set
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:468
show_log
static int show_log(WriterContext *w, int section_ids, int section_id, int log_level)
Definition: ffprobe.c:2290
OPT_STRING
#define OPT_STRING
Definition: cmdutils.h:169
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:985
AV_FIELD_TB
@ AV_FIELD_TB
Definition: codec_par.h:41
input_filename
static const char * input_filename
Definition: ffprobe.c:272
print_duration_ts
#define print_duration_ts(k, v)
Definition: ffprobe.c:1838
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
json_print_section_header
static void json_print_section_header(WriterContext *wctx)
Definition: ffprobe.c:1528
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:1302
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:91
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:3732
avsubtitle_free
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: avcodec.c:425
close_input_file
static void close_input_file(InputFile *ifile)
Definition: ffprobe.c:3242
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:97
AV_PKT_DATA_STRINGS_METADATA
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
Definition: packet.h:172
parse_read_intervals
static int parse_read_intervals(const char *intervals_spec)
Definition: ffprobe.c:3684
AVFormatContext::bit_rate
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:1309
av_get_bits_per_sample
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:580
AVCodecParameters::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: codec_par.h:148
json_print_item_str
static void json_print_item_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1588
av_packet_side_data_name
const char * av_packet_side_data_name(enum AVPacketSideDataType type)
Definition: avpacket.c:270
default_writer
static const Writer default_writer
Definition: ffprobe.c:1026
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:803
show_frame
static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, AVFormatContext *fmt_ctx)
Definition: ffprobe.c:2401
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: utils.c:1365
do_show_error
static int do_show_error
Definition: ffprobe.c:93
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:202
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:1429
AVFrameSideData::size
size_t size
Definition: frame.h:226
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
AVInputFormat
Definition: avformat.h:650
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_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:621
nb_streams_frames
static uint64_t * nb_streams_frames
Definition: ffprobe.c:299
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:357
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:207
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:120
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:40
postprocess.h
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:328
SECTION_ID_FORMAT_TAGS
@ SECTION_ID_FORMAT_TAGS
Definition: ffprobe.c:170
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:460
OPT_INT
#define OPT_INT
Definition: cmdutils.h:172
AVDOVIRpuDataHeader::rpu_type
uint8_t rpu_type
Definition: dovi_meta.h:77
writer_print_data_hash
static void writer_print_data_hash(WriterContext *wctx, const char *name, uint8_t *data, int size)
Definition: ffprobe.c:857
initialized
static int initialized
Definition: vaapi_transcode.c:46
avcodec_alloc_context3
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
Definition: options.c:141
do_count_frames
static int do_count_frames
Definition: ffprobe.c:88
AVChapter::end
int64_t end
chapter start/end time in time_base units
Definition: avformat.h:1162
writer_child_next
static void * writer_child_next(void *obj, void *prev)
Definition: ffprobe.c:516
print_section_footer
#define print_section_footer(s)
Definition: ffprobe.c:1847
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:132
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:2615
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
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
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:114
unit_bit_per_second_str
static const char unit_bit_per_second_str[]
Definition: ffprobe.c:295
show_program
static int show_program(WriterContext *w, InputFile *ifile, AVProgram *program)
Definition: ffprobe.c:3006
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:224
AV_PKT_DATA_MASTERING_DISPLAY_METADATA
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition: packet.h:222
xml_options
static const AVOption xml_options[]
Definition: ffprobe.c:1655
AVFormatContext::nb_programs
unsigned int nb_programs
Definition: avformat.h:1368
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:655
AVFormatContext::iformat
const struct AVInputFormat * iformat
The input container format.
Definition: avformat.h:1212
AVFormatContext::chapters
AVChapter ** chapters
Definition: avformat.h:1419
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:212
AVDictionaryEntry::key
char * key
Definition: dict.h:80
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:126
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:102
av_bprint_channel_layout
void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout)
Append a description of a channel layout to a bprint buffer.
Definition: channel_layout.c:183
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:186
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:1091
print_fmt
#define print_fmt(k, f,...)
Definition: ffprobe.c:1814
FlatContext
Definition: ffprobe.c:1250
avcodec_receive_frame
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder.
Definition: decode.c:642
FF_PROFILE_UNKNOWN
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:1526
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
xml_print_str
static void xml_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1747
probe_file
static int probe_file(WriterContext *wctx, const char *filename, const char *print_filename)
Definition: ffprobe.c:3256
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:1526
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1425
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
AVPacketSideData::data
uint8_t * data
Definition: packet.h:315
section::show_all_entries
int show_all_entries
Definition: ffprobe.c:160
AVDOVIDecoderConfigurationRecord::dv_profile
uint8_t dv_profile
Definition: dovi_meta.h:55
print_pkt_side_data
static void print_pkt_side_data(WriterContext *w, AVCodecParameters *par, const AVPacketSideData *side_data, int nb_side_data, SectionID id_data_list, SectionID id_data)
Definition: ffprobe.c:2121
ctx
AVFormatContext * ctx
Definition: movenc.c:48
flat_print_str
static void flat_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1348
SECTION_ID_ROOT
@ SECTION_ID_ROOT
Definition: ffprobe.c:205
nb_streams
static int nb_streams
Definition: ffprobe.c:297
ffprobe_show_program_version
static void ffprobe_show_program_version(WriterContext *w)
Definition: ffprobe.c:3344
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:141
pixel_formats
static enum AVPixelFormat pixel_formats[]
Definition: vf_sr.c:69
do_show_chapter_tags
static int do_show_chapter_tags
Definition: ffprobe.c:108
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:105
AV_DOVI_MAPPING_POLYNOMIAL
@ AV_DOVI_MAPPING_POLYNOMIAL
Definition: dovi_meta.h:95
parse_options
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *, const char *))
Definition: cmdutils.c:374
CompactContext::nested_section
int nested_section[SECTION_MAX_NB_LEVELS]
Definition: ffprobe.c:1096
AVCodecContext::rc_max_rate
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:1194
flat_writer
static const Writer flat_writer
Definition: ffprobe.c:1361
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:49
key
const char * key
Definition: hwcontext_opencl.c:168
color_range
color_range
Definition: vf_selectivecolor.c:44
flat_escape_value_str
static const char * flat_escape_value_str(AVBPrint *dst, const char *src)
Definition: ffprobe.c:1299
do_show_chapters
static int do_show_chapters
Definition: ffprobe.c:92
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:472
AVCPBProperties
This structure describes the bitrate properties of an encoded bitstream.
Definition: defs.h:104
AVFormatContext::probe_score
int probe_score
format probing score.
Definition: avformat.h:1625
AV_FIELD_BT
@ AV_FIELD_BT
Definition: codec_par.h:42
show_chapters
static int show_chapters(WriterContext *w, InputFile *ifile)
Definition: ffprobe.c:3055
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
find_stream_info
static int find_stream_info
Definition: ffprobe.c:141
SECTION_ID_FRAME_LOGS
@ SECTION_ID_FRAME_LOGS
Definition: ffprobe.c:183
FF_CODEC_PROPERTY_FILM_GRAIN
#define FF_CODEC_PROPERTY_FILM_GRAIN
Definition: avcodec.h:1825
arg
const char * arg
Definition: jacosubdec.c:67
AVStereo3D::flags
int flags
Additional information about the frame packing.
Definition: stereo3d.h:185
do_show_pixel_format_flags
static int do_show_pixel_format_flags
Definition: ffprobe.c:104
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
compact_print_section_header
static void compact_print_section_header(WriterContext *wctx)
Definition: ffprobe.c:1140
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:151
section::name
const char * name
Definition: ffprobe.c:149
open_input_file
static int open_input_file(InputFile *ifile, const char *filename, const char *print_filename)
Definition: ffprobe.c:3125
AVDOVINLQParams::linear_deadzone_threshold
uint64_t linear_deadzone_threshold
Definition: dovi_meta.h:131
writer_print_data
static void writer_print_data(WriterContext *wctx, const char *name, uint8_t *data, int size)
Definition: ffprobe.c:829
InputFile::streams
InputStream * streams
Definition: ffprobe.c:80
av_color_range_name
const char * av_color_range_name(enum AVColorRange range)
Definition: pixdesc.c:2988
ReadInterval::start
int64_t start
Definition: ffprobe.c:132
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:54
AVFormatContext
Format I/O context.
Definition: avformat.h:1200
print_int
#define print_int(k, v)
Definition: ffprobe.c:1830
init_dynload
void init_dynload(void)
Initialize dynamic library loading.
Definition: cmdutils.c:112
opts
AVDictionary * opts
Definition: movenc.c:50
read_intervals
static ReadInterval * read_intervals
Definition: ffprobe.c:138
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1095
opt_input_file
static void opt_input_file(void *optctx, const char *arg)
Definition: ffprobe.c:3561
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
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:133
avcodec_get_class
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
Definition: options.c:174
SECTION_ID_FRAME_LOG
@ SECTION_ID_FRAME_LOG
Definition: ffprobe.c:182
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:965
NULL
#define NULL
Definition: coverity.c:32
section::children_ids
int children_ids[SECTION_MAX_NB_CHILDREN+1]
list of children section IDS, terminated by -1
Definition: ffprobe.c:156
compact_print_str
static void compact_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1182
av_hash_names
const char * av_hash_names(int i)
Get the names of available hash algorithms.
Definition: hash.c:86
SET_DO_SHOW
#define SET_DO_SHOW(id, varname)
Definition: ffprobe.c:3863
print_color_range
static void print_color_range(WriterContext *w, enum AVColorRange color_range)
Definition: ffprobe.c:2223
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:84
compact_writer
static const Writer compact_writer
Definition: ffprobe.c:1205
StringValidation
StringValidation
Definition: ffprobe.c:442
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:1254
InputStream::st
AVStream * st
Definition: ffmpeg.h:304
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:139
fmt_ctx
static AVFormatContext * fmt_ctx
Definition: demuxing_decoding.c:38
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:1195
OPT_EXPERT
#define OPT_EXPERT
Definition: cmdutils.h:168
ERROR
static void ERROR(const char *str)
Definition: audio_fifo.c:58
do_read_frames
static int do_read_frames
Definition: ffprobe.c:90
SECTION_ID_LIBRARY_VERSION
@ SECTION_ID_LIBRARY_VERSION
Definition: ffprobe.c:184
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:156
hash
static struct AVHashContext * hash
Definition: ffprobe.c:276
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
SECTION_ID_STREAM_TAGS
@ SECTION_ID_STREAM_TAGS
Definition: ffprobe.c:209
SHOW_OPTIONAL_FIELDS_ALWAYS
#define SHOW_OPTIONAL_FIELDS_ALWAYS
Definition: ffprobe.c:123
AVPacketSideData::type
enum AVPacketSideDataType type
Definition: packet.h:317
print_q
#define print_q(k, v, s)
Definition: ffprobe.c:1831
AVFormatContext::pb
AVIOContext * pb
I/O context.
Definition: avformat.h:1242
av_log_set_flags
void av_log_set_flags(int arg)
Definition: log.c:445
AV_RN32
#define AV_RN32(p)
Definition: intreadwrite.h:364
src
#define src
Definition: vp8dsp.c:255
parseutils.h
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:143
WriterContext::name
char * name
name of this writer instance
Definition: ffprobe.c:470
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:119
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:1006
av_color_primaries_name
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition: pixdesc.c:3006
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:1617
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
AV_DICT_DONT_OVERWRITE
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
Definition: dict.h:74
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:137
xml_init
static av_cold int xml_init(WriterContext *wctx)
Definition: ffprobe.c:1665
WriterContext::sections
const struct section * sections
array containing all sections
Definition: ffprobe.c:473
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:160
csv_writer
static const Writer csv_writer
Definition: ffprobe.c:1236
print_color_trc
static void print_color_trc(WriterContext *w, enum AVColorTransferCharacteristic color_trc)
Definition: ffprobe.c:2253
Writer::print_integer
void(* print_integer)(WriterContext *wctx, const char *, long long int)
Definition: ffprobe.c:459
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:97
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
bin_str
const char * bin_str
Definition: ffprobe.c:281
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:2639
real_options
static const OptionDef real_options[]
Definition: ffprobe.c:3800
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:563
WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER
#define WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER
Definition: ffprobe.c:440
AVCodecParameters::level
int level
Definition: codec_par.h:121
WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
#define WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
Definition: ffprobe.c:439
swresample.h
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:294
program_birth_year
const int program_birth_year
program birth year, defined by the program for show_banner()
Definition: ffprobe.c:85
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:170
pthread_mutex_unlock
#define pthread_mutex_unlock(a)
Definition: ffprobe.c:68
AVAudioServiceType
AVAudioServiceType
Definition: defs.h:57
av_hash_freep
void av_hash_freep(AVHashContext **ctx)
Free hash context and set hash context pointer to NULL.
Definition: hash.c:236
show_format
static int show_format(WriterContext *w, InputFile *ifile)
Definition: ffprobe.c:3080
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:987
SECTION_ID_CHAPTER
@ SECTION_ID_CHAPTER
Definition: ffprobe.c:165
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:921
print_duration_time
#define print_duration_time(k, v, tb)
Definition: ffprobe.c:1837
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:78
show_value_unit
static int show_value_unit
Definition: ffprobe.c:115
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1256
print_input_filename
static const char * print_input_filename
Definition: ffprobe.c:273
SECTION_ID_FRAMES
@ SECTION_ID_FRAMES
Definition: ffprobe.c:172
codec_opts
AVDictionary * codec_opts
Definition: cmdutils.c:71
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:1065
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:2388
WRITER_STRING_VALIDATION_IGNORE
@ WRITER_STRING_VALIDATION_IGNORE
Definition: ffprobe.c:445
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:61
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:65
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:492
DefaultContext::noprint_wrappers
int noprint_wrappers
Definition: ffprobe.c:943
av_log_set_callback
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
Definition: log.c:455
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:374
ReadInterval::start_is_offset
int start_is_offset
Definition: ffprobe.c:134
do_show_packet_tags
static int do_show_packet_tags
Definition: ffprobe.c:113
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: utils.c:1543
id
enum AVCodecID id
Definition: extract_extradata_bsf.c:325
SECTION_ID_STREAM_DISPOSITION
@ SECTION_ID_STREAM_DISPOSITION
Definition: ffprobe.c:207
avformat_alloc_context
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:154
PRINT_PIX_FMT_FLAG
#define PRINT_PIX_FMT_FLAG(flagname, name)
Definition: ffprobe.c:3389
OPT_AUDIO
#define OPT_AUDIO
Definition: cmdutils.h:171
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
AVDOVIRpuDataHeader::vdr_rpu_profile
uint8_t vdr_rpu_profile
Definition: dovi_meta.h:79
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
XMLContext::fully_qualified
int fully_qualified
Definition: ffprobe.c:1648
AVFormatContext::url
char * url
input or output URL.
Definition: avformat.h:1283
si_prefixes
static const struct @4 si_prefixes[]
SECTION_FLAG_IS_ARRAY
#define SECTION_FLAG_IS_ARRAY
the section contains an array of elements of the same type
Definition: ffprobe.c:152
SectionID
SectionID
Definition: ffprobe.c:163
REALLOCZ_ARRAY_STREAM
#define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n)
Definition: ffprobe.c:1849
uninit_opts
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents.
Definition: cmdutils.c:83
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:166
AV_ESCAPE_MODE_XML
@ AV_ESCAPE_MODE_XML
Use XML non-markup character data escaping.
Definition: avstring.h:327
show_private_data
static int show_private_data
Definition: ffprobe.c:119
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:656
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
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:147
xml_print_int
static void xml_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1778
opt_show_versions
static int opt_show_versions(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3775
AVFrameSideData::data
uint8_t * data
Definition: frame.h:225
AVCodecParameters::profile
int profile
Codec-specific bitstream restrictions that the stream conforms to.
Definition: codec_par.h:120
format
ofilter format
Definition: ffmpeg_filter.c:172
PAL
#define PAL
Definition: bktr.c:65
setup_find_stream_info_opts
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
Definition: cmdutils.c:2178
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:617
ffprobe_show_library_versions
static void ffprobe_show_library_versions(WriterContext *w)
Definition: ffprobe.c:3375
printf
printf("static const uint8_t my_array[100] = {\n")
SECTION_ID_PACKETS_AND_FRAMES
@ SECTION_ID_PACKETS_AND_FRAMES
Definition: ffprobe.c:189
AVOption::name
const char * name
Definition: opt.h:248
use_value_prefix
static int use_value_prefix
Definition: ffprobe.c:116
SECTION_ID_ERROR
@ SECTION_ID_ERROR
Definition: ffprobe.c:168
DefaultContext::nested_section
int nested_section[SECTION_MAX_NB_LEVELS]
Definition: ffprobe.c:944
AVCPBProperties::min_bitrate
int64_t min_bitrate
Minimum bitrate of the stream, in bits per second.
Definition: defs.h:114
unit_value
Definition: ffprobe.c:377
flat_print_int
static void flat_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1343
avdevice.h
show_error
static void show_error(WriterContext *w, int err)
Definition: ffprobe.c:3111
Writer::flags
int flags
a combination or WRITER_FLAG_*
Definition: ffprobe.c:462
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:344
ini_print_str
static void ini_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1450
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
AV_OPT_SEARCH_CHILDREN
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition: opt.h:559
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
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:372
AVSphericalMapping::padding
uint32_t padding
Number of pixels to pad from the edge of each cube face.
Definition: spherical.h:182
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:487
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:174
SECTION_ID_PACKET_TAGS
@ SECTION_ID_PACKET_TAGS
Definition: ffprobe.c:187
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:58
line
Definition: graph2dot.c:48
AV_PKT_DATA_CONTENT_LIGHT_LEVEL
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: packet.h:235
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:379
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:64
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:203
do_show_format
static int do_show_format
Definition: ffprobe.c:94
AVCPBProperties::avg_bitrate
int64_t avg_bitrate
Average bitrate of the stream, in bits per second.
Definition: defs.h:119
ReadInterval
Definition: ffprobe.c:130
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:756
AV_STEREO3D_FLAG_INVERT
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
Definition: stereo3d.h:167
Writer
Definition: ffprobe.c:449
section::entries_to_show
AVDictionary * entries_to_show
Definition: ffprobe.c:159
do_show_stream_disposition
static int do_show_stream_disposition
Definition: ffprobe.c:99
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
xml_print_section_header
static void xml_print_section_header(WriterContext *wctx)
Definition: ffprobe.c:1688
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:451
AVStream::side_data
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
Definition: avformat.h:1044
AVChromaLocation
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:616
registered_writers
static const Writer * registered_writers[MAX_REGISTERED_WRITERS_NB+1]
Definition: ffprobe.c:900
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
show_banner
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
Definition: cmdutils.c:1185
do_count_packets
static int do_count_packets
Definition: ffprobe.c:89
iformat
static const AVInputFormat * iformat
Definition: ffprobe.c:274
SHOW_OPTIONAL_FIELDS_AUTO
#define SHOW_OPTIONAL_FIELDS_AUTO
Definition: ffprobe.c:121
pthread_mutex_destroy
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
Definition: os2threads.h:112
ReadInterval::has_start
int has_start
Definition: ffprobe.c:133
sections
static struct section sections[]
Definition: ffprobe.c:215
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:83
register_exit
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
Definition: cmdutils.c:123
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:134
unit_value::unit
const char * unit
Definition: ffprobe.c:379
AV_FIELD_BB
@ AV_FIELD_BB
Definition: codec_par.h:40
SECTION_ID_PROGRAM_STREAM_TAGS
@ SECTION_ID_PROGRAM_STREAM_TAGS
Definition: ffprobe.c:198
JSONContext::indent_level
int indent_level
Definition: ffprobe.c:1480
section::flags
int flags
For these sections the element_name field is mandatory.
Definition: ffprobe.c:155
avcodec_send_packet
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
Definition: decode.c:579
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:136
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:128
AVClassCategory
AVClassCategory
Definition: log.h:28
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:366
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:136
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:1822
SECTION_ID_PROGRAM
@ SECTION_ID_PROGRAM
Definition: ffprobe.c:199
AVChapter::id
int64_t id
unique ID to identify the chapter
Definition: avformat.h:1160
print_color_space
static void print_color_space(WriterContext *w, enum AVColorSpace color_space)
Definition: ffprobe.c:2233
ffprobe_show_pixel_formats
static void ffprobe_show_pixel_formats(WriterContext *w)
Definition: ffprobe.c:3394
WRITER_STRING_VALIDATION_NB
@ WRITER_STRING_VALIDATION_NB
Definition: ffprobe.c:446
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:253
show_usage
static void show_usage(void)
Definition: ffprobe.c:3337
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:479
csv_options
static const AVOption csv_options[]
Definition: ffprobe.c:1222
show_subtitle
static void show_subtitle(WriterContext *w, AVSubtitle *sub, AVStream *stream, AVFormatContext *fmt_ctx)
Definition: ffprobe.c:2378
AVCodecParameters::height
int height
Definition: codec_par.h:127
avcodec_parameters_to_context
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
Definition: codec_par.c:147
XMLContext::xsd_strict
int xsd_strict
Definition: ffprobe.c:1649
do_bitexact
static int do_bitexact
Definition: ffprobe.c:87
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:523
display.h
SECTION_ID_PACKETS
@ SECTION_ID_PACKETS
Definition: ffprobe.c:188
xml_writer
static Writer xml_writer
Definition: ffprobe.c:1785
AVCPBProperties::max_bitrate
int64_t max_bitrate
Maximum bitrate of the stream, in bits per second.
Definition: defs.h:109
AVDOVIDataMapping::num_y_partitions
uint32_t num_y_partitions
Definition: dovi_meta.h:148
LogBuffer::category
AVClassCategory category
Definition: ffprobe.c:309
writer_print_ts
static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, int is_duration)
Definition: ffprobe.c:820
filter_codec_opts
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec)
Filter out options for given codec.
Definition: cmdutils.c:2120
opt_show_entries
static int opt_show_entries(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3495
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:236
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:278
SECTION_ID_FRAME_SIDE_DATA
@ SECTION_ID_FRAME_SIDE_DATA
Definition: ffprobe.c:175
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:178
opt_sections
static int opt_sections(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3763
CompactContext::escape_str
const char *(* escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
Definition: ffprobe.c:1095
WriterContext::priv
void * priv
private data for use by the filter
Definition: ffprobe.c:471
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
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:263
AVProgram
New fields can be added to the end with minor version bumps.
Definition: avformat.h:1124
AV_PKT_DATA_CPB_PROPERTIES
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
Definition: packet.h:145
AV_PKT_DATA_SKIP_SAMPLES
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: packet.h:156
AVCodecParameters::color_range
enum AVColorRange color_range
Video only.
Definition: codec_par.h:146
AVMasteringDisplayMetadata
Mastering display metadata capable of representing the color volume of the display used to master the...
Definition: mastering_display_metadata.h:38
upcase_string
static char * upcase_string(char *dst, size_t dst_size, const char *src)
Definition: ffprobe.c:961
profile
int profile
Definition: mxfenc.c:2003
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:526
AVDOVINLQParams
Coefficients of the non-linear inverse quantization.
Definition: dovi_meta.h:126
dec_str
const char * dec_str
Definition: ffprobe.c:282
SECTION_ID_PACKET_SIDE_DATA
@ SECTION_ID_PACKET_SIDE_DATA
Definition: ffprobe.c:191
av_opt_next
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
Definition: opt.c:45
use_value_sexagesimal_format
static int use_value_sexagesimal_format
Definition: ffprobe.c:118
SECTION_ID_LIBRARY_VERSIONS
@ SECTION_ID_LIBRARY_VERSIONS
Definition: ffprobe.c:185
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
SECTION_ID_FRAME_SIDE_DATA_TIMECODE
@ SECTION_ID_FRAME_SIDE_DATA_TIMECODE
Definition: ffprobe.c:177
LogBuffer::parent_name
char * parent_name
Definition: ffprobe.c:310
log2
#define log2(x)
Definition: libm.h:404
AVCodecParameters::field_order
enum AVFieldOrder field_order
Video only.
Definition: codec_par.h:141
SECTION_ID_PROGRAM_VERSION
@ SECTION_ID_PROGRAM_VERSION
Definition: ffprobe.c:203
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:1083
AVDOVIDataMapping::curves
AVDOVIReshapingCurve curves[3]
Definition: dovi_meta.h:143
ini_writer
static const Writer ini_writer
Definition: ffprobe.c:1466
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:497
PRINT_STRING_OPT
#define PRINT_STRING_OPT
Definition: ffprobe.c:753
AVDOVINLQParams::linear_deadzone_slope
uint64_t linear_deadzone_slope
Definition: dovi_meta.h:130
SECTION_ID_PROGRAMS
@ SECTION_ID_PROGRAMS
Definition: ffprobe.c:204
json_print_str
static void json_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1600
ini_print_int
static void ini_print_int(WriterContext *wctx, const char *key, long long int value)
Definition: ffprobe.c:1461
WriterContext::string_validation_replacement
char * string_validation_replacement
Definition: ffprobe.c:491
AVDOVIReshapingCurve
Definition: dovi_meta.h:104
tag
uint32_t tag
Definition: movenc.c:1596
AVStream::id
int id
Format-specific stream ID.
Definition: avformat.h:949
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:935
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:283
AV_FRAME_DATA_GOP_TIMECODE
@ AV_FRAME_DATA_GOP_TIMECODE
The GOP timecode in 25 bit timecode format.
Definition: frame.h:124
log_buffer
static LogBuffer * log_buffer
Definition: ffprobe.c:314
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
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AVCPBProperties::buffer_size
int64_t buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
Definition: defs.h:125
normalize.ifile
ifile
Definition: normalize.py:6
AVSphericalMapping::pitch
int32_t pitch
Rotation around the right vector [-90, 90].
Definition: spherical.h:127
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:91
AVStream::nb_side_data
int nb_side_data
The number of elements in the AVStream.side_data array.
Definition: avformat.h:1048
AVStereo3D::type
enum AVStereo3DType type
How views are packed within the video.
Definition: stereo3d.h:180
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:3602
ALPHA
@ ALPHA
Definition: drawutils.c:32
avformat.h
dovi_meta.h
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:93
dict.h
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: packet.h:384
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:262
flat_init
static av_cold int flat_init(WriterContext *wctx)
Definition: ffprobe.c:1270
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
AV_DICT_MATCH_CASE
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
Definition: dict.h:67
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
log_buffer_size
static int log_buffer_size
Definition: ffprobe.c:315
AVCodecParameters::chroma_location
enum AVChromaLocation chroma_location
Definition: codec_par.h:150
AVDOVIReshapingCurve::num_pivots
uint8_t num_pivots
Definition: dovi_meta.h:105
avformat_network_deinit
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:1314
AVDOVIRpuDataHeader::vdr_rpu_level
uint8_t vdr_rpu_level
Definition: dovi_meta.h:80
WriterContext::writer
const Writer * writer
the Writer of which this is an instance
Definition: ffprobe.c:469
SECTION_ID_FRAME
@ SECTION_ID_FRAME
Definition: ffprobe.c:171
av_dovi_get_color
static av_always_inline AVDOVIColorMetadata * av_dovi_get_color(const AVDOVIMetadata *data)
Definition: dovi_meta.h:220
XML_INDENT
#define XML_INDENT()
Definition: ffprobe.c:1686
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:71
AV_FRAME_DATA_DYNAMIC_HDR_PLUS
@ AV_FRAME_DATA_DYNAMIC_HDR_PLUS
HDR dynamic metadata associated with a video frame.
Definition: frame.h:158
AVCodecContext
main external API structure.
Definition: avcodec.h:383
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:943
CMDUTILS_COMMON_OPTIONS
#define CMDUTILS_COMMON_OPTIONS
Definition: cmdutils.h:217
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:165
av_bprint_clear
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
Definition: bprint.c:226
hash.h
CompactContext::nokey
int nokey
Definition: ffprobe.c:1092
WriterContext
Definition: ffprobe.c:467
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:285
JSONContext::item_sep
const char * item_sep
Definition: ffprobe.c:1482
nb_streams_packets
static uint64_t * nb_streams_packets
Definition: ffprobe.c:298
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:101
DEFINE_OPT_SHOW_SECTION
#define DEFINE_OPT_SHOW_SECTION(section, target_section_id)
Definition: ffprobe.c:3782
AVInputFormat::flags
int flags
Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, AVFMT_NOTIMESTAMPS,...
Definition: avformat.h:669
AVRational::den
int den
Denominator.
Definition: rational.h:60
PRINT_STRING_VALIDATE
#define PRINT_STRING_VALIDATE
Definition: ffprobe.c:754
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:224
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:196
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:180
print_str_validate
#define print_str_validate(k, v)
Definition: ffprobe.c:1834
AVFrameSideData::type
enum AVFrameSideDataType type
Definition: frame.h:224
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:238
hdr_dynamic_metadata.h
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:1382
AVStream::r_frame_rate
AVRational r_frame_rate
Real base framerate of the stream.
Definition: avformat.h:1084
print_dynamic_hdr10_plus
static void print_dynamic_hdr10_plus(WriterContext *w, const AVDynamicHDRPlus *metadata)
Definition: ffprobe.c:2022
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:269
do_show_pixel_formats
static int do_show_pixel_formats
Definition: ffprobe.c:103
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:565
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:118
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:1824
AVFormatContext::duration
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1302
AVPacket::stream_index
int stream_index
Definition: packet.h:375
FlatContext::sep_str
const char * sep_str
Definition: ffprobe.c:1252
DEFINE_WRITER_CLASS
#define DEFINE_WRITER_CLASS(name)
Definition: ffprobe.c:927
opt_print_filename
static int opt_print_filename(void *optctx, const char *opt, const char *arg)
Definition: ffprobe.c:3580
AVCodecContext::coded_width
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:571
tc
#define tc
Definition: regdef.h:69
opt_default
int opt_default(void *optctx, const char *opt, const char *arg)
Fallback for options that are not explicitly handled, these will be parsed through AVOptions.
Definition: cmdutils.c:536
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:279
XMLContext
Definition: ffprobe.c:1644
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:111
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
WRITER_STRING_VALIDATION_REPLACE
@ WRITER_STRING_VALIDATION_REPLACE
Definition: ffprobe.c:444
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:346
unit_value::i
long long int i
Definition: ffprobe.c:378
CompactContext::item_sep_str
char * item_sep_str
Definition: ffprobe.c:1090
CompactContext::escape_mode_str
char * escape_mode_str
Definition: ffprobe.c:1094
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:213
AVCodecParameters::video_delay
int video_delay
Video only.
Definition: codec_par.h:155
FlatContext::sep
char sep
Definition: ffprobe.c:1253
AV_FIELD_PROGRESSIVE
@ AV_FIELD_PROGRESSIVE
Definition: codec_par.h:38
JSONContext::item_start_end
const char * item_start_end
Definition: ffprobe.c:1482
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:223
AVCodecParameters::format
int format
Definition: codec_par.h:84
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:279
ffprobe_cleanup
static void ffprobe_cleanup(int ret)
Definition: ffprobe.c:366
SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST
@ SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST
Definition: ffprobe.c:176
WRITER_STRING_VALIDATION_FAIL
@ WRITER_STRING_VALIDATION_FAIL
Definition: ffprobe.c:443
OPT_VIDEO
#define OPT_VIDEO
Definition: cmdutils.h:170
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVDictionaryEntry
Definition: dict.h:79
compact_options
static const AVOption compact_options[]
Definition: ffprobe.c:1104
CompactContext::has_nested_elems
int has_nested_elems[SECTION_MAX_NB_LEVELS]
Definition: ffprobe.c:1097
default_print_section_header
static void default_print_section_header(WriterContext *wctx)
Definition: ffprobe.c:970
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
DEFAULT
#define DEFAULT
Definition: avdct.c:28
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:410
AVPacket
This structure stores compressed data.
Definition: packet.h:350
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:241
WriterContext::nb_sections
int nb_sections
number of sections
Definition: ffprobe.c:474
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
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:70
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:217
cmdutils.h
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:393
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
av_frame_side_data_name
const char * av_frame_side_data_name(enum AVFrameSideDataType type)
Definition: frame.c:705
AVCodecParameters::channel_layout
uint64_t channel_layout
Audio only.
Definition: codec_par.h:162
SHOW_LIB_VERSION
#define SHOW_LIB_VERSION(libname, LIBNAME)
Definition: ffprobe.c:3360
OPT_BOOL
#define OPT_BOOL
Definition: cmdutils.h:167
writer_print_rational
static void writer_print_rational(WriterContext *wctx, const char *key, AVRational q, char sep)
Definition: ffprobe.c:794
d
d
Definition: ffmpeg_filter.c:153
XMLContext::indent_level
int indent_level
Definition: ffprobe.c:1647
int32_t
int32_t
Definition: audioconvert.c:56
convert_header.str
string str
Definition: convert_header.py:20
AVDOVINLQParams::nlq_offset
uint16_t nlq_offset
Definition: dovi_meta.h:127
timestamp.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVFrameSideData::metadata
AVDictionary * metadata
Definition: frame.h:227
AVCodecParameters::bit_rate
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:89
av_opt_get
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
Definition: opt.c:782
AVDOVIDataMapping::vdr_rpu_id
uint8_t vdr_rpu_id
Definition: dovi_meta.h:140
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVFormatContext::start_time
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1292
writer_print_section_footer
static void writer_print_section_footer(WriterContext *wctx)
Definition: ffprobe.c:670
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:1099
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:180
SECTION_ID_PROGRAM_STREAMS
@ SECTION_ID_PROGRAM_STREAMS
Definition: ffprobe.c:200
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:57
do_show_data
static int do_show_data
Definition: ffprobe.c:100
AVDOVIRpuDataHeader::disable_residual_flag
uint8_t disable_residual_flag
Definition: dovi_meta.h:91
flat_print_section_header
static void flat_print_section_header(WriterContext *wctx)
Definition: ffprobe.c:1317
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
LogBuffer::parent_category
AVClassCategory parent_category
Definition: ffprobe.c:311
AV_PKT_DATA_WEBVTT_IDENTIFIER
@ AV_PKT_DATA_WEBVTT_IDENTIFIER
The optional first identifier line of a WebVTT cue.
Definition: packet.h:196
SECTION_ID_PROGRAM_STREAM_DISPOSITION
@ SECTION_ID_PROGRAM_STREAM_DISPOSITION
Definition: ffprobe.c:197
avcodec_descriptor_get
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3521
AVStereo3D
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
Definition: stereo3d.h:176
AVDictionaryEntry::value
char * value
Definition: dict.h:81
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:975
show_data_hash
static char * show_data_hash
Definition: ffprobe.c:128
avstring.h
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:228
print_primaries
static void print_primaries(WriterContext *w, enum AVColorPrimaries color_primaries)
Definition: ffprobe.c:2243
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:169
do_show_streams
static int do_show_streams
Definition: ffprobe.c:98
unit_value::d
double d
Definition: ffprobe.c:378
InputFile::nb_streams
int nb_streams
Definition: ffmpeg.h:414
AVColorRange
AVColorRange
Visual content value range.
Definition: pixfmt.h:562
AVChapter::time_base
AVRational time_base
time base in which the start/end timestamps are specified
Definition: avformat.h:1161
int
int
Definition: ffmpeg_filter.c:153
AVDOVIDataMapping::nlq
AVDOVINLQParams nlq[3]
Definition: dovi_meta.h:149
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
snprintf
#define snprintf
Definition: snprintf.h:34
stream_specifier
static char * stream_specifier
Definition: ffprobe.c:127
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:872
log_callback
static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
Definition: ffprobe.c:317
AVDOVIDataMapping
Dolby Vision RPU data mapping parameters.
Definition: dovi_meta.h:139
SECTION_ID_CHAPTERS
@ SECTION_ID_CHAPTERS
Definition: ffprobe.c:167
color_primaries
static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
Definition: vf_colorspace.c:211
print_time
#define print_time(k, v, tb)
Definition: ffprobe.c:1835
default_print_str
static void default_print_str(WriterContext *wctx, const char *key, const char *value)
Definition: ffprobe.c:1008
AVSphericalMapping
This structure describes how to handle spherical videos, outlining information about projection,...
Definition: spherical.h:82
av_color_transfer_name
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition: pixdesc.c:3027
print_str_opt
#define print_str_opt(k, v)
Definition: ffprobe.c:1833
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:486
CompactContext::terminate_line
int terminate_line[SECTION_MAX_NB_LEVELS]
Definition: ffprobe.c:1098
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:139
default_print_section_footer
static void default_print_section_footer(WriterContext *wctx)
Definition: ffprobe.c:995
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:194
INIContext::hierarchical
int hierarchical
Definition: ffprobe.c:1376
AVSphericalMapping::yaw
int32_t yaw
Rotation around the up vector [-180, 180].
Definition: spherical.h:126
SECTION_ID_PACKET
@ SECTION_ID_PACKET
Definition: ffprobe.c:186
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:70
JSONContext::compact
int compact
Definition: ffprobe.c:1481
unit_second_str
static const char unit_second_str[]
Definition: ffprobe.c:292
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:308
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
dec_ctx
static AVCodecContext * dec_ctx
Definition: filtering_audio.c:44
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:385
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:34
writer_class
static const AVClass writer_class
Definition: ffprobe.c:524
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:2580
do_show_packets
static int do_show_packets
Definition: ffprobe.c:96
show_programs
static int show_programs(WriterContext *w, InputFile *ifile)
Definition: ffprobe.c:3037
JSONContext
Definition: ffprobe.c:1478
av_fourcc2str
#define av_fourcc2str(fourcc)
Definition: avutil.h:348
pthread_mutex_lock
#define pthread_mutex_lock(a)
Definition: ffprobe.c:64
bprint_bytes
static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
Definition: ffprobe.c:550
avdevice_register_all
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
Definition: alldevices.c:64
Writer::print_section_header
void(* print_section_header)(WriterContext *wctx)
Definition: ffprobe.c:457
AVDOVIDecoderConfigurationRecord
Definition: dovi_meta.h:52
writer_register
static int writer_register(const Writer *writer)
Definition: ffprobe.c:902