mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-09-19 21:06:42 +00:00
fftools/ffmpeg_filter: pass framerate through InputFilterOptions
Rather than read it directly from InputStream. This is a step towards avoiding the assumption that filtergraph inputs are always fed by demuxers.
This commit is contained in:
parent
fef3052df3
commit
826cfd9997
@ -253,6 +253,7 @@ typedef struct OptionsContext {
|
|||||||
enum IFilterFlags {
|
enum IFilterFlags {
|
||||||
IFILTER_FLAG_AUTOROTATE = (1 << 0),
|
IFILTER_FLAG_AUTOROTATE = (1 << 0),
|
||||||
IFILTER_FLAG_REINIT = (1 << 1),
|
IFILTER_FLAG_REINIT = (1 << 1),
|
||||||
|
IFILTER_FLAG_CFR = (1 << 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct InputFilterOptions {
|
typedef struct InputFilterOptions {
|
||||||
@ -261,6 +262,13 @@ typedef struct InputFilterOptions {
|
|||||||
|
|
||||||
uint8_t *name;
|
uint8_t *name;
|
||||||
|
|
||||||
|
/* When IFILTER_FLAG_CFR is set, the stream is guaranteed to be CFR with
|
||||||
|
* this framerate.
|
||||||
|
*
|
||||||
|
* Otherwise, this is an estimate that should not be relied upon to be
|
||||||
|
* accurate */
|
||||||
|
AVRational framerate;
|
||||||
|
|
||||||
int sub2video_width;
|
int sub2video_width;
|
||||||
int sub2video_height;
|
int sub2video_height;
|
||||||
|
|
||||||
@ -365,8 +373,6 @@ typedef struct InputStream {
|
|||||||
Decoder *decoder;
|
Decoder *decoder;
|
||||||
const AVCodec *dec;
|
const AVCodec *dec;
|
||||||
|
|
||||||
AVRational framerate_guessed;
|
|
||||||
|
|
||||||
/* framerate forced with -r */
|
/* framerate forced with -r */
|
||||||
AVRational framerate;
|
AVRational framerate;
|
||||||
#if FFMPEG_OPT_TOP
|
#if FFMPEG_OPT_TOP
|
||||||
|
@ -992,7 +992,13 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||||
|
if (ist->framerate.num > 0 && ist->framerate.den > 0) {
|
||||||
|
opts->framerate = ist->framerate;
|
||||||
|
opts->flags |= IFILTER_FLAG_CFR;
|
||||||
|
} else
|
||||||
|
opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL);
|
||||||
|
} else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
||||||
/* Compute the size of the canvas for the subtitles stream.
|
/* Compute the size of the canvas for the subtitles stream.
|
||||||
If the subtitles codecpar has set a size, use it. Otherwise use the
|
If the subtitles codecpar has set a size, use it. Otherwise use the
|
||||||
maximum dimensions of the video streams in the same file. */
|
maximum dimensions of the video streams in the same file. */
|
||||||
@ -1359,8 +1365,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
|
|||||||
MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);
|
MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ist->framerate_guessed = av_guess_frame_rate(ic, st, NULL);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_AUDIO: {
|
case AVMEDIA_TYPE_AUDIO: {
|
||||||
int guess_layout_max = INT_MAX;
|
int guess_layout_max = INT_MAX;
|
||||||
|
@ -1486,7 +1486,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
|
|||||||
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
|
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
|
||||||
const AVPixFmtDescriptor *desc;
|
const AVPixFmtDescriptor *desc;
|
||||||
InputStream *ist = ifp->ist;
|
InputStream *ist = ifp->ist;
|
||||||
AVRational fr = ist->framerate;
|
AVRational fr = ifp->opts.framerate;
|
||||||
AVRational sar;
|
AVRational sar;
|
||||||
AVBPrint args;
|
AVBPrint args;
|
||||||
char name[255];
|
char name[255];
|
||||||
@ -1495,14 +1495,11 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
|
|||||||
if (!par)
|
if (!par)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if (!fr.num)
|
|
||||||
fr = ist->framerate_guessed;
|
|
||||||
|
|
||||||
if (ifp->type_src == AVMEDIA_TYPE_SUBTITLE)
|
if (ifp->type_src == AVMEDIA_TYPE_SUBTITLE)
|
||||||
sub2video_prepare(ifp);
|
sub2video_prepare(ifp);
|
||||||
|
|
||||||
ifp->time_base = ist->framerate.num ? av_inv_q(ist->framerate) :
|
ifp->time_base = (ifp->opts.flags & IFILTER_FLAG_CFR) ?
|
||||||
ist->st->time_base;
|
av_inv_q(ifp->opts.framerate) : ist->st->time_base;
|
||||||
|
|
||||||
sar = ifp->sample_aspect_ratio;
|
sar = ifp->sample_aspect_ratio;
|
||||||
if(!sar.den)
|
if(!sar.den)
|
||||||
|
Loading…
Reference in New Issue
Block a user