[FFmpeg-cvslog] lavu: support arbitrary-point FFTs and all even (i)MDCT transforms

2021-01-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Jan 12 08:11:47 2021 
+0100| [06a8596825e069a2e26810be40871e7d98a00f67] | committer: Lynne

lavu: support arbitrary-point FFTs and all even (i)MDCT transforms

This patch adds support for arbitrary-point FFTs and all even MDCT
transforms.
Odd MDCTs are not supported yet as they're based on the DCT-II and DCT-III
and they're very niche.

With this we can now write tests.

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

 libavutil/tx.h  |   5 ++-
 libavutil/tx_priv.h |   3 ++
 libavutil/tx_template.c | 101 +---
 libavutil/version.h |   2 +-
 4 files changed, 102 insertions(+), 9 deletions(-)

diff --git a/libavutil/tx.h b/libavutil/tx.h
index 418e8ec1ed..f49eb8c4c7 100644
--- a/libavutil/tx.h
+++ b/libavutil/tx.h
@@ -51,6 +51,8 @@ enum AVTXType {
  * For inverse transforms, the stride specifies the spacing between each
  * sample in the input array in bytes. The output will be a flat array.
  * Stride must be a non-zero multiple of sizeof(float).
+ * NOTE: the inverse transform is half-length, meaning the output will not
+ * contain redundant data. This is what most codecs work with.
  */
 AV_TX_FLOAT_MDCT = 1,
 /**
@@ -93,8 +95,7 @@ typedef void (*av_tx_fn)(AVTXContext *s, void *out, void *in, 
ptrdiff_t stride);
 
 /**
  * Initialize a transform context with the given configuration
- * Currently power of two lengths from 2 to 131072 are supported, along with
- * any length decomposable to a power of two and either 3, 5 or 15.
+ * (i)MDCTs with an odd length are currently not supported.
  *
  * @param ctx the context to allocate, will be NULL on error
  * @param tx pointer to the transform function pointer to set
diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h
index 0ace3e90dc..18a07c312c 100644
--- a/libavutil/tx_priv.h
+++ b/libavutil/tx_priv.h
@@ -58,6 +58,7 @@ typedef void FFTComplex;
 (dim) = (are) * (bim) - (aim) * (bre); 
\
 } while (0)
 
+#define UNSCALE(x) (x)
 #define RESCALE(x) (x)
 
 #define FOLD(a, b) ((a) + (b))
@@ -85,6 +86,7 @@ typedef void FFTComplex;
 (dim)   = (int)(((accu) + 0x4000) >> 31);  
\
 } while (0)
 
+#define UNSCALE(x) ((double)x/2147483648.0)
 #define RESCALE(x) (av_clip64(lrintf((x) * 2147483648.0), INT32_MIN, 
INT32_MAX))
 
 #define FOLD(x, y) ((int)((x) + (unsigned)(y) + 32) >> 6)
@@ -108,6 +110,7 @@ struct AVTXContext {
 int m;  /* Ptwo part */
 int inv;/* Is inverted */
 int type;   /* Type */
+double scale;   /* Scale */
 
 FFTComplex *exptab; /* MDCT exptab */
 FFTComplex *tmp;/* Temporary buffer needed for all compound transforms 
*/
diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index 7f4ca2f31e..a91b8f900c 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -397,6 +397,31 @@ static void monolithic_fft(AVTXContext *s, void *_out, 
void *_in,
 fft_dispatch[mb](out);
 }
 
+static void naive_fft(AVTXContext *s, void *_out, void *_in,
+  ptrdiff_t stride)
+{
+FFTComplex *in = _in;
+FFTComplex *out = _out;
+const int n = s->n;
+double phase = s->inv ? 2.0*M_PI/n : -2.0*M_PI/n;
+
+for(int i = 0; i < n; i++) {
+FFTComplex tmp = { 0 };
+for(int j = 0; j < n; j++) {
+const double factor = phase*i*j;
+const FFTComplex mult = {
+RESCALE(cos(factor)),
+RESCALE(sin(factor)),
+};
+FFTComplex res;
+CMUL3(res, in[j], mult);
+tmp.re += res.re;
+tmp.im += res.im;
+}
+out[i] = tmp;
+}
+}
+
 #define DECL_COMP_IMDCT(N) 
\
 static void compound_imdct_##N##xM(AVTXContext *s, void *_dst, void *_src, 
\
ptrdiff_t stride)   
\
@@ -553,6 +578,57 @@ static void monolithic_mdct(AVTXContext *s, void *_dst, 
void *_src,
 }
 }
 
