• Home
  • Raw
  • Download

Lines Matching refs:wctx

440     int  (*init)  (WriterContext *wctx);
441 void (*uninit)(WriterContext *wctx);
443 void (*print_section_header)(WriterContext *wctx);
444 void (*print_section_footer)(WriterContext *wctx);
445 void (*print_integer) (WriterContext *wctx, const char *, long long int);
446 void (*print_rational) (WriterContext *wctx, AVRational *q, char *sep);
447 void (*print_string) (WriterContext *wctx, const char *, const char *);
483 WriterContext *wctx = p; in writer_get_name() local
484 return wctx->writer->name; in writer_get_name()
518 static void writer_close(WriterContext **wctx) in writer_close() argument
522 if (!*wctx) in writer_close()
525 if ((*wctx)->writer->uninit) in writer_close()
526 (*wctx)->writer->uninit(*wctx); in writer_close()
528 av_bprint_finalize(&(*wctx)->section_pbuf[i], NULL); in writer_close()
529 if ((*wctx)->writer->priv_class) in writer_close()
530 av_opt_free((*wctx)->priv); in writer_close()
531 av_freep(&((*wctx)->priv)); in writer_close()
532 av_opt_free(*wctx); in writer_close()
533 av_freep(wctx); in writer_close()
545 static int writer_open(WriterContext **wctx, const Writer *writer, const char *args, in writer_open() argument
550 if (!(*wctx = av_mallocz(sizeof(WriterContext)))) { in writer_open()
555 if (!((*wctx)->priv = av_mallocz(writer->priv_size))) { in writer_open()
560 (*wctx)->class = &writer_class; in writer_open()
561 (*wctx)->writer = writer; in writer_open()
562 (*wctx)->level = -1; in writer_open()
563 (*wctx)->sections = sections; in writer_open()
564 (*wctx)->nb_sections = nb_sections; in writer_open()
566 av_opt_set_defaults(*wctx); in writer_open()
569 void *priv_ctx = (*wctx)->priv; in writer_open()
580 …av_log(*wctx, AV_LOG_ERROR, "Failed to parse option string '%s' provided to writer context\n", arg… in writer_open()
586 if ((ret = av_opt_set(*wctx, opt->key, opt->value, AV_OPT_SEARCH_CHILDREN)) < 0) { in writer_open()
587 …av_log(*wctx, AV_LOG_ERROR, "Failed to set option '%s' with value '%s' provided to writer context\… in writer_open()
599 const uint8_t *p = (*wctx)->string_validation_replacement; in writer_open()
604 ret = av_utf8_decode(&code, &p, endp, (*wctx)->string_validation_utf8_flags); in writer_open()
609 av_log(wctx, AV_LOG_ERROR, in writer_open()
611 bp.str, (*wctx)->string_validation_replacement); in writer_open()
618 av_bprint_init(&(*wctx)->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED); in writer_open()
620 if ((*wctx)->writer->init) in writer_open()
621 ret = (*wctx)->writer->init(*wctx); in writer_open()
628 writer_close(wctx); in writer_open()
632 static inline void writer_print_section_header(WriterContext *wctx, in writer_print_section_header() argument
636 wctx->level++; in writer_print_section_header()
637 av_assert0(wctx->level < SECTION_MAX_NB_LEVELS); in writer_print_section_header()
638 parent_section_id = wctx->level ? in writer_print_section_header()
639 (wctx->section[wctx->level-1])->id : SECTION_ID_NONE; in writer_print_section_header()
641 wctx->nb_item[wctx->level] = 0; in writer_print_section_header()
642 wctx->section[wctx->level] = &wctx->sections[section_id]; in writer_print_section_header()
645 wctx->nb_section_packet = wctx->nb_section_frame = in writer_print_section_header()
646 wctx->nb_section_packet_frame = 0; in writer_print_section_header()
648 wctx->nb_section_packet_frame = section_id == SECTION_ID_PACKET ? in writer_print_section_header()
649 wctx->nb_section_packet : wctx->nb_section_frame; in writer_print_section_header()
652 if (wctx->writer->print_section_header) in writer_print_section_header()
653 wctx->writer->print_section_header(wctx); in writer_print_section_header()
656 static inline void writer_print_section_footer(WriterContext *wctx) in writer_print_section_footer() argument
658 int section_id = wctx->section[wctx->level]->id; in writer_print_section_footer()
659 int parent_section_id = wctx->level ? in writer_print_section_footer()
660 wctx->section[wctx->level-1]->id : SECTION_ID_NONE; in writer_print_section_footer()
663 wctx->nb_item[wctx->level-1]++; in writer_print_section_footer()
665 if (section_id == SECTION_ID_PACKET) wctx->nb_section_packet++; in writer_print_section_footer()
666 else wctx->nb_section_frame++; in writer_print_section_footer()
668 if (wctx->writer->print_section_footer) in writer_print_section_footer()
669 wctx->writer->print_section_footer(wctx); in writer_print_section_footer()
670 wctx->level--; in writer_print_section_footer()
673 static inline void writer_print_integer(WriterContext *wctx, in writer_print_integer() argument
676 const struct section *section = wctx->section[wctx->level]; in writer_print_integer()
679 wctx->writer->print_integer(wctx, key, val); in writer_print_integer()
680 wctx->nb_item[wctx->level]++; in writer_print_integer()
684 static inline int validate_string(WriterContext *wctx, char **dstp, const char *src) in validate_string() argument
698 if (av_utf8_decode(&code, &p, endp, wctx->string_validation_utf8_flags) < 0) { in validate_string()
702 av_log(wctx, AV_LOG_DEBUG, in validate_string()
710 switch (wctx->string_validation) { in validate_string()
712 av_log(wctx, AV_LOG_ERROR, in validate_string()
719 av_bprintf(&dstbuf, "%s", wctx->string_validation_replacement); in validate_string()
724 if (!invalid || wctx->string_validation == WRITER_STRING_VALIDATION_IGNORE) in validate_string()
728 if (invalid_chars_nb && wctx->string_validation == WRITER_STRING_VALIDATION_REPLACE) { in validate_string()
729 av_log(wctx, AV_LOG_WARNING, in validate_string()
731 invalid_chars_nb, src, wctx->string_validation_replacement); in validate_string()
742 static inline int writer_print_string(WriterContext *wctx, in writer_print_string() argument
745 const struct section *section = wctx->section[wctx->level]; in writer_print_string()
749 && !(wctx->writer->flags & WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS)) in writer_print_string()
755 ret = validate_string(wctx, &key1, key); in writer_print_string()
757 ret = validate_string(wctx, &val1, val); in writer_print_string()
759 wctx->writer->print_string(wctx, key1, val1); in writer_print_string()
762 av_log(wctx, AV_LOG_ERROR, in writer_print_string()
769 wctx->writer->print_string(wctx, key, val); in writer_print_string()
772 wctx->nb_item[wctx->level]++; in writer_print_string()
778 static inline void writer_print_rational(WriterContext *wctx, in writer_print_rational() argument
784 writer_print_string(wctx, key, buf.str, 0); in writer_print_rational()
787 static void writer_print_time(WriterContext *wctx, const char *key, in writer_print_time() argument
793 writer_print_string(wctx, key, "N/A", PRINT_STRING_OPT); in writer_print_time()
800 writer_print_string(wctx, key, buf, 0); in writer_print_time()
804 static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, int is_duration) in writer_print_ts() argument
807 writer_print_string(wctx, key, "N/A", PRINT_STRING_OPT); in writer_print_ts()
809 writer_print_integer(wctx, key, ts); in writer_print_ts()
813 static void writer_print_data(WriterContext *wctx, const char *name, in writer_print_data() argument
837 writer_print_string(wctx, name, bp.str, 0); in writer_print_data()
841 static void writer_print_data_hash(WriterContext *wctx, const char *name, in writer_print_data_hash() argument
853 writer_print_string(wctx, name, buf, 0); in writer_print_data_hash()
856 static void writer_print_integers(WriterContext *wctx, const char *name, in writer_print_integers() argument
878 writer_print_string(wctx, name, bp.str, 0); in writer_print_integers()
954 static void default_print_section_header(WriterContext *wctx) in default_print_section_header() argument
956 DefaultContext *def = wctx->priv; in default_print_section_header()
958 const struct section *section = wctx->section[wctx->level]; in default_print_section_header()
959 const struct section *parent_section = wctx->level ? in default_print_section_header()
960 wctx->section[wctx->level-1] : NULL; in default_print_section_header()
962 av_bprint_clear(&wctx->section_pbuf[wctx->level]); in default_print_section_header()
965 def->nested_section[wctx->level] = 1; in default_print_section_header()
966 av_bprintf(&wctx->section_pbuf[wctx->level], "%s%s:", in default_print_section_header()
967 wctx->section_pbuf[wctx->level-1].str, in default_print_section_header()
972 if (def->noprint_wrappers || def->nested_section[wctx->level]) in default_print_section_header()
979 static void default_print_section_footer(WriterContext *wctx) in default_print_section_footer() argument
981 DefaultContext *def = wctx->priv; in default_print_section_footer()
982 const struct section *section = wctx->section[wctx->level]; in default_print_section_footer()
985 if (def->noprint_wrappers || def->nested_section[wctx->level]) in default_print_section_footer()
992 static void default_print_str(WriterContext *wctx, const char *key, const char *value) in default_print_str() argument
994 DefaultContext *def = wctx->priv; in default_print_str()
997 printf("%s%s=", wctx->section_pbuf[wctx->level].str, key); in default_print_str()
1001 static void default_print_int(WriterContext *wctx, const char *key, long long int value) in default_print_int() argument
1003 DefaultContext *def = wctx->priv; in default_print_int()
1006 printf("%s%s=", wctx->section_pbuf[wctx->level].str, key); in default_print_int()
1102 static av_cold int compact_init(WriterContext *wctx) in compact_init() argument
1104 CompactContext *compact = wctx->priv; in compact_init()
1107 … av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n", in compact_init()
1117 av_log(wctx, AV_LOG_ERROR, "Unknown escape mode '%s'\n", compact->escape_mode_str); in compact_init()
1124 static void compact_print_section_header(WriterContext *wctx) in compact_print_section_header() argument
1126 CompactContext *compact = wctx->priv; in compact_print_section_header()
1127 const struct section *section = wctx->section[wctx->level]; in compact_print_section_header()
1128 const struct section *parent_section = wctx->level ? in compact_print_section_header()
1129 wctx->section[wctx->level-1] : NULL; in compact_print_section_header()
1130 compact->terminate_line[wctx->level] = 1; in compact_print_section_header()
1131 compact->has_nested_elems[wctx->level] = 0; in compact_print_section_header()
1133 av_bprint_clear(&wctx->section_pbuf[wctx->level]); in compact_print_section_header()
1136 compact->nested_section[wctx->level] = 1; in compact_print_section_header()
1137 compact->has_nested_elems[wctx->level-1] = 1; in compact_print_section_header()
1138 av_bprintf(&wctx->section_pbuf[wctx->level], "%s%s:", in compact_print_section_header()
1139 wctx->section_pbuf[wctx->level-1].str, in compact_print_section_header()
1141 wctx->nb_item[wctx->level] = wctx->nb_item[wctx->level-1]; in compact_print_section_header()
1143 if (parent_section && compact->has_nested_elems[wctx->level-1] && in compact_print_section_header()
1145 compact->terminate_line[wctx->level-1] = 0; in compact_print_section_header()
1154 static void compact_print_section_footer(WriterContext *wctx) in compact_print_section_footer() argument
1156 CompactContext *compact = wctx->priv; in compact_print_section_footer()
1158 if (!compact->nested_section[wctx->level] && in compact_print_section_footer()
1159 compact->terminate_line[wctx->level] && in compact_print_section_footer()
1160 !(wctx->section[wctx->level]->flags & (SECTION_FLAG_IS_WRAPPER|SECTION_FLAG_IS_ARRAY))) in compact_print_section_footer()
1164 static void compact_print_str(WriterContext *wctx, const char *key, const char *value) in compact_print_str() argument
1166 CompactContext *compact = wctx->priv; in compact_print_str()
1169 if (wctx->nb_item[wctx->level]) printf("%c", compact->item_sep); in compact_print_str()
1171 printf("%s%s=", wctx->section_pbuf[wctx->level].str, key); in compact_print_str()
1173 printf("%s", compact->escape_str(&buf, value, compact->item_sep, wctx)); in compact_print_str()
1177 static void compact_print_int(WriterContext *wctx, const char *key, long long int value) in compact_print_int() argument
1179 CompactContext *compact = wctx->priv; in compact_print_int()
1181 if (wctx->nb_item[wctx->level]) printf("%c", compact->item_sep); in compact_print_int()
1183 printf("%s%s=", wctx->section_pbuf[wctx->level].str, key); in compact_print_int()
1252 static av_cold int flat_init(WriterContext *wctx) in flat_init() argument
1254 FlatContext *flat = wctx->priv; in flat_init()
1257 … av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n", in flat_init()
1299 static void flat_print_section_header(WriterContext *wctx) in flat_print_section_header() argument
1301 FlatContext *flat = wctx->priv; in flat_print_section_header()
1302 AVBPrint *buf = &wctx->section_pbuf[wctx->level]; in flat_print_section_header()
1303 const struct section *section = wctx->section[wctx->level]; in flat_print_section_header()
1304 const struct section *parent_section = wctx->level ? in flat_print_section_header()
1305 wctx->section[wctx->level-1] : NULL; in flat_print_section_header()
1311 av_bprintf(buf, "%s", wctx->section_pbuf[wctx->level-1].str); in flat_print_section_header()
1315 av_bprintf(buf, "%s%s", wctx->section[wctx->level]->name, flat->sep_str); in flat_print_section_header()
1319 wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1]; in flat_print_section_header()
1325 static void flat_print_int(WriterContext *wctx, const char *key, long long int value) in flat_print_int() argument
1327 printf("%s%s=%lld\n", wctx->section_pbuf[wctx->level].str, key, value); in flat_print_int()
1330 static void flat_print_str(WriterContext *wctx, const char *key, const char *value) in flat_print_str() argument
1332 FlatContext *flat = wctx->priv; in flat_print_str()
1335 printf("%s", wctx->section_pbuf[wctx->level].str); in flat_print_str()
1399 static void ini_print_section_header(WriterContext *wctx) in ini_print_section_header() argument
1401 INIContext *ini = wctx->priv; in ini_print_section_header()
1402 AVBPrint *buf = &wctx->section_pbuf[wctx->level]; in ini_print_section_header()
1403 const struct section *section = wctx->section[wctx->level]; in ini_print_section_header()
1404 const struct section *parent_section = wctx->level ? in ini_print_section_header()
1405 wctx->section[wctx->level-1] : NULL; in ini_print_section_header()
1413 if (wctx->nb_item[wctx->level-1]) in ini_print_section_header()
1416 av_bprintf(buf, "%s", wctx->section_pbuf[wctx->level-1].str); in ini_print_section_header()
1419 av_bprintf(buf, "%s%s", buf->str[0] ? "." : "", wctx->section[wctx->level]->name); in ini_print_section_header()
1423 wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1]; in ini_print_section_header()
1432 static void ini_print_str(WriterContext *wctx, const char *key, const char *value) in ini_print_str() argument
1443 static void ini_print_int(WriterContext *wctx, const char *key, long long int value) in ini_print_int() argument
1478 static av_cold int json_init(WriterContext *wctx) in json_init() argument
1480 JSONContext *json = wctx->priv; in json_init()
1510 static void json_print_section_header(WriterContext *wctx) in json_print_section_header() argument
1512 JSONContext *json = wctx->priv; in json_print_section_header()
1514 const struct section *section = wctx->section[wctx->level]; in json_print_section_header()
1515 const struct section *parent_section = wctx->level ? in json_print_section_header()
1516 wctx->section[wctx->level-1] : NULL; in json_print_section_header()
1518 if (wctx->level && wctx->nb_item[wctx->level-1]) in json_print_section_header()
1526 json_escape_str(&buf, section->name, wctx); in json_print_section_header()
1548 static void json_print_section_footer(WriterContext *wctx) in json_print_section_footer() argument
1550 JSONContext *json = wctx->priv; in json_print_section_footer()
1551 const struct section *section = wctx->section[wctx->level]; in json_print_section_footer()
1553 if (wctx->level == 0) { in json_print_section_footer()
1570 static inline void json_print_item_str(WriterContext *wctx, in json_print_item_str() argument
1576 printf("\"%s\":", json_escape_str(&buf, key, wctx)); in json_print_item_str()
1578 printf(" \"%s\"", json_escape_str(&buf, value, wctx)); in json_print_item_str()
1582 static void json_print_str(WriterContext *wctx, const char *key, const char *value) in json_print_str() argument
1584 JSONContext *json = wctx->priv; in json_print_str()
1585 const struct section *parent_section = wctx->level ? in json_print_str()
1586 wctx->section[wctx->level-1] : NULL; in json_print_str()
1588 …if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_… in json_print_str()
1592 json_print_item_str(wctx, key, value); in json_print_str()
1595 static void json_print_int(WriterContext *wctx, const char *key, long long int value) in json_print_int() argument
1597 JSONContext *json = wctx->priv; in json_print_int()
1598 const struct section *parent_section = wctx->level ? in json_print_int()
1599 wctx->section[wctx->level-1] : NULL; in json_print_int()
1602 …if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_… in json_print_int()
1608 printf("\"%s\": %lld", json_escape_str(&buf, key, wctx), value); in json_print_int()
1647 static av_cold int xml_init(WriterContext *wctx) in xml_init() argument
1649 XMLContext *xml = wctx->priv; in xml_init()
1655 av_log(wctx, AV_LOG_ERROR, \ in xml_init()
1665 av_log(wctx, AV_LOG_ERROR, in xml_init()
1677 static void xml_print_section_header(WriterContext *wctx) in xml_print_section_header() argument
1679 XMLContext *xml = wctx->priv; in xml_print_section_header()
1680 const struct section *section = wctx->section[wctx->level]; in xml_print_section_header()
1681 const struct section *parent_section = wctx->level ? in xml_print_section_header()
1682 wctx->section[wctx->level-1] : NULL; in xml_print_section_header()
1684 if (wctx->level == 0) { in xml_print_section_header()
1704 wctx->level && wctx->nb_item[wctx->level-1]) in xml_print_section_header()
1717 static void xml_print_section_footer(WriterContext *wctx) in xml_print_section_footer() argument
1719 XMLContext *xml = wctx->priv; in xml_print_section_footer()
1720 const struct section *section = wctx->section[wctx->level]; in xml_print_section_footer()
1722 if (wctx->level == 0) { in xml_print_section_footer()
1736 static void xml_print_str(WriterContext *wctx, const char *key, const char *value) in xml_print_str() argument
1739 XMLContext *xml = wctx->priv; in xml_print_str()
1740 const struct section *section = wctx->section[wctx->level]; in xml_print_str()
1756 if (wctx->nb_item[wctx->level]) in xml_print_str()
1767 static void xml_print_int(WriterContext *wctx, const char *key, long long int value) in xml_print_int() argument
1769 if (wctx->nb_item[wctx->level]) in xml_print_int()
3065 static int probe_file(WriterContext *wctx, const char *filename, in probe_file() argument
3104 wctx->writer->flags & WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER) in probe_file()
3111 writer_print_section_header(wctx, section_id); in probe_file()
3112 ret = read_packets(wctx, &ifile); in probe_file()
3114 writer_print_section_footer(wctx); in probe_file()
3119 ret = show_programs(wctx, &ifile); in probe_file()
3124 ret = show_streams(wctx, &ifile); in probe_file()
3128 ret = show_chapters(wctx, &ifile); in probe_file()
3132 ret = show_format(wctx, &ifile); in probe_file()
3668 WriterContext *wctx; in main() local
3769 if ((ret = writer_open(&wctx, w, w_args, in main()
3772 wctx->string_validation_utf8_flags |= AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES; in main()
3774 writer_print_section_header(wctx, SECTION_ID_ROOT); in main()
3777 ffprobe_show_program_version(wctx); in main()
3779 ffprobe_show_library_versions(wctx); in main()
3781 ffprobe_show_pixel_formats(wctx); in main()
3791 ret = probe_file(wctx, input_filename, print_input_filename); in main()
3793 show_error(wctx, ret); in main()
3796 writer_print_section_footer(wctx); in main()
3797 writer_close(&wctx); in main()