diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-12-17 14:20:57 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-12-22 11:39:57 +0100 |
commit | 0ba70a679216a504ed4ea6f50c37283cf099e8ae (patch) | |
tree | 7a70044b7605933d36974c17edca23549a940432 /fftools/ffmpeg_demux.c | |
parent | 579238226901285eff24ef88ae1a53b7f166adf5 (diff) | |
download | ffmpeg-0ba70a679216a504ed4ea6f50c37283cf099e8ae.tar.gz |
fftools/cmdutils: add a struct for a list of SpecifierOpt
Significantly simplifies the code dealing with OPT_SPEC.
Diffstat (limited to 'fftools/ffmpeg_demux.c')
-rw-r--r-- | fftools/ffmpeg_demux.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index a28a94b5ed..238b37ad93 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1388,28 +1388,28 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch) ic = avformat_alloc_context(); if (!ic) return AVERROR(ENOMEM); - if (o->nb_audio_sample_rate) { - av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i, 0); + if (o->audio_sample_rate.nb_opt) { + av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate.opt[o->audio_sample_rate.nb_opt - 1].u.i, 0); } - if (o->nb_audio_channels) { + if (o->audio_channels.nb_opt) { const AVClass *priv_class; if (file_iformat && (priv_class = file_iformat->priv_class) && av_opt_find(&priv_class, "ch_layout", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)) { char buf[32]; - snprintf(buf, sizeof(buf), "%dC", o->audio_channels[o->nb_audio_channels - 1].u.i); + snprintf(buf, sizeof(buf), "%dC", o->audio_channels.opt[o->audio_channels.nb_opt - 1].u.i); av_dict_set(&o->g->format_opts, "ch_layout", buf, 0); } } - if (o->nb_audio_ch_layouts) { + if (o->audio_ch_layouts.nb_opt) { const AVClass *priv_class; if (file_iformat && (priv_class = file_iformat->priv_class) && av_opt_find(&priv_class, "ch_layout", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)) { - av_dict_set(&o->g->format_opts, "ch_layout", o->audio_ch_layouts[o->nb_audio_ch_layouts - 1].u.str, 0); + av_dict_set(&o->g->format_opts, "ch_layout", o->audio_ch_layouts.opt[o->audio_ch_layouts.nb_opt - 1].u.str, 0); } } - if (o->nb_frame_rates) { + if (o->frame_rates.nb_opt) { const AVClass *priv_class; /* set the format-level framerate option; * this is important for video grabbers, e.g. x11 */ @@ -1417,14 +1417,14 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch) av_opt_find(&priv_class, "framerate", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)) { av_dict_set(&o->g->format_opts, "framerate", - o->frame_rates[o->nb_frame_rates - 1].u.str, 0); + o->frame_rates.opt[o->frame_rates.nb_opt - 1].u.str, 0); } } - if (o->nb_frame_sizes) { - av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes[o->nb_frame_sizes - 1].u.str, 0); + if (o->frame_sizes.nb_opt) { + av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes.opt[o->frame_sizes.nb_opt - 1].u.str, 0); } - if (o->nb_frame_pix_fmts) - av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0); + if (o->frame_pix_fmts.nb_opt) + av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts.opt[o->frame_pix_fmts.nb_opt - 1].u.str, 0); MATCH_PER_TYPE_OPT(codec_names, str, video_codec_name, ic, "v"); MATCH_PER_TYPE_OPT(codec_names, str, audio_codec_name, ic, "a"); @@ -1648,14 +1648,14 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch) } av_dict_free(&unused_opts); - for (i = 0; i < o->nb_dump_attachment; i++) { + for (i = 0; i < o->dump_attachment.nb_opt; i++) { int j; for (j = 0; j < f->nb_streams; j++) { InputStream *ist = f->streams[j]; - if (check_stream_specifier(ic, ist->st, o->dump_attachment[i].specifier) == 1) { - ret = dump_attachment(ist, o->dump_attachment[i].u.str); + if (check_stream_specifier(ic, ist->st, o->dump_attachment.opt[i].specifier) == 1) { + ret = dump_attachment(ist, o->dump_attachment.opt[i].u.str); if (ret < 0) return ret; } |