[FFmpeg-cvslog] avfilter/af_biquads: implement 1st order allpass

2020-05-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat May 23 17:54:54 
2020 +0200| [1206a10d9c9f33487b4bfefa0b5805eb4c0669a2] | committer: Paul B Mahol

avfilter/af_biquads: implement 1st order allpass

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

 doc/filters.texi |  3 +++
 libavfilter/af_biquads.c | 28 ++--
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 85a511b205..5af4797b7e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1568,6 +1568,9 @@ Specify which channels to filter, by default all 
available are filtered.
 @item normalize, n
 Normalize biquad coefficients, by default is disabled.
 Enabling it will normalize magnitude response at DC to 0dB.
+
+@item order, o
+Set the filter order, can be 1 or 2. Default is 2.
 @end table
 
 @subsection Commands
diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c
index a2f7e3f061..81cdb0c10e 100644
--- a/libavfilter/af_biquads.c
+++ b/libavfilter/af_biquads.c
@@ -113,6 +113,7 @@ typedef struct BiquadsContext {
 double mix;
 uint64_t channels;
 int normalize;
+int order;
 
 double a0, a1, a2;
 double b0, b1, b2;
@@ -264,6 +265,7 @@ static int config_filter(AVFilterLink *outlink, int reset)
 AVFilterLink *inlink= ctx->inputs[0];
 double A = ff_exp10(s->gain / 40);
 double w0 = 2 * M_PI * s->frequency / inlink->sample_rate;
+double K = tan(w0 / 2.);
 double alpha, beta;
 
 if (w0 > M_PI) {
@@ -389,12 +391,24 @@ static int config_filter(AVFilterLink *outlink, int reset)
 }
 break;
 case allpass:
-s->a0 =  1 + alpha;
-s->a1 = -2 * cos(w0);
-s->a2 =  1 - alpha;
-s->b0 =  1 - alpha;
-s->b1 = -2 * cos(w0);
-s->b2 =  1 + alpha;
+switch (s->order) {
+case 1:
+s->a0 = 1.;
+s->a1 = -(1. - K) / (1. + K);
+s->a2 = 0.;
+s->b0 = s->a1;
+s->b1 = s->a0;
+s->b2 = 0.;
+break;
+case 2:
+s->a0 =  1 + alpha;
+s->a1 = -2 * cos(w0);
+s->a2 =  1 - alpha;
+s->b0 =  1 - alpha;
+s->b1 = -2 * cos(w0);
+s->b2 =  1 + alpha;
+break;
+}
 break;
 default:
 av_assert0(0);
@@ -773,6 +787,8 @@ static const AVOption allpass_options[] = {
 {"c","set channels to filter", OFFSET(channels), 
AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
 {"normalize", "normalize coefficients", OFFSET(normalize), 
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
 {"n", "normalize coefficients", OFFSET(normalize), 
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
+{"order", "set filter order", OFFSET(order), AV_OPT_TYPE_INT, {.i64=2}, 1, 
2, FLAGS},
+{"o", "set filter order", OFFSET(order), AV_OPT_TYPE_INT, {.i64=2}, 1, 
2, FLAGS},
 {NULL}
 };
 

___
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] Revert "avfilter/af_aiir: move response drawing as last step"

2020-05-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat May 30 09:50:59 
2020 +0200| [6485b54477e7f5d9feb382c4bd527279c5181261] | committer: Paul B Mahol

Revert "avfilter/af_aiir: move response drawing as last step"

This reverts commit ca7095a9072fab4cdb41af12da9d94752e082e34.

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

 libavfilter/af_aiir.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 36788c38b3..503d5b9329 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -1028,6 +1028,15 @@ static int config_output(AVFilterLink *outlink)
 check_stability(ctx, inlink->channels);
 }
 
+av_frame_free(&s->video);
+if (s->response) {
+s->video = ff_get_video_buffer(ctx->outputs[1], s->w, s->h);
+if (!s->video)
+return AVERROR(ENOMEM);
+
+draw_response(ctx, s->video, inlink->sample_rate);
+}
+
 if (s->format == 0)
 av_log(ctx, AV_LOG_WARNING, "tf coefficients format is not recommended 
for too high number of zeros/poles.\n");
 
@@ -1071,15 +1080,6 @@ static int config_output(AVFilterLink *outlink)
 case AV_SAMPLE_FMT_S16P: s->iir_channel = s->process == 1 ? 
iir_ch_serial_s16p : iir_ch_s16p; break;
 }
 
-av_frame_free(&s->video);
-if (s->response) {
-s->video = ff_get_video_buffer(ctx->outputs[1], s->w, s->h);
-if (!s->video)
-return AVERROR(ENOMEM);
-
-draw_response(ctx, s->video, inlink->sample_rate);
-}
-
 return 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] avfilter/af_aiir: improve response calculation with zp coefficients

2020-05-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat May 30 09:47:12 
2020 +0200| [3fc7b01c52746cdfa13b99117642644d6bda38c8] | committer: Paul B Mahol

avfilter/af_aiir: improve response calculation with zp coefficients

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

 libavfilter/af_aiir.c | 54 ++-
 1 file changed, 23 insertions(+), 31 deletions(-)

diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index f6dff2338b..36788c38b3 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -824,9 +824,14 @@ static void draw_line(AVFrame *out, int x0, int y0, int 
x1, int y1, uint32_t col
 }
 }
 
