This avoids per parameter changes in ffmpeg at the cost of making access
somewhat more annoying.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -62,7 +62,7 @@ |
62 | 62 |
static int init_report(const char *env); |
63 | 63 |
|
64 | 64 |
struct SwsContext *sws_opts; |
65 |
-SwrContext *swr_opts; |
|
65 |
+AVDictionary *swr_opts; |
|
66 | 66 |
AVDictionary *format_opts, *codec_opts, *resample_opts; |
67 | 67 |
|
68 | 68 |
const int this_year = 2013; |
... | ... |
@@ -75,9 +75,6 @@ void init_opts(void) |
75 | 75 |
if(CONFIG_SWSCALE) |
76 | 76 |
sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, |
77 | 77 |
NULL, NULL, NULL); |
78 |
- |
|
79 |
- if(CONFIG_SWRESAMPLE) |
|
80 |
- swr_opts = swr_alloc(); |
|
81 | 78 |
} |
82 | 79 |
|
83 | 80 |
void uninit_opts(void) |
... | ... |
@@ -87,9 +84,7 @@ void uninit_opts(void) |
87 | 87 |
sws_opts = NULL; |
88 | 88 |
#endif |
89 | 89 |
|
90 |
- if(CONFIG_SWRESAMPLE) |
|
91 |
- swr_free(&swr_opts); |
|
92 |
- |
|
90 |
+ av_dict_free(&swr_opts); |
|
93 | 91 |
av_dict_free(&format_opts); |
94 | 92 |
av_dict_free(&codec_opts); |
95 | 93 |
av_dict_free(&resample_opts); |
... | ... |
@@ -518,13 +513,16 @@ int opt_default(void *optctx, const char *opt, const char *arg) |
518 | 518 |
#endif |
519 | 519 |
#if CONFIG_SWRESAMPLE |
520 | 520 |
swr_class = swr_get_class(); |
521 |
- if (!consumed && av_opt_find(&swr_class, opt, NULL, 0, |
|
522 |
- AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { |
|
523 |
- int ret = av_opt_set(swr_opts, opt, arg, 0); |
|
521 |
+ if (!consumed && (o=av_opt_find(&swr_class, opt, NULL, 0, |
|
522 |
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { |
|
523 |
+ struct SwrContext *swr = swr_alloc(); |
|
524 |
+ int ret = av_opt_set(swr, opt, arg, 0); |
|
525 |
+ swr_free(&swr); |
|
524 | 526 |
if (ret < 0) { |
525 | 527 |
av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); |
526 | 528 |
return ret; |
527 | 529 |
} |
530 |
+ av_dict_set(&swr_opts, opt, arg, FLAGS); |
|
528 | 531 |
consumed = 1; |
529 | 532 |
} |
530 | 533 |
#endif |
... | ... |
@@ -651,8 +649,7 @@ void uninit_parse_context(OptionParseContext *octx) |
651 | 651 |
#if CONFIG_SWSCALE |
652 | 652 |
sws_freeContext(l->groups[j].sws_opts); |
653 | 653 |
#endif |
654 |
- if(CONFIG_SWRESAMPLE) |
|
655 |
- swr_free(&l->groups[j].swr_opts); |
|
654 |
+ av_dict_free(&l->groups[j].swr_opts); |
|
656 | 655 |
} |
657 | 656 |
av_freep(&l->groups); |
658 | 657 |
} |
... | ... |
@@ -51,7 +51,7 @@ extern const int this_year; |
51 | 51 |
extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; |
52 | 52 |
extern AVFormatContext *avformat_opts; |
53 | 53 |
extern struct SwsContext *sws_opts; |
54 |
-extern struct SwrContext *swr_opts; |
|
54 |
+extern AVDictionary *swr_opts; |
|
55 | 55 |
extern AVDictionary *format_opts, *codec_opts, *resample_opts; |
56 | 56 |
|
57 | 57 |
/** |
... | ... |
@@ -255,7 +255,7 @@ typedef struct OptionGroup { |
255 | 255 |
AVDictionary *format_opts; |
256 | 256 |
AVDictionary *resample_opts; |
257 | 257 |
struct SwsContext *sws_opts; |
258 |
- struct SwrContext *swr_opts; |
|
258 |
+ AVDictionary *swr_opts; |
|
259 | 259 |
} OptionGroup; |
260 | 260 |
|
261 | 261 |
/** |
... | ... |
@@ -346,10 +346,8 @@ typedef struct OutputStream { |
346 | 346 |
char *avfilter; |
347 | 347 |
|
348 | 348 |
int64_t sws_flags; |
349 |
- int64_t swr_filter_type; |
|
350 |
- int64_t swr_dither_method; |
|
351 |
- double swr_dither_scale; |
|
352 | 349 |
AVDictionary *opts; |
350 |
+ AVDictionary *swr_opts; |
|
353 | 351 |
AVDictionary *resample_opts; |
354 | 352 |
int finished; /* no more packets should be written for this stream */ |
355 | 353 |
int unavailable; /* true if the steram is unavailable (possibly temporarily) */ |
... | ... |
@@ -739,12 +739,10 @@ int configure_filtergraph(FilterGraph *fg) |
739 | 739 |
fg->graph->scale_sws_opts = av_strdup(args); |
740 | 740 |
|
741 | 741 |
args[0] = 0; |
742 |
- if (ost->swr_filter_type != SWR_FILTER_TYPE_KAISER) |
|
743 |
- av_strlcatf(args, sizeof(args), "filter_type=%d:", (int)ost->swr_filter_type); |
|
744 |
- if (ost->swr_dither_method) |
|
745 |
- av_strlcatf(args, sizeof(args), "dither_method=%d:", (int)ost->swr_dither_method); |
|
746 |
- if (ost->swr_dither_scale != 1.0) |
|
747 |
- av_strlcatf(args, sizeof(args), "dither_scale=%f:", ost->swr_dither_scale); |
|
742 |
+ while ((e = av_dict_get(ost->swr_opts, "", e, |
|
743 |
+ AV_DICT_IGNORE_SUFFIX))) { |
|
744 |
+ av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value); |
|
745 |
+ } |
|
748 | 746 |
if (strlen(args)) |
749 | 747 |
args[strlen(args)-1] = 0; |
750 | 748 |
av_opt_set(fg->graph, "aresample_swr_opts", args, 0); |
... | ... |
@@ -1002,11 +1002,10 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e |
1002 | 1002 |
st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; |
1003 | 1003 |
|
1004 | 1004 |
av_opt_get_int(o->g->sws_opts, "sws_flags", 0, &ost->sws_flags); |
1005 |
- av_opt_get_int (o->g->swr_opts, "filter_type" , 0, &ost->swr_filter_type); |
|
1006 |
- av_opt_get_int (o->g->swr_opts, "dither_method", 0, &ost->swr_dither_method); |
|
1007 |
- av_opt_get_double(o->g->swr_opts, "dither_scale" , 0, &ost->swr_dither_scale); |
|
1005 |
+ |
|
1006 |
+ av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0); |
|
1008 | 1007 |
if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24) |
1009 |
- ost->swr_dither_scale = ost->swr_dither_scale*256; |
|
1008 |
+ av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0); |
|
1010 | 1009 |
|
1011 | 1010 |
av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0); |
1012 | 1011 |
|