diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-04-02 13:58:59 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-04-09 10:34:18 +0200 |
commit | b8e6802023a5e687c40b6565745a225f8e069657 (patch) | |
tree | db30e5f1383bbb4d284bd17ca072937d0ca08c1a /fftools/ffmpeg_filter.c | |
parent | 23c23077fc79f27022f56855080debdba7a00274 (diff) | |
download | ffmpeg-b8e6802023a5e687c40b6565745a225f8e069657.tar.gz |
fftools/ffmpeg_filter: pass sws/swr opts through OutputFilterOptions
Do not read them from OutputStream directly.
Will allow decoupling filtering from encoding in future commits.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r-- | fftools/ffmpeg_filter.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index d2fd26af7e..8aa4053716 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -210,6 +210,9 @@ typedef struct OutputFilterPriv { AVRational sample_aspect_ratio; + AVDictionary *sws_opts; + AVDictionary *swr_opts; + // those are only set if no format is specified and the encoder gives us multiple options // They point directly to the relevant lists of the encoder. const int *formats; @@ -813,6 +816,17 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, if (!ofp->name) return AVERROR(EINVAL); + ret = av_dict_copy(&ofp->sws_opts, opts->sws_opts, 0); + if (ret < 0) + return ret; + + ret = av_dict_copy(&ofp->swr_opts, opts->swr_opts, 0); + if (ret < 0) + return ret; + + if (opts->flags & OFILTER_FLAG_AUDIO_24BIT) + av_dict_set(&ofp->swr_opts, "output_sample_bits", "24", 0); + if (fgp->is_simple) { // for simple filtergraph there is just one output, // so use only graph-level information for logging @@ -945,6 +959,8 @@ void fg_free(FilterGraph **pfg) OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); av_frame_free(&ofp->fps.last_frame); + av_dict_free(&ofp->sws_opts); + av_dict_free(&ofp->swr_opts); av_freep(&ofilter->linklabel); av_freep(&ofilter->name); @@ -1358,7 +1374,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, snprintf(args, sizeof(args), "%d:%d", ofp->width, ofp->height); - while ((e = av_dict_iterate(ost->sws_dict, e))) { + while ((e = av_dict_iterate(ofp->sws_opts, e))) { av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value); } @@ -1725,6 +1741,7 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) return AVERROR(ENOMEM); if (simple) { + OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[0]); OutputStream *ost = fg->outputs[0]->ost; if (filter_nbthreads) { @@ -1738,17 +1755,17 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) av_opt_set(fgt->graph, "threads", e->value, 0); } - if (av_dict_count(ost->sws_dict)) { - ret = av_dict_get_string(ost->sws_dict, + if (av_dict_count(ofp->sws_opts)) { + ret = av_dict_get_string(ofp->sws_opts, &fgt->graph->scale_sws_opts, '=', ':'); if (ret < 0) goto fail; } - if (av_dict_count(ost->swr_opts)) { + if (av_dict_count(ofp->swr_opts)) { char *args; - ret = av_dict_get_string(ost->swr_opts, &args, '=', ':'); + ret = av_dict_get_string(ofp->swr_opts, &args, '=', ':'); if (ret < 0) goto fail; av_opt_set(fgt->graph, "aresample_swr_opts", args, 0); |