History

Merge commit '9f1223562e134bac6345a465870b9d56ff7d60cf'

* commit '9f1223562e134bac6345a465870b9d56ff7d60cf': lavfi: connect libavresample options to af_resample via AVFilterGraph Conflicts: doc/APIchanges libavfilter/avfiltergraph.c libavfilter/avfiltergraph.h libavfilter/version.h

Michael Niedermayer committed 13 years ago

Commit 71cf0942 parents f7c4b76 9f122355 files · +49 −3Browse files

Unified · Split

5 files
  1. doc/APIchanges +4 −0
  2. libavfilter/af_resample.c +35 −0
  3. libavfilter/avfiltergraph.c +7 −1
  4. libavfilter/avfiltergraph.h +1 −0
  5. libavfilter/version.h +2 −2
doc/APIchanges+4−0
@@ -138,6 +138,10 @@ API changes, most recent first: · 137 unmodified lines
138138 2012-03-26 - a67d9cf - lavfi 2.66.100
139139 Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
140140
141+2013-xx-xx - xxxxxxx - lavfi 3.4.0 - avfiltergraph.h
142+ Add resample_lavr_opts to AVFilterGraph for setting libavresample options
143+ for auto-inserted resample filters.
144+
141145 2013-xx-xx - xxxxxxx - lavu 52.7.0 - dict.h
142146 Add av_dict_parse_string() to set multiple key/value pairs at once from a
143147 string.
libavfilter/af_resample.c+35−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include "libavutil/avassert.h"
2626 #include "libavutil/avstring.h"
2727 #include "libavutil/common.h"
28+#include "libavutil/dict.h"
2829 #include "libavutil/mathematics.h"
2930 #include "libavutil/opt.h"
3031
@@ -37,6 +38,7 @@ · 6 unmodified lines
3738
3839 typedef struct ResampleContext {
3940 AVAudioResampleContext *avr;
41+ AVDictionary *options;
4042
4143 int64_t next_pts;
4244
@@ -44,6 +46,29 @@ typedef struct ResampleContext { · 1 unmodified line
4446 int got_output;
4547 } ResampleContext;
4648
49+static av_cold int init(AVFilterContext *ctx, const char *args)
50+{
51+ ResampleContext *s = ctx->priv;
52+
53+ if (args) {
54+ int ret = av_dict_parse_string(&s->options, args, "=", ":", 0);
55+ if (ret < 0) {
56+ av_log(ctx, AV_LOG_ERROR, "error setting option string: %s\n", args);
57+ return ret;
58+ }
59+
60+ /* do not allow the user to override basic format options */
61+ av_dict_set(&s->options, "in_channel_layout", NULL, 0);
62+ av_dict_set(&s->options, "out_channel_layout", NULL, 0);
63+ av_dict_set(&s->options, "in_sample_fmt", NULL, 0);
64+ av_dict_set(&s->options, "out_sample_fmt", NULL, 0);
65+ av_dict_set(&s->options, "in_sample_rate", NULL, 0);
66+ av_dict_set(&s->options, "out_sample_rate", NULL, 0);
67+ }
68+
69+ return 0;
70+}
71+
4772 static av_cold void uninit(AVFilterContext *ctx)
4873 {
4974 ResampleContext *s = ctx->priv;
@@ -52,6 +77,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 2 unmodified lines
5277 avresample_close(s->avr);
5378 avresample_free(&s->avr);
5479 }
80+ av_dict_free(&s->options);
5581 }
5682
5783 static int query_formats(AVFilterContext *ctx)
@@ -103,6 +129,14 @@ static int config_output(AVFilterLink *outlink) · 45 unmodified lines
103129 if (!(s->avr = avresample_alloc_context()))
104130 return AVERROR(ENOMEM);
105131
132+ if (s->options) {
133+ AVDictionaryEntry *e = NULL;
134+ while ((e = av_dict_get(s->options, "", e, AV_DICT_IGNORE_SUFFIX)))
135+ av_log(ctx, AV_LOG_VERBOSE, "lavr option: %s=%s\n", e->key, e->value);
136+
137+ av_opt_set_dict(s->avr, &s->options);
138+ }
139+
106140 av_opt_set_int(s->avr, "in_channel_layout", inlink ->channel_layout, 0);
107141 av_opt_set_int(s->avr, "out_channel_layout", outlink->channel_layout, 0);
108142 av_opt_set_int(s->avr, "in_sample_fmt", inlink ->format, 0);
@@ -264,6 +298,7 @@ AVFilter avfilter_af_resample = { · 155 unmodified lines
264298 .description = NULL_IF_CONFIG_SMALL("Audio resampling and conversion."),
265299 .priv_size = sizeof(ResampleContext),
266300
301+ .init = init,
267302 .uninit = uninit,
268303 .query_formats = query_formats,
269304
libavfilter/avfiltergraph.c+7−1
@@ -68,6 +68,7 @@ void avfilter_graph_free(AVFilterGraph **graph) · 67 unmodified lines
6868 av_freep(&(*graph)->sink_links);
6969 av_freep(&(*graph)->scale_sws_opts);
7070 av_freep(&(*graph)->aresample_swr_opts);
71+ av_freep(&(*graph)->resample_lavr_opts);
7172 av_freep(&(*graph)->filters);
7273 av_freep(graph);
7374 }
@@ -323,8 +324,13 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 249 unmodified lines
323324
324325 snprintf(inst_name, sizeof(inst_name), "auto-inserted resampler %d",
325326 resampler_count++);
327+ scale_args[0] = '\0';
328+ if (graph->aresample_swr_opts)
329+ snprintf(scale_args, sizeof(scale_args), "%s",
330+ graph->aresample_swr_opts);
326331 if ((ret = avfilter_graph_create_filter(&convert, filter,
327− inst_name, graph->aresample_swr_opts, NULL, graph)) < 0)
332+ inst_name, graph->aresample_swr_opts,
333+ NULL, graph)) < 0)
328334 return ret;
329335 break;
330336 default:
libavfilter/avfiltergraph.h+1−0
@@ -45,6 +45,7 @@ typedef struct AVFilterGraph { · 44 unmodified lines
4545 int sink_links_count;
4646
4747 unsigned disable_auto_convert;
48+ char *resample_lavr_opts; ///< libavresample options to use for the auto-inserted resample filters
4849 } AVFilterGraph;
4950
5051 /**
libavfilter/version.h+2−2
@@ -29,8 +29,8 @@ · 28 unmodified lines
2929 #include "libavutil/avutil.h"
3030
3131 #define LIBAVFILTER_VERSION_MAJOR 3
32−#define LIBAVFILTER_VERSION_MINOR 39
33−#define LIBAVFILTER_VERSION_MICRO 101
32+#define LIBAVFILTER_VERSION_MINOR 40
33+#define LIBAVFILTER_VERSION_MICRO 100
3434
3535 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
3636 LIBAVFILTER_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t