[FFmpeg-devel] [PATCH] avcodec/noise_bsf: Add keyframes option.
Josh Allmann
joshua.allmann at gmail.com
Thu Mar 8 01:37:00 EET 2018
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?
> 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?
> 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
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list