mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
avplay: Factorize code for adding filters to the filter pipeline
Significantly based on a patch by Clément Bœsch. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
3ecb82dd41
commit
21180b7323
32
avplay.c
32
avplay.c
@ -1504,7 +1504,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
|
|||||||
char sws_flags_str[128];
|
char sws_flags_str[128];
|
||||||
char buffersrc_args[256];
|
char buffersrc_args[256];
|
||||||
int ret;
|
int ret;
|
||||||
AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format;
|
AVFilterContext *filt_src = NULL, *filt_out = NULL, *last_filter;
|
||||||
AVCodecContext *codec = is->video_st->codec;
|
AVCodecContext *codec = is->video_st->codec;
|
||||||
|
|
||||||
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%"PRId64, sws_flags);
|
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%"PRId64, sws_flags);
|
||||||
@ -1526,13 +1526,27 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
|
|||||||
"out", NULL, NULL, graph)) < 0)
|
"out", NULL, NULL, graph)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if ((ret = avfilter_graph_create_filter(&filt_format,
|
last_filter = filt_out;
|
||||||
avfilter_get_by_name("format"),
|
|
||||||
"format", "yuv420p", NULL, graph)) < 0)
|
|
||||||
return ret;
|
|
||||||
if ((ret = avfilter_link(filt_format, 0, filt_out, 0)) < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
|
/* Note: this macro adds a filter before the lastly added filter, so the
|
||||||
|
* processing order of the filters is in reverse */
|
||||||
|
#define INSERT_FILT(name, arg) do { \
|
||||||
|
AVFilterContext *filt_ctx; \
|
||||||
|
\
|
||||||
|
ret = avfilter_graph_create_filter(&filt_ctx, \
|
||||||
|
avfilter_get_by_name(name), \
|
||||||
|
"avplay_" name, arg, NULL, graph); \
|
||||||
|
if (ret < 0) \
|
||||||
|
return ret; \
|
||||||
|
\
|
||||||
|
ret = avfilter_link(filt_ctx, 0, last_filter, 0); \
|
||||||
|
if (ret < 0) \
|
||||||
|
return ret; \
|
||||||
|
\
|
||||||
|
last_filter = filt_ctx; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
INSERT_FILT("format", "yuv420p");
|
||||||
|
|
||||||
if (vfilters) {
|
if (vfilters) {
|
||||||
AVFilterInOut *outputs = avfilter_inout_alloc();
|
AVFilterInOut *outputs = avfilter_inout_alloc();
|
||||||
@ -1544,14 +1558,14 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
|
|||||||
outputs->next = NULL;
|
outputs->next = NULL;
|
||||||
|
|
||||||
inputs->name = av_strdup("out");
|
inputs->name = av_strdup("out");
|
||||||
inputs->filter_ctx = filt_format;
|
inputs->filter_ctx = last_filter;
|
||||||
inputs->pad_idx = 0;
|
inputs->pad_idx = 0;
|
||||||
inputs->next = NULL;
|
inputs->next = NULL;
|
||||||
|
|
||||||
if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
|
if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
if ((ret = avfilter_link(filt_src, 0, filt_format, 0)) < 0)
|
if ((ret = avfilter_link(filt_src, 0, last_filter, 0)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user