+static void naive_imdct(AVTXContext *s, void *_dst, void *_src,
+ptrdiff_t stride)
+{
+int len = s->n;
+int len2 = len*2;
+FFTSample *src = _src;
+FFTSample *dst = _dst;
+double scale = s->scale;
+const double phase = M_PI/(4.0*len2);
+
+stride /= sizeof(*src);
+
+for (int i = 0; i < len; i++) {
+double sum_d = 0.0;
+double sum_u = 0.0;
+double i_d = phase * (4*len  - 2*i - 1);
+double i_u = phase * (3*len2 + 2*i + 1);
+for (int j = 0; j < len2; j++) {
+double a = (2 * j + 1);
+double a_d = cos(a * i_d);
+double a_u = cos(a * i_u);
+double val = UNSCALE(src[j*stride]);
+sum_d += a_d * val;
+sum_u += a_u * val;
+}
+  

[FFmpeg-cvslog] kmsgrab: Do not require the modifier to stay constant.

2021-01-13 Thread Bas Nieuwenhuizen
ffmpeg | branch: master | Bas Nieuwenhuizen  | Sat 
Nov 14 00:15:47 2020 +0100| [4386060164deb07d9fdda1716d9a3c07b24b271c] | 
committer: Mark Thompson

kmsgrab: Do not require the modifier to stay constant.

As we get a new set of objects each frame anyway, we
do not gain anything by keeping the modifier constant.

This helps with capturing when switching your setup a
bit, e.g. from ingame to desktop or from X11 to wayland.

Signed-off-by: Mark Thompson 

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

 libavdevice/kmsgrab.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
index b740a32171..94e32b9cae 100644
--- a/libavdevice/kmsgrab.c
+++ b/libavdevice/kmsgrab.c
@@ -176,13 +176,6 @@ static int kmsgrab_get_fb2(AVFormatContext *avctx,
 err = AVERROR(EIO);
 goto fail;
 }
-if (fb->modifier != ctx->drm_format_modifier) {
-av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" framebuffer "
-   "format modifier changed: now %"PRIx64".\n",
-   ctx->plane_id, fb->modifier);
-err = AVERROR(EIO);
-goto fail;
-}
 if (fb->width != ctx->width || fb->height != ctx->height) {
 av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" framebuffer "
"dimensions changed: now %"PRIu32"x%"PRIu32".\n",

___
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] kmsgrab: Use invalid modifier if modifiers weren't used.

2021-01-13 Thread Bas Nieuwenhuizen
ffmpeg | branch: master | Bas Nieuwenhuizen  | Sat 
Nov 14 00:15:46 2020 +0100| [03f4b203ba0ec58fc5c1ef8ee1fe740b8fcab9ab] | 
committer: Mark Thompson

kmsgrab: Use invalid modifier if modifiers weren't used.

The kernel defaults to initializing the field to 0 when modifiers
are not used and this happens to be linear. If we end up actually
passing the modifier to a driver, tiling issues happen.

So if the kernel doesn't return a modifier set it explicitly to
INVALID. That way later processing knows there is no explicit
modifier.

Signed-off-by: Mark Thompson 

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

 libavdevice/kmsgrab.c | 27 +--
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
index a0aa9dc22f..b740a32171 100644
--- a/libavdevice/kmsgrab.c
+++ b/libavdevice/kmsgrab.c
@@ -160,6 +160,7 @@ static int kmsgrab_get_fb2(AVFormatContext *avctx,
 KMSGrabContext *ctx = avctx->priv_data;
 drmModeFB2 *fb;
 int err, i, nb_objects;
+uint64_t modifier = ctx->drm_format_modifier;
 
 fb = drmModeGetFB2(ctx->hwctx->fd, plane->fb_id);
 if (!fb) {
@@ -195,6 +196,9 @@ static int kmsgrab_get_fb2(AVFormatContext *avctx,
 goto fail;
 }
 
+if (fb->flags & DRM_MODE_FB_MODIFIERS)
+modifier = fb->modifier;
+
 *desc = (AVDRMFrameDescriptor) {
 .nb_layers = 1,
 .layers[0] = {
@@ -243,7 +247,7 @@ static int kmsgrab_get_fb2(AVFormatContext *avctx,
 desc->objects[obj] = (AVDRMObjectDescriptor) {
 .fd  = fd,
 .size= size,
-.format_modifier = fb->modifier,
+.format_modifier = modifier,
 };
 desc->layers[0].planes[i] = (AVDRMPlaneDescriptor) {
 .object_index = obj,
@@ -557,15 +561,18 @@ static av_cold int kmsgrab_read_header(AVFormatContext 
*avctx)
 err = AVERROR(EINVAL);
 goto fail;
 }
-if (ctx->drm_format_modifier != DRM_FORMAT_MOD_INVALID &&
-ctx->drm_format_modifier != fb2->modifier) {
-av_log(avctx, AV_LOG_ERROR, "Framebuffer format modifier "
-   "%"PRIx64" does not match expected modifier.\n",
-   fb2->modifier);
-err = AVERROR(EINVAL);
-goto fail;
-} else {
-ctx->drm_format_modifier = fb2->modifier;
+
+if (fb2->flags & DRM_MODE_FB_MODIFIERS) {
+if (ctx->drm_format_modifier != DRM_FORMAT_MOD_INVALID &&
+ctx->drm_format_modifier != fb2->modifier) {
+av_log(avctx, AV_LOG_ERROR, "Framebuffer format modifier "
+   "%"PRIx64" does not match expected modifier.\n",
+   fb2->modifier);
+err = AVERROR(EINVAL);
+goto fail;
+} else {
+ctx->drm_format_modifier = fb2->modifier;
+}
 }
 av_log(avctx, AV_LOG_VERBOSE, "Format is %s, from "
"DRM format %"PRIx32" modifier %"PRIx64".\n",

___
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] ac3enc: do not clip coefficients after transforms

2021-01-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Jan  9 09:05:18 2021 
+0100| [784c08af3005390cb1d74add13b58edf1663cd40] | committer: Lynne

ac3enc: do not clip coefficients after transforms

In either encoder, its impossible for the coefficients to go past 25 bits
right after the MDCT. Our MDCT is numerically stable.
For the floating point encoder, in case a NaN is contained, lrintf() will
raise a floating point exception during the conversion.

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

 libavcodec/ac3enc_template.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index de6eba71d8..4f1e181e0b 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -383,9 +383,6 @@ int AC3_NAME(encode_frame)(AVCodecContext *avctx, AVPacket 
*avpkt,
 
 apply_mdct(s);
 
-clip_coefficients(&s->adsp, s->blocks[0].mdct_coef[1],
-  AC3_MAX_COEFS * s->num_blocks * s->channels);
-
 s->cpl_on = s->cpl_enabled;
 ff_ac3_compute_coupling_strategy(s);
 

___
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] ac3enc_fixed: convert to 32-bit sample format

2021-01-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Jan  9 01:51:52 2021 
+0100| [2d85e6e7230406e33e61d903b9c29ab562e158bd] | committer: Lynne

ac3enc_fixed: convert to 32-bit sample format

The AC3 encoder used to be a separate library called "Aften", which
got merged into libavcodec (literally, SVN commits and all).
The merge preserved as much features from the library as possible.

The code had two versions - a fixed point version and a floating
point version. FFmpeg had floating point DSP code used by other
codecs, the AC3 decoder including, so the floating-point DSP was
simply replaced with FFmpeg's own functions.
However, FFmpeg had no fixed-point audio code at that point. So
the encoder brought along its own fixed-point DSP functions,
including a fixed-point MDCT.

The fixed-point MDCT itself is trivially just a float MDCT with a
different type and each multiply being a fixed-point multiply.
So over time, it got refactored, and the FFT used for all other codecs
was templated.

Due to design decisions at the time, the fixed-point version of the
encoder operates at 16-bits of precision. Although convenient, this,
even at the time, was inadequate and inefficient. The encoder is noisy,
does not produce output comparable to the float encoder, and even
rings at higher frequencies due to the badly approximated winow function.

Enter MIPS (owned by Imagination Technologies at the time). They wanted
quick fixed-point decoding on their FPUless cores. So they contributed
patches to template the AC3 decoder so it had both a fixed-point
and a floating-point version. They also did the same for the AAC decoder.
They however, used 32-bit samples. Not 16-bits. And we did not have
32-bit fixed-point DSP functions, including an MDCT. But instead of
templating our MDCT to output 3 versions (float, 32-bit fixed and 16-bit fixed),
they simply copy-pasted their own MDCT into ours, and completely
ifdeffed our own MDCT code out if a 32-bit fixed point MDCT was selected.

This is also the status quo nowadays - 2 separate MDCTs, one which
produces floating point and 16-bit fixed point versions, and one
sort-of integrated which produces 32-bit MDCT.

MIPS weren't all that interested in encoding, so they left the encoder
as-is, and they didn't care much about the ifdeffery, mess or quality - it's
not their problem.

So the MDCT/FFT code has always been a thorn in anyone looking to clean up
code's eye.

Backstory over. Internally AC3 operates on 25-bit fixed-point coefficients.
So for the floating point version, the encoder simply runs the float MDCT,
and converts the resulting coefficients to 25-bit fixed-point, as AC3 is 
inherently
a fixed-point codec. For the fixed-point version, the input is 16-bit samples,
so to maximize precision the frame samples are analyzed and the highest set
bit is detected via ac3_max_msb_abs_int16(), and the coefficients are then
scaled up via ac3_lshift_int16(), so the input for the FFT is always at least 
14 bits,
computed in normalize_samples(). After FFT, the coefficients are scaled up to 
25 bits.

This patch simply changes the encoder to accept 32-bit samples, reusing
the already well-optimized 32-bit MDCT code, allowing us to clean up and drop
a large part of a very messy code of ours, as well as prepare for the future 
lavu/tx
conversion. The coefficients are simply scaled down to 25 bits during windowing,
skipping 2 separate scalings, as the hacks to extend precision are simply no 
longer
necessary. There's no point in running the MDCT always at 32 bits when you're
going to drop 6 bits off anyway, the headroom is plenty, and the MDCT rounds
properly.

This also makes the encoder even slightly more accurate over the float version,
as there's no coefficient conversion step necessary.

SIZE SAVINGS:
ARM32:
HARDCODED TABLES:
BASE   - 10709590
DROP  DSP  - 10702872 - diff:   -6.56KiB
DROP  MDCT - 10667932 - diff:  -34.12KiB - both:   -40.68KiB
DROP  FFT  - 10336652 - diff: -323.52KiB - all:   -364.20KiB
SOFTCODED TABLES:
BASE   -  9685096
DROP  DSP  -  9678378 - diff:   -6.56KiB
DROP  MDCT -  9643466 - diff:  -34.09KiB - both:   -40.65KiB
DROP  FFT  -  9573918 - diff:  -67.92KiB - all:   -108.57KiB

ARM64:
HARDCODED TABLES:
BASE   - 14641112
DROP  DSP  - 14633806 - diff:   -7.13KiB
DROP  MDCT - 14604812 - diff:  -28.31KiB - both:   -35.45KiB
DROP  FFT  - 14286826 - diff: -310.53KiB - all:   -345.98KiB
SOFTCODED TABLES:
BASE   - 13636238
DROP  DSP  - 13628932 - diff:   -7.13KiB
DROP  MDCT - 13599866 - diff:  -28.38KiB - both:   -35.52KiB
DROP  FFT  - 13542080 - diff:  -56.43KiB - all:-91.95KiB

x86:
HARDCODED TABLES:
BASE   - 12367336
DROP  DSP  - 12354698 - diff:  -12.34KiB
DROP  MDCT - 12331024 - diff:  -23.12KiB - both:   -35.46KiB
DROP  FFT  - 12029788 - diff: -294.18KiB - all:   -329.64KiB
SOFTCODED TABLES:
BASE   - 11358094
DROP  DSP  - 11345456 - diff:  -12.34KiB
DROP  MDCT - 1132174

[FFmpeg-cvslog] ac3enc: halve the MDCT window size by using vector_fmul_reverse

2021-01-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Jan  9 17:27:16 2021 
+0100| [238b2d4155d9779d770fccb3594076bb32742c82] | committer: Lynne

ac3enc: halve the MDCT window size by using vector_fmul_reverse

This brings the encoder in-line with the rest of ours and saves
on a bit of memory.

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

 libavcodec/ac3enc_fixed.c|  8 +++-
 libavcodec/ac3enc_float.c| 15 ---
 libavcodec/ac3enc_template.c |  5 -
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index eab086cdab..7a8a77fb93 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -101,15 +101,13 @@ static av_cold int ac3_fixed_mdct_init(AC3EncodeContext 
*s)
 {
 float fwin[AC3_BLOCK_SIZE];
 
-int32_t *iwin = av_malloc_array(AC3_WINDOW_SIZE, sizeof(*iwin));
+int32_t *iwin = av_malloc_array(AC3_BLOCK_SIZE, sizeof(*iwin));
 if (!iwin)
 return AVERROR(ENOMEM);
 
-ff_kbd_window_init(fwin, 5.0, AC3_WINDOW_SIZE/2);
-for (int i = 0; i < AC3_WINDOW_SIZE/2; i++) {
+ff_kbd_window_init(fwin, 5.0, AC3_BLOCK_SIZE);
+for (int i = 0; i < AC3_BLOCK_SIZE; i++)
 iwin[i] = lrintf(fwin[i] * (1 << 22));
-iwin[AC3_WINDOW_SIZE-1-i] = lrintf(fwin[i] * (1 << 22));
-}
 
 s->mdct_window = iwin;
 
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index b17b3a2365..74f3ab8d86 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -108,23 +108,16 @@ static av_cold void ac3_float_mdct_end(AC3EncodeContext 
*s)
  */
 static av_cold int ac3_float_mdct_init(AC3EncodeContext *s)
 {
-float *window;
-int i, n, n2;
-
-n  = 1 << 9;
-n2 = n >> 1;
-
-window = av_malloc_array(n, sizeof(*window));
+float *window = av_malloc_array(AC3_BLOCK_SIZE, sizeof(*window));
 if (!window) {
 av_log(s->avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
 return AVERROR(ENOMEM);
 }
-ff_kbd_window_init(window, 5.0, n2);
-for (i = 0; i < n2; i++)
-window[n-1-i] = window[i];
+
+ff_kbd_window_init(window, 5.0, AC3_BLOCK_SIZE);
 s->mdct_window = window;
 
-return ff_mdct_init(&s->mdct, 9, 0, -2.0 / n);
+return ff_mdct_init(&s->mdct, 9, 0, -2.0 / AC3_WINDOW_SIZE);
 }
 
 
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index 4f1e181e0b..5ecef3b178 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -92,7 +92,10 @@ static void apply_mdct(AC3EncodeContext *s)
 const SampleType *input_samples = &s->planar_samples[ch][blk * 
AC3_BLOCK_SIZE];
 
 s->fdsp->vector_fmul(s->windowed_samples, input_samples,
- s->mdct_window, AC3_WINDOW_SIZE);
+ s->mdct_window, AC3_BLOCK_SIZE);
+s->fdsp->vector_fmul_reverse(s->windowed_samples + AC3_BLOCK_SIZE,
+ &input_samples[AC3_BLOCK_SIZE],
+ s->mdct_window, AC3_BLOCK_SIZE);
 
 s->mdct.mdct_calc(&s->mdct, block->mdct_coef[ch+1],
   s->windowed_samples);

___
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] ac3enc_fixed: drop unnecessary fixed-point DSP code

2021-01-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Jan  9 03:19:18 2021 
+0100| [9e05421dbe0c733dca2a39f8399db86acc7e82bc] | committer: Lynne

ac3enc_fixed: drop unnecessary fixed-point DSP code

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

 libavcodec/ac3dsp.c  |  60 -
 libavcodec/ac3dsp.h  |  47 ---
 libavcodec/ac3tab.c  |  38 --
 libavcodec/ac3tab.h  |   1 -
 libavcodec/arm/ac3dsp_init_arm.c |   9 --
 libavcodec/x86/ac3dsp.asm| 258 ---
 libavcodec/x86/ac3dsp_init.c |  52 +---
 7 files changed, 1 insertion(+), 464 deletions(-)

diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
index 382f87c05f..85c721dd3b 100644
--- a/libavcodec/ac3dsp.c
+++ b/libavcodec/ac3dsp.c
@@ -46,49 +46,6 @@ static void ac3_exponent_min_c(uint8_t *exp, int 
num_reuse_blocks, int nb_coefs)
 }
 }
 
-static int ac3_max_msb_abs_int16_c(const int16_t *src, int len)
-{
-int i, v = 0;
-for (i = 0; i < len; i++)
-v |= abs(src[i]);
-return v;
-}
-
-static void ac3_lshift_int16_c(int16_t *src, unsigned int len,
-   unsigned int shift)
-{
-uint32_t *src32 = (uint32_t *)src;
-const uint32_t mask = ~(((1 << shift) - 1) << 16);
-int i;
-len >>= 1;
-for (i = 0; i < len; i += 8) {
-src32[i  ] = (src32[i  ] << shift) & mask;
-src32[i+1] = (src32[i+1] << shift) & mask;
-src32[i+2] = (src32[i+2] << shift) & mask;
-src32[i+3] = (src32[i+3] << shift) & mask;
-src32[i+4] = (src32[i+4] << shift) & mask;
-src32[i+5] = (src32[i+5] << shift) & mask;
-src32[i+6] = (src32[i+6] << shift) & mask;
-src32[i+7] = (src32[i+7] << shift) & mask;
-}
-}
-
-static void ac3_rshift_int32_c(int32_t *src, unsigned int len,
-   unsigned int shift)
-{
-do {
-*src++ >>= shift;
-*src++ >>= shift;
-*src++ >>= shift;
-*src++ >>= shift;
-*src++ >>= shift;
-*src++ >>= shift;
-*src++ >>= shift;
-*src++ >>= shift;
-len -= 8;
-} while (len > 0);
-}
-
 static void float_to_fixed24_c(int32_t *dst, const float *src, unsigned int 
len)
 {
 const float scale = 1 << 24;
@@ -376,19 +333,6 @@ void ff_ac3dsp_downmix_fixed(AC3DSPContext *c, int32_t 
**samples, int16_t **matr
 ac3_downmix_c_fixed(samples, matrix, out_ch, in_ch, len);
 }
 
-static void apply_window_int16_c(int16_t *output, const int16_t *input,
- const int16_t *window, unsigned int len)
-{
-int i;
-int len2 = len >> 1;
-
-for (i = 0; i < len2; i++) {
-int16_t w   = window[i];
-output[i]   = (MUL16(input[i],   w) + (1 << 14)) >> 15;
-output[len-i-1] = (MUL16(input[len-i-1], w) + (1 << 14)) >> 15;
-}
-}
-
 void ff_ac3dsp_downmix(AC3DSPContext *c, float **samples, float **matrix,
int out_ch, int in_ch, int len)
 {
@@ -424,9 +368,6 @@ void ff_ac3dsp_downmix(AC3DSPContext *c, float **samples, 
float **matrix,
 av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
 {
 c->ac3_exponent_min = ac3_exponent_min_c;
-c->ac3_max_msb_abs_int16 = ac3_max_msb_abs_int16_c;
-c->ac3_lshift_int16 = ac3_lshift_int16_c;
-c->ac3_rshift_int32 = ac3_rshift_int32_c;
 c->float_to_fixed24 = float_to_fixed24_c;
 c->bit_alloc_calc_bap = ac3_bit_alloc_calc_bap_c;
 c->update_bap_counts = ac3_update_bap_counts_c;
@@ -438,7 +379,6 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
 c->out_channels  = 0;
 c->downmix   = NULL;
 c->downmix_fixed = NULL;
-c->apply_window_int16 = apply_window_int16_c;
 
 if (ARCH_ARM)
 ff_ac3dsp_init_arm(c, bit_exact);
diff --git a/libavcodec/ac3dsp.h b/libavcodec/ac3dsp.h
index 161de4cb86..a23b11526e 100644
--- a/libavcodec/ac3dsp.h
+++ b/libavcodec/ac3dsp.h
@@ -42,39 +42,6 @@ typedef struct AC3DSPContext {
  */
 void (*ac3_exponent_min)(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
 
-/**
- * Calculate the maximum MSB of the absolute value of each element in an
- * array of int16_t.
- * @param src input array
- *constraints: align 16. values must be in range [-32767,32767]
- * @param len number of values in the array
- *constraints: multiple of 16 greater than 0
- * @returna value with the same MSB as max(abs(src[]))
- */
-int (*ac3_max_msb_abs_int16)(const int16_t *src, int len);
-
-/**
- * Left-shift each value in an array of int16_t by a specified amount.
- * @param srcinput array
- *   constraints: align 16
- * @param lennumber of values in the array
- *   constraints: multiple of 32 greater than 0
- * @param shift  left shift amount
- *   const

[FFmpeg-cvslog] fft: remove 16-bit FFT and MDCT code

2021-01-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Jan  9 16:23:20 2021 
+0100| [151b41c8cc55eec5e7bf8896c21cdc0c1f99b3cf] | committer: Lynne

fft: remove 16-bit FFT and MDCT code

No longer used by anything.
Unfortunately the old FFT_FLOAT/FFT_FIXED_32 is left as-is. It's
simply too much work for code meant to be all removed anyway.

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

 libavcodec/Makefile |  11 +-
 libavcodec/arm/Makefile |   9 +-
 libavcodec/arm/fft_fixed_init_arm.c |  50 ---
 libavcodec/arm/fft_fixed_neon.S | 261 
 libavcodec/arm/mdct_fixed_neon.S| 193 --
 libavcodec/fft-internal.h   |  29 +---
 libavcodec/fft.h|   9 --
 libavcodec/fft_fixed.c  |  21 ---
 libavcodec/fft_template.c   |   4 -
 libavcodec/mdct_fixed.c |  65 -
 libavcodec/tests/.gitignore |   1 -
 libavcodec/tests/fft-fixed.c|  21 ---
 tests/fate/fft.mak  |  30 +
 13 files changed, 14 insertions(+), 690 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0546e6f6c5..446e6e6b3b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -83,10 +83,9 @@ OBJS-$(CONFIG_EXIF)+= exif.o 
tiff_common.o
 OBJS-$(CONFIG_FAANDCT) += faandct.o
 OBJS-$(CONFIG_FAANIDCT)+= faanidct.o
 OBJS-$(CONFIG_FDCTDSP) += fdctdsp.o jfdctfst.o jfdctint.o
-FFT-OBJS-$(CONFIG_HARDCODED_TABLES)+= cos_tables.o cos_fixed_tables.o
-OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \
-  fft_fixed_32.o fft_init_table.o \
-  $(FFT-OBJS-yes)
+FFT-OBJS-$(CONFIG_HARDCODED_TABLES)+= cos_tables.o
+OBJS-$(CONFIG_FFT) += avfft.o fft_float.o fft_fixed_32.o \
+  fft_init_table.o $(FFT-OBJS-yes)
 OBJS-$(CONFIG_FLACDSP) += flacdsp.o
 OBJS-$(CONFIG_FMTCONVERT)  += fmtconvert.o
 OBJS-$(CONFIG_GOLOMB)  += golomb.o
@@ -115,7 +114,7 @@ OBJS-$(CONFIG_LLVIDENCDSP) += 
lossless_videoencdsp.o
 OBJS-$(CONFIG_LPC) += lpc.o
 OBJS-$(CONFIG_LSP) += lsp.o
 OBJS-$(CONFIG_LZF) += lzf.o
-OBJS-$(CONFIG_MDCT)+= mdct_fixed.o mdct_float.o 
mdct_fixed_32.o
+OBJS-$(CONFIG_MDCT)+= mdct_float.o mdct_fixed_32.o
 OBJS-$(CONFIG_ME_CMP)  += me_cmp.o
 OBJS-$(CONFIG_MEDIACODEC)  += mediacodecdec_common.o 
mediacodec_surface.o mediacodec_wrapper.o mediacodec_sw_buffer.o
 OBJS-$(CONFIG_MPEG_ER) += mpeg_er.o
@@ -1217,7 +1216,7 @@ TESTPROGS = avpacket  
  \
 
 TESTPROGS-$(CONFIG_CABAC) += cabac
 TESTPROGS-$(CONFIG_DCT)   += avfft
-TESTPROGS-$(CONFIG_FFT)   += fft fft-fixed fft-fixed32
+TESTPROGS-$(CONFIG_FFT)   += fft fft-fixed32
 TESTPROGS-$(CONFIG_GOLOMB)+= golomb
 TESTPROGS-$(CONFIG_IDCTDSP)   += dct
 TESTPROGS-$(CONFIG_IIRFILTER) += iirfilter
diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile
index c6be814153..c4ab93aeeb 100644
--- a/libavcodec/arm/Makefile
+++ b/libavcodec/arm/Makefile
@@ -5,8 +5,7 @@ OBJS-$(CONFIG_AC3DSP)  += arm/ac3dsp_init_arm.o 
\
   arm/ac3dsp_arm.o
 OBJS-$(CONFIG_AUDIODSP)+= arm/audiodsp_init_arm.o
 OBJS-$(CONFIG_BLOCKDSP)+= arm/blockdsp_init_arm.o
-OBJS-$(CONFIG_FFT) += arm/fft_init_arm.o\
-  arm/fft_fixed_init_arm.o
+OBJS-$(CONFIG_FFT) += arm/fft_init_arm.o
 OBJS-$(CONFIG_FLACDSP) += arm/flacdsp_init_arm.o\
   arm/flacdsp_arm.o
 OBJS-$(CONFIG_FMTCONVERT)  += arm/fmtconvert_init_arm.o
@@ -108,8 +107,7 @@ NEON-OBJS-$(CONFIG_AUDIODSP)   += 
arm/audiodsp_init_neon.o  \
   arm/int_neon.o
 NEON-OBJS-$(CONFIG_BLOCKDSP)   += arm/blockdsp_init_neon.o  \
   arm/blockdsp_neon.o
-NEON-OBJS-$(CONFIG_FFT)+= arm/fft_neon.o\
-  arm/fft_fixed_neon.o
+NEON-OBJS-$(CONFIG_FFT)+= arm/fft_neon.o
 NEON-OBJS-$(CONFIG_FMTCONVERT) += arm/fmtconvert_neon.o
 NEON-OBJS-$(CONFIG_G722DSP)+= arm/g722dsp_neon.o
 NEON-OBJS-$(CONFIG_H264CHROMA) += arm/h264cmc_neon.o
@@ -123,8 +121,7 @@ NEON-OBJS-$(CONFIG_HPELDSP)+= 
arm/hpeldsp_init_neon.o   \
 NEON-OBJS-$(CONFIG_I

[FFmpeg-cvslog] avutil/tx: use ENOSYS instead of ENOTSUP

2021-01-13 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Jan 13 23:02:19 
2021 -0300| [f6477ac9f4daf3de2604d1cc5b27e66952d610b1] | committer: James Almer

avutil/tx: use ENOSYS instead of ENOTSUP

It's the standard error code used across the codebase to signal unimplemented
or unsupported features.

Signed-off-by: James Almer 

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

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

diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index a91b8f900c..155e879f8e 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -684,7 +684,7 @@ int TX_NAME(ff_tx_init_mdct_fft)(AVTXContext *s, av_tx_fn 
*tx,
  * direct 3, 5 and 15 transforms as they're too niche. */
 if (len > 1 || m == 1) {
 if (is_mdct && (l & 1)) /* Odd (i)MDCTs are not supported yet */
-return AVERROR(ENOTSUP);
+return AVERROR(ENOSYS);
 s->n = l;
 s->m = 1;
 *tx = naive_fft;

___
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".