[FFmpeg-cvslog] avfilter/af_afftdn: stop producing small impulsive noise at start of output

2022-03-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Mon Mar 14 10:02:18 
2022 +0100| [a71a3d1ed24fdcfb3f09795e1fbfeca990463d69] | committer: Paul B Mahol

avfilter/af_afftdn: stop producing small impulsive noise at start of output

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

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

diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index 7257de73d3..48f7a888aa 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -329,13 +329,15 @@ static double limit_gain(double a, double b)
 return 1.0;
 }
 
-static void process_frame(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch,
+static void process_frame(AVFilterContext *ctx,
+  AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch,
   AVComplexFloat *fft_data,
   double *prior, double *prior_band_excit, int 
track_noise)
 {
+AVFilterLink *outlink = ctx->outputs[0];
 const double sample_floor = s->sample_floor;
 const double *abs_var = dnch->abs_var;
-const double ratio = s->ratio;
+const double ratio = outlink->frame_count_out ? s->ratio : 1.0;
 const double rratio = 1. - ratio;
 const int *bin2band = s->bin2band;
 double *band_excit = dnch->band_excit;
@@ -784,7 +786,6 @@ static int config_input(AVFilterLink *inlink)
 for (int ch = 0; ch < inlink->channels; ch++) {
 DeNoiseChannel *dnch = &s->dnch[ch];
 double *prior_band_excit = dnch->prior_band_excit;
-double *prior = dnch->prior;
 double min, max;
 double p1, p2;
 
@@ -828,8 +829,6 @@ static int config_input(AVFilterLink *inlink)
 dnch->band_excit[i] = av_clipd(dnch->band_excit[i], min, max);
 }
 
-for (int i = 0; i <= s->fft_length2; i++)
-prior[i] = 1.0 - s->ratio;
 for (int i = 0; i < s->buffer_length; i++)
 dnch->out_samples[i] = 0;
 
@@ -1067,7 +1066,7 @@ static int filter_channel(AVFilterContext *ctx, void 
*arg, int jobnr, int nb_job
 
 dnch->tx_fn(dnch->fft, dnch->fft_out, fft_in, sizeof(float));
 
-process_frame(s, dnch, dnch->fft_out,
+process_frame(ctx, s, dnch, dnch->fft_out,
   dnch->prior,
   dnch->prior_band_excit,
   s->track_noise);

___
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] fate: add decimate filter test

2022-03-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Mar 13 22:07:57 
2022 +0100| [4eb76e74612942d10ecce806d7bbdedeb6008faf] | committer: Paul B Mahol

fate: add decimate filter test

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

 tests/fate/filter-video.mak|   3 +
 tests/ref/fate/filter-decimate | 245 +
 2 files changed, 248 insertions(+)

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 510bb3ffbc..cd33361880 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -451,6 +451,9 @@ fate-filter-concat: CMD = framecrc -filter_complex_script 
$(TARGET_PATH)/tests/d
 fate-filter-concat-vfr: tests/data/filtergraphs/concat-vfr
 fate-filter-concat-vfr: CMD = framecrc -filter_complex_script 
$(TARGET_PATH)/tests/data/filtergraphs/concat-vfr
 
+FATE_FILTER-$(call ALLYES, TESTSRC2_FILTER FPS_FILTER DECIMATE_FILTER) += 
fate-filter-decimate
+fate-filter-decimate: CMD = framecrc -lavfi 
testsrc2=r=24:d=10,fps=60,decimate=5,decimate=4,decimate=3 -pix_fmt yuv420p
+
 FATE_FILTER-$(call ALLYES, TESTSRC2_FILTER FPS_FILTER MPDECIMATE_FILTER) += 
fate-filter-mpdecimate
 fate-filter-mpdecimate: CMD = framecrc -lavfi 
testsrc2=r=2:d=10,fps=3,mpdecimate -r 3 -pix_fmt yuv420p
 
diff --git a/tests/ref/fate/filter-decimate b/tests/ref/fate/filter-decimate
new file mode 100644
index 00..7c51b438a4
--- /dev/null
+++ b/tests/ref/fate/filter-decimate
@@ -0,0 +1,245 @@
+#tb 0: 1/24
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 320x240
+#sar 0: 1/1
+0,  0,  0,1,   115200, 0x3744b3ed
+0,  1,  1,1,   115200, 0x960ae41c
+0,  2,  2,1,   115200, 0xe8031d25
+0,  3,  3,1,   115200, 0x13254a89
+0,  4,  4,1,   115200, 0x939c7f3d
+0,  5,  5,1,   115200, 0xa68ba085
+0,  6,  6,1,   115200, 0xe7bda27b
+0,  7,  7,1,   115200, 0x00679a86
+0,  8,  8,1,   115200, 0x0c849830
+0,  9,  9,1,   115200, 0x2e6a927d
+0, 10, 10,1,   115200, 0x475b92e1
+0, 11, 11,1,   115200, 0xfe3e9516
+0, 12, 12,1,   115200, 0xc5d79a51
+0, 13, 13,1,   115200, 0x9dd29e29
+0, 14, 14,1,   115200, 0x16b3ae83
+0, 15, 15,1,   115200, 0x4151b7b0
+0, 16, 16,1,   115200, 0x5f54b19d
+0, 17, 17,1,   115200, 0xd776b3e3
+0, 18, 18,1,   115200, 0xe55ab961
+0, 19, 19,1,   115200, 0xad23bb36
+0, 20, 20,1,   115200, 0x7f4db57f
+0, 21, 21,1,   115200, 0xbafda06e
+0, 22, 22,1,   115200, 0xf263893c
+0, 23, 23,1,   115200, 0x53ba81d3
+0, 24, 24,1,   115200, 0x0fa465ad
+0, 25, 25,1,   115200, 0x214a709b
+0, 26, 26,1,   115200, 0x51878099
+0, 27, 27,1,   115200, 0x6e1a7b19
+0, 28, 28,1,   115200, 0x96ed90b3
+0, 29, 29,1,   115200, 0x91aba349
+0, 30, 30,1,   115200, 0xfd35adb5
+0, 31, 31,1,   115200, 0xec62b4a5
+0, 32, 32,1,   115200, 0x8898b87a
+0, 33, 33,1,   115200, 0x517dc6b8
+0, 34, 34,1,   115200, 0xb7cdcc9c
+0, 35, 35,1,   115200, 0x9ba9dfb5
+0, 36, 36,1,   115200, 0xd162f354
+0, 37, 37,1,   115200, 0x1f25e394
+0, 38, 38,1,   115200, 0xd828e1dc
+0, 39, 39,1,   115200, 0xa02cce79
+0, 40, 40,1,   115200, 0x1ca0c5ec
+0, 41, 41,1,   115200, 0xab66ba79
+0, 42, 42,1,   115200, 0x484c9be1
+0, 43, 43,1,   115200, 0x8d3b7e1c
+0, 44, 44,1,   115200, 0x50fe70d4
+0, 45, 45,1,   115200, 0x54b85d95
+0, 46, 46,1,   115200, 0xea0451c2
+0, 47, 47,1,   115200, 0x3811656f
+0, 48, 48,1,   115200, 0x0c7c7081
+0, 49, 49,1,   115200, 0xe0b15961
+0, 50, 50,1,   115200, 0x227f6926
+0, 51, 51,1,   115200, 0xfbb26630
+0, 52, 52,1,   115200, 0x7d3e840d
+0, 53, 53,1,   115200, 0xeb5fa9c0
+0, 54, 54,1,   115200, 0x0c54b377
+0, 55, 55,1,   115200, 0xab62be11
+0, 56, 56,1,   115200, 0xf6a1c43b
+0, 57,

[FFmpeg-cvslog] avfilter/af_afftdn: use correct variable in for loops

2022-03-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Mon Mar 14 10:35:23 
2022 +0100| [deffacb6b4b79a375132f078115beb72ee6acb1f] | committer: Paul B Mahol

avfilter/af_afftdn: use correct variable in for loops

Tehnically changes nothing as they are same value currently.

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

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

diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index 48f7a888aa..a0af0c00da 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -467,7 +467,7 @@ static void process_frame(AVFilterContext *ctx,
 for (int i = 0; i < s->bin_count; i++)
 dnch->amt[i] = band_amt[bin2band[i]];
 
-for (int i = 0; i <= s->fft_length2; i++) {
+for (int i = 0; i < s->bin_count; i++) {
 if (dnch->amt[i] > abs_var[i]) {
 gain[i] = 1.0;
 } else if (dnch->amt[i] > dnch->min_abs_var[i]) {
@@ -523,7 +523,7 @@ static void set_band_parameters(AudioFFTDeNoiseContext *s,
 
 d5 = 0.0;
 band_noise = process_get_band_noise(s, dnch, 0);
-for (int m = j; m <= s->fft_length2; m++) {
+for (int m = j; m < s->bin_count; m++) {
 if (m == j) {
 i = j;
 d5 = band_noise;
@@ -612,7 +612,7 @@ static void set_parameters(AudioFFTDeNoiseContext *s, 
DeNoiseChannel *dnch, int
 if (update_var) {
 set_band_parameters(s, dnch);
 
-for (int i = 0; i <= s->fft_length2; i++) {
+for (int i = 0; i < s->bin_count; i++) {
 dnch->abs_var[i] = fmax(dnch->max_var * dnch->rel_var[i], 1.0);
 dnch->min_abs_var[i] = dnch->gain_scale * dnch->abs_var[i];
 }
@@ -691,7 +691,7 @@ static int config_input(AVFilterLink *inlink)
 return AVERROR(ENOMEM);
 
 sdiv = s->sample_rate / 17640.0;
-for (i = 0; i <= s->fft_length2; i++)
+for (i = 0; i < s->bin_count; i++)
 s->bin2band[i] = lrint(sdiv * freq2bark((0.5 * i * s->sample_rate) / 
s->fft_length2));
 
 s->number_of_bands = s->bin2band[s->fft_length2] + 1;
@@ -809,7 +809,7 @@ static int config_input(AVFilterLink *inlink)
 prior_band_excit[m] = 0.0;
 }
 
-for (m = 0; m <= s->fft_length2; m++)
+for (m = 0; m < s->bin_count; m++)
 dnch->band_excit[s->bin2band[m]] += 1.0;
 
 j = 0;
@@ -840,7 +840,7 @@ static int config_input(AVFilterLink *inlink)
 
 j = 0;
 sar = s->sample_advance / s->sample_rate;
-for (int i = 0; i <= s->fft_length2; i++) {
+for (int i = 0; i < s->bin_count; i++) {
 if ((i == s->fft_length2) || (s->bin2band[i] > j)) {
 double d6 = (i - 1) * s->sample_rate / s->fft_length;
 double d7 = fmin(0.008 + 2.2 / d6, 0.03);

___
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: allow user to control number of bands

2022-03-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Mon Mar 14 11:20:23 
2022 +0100| [c0f49378a9520ccd9ee4398bf3e1721a76b0569b] | committer: Paul B Mahol

avfilter/af_afftdn: allow user to control number of bands

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

 doc/filters.texi| 4 
 libavfilter/af_afftdn.c | 5 -
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 73081bed4c..c4cf083526 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1367,6 +1367,10 @@ Use measured average noise floor of all channels.
 
 Default value is @var{min}.
 @end table
+
+@item band_multiplier, bm
+Set the band multiplier factor, used how much to spread bands across frequency 
bins.
+Allowed range is from @var{0.2} to @var{5}. Default value is @var{1.25}.
 @end table
 
 @subsection Commands
diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index a0af0c00da..29b9ffe6d8 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -113,6 +113,7 @@ typedef struct AudioFFTDeNoiseContext {
 int output_mode;
 int noise_floor_link;
 float   ratio;
+float   band_multiplier;
 
 float   last_residual_floor;
 float   last_noise_floor;
@@ -200,6 +201,8 @@ static const AVOption afftdn_options[] = {
 {  "min", "min",  0,   
AV_OPT_TYPE_CONST,  {.i64 = MIN_LINK},  0,  0, AFR, "link" },
 {  "max", "max",  0,   
AV_OPT_TYPE_CONST,  {.i64 = MAX_LINK},  0,  0, AFR, "link" },
 {  "average", "average",  0,   
AV_OPT_TYPE_CONST,  {.i64 = AVERAGE_LINK},  0,  0, AFR, "link" },
+{ "band_multiplier", "set band multiplier",OFFSET(band_multiplier), 
AV_OPT_TYPE_FLOAT,{.dbl = 1.25},   0.2,5, AF  },
+{ "bm",   "set band multiplier",   OFFSET(band_multiplier), 
AV_OPT_TYPE_FLOAT,{.dbl = 1.25},   0.2,5, AF  },
 { NULL }
 };
 
@@ -690,7 +693,7 @@ static int config_input(AVFilterLink *inlink)
 if (!s->window || !s->bin2band)
 return AVERROR(ENOMEM);
 
-sdiv = s->sample_rate / 17640.0;
+sdiv = s->band_multiplier;
 for (i = 0; i < s->bin_count; i++)
 s->bin2band[i] = lrint(sdiv * freq2bark((0.5 * i * s->sample_rate) / 
s->fft_length2));
 

___
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_fieldhint: add pattern mode of filtering

2022-03-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Mon Mar 14 17:39:01 
2022 +0100| [1ab83dd3693742da42a32e1f8ed5f9a0778ed43e] | committer: Paul B Mahol

avfilter/vf_fieldhint: add pattern mode of filtering

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

 doc/filters.texi   |  4 +++-
 libavfilter/vf_fieldhint.c | 31 ---
 2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index c4cf083526..2607c1330b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12318,7 +12318,9 @@ case of @code{b} it will use only bottom field.
 If line starts with @code{#} or @code{;} that line is skipped.
 
 @item mode
-Can be item @code{absolute} or @code{relative}. Default is @code{absolute}.
+Can be item @code{absolute} or @code{relative} or @code{pattern}. Default is 
@code{absolute}.
+The @code{pattern} mode is same as @code{relative} mode, except at last entry 
of file if there
+are more frames to process than @code{hint} file is seek back to start.
 @end table
 
 Example of first several lines of @code{hint} file for @code{relative} mode:
diff --git a/libavfilter/vf_fieldhint.c b/libavfilter/vf_fieldhint.c
index e4513dddfa..e7afac1116 100644
--- a/libavfilter/vf_fieldhint.c
+++ b/libavfilter/vf_fieldhint.c
@@ -27,6 +27,13 @@
 #include "internal.h"
 #include "video.h"
 
+enum HintModes {
+ABSOLUTE_HINT,
+RELATIVE_HINT,
+PATTERN_HINT,
+NB_HINTS,
+};
+
 typedef struct FieldHintContext {
 const AVClass *class;
 
@@ -48,9 +55,10 @@ typedef struct FieldHintContext {
 
 static const AVOption fieldhint_options[] = {
 { "hint", "set hint file", OFFSET(hint_file_str), AV_OPT_TYPE_STRING, 
{.str=NULL}, 0, 0, FLAGS },
-{ "mode", "set hint mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
FLAGS, "mode" },
-{   "absolute", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode" },
-{   "relative", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode" },
+{ "mode", "set hint mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 
NB_HINTS-1, FLAGS, "mode" },
+{   "absolute", 0, 0, AV_OPT_TYPE_CONST, {.i64=ABSOLUTE_HINT}, 0, 0, 
FLAGS, "mode" },
+{   "relative", 0, 0, AV_OPT_TYPE_CONST, {.i64=RELATIVE_HINT}, 0, 0, 
FLAGS, "mode" },
+{   "pattern",  0, 0, AV_OPT_TYPE_CONST, {.i64=PATTERN_HINT},  0, 0, 
FLAGS, "mode" },
 { NULL }
 };
 
@@ -141,22 +149,30 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 return AVERROR_INVALIDDATA;
 }
 switch (s->mode) {
-case 0:
+case ABSOLUTE_HINT:
 if (tf > outlink->frame_count_in + 1 || tf < FFMAX(0, 
outlink->frame_count_in - 1) ||
 bf > outlink->frame_count_in + 1 || bf < FFMAX(0, 
outlink->frame_count_in - 1)) {
 av_log(ctx, AV_LOG_ERROR, "Out of range frames %"PRId64" 
and/or %"PRId64" on line %"PRId64" for %"PRId64". input frame.\n", tf, bf, 
s->line, inlink->frame_count_out);
 return AVERROR_INVALIDDATA;
 }
 break;
-case 1:
+case PATTERN_HINT:
+case RELATIVE_HINT:
 if (tf > 1 || tf < -1 ||
 bf > 1 || bf < -1) {
 av_log(ctx, AV_LOG_ERROR, "Out of range %"PRId64" and/or 
%"PRId64" on line %"PRId64" for %"PRId64". input frame.\n", tf, bf, s->line, 
inlink->frame_count_out);
 return AVERROR_INVALIDDATA;
 }
+break;
+default:
+return AVERROR_BUG;
 };
 break;
 } else {
+if (s->mode == PATTERN_HINT) {
+fseek(s->hint, 0, SEEK_SET);
+continue;
+}
 av_log(ctx, AV_LOG_ERROR, "Missing entry for %"PRId64". input 
frame.\n", inlink->frame_count_out);
 return AVERROR_INVALIDDATA;
 }
@@ -168,11 +184,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 av_frame_copy_props(out, s->frame[1]);
 
 switch (s->mode) {
-case 0:
+case ABSOLUTE_HINT:
 top= s->frame[tf - outlink->frame_count_in + 1];
 bottom = s->frame[bf - outlink->frame_count_in + 1];
 break;
-case 1:
+case PATTERN_HINT:
+case RELATIVE_HINT:
 top= s->frame[1 + tf];
 bottom = s->frame[1 + bf];
 break;

___
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] avutil/hwcontext_vulkan: fix typo in undef

2022-03-14 Thread Zhao Zhili
ffmpeg | branch: master | Zhao Zhili  | Thu Mar 10 
01:02:38 2022 +0800| [910a24eb330694a24da20efd03706a7a6052bb77] | committer: 
Lynne

avutil/hwcontext_vulkan: fix typo in undef

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

 libavutil/hwcontext_vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 0c942fbc96..237caa4bc0 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1054,7 +1054,7 @@ static int setup_queue_families(AVHWDeviceContext *ctx, 
VkDeviceCreateInfo *cd)
 SETUP_QUEUE(enc_index)
 SETUP_QUEUE(dec_index)
 
-#undef ADD_QUEUE
+#undef SETUP_QUEUE
 
 av_free(qf);
 

___
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_palettegen: add protection against potential divide by zero

2022-03-14 Thread Yiyuan GUO
ffmpeg | branch: master | Yiyuan GUO  | Sat May 15 13:54:35 
2021 +0800| [2201c91fbf672447aa2063bd752d821466b8f11b] | committer: Paul B Mahol

avfilter/vf_palettegen: add protection against potential divide by zero

In libavfilter/vf_palettegen.c, the function get_avg_color requires
that box->len greater than zero to avoid dividing by zero. However,
the call sequence filter_frame -> get_palette_frame -> get_avg_color
may not satisfy this precondition. Fixes #9222.

Signed-off-by: Yiyuan GUO 

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

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

diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c
index 4f53aa1aad..27f74fd147 100644
--- a/libavfilter/vf_palettegen.c
+++ b/libavfilter/vf_palettegen.c
@@ -528,7 +528,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 if (s->stats_mode == STATS_MODE_DIFF_FRAMES) {
 av_frame_free(&s->prev_frame);
 s->prev_frame = in;
-} else if (s->stats_mode == STATS_MODE_SINGLE_FRAMES) {
+} else if (s->stats_mode == STATS_MODE_SINGLE_FRAMES && s->nb_refs > 0) {
 AVFrame *out;
 int i;
 

___
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/avf_abitscope: rename macro to less generic one

2022-03-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Mon Mar 14 18:25:10 
2022 +0100| [58f867ffef38ff8694dbed537b99521c24345320] | committer: Paul B Mahol

avfilter/avf_abitscope: rename macro to less generic one

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

 libavfilter/avf_abitscope.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavfilter/avf_abitscope.c b/libavfilter/avf_abitscope.c
index e6415ddfbf..1db7f77a5b 100644
--- a/libavfilter/avf_abitscope.c
+++ b/libavfilter/avf_abitscope.c
@@ -174,7 +174,7 @@ static int config_output(AVFilterLink *outlink)
 }   \
 }
 
-#define TRACE(type, depth, one) \
+#define DO_TRACE(type, depth, one)  \
 for (int ch = 0; ch < inlink->channels; ch++) { \
 const int w = outpicref->width / inlink->channels;  \
 const type *in = (const type *)insamples->extended_data[ch];\
@@ -238,18 +238,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 
 switch (insamples->format) {
 case AV_SAMPLE_FMT_U8P:
-if (s->mode == 0) { BARS(uint8_t,   8, 1) } else { TRACE(uint8_t,   8, 
1) }
+if (s->mode == 0) { BARS(uint8_t,   8, 1) } else { DO_TRACE(uint8_t,   
8, 1) }
 break;
 case AV_SAMPLE_FMT_S16P:
-if (s->mode == 0) { BARS(uint16_t, 16, 1) } else { TRACE(uint16_t, 16, 
1) }
+if (s->mode == 0) { BARS(uint16_t, 16, 1) } else { DO_TRACE(uint16_t, 
16, 1) }
 break;
 case AV_SAMPLE_FMT_FLTP:
 case AV_SAMPLE_FMT_S32P:
-if (s->mode == 0) { BARS(uint32_t, 32, 1U) } else { TRACE(uint32_t, 
32, 1U) }
+if (s->mode == 0) { BARS(uint32_t, 32, 1U) } else { DO_TRACE(uint32_t, 
32, 1U) }
 break;
 case AV_SAMPLE_FMT_DBLP:
 case AV_SAMPLE_FMT_S64P:
-if (s->mode == 0) { BARS(uint64_t, 64, 1ULL) } else { TRACE(uint64_t, 
64, 1ULL) }
+if (s->mode == 0) { BARS(uint64_t, 64, 1ULL) } else { 
DO_TRACE(uint64_t, 64, 1ULL) }
 break;
 }
 

___
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] tools/target_dec_fuzzer: Adjust threshold for DFA

2022-03-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Mar 11 20:52:19 2022 +0100| [31c4c99ff906a98b298a6b3dad346fdd288c1ee0] | 
committer: Michael Niedermayer

tools/target_dec_fuzzer: Adjust threshold for DFA

Fixes: Timeout
Fixes: 
45351/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DFA_fuzzer-5768895011618816

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 tools/target_dec_fuzzer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index cef71e1e0a..23b0184059 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -157,6 +157,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 case AV_CODEC_ID_BINKVIDEO:   maxpixels  /= 32;break;
 case AV_CODEC_ID_CFHD:maxpixels  /= 128;   break;
 case AV_CODEC_ID_COOK:maxsamples /= 1<<20; break;
+case AV_CODEC_ID_DFA: maxpixels  /= 1024;  break;
 case AV_CODEC_ID_DIRAC:   maxpixels  /= 8192;  break;
 case AV_CODEC_ID_DST: maxsamples /= 1<<20; break;
 case AV_CODEC_ID_DVB_SUBTITLE: av_dict_set_int(&opts, "compute_clut", -2, 
0); break;

___
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] avcodec: Add dv marker bsf

2022-03-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue 
Feb 22 22:50:42 2022 +0100| [6f9b4b3e1500180280e0bc0fee6b9ee62dd2756e] | 
committer: Michael Niedermayer

avcodec: Add dv marker bsf

Signed-off-by: Michael Niedermayer 

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

 doc/bitstream_filters.texi   |  30 +
 libavcodec/Makefile  |   1 +
 libavcodec/bitstream_filters.c   |   1 +
 libavcodec/dv_error_marker_bsf.c | 138 +++
 4 files changed, 170 insertions(+)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index a0092878c8..8c5d84dceb 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -132,6 +132,36 @@ the header stored in extradata to the key packets:
 ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra 
out.ts
 @end example
 
+@section dv_error_marker
+
+Blocks in DV which are marked as damaged are replaced by blocks of the 
specified color.
+
+@table @option
+@item color
+The color to replace damaged blocks by
+@item sta
+A 16 bit mask which specifies which of the 16 possible error status values are
+to be replaced by colored blocks. 0xFFFE is the default which replaces all non 0
+error status values.
+@table @samp
+@item ok
+No error, no concealment
+@item err
+Error, No concealment
+@item res
+Reserved
+@item notok
+Error or concealment
+@item notres
+Not reserved
+@item Aa, Ba, Ca, Ab, Bb, Cb, A, B, C, a, b, erri, erru
+The specific error status code
+@end table
+see page 44-46 or section 5.5 of
+@url{http://web.archive.org/web/20060927044735/http://www.smpte.org/smpte_store/standards/pdf/s314m.pdf}
+
+@end table
+
 @section eac3_core
 
 Extract the core from a E-AC-3 stream, dropping extra channels.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cd929da8e6..f36b2e992d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1163,6 +1163,7 @@ OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= 
av1_frame_split_bsf.o
 OBJS-$(CONFIG_CHOMP_BSF)  += chomp_bsf.o
 OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
 OBJS-$(CONFIG_DCA_CORE_BSF)   += dca_core_bsf.o
+OBJS-$(CONFIG_DV_ERROR_MARKER_BSF)+= dv_error_marker_bsf.o
 OBJS-$(CONFIG_EAC3_CORE_BSF)  += eac3_core_bsf.o
 OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF)  += extract_extradata_bsf.o\
  av1_parse.o h2645_parse.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index d565286397..ab27972a88 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -31,6 +31,7 @@ extern const AVBitStreamFilter ff_av1_metadata_bsf;
 extern const AVBitStreamFilter ff_chomp_bsf;
 extern const AVBitStreamFilter ff_dump_extradata_bsf;
 extern const AVBitStreamFilter ff_dca_core_bsf;
+extern const AVBitStreamFilter ff_dv_error_marker_bsf;
 extern const AVBitStreamFilter ff_eac3_core_bsf;
 extern const AVBitStreamFilter ff_extract_extradata_bsf;
 extern const AVBitStreamFilter ff_filter_units_bsf;
diff --git a/libavcodec/dv_error_marker_bsf.c b/libavcodec/dv_error_marker_bsf.c
new file mode 100644
index 00..a2b9e09ce5
--- /dev/null
+++ b/libavcodec/dv_error_marker_bsf.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2022 Michael Niedermayer
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "libavutil/colorspace.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+
+typedef struct DVErrorMarkerContext {
+const AVClass *class;
+uint8_t color_rgba[4];
+int sta;
+uint8_t marked_block[76];
+} DVErrorMarkerContext;
+
+static void setdc(uint8_t *b, const uint8_t color_rgba[4], int cblocks, int 
y_step, int v_step, int u_step) {
+for (int i=0; i<4; i++) {
+b[0] = RGB_TO_Y_JPEG(color_rgba[0], color_rgba[1],color_rgba[2]) + 128;
+b[1] = 0x06;
+b += y_step;
+}
+for (int i=0; ipriv_data;
+
+memset(s->marked_block, -1, 76);
+setdc(s->marked_block, s->color_rgba, 1, 14, 10, 10);
+setdc(s->marked_block, s->color_rgba, 2, 10, 10,  8);
+
+return 0;
+}
+
+static int dv_error_mark

[FFmpeg-cvslog] avfilter/vf_epx: stop doing read overflow

2022-03-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Mon Mar 14 22:56:28 
2022 +0100| [2ba38beb7929f6dd63f8609e15570891fdf5645a] | committer: Paul B Mahol

avfilter/vf_epx: stop doing read overflow

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

 libavfilter/vf_epx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_epx.c b/libavfilter/vf_epx.c
index 9d79648ac1..d706229ab8 100644
--- a/libavfilter/vf_epx.c
+++ b/libavfilter/vf_epx.c
@@ -100,7 +100,7 @@ static int epx2_slice(AVFilterContext *ctx, void *arg, int 
jobnr, int nb_jobs)
 src_line[1] = src_line[2];
 src_line[2] = src_line[1];
 
-if (y < height - 1)
+if (y < height - 2)
 src_line[2] += src_linesize;
 }
 }
@@ -187,7 +187,7 @@ static int epx3_slice(AVFilterContext *ctx, void *arg, int 
jobnr, int nb_jobs)
 src_line[1] = src_line[2];
 src_line[2] = src_line[1];
 
-if (y < height - 1)
+if (y < height - 2)
 src_line[2] += src_linesize;
 }
 }

___
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] aarch64: Only emit the PAC/BTI note section when targeting ELF

2022-03-14 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Wed Mar  9 
15:11:45 2022 +0200| [c3fea6d83be43198060f2dc577fd642290966537] | committer: 
Martin Storsjö

aarch64: Only emit the PAC/BTI note section when targeting ELF

This avoids build errors if such features are enabled while targeting
another binary format. (Using such features on other platforms
might require some other form of signaling/setup though, but
the ELF specific .note section isn't applicable at least.)

Signed-off-by: Martin Storsjö 

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

 libavutil/aarch64/asm.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/aarch64/asm.S b/libavutil/aarch64/asm.S
index b817eaab22..a7782415d7 100644
--- a/libavutil/aarch64/asm.S
+++ b/libavutil/aarch64/asm.S
@@ -141,7 +141,7 @@
 #endif
 
 
-#if (GNU_PROPERTY_AARCH64_BTI != 0 || GNU_PROPERTY_AARCH64_PAC != 0)
+#if (GNU_PROPERTY_AARCH64_BTI != 0 || GNU_PROPERTY_AARCH64_PAC != 0) && 
defined(__ELF__)
 .pushsection .note.gnu.property, "a"
 .balign 8
 .long 4

___
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] avcodec/flashsv: Avoid copying packet

2022-03-14 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Mar  4 23:11:01 2022 +0100| [88cccd1c7303b2560a94f9d947d422e11f239031] | 
committer: Andreas Rheinhardt

avcodec/flashsv: Avoid copying packet

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/flashsv.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c
index 00f77f4902..5f0bc0c6df 100644
--- a/libavcodec/flashsv.c
+++ b/libavcodec/flashsv.c
@@ -44,7 +44,7 @@
 #include "internal.h"
 
 typedef struct BlockInfo {
-uint8_t *pos;
+const uint8_t *pos;
 int  size;
 } BlockInfo;
 
@@ -59,7 +59,8 @@ typedef struct FlashSVContext {
 int ver;
 const uint32_t *pal;
 int is_keyframe;
-uint8_t*keyframedata;
+const uint8_t  *keyframedata;
+AVBufferRef*keyframedata_buf;
 uint8_t*keyframe;
 BlockInfo  *blocks;
 uint8_t*deflate_block;
@@ -138,7 +139,7 @@ static av_cold int flashsv_decode_init(AVCodecContext 
*avctx)
 return 0;
 }
 
-static int flashsv2_prime(FlashSVContext *s, uint8_t *src, int size)
+static int flashsv2_prime(FlashSVContext *s, const uint8_t *src, int size)
 {
 z_stream zs;
 int zret; // Zlib return code
@@ -355,10 +356,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, 
void *data,
 /* we care for keyframes only in Screen Video v2 */
 s->is_keyframe = (avpkt->flags & AV_PKT_FLAG_KEY) && (s->ver == 2);
 if (s->is_keyframe) {
-int err;
-if ((err = av_reallocp(&s->keyframedata, avpkt->size)) < 0)
+int err = av_buffer_replace(&s->keyframedata_buf, avpkt->buf);
+if (err < 0)
 return err;
-memcpy(s->keyframedata, avpkt->data, avpkt->size);
+s->keyframedata = avpkt->data;
 }
 if(s->ver == 2 && !s->blocks)
 s->blocks = av_mallocz((v_blocks + !!v_part) * (h_blocks + !!h_part) *
@@ -566,7 +567,7 @@ static av_cold int flashsv2_decode_end(AVCodecContext 
*avctx)
 {
 FlashSVContext *s = avctx->priv_data;
 
-av_freep(&s->keyframedata);
+av_buffer_unref(&s->keyframedata_buf);
 av_freep(&s->blocks);
 av_freep(&s->keyframe);
 av_freep(&s->deflate_block);

___
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] avcodec/flashsv: Avoid deflating data

2022-03-14 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Mar 11 14:19:27 2022 +0100| [dcc3f6227070fe8fecbcfe7849fb69f5e8b832f7] | 
committer: Andreas Rheinhardt

avcodec/flashsv: Avoid deflating data

Currently priming the zlib decompressor involves compressing
data directly after having decompressed it and decompressing
it again in order to set the "dictionary" and to initialize
the adler32-checksum. Yet this is wasteful and can be simplified
by synthetizing the compressed data via non-compressed blocks.

This reduced the amount of allocations for the decoding part
of fate-vsynth1-flashsv2, namely from
total heap usage: 9,135 allocs, 9,135 frees, 376,503,427 bytes allocated
to
total heap usage: 2,373 allocs, 2,373 frees, 14,144,083 bytes allocated

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/flashsv.c | 89 ++--
 1 file changed, 38 insertions(+), 51 deletions(-)

diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c
index 5f0bc0c6df..e284439972 100644
--- a/libavcodec/flashsv.c
+++ b/libavcodec/flashsv.c
@@ -63,11 +63,10 @@ typedef struct FlashSVContext {
 AVBufferRef*keyframedata_buf;
 uint8_t*keyframe;
 BlockInfo  *blocks;
-uint8_t*deflate_block;
-int deflate_block_size;
 int color_depth;
 int zlibprime_curr, zlibprime_prev;
 int diff_start, diff_height;
+uint8_t tmp[UINT16_MAX];
 } FlashSVContext;
 
 static int decode_hybrid(const uint8_t *sptr, const uint8_t *sptr_end, uint8_t 
*dptr, int dx, int dy,
@@ -141,41 +140,59 @@ static av_cold int flashsv_decode_init(AVCodecContext 
*avctx)
 
 static int flashsv2_prime(FlashSVContext *s, const uint8_t *src, int size)
 {
-z_stream zs;
 int zret; // Zlib return code
+static const uint8_t zlib_header[] = { 0x78, 0x01 };
+uint8_t *data = s->tmpblock;
+unsigned remaining;
 
 if (!src)
 return AVERROR_INVALIDDATA;
 
-zs.zalloc = NULL;
-zs.zfree  = NULL;
-zs.opaque = NULL;
-
 s->zstream.next_in   = src;
 s->zstream.avail_in  = size;
-s->zstream.next_out  = s->tmpblock;
+s->zstream.next_out  = data;
 s->zstream.avail_out = s->block_size * 3;
 inflate(&s->zstream, Z_SYNC_FLUSH);
-
-if (deflateInit(&zs, 0) != Z_OK)
-return -1;
-zs.next_in   = s->tmpblock;
-zs.avail_in  = s->block_size * 3 - s->zstream.avail_out;
-zs.next_out  = s->deflate_block;
-zs.avail_out = s->deflate_block_size;
-deflate(&zs, Z_SYNC_FLUSH);
-deflateEnd(&zs);
+remaining = s->block_size * 3 - s->zstream.avail_out;
 
 if ((zret = inflateReset(&s->zstream)) != Z_OK) {
 av_log(s->avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
 return AVERROR_UNKNOWN;
 }
 
-s->zstream.next_in   = s->deflate_block;
-s->zstream.avail_in  = s->deflate_block_size - zs.avail_out;
-s->zstream.next_out  = s->tmpblock;
-s->zstream.avail_out = s->block_size * 3;
+/* Create input for zlib that is equivalent to encoding the output
+ * from above and decoding it again (the net result of this is that
+ * the dictionary of past decoded data is correctly primed and
+ * the adler32 checksum is correctly initialized).
+ * This is accomplished by synthetizing blocks of uncompressed data
+ * out of the output from above. See section 3.2.4 of RFC 1951. */
+s->zstream.next_in  = zlib_header;
+s->zstream.avail_in = sizeof(zlib_header);
 inflate(&s->zstream, Z_SYNC_FLUSH);
+while (remaining > 0) {
+unsigned block_size = FFMIN(UINT16_MAX, remaining);
+uint8_t header[5];
+/* Bit 0: Non-last-block, bits 1-2: BTYPE for uncompressed block */
+header[0] = 0;
+/* Block size */
+AV_WL16(header + 1, block_size);
+/* Block size (one's complement) */
+AV_WL16(header + 3, block_size ^ 0x);
+s->zstream.next_in   = header;
+s->zstream.avail_in  = sizeof(header);
+s->zstream.next_out  = s->tmp;
+s->zstream.avail_out = sizeof(s->tmp);
+zret = inflate(&s->zstream, Z_SYNC_FLUSH);
+if (zret != Z_OK)
+return AVERROR_UNKNOWN;
+s->zstream.next_in   = data;
+s->zstream.avail_in  = block_size;
+zret = inflate(&s->zstream, Z_SYNC_FLUSH);
+if (zret != Z_OK)
+return AVERROR_UNKNOWN;
+data  += block_size;
+remaining -= block_size;
+}
 
 return 0;
 }
@@ -248,22 +265,6 @@ static int flashsv_decode_block(AVCodecContext *avctx, 
const AVPacket *avpkt,
 return 0;
 }
 
-static int calc_deflate_block_size(int tmpblock_size)
-{
-z_stream zstream;
-int size;
-
-zstream.zalloc = Z_NULL;
-zstream.zfree  = Z_NULL;
-zstream.opaque = Z_NULL;
-if (deflateInit(&zstream, 0) != Z_OK)
-return -1