fftools/ffmpeg_filter: pass autorotate/reinit flags through InputFilterOptions

Rather than read them directly from InputStream.

This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
This commit is contained in:
Anton Khirnov 2024-02-13 12:18:27 +01:00
parent 6315f78e0c
commit fef3052df3
3 changed files with 17 additions and 6 deletions

View File

@ -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 {

View File

@ -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;

View File

@ -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 ||