Lines Matching refs:wctx
439 int (*init) (WriterContext *wctx);
440 void (*uninit)(WriterContext *wctx);
442 void (*print_section_header)(WriterContext *wctx);
443 void (*print_section_footer)(WriterContext *wctx);
444 void (*print_integer) (WriterContext *wctx, const char *, long long int);
445 void (*print_rational) (WriterContext *wctx, AVRational *q, char *sep);
446 void (*print_string) (WriterContext *wctx, const char *, const char *);
482 WriterContext *wctx = p; in writer_get_name() local
483 return wctx->writer->name; in writer_get_name()
517 static void writer_close(WriterContext **wctx) in writer_close() argument
521 if (!*wctx) in writer_close()
524 if ((*wctx)->writer->uninit) in writer_close()
525 (*wctx)->writer->uninit(*wctx); in writer_close()
527 av_bprint_finalize(&(*wctx)->section_pbuf[i], NULL); in writer_close()
528 if ((*wctx)->writer->priv_class) in writer_close()
529 av_opt_free((*wctx)->priv); in writer_close()
530 av_freep(&((*wctx)->priv)); in writer_close()
531 av_opt_free(*wctx); in writer_close()
532 av_freep(wctx); in writer_close()
544 static int writer_open(WriterContext **wctx, const Writer *writer, const char *args, in writer_open() argument
549 if (!(*wctx = av_mallocz(sizeof(WriterContext)))) { in writer_open()
554 if (!((*wctx)->priv = av_mallocz(writer->priv_size))) { in writer_open()
559 (*wctx)->class = &writer_class; in writer_open()
560 (*wctx)->writer = writer; in writer_open()
561 (*wctx)->level = -1; in writer_open()
562 (*wctx)->sections = sections; in writer_open()
563 (*wctx)->nb_sections = nb_sections; in writer_open()
565 av_opt_set_defaults(*wctx); in writer_open()
568 void *priv_ctx = (*wctx)->priv; in writer_open()
579 …av_log(*wctx, AV_LOG_ERROR, "Failed to parse option string '%s' provided to writer context\n", arg… in writer_open()
585 if ((ret = av_opt_set(*wctx, opt->key, opt->value, AV_OPT_SEARCH_CHILDREN)) < 0) { in writer_open()
586 …av_log(*wctx, AV_LOG_ERROR, "Failed to set option '%s' with value '%s' provided to writer context\… in writer_open()
598 const uint8_t *p = (*wctx)->string_validation_replacement; in writer_open()
603 ret = av_utf8_decode(&code, &p, endp, (*wctx)->string_validation_utf8_flags); in writer_open()
608 av_log(wctx, AV_LOG_ERROR, in writer_open()
610 bp.str, (*wctx)->string_validation_replacement); in writer_open()
617 av_bprint_init(&(*wctx)->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED); in writer_open()
619 if ((*wctx)->writer->init) in writer_open()
620 ret = (*wctx)->writer->init(*wctx); in writer_open()
627 writer_close(wctx); in writer_open()
631 static inline void writer_print_section_header(WriterContext *wctx, in writer_print_section_header() argument
635 wctx->level++; in writer_print_section_header()
636 av_assert0(wctx->level < SECTION_MAX_NB_LEVELS); in writer_print_section_header()
637 parent_section_id = wctx->level ? in writer_print_section_header()
638 (wctx->section[wctx->level-1])->id : SECTION_ID_NONE; in writer_print_section_header()
640 wctx->nb_item[wctx->level] = 0; in writer_print_section_header()
641 wctx->section[wctx->level] = &wctx->sections[section_id]; in writer_print_section_header()
644 wctx->nb_section_packet = wctx->nb_section_frame = in writer_print_section_header()
645 wctx->nb_section_packet_frame = 0; in writer_print_section_header()
647 wctx->nb_section_packet_frame = section_id == SECTION_ID_PACKET ? in writer_print_section_header()
648 wctx->nb_section_packet : wctx->nb_section_frame; in writer_print_section_header()
651 if (wctx->writer->print_section_header) in writer_print_section_header()
652 wctx->writer->print_section_header(wctx); in writer_print_section_header()
655 static inline void writer_print_section_footer(WriterContext *wctx) in writer_print_section_footer() argument
657 int section_id = wctx->section[wctx->level]->id; in writer_print_section_footer()
658 int parent_section_id = wctx->level ? in writer_print_section_footer()
659 wctx->section[wctx->level-1]->id : SECTION_ID_NONE; in writer_print_section_footer()
662 wctx->nb_item[wctx->level-1]++; in writer_print_section_footer()
664 if (section_id == SECTION_ID_PACKET) wctx->nb_section_packet++; in writer_print_section_footer()
665 else wctx->nb_section_frame++; in writer_print_section_footer()
667 if (wctx->writer->print_section_footer) in writer_print_section_footer()
668 wctx->writer->print_section_footer(wctx); in writer_print_section_footer()
669 wctx->level--; in writer_print_section_footer()
672 static inline void writer_print_integer(WriterContext *wctx, in writer_print_integer() argument
675 const struct section *section = wctx->section[wctx->level]; in writer_print_integer()
678 wctx->writer->print_integer(wctx, key, val); in writer_print_integer()
679 wctx->nb_item[wctx->level]++; in writer_print_integer()
683 static inline int validate_string(WriterContext *wctx, char **dstp, const char *src) in validate_string() argument
697 if (av_utf8_decode(&code, &p, endp, wctx->string_validation_utf8_flags) < 0) { in validate_string()
701 av_log(wctx, AV_LOG_DEBUG, in validate_string()
709 switch (wctx->string_validation) { in validate_string()
711 av_log(wctx, AV_LOG_ERROR, in validate_string()
718 av_bprintf(&dstbuf, "%s", wctx->string_validation_replacement); in validate_string()
723 if (!invalid || wctx->string_validation == WRITER_STRING_VALIDATION_IGNORE) in validate_string()
727 if (invalid_chars_nb && wctx->string_validation == WRITER_STRING_VALIDATION_REPLACE) { in validate_string()
728 av_log(wctx, AV_LOG_WARNING, in validate_string()
730 invalid_chars_nb, src, wctx->string_validation_replacement); in validate_string()
741 static inline int writer_print_string(WriterContext *wctx, in writer_print_string() argument
744 const struct section *section = wctx->section[wctx->level]; in writer_print_string()
748 && !(wctx->writer->flags & WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS)) in writer_print_string()
754 ret = validate_string(wctx, &key1, key); in writer_print_string()
756 ret = validate_string(wctx, &val1, val); in writer_print_string()
758 wctx->writer->print_string(wctx, key1, val1); in writer_print_string()
761 av_log(wctx, AV_LOG_ERROR, in writer_print_string()
768 wctx->writer->print_string(wctx, key, val); in writer_print_string()
771 wctx->nb_item[wctx->level]++; in writer_print_string()
777 static inline void writer_print_rational(WriterContext *wctx, in writer_print_rational() argument
783 writer_print_string(wctx, key, buf.str, 0); in writer_print_rational()
786 static void writer_print_time(WriterContext *wctx, const char *key, in writer_print_time() argument
792 writer_print_string(wctx, key, "N/A", PRINT_STRING_OPT); in writer_print_time()
799 writer_print_string(wctx, key, buf, 0); in writer_print_time()
803 static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, int is_duration) in writer_print_ts() argument
806 writer_print_string(wctx, key, "N/A", PRINT_STRING_OPT); in writer_print_ts()
808 writer_print_integer(wctx, key, ts); in writer_print_ts()
812 static void writer_print_data(WriterContext *wctx, const char *name, in writer_print_data() argument
836 writer_print_string(wctx, name, bp.str, 0); in writer_print_data()
840 static void writer_print_data_hash(WriterContext *wctx, const char *name, in writer_print_data_hash() argument
852 writer_print_string(wctx, name, buf, 0); in writer_print_data_hash()
855 static void writer_print_integers(WriterContext *wctx, const char *name, in writer_print_integers() argument
877 writer_print_string(wctx, name, bp.str, 0); in writer_print_integers()
953 static void default_print_section_header(WriterContext *wctx) in default_print_section_header() argument
955 DefaultContext *def = wctx->priv; in default_print_section_header()
957 const struct section *section = wctx->section[wctx->level]; in default_print_section_header()
958 const struct section *parent_section = wctx->level ? in default_print_section_header()
959 wctx->section[wctx->level-1] : NULL; in default_print_section_header()
961 av_bprint_clear(&wctx->section_pbuf[wctx->level]); in default_print_section_header()
964 def->nested_section[wctx->level] = 1; in default_print_section_header()
965 av_bprintf(&wctx->section_pbuf[wctx->level], "%s%s:", in default_print_section_header()
966 wctx->section_pbuf[wctx->level-1].str, in default_print_section_header()
971 if (def->noprint_wrappers || def->nested_section[wctx->level]) in default_print_section_header()
978 static void default_print_section_footer(WriterContext *wctx) in default_print_section_footer() argument
980 DefaultContext *def = wctx->priv; in default_print_section_footer()
981 const struct section *section = wctx->section[wctx->level]; in default_print_section_footer()
984 if (def->noprint_wrappers || def->nested_section[wctx->level]) in default_print_section_footer()
991 static void default_print_str(WriterContext *wctx, const char *key, const char *value) in default_print_str() argument
993 DefaultContext *def = wctx->priv; in default_print_str()
996 printf("%s%s=", wctx->section_pbuf[wctx->level].str, key); in default_print_str()
1000 static void default_print_int(WriterContext *wctx, const char *key, long long int value) in default_print_int() argument
1002 DefaultContext *def = wctx->priv; in default_print_int()
1005 printf("%s%s=", wctx->section_pbuf[wctx->level].str, key); in default_print_int()
1101 static av_cold int compact_init(WriterContext *wctx) in compact_init() argument
1103 CompactContext *compact = wctx->priv; in compact_init()
1106 … av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n", in compact_init()
1116 av_log(wctx, AV_LOG_ERROR, "Unknown escape mode '%s'\n", compact->escape_mode_str); in compact_init()
1123 static void compact_print_section_header(WriterContext *wctx) in compact_print_section_header() argument
1125 CompactContext *compact = wctx->priv; in compact_print_section_header()
1126 const struct section *section = wctx->section[wctx->level]; in compact_print_section_header()
1127 const struct section *parent_section = wctx->level ? in compact_print_section_header()
1128 wctx->section[wctx->level-1] : NULL; in compact_print_section_header()
1129 compact->terminate_line[wctx->level] = 1; in compact_print_section_header()
1130 compact->has_nested_elems[wctx->level] = 0; in compact_print_section_header()
1132 av_bprint_clear(&wctx->section_pbuf[wctx->level]); in compact_print_section_header()
1135 compact->nested_section[wctx->level] = 1; in compact_print_section_header()
1136 compact->has_nested_elems[wctx->level-1] = 1; in compact_print_section_header()
1137 av_bprintf(&wctx->section_pbuf[wctx->level], "%s%s:", in compact_print_section_header()
1138 wctx->section_pbuf[wctx->level-1].str, in compact_print_section_header()
1140 wctx->nb_item[wctx->level] = wctx->nb_item[wctx->level-1]; in compact_print_section_header()
1142 if (parent_section && compact->has_nested_elems[wctx->level-1] && in compact_print_section_header()
1144 compact->terminate_line[wctx->level-1] = 0; in compact_print_section_header()
1153 static void compact_print_section_footer(WriterContext *wctx) in compact_print_section_footer() argument
1155 CompactContext *compact = wctx->priv; in compact_print_section_footer()
1157 if (!compact->nested_section[wctx->level] && in compact_print_section_footer()
1158 compact->terminate_line[wctx->level] && in compact_print_section_footer()
1159 !(wctx->section[wctx->level]->flags & (SECTION_FLAG_IS_WRAPPER|SECTION_FLAG_IS_ARRAY))) in compact_print_section_footer()
1163 static void compact_print_str(WriterContext *wctx, const char *key, const char *value) in compact_print_str() argument
1165 CompactContext *compact = wctx->priv; in compact_print_str()
1168 if (wctx->nb_item[wctx->level]) printf("%c", compact->item_sep); in compact_print_str()
1170 printf("%s%s=", wctx->section_pbuf[wctx->level].str, key); in compact_print_str()
1172 printf("%s", compact->escape_str(&buf, value, compact->item_sep, wctx)); in compact_print_str()
1176 static void compact_print_int(WriterContext *wctx, const char *key, long long int value) in compact_print_int() argument
1178 CompactContext *compact = wctx->priv; in compact_print_int()
1180 if (wctx->nb_item[wctx->level]) printf("%c", compact->item_sep); in compact_print_int()
1182 printf("%s%s=", wctx->section_pbuf[wctx->level].str, key); in compact_print_int()
1251 static av_cold int flat_init(WriterContext *wctx) in flat_init() argument
1253 FlatContext *flat = wctx->priv; in flat_init()
1256 … av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n", in flat_init()
1298 static void flat_print_section_header(WriterContext *wctx) in flat_print_section_header() argument
1300 FlatContext *flat = wctx->priv; in flat_print_section_header()
1301 AVBPrint *buf = &wctx->section_pbuf[wctx->level]; in flat_print_section_header()
1302 const struct section *section = wctx->section[wctx->level]; in flat_print_section_header()
1303 const struct section *parent_section = wctx->level ? in flat_print_section_header()
1304 wctx->section[wctx->level-1] : NULL; in flat_print_section_header()
1310 av_bprintf(buf, "%s", wctx->section_pbuf[wctx->level-1].str); in flat_print_section_header()
1314 av_bprintf(buf, "%s%s", wctx->section[wctx->level]->name, flat->sep_str); in flat_print_section_header()
1318 wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1]; in flat_print_section_header()
1324 static void flat_print_int(WriterContext *wctx, const char *key, long long int value) in flat_print_int() argument
1326 printf("%s%s=%lld\n", wctx->section_pbuf[wctx->level].str, key, value); in flat_print_int()
1329 static void flat_print_str(WriterContext *wctx, const char *key, const char *value) in flat_print_str() argument
1331 FlatContext *flat = wctx->priv; in flat_print_str()
1334 printf("%s", wctx->section_pbuf[wctx->level].str); in flat_print_str()
1398 static void ini_print_section_header(WriterContext *wctx) in ini_print_section_header() argument
1400 INIContext *ini = wctx->priv; in ini_print_section_header()
1401 AVBPrint *buf = &wctx->section_pbuf[wctx->level]; in ini_print_section_header()
1402 const struct section *section = wctx->section[wctx->level]; in ini_print_section_header()
1403 const struct section *parent_section = wctx->level ? in ini_print_section_header()
1404 wctx->section[wctx->level-1] : NULL; in ini_print_section_header()
1412 if (wctx->nb_item[wctx->level-1]) in ini_print_section_header()
1415 av_bprintf(buf, "%s", wctx->section_pbuf[wctx->level-1].str); in ini_print_section_header()
1418 av_bprintf(buf, "%s%s", buf->str[0] ? "." : "", wctx->section[wctx->level]->name); in ini_print_section_header()
1422 wctx->nb_section_packet_frame : wctx->nb_item[wctx->level-1]; in ini_print_section_header()
1431 static void ini_print_str(WriterContext *wctx, const char *key, const char *value) in ini_print_str() argument
1442 static void ini_print_int(WriterContext *wctx, const char *key, long long int value) in ini_print_int() argument
1477 static av_cold int json_init(WriterContext *wctx) in json_init() argument
1479 JSONContext *json = wctx->priv; in json_init()
1509 static void json_print_section_header(WriterContext *wctx) in json_print_section_header() argument
1511 JSONContext *json = wctx->priv; in json_print_section_header()
1513 const struct section *section = wctx->section[wctx->level]; in json_print_section_header()
1514 const struct section *parent_section = wctx->level ? in json_print_section_header()
1515 wctx->section[wctx->level-1] : NULL; in json_print_section_header()
1517 if (wctx->level && wctx->nb_item[wctx->level-1]) in json_print_section_header()
1525 json_escape_str(&buf, section->name, wctx); in json_print_section_header()
1547 static void json_print_section_footer(WriterContext *wctx) in json_print_section_footer() argument
1549 JSONContext *json = wctx->priv; in json_print_section_footer()
1550 const struct section *section = wctx->section[wctx->level]; in json_print_section_footer()
1552 if (wctx->level == 0) { in json_print_section_footer()
1569 static inline void json_print_item_str(WriterContext *wctx, in json_print_item_str() argument
1575 printf("\"%s\":", json_escape_str(&buf, key, wctx)); in json_print_item_str()
1577 printf(" \"%s\"", json_escape_str(&buf, value, wctx)); in json_print_item_str()
1581 static void json_print_str(WriterContext *wctx, const char *key, const char *value) in json_print_str() argument
1583 JSONContext *json = wctx->priv; in json_print_str()
1584 const struct section *parent_section = wctx->level ? in json_print_str()
1585 wctx->section[wctx->level-1] : NULL; in json_print_str()
1587 …if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_… in json_print_str()
1591 json_print_item_str(wctx, key, value); in json_print_str()
1594 static void json_print_int(WriterContext *wctx, const char *key, long long int value) in json_print_int() argument
1596 JSONContext *json = wctx->priv; in json_print_int()
1597 const struct section *parent_section = wctx->level ? in json_print_int()
1598 wctx->section[wctx->level-1] : NULL; in json_print_int()
1601 …if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_… in json_print_int()
1607 printf("\"%s\": %lld", json_escape_str(&buf, key, wctx), value); in json_print_int()
1646 static av_cold int xml_init(WriterContext *wctx) in xml_init() argument
1648 XMLContext *xml = wctx->priv; in xml_init()
1654 av_log(wctx, AV_LOG_ERROR, \ in xml_init()
1664 av_log(wctx, AV_LOG_ERROR, in xml_init()
1694 static void xml_print_section_header(WriterContext *wctx) in xml_print_section_header() argument
1696 XMLContext *xml = wctx->priv; in xml_print_section_header()
1697 const struct section *section = wctx->section[wctx->level]; in xml_print_section_header()
1698 const struct section *parent_section = wctx->level ? in xml_print_section_header()
1699 wctx->section[wctx->level-1] : NULL; in xml_print_section_header()
1701 if (wctx->level == 0) { in xml_print_section_header()
1721 wctx->level && wctx->nb_item[wctx->level-1]) in xml_print_section_header()
1734 static void xml_print_section_footer(WriterContext *wctx) in xml_print_section_footer() argument
1736 XMLContext *xml = wctx->priv; in xml_print_section_footer()
1737 const struct section *section = wctx->section[wctx->level]; in xml_print_section_footer()
1739 if (wctx->level == 0) { in xml_print_section_footer()
1753 static void xml_print_str(WriterContext *wctx, const char *key, const char *value) in xml_print_str() argument
1756 XMLContext *xml = wctx->priv; in xml_print_str()
1757 const struct section *section = wctx->section[wctx->level]; in xml_print_str()
1764 section->element_name, xml_escape_str(&buf, key, wctx)); in xml_print_str()
1766 printf(" value=\"%s\"/>\n", xml_escape_str(&buf, value, wctx)); in xml_print_str()
1768 if (wctx->nb_item[wctx->level]) in xml_print_str()
1770 printf("%s=\"%s\"", key, xml_escape_str(&buf, value, wctx)); in xml_print_str()
1776 static void xml_print_int(WriterContext *wctx, const char *key, long long int value) in xml_print_int() argument
1778 if (wctx->nb_item[wctx->level]) in xml_print_int()
2993 static int probe_file(WriterContext *wctx, const char *filename, in probe_file() argument
3032 wctx->writer->flags & WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER) in probe_file()
3039 writer_print_section_header(wctx, section_id); in probe_file()
3040 ret = read_packets(wctx, &ifile); in probe_file()
3042 writer_print_section_footer(wctx); in probe_file()
3047 ret = show_programs(wctx, &ifile); in probe_file()
3052 ret = show_streams(wctx, &ifile); in probe_file()
3056 ret = show_chapters(wctx, &ifile); in probe_file()
3060 ret = show_format(wctx, &ifile); in probe_file()
3599 WriterContext *wctx; in main() local
3700 if ((ret = writer_open(&wctx, w, w_args, in main()
3703 wctx->string_validation_utf8_flags |= AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES; in main()
3705 writer_print_section_header(wctx, SECTION_ID_ROOT); in main()
3708 ffprobe_show_program_version(wctx); in main()
3710 ffprobe_show_library_versions(wctx); in main()
3712 ffprobe_show_pixel_formats(wctx); in main()
3722 ret = probe_file(wctx, input_filename, print_input_filename); in main()
3724 show_error(wctx, ret); in main()
3727 writer_print_section_footer(wctx); in main()
3728 writer_close(&wctx); in main()