mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
avcodec/noise_bsf: restore dropamount for backwards compatibility
This commit is contained in:
parent
ae94868a57
commit
b9176dbfb7
@ -538,11 +538,16 @@ Accepts an expression whose evaluation per-packet determines how often bytes in
|
||||
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 nor drop is specified,
|
||||
amount will be set to @var{-1}. See below for accepted variables.
|
||||
@item drop, dropamount
|
||||
@item drop
|
||||
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.
|
||||
@item dropamount
|
||||
Accepts a non-negative integer, which assigns a variable chance of it being dropped, roughly inverse
|
||||
in proportion to the value. Default is 0 which results in no drops. This option is kept for backwards
|
||||
compatibility and is equivalent to setting drop to a negative value with the same magnitude
|
||||
i.e. @code{dropamount=4} is the same as @code{drop=-4}. Ignored if drop is also specified.
|
||||
@end table
|
||||
|
||||
Both @code{amount} and @code{drop} accept expressions containing the following variables:
|
||||
|
@ -65,6 +65,7 @@ typedef struct NoiseContext {
|
||||
|
||||
char *amount_str;
|
||||
char *drop_str;
|
||||
int dropamount;
|
||||
|
||||
AVExpr *amount_pexpr;
|
||||
AVExpr *drop_pexpr;
|
||||
@ -81,7 +82,7 @@ static int noise_init(AVBSFContext *ctx)
|
||||
int ret;
|
||||
|
||||
if (!s->amount_str) {
|
||||
s->amount_str = !s->drop_str ? av_strdup("-1") : av_strdup("0");
|
||||
s->amount_str = (!s->drop_str && !s->dropamount) ? av_strdup("-1") : av_strdup("0");
|
||||
if (!s->amount_str)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
@ -93,6 +94,12 @@ static int noise_init(AVBSFContext *ctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (s->drop_str && s->dropamount) {
|
||||
av_log(ctx, AV_LOG_WARNING, "Both drop '%s' and dropamount=%d set. Ignoring dropamount.\n",
|
||||
s->drop_str, s->dropamount);
|
||||
s->dropamount = 0;
|
||||
}
|
||||
|
||||
if (s->drop_str) {
|
||||
ret = av_expr_parse(&s->drop_pexpr, s->drop_str,
|
||||
var_names, NULL, NULL, NULL, NULL, 0, ctx);
|
||||
@ -114,7 +121,7 @@ static int noise_init(AVBSFContext *ctx)
|
||||
static int noise(AVBSFContext *ctx, AVPacket *pkt)
|
||||
{
|
||||
NoiseContext *s = ctx->priv_data;
|
||||
int i, ret, amount, drop;
|
||||
int i, ret, amount, drop = 0;
|
||||
double res;
|
||||
|
||||
ret = ff_bsf_get_packet_ref(ctx, pkt);
|
||||
@ -156,10 +163,14 @@ static int noise(AVBSFContext *ctx, AVPacket *pkt)
|
||||
drop = !!res;
|
||||
}
|
||||
|
||||
if(s->dropamount) {
|
||||
drop = !(s->state % s->dropamount);
|
||||
}
|
||||
|
||||
av_log(ctx, AV_LOG_VERBOSE, "Stream #%d packet %d pts %"PRId64" - amount %d drop %d\n",
|
||||
pkt->stream_index, (unsigned int)s->var_values[VAR_N], pkt->pts, amount, drop);
|
||||
|
||||
if (s->drop_str && drop) {
|
||||
if (drop) {
|
||||
s->var_values[VAR_STATE] = ++s->state;
|
||||
av_packet_unref(pkt);
|
||||
return AVERROR(EAGAIN);
|
||||
@ -198,7 +209,7 @@ static void noise_close(AVBSFContext *bsf)
|
||||
static const AVOption options[] = {
|
||||
{ "amount", NULL, OFFSET(amount_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
|
||||
{ "drop", NULL, OFFSET(drop_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
|
||||
{ "dropamount", NULL, OFFSET(drop_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
|
||||
{ "dropamount", NULL, OFFSET(dropamount), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
|
@ -88,7 +88,7 @@ FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MXF_DEMUXER \
|
||||
MATROSKA_MUXER MATROSKA_DEMUXER \
|
||||
FRAMECRC_MUXER PIPE_PROTOCOL) \
|
||||
+= fate-matroska-mastering-display-metadata
|
||||
fate-matroska-mastering-display-metadata: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/Meridian-Apple_ProResProxy-HDR10.mxf matroska "-map 0 -map 0:0 -c:v:0 copy -c:v:1 ffv1 -c:a:0 copy -bsf:a:0 noise=amount=3 -filter:a:1 aresample -c:a:1 pcm_s16be -bsf:a:1 noise=amount=-1:dropamount=-4" "-map 0 -c copy" "" "-show_entries stream_side_data_list:stream=index,codec_name"
|
||||
fate-matroska-mastering-display-metadata: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/Meridian-Apple_ProResProxy-HDR10.mxf matroska "-map 0 -map 0:0 -c:v:0 copy -c:v:1 ffv1 -c:a:0 copy -bsf:a:0 noise=amount=3 -filter:a:1 aresample -c:a:1 pcm_s16be -bsf:a:1 noise=amount=-1:drop=-4" "-map 0 -c copy" "" "-show_entries stream_side_data_list:stream=index,codec_name"
|
||||
|
||||
# This test tests remuxing annex B H.264 into Matroska. It also tests writing
|
||||
# the correct interlaced flags and overriding the sample aspect ratio, leading
|
||||
|
Loading…
Reference in New Issue
Block a user