You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	af_aresample: support all swresample parameters.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
		| @@ -24,6 +24,8 @@ | |||||||
|  * resampling audio filter |  * resampling audio filter | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  | #include "libavutil/avstring.h" | ||||||
|  | #include "libavutil/opt.h" | ||||||
| #include "libswresample/swresample.h" | #include "libswresample/swresample.h" | ||||||
| #include "avfilter.h" | #include "avfilter.h" | ||||||
| #include "audio.h" | #include "audio.h" | ||||||
| @@ -38,16 +40,33 @@ typedef struct { | |||||||
| static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) | static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) | ||||||
| { | { | ||||||
|     AResampleContext *aresample = ctx->priv; |     AResampleContext *aresample = ctx->priv; | ||||||
|     int ret; |     int ret = 0; | ||||||
|  |     char *argd = av_strdup(args); | ||||||
|  |  | ||||||
|  |     aresample->swr = swr_alloc(); | ||||||
|  |     if (!aresample->swr) | ||||||
|  |         return AVERROR(ENOMEM); | ||||||
|  |  | ||||||
|     if (args) { |     if (args) { | ||||||
|         if ((ret = ff_parse_sample_rate(&aresample->out_rate, args, ctx)) < 0) |         char *ptr=argd, *token; | ||||||
|             return ret; |  | ||||||
|  |         while(token = av_strtok(ptr, ":", &ptr)) { | ||||||
|  |             char *value; | ||||||
|  |             av_strtok(token, "=", &value); | ||||||
|  |  | ||||||
|  |             if(value) { | ||||||
|  |                 if((ret=av_opt_set(aresample->swr, token, value, 0)) < 0) | ||||||
|  |                     goto end; | ||||||
|  |             } else if ((ret = ff_parse_sample_rate(&aresample->out_rate, token, ctx)) < 0) | ||||||
|  |                 goto end; | ||||||
|  |         } | ||||||
|  |  | ||||||
|     } else { |     } else { | ||||||
|         aresample->out_rate = -1; |         aresample->out_rate = -1; | ||||||
|     } |     } | ||||||
|  | end: | ||||||
|     return 0; |     av_free(argd); | ||||||
|  |     return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| static av_cold void uninit(AVFilterContext *ctx) | static av_cold void uninit(AVFilterContext *ctx) | ||||||
| @@ -105,7 +124,6 @@ static int config_output(AVFilterLink *outlink) | |||||||
|         outlink->sample_rate = aresample->out_rate; |         outlink->sample_rate = aresample->out_rate; | ||||||
|     outlink->time_base = (AVRational) {1, aresample->out_rate}; |     outlink->time_base = (AVRational) {1, aresample->out_rate}; | ||||||
|  |  | ||||||
|     //TODO: make the resampling parameters (filter size, phrase shift, linear, cutoff) configurable |  | ||||||
|     aresample->swr = swr_alloc_set_opts(aresample->swr, |     aresample->swr = swr_alloc_set_opts(aresample->swr, | ||||||
|                                         outlink->channel_layout, outlink->format, outlink->sample_rate, |                                         outlink->channel_layout, outlink->format, outlink->sample_rate, | ||||||
|                                         inlink->channel_layout, inlink->format, inlink->sample_rate, |                                         inlink->channel_layout, inlink->format, inlink->sample_rate, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user