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