mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
fftools/ffmpeg_filter: stop accessing OutputStream.[max_]frame_rate
Pass them to ofilter_bind_ost() via OutputFilterOptions, as is done for most other data it needs. OutputStream.[max_]frame_rate/force_fps are no longer used outside of ffmpeg_mux*, and so can be made private. This is a step toward decoupling encoders from muxers.
This commit is contained in:
parent
ac578ccb8e
commit
addc29f67a
@ -328,6 +328,8 @@ typedef struct OutputFilterOptions {
|
|||||||
enum AVColorRange color_range;
|
enum AVColorRange color_range;
|
||||||
|
|
||||||
enum VideoSyncMethod vsync_method;
|
enum VideoSyncMethod vsync_method;
|
||||||
|
AVRational frame_rate;
|
||||||
|
AVRational max_frame_rate;
|
||||||
|
|
||||||
int sample_rate;
|
int sample_rate;
|
||||||
AVChannelLayout ch_layout;
|
AVChannelLayout ch_layout;
|
||||||
@ -605,9 +607,6 @@ typedef struct OutputStream {
|
|||||||
AVCodecContext *enc_ctx;
|
AVCodecContext *enc_ctx;
|
||||||
|
|
||||||
/* video only */
|
/* video only */
|
||||||
AVRational frame_rate;
|
|
||||||
AVRational max_frame_rate;
|
|
||||||
int force_fps;
|
|
||||||
#if FFMPEG_OPT_TOP
|
#if FFMPEG_OPT_TOP
|
||||||
int top_field_first;
|
int top_field_first;
|
||||||
#endif
|
#endif
|
||||||
|
@ -854,8 +854,8 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
|
|||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
ofp->fps.vsync_method = opts->vsync_method;
|
ofp->fps.vsync_method = opts->vsync_method;
|
||||||
ofp->fps.framerate = ost->frame_rate;
|
ofp->fps.framerate = opts->frame_rate;
|
||||||
ofp->fps.framerate_max = ost->max_frame_rate;
|
ofp->fps.framerate_max = opts->max_frame_rate;
|
||||||
ofp->fps.framerate_supported = opts->frame_rates;
|
ofp->fps.framerate_supported = opts->frame_rates;
|
||||||
|
|
||||||
// reduce frame rate for mpeg4 to be within the spec limits
|
// reduce frame rate for mpeg4 to be within the spec limits
|
||||||
|
@ -85,6 +85,10 @@ typedef struct MuxStream {
|
|||||||
int ts_drop;
|
int ts_drop;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
AVRational frame_rate;
|
||||||
|
AVRational max_frame_rate;
|
||||||
|
int force_fps;
|
||||||
|
|
||||||
const char *apad;
|
const char *apad;
|
||||||
} MuxStream;
|
} MuxStream;
|
||||||
|
|
||||||
|
@ -605,13 +605,13 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
st = ost->st;
|
st = ost->st;
|
||||||
|
|
||||||
opt_match_per_stream_str(ost, &o->frame_rates, oc, st, &frame_rate);
|
opt_match_per_stream_str(ost, &o->frame_rates, oc, st, &frame_rate);
|
||||||
if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) {
|
if (frame_rate && av_parse_video_rate(&ms->frame_rate, frame_rate) < 0) {
|
||||||
av_log(ost, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate);
|
av_log(ost, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
opt_match_per_stream_str(ost, &o->max_frame_rates, oc, st, &max_frame_rate);
|
opt_match_per_stream_str(ost, &o->max_frame_rates, oc, st, &max_frame_rate);
|
||||||
if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, max_frame_rate) < 0) {
|
if (max_frame_rate && av_parse_video_rate(&ms->max_frame_rate, max_frame_rate) < 0) {
|
||||||
av_log(ost, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate);
|
av_log(ost, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
@ -775,7 +775,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
opt_match_per_stream_int(ost, &o->force_fps, oc, st, &ost->force_fps);
|
opt_match_per_stream_int(ost, &o->force_fps, oc, st, &ms->force_fps);
|
||||||
|
|
||||||
#if FFMPEG_OPT_TOP
|
#if FFMPEG_OPT_TOP
|
||||||
ost->top_field_first = -1;
|
ost->top_field_first = -1;
|
||||||
@ -796,7 +796,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ost->frame_rate.num || ost->max_frame_rate.num) &&
|
if ((ms->frame_rate.num || ms->max_frame_rate.num) &&
|
||||||
!(*vsync_method == VSYNC_AUTO ||
|
!(*vsync_method == VSYNC_AUTO ||
|
||||||
*vsync_method == VSYNC_CFR || *vsync_method == VSYNC_VSCFR)) {
|
*vsync_method == VSYNC_CFR || *vsync_method == VSYNC_VSCFR)) {
|
||||||
av_log(ost, AV_LOG_FATAL, "One of -r/-fpsmax was specified "
|
av_log(ost, AV_LOG_FATAL, "One of -r/-fpsmax was specified "
|
||||||
@ -805,7 +805,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*vsync_method == VSYNC_AUTO) {
|
if (*vsync_method == VSYNC_AUTO) {
|
||||||
if (ost->frame_rate.num || ost->max_frame_rate.num) {
|
if (ms->frame_rate.num || ms->max_frame_rate.num) {
|
||||||
*vsync_method = VSYNC_CFR;
|
*vsync_method = VSYNC_CFR;
|
||||||
} else if (!strcmp(oc->oformat->name, "avi")) {
|
} else if (!strcmp(oc->oformat->name, "avi")) {
|
||||||
*vsync_method = VSYNC_VFR;
|
*vsync_method = VSYNC_VFR;
|
||||||
@ -937,6 +937,8 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
|
|||||||
.color_space = enc_ctx->colorspace,
|
.color_space = enc_ctx->colorspace,
|
||||||
.color_range = enc_ctx->color_range,
|
.color_range = enc_ctx->color_range,
|
||||||
.vsync_method = vsync_method,
|
.vsync_method = vsync_method,
|
||||||
|
.frame_rate = ms->frame_rate,
|
||||||
|
.max_frame_rate = ms->max_frame_rate,
|
||||||
.sample_rate = enc_ctx->sample_rate,
|
.sample_rate = enc_ctx->sample_rate,
|
||||||
.ch_layout = enc_ctx->ch_layout,
|
.ch_layout = enc_ctx->ch_layout,
|
||||||
.sws_opts = o->g->sws_dict,
|
.sws_opts = o->g->sws_dict,
|
||||||
@ -963,7 +965,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (!ost->force_fps) {
|
if (!ms->force_fps) {
|
||||||
ret = avcodec_get_supported_config(enc_ctx, NULL,
|
ret = avcodec_get_supported_config(enc_ctx, NULL,
|
||||||
AV_CODEC_CONFIG_FRAME_RATE, 0,
|
AV_CODEC_CONFIG_FRAME_RATE, 0,
|
||||||
(const void **) &opts.frame_rates, NULL);
|
(const void **) &opts.frame_rates, NULL);
|
||||||
@ -1035,7 +1037,7 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost, AVDictionary **e
|
|||||||
|
|
||||||
AVCodecContext *codec_ctx = NULL;
|
AVCodecContext *codec_ctx = NULL;
|
||||||
|
|
||||||
AVRational fr = ost->frame_rate;
|
AVRational fr = ms->frame_rate;
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user