diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-12-08 12:07:03 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-12-08 15:40:07 +0100 |
commit | 10db70d5e9c92f0464089476694d9a440cdac321 (patch) | |
tree | 4dfa17670afb93b371a339d22c7830c1966d6a35 /libavfilter | |
parent | 759e7a237fb60a5a0a157921867fcb73d90e2c53 (diff) | |
download | ffmpeg-10db70d5e9c92f0464089476694d9a440cdac321.tar.gz |
lavfi: drop af_volume_stefano.c in favor of af_volume_justin.c
Justin's version has more features but is otherwise equivalent from the
point of view of the syntax.
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/Makefile | 3 | ||||
-rw-r--r-- | libavfilter/af_volume.c (renamed from libavfilter/af_volume_justin.c) | 4 | ||||
-rw-r--r-- | libavfilter/af_volume_stefano.c | 201 | ||||
-rw-r--r-- | libavfilter/allfilters.c | 1 | ||||
-rw-r--r-- | libavfilter/version.h | 4 |
5 files changed, 5 insertions, 208 deletions
diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 7f9f0ef2a5..377bd4d701 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -71,8 +71,7 @@ OBJS-$(CONFIG_JOIN_FILTER) += af_join.o OBJS-$(CONFIG_PAN_FILTER) += af_pan.o OBJS-$(CONFIG_RESAMPLE_FILTER) += af_resample.o OBJS-$(CONFIG_SILENCEDETECT_FILTER) += af_silencedetect.o -OBJS-$(CONFIG_VOLUME_FILTER) += af_volume_stefano.o -OBJS-$(CONFIG_VOLUME_JUSTIN_FILTER) += af_volume_justin.o +OBJS-$(CONFIG_VOLUME_FILTER) += af_volume.o OBJS-$(CONFIG_VOLUMEDETECT_FILTER) += af_volumedetect.o OBJS-$(CONFIG_AEVALSRC_FILTER) += asrc_aevalsrc.o diff --git a/libavfilter/af_volume_justin.c b/libavfilter/af_volume.c index 0ba466a348..5ffa1fea4f 100644 --- a/libavfilter/af_volume_justin.c +++ b/libavfilter/af_volume.c @@ -299,8 +299,8 @@ static const AVFilterPad avfilter_af_volume_outputs[] = { { NULL } }; -AVFilter avfilter_af_volume_justin = { - .name = "volume_justin", +AVFilter avfilter_af_volume = { + .name = "volume", .description = NULL_IF_CONFIG_SMALL("Change input volume."), .query_formats = query_formats, .priv_size = sizeof(VolumeContext), diff --git a/libavfilter/af_volume_stefano.c b/libavfilter/af_volume_stefano.c deleted file mode 100644 index 7608083640..0000000000 --- a/libavfilter/af_volume_stefano.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2011 Stefano Sabatini - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * audio volume filter - * based on ffmpeg.c code - */ - -#include "libavutil/channel_layout.h" -#include "libavutil/eval.h" -#include "audio.h" -#include "avfilter.h" -#include "formats.h" - -typedef struct { - double volume; - int volume_i; -} VolumeContext; - -static av_cold int init(AVFilterContext *ctx, const char *args) -{ - VolumeContext *vol = ctx->priv; - char *tail; - int ret = 0; - - vol->volume = 1.0; - - if (args) { - /* parse the number as a decimal number */ - double d = strtod(args, &tail); - - if (*tail) { - if (!strcmp(tail, "dB")) { - /* consider the argument an adjustement in decibels */ - d = pow(10, d/20); - } else { - /* parse the argument as an expression */ - ret = av_expr_parse_and_eval(&d, args, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, 0, ctx); - } - } - - if (ret < 0) { - av_log(ctx, AV_LOG_ERROR, - "Invalid volume argument '%s'\n", args); - return AVERROR(EINVAL); - } - - if (d < 0 || d > 65536) { /* 65536 = INT_MIN / (128 * 256) */ - av_log(ctx, AV_LOG_ERROR, - "Negative or too big volume value %f\n", d); - return AVERROR(EINVAL); - } - - vol->volume = d; - } - - vol->volume_i = (int)(vol->volume * 256 + 0.5); - av_log(ctx, AV_LOG_VERBOSE, "volume=%f\n", vol->volume); - return 0; -} - -static int query_formats(AVFilterContext *ctx) -{ - AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts; - enum AVSampleFormat sample_fmts[] = { - AV_SAMPLE_FMT_U8, - AV_SAMPLE_FMT_S16, - AV_SAMPLE_FMT_S32, - AV_SAMPLE_FMT_FLT, - AV_SAMPLE_FMT_DBL, - AV_SAMPLE_FMT_NONE - }; - - layouts = ff_all_channel_layouts(); - if (!layouts) - return AVERROR(ENOMEM); - ff_set_common_channel_layouts(ctx, layouts); - - formats = ff_make_format_list(sample_fmts); - if (!formats) - return AVERROR(ENOMEM); - ff_set_common_formats(ctx, formats); - - formats = ff_all_samplerates(); - if (!formats) - return AVERROR(ENOMEM); - ff_set_common_samplerates(ctx, formats); - - return 0; -} - -static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples) -{ - VolumeContext *vol = inlink->dst->priv; - AVFilterLink *outlink = inlink->dst->outputs[0]; - const int nb_samples = insamples->audio->nb_samples * - av_get_channel_layout_nb_channels(insamples->audio->channel_layout); - const double volume = vol->volume; - const int volume_i = vol->volume_i; - int i; - - if (volume_i != 256) { - switch (insamples->format) { - case AV_SAMPLE_FMT_U8: - { - uint8_t *p = (void *)insamples->data[0]; - for (i = 0; i < nb_samples; i++) { - int v = (((*p - 128) * volume_i + 128) >> 8) + 128; - *p++ = av_clip_uint8(v); - } - break; - } - case AV_SAMPLE_FMT_S16: - { - int16_t *p = (void *)insamples->data[0]; - for (i = 0; i < nb_samples; i++) { - int v = ((int64_t)*p * volume_i + 128) >> 8; - *p++ = av_clip_int16(v); - } - break; - } - case AV_SAMPLE_FMT_S32: - { - int32_t *p = (void *)insamples->data[0]; - for (i = 0; i < nb_samples; i++) { - int64_t v = (((int64_t)*p * volume_i + 128) >> 8); - *p++ = av_clipl_int32(v); - } - break; - } - case AV_SAMPLE_FMT_FLT: - { - float *p = (void *)insamples->data[0]; - float scale = (float)volume; - for (i = 0; i < nb_samples; i++) { - *p++ *= scale; - } - break; - } - case AV_SAMPLE_FMT_DBL: - { - double *p = (void *)insamples->data[0]; - for (i = 0; i < nb_samples; i++) { - *p *= volume; - p++; - } - break; - } - } - } - return ff_filter_frame(outlink, insamples); -} - -static const AVFilterPad volume_inputs[] = { - { - .name = "default", - .type = AVMEDIA_TYPE_AUDIO, - .filter_frame = filter_frame, - .min_perms = AV_PERM_READ | AV_PERM_WRITE, - }, - { NULL }, -}; - -static const AVFilterPad volume_outputs[] = { - { - .name = "default", - .type = AVMEDIA_TYPE_AUDIO, - }, - { NULL }, -}; - -AVFilter avfilter_af_volume = { - .name = "volume", - .description = NULL_IF_CONFIG_SMALL("Change input volume."), - .query_formats = query_formats, - .priv_size = sizeof(VolumeContext), - .init = init, - .inputs = volume_inputs, - .outputs = volume_outputs, -}; diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index f9cacfc9bf..ffde5ce112 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -64,7 +64,6 @@ void avfilter_register_all(void) REGISTER_FILTER (RESAMPLE, resample, af); REGISTER_FILTER (SILENCEDETECT, silencedetect, af); REGISTER_FILTER (VOLUME, volume, af); - REGISTER_FILTER (VOLUME_JUSTIN, volume_justin, af); REGISTER_FILTER (VOLUMEDETECT,volumedetect,af); REGISTER_FILTER (AEVALSRC, aevalsrc, asrc); diff --git a/libavfilter/version.h b/libavfilter/version.h index 68a3543179..ed17978c2e 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -29,8 +29,8 @@ #include "libavutil/avutil.h" #define LIBAVFILTER_VERSION_MAJOR 3 -#define LIBAVFILTER_VERSION_MINOR 25 -#define LIBAVFILTER_VERSION_MICRO 102 +#define LIBAVFILTER_VERSION_MINOR 26 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ |