aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-04-11 12:57:30 +0200
committerAnton Khirnov <anton@khirnov.net>2023-04-17 12:01:40 +0200
commitae071c9e3944ebe12e4088c81992f31d974ea904 (patch)
tree016d42cb98fc3b269da209228eb312f25dcbc041
parentc7438e87377b95191b395fcf72f1653ac69eab9c (diff)
downloadffmpeg-ae071c9e3944ebe12e4088c81992f31d974ea904.tar.gz
fftools/ffmpeg: add a function adding a destination filter for InputStream
This way filtering code does not directly mess with InputStream internals. Will become more useful in following commits.
-rw-r--r--fftools/ffmpeg.h1
-rw-r--r--fftools/ffmpeg_demux.c6
-rw-r--r--fftools/ffmpeg_filter.c8
3 files changed, 10 insertions, 5 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 17076f018d..d25377514e 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -880,6 +880,7 @@ void ifile_close(InputFile **f);
int ifile_get_packet(InputFile *f, AVPacket **pkt);
void ist_output_add(InputStream *ist, OutputStream *ost);
+void ist_filter_add(InputStream *ist, InputFilter *ifilter);
/* iterate over all input streams in all input files;
* pass NULL to start iteration */
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index d89e28b9f6..6f68c7f6b5 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -567,6 +567,12 @@ void ist_output_add(InputStream *ist, OutputStream *ost)
ist->outputs[ist->nb_outputs - 1] = ost;
}
+void ist_filter_add(InputStream *ist, InputFilter *ifilter)
+{
+ GROW_ARRAY(ist->filters, ist->nb_filters);
+ ist->filters[ist->nb_filters - 1] = ifilter;
+}
+
static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream *st,
enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type)
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 584f51ac3f..d2a185cf98 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -212,12 +212,11 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
if (!ifilter->frame_queue)
report_and_exit(AVERROR(ENOMEM));
- GROW_ARRAY(ist->filters, ist->nb_filters);
- ist->filters[ist->nb_filters - 1] = ifilter;
-
GROW_ARRAY(filtergraphs, nb_filtergraphs);
filtergraphs[nb_filtergraphs - 1] = fg;
+ ist_filter_add(ist, ifilter);
+
return 0;
}
@@ -319,8 +318,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
if (!ifilter->frame_queue)
report_and_exit(AVERROR(ENOMEM));
- GROW_ARRAY(ist->filters, ist->nb_filters);
- ist->filters[ist->nb_filters - 1] = ifilter;
+ ist_filter_add(ist, ifilter);
}
static int read_binary(const char *path, uint8_t **data, int *len)