MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / init_report

Function init_report

fftools/opt_common.c:1148–1231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1146}
1147
1148int init_report(const char *env, FILE **file)
1149{
1150 char *filename_template = NULL;
1151 char *key, *val;
1152 int ret, count = 0;
1153 int prog_loglevel, envlevel = 0;
1154 time_t now;
1155 struct tm *tm;
1156 AVBPrint filename;
1157
1158 if (report_file) /* already opened */
1159 return 0;
1160 time(&now);
1161 tm = localtime(&now);
1162
1163 while (env && *env) {
1164 if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) {
1165 if (count)
1166 av_log(NULL, AV_LOG_ERROR,
1167 "Failed to parse FFREPORT environment variable: %s\n",
1168 av_err2str(ret));
1169 break;
1170 }
1171 if (*env)
1172 env++;
1173 count++;
1174 if (!strcmp(key, "file")) {
1175 av_free(filename_template);
1176 filename_template = val;
1177 val = NULL;
1178 } else if (!strcmp(key, "level")) {
1179 char *tail;
1180 report_file_level = strtol(val, &tail, 10);
1181 if (*tail) {
1182 av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n");
1183 av_free(key);
1184 av_free(val);
1185 av_free(filename_template);
1186 return AVERROR(EINVAL);
1187 }
1188 envlevel = 1;
1189 } else {
1190 av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key);
1191 }
1192 av_free(val);
1193 av_free(key);
1194 }
1195
1196 av_bprint_init(&filename, 0, AV_BPRINT_SIZE_AUTOMATIC);
1197 expand_filename_template(&filename,
1198 av_x_if_null(filename_template, "%p-%t.log"), tm);
1199 av_free(filename_template);
1200 if (!av_bprint_is_complete(&filename)) {
1201 av_log(NULL, AV_LOG_ERROR, "Out of memory building report file name\n");
1202 return AVERROR(ENOMEM);
1203 }
1204
1205 prog_loglevel = av_log_get_level();

Callers 2

opt_reportFunction · 0.85
parse_loglevelFunction · 0.85

Calls 11

av_opt_get_key_valueFunction · 0.85
av_logFunction · 0.85
av_bprint_initFunction · 0.85
expand_filename_templateFunction · 0.85
av_x_if_nullFunction · 0.85
av_bprint_is_completeFunction · 0.85
av_log_get_levelFunction · 0.85
fopen_utf8Function · 0.85
av_log_set_callbackFunction · 0.85
av_bprint_finalizeFunction · 0.85
av_freeFunction · 0.50

Tested by

no test coverage detected