[FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_filter: pass autorotate/reinit flags through InputFilterOptions
Anton Khirnov
anton at khirnov.net
Wed Feb 14 20:24:30 EET 2024
Rather than read them directly from InputStream.
This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
---
fftools/ffmpeg.h | 10 ++++++++--
fftools/ffmpeg_demux.c | 8 ++++++--
fftools/ffmpeg_filter.c | 5 +++--
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6db7b8a9c4..9942342f03 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -250,6 +250,11 @@ typedef struct OptionsContext {
SpecifierOptList mux_stats_fmt;
} OptionsContext;
+enum IFilterFlags {
+ IFILTER_FLAG_AUTOROTATE = (1 << 0),
+ IFILTER_FLAG_REINIT = (1 << 1),
+};
+
typedef struct InputFilterOptions {
int64_t trim_start_us;
int64_t trim_end_us;
@@ -258,6 +263,9 @@ typedef struct InputFilterOptions {
int sub2video_width;
int sub2video_height;
+
+ // a combination of IFILTER_FLAG_*
+ unsigned flags;
} InputFilterOptions;
typedef struct InputFilter {
@@ -381,8 +389,6 @@ typedef struct InputStream {
*/
struct OutputStream **outputs;
int nb_outputs;
-
- int reinit_filters;
} InputStream;
typedef struct InputFile {
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 87ed8225c2..317e27e294 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -63,6 +63,7 @@ typedef struct DemuxStream {
int streamcopy_needed;
int have_sub2video;
+ int reinit_filters;
int wrap_correction_done;
int saw_first_ts;
@@ -1033,6 +1034,9 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
if (!opts->name)
return AVERROR(ENOMEM);
+ opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ist->autorotate) |
+ IFILTER_FLAG_REINIT * !!(ds->reinit_filters);
+
return ds->sch_idx_dec;
}
@@ -1309,8 +1313,8 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
if (ret < 0)
return ret;
- ist->reinit_filters = -1;
- MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
+ ds->reinit_filters = -1;
+ MATCH_PER_STREAM_OPT(reinit_filters, i, ds->reinit_filters, ic, st);
ist->user_set_discard = AVDISCARD_NONE;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index d182f3ab2e..56aa3edd78 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1534,7 +1534,8 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
av_assert0(desc);
// TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
- if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
+ if ((ifp->opts.flags & IFILTER_FLAG_AUTOROTATE) &&
+ !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
int32_t *displaymatrix = ifp->displaymatrix;
double theta;
@@ -2614,7 +2615,7 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
} else if (ifp->displaymatrix_present)
need_reinit |= MATRIX_CHANGED;
- if (!ifp->ist->reinit_filters && fgt->graph)
+ if (!(ifp->opts.flags & IFILTER_FLAG_REINIT) && fgt->graph)
need_reinit = 0;
if (!!ifp->hw_frames_ctx != !!frame->hw_frames_ctx ||
--
2.42.0
More information about the ffmpeg-devel
mailing list