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

Michael Niedermayer michael at niedermayer.cc
Thu Mar 8 02:11:45 EET 2018


On Wed, Mar 07, 2018 at 11:37:00PM +0000, Josh Allmann wrote:
> On 7 March 2018 at 18:03, Michael Niedermayer <michael at niedermayer.cc> wrote:
> > 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);
> >> +    }
> >
> 
> Thanks for the feedback.
> 

> > 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
> 
> Something like this?
> 
> noise=keyframes=1,3,5,7
> 
> in order to drop the 1st, 3rd, 5th and 7th keyframes?

yes something like this


> 
> > also keeping keyframes and dropamount behave the same
> > is more consistent
> >
> 
> Do you mean more consistent with respect to the 'amount' param of added noise,
> as opposed to the patch's behavior of skipping noise if the 'keyframes' param is
> present?

both. 
i meant the param but as you mention the skiping, that doesnt seem expected by a
user either so it likely would be confusing.

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- 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/20180308/0f2221bd/attachment.sig>


More information about the ffmpeg-devel mailing list