| 274 | } |
| 275 | |
| 276 | static int opt_map(void *optctx, const char *opt, const char *arg) |
| 277 | { |
| 278 | OptionsContext *o = optctx; |
| 279 | StreamMap *m = NULL; |
| 280 | int i, negative = 0, file_idx; |
| 281 | int sync_file_idx = -1, sync_stream_idx = 0; |
| 282 | char *p, *sync; |
| 283 | char *map; |
| 284 | char *allow_unused; |
| 285 | |
| 286 | if (*arg == '-') { |
| 287 | negative = 1; |
| 288 | arg++; |
| 289 | } |
| 290 | map = av_strdup(arg); |
| 291 | if (!map) |
| 292 | return AVERROR(ENOMEM); |
| 293 | |
| 294 | /* parse sync stream first, just pick first matching stream */ |
| 295 | if (sync = strchr(map, ',')) { |
| 296 | *sync = 0; |
| 297 | sync_file_idx = strtol(sync + 1, &sync, 0); |
| 298 | if (sync_file_idx >= nb_input_files || sync_file_idx < 0) { |
| 299 | av_log(NULL, AV_LOG_FATAL, "Invalid sync file index: %d.\n", sync_file_idx); |
| 300 | exit_program(1); |
| 301 | } |
| 302 | if (*sync) |
| 303 | sync++; |
| 304 | for (i = 0; i < input_files[sync_file_idx]->nb_streams; i++) |
| 305 | if (check_stream_specifier(input_files[sync_file_idx]->ctx, |
| 306 | input_files[sync_file_idx]->ctx->streams[i], sync) == 1) { |
| 307 | sync_stream_idx = i; |
| 308 | break; |
| 309 | } |
| 310 | if (i == input_files[sync_file_idx]->nb_streams) { |
| 311 | av_log(NULL, AV_LOG_FATAL, "Sync stream specification in map %s does not " |
| 312 | "match any streams.\n", arg); |
| 313 | exit_program(1); |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | |
| 318 | if (map[0] == '[') { |
| 319 | /* this mapping refers to lavfi output */ |
| 320 | const char *c = map + 1; |
| 321 | GROW_ARRAY(o->stream_maps, o->nb_stream_maps); |
| 322 | m = &o->stream_maps[o->nb_stream_maps - 1]; |
| 323 | m->linklabel = av_get_token(&c, "]"); |
| 324 | if (!m->linklabel) { |
| 325 | av_log(NULL, AV_LOG_ERROR, "Invalid output link label: %s.\n", map); |
| 326 | exit_program(1); |
| 327 | } |
| 328 | } else { |
| 329 | if (allow_unused = strchr(map, '?')) |
| 330 | *allow_unused = 0; |
| 331 | file_idx = strtol(map, &p, 0); |
| 332 | if (file_idx >= nb_input_files || file_idx < 0) { |
| 333 | av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx); |
nothing calls this directly
no test coverage detected