2011-02-10 19:20:36 +02:00
|
|
|
/*
|
2014-01-29 15:12:59 +03:00
|
|
|
* x86-optimized AC-3 DSP functions
|
2011-02-10 19:20:36 +02:00
|
|
|
* Copyright (c) 2011 Justin Ruggles
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2014-01-09 16:06:31 +03:00
|
|
|
#include "libavutil/attributes.h"
|
2012-08-08 15:51:52 +03:00
|
|
|
#include "libavutil/x86/asm.h"
|
2012-08-29 20:01:05 +03:00
|
|
|
#include "libavutil/x86/cpu.h"
|
2011-02-10 19:20:36 +02:00
|
|
|
#include "libavcodec/ac3dsp.h"
|
|
|
|
|
2013-03-26 20:41:24 +03:00
|
|
|
void ff_ac3_exponent_min_sse2 (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
|
2011-02-10 19:20:36 +02:00
|
|
|
|
2023-11-22 21:41:00 +02:00
|
|
|
void ff_float_to_fixed24_sse2 (int32_t *dst, const float *src, size_t len);
|
2023-11-22 21:25:54 +02:00
|
|
|
void ff_float_to_fixed24_avx (int32_t *dst, const float *src, size_t len);
|
2011-03-16 04:29:04 +02:00
|
|
|
|
2013-03-26 20:41:24 +03:00
|
|
|
int ff_ac3_compute_mantissa_size_sse2(uint16_t mant_cnt[6][16]);
|
2011-05-26 22:53:25 +03:00
|
|
|
|
2013-03-26 20:41:24 +03:00
|
|
|
void ff_ac3_extract_exponents_sse2 (uint8_t *exp, int32_t *coef, int nb_coefs);
|
|
|
|
void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs);
|
2011-07-01 00:48:44 +03:00
|
|
|
|
2022-09-26 15:04:26 +02:00
|
|
|
av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c)
|
2011-02-10 19:20:36 +02:00
|
|
|
{
|
2013-07-17 21:19:24 +03:00
|
|
|
int cpu_flags = av_get_cpu_flags();
|
2011-02-10 19:20:36 +02:00
|
|
|
|
2013-07-17 21:19:24 +03:00
|
|
|
if (EXTERNAL_SSE2(cpu_flags)) {
|
2011-02-10 19:20:36 +02:00
|
|
|
c->ac3_exponent_min = ff_ac3_exponent_min_sse2;
|
2011-03-16 04:29:04 +02:00
|
|
|
c->float_to_fixed24 = ff_float_to_fixed24_sse2;
|
2011-05-26 22:53:25 +03:00
|
|
|
c->compute_mantissa_size = ff_ac3_compute_mantissa_size_sse2;
|
2011-07-01 00:48:44 +03:00
|
|
|
c->extract_exponents = ff_ac3_extract_exponents_sse2;
|
2011-02-13 21:49:50 +02:00
|
|
|
}
|
2016-01-14 11:57:41 +02:00
|
|
|
|
2013-07-17 21:19:24 +03:00
|
|
|
if (EXTERNAL_SSSE3(cpu_flags)) {
|
2021-01-09 04:19:18 +02:00
|
|
|
if (!(cpu_flags & AV_CPU_FLAG_ATOM))
|
2011-07-01 00:48:44 +03:00
|
|
|
c->extract_exponents = ff_ac3_extract_exponents_ssse3;
|
2011-02-10 19:20:36 +02:00
|
|
|
}
|
2023-11-22 21:25:54 +02:00
|
|
|
if (EXTERNAL_AVX_FAST(cpu_flags)) {
|
|
|
|
c->float_to_fixed24 = ff_float_to_fixed24_avx;
|
|
|
|
}
|
2015-10-28 16:38:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DOWNMIX_FUNC_OPT(ch, opt) \
|
|
|
|
void ff_ac3_downmix_ ## ch ## _to_1_ ## opt(float **samples, \
|
|
|
|
float **matrix, int len); \
|
|
|
|
void ff_ac3_downmix_ ## ch ## _to_2_ ## opt(float **samples, \
|
|
|
|
float **matrix, int len);
|
|
|
|
|
|
|
|
#define DOWNMIX_FUNCS(opt) \
|
|
|
|
DOWNMIX_FUNC_OPT(3, opt) \
|
|
|
|
DOWNMIX_FUNC_OPT(4, opt) \
|
|
|
|
DOWNMIX_FUNC_OPT(5, opt) \
|
|
|
|
DOWNMIX_FUNC_OPT(6, opt)
|
|
|
|
|
|
|
|
DOWNMIX_FUNCS(sse)
|
|
|
|
DOWNMIX_FUNCS(avx)
|
|
|
|
DOWNMIX_FUNCS(fma3)
|
|
|
|
|
|
|
|
void ff_ac3dsp_set_downmix_x86(AC3DSPContext *c)
|
|
|
|
{
|
|
|
|
int cpu_flags = av_get_cpu_flags();
|
|
|
|
|
|
|
|
#define SET_DOWNMIX(ch, suf, SUF) \
|
|
|
|
if (ch == c->in_channels) { \
|
|
|
|
if (EXTERNAL_ ## SUF (cpu_flags)) { \
|
|
|
|
if (c->out_channels == 1) \
|
|
|
|
c->downmix = ff_ac3_downmix_ ## ch ## _to_1_ ## suf; \
|
|
|
|
else \
|
|
|
|
c->downmix = ff_ac3_downmix_ ## ch ## _to_2_ ## suf; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SET_DOWNMIX_ALL(suf, SUF) \
|
|
|
|
SET_DOWNMIX(3, suf, SUF) \
|
|
|
|
SET_DOWNMIX(4, suf, SUF) \
|
|
|
|
SET_DOWNMIX(5, suf, SUF) \
|
|
|
|
SET_DOWNMIX(6, suf, SUF)
|
2012-09-11 19:55:11 +03:00
|
|
|
|
2015-10-28 16:38:22 +02:00
|
|
|
SET_DOWNMIX_ALL(sse, SSE)
|
|
|
|
if (!(cpu_flags & AV_CPU_FLAG_AVXSLOW)) {
|
|
|
|
SET_DOWNMIX_ALL(avx, AVX)
|
|
|
|
SET_DOWNMIX_ALL(fma3, FMA3)
|
2012-09-11 19:55:11 +03:00
|
|
|
}
|
2011-02-10 19:20:36 +02:00
|
|
|
}
|