| 423 | } |
| 424 | |
| 425 | static int init_filters(void) |
| 426 | { |
| 427 | const char *filter_spec; |
| 428 | unsigned int i; |
| 429 | int ret; |
| 430 | filter_ctx = av_malloc_array(ifmt_ctx->nb_streams, sizeof(*filter_ctx)); |
| 431 | if (!filter_ctx) |
| 432 | return AVERROR(ENOMEM); |
| 433 | |
| 434 | for (i = 0; i < ifmt_ctx->nb_streams; i++) { |
| 435 | filter_ctx[i].buffersrc_ctx = NULL; |
| 436 | filter_ctx[i].buffersink_ctx = NULL; |
| 437 | filter_ctx[i].filter_graph = NULL; |
| 438 | if (!(ifmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO |
| 439 | || ifmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)) |
| 440 | continue; |
| 441 | |
| 442 | |
| 443 | if (ifmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) |
| 444 | filter_spec = "null"; /* passthrough (dummy) filter for video */ |
| 445 | else |
| 446 | filter_spec = "anull"; /* passthrough (dummy) filter for audio */ |
| 447 | ret = init_filter(&filter_ctx[i], stream_ctx[i].dec_ctx, |
| 448 | stream_ctx[i].enc_ctx, filter_spec); |
| 449 | if (ret) |
| 450 | return ret; |
| 451 | |
| 452 | filter_ctx[i].enc_pkt = av_packet_alloc(); |
| 453 | if (!filter_ctx[i].enc_pkt) |
| 454 | return AVERROR(ENOMEM); |
| 455 | |
| 456 | filter_ctx[i].filtered_frame = av_frame_alloc(); |
| 457 | if (!filter_ctx[i].filtered_frame) |
| 458 | return AVERROR(ENOMEM); |
| 459 | } |
| 460 | return 0; |
| 461 | } |
| 462 | |
| 463 | static int encode_write_frame(unsigned int stream_index, int flush) |
| 464 | { |
no test coverage detected