[FFmpeg-devel] [PATCH] avcodec/noise_bsf: Add keyframes option.

Michael Niedermayer michael at niedermayer.cc
Wed Mar 7 20:03:12 EET 2018


On Tue, Mar 06, 2018 at 12:47:15PM -0800, Josh Allmann wrote:
> ---
>  doc/bitstream_filters.texi |  5 +++++
>  libavcodec/noise_bsf.c     | 12 ++++++++++++
>  libavcodec/version.h       |  2 +-
>  3 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
> index cfd81fa12d..a9f17f32ec 100644
> --- a/doc/bitstream_filters.texi
> +++ b/doc/bitstream_filters.texi
> @@ -399,6 +399,11 @@ every byte is modified.
>  A numeral string, whose value is related to how often packets will be dropped.
>  Therefore, values below or equal to 0 are forbidden, and the lower the more
>  frequent packets will be dropped, with 1 meaning every packet is dropped.
> + at item keyframes
> +A numeral string, whose value indicates the number of keyframe packets that
> +will be dropped from the beginning of the stream. This option will not add
> +noise to the source data. If used with stream copy, then -copyinkf should
> +be added to the output options as well.
>  @end table
>  
>  The following example applies the modification to every byte but does not drop
> diff --git a/libavcodec/noise_bsf.c b/libavcodec/noise_bsf.c
> index 84b94032ad..363ea4fc71 100644
> --- a/libavcodec/noise_bsf.c
> +++ b/libavcodec/noise_bsf.c
> @@ -32,6 +32,7 @@ typedef struct NoiseContext {
>      const AVClass *class;
>      int amount;
>      int dropamount;
> +    int keyframes;
>      unsigned int state;
>  } NoiseContext;
>  
> @@ -49,6 +50,13 @@ static int noise(AVBSFContext *ctx, AVPacket *out)
>      if (ret < 0)
>          return ret;
>  
> +    if (s->keyframes > 0 && in->flags & AV_PKT_FLAG_KEY) {
> +      s->keyframes--;
> +      if (!s->keyframes) s->keyframes = -1;
> +      av_packet_free(&in);
> +      return AVERROR(EAGAIN);
> +    }

I think keyframe should work like dropamount, that is randomly.

a non random droping could be added, maybe by the user specifying in
a list what to drop.
That would be more powerfull and flexible but probably not much harder
to implement. also keeping keyframes and dropamount behave the same
is more consistent

also the indention depth mismatches the surrounding code


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180307/6f590ab1/attachment.sig>


More information about the ffmpeg-devel mailing list