mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
fftools/ffmpeg_filter: pass keep_pix_fmt through OutputFilterOptions
Reduces the need to access OutputStream, which will allow decoupling filtering from encoding in future commits.
This commit is contained in:
parent
b3864e7a08
commit
e903c31fd1
@ -263,11 +263,18 @@ typedef struct InputFilterOptions {
|
||||
AVFrame *fallback;
|
||||
} InputFilterOptions;
|
||||
|
||||
enum OFilterFlags {
|
||||
OFILTER_FLAG_DISABLE_CONVERT = (1 << 0),
|
||||
};
|
||||
|
||||
typedef struct OutputFilterOptions {
|
||||
// Codec used for encoding, may be NULL
|
||||
const AVCodec *enc;
|
||||
|
||||
int64_t ts_offset;
|
||||
|
||||
// A combination of OFilterFlags.
|
||||
unsigned flags;
|
||||
} OutputFilterOptions;
|
||||
|
||||
typedef struct InputFilter {
|
||||
@ -556,8 +563,6 @@ typedef struct OutputStream {
|
||||
|
||||
char *attachment_filename;
|
||||
|
||||
int keep_pix_fmt;
|
||||
|
||||
/* stats */
|
||||
// number of packets send to the muxer
|
||||
atomic_uint_least64_t packets_written;
|
||||
|
@ -214,6 +214,8 @@ typedef struct OutputFilterPriv {
|
||||
int64_t ts_offset;
|
||||
int64_t next_pts;
|
||||
FPSConvContext fps;
|
||||
|
||||
unsigned flags;
|
||||
} OutputFilterPriv;
|
||||
|
||||
static OutputFilterPriv *ofp_from_ofilter(OutputFilter *ofilter)
|
||||
@ -355,11 +357,10 @@ static int choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint,
|
||||
const char **dst)
|
||||
{
|
||||
OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
|
||||
OutputStream *ost = ofilter->ost;
|
||||
|
||||
*dst = NULL;
|
||||
|
||||
if (ost->keep_pix_fmt || ofp->format != AV_PIX_FMT_NONE) {
|
||||
if (ofp->flags & OFILTER_FLAG_DISABLE_CONVERT || ofp->format != AV_PIX_FMT_NONE) {
|
||||
*dst = ofp->format == AV_PIX_FMT_NONE ? NULL :
|
||||
av_get_pix_fmt_name(ofp->format);
|
||||
} else if (ofp->formats) {
|
||||
@ -777,6 +778,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
|
||||
ofilter->ost = ost;
|
||||
av_freep(&ofilter->linklabel);
|
||||
|
||||
ofp->flags = opts->flags;
|
||||
ofp->ts_offset = opts->ts_offset;
|
||||
ofp->enc_timebase = ost->enc_timebase;
|
||||
|
||||
@ -814,7 +816,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
|
||||
}
|
||||
}
|
||||
|
||||
fgp->disable_conversions |= ost->keep_pix_fmt;
|
||||
fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT);
|
||||
|
||||
ofp->fps.last_frame = av_frame_alloc();
|
||||
if (!ofp->fps.last_frame)
|
||||
|
@ -580,7 +580,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name)
|
||||
}
|
||||
|
||||
static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
||||
OutputStream *ost)
|
||||
OutputStream *ost, int *keep_pix_fmt)
|
||||
{
|
||||
AVFormatContext *oc = mux->fc;
|
||||
AVStream *st;
|
||||
@ -638,7 +638,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
||||
|
||||
MATCH_PER_STREAM_OPT(frame_pix_fmts, str, frame_pix_fmt, oc, st);
|
||||
if (frame_pix_fmt && *frame_pix_fmt == '+') {
|
||||
ost->keep_pix_fmt = 1;
|
||||
*keep_pix_fmt = 1;
|
||||
if (!*++frame_pix_fmt)
|
||||
frame_pix_fmt = NULL;
|
||||
}
|
||||
@ -1041,7 +1041,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
||||
OutputStream *ost;
|
||||
const AVCodec *enc;
|
||||
AVStream *st;
|
||||
int ret = 0;
|
||||
int ret = 0, keep_pix_fmt = 0;
|
||||
const char *bsfs = NULL, *time_base = NULL;
|
||||
char *filters = NULL, *next, *codec_tag = NULL;
|
||||
double qscale = -1;
|
||||
@ -1356,7 +1356,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
||||
ms->copy_initial_nonkeyframes, oc, st);
|
||||
|
||||
switch (type) {
|
||||
case AVMEDIA_TYPE_VIDEO: ret = new_stream_video (mux, o, ost); break;
|
||||
case AVMEDIA_TYPE_VIDEO: ret = new_stream_video (mux, o, ost, &keep_pix_fmt); break;
|
||||
case AVMEDIA_TYPE_AUDIO: ret = new_stream_audio (mux, o, ost); break;
|
||||
case AVMEDIA_TYPE_SUBTITLE: ret = new_stream_subtitle (mux, o, ost); break;
|
||||
}
|
||||
@ -1375,6 +1375,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
||||
.enc = enc,
|
||||
.ts_offset = mux->of.start_time == AV_NOPTS_VALUE ?
|
||||
0 : mux->of.start_time,
|
||||
.flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt,
|
||||
};
|
||||
|
||||
if (ofilter) {
|
||||
|
Loading…
Reference in New Issue
Block a user