summaryrefslogtreecommitdiffstats
path: root/libavcodec/noise_bsf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/noise_bsf.c')
-rw-r--r--libavcodec/noise_bsf.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/libavcodec/noise_bsf.c b/libavcodec/noise_bsf.c
index 3b41dbf..84b9403 100644
--- a/libavcodec/noise_bsf.c
+++ b/libavcodec/noise_bsf.c
@@ -1,20 +1,20 @@
/*
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * 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.
*
- * Libav is distributed in the hope that it will be useful,
+ * 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 Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -31,6 +31,7 @@
typedef struct NoiseContext {
const AVClass *class;
int amount;
+ int dropamount;
unsigned int state;
} NoiseContext;
@@ -41,10 +42,19 @@ static int noise(AVBSFContext *ctx, AVPacket *out)
int amount = s->amount > 0 ? s->amount : (s->state % 10001 + 1);
int i, ret = 0;
+ if (amount <= 0)
+ return AVERROR(EINVAL);
+
ret = ff_bsf_get_packet(ctx, &in);
if (ret < 0)
return ret;
+ if (s->dropamount > 0 && s->state % s->dropamount == 0) {
+ s->state++;
+ av_packet_free(&in);
+ return AVERROR(EAGAIN);
+ }
+
ret = av_new_packet(out, in->size);
if (ret < 0)
goto fail;
@@ -70,6 +80,7 @@ fail:
#define OFFSET(x) offsetof(NoiseContext, x)
static const AVOption options[] = {
{ "amount", NULL, OFFSET(amount), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX },
+ { "dropamount", NULL, OFFSET(dropamount), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX },
{ NULL },
};
@@ -82,7 +93,7 @@ static const AVClass noise_class = {
const AVBitStreamFilter ff_noise_bsf = {
.name = "noise",
- .priv_data_size = sizeof(int),
+ .priv_data_size = sizeof(NoiseContext),
.priv_class = &noise_class,
.filter = noise,
};
OpenPOWER on IntegriCloud