+static double distance(double x0, double x1, double y0, double y1)
+{
+return hypot(x0 - x1, y0 - y1);
+}
+
 static void get_response(int channel, int format, double w,
  const double *b, const double *a,
- int nb_b, int nb_a, double *r, double *i)
+ int nb_b, int nb_a, double *magnitude, double *phase)
 {
 double realz, realp;
 double imagz, imagp;
@@ -849,39 +854,26 @@ static void get_response(int channel, int format, double 
w,
 div = realp * realp + imagp * imagp;
 real = (realz * realp + imagz * imagp) / div;
 imag = (imagz * realp - imagp * realz) / div;
-} else {
-real = 1;
-imag = 0;
-for (int x = 0; x < nb_a; x++) {
-double ore, oim, re, im;
-
-re = cos(w) - a[2 * x];
-im = sin(w) - a[2 * x + 1];
 
-ore = real;
-oim = imag;
+*magnitude = hypot(real, imag);
+*phase = atan2(imag, real);
+} else {
+double p = 1., z = 1.;
+double acc = 0.;
 
-real = ore * re - oim * im;
-imag = ore * im + oim * re;
+for (int x = 0; x < nb_a; x++) {
+z *= distance(cos(w), a[2 * x], sin(w), a[2 * x + 1]);
+acc += atan2(sin(w) - a[2 * x + 1], cos(w) - a[2 * x]);
 }
 
 for (int x = 0; x < nb_b; x++) {
-double ore, oim, re, im;
-
-re = cos(w) - b[2 * x];
-im = sin(w) - b[2 * x + 1];
-
-ore = real;
-oim = imag;
-div = re * re + im * im;
-
-real = (ore * re + oim * im) / div;
-imag = (oim * re - ore * im) / div;
+p *= distance(cos(w), b[2 * x], sin(w), b[2 * x + 1]);
+acc -= atan2(sin(w) - b[2 * x + 1], cos(w) - b[2 * x]);
 }
-}
 
-*r = real;
-*i = imag;
+*magnitude = z / p;
+*phase = acc;
+}
 }
 
 static void draw_response(AVFilterContext *ctx, AVFrame *out, int sample_rate)
@@ -909,12 +901,12 @@ static void draw_response(AVFilterContext *ctx, AVFrame 
*out, int sample_rate)
 const int nb_b = s->iir[ch].nb_ab[0];
 const int nb_a = s->iir[ch].nb_ab[1];
 double w = i * M_PI / (s->w - 1);
-double real, imag;
+double m, p;
 
-get_response(ch, s->format, w, b, a, nb_b, nb_a, &real, &imag);
+get_response(ch, s->format, w, b, a, nb_b, nb_a, &m, &p);
 
-mag[i] = s->iir[ch].g * hypot(real, imag);
-phase[i] = atan2(imag, real);
+mag[i] = s->iir[ch].g * m;
+phase[i] = p;
 min = fmin(min, mag[i]);
 max = fmax(max, mag[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/af_aiir: make it clear that transfer function is digital one

2020-05-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Fri May 29 20:44:41 
2020 +0200| [327b52412dc63b5b699dc9ff9fb41e49010d643c] | committer: Paul B Mahol

avfilter/af_aiir: make it clear that transfer function is digital one

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

 doc/filters.texi  | 2 +-
 libavfilter/af_aiir.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5af4797b7e..869090c3f4 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1409,7 +1409,7 @@ Set coefficients format.
 
 @table @samp
 @item tf
-transfer function
+digital transfer function
 @item zp
 Z-plane zeros/poles, cartesian (default)
 @item pr
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 92ff348dd6..b9a06bbb7b 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -1223,7 +1223,7 @@ static const AVOption aiir_options[] = {
 { "wet", "set wet gain",   OFFSET(wet_gain), 
AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, AF },
 { "format", "set coefficients format", OFFSET(format),   
AV_OPT_TYPE_INT,{.i64=1}, 0, 3, AF, "format" },
 { "f", "set coefficients format",  OFFSET(format),   
AV_OPT_TYPE_INT,{.i64=1}, 0, 3, AF, "format" },
-{ "tf", "transfer function",   0,
AV_OPT_TYPE_CONST,  {.i64=0}, 0, 0, AF, "format" },
+{ "tf", "digital transfer function",   0,
AV_OPT_TYPE_CONST,  {.i64=0}, 0, 0, AF, "format" },
 { "zp", "Z-plane zeros/poles", 0,
AV_OPT_TYPE_CONST,  {.i64=1}, 0, 0, AF, "format" },
 { "pr", "Z-plane zeros/poles (polar radians)", 0,
AV_OPT_TYPE_CONST,  {.i64=2}, 0, 0, AF, "format" },
 { "pd", "Z-plane zeros/poles (polar degrees)", 0,
AV_OPT_TYPE_CONST,  {.i64=3}, 0, 0, AF, "format" },

___
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_aiir: add S-plane support

2020-05-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Fri May 29 22:05:01 
2020 +0200| [e2e8121eaac62fc77576a36801eedf7e32d0b67b] | committer: Paul B Mahol

avfilter/af_aiir: add S-plane support

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

 doc/filters.texi  |  2 ++
 libavfilter/af_aiir.c | 42 +++---
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 869090c3f4..1f9ea89ada 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1416,6 +1416,8 @@ Z-plane zeros/poles, cartesian (default)
 Z-plane zeros/poles, polar radians
 @item pd
 Z-plane zeros/poles, polar degrees
+@item sp
+S-plane zeros/poles
 @end table
 
 @item process, r
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index b9a06bbb7b..f6dff2338b 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -336,7 +336,7 @@ static int read_zp_coefficients(AVFilterContext *ctx, char 
*item_str, int nb_ite
 return 0;
 }
 
-static const char *format[] = { "%lf", "%lf %lfi", "%lf %lfr", "%lf %lfd" };
+static const char *format[] = { "%lf", "%lf %lfi", "%lf %lfr", "%lf %lfd", 
"%lf %lfi" };
 
 static int read_channels(AVFilterContext *ctx, int channels, uint8_t 
*item_str, int ab)
 {
@@ -696,6 +696,39 @@ static void convert_pr2zp(AVFilterContext *ctx, int 
channels)
 }
 }
 
+static void convert_sp2zp(AVFilterContext *ctx, int channels)
+{
+AudioIIRContext *s = ctx->priv;
+int ch;
+
+for (ch = 0; ch < channels; ch++) {
+IIRChannel *iir = &s->iir[ch];
+int n;
+
+for (n = 0; n < iir->nb_ab[0]; n++) {
+double sr = iir->ab[0][2*n];
+double si = iir->ab[0][2*n+1];
+double snr = 1. + sr;
+double sdr = 1. - sr;
+double div = sdr * sdr + si * si;
+
+iir->ab[0][2*n]   = (snr * sdr - si * si) / div;
+iir->ab[0][2*n+1] = (sdr * si + snr * si) / div;
+}
+
+for (n = 0; n < iir->nb_ab[1]; n++) {
+double sr = iir->ab[1][2*n];
+double si = iir->ab[1][2*n+1];
+double snr = 1. + sr;
+double sdr = 1. - sr;
+double div = sdr * sdr + si * si;
+
+iir->ab[1][2*n]   = (snr * sdr - si * si) / div;
+iir->ab[1][2*n+1] = (sdr * si + snr * si) / div;
+}
+}
+}
+
 static void convert_pd2zp(AVFilterContext *ctx, int channels)
 {
 AudioIIRContext *s = ctx->priv;
@@ -996,6 +1029,8 @@ static int config_output(AVFilterLink *outlink)
 convert_pr2zp(ctx, inlink->channels);
 } else if (s->format == 3) {
 convert_pd2zp(ctx, inlink->channels);
+} else if (s->format == 4) {
+convert_sp2zp(ctx, inlink->channels);
 }
 if (s->format > 0) {
 check_stability(ctx, inlink->channels);
@@ -1221,12 +1256,13 @@ static const AVOption aiir_options[] = {
 { "k", "set channels gains",   OFFSET(g_str),
AV_OPT_TYPE_STRING, {.str="1|1"}, 0, 0, AF },
 { "dry", "set dry gain",   OFFSET(dry_gain), 
AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, AF },
 { "wet", "set wet gain",   OFFSET(wet_gain), 
AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, AF },
-{ "format", "set coefficients format", OFFSET(format),   
AV_OPT_TYPE_INT,{.i64=1}, 0, 3, AF, "format" },
-{ "f", "set coefficients format",  OFFSET(format),   
AV_OPT_TYPE_INT,{.i64=1}, 0, 3, AF, "format" },
+{ "format", "set coefficients format", OFFSET(format),   
AV_OPT_TYPE_INT,{.i64=1}, 0, 4, AF, "format" },
+{ "f", "set coefficients format",  OFFSET(format),   
AV_OPT_TYPE_INT,{.i64=1}, 0, 4, AF, "format" },
 { "tf", "digital transfer function",   0,
AV_OPT_TYPE_CONST,  {.i64=0}, 0, 0, AF, "format" },
 { "zp", "Z-plane zeros/poles", 0,
AV_OPT_TYPE_CONST,  {.i64=1}, 0, 0, AF, "format" },
 { "pr", "Z-plane zeros/poles (polar radians)", 0,
AV_OPT_TYPE_CONST,  {.i64=2}, 0, 0, AF, "format" },
 { "pd", "Z-plane zeros/poles (polar degrees)", 0,
AV_OPT_TYPE_CONST,  {.i64=3}, 0, 0, AF, "format" },
+{ "sp", "S-plane zeros/poles", 0,
AV_OPT_TYPE_CONST,  {.i64=4}, 0, 0, AF, "format" },
 { "process", "set kind of processing", OFFSET(process),  
AV_OPT_TYPE_INT,{.i64=1}, 0, 1, AF, "process" },
 { "r", "set kind of processing",   OFFSET(process),  
AV_OPT_TYPE_INT,{.i64=1}, 0, 1, AF, "process" },
 { "d", "direct",   0,
AV_OPT_TYPE_CONST,  {.i64=0}, 0, 0, AF, "process" },

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

To unsubscribe, visi

[FFmpeg-cvslog] avutil/attributes: Fix too many warning: false is not defined [-Wundef]

2020-05-30 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Fri May 29 
19:14:18 2020 +0800| [77e15f01fb876561054376c11b1529b202f8130d] | committer: 
Limin Wang

avutil/attributes: Fix too many warning: false is not defined [-Wundef]

Reviewed-by: James Almer 
Reviewed-by: Hendrik Leppkes 
Signed-off-by: Limin Wang 

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

 libavutil/attributes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index ab2a1fdd0e..5cb9fe3452 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -37,7 +37,7 @@
 #ifdef __has_builtin
 #define AV_HAS_BUILTIN(x) __has_builtin(x)
 #else
-#define AV_HAS_BUILTIN(x) false
+#define AV_HAS_BUILTIN(x) 0
 #endif
 
 #ifndef av_always_inline

___
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] lavfi/afir: fix vpad.name leak

2020-05-30 Thread Jun Zhao
ffmpeg | branch: master | Jun Zhao  | Mon May 25 
08:48:12 2020 +0800| [ff8329a73054bc6055a69860507fe45386e94798] | committer: 
Jun Zhao

lavfi/afir: fix vpad.name leak

Fix vpad.name leak in error path, move the vpad related operation
only if enabled show IR frequency response.

Signed-off-by: Jun Zhao 

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

 libavfilter/af_afir.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 7c7e8458d4..5ba880f10b 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -876,6 +876,12 @@ static av_cold int init(AVFilterContext *ctx)
 if (!pad.name)
 return AVERROR(ENOMEM);
 
+ret = ff_insert_outpad(ctx, 0, &pad);
+if (ret < 0) {
+av_freep(&pad.name);
+return ret;
+}
+
 if (s->response) {
 vpad = (AVFilterPad){
 .name = av_strdup("filter_response"),
@@ -884,15 +890,7 @@ static av_cold int init(AVFilterContext *ctx)
 };
 if (!vpad.name)
 return AVERROR(ENOMEM);
-}
 
-ret = ff_insert_outpad(ctx, 0, &pad);
-if (ret < 0) {
-av_freep(&pad.name);
-return ret;
-}
-
-if (s->response) {
 ret = ff_insert_outpad(ctx, 1, &vpad);
 if (ret < 0) {
 av_freep(&vpad.name);

___
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] lavfi/aiir: Refine the pad/vpad related operation

2020-05-30 Thread Jun Zhao
ffmpeg | branch: master | Jun Zhao  | Mon May 25 
16:10:29 2020 +0800| [018cd437f898aa72eafcd44dba263dc1ec8fcf05] | committer: 
Jun Zhao

lavfi/aiir: Refine the pad/vpad related operation

move the pad/vpad related operation with more natural
coding style.

Signed-off-by: Jun Zhao 

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

 libavfilter/af_aiir.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 503d5b9329..214c998348 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -1180,6 +1180,10 @@ static av_cold int init(AVFilterContext *ctx)
 if (!pad.name)
 return AVERROR(ENOMEM);
 
+ret = ff_insert_outpad(ctx, 0, &pad);
+if (ret < 0)
+return ret;
+
 if (s->response) {
 vpad = (AVFilterPad){
 .name = av_strdup("filter_response"),
@@ -1188,13 +1192,7 @@ static av_cold int init(AVFilterContext *ctx)
 };
 if (!vpad.name)
 return AVERROR(ENOMEM);
-}
 
-ret = ff_insert_outpad(ctx, 0, &pad);
-if (ret < 0)
-return ret;
-
-if (s->response) {
 ret = ff_insert_outpad(ctx, 1, &vpad);
 if (ret < 0)
 return ret;

___
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] lavf/utils: fix start_time/duration dump if it is AV_NOPTS_VALUE

2020-05-30 Thread Jun Zhao
ffmpeg | branch: master | Jun Zhao  | Wed May 27 
00:37:21 2020 +0800| [439128960991aea38263a53c7634a0e2aa786691] | committer: 
Jun Zhao

lavf/utils: fix start_time/duration dump if it is AV_NOPTS_VALUE

e,g: the command:
ffprobe -show_format -i fate-suite/aac/foo.aac -loglevel 99 will
dump the trace message as follow when start_time is AV_NOPTS_VALUE
[aac @ 0x55bf8e1f3dc0] stream 0: start_time: -326791809695.818 duration: 2.174
[aac @ 0x55bf8e1f3dc0] format: start_time: -9223372036854.775 duration: 2.174 
bitrate=120 kb/s

after this fix, will dump the start_time with "NOPTS".

Signed-off-by: Jun Zhao 

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

 libavformat/utils.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 9e3ea421cb..c9385318f6 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2984,16 +2984,16 @@ static void estimate_timings(AVFormatContext *ic, 
int64_t old_offset)
 for (i = 0; i < ic->nb_streams; i++) {
 st = ic->streams[i];
 if (st->time_base.den)
-av_log(ic, AV_LOG_TRACE, "stream %d: start_time: %0.3f 
duration: %0.3f\n", i,
-   (double) st->start_time * av_q2d(st->time_base),
-   (double) st->duration   * av_q2d(st->time_base));
+av_log(ic, AV_LOG_TRACE, "stream %d: start_time: %s duration: 
%s\n", i,
+   av_ts2timestr(st->start_time, &st->time_base),
+   av_ts2timestr(st->duration, &st->time_base));
 }
 av_log(ic, AV_LOG_TRACE,
-"format: start_time: %0.3f duration: %0.3f (estimate from %s) 
bitrate=%"PRId64" kb/s\n",
-(double) ic->start_time / AV_TIME_BASE,
-(double) ic->duration   / AV_TIME_BASE,
-duration_estimate_name(ic->duration_estimation_method),
-(int64_t)ic->bit_rate / 1000);
+   "format: start_time: %s duration: %s (estimate from %s) 
bitrate=%"PRId64" kb/s\n",
+   av_ts2timestr(ic->start_time, &AV_TIME_BASE_Q),
+   av_ts2timestr(ic->duration, &AV_TIME_BASE_Q),
+   duration_estimate_name(ic->duration_estimation_method),
+   (int64_t)ic->bit_rate / 1000);
 }
 }
 

___
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_aiir: use correct size when allocating in zp2tf

2020-05-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat May 30 10:55:28 
2020 +0200| [aac16abd926e3813eff8b25902ae61222af8d37c] | committer: Paul B Mahol

avfilter/af_aiir: use correct size when allocating in zp2tf

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

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

diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 214c998348..9427d25b50 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -468,8 +468,8 @@ static int convert_zp2tf(AVFilterContext *ctx, int channels)
 IIRChannel *iir = &s->iir[ch];
 double *topc, *botc;
 
-topc = av_calloc((iir->nb_ab[0] + 1) * 2, sizeof(*topc));
-botc = av_calloc((iir->nb_ab[1] + 1) * 2, sizeof(*botc));
+topc = av_calloc((iir->nb_ab[1] + 1) * 2, sizeof(*topc));
+botc = av_calloc((iir->nb_ab[0] + 1) * 2, sizeof(*botc));
 if (!topc || !botc) {
 ret = AVERROR(ENOMEM);
 goto fail;

___
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: add dblur video filter

2020-05-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed May 27 12:03:02 
2020 +0200| [726dbc57f8162ce82c245a2fdfef2fa074c99dc4] | committer: Paul B Mahol

avfilter: add dblur video filter

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

 Changelog|   1 +
 doc/filters.texi |  23 
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 libavfilter/vf_dblur.c   | 307 +++
 6 files changed, 334 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 6a4a63a643..f36cf4fc7f 100644
--- a/Changelog
+++ b/Changelog
@@ -73,6 +73,7 @@ version :
 - untile filter
 - Simon & Schuster Interactive ADPCM encoder
 - PFM decoder
+- dblur video filter
 
 
 version 4.2:
diff --git a/doc/filters.texi b/doc/filters.texi
index 1f9ea89ada..f76604c51e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8563,6 +8563,29 @@ Set background opacity.
 Set display number format. Can be @code{hex}, or @code{dec}. Default is 
@code{hex}.
 @end table
 
+@section dblur
+Apply Directional blur filter.
+
+The filter accepts the following options:
+
+@table @option
+@item angle
+Set angle of directional blur. Default is @code{45}.
+
+@item radius
+Set radius of directional blur. Default is @code{5}.
+
+@item planes
+Set which planes to filter. By default all planes are filtered.
+@end table
+
+@subsection Commands
+This filter supports same @ref{commands} as options.
+The command accepts the same syntax of the corresponding option.
+
+If the specified expression is not valid, it is kept at its current
+value.
+
 @section dctdnoiz
 
 Denoise frames using 2D DCT (frequency domain filtering).
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 994a4172a3..5123540653 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -206,6 +206,7 @@ OBJS-$(CONFIG_CROPDETECT_FILTER) += 
vf_cropdetect.o
 OBJS-$(CONFIG_CUE_FILTER)+= f_cue.o
 OBJS-$(CONFIG_CURVES_FILTER) += vf_curves.o
 OBJS-$(CONFIG_DATASCOPE_FILTER)  += vf_datascope.o
+OBJS-$(CONFIG_DBLUR_FILTER)  += vf_dblur.o
 OBJS-$(CONFIG_DCTDNOIZ_FILTER)   += vf_dctdnoiz.o
 OBJS-$(CONFIG_DEBAND_FILTER) += vf_deband.o
 OBJS-$(CONFIG_DEBLOCK_FILTER)+= vf_deblock.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f2a44b0090..1183e40267 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -194,6 +194,7 @@ extern AVFilter ff_vf_cropdetect;
 extern AVFilter ff_vf_cue;
 extern AVFilter ff_vf_curves;
 extern AVFilter ff_vf_datascope;
+extern AVFilter ff_vf_dblur;
 extern AVFilter ff_vf_dctdnoiz;
 extern AVFilter ff_vf_deband;
 extern AVFilter ff_vf_deblock;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index a820d0bbbf..980d9baca3 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR   7
-#define LIBAVFILTER_VERSION_MINOR  83
+#define LIBAVFILTER_VERSION_MINOR  84
 #define LIBAVFILTER_VERSION_MICRO 100
 
 
diff --git a/libavfilter/vf_dblur.c b/libavfilter/vf_dblur.c
new file mode 100644
index 00..cc127da73f
--- /dev/null
+++ b/libavfilter/vf_dblur.c
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) 2020 Paul B Mahol
+ *
+ * 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 "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct DBlurContext {
+const AVClass *class;
+
+float angle;
+float radius;
+int planes;
+
+float b0, b1, q, c, R3;
+
+int depth;
+int planewidth[4];
+int planeheight[4];
+float *buffer;
+int nb_planes;
+void (*horiz_slice)(float *buffer, int width, int height, int steps, float 
nu, float bscale);
+} DBlurContext;
+
+#define OFFSET(x) offsetof(DBlurContext, x)
+#define FLAGS 
AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+
+static const AVOption dblur_options[] = {
+{ "angle",  "set angle",OFF

[FFmpeg-cvslog] avcodec: add PFM image decoder

2020-05-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed May 27 16:42:24 
2020 +0200| [d49db99ce2be29c4ae4083dfb04128ff842285fd] | committer: Paul B Mahol

avcodec: add PFM image decoder

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

 Changelog   |  1 +
 libavcodec/Makefile |  1 +
 libavcodec/allcodecs.c  |  1 +
 libavcodec/codec_desc.c |  7 +++
 libavcodec/codec_id.h   |  1 +
 libavcodec/pnm.c| 21 +++
 libavcodec/pnm.h|  2 ++
 libavcodec/pnmdec.c | 55 +
 libavcodec/version.h|  2 +-
 libavformat/img2.c  |  1 +
 10 files changed, 87 insertions(+), 5 deletions(-)

diff --git a/Changelog b/Changelog
index 24dbbc2208..6a4a63a643 100644
--- a/Changelog
+++ b/Changelog
@@ -72,6 +72,7 @@ version :
 - MediaFoundation encoder wrapper
 - untile filter
 - Simon & Schuster Interactive ADPCM encoder
+- PFM decoder
 
 
 version 4.2:
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d0917a656f..0a3bbc7128 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -530,6 +530,7 @@ OBJS-$(CONFIG_PBM_DECODER) += pnmdec.o pnm.o
 OBJS-$(CONFIG_PBM_ENCODER) += pnmenc.o
 OBJS-$(CONFIG_PCX_DECODER) += pcx.o
 OBJS-$(CONFIG_PCX_ENCODER) += pcxenc.o
+OBJS-$(CONFIG_PFM_DECODER) += pnmdec.o pnm.o
 OBJS-$(CONFIG_PGM_DECODER) += pnmdec.o pnm.o
 OBJS-$(CONFIG_PGM_ENCODER) += pnmenc.o
 OBJS-$(CONFIG_PGMYUV_DECODER)  += pnmdec.o pnm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 5899eee5ee..5240d0afdf 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -233,6 +233,7 @@ extern AVCodec ff_pbm_encoder;
 extern AVCodec ff_pbm_decoder;
 extern AVCodec ff_pcx_encoder;
 extern AVCodec ff_pcx_decoder;
+extern AVCodec ff_pfm_decoder;
 extern AVCodec ff_pgm_encoder;
 extern AVCodec ff_pgm_decoder;
 extern AVCodec ff_pgmyuv_encoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index b94ad0b1e6..9f8847544f 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1770,6 +1770,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("NotchLC"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_PFM,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "pfm",
+.long_name = NULL_IF_CONFIG_SMALL("PFM (Portable FloatMap) image"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index f7cb0a6056..d885962c9c 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -294,6 +294,7 @@ enum AVCodecID {
 AV_CODEC_ID_CDTOONS,
 AV_CODEC_ID_MV30,
 AV_CODEC_ID_NOTCHLC,
+AV_CODEC_ID_PFM,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index b5c2881948..a6ae01b494 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -24,6 +24,7 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/avstring.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "pnm.h"
@@ -69,8 +70,9 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * 
const s)
 
 if (s->bytestream_end - s->bytestream < 3 ||
 s->bytestream[0] != 'P' ||
-s->bytestream[1] < '1'  ||
-s->bytestream[1] > '7') {
+(s->bytestream[1] < '1' ||
+ s->bytestream[1] > '7' &&
+ s->bytestream[1] != 'F')) {
 s->bytestream += s->bytestream_end > s->bytestream;
 s->bytestream += s->bytestream_end > s->bytestream;
 return AVERROR_INVALIDDATA;
@@ -78,7 +80,9 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * 
const s)
 pnm_get(s, buf1, sizeof(buf1));
 s->type= buf1[1]-'0';
 
-if (s->type==1 || s->type==4) {
+if (buf1[1] == 'F') {
+avctx->pix_fmt = AV_PIX_FMT_GBRPF32;
+} else if (s->type==1 || s->type==4) {
 avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
 } else if (s->type==2 || s->type==5) {
 if (avctx->codec_id == AV_CODEC_ID_PGMYUV)
@@ -173,7 +177,16 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext 
* const s)
 if (ret < 0)
 return ret;
 
-if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE && avctx->pix_fmt != 
AV_PIX_FMT_MONOBLACK) {
+if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32) {
+pnm_get(s, buf1, sizeof(buf1));
+if (av_sscanf(buf1, "%f", &s->scale) != 1) {
+av_log(avctx, AV_LOG_ERROR, "Invalid scale.\n");
+return AVERROR_INVALIDDATA;
+}
+s->endian = s->scale < 0.f;
+s->scale = fabsf(s->scale);
+s->maxval = (1ULL <<

[FFmpeg-cvslog] avfilter/af_aiir: simplify polynomial evaluation

2020-05-30 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat May 30 17:55:32 
2020 +0200| [1329db8cfb63e1c87e9aa2d514ca9eaf20939228] | committer: Paul B Mahol

avfilter/af_aiir: simplify polynomial evaluation

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

 libavfilter/af_aiir.c | 49 ++---
 1 file changed, 18 insertions(+), 31 deletions(-)

diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 9427d25b50..bc31e5141e 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -385,45 +385,32 @@ static int read_channels(AVFilterContext *ctx, int 
channels, uint8_t *item_str,
 return 0;
 }
 
-static void multiply(double wre, double wim, int npz, double *coeffs)
+static void cmul(double re, double im, double re2, double im2, double *RE, 
double *IM)
 {
-double nwre = -wre, nwim = -wim;
-double cre, cim;
-int i;
-
-for (i = npz; i >= 1; i--) {
-cre = coeffs[2 * i + 0];
-cim = coeffs[2 * i + 1];
-
-coeffs[2 * i + 0] = (nwre * cre - nwim * cim) + coeffs[2 * (i - 1) + 
0];
-coeffs[2 * i + 1] = (nwre * cim + nwim * cre) + coeffs[2 * (i - 1) + 
1];
-}
-
-cre = coeffs[0];
-cim = coeffs[1];
-coeffs[0] = nwre * cre - nwim * cim;
-coeffs[1] = nwre * cim + nwim * cre;
+*RE = re * re2 - im * im2;
+*IM = re * im2 + re2 * im;
 }
 
-static int expand(AVFilterContext *ctx, double *pz, int nb, double *coeffs)
+static int expand(AVFilterContext *ctx, double *pz, int n, double *coefs)
 {
-int i;
+coefs[2 * n] = 1.0;
 
-coeffs[0] = 1.0;
-coeffs[1] = 0.0;
+for (int i = 1; i <= n; i++) {
+for (int j = n - i; j < n; j++) {
+double re, im;
 
-for (i = 0; i < nb; i++) {
-coeffs[2 * (i + 1)] = 0.0;
-coeffs[2 * (i + 1) + 1] = 0.0;
-}
+cmul(coefs[2 * (j + 1)], coefs[2 * (j + 1) + 1],
+ pz[2 * (i - 1)], pz[2 * (i - 1) + 1], &re, &im);
 
-for (i = 0; i < nb; i++)
-multiply(pz[2 * i], pz[2 * i + 1], nb, coeffs);
+coefs[2 * j] -= re;
+coefs[2 * j + 1] -= im;
+}
+}
 
-for (i = 0; i < nb + 1; i++) {
-if (fabs(coeffs[2 * i + 1]) > FLT_EPSILON) {
-av_log(ctx, AV_LOG_ERROR, "coeff: %f of z^%d is not real; 
poles/zeros are not complex conjugates.\n",
-   coeffs[2 * i + 1], i);
+for (int i = 0; i < n + 1; i++) {
+if (fabs(coefs[2 * i + 1]) > FLT_EPSILON) {
+av_log(ctx, AV_LOG_ERROR, "coefs: %f of z^%d is not real; 
poles/zeros are not complex conjugates.\n",
+   coefs[2 * i + 1], i);
 return AVERROR(EINVAL);
 }
 }

___
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_lut3d: prelut support for 3d cinespace luts

2020-05-30 Thread Mark Reid
ffmpeg | branch: master | Mark Reid  | Sat May 23 19:04:51 
2020 -0700| [a1221b96d81b9bc4ec92ad0d1fb06e7864cb40f7] | committer: Michael 
Niedermayer

avfilter/vf_lut3d: prelut support for 3d cinespace luts

Reviewed-by: Paul B Mahol 
Signed-off-by: Michael Niedermayer 

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

 libavfilter/vf_lut3d.c | 372 +
 1 file changed, 317 insertions(+), 55 deletions(-)

diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c
index 482e2394a7..e5d9fcc068 100644
--- a/libavfilter/vf_lut3d.c
+++ b/libavfilter/vf_lut3d.c
@@ -59,6 +59,15 @@ struct rgbvec {
 /* 3D LUT don't often go up to level 32, but it is common to have a Hald CLUT
  * of 512x512 (64x64x64) */
 #define MAX_LEVEL 256
+#define PRELUT_SIZE 65536
+
+typedef struct Lut3DPreLut {
+int size;
+float min[3];
+float max[3];
+float scale[3];
+float* lut[3];
+} Lut3DPreLut;
 
 typedef struct LUT3DContext {
 const AVClass *class;
@@ -71,6 +80,7 @@ typedef struct LUT3DContext {
 struct rgbvec *lut;
 int lutsize;
 int lutsize2;
+Lut3DPreLut prelut;
 #if CONFIG_HALDCLUT_FILTER
 uint8_t clut_rgba_map[4];
 int clut_step;
@@ -234,11 +244,39 @@ static inline struct rgbvec interp_tetrahedral(const 
LUT3DContext *lut3d,
 return c;
 }
 
+static inline float prelut_interp_1d_linear(const Lut3DPreLut *prelut,
+int idx, const float s)
+{
+const int lut_max = prelut->size - 1;
+const float scaled = (s - prelut->min[idx]) * prelut->scale[idx];
+const float x = av_clipf(scaled, 0.0f, lut_max);
+const int prev = PREV(x);
+const int next = FFMIN((int)(x) + 1, lut_max);
+const float p = prelut->lut[idx][prev];
+const float n = prelut->lut[idx][next];
+const float d = x - (float)prev;
+return lerpf(p, n, d);
+}
+
+static inline struct rgbvec apply_prelut(const Lut3DPreLut *prelut,
+ const struct rgbvec *s)
+{
+if (prelut->size <= 0)
+return *s;
+
+struct rgbvec c;
+c.r = prelut_interp_1d_linear(prelut, 0, s->r);
+c.g = prelut_interp_1d_linear(prelut, 1, s->g);
+c.b = prelut_interp_1d_linear(prelut, 2, s->b);
+return c;
+}
+
 #define DEFINE_INTERP_FUNC_PLANAR(name, nbits, depth)  
\
 static int interp_##nbits##_##name##_p##depth(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs) \
 {  
\
 int x, y;  
\
 const LUT3DContext *lut3d = ctx->priv; 
\
+const Lut3DPreLut *prelut = &lut3d->prelut;
\
 const ThreadData *td = arg;
\
 const AVFrame *in  = td->in;   
\
 const AVFrame *out = td->out;  
\
@@ -253,9 +291,11 @@ static int 
interp_##nbits##_##name##_p##depth(AVFilterContext *ctx, void *arg, i
 const uint8_t *srcbrow = in->data[1] + slice_start * in->linesize[1];  
\
 const uint8_t *srcrrow = in->data[2] + slice_start * in->linesize[2];  
\
 const uint8_t *srcarow = in->data[3] + slice_start * in->linesize[3];  
\
-const float scale_r = (lut3d->scale.r / ((1scale.g / ((1scale.b / ((1lutsize - 1;  
\
+const float scale_f = 1.0f / ((1scale.g * lut_max;
\
+const float scale_b = lut3d->scale.b * lut_max;
\

\
 for (y = slice_start; y < slice_end; y++) {
\
 uint##nbits##_t *dstg = (uint##nbits##_t *)grow;   
\
@@ -267,9 +307,13 @@ static int 
interp_##nbits##_##name##_p##depth(AVFilterContext *ctx, void *arg, i
 const uint##nbits##_t *srcr = (const uint##nbits##_t *)srcrrow;
\
 const uint##nbits##_t *srca = (const uint##nbits##_t *)src

[FFmpeg-cvslog] avformat/oggparsetheora: Don't update start time when lastpts is AV_NOPTS_VALUE.

2020-05-30 Thread Dale Curtis
ffmpeg | branch: master | Dale Curtis  | Fri May 15 
12:37:02 2020 -0700| [57564a2cfc9c424d137e8279955ac9e892c8d794] | committer: 
Michael Niedermayer

avformat/oggparsetheora: Don't update start time when lastpts is AV_NOPTS_VALUE.

Signed-off-by: Dale Curtis 
Signed-off-by: Michael Niedermayer 

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

 libavformat/oggparsetheora.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index c481a79d4b..d1064e4328 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -193,7 +193,7 @@ static int theora_packet(AVFormatContext *s, int idx)
 if (pts != AV_NOPTS_VALUE)
 pts = av_sat_sub64(pts, duration);
 os->lastpts = os->lastdts = pts;
-if(s->streams[idx]->start_time == AV_NOPTS_VALUE) {
+if(s->streams[idx]->start_time == AV_NOPTS_VALUE && os->lastpts != 
AV_NOPTS_VALUE) {
 s->streams[idx]->start_time = os->lastpts;
 if (s->streams[idx]->duration > 0)
 s->streams[idx]->duration -= s->streams[idx]->start_time;

___
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] avformat: add kvag muxer

2020-05-30 Thread Zane van Iperen
ffmpeg | branch: master | Zane van Iperen  | Fri May 29 
10:54:59 2020 +| [4aa07d1a74289dcdf12ea65ac975b415e26e3801] | committer: 
Michael Niedermayer

avformat: add kvag muxer

Signed-off-by: Zane van Iperen 
Signed-off-by: Michael Niedermayer 

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

 Changelog|  1 +
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/kvag.c   | 82 +++-
 libavformat/version.h|  2 +-
 5 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index f36cf4fc7f..711c843b99 100644
--- a/Changelog
+++ b/Changelog
@@ -74,6 +74,7 @@ version :
 - Simon & Schuster Interactive ADPCM encoder
 - PFM decoder
 - dblur video filter
+- Real War KVAG muxer
 
 
 version 4.2:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index efe82f9f08..0658fa3710 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -285,6 +285,7 @@ OBJS-$(CONFIG_JACOSUB_MUXER) += jacosubenc.o 
rawenc.o
 OBJS-$(CONFIG_JV_DEMUXER)+= jvdec.o
 OBJS-$(CONFIG_KUX_DEMUXER)   += flvdec.o
 OBJS-$(CONFIG_KVAG_DEMUXER)  += kvag.o
+OBJS-$(CONFIG_KVAG_MUXER)+= kvag.o rawenc.o
 OBJS-$(CONFIG_LATM_MUXER)+= latmenc.o rawenc.o
 OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o
 OBJS-$(CONFIG_LOAS_DEMUXER)  += loasdec.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 3919c9e4c1..a7c5c9db89 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -220,6 +220,7 @@ extern AVOutputFormat ff_jacosub_muxer;
 extern AVInputFormat  ff_jv_demuxer;
 extern AVInputFormat  ff_kux_demuxer;
 extern AVInputFormat  ff_kvag_demuxer;
+extern AVOutputFormat ff_kvag_muxer;
 extern AVOutputFormat ff_latm_muxer;
 extern AVInputFormat  ff_lmlm4_demuxer;
 extern AVInputFormat  ff_loas_demuxer;
diff --git a/libavformat/kvag.c b/libavformat/kvag.c
index 71b0eb4118..0a11fc0556 100644
--- a/libavformat/kvag.c
+++ b/libavformat/kvag.c
@@ -1,5 +1,5 @@
 /*
- * Simon & Schuster Interactive VAG demuxer
+ * Simon & Schuster Interactive VAG (de)muxer
  *
  * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
  *
@@ -21,6 +21,7 @@
  */
 #include "avformat.h"
 #include "internal.h"
+#include "rawenc.h"
 #include "libavutil/intreadwrite.h"
 
 #define KVAG_TAGMKTAG('K', 'V', 'A', 'G')
@@ -34,6 +35,7 @@ typedef struct KVAGHeader {
 uint16_tstereo;
 } KVAGHeader;
 
+#if CONFIG_KVAG_DEMUXER
 static int kvag_probe(const AVProbeData *p)
 {
 if (AV_RL32(p->buf) != KVAG_TAG)
@@ -115,3 +117,81 @@ AVInputFormat ff_kvag_demuxer = {
 .read_header= kvag_read_header,
 .read_packet= kvag_read_packet
 };
+#endif
+
+#if CONFIG_KVAG_MUXER
+static int kvag_write_init(AVFormatContext *s)
+{
+AVCodecParameters *par;
+
+if (s->nb_streams != 1) {
+av_log(s, AV_LOG_ERROR, "KVAG files have exactly one stream\n");
+return AVERROR(EINVAL);
+}
+
+par = s->streams[0]->codecpar;
+
+if (par->codec_id != AV_CODEC_ID_ADPCM_IMA_SSI) {
+av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
+   avcodec_get_name(par->codec_id));
+return AVERROR(EINVAL);
+}
+
+if (par->channels > 2) {
+av_log(s, AV_LOG_ERROR, "KVAG files only support up to 2 channels\n");
+return AVERROR(EINVAL);
+}
+
+if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
+av_log(s, AV_LOG_WARNING, "Stream not seekable, unable to write output 
file\n");
+return AVERROR(EINVAL);
+}
+
+return 0;
+}
+
+static int kvag_write_header(AVFormatContext *s)
+{
+uint8_t buf[KVAG_HEADER_SIZE];
+AVCodecParameters *par = s->streams[0]->codecpar;
+
+AV_WL32(buf +  0, KVAG_TAG);
+AV_WL32(buf +  4, 0); /* Data size, we fix this up later. */
+AV_WL32(buf +  8, par->sample_rate);
+AV_WL16(buf + 12, par->channels == 2);
+
+avio_write(s->pb, buf, sizeof(buf));
+return 0;
+}
+
+static int kvag_write_trailer(AVFormatContext *s)
+{
+int64_t file_size, data_size;
+
+file_size = avio_tell(s->pb);
+data_size = file_size - KVAG_HEADER_SIZE;
+if (data_size < UINT32_MAX) {
+avio_seek(s->pb, 4, SEEK_SET);
+avio_wl32(s->pb, (uint32_t)data_size);
+avio_seek(s->pb, file_size, SEEK_SET);
+} else {
+av_log(s, AV_LOG_WARNING,
+   "Filesize %"PRId64" invalid for KVAG, output file will be 
broken\n",
+   file_size);
+}
+
+return 0;
+}
+
+AVOutputFormat ff_kvag_muxer = {
+.name   = "kvag",
+.long_name  = NULL_IF_CONFIG_SMALL("Simon & Schuster Interactive VAG"),
+.extensions = "vag",
+.audio_codec= AV_CODEC_ID_ADPCM_IMA_SSI,
+.video_codec= AV_CODEC_ID_NONE,
+.init   = kvag_write_init,
+.write_header   = kvag_write_head