[FFmpeg-devel] [PATCH v2] avcodec/noise_bsf: add expr support

Michael Niedermayer michael at niedermayer.cc
Thu Jul 29 00:03:19 EEST 2021


On Wed, Jul 28, 2021 at 09:56:35AM +0530, Gyan Doshi wrote:
> ---
>  doc/bitstream_filters.texi |  64 ++++++++++++---
>  libavcodec/noise_bsf.c     | 161 +++++++++++++++++++++++++++++++++----
>  tests/fate/matroska.mak    |   2 +-
>  3 files changed, 199 insertions(+), 28 deletions(-)
> 
> diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
> index d10842ae47..46e4869f80 100644
> --- a/doc/bitstream_filters.texi
> +++ b/doc/bitstream_filters.texi
> @@ -534,20 +534,62 @@ container. Can be used for fuzzing or testing error resilience/concealment.
>  Parameters:
>  @table @option
>  @item amount
> -A numeral string, whose value is related to how often output bytes will
> -be modified. Therefore, values below or equal to 0 are forbidden, and
> -the lower the more frequent bytes will be modified, with 1 meaning
> -every byte is modified.
> - at item dropamount
> -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.
> +Accepts an expression whose evaluation per-packet determines how often bytes in that
> +packet will be modified. A value below 0 will result in a variable frequency.
> +Default is 0 which results in no modification. However, if neither amount or drop is specified,
> +amount will be set to @var{-1}. See below for accepted variables.
> + at item drop, dropamount
> +Accepts an expression evaluated per-packet whose value determines whether that packet is dropped.
> +Evaluation to a positive value results in the packet being dropped. Evaluation to a negative
> +value results in a variable chance of it being dropped, roughly inverse in proportion to the magnitude
> +of the value. Default is 0 which results in no drops. See below for accepted variables.
>  @end table
>  
> -The following example applies the modification to every byte but does not drop
> -any packets.
> +Both @code{amount} and @code{drop} accept expressions containing the following variables:
> +
> + at table @samp
> + at item n
> +The index of the packet, starting from zero.
> + at item tb
> +The timebase for packet timestamps.
> + at item pts
> +Packet presentation timestamp.
> + at item dts
> +Packet decoding timestamp.
> + at item nopts
> +Constant representing AV_NOPTS_VALUE.
> + at item startpts
> +First non-AV_NOPTS_VALUE PTS seen in the stream.
> + at item startdts
> +First non-AV_NOPTS_VALUE DTS seen in the stream.
> + at item duration
> + at itemx d
> +Packet duration, in timebase units.
> + at item pos
> +Packet position in input; may be -1 when unknown or not set.
> + at item size
> +Packet size, in bytes.
> + at item key
> +Whether packet is marked as a keyframe.
> + at item state
> +A pseudo random integer, primarily derived from the content of packet payload.
> + at end table
> +
> + at subsection Examples
> +Apply modification to every byte but don't drop any packets.
> + at example
> +ffmpeg -i INPUT -c copy -bsf noise=1 output.mkv
> + at end example
> +
> +Drop every video packet not marked as a keyframe after timestamp 30s but do not
> +modify any of the remaining packets.
> + at example
> +ffmpeg -i INPUT -c copy -bsf:v noise=drop='gt(t\,30)*not(key)' output.mkv
> + at end example
> +
> +Drop one second of audio every 10 seconds and add some random noise to the rest.
>  @example
> -ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
> +ffmpeg -i INPUT -c copy -bsf:a noise=amount=-1:drop='between(mod(t\,10)\,9\,10)' output.mkv
>  @end example
>  
>  @section null
> diff --git a/libavcodec/noise_bsf.c b/libavcodec/noise_bsf.c

Thanks for implementing eval support


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

If the United States is serious about tackling the national security threats 
related to an insecure 5G network, it needs to rethink the extent to which it
values corporate profits and government espionage over security.-Bruce Schneier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210728/2353db53/attachment.sig>


More information about the ffmpeg-devel mailing list