| 74 | } |
| 75 | |
| 76 | static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, |
| 77 | const char *filt_name, const char *args, |
| 78 | AVClass *log_ctx) |
| 79 | { |
| 80 | AVFilterContext *filt_ctx; |
| 81 | |
| 82 | AVFilter *filt; |
| 83 | char inst_name[30]; |
| 84 | |
| 85 | snprintf(inst_name, sizeof(inst_name), "Parsed filter %d", index); |
| 86 | |
| 87 | filt = avfilter_get_by_name(filt_name); |
| 88 | |
| 89 | if(!filt) { |
| 90 | av_log(log_ctx, AV_LOG_ERROR, |
| 91 | "no such filter: '%s'\n", filt_name); |
| 92 | return NULL; |
| 93 | } |
| 94 | |
| 95 | filt_ctx = avfilter_open(filt, inst_name); |
| 96 | if(!filt_ctx) { |
| 97 | av_log(log_ctx, AV_LOG_ERROR, |
| 98 | "error creating filter '%s'\n", filt_name); |
| 99 | return NULL; |
| 100 | } |
| 101 | |
| 102 | if(avfilter_graph_add_filter(ctx, filt_ctx) < 0) { |
| 103 | avfilter_destroy(filt_ctx); |
| 104 | return NULL; |
| 105 | } |
| 106 | |
| 107 | if(avfilter_init_filter(filt_ctx, args, NULL)) { |
| 108 | av_log(log_ctx, AV_LOG_ERROR, |
| 109 | "error initializing filter '%s' with args '%s'\n", filt_name, args); |
| 110 | return NULL; |
| 111 | } |
| 112 | |
| 113 | return filt_ctx; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Parse "filter=params" |
no test coverage detected