[FFmpeg-cvslog] avfilter/af_afftdn: add support for writable input frames

2022-02-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Feb 27 11:49:34 
2022 +0100| [2cb482aa7491f15fe8e62c9f366cb25b6ce7db17] | committer: Paul B Mahol

avfilter/af_afftdn: add support for writable input frames

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2cb482aa7491f15fe8e62c9f366cb25b6ce7db17
---

 libavfilter/af_afftdn.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index 403464baee..d7db625c35 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -1164,9 +1164,8 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
 AudioFFTDeNoiseContext *s = ctx->priv;
 const int output_mode = ctx->is_disabled ? IN_MODE : s->output_mode;
 const int offset = s->window_length - s->sample_advance;
-AVFrame *out = NULL;
+AVFrame *out;
 ThreadData td;
-int ret = 0;
 
 for (int ch = 0; ch < s->channels; ch++) {
 float *src = (float *)s->winframe->extended_data[ch];
@@ -1225,10 +1224,16 @@ static int output_frame(AVFilterLink *inlink, AVFrame 
*in)
 ff_filter_execute(ctx, filter_channel, &td, NULL,
   FFMIN(outlink->channels, ff_filter_get_nb_threads(ctx)));
 
-out = ff_get_audio_buffer(outlink, in->nb_samples);
-if (!out) {
-ret = AVERROR(ENOMEM);
-goto end;
+if (av_frame_is_writable(in)) {
+out = in;
+} else {
+out = ff_get_audio_buffer(outlink, in->nb_samples);
+if (!out) {
+av_frame_free(&in);
+return AVERROR(ENOMEM);
+}
+
+out->pts = in->pts;
 }
 
 for (int ch = 0; ch < inlink->channels; ch++) {
@@ -1251,23 +1256,18 @@ static int output_frame(AVFilterLink *inlink, AVFrame 
*in)
 dst[m] = orig[m] - src[m];
 break;
 default:
+if (in != out)
+av_frame_free(&in);
 av_frame_free(&out);
-ret = AVERROR_BUG;
-goto end;
+return AVERROR_BUG;
 }
 memmove(src, src + s->sample_advance, (s->window_length - 
s->sample_advance) * sizeof(*src));
 memset(src + (s->window_length - s->sample_advance), 0, 
s->sample_advance * sizeof(*src));
 }
 
-out->pts = in->pts;
-
-ret = ff_filter_frame(outlink, out);
-if (ret < 0)
-goto end;
-end:
-av_frame_free(&in);
-
-return ret;
+if (out != in)
+av_frame_free(&in);
+return ff_filter_frame(outlink, out);
 }
 
 static int activate(AVFilterContext *ctx)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/af_afftdn: add more verbose options aliases

2022-02-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Feb 27 12:00:21 
2022 +0100| [0d0002cd20b496c96d659b21b7cd462a100ebbc9] | committer: Paul B Mahol

avfilter/af_afftdn: add more verbose options aliases

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0d0002cd20b496c96d659b21b7cd462a100ebbc9
---

 doc/filters.texi| 32 
 libavfilter/af_afftdn.c | 15 +++
 2 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 0650879cfa..25a11fcd10 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1282,64 +1282,64 @@ Denoise audio samples with FFT.
 A description of the accepted parameters follows.
 
 @table @option
-@item nr
+@item noise_reduction, nr
 Set the noise reduction in dB, allowed range is 0.01 to 97.
 Default value is 12 dB.
 
-@item nf
+@item noise_floor, nf
 Set the noise floor in dB, allowed range is -80 to -20.
 Default value is -50 dB.
 
-@item nt
+@item noise_type, nt
 Set the noise type.
 
 It accepts the following values:
 @table @option
-@item w
+@item white, w
 Select white noise.
 
-@item v
+@item vinyl, v
 Select vinyl noise.
 
-@item s
+@item shellac, s
 Select shellac noise.
 
-@item c
+@item custom, c
 Select custom noise, defined in @code{bn} option.
 
 Default value is white noise.
 @end table
 
-@item bn
+@item band_noise, bn
 Set custom band noise for every one of 15 bands.
 Bands are separated by ' ' or '|'.
 
-@item rf
+@item residual_floor, rf
 Set the residual floor in dB, allowed range is -80 to -20.
 Default value is -38 dB.
 
-@item tn
+@item track_noise, tn
 Enable noise tracking. By default is disabled.
 With this enabled, noise floor is automatically adjusted.
 
-@item tr
+@item track_residual, tr
 Enable residual tracking. By default is disabled.
 
-@item om
+@item output_mode, om
 Set the output mode.
 
 It accepts the following values:
 @table @option
-@item i
+@item input, i
 Pass input unchanged.
 
-@item o
+@item output, o
 Pass noise filtered out.
 
-@item n
+@item noise, n
 Pass only noise.
 
-Default value is @var{o}.
+Default value is @var{output}.
 @end table
 @end table
 
diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index 628336b18b..2758ae8a8d 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -145,20 +145,35 @@ typedef struct AudioFFTDeNoiseContext {
 #define AFR 
AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
 static const AVOption afftdn_options[] = {
+{ "noise_reduction", "set the noise reduction",OFFSET(noise_reduction), 
AV_OPT_TYPE_FLOAT,{.dbl = 12},   .01, 97, AFR },
 { "nr", "set the noise reduction",OFFSET(noise_reduction), 
AV_OPT_TYPE_FLOAT,  {.dbl = 12},  .01, 97, AFR },
+{ "noise_floor", "set the noise floor",OFFSET(noise_floor),
AV_OPT_TYPE_FLOAT,  {.dbl =-50},  -80,-20, AFR },
 { "nf", "set the noise floor",OFFSET(noise_floor), 
AV_OPT_TYPE_FLOAT,  {.dbl =-50},  -80,-20, AFR },
+{ "noise_type", "set the noise type", OFFSET(noise_type),  
AV_OPT_TYPE_INT,{.i64 = WHITE_NOISE}, WHITE_NOISE, NB_NOISE-1, AF, "type" },
 { "nt", "set the noise type", OFFSET(noise_type),  
AV_OPT_TYPE_INT,{.i64 = WHITE_NOISE}, WHITE_NOISE, NB_NOISE-1, AF, "type" },
+{  "white", "white noise",0,   
AV_OPT_TYPE_CONST,  {.i64 = WHITE_NOISE},   0,  0, AF, "type" },
 {  "w", "white noise",0,   
AV_OPT_TYPE_CONST,  {.i64 = WHITE_NOISE},   0,  0, AF, "type" },
+{  "vinyl", "vinyl noise",0,   
AV_OPT_TYPE_CONST,  {.i64 = VINYL_NOISE},   0,  0, AF, "type" },
 {  "v", "vinyl noise",0,   
AV_OPT_TYPE_CONST,  {.i64 = VINYL_NOISE},   0,  0, AF, "type" },
+{  "shellac", "shellac noise",0,   
AV_OPT_TYPE_CONST,  {.i64 = SHELLAC_NOISE}, 0,  0, AF, "type" },
 {  "s", "shellac noise",  0,   
AV_OPT_TYPE_CONST,  {.i64 = SHELLAC_NOISE}, 0,  0, AF, "type" },
+{  "custom", "custom noise",  0,   
AV_OPT_TYPE_CONST,  {.i64 = CUSTOM_NOISE},  0,  0, AF, "type" },
 {  "c", "custom noise",   0,   
AV_OPT_TYPE_CONST,  {.i64 = CUSTOM_NOISE},  0,  0, AF, "type" },
+{ "band_noise", "set the custom bands noise", OFFSET(band_noise_str),  
AV_OPT_TYPE_STRING, {.str = 0}, 0,  0, AF },
 { "bn", "set the custom bands noise", OFFSET(band_noise_str),  
AV_OPT_TYPE_STRING, {.str = 0}, 0,  0, AF },
+{ "residual_floor", "set the residual floor",OFFSET(residual_floor),  
AV_OPT_TYPE_FLOAT, {.dbl =-38},-80,-20, AFR },
 { "rf", "set the residual floor", OFFSET(residual_floor),  
AV_OPT_TYPE_FLOAT,  {.dbl =-38},  -80,-20, AFR },
+{ "track_noise", "track noise",   OFFSET(track_noise), 
AV_OPT_TYPE_BOOL,   {.i64 

[FFmpeg-cvslog] avfilter/af_afftdn: remove ThreadData struct code

2022-02-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Feb 27 11:52:00 
2022 +0100| [592cef61353b1712745a121c68df0c26178db86c] | committer: Paul B Mahol

avfilter/af_afftdn: remove ThreadData struct code

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=592cef61353b1712745a121c68df0c26178db86c
---

 libavfilter/af_afftdn.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index d7db625c35..628336b18b 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -1083,15 +1083,10 @@ static void set_noise_profile(AudioFFTDeNoiseContext *s,
 s->noise_floor = new_noise_floor;
 }
 
-typedef struct ThreadData {
-AVFrame *in;
-} ThreadData;
-
 static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
 {
 AudioFFTDeNoiseContext *s = ctx->priv;
-ThreadData *td = arg;
-AVFrame *in = td->in;
+AVFrame *in = arg;
 const int start = (in->channels * jobnr) / nb_jobs;
 const int end = (in->channels * (jobnr+1)) / nb_jobs;
 
@@ -1165,7 +1160,6 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
 const int output_mode = ctx->is_disabled ? IN_MODE : s->output_mode;
 const int offset = s->window_length - s->sample_advance;
 AVFrame *out;
-ThreadData td;
 
 for (int ch = 0; ch < s->channels; ch++) {
 float *src = (float *)s->winframe->extended_data[ch];
@@ -1220,8 +1214,7 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
 }
 
 s->block_count++;
-td.in = s->winframe;
-ff_filter_execute(ctx, filter_channel, &td, NULL,
+ff_filter_execute(ctx, filter_channel, s->winframe, NULL,
   FFMIN(outlink->channels, ff_filter_get_nb_threads(ctx)));
 
 if (av_frame_is_writable(in)) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/af_tremolo: add timeline support

2022-02-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Feb 27 15:27:49 
2022 +0100| [57580376f7e467e5468d1ddb47ba3995130f732e] | committer: Paul B Mahol

avfilter/af_tremolo: add timeline support

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=57580376f7e467e5468d1ddb47ba3995130f732e
---

 libavfilter/af_tremolo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/af_tremolo.c b/libavfilter/af_tremolo.c
index b34a7b79f7..61c5066bdc 100644
--- a/libavfilter/af_tremolo.c
+++ b/libavfilter/af_tremolo.c
@@ -137,4 +137,5 @@ const AVFilter ff_af_tremolo = {
 FILTER_INPUTS(avfilter_af_tremolo_inputs),
 FILTER_OUTPUTS(avfilter_af_tremolo_outputs),
 FILTER_SINGLE_SAMPLEFMT(AV_SAMPLE_FMT_DBL),
+.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/af_vibrato: add timeline support

2022-02-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Feb 27 16:29:31 
2022 +0100| [8bcb7d49f9d2e7dbb7cbdb84ac4ea9a6e217bda0] | committer: Paul B Mahol

avfilter/af_vibrato: add timeline support

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8bcb7d49f9d2e7dbb7cbdb84ac4ea9a6e217bda0
---

 libavfilter/af_vibrato.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/af_vibrato.c b/libavfilter/af_vibrato.c
index 2cf1364273..fbb59059b0 100644
--- a/libavfilter/af_vibrato.c
+++ b/libavfilter/af_vibrato.c
@@ -71,7 +71,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 av_frame_copy_props(out, in);
 }
 
-
 for (n = 0; n < in->nb_samples; n++) {
 double integer, decimal;
 decimal = modf(s->depth * s->wave_table[s->wave_table_index], 
&integer);
@@ -175,4 +174,5 @@ const AVFilter ff_af_vibrato = {
 FILTER_INPUTS(avfilter_af_vibrato_inputs),
 FILTER_OUTPUTS(avfilter_af_vibrato_outputs),
 FILTER_SINGLE_SAMPLEFMT(AV_SAMPLE_FMT_DBLP),
+.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/af_acrusher: add timeline support

2022-02-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Feb 27 16:52:48 
2022 +0100| [b15c26a22cfad3d8c677bb397c734f88607f07ea] | committer: Paul B Mahol

avfilter/af_acrusher: add timeline support

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b15c26a22cfad3d8c677bb397c734f88607f07ea
---

 libavfilter/af_acrusher.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_acrusher.c b/libavfilter/af_acrusher.c
index 14d66e88ea..6295646c04 100644
--- a/libavfilter/af_acrusher.c
+++ b/libavfilter/af_acrusher.c
@@ -248,7 +248,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 double sample = src[c] * level_in;
 
 sample = mix * samplereduction(s, &s->sr[c], sample) + src[c] * 
(1. - mix) * level_in;
-dst[c] = bitreduction(s, sample) * level_out;
+dst[c] = ctx->is_disabled ? src[c] : bitreduction(s, sample) * 
level_out;
 }
 src += c;
 dst += c;
@@ -342,4 +342,5 @@ const AVFilter ff_af_acrusher = {
 FILTER_OUTPUTS(avfilter_af_acrusher_outputs),
 FILTER_SINGLE_SAMPLEFMT(AV_SAMPLE_FMT_DBL),
 .process_command = process_command,
+.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
 };

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/af_dynaudnorm: make frame writable if it may be changed

2022-02-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Feb 27 18:46:03 
2022 +0100| [b9f91a7cbcf12564ea5205af0bd462dc3541ce40] | committer: Paul B Mahol

avfilter/af_dynaudnorm: make frame writable if it may be changed

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b9f91a7cbcf12564ea5205af0bd462dc3541ce40
---

 libavfilter/af_dynaudnorm.c | 27 +++
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
index 121a3ef5d7..4935b09d08 100644
--- a/libavfilter/af_dynaudnorm.c
+++ b/libavfilter/af_dynaudnorm.c
@@ -631,15 +631,20 @@ static void 
perform_compression(DynamicAudioNormalizerContext *s, AVFrame *frame
 }
 }
 
-static void analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame)
+static int analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame)
 {
-if (s->dc_correction) {
-perform_dc_correction(s, frame);
+if (s->dc_correction || s->compress_factor > DBL_EPSILON) {
+int ret;
+
+if ((ret = av_frame_make_writable(frame)) < 0)
+return ret;
 }
 
-if (s->compress_factor > DBL_EPSILON) {
+if (s->dc_correction)
+perform_dc_correction(s, frame);
+
+if (s->compress_factor > DBL_EPSILON)
 perform_compression(s, frame);
-}
 
 if (s->channels_coupled) {
 const local_gain gain = get_max_local_gain(s, frame, -1);
@@ -653,6 +658,8 @@ static void analyze_frame(DynamicAudioNormalizerContext *s, 
AVFrame *frame)
 for (c = 0; c < s->channels; c++)
 update_gain_history(s, c, get_max_local_gain(s, frame, c));
 }
+
+return 0;
 }
 
 static void amplify_frame(DynamicAudioNormalizerContext *s, AVFrame *in,
@@ -684,7 +691,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 AVFilterContext *ctx = inlink->dst;
 DynamicAudioNormalizerContext *s = ctx->priv;
 AVFilterLink *outlink = ctx->outputs[0];
-int ret = 1;
+int ret;
 
 while (((s->queue.available >= s->filter_size) ||
 (s->eof && s->queue.available)) &&
@@ -712,9 +719,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 if (out != in)
 av_frame_free(&in);
 ret = ff_filter_frame(outlink, out);
+if (ret < 0)
+return ret;
 }
 
-analyze_frame(s, in);
+ret = analyze_frame(s, in);
+if (ret < 0)
+return ret;
 if (!s->eof) {
 ff_bufqueue_add(ctx, &s->queue, in);
 cqueue_enqueue(s->is_enabled, !ctx->is_disabled);
@@ -722,7 +733,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 av_frame_free(&in);
 }
 
-return ret;
+return 1;
 }
 
 static int flush_buffer(DynamicAudioNormalizerContext *s, AVFilterLink *inlink,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/af_dynaudnorm: allow to filter subset of channels

2022-02-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Feb 27 19:37:10 
2022 +0100| [a9124a75b0a2bce3c810bc5dfd5c2360764c92dd] | committer: Paul B Mahol

avfilter/af_dynaudnorm: allow to filter subset of channels

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a9124a75b0a2bce3c810bc5dfd5c2360764c92dd
---

 doc/filters.texi|  3 +++
 libavfilter/af_dynaudnorm.c | 25 +
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 25a11fcd10..b3ae139613 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -4389,6 +4389,9 @@ If input frame volume is above this value frame will be 
normalized.
 Otherwise frame may not be normalized at all. The default value is set
 to 0, which means all input frames will be normalized.
 This option is mostly useful if digital noise is not wanted to be amplified.
+
+@item channels, h
+Specify which channels to filter, by default all available channels are 
filtered.
 @end table
 
 @subsection Commands
diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
index 4935b09d08..7d779856a8 100644
--- a/libavfilter/af_dynaudnorm.c
+++ b/libavfilter/af_dynaudnorm.c
@@ -27,6 +27,7 @@
 #include 
 
 #include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
 
 #define MIN_FILTER_SIZE 3
@@ -76,6 +77,7 @@ typedef struct DynamicAudioNormalizerContext {
 
 int channels;
 int eof;
+uint64_t channels_to_filter;
 int64_t pts;
 
 cqueue **gain_history_original;
@@ -110,6 +112,8 @@ static const AVOption dynaudnorm_options[] = {
 { "s",   "set the compress factor",  
OFFSET(compress_factor),   AV_OPT_TYPE_DOUBLE, {.dbl = 0.0},  0.0,  30.0, FLAGS 
},
 { "threshold",   "set the threshold value",  OFFSET(threshold),
 AV_OPT_TYPE_DOUBLE, {.dbl = 0.0},  0.0,   1.0, FLAGS },
 { "t",   "set the threshold value",  OFFSET(threshold),
 AV_OPT_TYPE_DOUBLE, {.dbl = 0.0},  0.0,   1.0, FLAGS },
+{ "channels","set channels to filter",   
OFFSET(channels_to_filter),AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, 
INT64_MAX, FLAGS },
+{ "h",   "set channels to filter",   
OFFSET(channels_to_filter),AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, 
INT64_MAX, FLAGS },
 { NULL }
 };
 
@@ -514,6 +518,11 @@ static inline double update_value(double new, double old, 
double aggressiveness)
 return aggressiveness * new + (1.0 - aggressiveness) * old;
 }
 
+static inline int bypass_channel(DynamicAudioNormalizerContext *s, AVFrame 
*frame, int ch)
+{
+return !(av_channel_layout_extract_channel(frame->channel_layout, ch) & 
s->channels_to_filter);
+}
+
 static void perform_dc_correction(DynamicAudioNormalizerContext *s, AVFrame 
*frame)
 {
 const double diff = 1.0 / frame->nb_samples;
@@ -521,6 +530,7 @@ static void 
perform_dc_correction(DynamicAudioNormalizerContext *s, AVFrame *fra
 int c, i;
 
 for (c = 0; c < s->channels; c++) {
+const int bypass = bypass_channel(s, frame, c);
 double *dst_ptr = (double *)frame->extended_data[c];
 double current_average_value = 0.0;
 double prev_value;
@@ -531,7 +541,7 @@ static void 
perform_dc_correction(DynamicAudioNormalizerContext *s, AVFrame *fra
 prev_value = is_first_frame ? current_average_value : 
s->dc_correction_value[c];
 s->dc_correction_value[c] = is_first_frame ? current_average_value : 
update_value(current_average_value, s->dc_correction_value[c], 0.1);
 
-for (i = 0; i < frame->nb_samples; i++) {
+for (i = 0; i < frame->nb_samples && !bypass; i++) {
 dst_ptr[i] -= fade(prev_value, s->dc_correction_value[c], i, 
frame->nb_samples);
 }
 }
@@ -604,6 +614,11 @@ static void 
perform_compression(DynamicAudioNormalizerContext *s, AVFrame *frame
 
 for (c = 0; c < s->channels; c++) {
 double *const dst_ptr = (double *)frame->extended_data[c];
+const int bypass = bypass_channel(s, frame, c);
+
+if (bypass)
+continue;
+
 for (i = 0; i < frame->nb_samples; i++) {
 const double localThresh = fade(prev_actual_thresh, 
curr_actual_thresh, i, frame->nb_samples);
 dst_ptr[i] = copysign(bound(localThresh, fabs(dst_ptr[i])), 
dst_ptr[i]);
@@ -611,19 +626,20 @@ static void 
perform_compression(DynamicAudioNormalizerContext *s, AVFrame *frame
 }
 } else {
 for (c = 0; c < s->channels; c++) {
+const int bypass = bypass_channel(s, frame, c);
 const double standard_deviation = compute_frame_std_dev(s, frame, 
c);
 const double current_threshold  = setup_compress_thresh(FFMIN(1.0, 
s->compress_factor * standard_deviation));
-
 const double prev_value = is_first_frame ? current_threshold : 
s->compress_threshold[c];
 double prev_actual_t

[FFmpeg-cvslog] avfilter/af_dynaudnorm: allocate new frame instead of making it writable

2022-02-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Feb 27 19:58:06 
2022 +0100| [a2dbd1778848c260fc9ef9c903ebc7a3cb67968e] | committer: Paul B Mahol

avfilter/af_dynaudnorm: allocate new frame instead of making it writable

Later case does not use frame pool at all.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a2dbd1778848c260fc9ef9c903ebc7a3cb67968e
---

 libavfilter/af_dynaudnorm.c | 35 +++
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
index 7d779856a8..8015c8429c 100644
--- a/libavfilter/af_dynaudnorm.c
+++ b/libavfilter/af_dynaudnorm.c
@@ -647,23 +647,42 @@ static void 
perform_compression(DynamicAudioNormalizerContext *s, AVFrame *frame
 }
 }
 
-static int analyze_frame(DynamicAudioNormalizerContext *s, AVFrame *frame)
+static int analyze_frame(DynamicAudioNormalizerContext *s, AVFilterLink 
*outlink, AVFrame **frame)
 {
 if (s->dc_correction || s->compress_factor > DBL_EPSILON) {
 int ret;
 
-if ((ret = av_frame_make_writable(frame)) < 0)
-return ret;
+if (!av_frame_is_writable(*frame)) {
+AVFrame *out = ff_get_audio_buffer(outlink, (*frame)->nb_samples);
+
+if (!out) {
+av_frame_free(frame);
+return AVERROR(ENOMEM);
+}
+ret = av_frame_copy_props(out, *frame);
+if (ret < 0) {
+av_frame_free(&out);
+return ret;
+}
+ret = av_frame_copy(out, *frame);
+if (ret < 0) {
+av_frame_free(&out);
+return ret;
+}
+
+av_frame_free(frame);
+*frame = out;
+}
 }
 
 if (s->dc_correction)
-perform_dc_correction(s, frame);
+perform_dc_correction(s, *frame);
 
 if (s->compress_factor > DBL_EPSILON)
-perform_compression(s, frame);
+perform_compression(s, *frame);
 
 if (s->channels_coupled) {
-const local_gain gain = get_max_local_gain(s, frame, -1);
+const local_gain gain = get_max_local_gain(s, *frame, -1);
 int c;
 
 for (c = 0; c < s->channels; c++)
@@ -672,7 +691,7 @@ static int analyze_frame(DynamicAudioNormalizerContext *s, 
AVFrame *frame)
 int c;
 
 for (c = 0; c < s->channels; c++)
-update_gain_history(s, c, get_max_local_gain(s, frame, c));
+update_gain_history(s, c, get_max_local_gain(s, *frame, c));
 }
 
 return 0;
@@ -740,7 +759,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 return ret;
 }
 
-ret = analyze_frame(s, in);
+ret = analyze_frame(s, outlink, &in);
 if (ret < 0)
 return ret;
 if (!s->eof) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/vf_amplify: improve performance

2022-02-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Feb 27 23:40:57 
2022 +0100| [567cab3bd8b797f46506e0b363d6a1255556] | committer: Paul B Mahol

avfilter/vf_amplify: improve performance

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=567cab3bd8b797f46506e0b363d6a1255556
---

 libavfilter/vf_amplify.c | 22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/libavfilter/vf_amplify.c b/libavfilter/vf_amplify.c
index 3c393ecfb0..0891d26413 100644
--- a/libavfilter/vf_amplify.c
+++ b/libavfilter/vf_amplify.c
@@ -96,8 +96,7 @@ typedef struct ThreadData {
 } ThreadData;
 
 #define AMPLIFY_SLICE(type, stype, clip)   
 \
-const stype llimit = s->llimit;
 \
-const stype hlimit = s->hlimit;
 \
+const stype limit[2] = { s->llimit, s->hlimit };   
 \

 \
 for (int p = 0; p < s->nb_planes; p++) {   
 \
 const int slice_start = (s->height[p] * jobnr) / nb_jobs;  
 \
@@ -116,23 +115,19 @@ typedef struct ThreadData {
 for (int y = slice_start; y < slice_end; y++) {
 \
 for (int x = 0; x < s->linesize[p] / sizeof(type); x++) {  
 \
 stype src = *(type *)(in[radius]->data[p] + y * 
in[radius]->linesize[p] + x * sizeof(type));\
-float diff, avg;   
 \
+float diff, abs_diff, avg; 
 \
 stype sum = 0; 
 \

 \
 for (int i = 0; i < nb_inputs; i++) {  
 \
 sum += *(type *)(in[i]->data[p] + y * in[i]->linesize[p] + 
x * sizeof(type));\
 }  
 \

 \
-avg = sum / (float)nb_inputs;  
 \
+avg = sum * scale; 
 \
 diff = src - avg;  
 \
+abs_diff = fabsf(diff);
 \

 \
-if (fabsf(diff) < threshold && fabsf(diff) > tolerance) {  
 \
-stype amp; 
 \
-if (diff < 0) {
 \
-amp = -FFMIN(FFABS(diff * factor), llimit);
 \
-} else {   
 \
-amp = FFMIN(FFABS(diff * factor), hlimit); 
 \
-}  
 \
+if (abs_diff < threshold && abs_diff > tolerance) {
 \
+float amp = copysignf(fminf(abs_diff * factor, limit[diff 
>= 0]), diff);\
 dst[x] = clip(src + amp, depth);   
 \
 } else {   
 \
 dst[x] = src;  
 \
@@ -143,8 +138,8 @@ typedef struct ThreadData {
 }  
 \
 }
 
-#define CLIP8(x, depth) av_clip_uint8(x)
-#define CLIP16(x, depth) av_clip_uintp2_c(x, depth)
+#define CLIP8(x, depth) av_clip_uint8(lrintf(x))
+#define CLIP16(x, depth) av_clip_uintp2_c(lrintf(x), depth)
 #define NOP(x, depth) (x)
 
 static int amplify_frame(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
@@ -157,6 +152,7 @@ static int amplify_frame(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs
 const int nb_inputs = s->nb_inputs;
 const float threshold = s->threshold;
 const float tolerance = s->tolerance;
+const float scale = 1.f / nb_inputs;
 const float factor = s->factor;
 const int depth = s->de

[FFmpeg-cvslog] libavcodec/vaapi_encode: Add async_depth to vaapi_encoder to increase performance

2022-02-27 Thread Wenbin Chen
ffmpeg | branch: master | Wenbin Chen  | 
Fri Feb 18 11:07:47 2022 +0800| [d165ce22a4a7cc4ed60238ce8f3d5dcbbad3e266] | 
committer: Haihao Xiang

libavcodec/vaapi_encode: Add async_depth to vaapi_encoder to increase 
performance

Fix: #7706. After commit 5fdcf85bbffe7451c2, vaapi encoder's performance
decrease. The reason is that vaRenderPicture() and vaSyncBuffer() are
called at the same time (vaRenderPicture() always followed by a
vaSyncBuffer()). Now I changed them to be called in a asynchronous way,
which will make better use of hardware.
Async_depth is added to increase encoder's performance. The frames that
are sent to hardware are stored in a fifo. Encoder will sync output
after async fifo is full.

Signed-off-by: Wenbin Chen 
Signed-off-by: Haihao Xiang 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d165ce22a4a7cc4ed60238ce8f3d5dcbbad3e266
---

 doc/encoders.texi |  6 +
 libavcodec/vaapi_encode.c | 64 +--
 libavcodec/vaapi_encode.h | 16 ++--
 3 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 9afb920f69..64e8c5d129 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3591,6 +3591,12 @@ will refer only to P- or I-frames.  When set to greater 
values multiple layers
 of B-frames will be present, frames in each layer only referring to frames in
 higher layers.
 
+@item async_depth
+Maximum processing parallelism. Increase this to improve single channel
+performance. This option doesn't work if driver doesn't implement vaSyncBuffer
+function. Please make sure there are enough hw_frames allocated if a large
+number of async_depth is used.
+
 @item rc_mode
 Set the rate control mode to use.  A given driver may only support a subset of
 modes.
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 3f8c8ace2a..8c6e881702 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -965,8 +965,10 @@ static int vaapi_encode_pick_next(AVCodecContext *avctx,
 if (!pic && ctx->end_of_stream) {
 --b_counter;
 pic = ctx->pic_end;
-if (pic->encode_issued)
+if (pic->encode_complete)
 return AVERROR_EOF;
+else if (pic->encode_issued)
+return AVERROR(EAGAIN);
 }
 
 if (!pic) {
@@ -1137,7 +1139,8 @@ static int vaapi_encode_send_frame(AVCodecContext *avctx, 
AVFrame *frame)
 if (ctx->input_order == ctx->decode_delay)
 ctx->dts_pts_diff = pic->pts - ctx->first_pts;
 if (ctx->output_delay > 0)
-ctx->ts_ring[ctx->input_order % (3 * ctx->output_delay)] = 
pic->pts;
+ctx->ts_ring[ctx->input_order %
+(3 * ctx->output_delay + ctx->async_depth)] = pic->pts;
 
 pic->display_order = ctx->input_order;
 ++ctx->input_order;
@@ -1191,18 +1194,47 @@ int ff_vaapi_encode_receive_packet(AVCodecContext 
*avctx, AVPacket *pkt)
 return AVERROR(EAGAIN);
 }
 
-pic = NULL;
-err = vaapi_encode_pick_next(avctx, &pic);
-if (err < 0)
-return err;
-av_assert0(pic);
+if (ctx->has_sync_buffer_func) {
+pic = NULL;
+
+if (av_fifo_can_write(ctx->encode_fifo)) {
+err = vaapi_encode_pick_next(avctx, &pic);
+if (!err) {
+av_assert0(pic);
+pic->encode_order = ctx->encode_order +
+av_fifo_can_read(ctx->encode_fifo);
+err = vaapi_encode_issue(avctx, pic);
+if (err < 0) {
+av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
+return err;
+}
+av_fifo_write(ctx->encode_fifo, &pic, 1);
+}
+}
 
-pic->encode_order = ctx->encode_order++;
+if (!av_fifo_can_read(ctx->encode_fifo))
+return err;
 
-err = vaapi_encode_issue(avctx, pic);
-if (err < 0) {
-av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
-return err;
+// More frames can be buffered
+if (av_fifo_can_write(ctx->encode_fifo) && !ctx->end_of_stream)
+return AVERROR(EAGAIN);
+
+av_fifo_read(ctx->encode_fifo, &pic, 1);
+ctx->encode_order = pic->encode_order + 1;
+} else {
+pic = NULL;
+err = vaapi_encode_pick_next(avctx, &pic);
+if (err < 0)
+return err;
+av_assert0(pic);
+
+pic->encode_order = ctx->encode_order++;
+
+err = vaapi_encode_issue(avctx, pic);
+if (err < 0) {
+av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
+return err;
+}
 }
 
 err = vaapi_encode_output(avctx, pic, pkt);
@@ -1220,7 +1252,7 @@ int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff;
 } else {
 pkt->dts = ctx->ts_ring

[FFmpeg-cvslog] libavcodec/vaapi_encode: Add new API adaption to vaapi_encode

2022-02-27 Thread Wenbin Chen
ffmpeg | branch: master | Wenbin Chen  | 
Fri Feb 18 11:07:46 2022 +0800| [e0ff86993052b49a64d434bac345e92fc149f446] | 
committer: Haihao Xiang

libavcodec/vaapi_encode: Add new API adaption to vaapi_encode

Add vaSyncBuffer to VAAPI encoder. Old version API vaSyncSurface wait
surface to complete. When surface is used for multiple operation, it
waits all operations to finish. vaSyncBuffer only wait one channel to
finish.

Signed-off-by: Wenbin Chen 
Signed-off-by: Haihao Xiang 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e0ff86993052b49a64d434bac345e92fc149f446
---

 libavcodec/vaapi_encode.c | 32 +++-
 libavcodec/vaapi_encode.h |  3 +++
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 3bf379b1a0..3f8c8ace2a 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -150,11 +150,25 @@ static int vaapi_encode_wait(AVCodecContext *avctx,
"(input surface %#x).\n", pic->display_order,
pic->encode_order, pic->input_surface);
 
-vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);
-if (vas != VA_STATUS_SUCCESS) {
-av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: "
-   "%d (%s).\n", vas, vaErrorStr(vas));
-return AVERROR(EIO);
+#if VA_CHECK_VERSION(1, 9, 0)
+if (ctx->has_sync_buffer_func) {
+vas = vaSyncBuffer(ctx->hwctx->display,
+   pic->output_buffer,
+   VA_TIMEOUT_INFINITE);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to sync to output buffer 
completion: "
+   "%d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
+} else
+#endif
+{ // If vaSyncBuffer is not implemented, try old version API.
+vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: 
"
+"%d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
 }
 
 // Input is definitely finished with now.
@@ -2522,6 +2536,14 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
 }
 }
 
+#if VA_CHECK_VERSION(1, 9, 0)
+// check vaSyncBuffer function
+vas = vaSyncBuffer(ctx->hwctx->display, VA_INVALID_ID, 0);
+if (vas != VA_STATUS_ERROR_UNIMPLEMENTED) {
+ctx->has_sync_buffer_func = 1;
+}
+#endif
+
 return 0;
 
 fail:
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index b41604a883..29d9e9b91c 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -345,6 +345,9 @@ typedef struct VAAPIEncodeContext {
 int roi_warned;
 
 AVFrame *frame;
+
+// Whether the driver support vaSyncBuffer
+int has_sync_buffer_func;
 } VAAPIEncodeContext;
 
 enum {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] qsv: add return value check for MFXQueryIMPL

2022-02-27 Thread Tong Wu
ffmpeg | branch: master | Tong Wu  | Thu Feb 
24 10:27:39 2022 +0800| [d05ca3d779aed2df3d1cd74d1d295eb3729b7bf2] | committer: 
Haihao Xiang

qsv: add return value check for MFXQueryIMPL

add a return value check for function MFXQueryIMPL to handle the error
message.

Signed-off-by: Tong Wu 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d05ca3d779aed2df3d1cd74d1d295eb3729b7bf2
---

 libavcodec/qsv.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index b75877e698..67d0e3934a 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -424,7 +424,10 @@ int ff_qsv_init_internal_session(AVCodecContext *avctx, 
QSVSession *qs,
 return ret;
 }
 
-MFXQueryIMPL(qs->session, &impl);
+ret = MFXQueryIMPL(qs->session, &impl);
+if (ret != MFX_ERR_NONE)
+return ff_qsv_print_error(avctx, ret,
+  "Error querying the session attributes");
 
 switch (MFX_IMPL_BASETYPE(impl)) {
 case MFX_IMPL_SOFTWARE:

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] libavcodec/qsvenc: add more ChromaFormat support to mjpeg_qsv

2022-02-27 Thread Wenbin Chen
ffmpeg | branch: master | Wenbin Chen  | 
Mon Feb 21 15:28:33 2022 +0800| [4869ccb3f38a606401a1c3e3a31f18d35eb7dc39] | 
committer: Haihao Xiang

libavcodec/qsvenc: add more ChromaFormat support to mjpeg_qsv

ChromaForamt for mjpeg-qsv is always set to yuv420, and this will be
wrong when encode other pixel format (for example yuyv422). ChromaFormat
is changed to be adaptive to pix_fmt.

Signed-off-by: Wenbin Chen 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4869ccb3f38a606401a1c3e3a31f18d35eb7dc39
---

 libavcodec/qsvenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 40d60cde3c..3008f329e5 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -616,7 +616,8 @@ static int init_video_param_jpeg(AVCodecContext *avctx, 
QSVEncContext *q)
 q->param.mfx.FrameInfo.CropH  = avctx->height;
 q->param.mfx.FrameInfo.AspectRatioW   = avctx->sample_aspect_ratio.num;
 q->param.mfx.FrameInfo.AspectRatioH   = avctx->sample_aspect_ratio.den;
-q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
+q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420 +
+!desc->log2_chroma_w + 
!desc->log2_chroma_h;
 q->param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
 q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
 q->param.mfx.FrameInfo.Shift  = desc->comp[0].depth > 8;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] qsvenc: avoid dereferencing the null pointer

2022-02-27 Thread Tong Wu
ffmpeg | branch: master | Tong Wu  | Thu Feb 
24 10:27:40 2022 +0800| [a0a2ccd55d2038867b0677c31f70632a69f6e9e3] | committer: 
Haihao Xiang

qsvenc: avoid dereferencing the null pointer

The variable AVFrame *frame could be a null pointer, now add a null
pointer check to avoid dereferencing the null pointer.

Signed-off-by: Tong Wu 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0a2ccd55d2038867b0677c31f70632a69f6e9e3
---

 libavcodec/qsvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 49f61ae6bb..9b71487666 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1736,7 +1736,7 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 goto free;
 }
 
-if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM && frame->interlaced_frame)
+if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM && frame && 
frame->interlaced_frame)
 print_interlace_msg(avctx, q);
 
 ret = 0;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] libavcodec/qsvenc: add mbbrc to hevc_qsv

2022-02-27 Thread Wenbin Chen
ffmpeg | branch: master | Wenbin Chen  | 
Mon Feb 21 16:56:56 2022 +0800| [342d4fb0563cafa4e444c83dc4ecfa0d69a71eda] | 
committer: Haihao Xiang

libavcodec/qsvenc: add mbbrc to hevc_qsv

Add mbbrc to hevc_qsv
For detailed description, please see "mbbrc" part in:
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxextcodingoption2

Signed-off-by: Wenbin Chen 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=342d4fb0563cafa4e444c83dc4ecfa0d69a71eda
---

 doc/encoders.texi   | 5 +
 libavcodec/qsvenc.c | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 64e8c5d129..1bd38671ca 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3395,6 +3395,11 @@ Maximum encoded frame size in bytes.
 @item @var{max_slice_size}
 Maximum encoded slice size in bytes.
 
+@item @var{mbbrc}
+Setting this flag enables macroblock level bitrate control that generally
+improves subjective visual quality. Enabling this flag may have negative impact
+on performance and objective visual quality metric.
+
 @item @var{p_strategy}
 Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 3008f329e5..49f61ae6bb 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -878,8 +878,6 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 if (avctx->codec_id == AV_CODEC_ID_H264) {
 if (q->bitrate_limit >= 0)
 q->extco2.BitrateLimit = q->bitrate_limit ? 
MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
-if (q->mbbrc >= 0)
-q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 
 #if QSV_HAVE_TRELLIS
 if (avctx->trellis >= 0)
@@ -936,6 +934,9 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI;
 }
 #endif
+if (q->mbbrc >= 0)
+q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
+
 q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
 q->extco2.Header.BufferSz = sizeof(q->extco2);
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".