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
1382012-03-26 - a67d9cf - lavfi 2.66.1001382012-03-26 - a67d9cf - lavfi 2.66.100
139 Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.139 Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
140 140
1412013-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
1412013-xx-xx - xxxxxxx - lavu 52.7.0 - dict.h1452013-xx-xx - xxxxxxx - lavu 52.7.0 - dict.h
142 Add av_dict_parse_string() to set multiple key/value pairs at once from a146 Add av_dict_parse_string() to set multiple key/value pairs at once from a
143 string.147 string.
libavfilter/af_resample.c+35−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
25#include "libavutil/avassert.h"25#include "libavutil/avassert.h"
26#include "libavutil/avstring.h"26#include "libavutil/avstring.h"
27#include "libavutil/common.h"27#include "libavutil/common.h"
28#include "libavutil/dict.h"
28#include "libavutil/mathematics.h"29#include "libavutil/mathematics.h"
29#include "libavutil/opt.h"30#include "libavutil/opt.h"
30 31
@@ -37,6 +38,7 @@ · 6 unmodified lines
37 38
38typedef struct ResampleContext {39typedef struct ResampleContext {
39 AVAudioResampleContext *avr;40 AVAudioResampleContext *avr;
41 AVDictionary *options;
40 42
41 int64_t next_pts;43 int64_t next_pts;
42 44
@@ -44,6 +46,29 @@ typedef struct ResampleContext { · 1 unmodified line
44 int got_output;46 int got_output;
45} ResampleContext;47} ResampleContext;
46 48
49static 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
47static av_cold void uninit(AVFilterContext *ctx)72static av_cold void uninit(AVFilterContext *ctx)
48{73{
49 ResampleContext *s = ctx->priv;74 ResampleContext *s = ctx->priv;
@@ -52,6 +77,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 2 unmodified lines
52 avresample_close(s->avr);77 avresample_close(s->avr);
53 avresample_free(&s->avr);78 avresample_free(&s->avr);
54 }79 }
80 av_dict_free(&s->options);
55}81}
56 82
57static int query_formats(AVFilterContext *ctx)83static int query_formats(AVFilterContext *ctx)
@@ -103,6 +129,14 @@ static int config_output(AVFilterLink *outlink) · 45 unmodified lines
103 if (!(s->avr = avresample_alloc_context()))129 if (!(s->avr = avresample_alloc_context()))
104 return AVERROR(ENOMEM);130 return AVERROR(ENOMEM);
105 131
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
106 av_opt_set_int(s->avr, "in_channel_layout", inlink ->channel_layout, 0);140 av_opt_set_int(s->avr, "in_channel_layout", inlink ->channel_layout, 0);
107 av_opt_set_int(s->avr, "out_channel_layout", outlink->channel_layout, 0);141 av_opt_set_int(s->avr, "out_channel_layout", outlink->channel_layout, 0);
108 av_opt_set_int(s->avr, "in_sample_fmt", inlink ->format, 0);142 av_opt_set_int(s->avr, "in_sample_fmt", inlink ->format, 0);
@@ -264,6 +298,7 @@ AVFilter avfilter_af_resample = { · 155 unmodified lines
264 .description = NULL_IF_CONFIG_SMALL("Audio resampling and conversion."),298 .description = NULL_IF_CONFIG_SMALL("Audio resampling and conversion."),
265 .priv_size = sizeof(ResampleContext),299 .priv_size = sizeof(ResampleContext),
266 300
301 .init = init,
267 .uninit = uninit,302 .uninit = uninit,
268 .query_formats = query_formats,303 .query_formats = query_formats,
269 304
libavfilter/avfiltergraph.c+7−1
@@ -68,6 +68,7 @@ void avfilter_graph_free(AVFilterGraph **graph) · 67 unmodified lines
68 av_freep(&(*graph)->sink_links);68 av_freep(&(*graph)->sink_links);
69 av_freep(&(*graph)->scale_sws_opts);69 av_freep(&(*graph)->scale_sws_opts);
70 av_freep(&(*graph)->aresample_swr_opts);70 av_freep(&(*graph)->aresample_swr_opts);
71 av_freep(&(*graph)->resample_lavr_opts);
71 av_freep(&(*graph)->filters);72 av_freep(&(*graph)->filters);
72 av_freep(graph);73 av_freep(graph);
73}74}
@@ -323,8 +324,13 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 249 unmodified lines
323 324
324 snprintf(inst_name, sizeof(inst_name), "auto-inserted resampler %d",325 snprintf(inst_name, sizeof(inst_name), "auto-inserted resampler %d",
325 resampler_count++);326 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);
326 if ((ret = avfilter_graph_create_filter(&convert, filter,331 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)
328 return ret;334 return ret;
329 break;335 break;
330 default:336 default:
libavfilter/avfiltergraph.h+1−0
@@ -45,6 +45,7 @@ typedef struct AVFilterGraph { · 44 unmodified lines
45 int sink_links_count;45 int sink_links_count;
46 46
47 unsigned disable_auto_convert;47 unsigned disable_auto_convert;
48 char *resample_lavr_opts; ///< libavresample options to use for the auto-inserted resample filters
48} AVFilterGraph;49} AVFilterGraph;
49 50
50/**51/**
libavfilter/version.h+2−2
@@ -29,8 +29,8 @@ · 28 unmodified lines
29#include "libavutil/avutil.h"29#include "libavutil/avutil.h"
30 30
31#define LIBAVFILTER_VERSION_MAJOR 331#define LIBAVFILTER_VERSION_MAJOR 3
32#define LIBAVFILTER_VERSION_MINOR 3932#define LIBAVFILTER_VERSION_MINOR 40
33#define LIBAVFILTER_VERSION_MICRO 10133#define LIBAVFILTER_VERSION_MICRO 100
34 34
35#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \35#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
36 LIBAVFILTER_VERSION_MINOR, \36 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