diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-04-18 14:11:03 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-04-24 16:56:06 +0200 |
commit | 8b56480652c83603a877c8e72c20c30c7de5b9cf (patch) | |
tree | 728656bd975919299a7eb3bf5012db9c0dc84a7b /fftools/ffmpeg_filter.c | |
parent | 2104de13e93fc91c99d9c0e5cac4147b67a900d7 (diff) | |
download | ffmpeg-8b56480652c83603a877c8e72c20c30c7de5b9cf.tar.gz |
fftools/ffmpeg_filter: add a function for creating a filtergraph
Code creating a new filtergraph is currently duplicated in 3 places.
This commit unifies it and moves towards making filtergraphs more
self-contained.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r-- | fftools/ffmpeg_filter.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ea182089b1..7b3d9a490f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -188,15 +188,26 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg) return ofilter; } +FilterGraph *fg_create(char *graph_desc) +{ + FilterGraph *fg; + + fg = ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs); + fg->index = nb_filtergraphs - 1; + fg->graph_desc = graph_desc; + + return fg; +} + int init_simple_filtergraph(InputStream *ist, OutputStream *ost) { - FilterGraph *fg = av_mallocz(sizeof(*fg)); + FilterGraph *fg; OutputFilter *ofilter; InputFilter *ifilter; + fg = fg_create(NULL); if (!fg) report_and_exit(AVERROR(ENOMEM)); - fg->index = nb_filtergraphs; ofilter = ofilter_alloc(fg); ofilter->ost = ost; @@ -212,9 +223,6 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) if (!ifilter->frame_queue) report_and_exit(AVERROR(ENOMEM)); - GROW_ARRAY(filtergraphs, nb_filtergraphs); - filtergraphs[nb_filtergraphs - 1] = fg; - ist_filter_add(ist, ifilter, 1); return 0; |