From 27e28a59524e899010ea36a2936b0f7a31572bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 11 Apr 2024 02:12:16 +0200 Subject: [PATCH] Remove samplefmt --- Common/Common.vcxproj | 14 +- Common/Common.vcxproj.filters | 32 +- ext/at3_standalone/aac_defines.h | 2 - ext/at3_standalone/atrac.c | 4 +- ext/at3_standalone/atrac3.c | 8 +- ext/at3_standalone/atrac3plus.c | 4 +- ext/at3_standalone/atrac3plusdec.c | 2 +- ext/at3_standalone/atrac3plusdsp.c | 5 +- ext/at3_standalone/avcodec.c | 116 ++++++- ext/at3_standalone/avcodec.h | 2 +- ext/at3_standalone/avfft.h | 34 -- ext/at3_standalone/avutil.h | 91 +----- ext/at3_standalone/bitstream.c | 23 +- ext/at3_standalone/channel_layout.c | 2 + ext/at3_standalone/common.h | 1 - ext/at3_standalone/compat.c | 43 +-- ext/at3_standalone/compat.h | 13 +- ext/at3_standalone/dct.c | 224 ------------- ext/at3_standalone/dct.h | 68 ---- ext/at3_standalone/error.h | 45 --- ext/at3_standalone/fft-internal.h | 43 --- ext/at3_standalone/fft.h | 56 +--- ext/at3_standalone/fft_template.c | 78 ++--- ext/at3_standalone/float_dsp.c | 2 +- ext/at3_standalone/libm.h | 448 -------------------------- ext/at3_standalone/log.h | 1 - ext/at3_standalone/mathematics.c | 1 - ext/at3_standalone/mdct_template.c | 11 +- ext/at3_standalone/mem.c | 2 - ext/at3_standalone/mem.h | 3 +- ext/at3_standalone/qsort.h | 122 ------- ext/at3_standalone/samplefmt.c | 237 -------------- ext/at3_standalone/samplefmt.h | 259 --------------- ext/at3_standalone/sinewin.c | 42 ++- ext/at3_standalone/sinewin.h | 46 +-- ext/at3_standalone/sinewin_tablegen.c | 24 -- ext/at3_standalone/sinewin_tablegen.h | 80 ----- ext/at3_standalone/util_internal.h | 40 --- ext/at3_standalone/utils.c | 145 --------- ext/at3_standalone/version.h | 62 ---- 40 files changed, 268 insertions(+), 2167 deletions(-) delete mode 100644 ext/at3_standalone/avfft.h delete mode 100644 ext/at3_standalone/dct.c delete mode 100644 ext/at3_standalone/dct.h delete mode 100644 ext/at3_standalone/error.h delete mode 100644 ext/at3_standalone/fft-internal.h delete mode 100644 ext/at3_standalone/libm.h delete mode 100644 ext/at3_standalone/qsort.h delete mode 100644 ext/at3_standalone/samplefmt.c delete mode 100644 ext/at3_standalone/samplefmt.h delete mode 100644 ext/at3_standalone/sinewin_tablegen.c delete mode 100644 ext/at3_standalone/sinewin_tablegen.h delete mode 100644 ext/at3_standalone/util_internal.h delete mode 100644 ext/at3_standalone/utils.c delete mode 100644 ext/at3_standalone/version.h diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index 1051eab494..9335079a50 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -1,4 +1,4 @@ - + @@ -391,29 +391,21 @@ - + - - - - - - - - @@ -628,9 +620,7 @@ - - NotUsing diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters index 0afb65955f..d775f3f937 100644 --- a/Common/Common.vcxproj.filters +++ b/Common/Common.vcxproj.filters @@ -554,24 +554,12 @@ ext\at3_standalone - - ext\at3_standalone - - - ext\at3_standalone - ext\at3_standalone - - ext\at3_standalone - ext\at3_standalone - - ext\at3_standalone - ext\at3_standalone @@ -581,15 +569,9 @@ ext\at3_standalone - - ext\at3_standalone - ext\at3_standalone - - ext\at3_standalone - ext\at3_standalone @@ -602,13 +584,7 @@ ext\at3_standalone - - ext\at3_standalone - - - ext\at3_standalone - - + ext\at3_standalone @@ -1083,9 +1059,6 @@ ext\at3_standalone - - ext\at3_standalone - ext\at3_standalone @@ -1098,9 +1071,6 @@ ext\at3_standalone - - ext\at3_standalone - ext\at3_standalone diff --git a/ext/at3_standalone/aac_defines.h b/ext/at3_standalone/aac_defines.h index eff63b347c..d9aa087fc3 100644 --- a/ext/at3_standalone/aac_defines.h +++ b/ext/at3_standalone/aac_defines.h @@ -80,8 +80,6 @@ typedef int AAC_SIGNE; #define FFT_FLOAT 1 #define FFT_FIXED_32 0 -#define AAC_RENAME(x) x -#define AAC_RENAME_32(x) x typedef float INTFLOAT; typedef float INT64FLOAT; typedef float SHORTFLOAT; diff --git a/ext/at3_standalone/atrac.c b/ext/at3_standalone/atrac.c index 12e8997dbc..8c6a3f0f89 100644 --- a/ext/at3_standalone/atrac.c +++ b/ext/at3_standalone/atrac.c @@ -45,7 +45,7 @@ static const float qmf_48tap_half[24] = { -0.043596379, -0.099384367, 0.13207909, 0.46424159 }; -av_cold void ff_atrac_generate_tables(void) +void ff_atrac_generate_tables(void) { int i; float s; @@ -63,7 +63,7 @@ av_cold void ff_atrac_generate_tables(void) } } -av_cold void ff_atrac_init_gain_compensation(AtracGCContext *gctx, int id2exp_offset, +void ff_atrac_init_gain_compensation(AtracGCContext *gctx, int id2exp_offset, int loc_scale) { int i; diff --git a/ext/at3_standalone/atrac3.c b/ext/at3_standalone/atrac3.c index 0c251aa1b7..630bc59dd3 100644 --- a/ext/at3_standalone/atrac3.c +++ b/ext/at3_standalone/atrac3.c @@ -168,7 +168,7 @@ static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes) return off; } -static av_cold void init_imdct_window(void) +static void init_imdct_window(void) { int i, j; @@ -183,7 +183,7 @@ static av_cold void init_imdct_window(void) } } -static av_cold int atrac3_decode_close(AVCodecContext *avctx) +static int atrac3_decode_close(AVCodecContext *avctx) { ATRAC3Context *q = avctx->priv_data; @@ -764,7 +764,7 @@ int atrac3_decode_frame(AVCodecContext *avctx, float *out_data[2], int *nb_sampl return avctx->block_align; } -static av_cold void atrac3_init_static_data(void) +static void atrac3_init_static_data(void) { int i; @@ -784,7 +784,7 @@ static av_cold void atrac3_init_static_data(void) static int static_init_done; -static av_cold int atrac3_decode_init(AVCodecContext *avctx) +static int atrac3_decode_init(AVCodecContext *avctx) { int i, ret; int version, delay, samples_per_frame, frame_factor; diff --git a/ext/at3_standalone/atrac3plus.c b/ext/at3_standalone/atrac3plus.c index e37f200c13..ec4ac42be1 100644 --- a/ext/at3_standalone/atrac3plus.c +++ b/ext/at3_standalone/atrac3plus.c @@ -49,7 +49,7 @@ static VLC tone_vlc_tabs[7]; * @param[in,out] tab_offset starting offset to the generated vlc table * @param[out] out_vlc ptr to vlc table to be generated */ -static av_cold void build_canonical_huff(const uint8_t *cb, const uint8_t *xlat, +static void build_canonical_huff(const uint8_t *cb, const uint8_t *xlat, int *tab_offset, VLC *out_vlc) { int i, b; @@ -79,7 +79,7 @@ static av_cold void build_canonical_huff(const uint8_t *cb, const uint8_t *xlat, *tab_offset += 1 << max_len; } -av_cold void ff_atrac3p_init_vlcs(void) +void ff_atrac3p_init_vlcs(void) { int i, wl_vlc_offs, ct_vlc_offs, sf_vlc_offs, tab_offset; diff --git a/ext/at3_standalone/atrac3plusdec.c b/ext/at3_standalone/atrac3plusdec.c index 7f942c80fa..e82bcab8ba 100644 --- a/ext/at3_standalone/atrac3plusdec.c +++ b/ext/at3_standalone/atrac3plusdec.c @@ -78,7 +78,7 @@ int atrac3p_decode_close(AVCodecContext *avctx) return 0; } -static av_cold int set_channel_params(ATRAC3PContext *ctx, +static int set_channel_params(ATRAC3PContext *ctx, AVCodecContext *avctx) { memset(ctx->channel_blocks, 0, sizeof(ctx->channel_blocks)); diff --git a/ext/at3_standalone/atrac3plusdsp.c b/ext/at3_standalone/atrac3plusdsp.c index 9c30a64415..399bbdc17e 100644 --- a/ext/at3_standalone/atrac3plusdsp.c +++ b/ext/at3_standalone/atrac3plusdsp.c @@ -29,7 +29,6 @@ #include #include "float_dsp.h" -#include "libm.h" #include "avcodec.h" #include "sinewin.h" #include "fft.h" @@ -78,7 +77,7 @@ const float ff_atrac3p_mant_tab[8] = { #define ATRAC3P_MDCT_SIZE (ATRAC3P_SUBBAND_SAMPLES * 2) -av_cold void ff_atrac3p_init_imdct(AVCodecContext *avctx, FFTContext *mdct_ctx) +void ff_atrac3p_init_imdct(AVCodecContext *avctx, FFTContext *mdct_ctx) { ff_init_ff_sine_windows(7); ff_init_ff_sine_windows(6); @@ -95,7 +94,7 @@ static DECLARE_ALIGNED(32, float, sine_table)[2048]; ///< wave table static DECLARE_ALIGNED(32, float, hann_window)[256]; ///< Hann windowing function static float amp_sf_tab[64]; ///< scalefactors for quantized amplitudes -av_cold void ff_atrac3p_init_wave_synth(void) +void ff_atrac3p_init_wave_synth(void) { int i; diff --git a/ext/at3_standalone/avcodec.c b/ext/at3_standalone/avcodec.c index 9f8f353db3..1956a1f360 100644 --- a/ext/at3_standalone/avcodec.c +++ b/ext/at3_standalone/avcodec.c @@ -25,10 +25,19 @@ */ #include "avcodec.h" +#include "compat.h" +#include "channel_layout.h" #include "common.h" -#include "util_internal.h" +#include "mathematics.h" +#include "avcodec.h" +#include "bytestream.h" #include "mem.h" + +#include +#include #include +#include +#include static const AVClass av_codec_context_class = { .class_name = "AVCodecContext", @@ -75,3 +84,108 @@ void avcodec_free_context(AVCodecContext **pavctx) av_freep(&avctx->extradata); av_freep(pavctx); } + + +int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, void **options) +{ + if ((codec && avctx->codec && codec != avctx->codec)) { + av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, " + "but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name); + return AVERROR(EINVAL); + } + if (!codec) + codec = avctx->codec; + + if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE) + return AVERROR(EINVAL); + + int ret = 0; + + if (codec->priv_data_size > 0) { + if (!avctx->priv_data) { + avctx->priv_data = av_mallocz(codec->priv_data_size); + if (!avctx->priv_data) { + ret = AVERROR(ENOMEM); + goto end; + } + if (codec->priv_class) { + *(const AVClass **)avctx->priv_data = codec->priv_class; + } + } + } else { + avctx->priv_data = NULL; + } + + if (avctx->channels > FF_SANE_NB_CHANNELS) { + ret = AVERROR(EINVAL); + goto free_and_end; + } + + avctx->codec = codec; + avctx->codec_id = codec->id; + + avctx->frame_number = 0; + + if (avctx->codec->init) { + ret = avctx->codec->init(avctx); + if (ret < 0) { + goto free_and_end; + } + } + + ret = 0; + + /* validate channel layout from the decoder */ + if (avctx->channel_layout) { + int channels = av_get_channel_layout_nb_channels(avctx->channel_layout); + if (!avctx->channels) + avctx->channels = channels; + else if (channels != avctx->channels) { + char buf[512] = ""; + av_log(avctx, AV_LOG_WARNING, + "Channel layout '%s' with %d channels does not match specified number of channels %d: " + "ignoring specified channel layout\n", + buf, channels, avctx->channels); + avctx->channel_layout = 0; + } + } + if (avctx->channels && avctx->channels < 0 || + avctx->channels > FF_SANE_NB_CHANNELS) { + ret = AVERROR(EINVAL); + goto free_and_end; + } + if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) { + av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class); + } + +end: + + return ret; +free_and_end: + if (avctx->codec) + avctx->codec->close(avctx); + + av_freep(&avctx->priv_data); + avctx->codec = NULL; + goto end; +} + +int avcodec_close(AVCodecContext *avctx) +{ + int i; + + if (!avctx) + return 0; + + if (avctx->codec && avctx->codec->close) + avctx->codec->close(avctx); + av_freep(&avctx->priv_data); + avctx->codec = NULL; + return 0; +} + +void avcodec_flush_buffers(AVCodecContext *avctx) +{ + if (avctx->codec->flush) + avctx->codec->flush(avctx); +} diff --git a/ext/at3_standalone/avcodec.h b/ext/at3_standalone/avcodec.h index 2d51d134d6..a2caa92db7 100644 --- a/ext/at3_standalone/avcodec.h +++ b/ext/at3_standalone/avcodec.h @@ -30,8 +30,8 @@ #include #include "compat.h" #include "channel_layout.h" +#include "mem.h" #include "log.h" -#include "version.h" /** * @defgroup libavc Encoding/Decoding Library diff --git a/ext/at3_standalone/avfft.h b/ext/at3_standalone/avfft.h deleted file mode 100644 index 684af4d18b..0000000000 --- a/ext/at3_standalone/avfft.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 - */ - -#ifndef AVCODEC_AVFFT_H -#define AVCODEC_AVFFT_H - -typedef float FFTSample; - -typedef struct FFTComplex { - FFTSample re, im; -} FFTComplex; - -typedef struct FFTContext FFTContext; - -/** - * @} - */ - -#endif /* AVCODEC_AVFFT_H */ diff --git a/ext/at3_standalone/avutil.h b/ext/at3_standalone/avutil.h index 23f9673c14..92a281532e 100644 --- a/ext/at3_standalone/avutil.h +++ b/ext/at3_standalone/avutil.h @@ -77,89 +77,6 @@ * version number. */ -/** - * @defgroup lavu Common utility functions - * - * @brief - * libavutil contains the code shared across all the other FFmpeg - * libraries - * - * @note In order to use the functions provided by avutil you must include - * the specific header. - * - * @{ - * - * @defgroup lavu_crypto Crypto and Hashing - * - * @{ - * @} - * - * @defgroup lavu_math Maths - * @{ - * - * @} - * - * @defgroup lavu_string String Manipulation - * - * @{ - * - * @} - * - * @defgroup lavu_mem Memory Management - * - * @{ - * - * @} - * - * @defgroup lavu_data Data Structures - * @{ - * - * @} - * - * @defgroup lavu_audio Audio related - * - * @{ - * - * @} - * - * @defgroup lavu_error Error Codes - * - * @{ - * - * @} - * - * @defgroup lavu_log Logging Facility - * - * @{ - * - * @} - * - * @defgroup lavu_misc Other - * - * @{ - * - * @defgroup preproc_misc Preprocessor String Macros - * - * @{ - * - * @} - * - * @defgroup version_utils Library Version Macros - * - * @{ - * - * @} - */ - - -/** - * @addtogroup lavu_ver - * @{ - */ -/** - * @} - */ - /** * @brief Undefined timestamp value @@ -186,12 +103,6 @@ * @} */ -#include "common.h" -#include "error.h" -#include "version.h" -#include "mathematics.h" -#include "log.h" - /** * Return x default pointer in case p is NULL. */ @@ -209,7 +120,7 @@ static inline void *av_x_if_null(const void *p, const void *x) * @return length of the list, in elements, not counting the terminator */ unsigned av_int_list_length_for_size(unsigned elsize, - const void *list, uint64_t term) av_pure; + const void *list, uint64_t term); /** * Compute the length of an integer list. diff --git a/ext/at3_standalone/bitstream.c b/ext/at3_standalone/bitstream.c index bdb56916ba..2bd610ce0d 100644 --- a/ext/at3_standalone/bitstream.c +++ b/ext/at3_standalone/bitstream.c @@ -31,13 +31,30 @@ #include #include -#include "qsort.h" #include "avcodec.h" #include "common.h" -#include "util_internal.h" #include "mathematics.h" #include "get_bits.h" +static const uint8_t ff_reverse[256] = { +0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0, +0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8, +0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4, +0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC, +0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2, +0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA, +0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6, +0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE, +0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1, +0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9, +0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5, +0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD, +0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3, +0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB, +0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7, +0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF, +}; + /* VLC decoding */ #define GET_DATA(v, table, i, wrap, size) \ @@ -284,7 +301,7 @@ int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, } COPY(buf[j].bits > nb_bits); // qsort is the slowest part of init_vlc, and could probably be improved or avoided - AV_QSORT(buf, j, struct VLCcode, compare_vlcspec); + qsort(buf, j, sizeof(struct VLCcode), compare_vlcspec); COPY(buf[j].bits && buf[j].bits <= nb_bits); nb_codes = j; diff --git a/ext/at3_standalone/channel_layout.c b/ext/at3_standalone/channel_layout.c index 9bcd52e377..47fee23733 100644 --- a/ext/at3_standalone/channel_layout.c +++ b/ext/at3_standalone/channel_layout.c @@ -24,6 +24,8 @@ */ #include +#include +#include #include "avutil.h" #include "channel_layout.h" diff --git a/ext/at3_standalone/common.h b/ext/at3_standalone/common.h index 891659ba0c..f1a4bd9d52 100644 --- a/ext/at3_standalone/common.h +++ b/ext/at3_standalone/common.h @@ -35,7 +35,6 @@ #include #include "compat.h" -#include "version.h" #include "mem.h" //rounded division & shift diff --git a/ext/at3_standalone/compat.c b/ext/at3_standalone/compat.c index fc285e6b2c..80dfc9a566 100644 --- a/ext/at3_standalone/compat.c +++ b/ext/at3_standalone/compat.c @@ -12,13 +12,6 @@ int av_get_cpu_flags(void) { return 0; } -void ff_fft_init_aarch64(void) {} -void ff_fft_init_x86(void) {} -void ff_fft_init_arm(void) {} -void ff_fft_init_mips(void) {} -void ff_fft_init_ppc(void) {} - - size_t av_strlcpy(char *dst, const char *src, size_t size) { size_t len = 0; @@ -29,33 +22,13 @@ size_t av_strlcpy(char *dst, const char *src, size_t size) return len + strlen(src) - 1; } - -const uint8_t ff_reverse[256] = { -0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0, -0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8, -0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4, -0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC, -0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2, -0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA, -0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6, -0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE, -0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1, -0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9, -0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5, -0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD, -0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3, -0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB, -0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7, -0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF, -}; - const uint8_t ff_log2_tab[256] = { - 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 + 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 }; diff --git a/ext/at3_standalone/compat.h b/ext/at3_standalone/compat.h index c2150fab1a..4bc4ac9b06 100644 --- a/ext/at3_standalone/compat.h +++ b/ext/at3_standalone/compat.h @@ -2,8 +2,6 @@ // Compat hacks -#include "error.h" - #define CONFIG_MEMORY_POISONING 0 #define CONFIG_HARDCODED_TABLES 0 #define CONFIG_ME_CMP 0 @@ -20,10 +18,8 @@ #define FF_API_AVPACKET_OLD_API 1 #define FF_DISABLE_DEPRECATION_WARNINGS #define FF_ENABLE_DEPRECATION_WARNINGS -#define CONFIG_MDCT 1 #define CONFIG_FFT 1 -#define av_cold #define DECLARE_ALIGNED(bits, type, name) type name #define LOCAL_ALIGNED(bits, type, name, subscript) type name subscript #define av_restrict @@ -41,6 +37,15 @@ #define av_printf_format(a,b) #define avpriv_report_missing_feature(...) + +#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions. +#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value. + +#define FFERRTAG(a, b, c, d) (-(int)MKTAG(a, b, c, d)) + +#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input +#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome + #pragma warning(disable:4305) #pragma warning(disable:4244) diff --git a/ext/at3_standalone/dct.c b/ext/at3_standalone/dct.c deleted file mode 100644 index cca51eeaf8..0000000000 --- a/ext/at3_standalone/dct.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * (I)DCT Transforms - * Copyright (c) 2009 Peter Ross - * Copyright (c) 2010 Alex Converse - * Copyright (c) 2010 Vitor Sessak - * - * 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 St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * (Inverse) Discrete Cosine Transforms. These are also known as the - * type II and type III DCTs respectively. - */ - -#include -#include - -#include "libavutil/mathematics.h" -#include "dct.h" -#include "dct32.h" - -/* sin((M_PI * x / (2 * n)) */ -#define SIN(s, n, x) (s->costab[(n) - (x)]) - -/* cos((M_PI * x / (2 * n)) */ -#define COS(s, n, x) (s->costab[x]) - -static void dst_calc_I_c(DCTContext *ctx, FFTSample *data) -{ - int n = 1 << ctx->nbits; - int i; - - data[0] = 0; - for (i = 1; i < n / 2; i++) { - float tmp1 = data[i ]; - float tmp2 = data[n - i]; - float s = SIN(ctx, n, 2 * i); - - s *= tmp1 + tmp2; - tmp1 = (tmp1 - tmp2) * 0.5f; - data[i] = s + tmp1; - data[n - i] = s - tmp1; - } - - data[n / 2] *= 2; - ctx->rdft.rdft_calc(&ctx->rdft, data); - - data[0] *= 0.5f; - - for (i = 1; i < n - 2; i += 2) { - data[i + 1] += data[i - 1]; - data[i] = -data[i + 2]; - } - - data[n - 1] = 0; -} - -static void dct_calc_I_c(DCTContext *ctx, FFTSample *data) -{ - int n = 1 << ctx->nbits; - int i; - float next = -0.5f * (data[0] - data[n]); - - for (i = 0; i < n / 2; i++) { - float tmp1 = data[i]; - float tmp2 = data[n - i]; - float s = SIN(ctx, n, 2 * i); - float c = COS(ctx, n, 2 * i); - - c *= tmp1 - tmp2; - s *= tmp1 - tmp2; - - next += c; - - tmp1 = (tmp1 + tmp2) * 0.5f; - data[i] = tmp1 - s; - data[n - i] = tmp1 + s; - } - - ctx->rdft.rdft_calc(&ctx->rdft, data); - data[n] = data[1]; - data[1] = next; - - for (i = 3; i <= n; i += 2) - data[i] = data[i - 2] - data[i]; -} - -static void dct_calc_III_c(DCTContext *ctx, FFTSample *data) -{ - int n = 1 << ctx->nbits; - int i; - - float next = data[n - 1]; - float inv_n = 1.0f / n; - - for (i = n - 2; i >= 2; i -= 2) { - float val1 = data[i]; - float val2 = data[i - 1] - data[i + 1]; - float c = COS(ctx, n, i); - float s = SIN(ctx, n, i); - - data[i] = c * val1 + s * val2; - data[i + 1] = s * val1 - c * val2; - } - - data[1] = 2 * next; - - ctx->rdft.rdft_calc(&ctx->rdft, data); - - for (i = 0; i < n / 2; i++) { - float tmp1 = data[i] * inv_n; - float tmp2 = data[n - i - 1] * inv_n; - float csc = ctx->csc2[i] * (tmp1 - tmp2); - - tmp1 += tmp2; - data[i] = tmp1 + csc; - data[n - i - 1] = tmp1 - csc; - } -} - -static void dct_calc_II_c(DCTContext *ctx, FFTSample *data) -{ - int n = 1 << ctx->nbits; - int i; - float next; - - for (i = 0; i < n / 2; i++) { - float tmp1 = data[i]; - float tmp2 = data[n - i - 1]; - float s = SIN(ctx, n, 2 * i + 1); - - s *= tmp1 - tmp2; - tmp1 = (tmp1 + tmp2) * 0.5f; - - data[i] = tmp1 + s; - data[n-i-1] = tmp1 - s; - } - - ctx->rdft.rdft_calc(&ctx->rdft, data); - - next = data[1] * 0.5; - data[1] *= -1; - - for (i = n - 2; i >= 0; i -= 2) { - float inr = data[i ]; - float ini = data[i + 1]; - float c = COS(ctx, n, i); - float s = SIN(ctx, n, i); - - data[i] = c * inr + s * ini; - data[i + 1] = next; - - next += s * inr - c * ini; - } -} - -static void dct32_func(DCTContext *ctx, FFTSample *data) -{ - ctx->dct32(data, data); -} - -av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) -{ - int n = 1 << nbits; - int i; - - memset(s, 0, sizeof(*s)); - - s->nbits = nbits; - s->inverse = inverse; - - if (inverse == DCT_II && nbits == 5) { - s->dct_calc = dct32_func; - } else { - ff_init_ff_cos_tabs(nbits + 2); - - s->costab = ff_cos_tabs[nbits + 2]; - s->csc2 = av_malloc_array(n / 2, sizeof(FFTSample)); - if (!s->csc2) - return AVERROR(ENOMEM); - - if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) { - av_freep(&s->csc2); - return -1; - } - - for (i = 0; i < n / 2; i++) - s->csc2[i] = 0.5 / sin((M_PI / (2 * n) * (2 * i + 1))); - - switch (inverse) { - case DCT_I : s->dct_calc = dct_calc_I_c; break; - case DCT_II : s->dct_calc = dct_calc_II_c; break; - case DCT_III: s->dct_calc = dct_calc_III_c; break; - case DST_I : s->dct_calc = dst_calc_I_c; break; - } - } - - s->dct32 = ff_dct32_float; - if (ARCH_X86) - ff_dct_init_x86(s); - - return 0; -} - -av_cold void ff_dct_end(DCTContext *s) -{ - ff_rdft_end(&s->rdft); - av_freep(&s->csc2); -} diff --git a/ext/at3_standalone/dct.h b/ext/at3_standalone/dct.h deleted file mode 100644 index 05297ba9db..0000000000 --- a/ext/at3_standalone/dct.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * (I)DCT Transforms - * Copyright (c) 2009 Peter Ross - * Copyright (c) 2010 Alex Converse - * Copyright (c) 2010 Vitor Sessak - * - * 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 St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined(AVCODEC_DCT_H) && (!defined(FFT_FLOAT) || FFT_FLOAT) -#define AVCODEC_DCT_H - -#include - -#include "rdft.h" - -struct DCTContext { - int nbits; - int inverse; - RDFTContext rdft; - const float *costab; - FFTSample *csc2; - void (*dct_calc)(struct DCTContext *s, FFTSample *data); - void (*dct32)(FFTSample *out, const FFTSample *in); -}; - -/** - * Set up DCT. - * @param nbits size of the input array: - * (1 << nbits) for DCT-II, DCT-III and DST-I - * (1 << nbits) + 1 for DCT-I - * - * @note the first element of the input of DST-I is ignored - */ -int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type); -void ff_dct_end (DCTContext *s); - -void ff_dct_init_x86(DCTContext *s); - -void ff_fdct_ifast(int16_t *data); -void ff_fdct_ifast248(int16_t *data); -void ff_jpeg_fdct_islow_8(int16_t *data); -void ff_jpeg_fdct_islow_10(int16_t *data); -void ff_fdct248_islow_8(int16_t *data); -void ff_fdct248_islow_10(int16_t *data); - -void ff_j_rev_dct(int16_t *data); -void ff_j_rev_dct4(int16_t *data); -void ff_j_rev_dct2(int16_t *data); -void ff_j_rev_dct1(int16_t *data); -void ff_jref_idct_put(uint8_t *dest, int line_size, int16_t *block); -void ff_jref_idct_add(uint8_t *dest, int line_size, int16_t *block); - -#endif /* AVCODEC_DCT_H */ diff --git a/ext/at3_standalone/error.h b/ext/at3_standalone/error.h deleted file mode 100644 index eedd7a9023..0000000000 --- a/ext/at3_standalone/error.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 - */ - -/** - * @file - * error code definitions - */ - -#ifndef AVUTIL_ERROR_H -#define AVUTIL_ERROR_H - -#include -#include - -/* error handling */ -#if EDOM > 0 -#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions. -#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value. -#else -/* Some platforms have E* and errno already negated. */ -#define AVERROR(e) (e) -#define AVUNERROR(e) (e) -#endif - -#define FFERRTAG(a, b, c, d) (-(int)MKTAG(a, b, c, d)) - -#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input -#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome - -#endif /* AVUTIL_ERROR_H */ diff --git a/ext/at3_standalone/fft-internal.h b/ext/at3_standalone/fft-internal.h deleted file mode 100644 index 55f083640b..0000000000 --- a/ext/at3_standalone/fft-internal.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - */ - -#ifndef AVCODEC_FFT_INTERNAL_H -#define AVCODEC_FFT_INTERNAL_H - -#define FIX15(v) (v) -#define sqrthalf (float)M_SQRT1_2 - -#define BF(x, y, a, b) do { \ - x = a - b; \ - y = a + b; \ - } while (0) - -#define CMUL(dre, dim, are, aim, bre, bim) do { \ - (dre) = (are) * (bre) - (aim) * (bim); \ - (dim) = (are) * (bim) + (aim) * (bre); \ - } while (0) - -#define ff_imdct_calc_c FFT_NAME(ff_imdct_calc_c) -#define ff_imdct_half_c FFT_NAME(ff_imdct_half_c) -#define ff_mdct_calc_c FFT_NAME(ff_mdct_calc_c) - -void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); -void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input); -void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); - -#endif /* AVCODEC_FFT_INTERNAL_H */ diff --git a/ext/at3_standalone/fft.h b/ext/at3_standalone/fft.h index 4d5dae9e53..d0b8f579d1 100644 --- a/ext/at3_standalone/fft.h +++ b/ext/at3_standalone/fft.h @@ -30,54 +30,33 @@ #define FFT_FIXED_32 0 #endif +#define FIX15(v) (v) + +#define CMUL(dre, dim, are, aim, bre, bim) do { \ + (dre) = (are) * (bre) - (aim) * (bim); \ + (dim) = (are) * (bim) + (aim) * (bre); \ + } while (0) + #include -#if FFT_FLOAT +typedef float FFTSample; -#include "avfft.h" +typedef struct FFTComplex { + FFTSample re, im; +} FFTComplex; + +typedef struct FFTContext FFTContext; #define FFT_NAME(x) x typedef float FFTDouble; -#else - -#if FFT_FIXED_32 - -#define Q31(x) (int)((x)*2147483648.0 + 0.5) -#define FFT_NAME(x) x ## _fixed_32 - -typedef int32_t FFTSample; - -#else /* FFT_FIXED_32 */ - -#define FFT_NAME(x) x ## _fixed - -typedef int16_t FFTSample; - -#endif /* FFT_FIXED_32 */ - -typedef struct FFTComplex { - FFTSample re, im; -} FFTComplex; - -typedef int FFTDouble; -typedef struct FFTContext FFTContext; - -#endif /* FFT_FLOAT */ - typedef struct FFTDComplex { FFTDouble re, im; } FFTDComplex; /* FFT computation */ -enum fft_permutation_type { - FF_FFT_PERM_DEFAULT, - FF_FFT_PERM_SWAP_LSBS, - FF_FFT_PERM_AVX, -}; - enum mdct_permutation_type { FF_MDCT_PERM_NONE, FF_MDCT_PERM_INTERLEAVE, @@ -106,7 +85,6 @@ struct FFTContext { void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input); void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); void (*mdct_calcw)(struct FFTContext *s, FFTDouble *output, const FFTSample *input); - enum fft_permutation_type fft_permutation; enum mdct_permutation_type mdct_permutation; }; @@ -152,14 +130,6 @@ void ff_init_ff_cos_tabs(int index); */ int ff_fft_init(FFTContext *s, int nbits, int inverse); -void ff_fft_init_aarch64(FFTContext *s); -void ff_fft_init_x86(FFTContext *s); -void ff_fft_init_arm(FFTContext *s); -void ff_fft_init_mips(FFTContext *s); -void ff_fft_init_ppc(FFTContext *s); - -void ff_fft_fixed_init_arm(FFTContext *s); - void ff_fft_end(FFTContext *s); #define ff_mdct_init FFT_NAME(ff_mdct_init) diff --git a/ext/at3_standalone/fft_template.c b/ext/at3_standalone/fft_template.c index 1cfd90b0a2..94118d4880 100644 --- a/ext/at3_standalone/fft_template.c +++ b/ext/at3_standalone/fft_template.c @@ -32,7 +32,21 @@ #include "mem.h" #include "mathematics.h" #include "fft.h" -#include "fft-internal.h" + +#define sqrthalf (float)M_SQRT1_2 + +#define BF(x, y, a, b) do { \ + x = a - b; \ + y = a + b; \ + } while (0) + +#define ff_imdct_calc_c FFT_NAME(ff_imdct_calc_c) +#define ff_imdct_half_c FFT_NAME(ff_imdct_half_c) +#define ff_mdct_calc_c FFT_NAME(ff_mdct_calc_c) + +void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); +void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input); +void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */ #if !CONFIG_HARDCODED_TABLES @@ -81,7 +95,7 @@ static int split_radix_permutation(int i, int n, int inverse) else return split_radix_permutation(i, m, inverse)*4 - 1; } -av_cold void ff_init_ff_cos_tabs(int index) +void ff_init_ff_cos_tabs(int index) { #if (!CONFIG_HARDCODED_TABLES) && (!FFT_FIXED_32) int i; @@ -111,29 +125,7 @@ static int is_second_half_of_fft32(int i, int n) return is_second_half_of_fft32(i - 3*n/4, n/4); } -static av_cold void fft_perm_avx(FFTContext *s) -{ - int i; - int n = 1 << s->nbits; - - for (i = 0; i < n; i += 16) { - int k; - if (is_second_half_of_fft32(i, n)) { - for (k = 0; k < 16; k++) - s->revtab[-split_radix_permutation(i + k, n, s->inverse) & (n - 1)] = - i + avx_tab[k]; - - } else { - for (k = 0; k < 16; k++) { - int j = i + k; - j = (j & ~7) | ((j >> 1) & 3) | ((j << 2) & 4); - s->revtab[-split_radix_permutation(i + k, n, s->inverse) & (n - 1)] = j; - } - } - } -} - -av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) +int ff_fft_init(FFTContext *s, int nbits, int inverse) { int i, j, n; @@ -149,41 +141,21 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) if (!s->tmp_buf) goto fail; s->inverse = inverse; - s->fft_permutation = FF_FFT_PERM_DEFAULT; s->fft_permute = fft_permute_c; s->fft_calc = fft_calc_c; -#if CONFIG_MDCT s->imdct_calc = ff_imdct_calc_c; s->imdct_half = ff_imdct_half_c; s->mdct_calc = ff_mdct_calc_c; -#endif - -#if FFT_FLOAT - if (ARCH_AARCH64) ff_fft_init_aarch64(s); - if (ARCH_ARM) ff_fft_init_arm(s); - if (ARCH_PPC) ff_fft_init_ppc(s); - if (ARCH_X86) ff_fft_init_x86(s); - if (CONFIG_MDCT) s->mdct_calcw = s->mdct_calc; - if (HAVE_MIPSFPU) ff_fft_init_mips(s); -#else - if (CONFIG_MDCT) s->mdct_calcw = ff_mdct_calcw_c; - if (ARCH_ARM) ff_fft_fixed_init_arm(s); -#endif + s->mdct_calcw = s->mdct_calc; for(j=4; j<=nbits; j++) { ff_init_ff_cos_tabs(j); } - if (s->fft_permutation == FF_FFT_PERM_AVX) { - fft_perm_avx(s); - } else { - for(i=0; ifft_permutation == FF_FFT_PERM_SWAP_LSBS) - j = (j&~3) | ((j>>1)&1) | ((j<<1)&2); - int index = -split_radix_permutation(i, n, s->inverse) & (n - 1); - s->revtab[index] = j; - } + for(i=0; iinverse) & (n - 1); + s->revtab[index] = j; } return 0; @@ -199,17 +171,17 @@ static void fft_permute_c(FFTContext *s, FFTComplex *z) const uint16_t *revtab = s->revtab; np = 1 << s->nbits; /* TODO: handle split-radix permute in a more optimal way, probably in-place */ - for(j=0;jtmp_buf[revtab[j]] = z[j]; + for(j=0;jtmp_buf[revtab[j]] = z[j]; memcpy(z, s->tmp_buf, np * sizeof(FFTComplex)); } -av_cold void ff_fft_end(FFTContext *s) +void ff_fft_end(FFTContext *s) { av_freep(&s->revtab); av_freep(&s->tmp_buf); } - #define BUTTERFLIES(a0,a1,a2,a3) {\ BF(t3, t5, t5, t1);\ BF(a2.re, a0.re, a0.re, t5);\ diff --git a/ext/at3_standalone/float_dsp.c b/ext/at3_standalone/float_dsp.c index 351ee9a6c9..b1e59ec837 100644 --- a/ext/at3_standalone/float_dsp.c +++ b/ext/at3_standalone/float_dsp.c @@ -92,7 +92,7 @@ static void vector_fmul_reverse_c(float *dst, const float *src0, dst[i] = src0[i] * src1[-i]; } -av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) +AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) { AVFloatDSPContext *fdsp = av_mallocz(sizeof(AVFloatDSPContext)); if (!fdsp) diff --git a/ext/at3_standalone/libm.h b/ext/at3_standalone/libm.h deleted file mode 100644 index f64851cb06..0000000000 --- a/ext/at3_standalone/libm.h +++ /dev/null @@ -1,448 +0,0 @@ -/* - * erf function: Copyright (c) 2006 John Maddock - * 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 - */ - -/** - * @file - * Replacements for frequently missing libm functions - */ - -#ifndef AVUTIL_LIBM_H -#define AVUTIL_LIBM_H - -#include -#include "compat.h" -#include "intfloat.h" -#include "mathematics.h" - -#if HAVE_MIPSFPU && HAVE_INLINE_ASM -#include "libavutil/mips/libm_mips.h" -#endif /* HAVE_MIPSFPU && HAVE_INLINE_ASM*/ - -#if !HAVE_ATANF -#undef atanf -#define atanf(x) ((float)atan(x)) -#endif /* HAVE_ATANF */ - -#if !HAVE_ATAN2F -#undef atan2f -#define atan2f(y, x) ((float)atan2(y, x)) -#endif /* HAVE_ATAN2F */ - -#if !HAVE_POWF -#undef powf -#define powf(x, y) ((float)pow(x, y)) -#endif /* HAVE_POWF */ - -#if !HAVE_CBRT -static av_always_inline double cbrt(double x) -{ - return x < 0 ? -pow(-x, 1.0 / 3.0) : pow(x, 1.0 / 3.0); -} -#endif /* HAVE_CBRT */ - -#if !HAVE_CBRTF -static av_always_inline float cbrtf(float x) -{ - return x < 0 ? -powf(-x, 1.0 / 3.0) : powf(x, 1.0 / 3.0); -} -#endif /* HAVE_CBRTF */ - -#if !HAVE_COPYSIGN -static av_always_inline double copysign(double x, double y) -{ - uint64_t vx = av_double2int(x); - uint64_t vy = av_double2int(y); - return av_int2double((vx & UINT64_C(0x7fffffffffffffff)) | (vy & UINT64_C(0x8000000000000000))); -} -#endif /* HAVE_COPYSIGN */ - -#if !HAVE_COSF -#undef cosf -#define cosf(x) ((float)cos(x)) -#endif /* HAVE_COSF */ - -#if !HAVE_ERF -static inline double ff_eval_poly(const double *coeff, int size, double x) { - double sum = coeff[size-1]; - int i; - for (i = size-2; i >= 0; --i) { - sum *= x; - sum += coeff[i]; - } - return sum; -} - -/** - * erf function - * Algorithm taken from the Boost project, source: - * http://www.boost.org/doc/libs/1_46_1/boost/math/special_functions/erf.hpp - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0 (see notice below). - * Boost Software License - Version 1.0 - August 17th, 2003 -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - */ -static inline double erf(double z) -{ -#ifndef FF_ARRAY_ELEMS -#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) -#endif - double result; - - /* handle the symmetry: erf(-x) = -erf(x) */ - if (z < 0) - return -erf(-z); - - /* branch based on range of z, and pick appropriate approximation */ - if (z == 0) - return 0; - else if (z < 1e-10) - return z * 1.125 + z * 0.003379167095512573896158903121545171688; - else if (z < 0.5) { - // Maximum Deviation Found: 1.561e-17 - // Expected Error Term: 1.561e-17 - // Maximum Relative Change in Control Points: 1.155e-04 - // Max Error found at double precision = 2.961182e-17 - - static const double y = 1.044948577880859375; - static const double p[] = { - 0.0834305892146531832907, - -0.338165134459360935041, - -0.0509990735146777432841, - -0.00772758345802133288487, - -0.000322780120964605683831, - }; - static const double q[] = { - 1, - 0.455004033050794024546, - 0.0875222600142252549554, - 0.00858571925074406212772, - 0.000370900071787748000569, - }; - double zz = z * z; - return z * (y + ff_eval_poly(p, FF_ARRAY_ELEMS(p), zz) / ff_eval_poly(q, FF_ARRAY_ELEMS(q), zz)); - } - /* here onwards compute erfc */ - else if (z < 1.5) { - // Maximum Deviation Found: 3.702e-17 - // Expected Error Term: 3.702e-17 - // Maximum Relative Change in Control Points: 2.845e-04 - // Max Error found at double precision = 4.841816e-17 - static const double y = 0.405935764312744140625; - static const double p[] = { - -0.098090592216281240205, - 0.178114665841120341155, - 0.191003695796775433986, - 0.0888900368967884466578, - 0.0195049001251218801359, - 0.00180424538297014223957, - }; - static const double q[] = { - 1, - 1.84759070983002217845, - 1.42628004845511324508, - 0.578052804889902404909, - 0.12385097467900864233, - 0.0113385233577001411017, - 0.337511472483094676155e-5, - }; - result = y + ff_eval_poly(p, FF_ARRAY_ELEMS(p), z - 0.5) / ff_eval_poly(q, FF_ARRAY_ELEMS(q), z - 0.5); - result *= exp(-z * z) / z; - return 1 - result; - } - else if (z < 2.5) { - // Max Error found at double precision = 6.599585e-18 - // Maximum Deviation Found: 3.909e-18 - // Expected Error Term: 3.909e-18 - // Maximum Relative Change in Control Points: 9.886e-05 - static const double y = 0.50672817230224609375; - static const double p[] = { - -0.0243500476207698441272, - 0.0386540375035707201728, - 0.04394818964209516296, - 0.0175679436311802092299, - 0.00323962406290842133584, - 0.000235839115596880717416, - }; - static const double q[] = { - 1, - 1.53991494948552447182, - 0.982403709157920235114, - 0.325732924782444448493, - 0.0563921837420478160373, - 0.00410369723978904575884, - }; - result = y + ff_eval_poly(p, FF_ARRAY_ELEMS(p), z - 1.5) / ff_eval_poly(q, FF_ARRAY_ELEMS(q), z - 1.5); - result *= exp(-z * z) / z; - return 1 - result; - } - else if (z < 4.5) { - // Maximum Deviation Found: 1.512e-17 - // Expected Error Term: 1.512e-17 - // Maximum Relative Change in Control Points: 2.222e-04 - // Max Error found at double precision = 2.062515e-17 - static const double y = 0.5405750274658203125; - static const double p[] = { - 0.00295276716530971662634, - 0.0137384425896355332126, - 0.00840807615555585383007, - 0.00212825620914618649141, - 0.000250269961544794627958, - 0.113212406648847561139e-4, - }; - static const double q[] = { - 1, - 1.04217814166938418171, - 0.442597659481563127003, - 0.0958492726301061423444, - 0.0105982906484876531489, - 0.000479411269521714493907, - }; - result = y + ff_eval_poly(p, FF_ARRAY_ELEMS(p), z - 3.5) / ff_eval_poly(q, FF_ARRAY_ELEMS(q), z - 3.5); - result *= exp(-z * z) / z; - return 1 - result; - } - /* differ from Boost here, the claim of underflow of erfc(x) past 5.8 is - * slightly incorrect, change to 5.92 - * (really somewhere between 5.9125 and 5.925 is when it saturates) */ - else if (z < 5.92) { - // Max Error found at double precision = 2.997958e-17 - // Maximum Deviation Found: 2.860e-17 - // Expected Error Term: 2.859e-17 - // Maximum Relative Change in Control Points: 1.357e-05 - static const double y = 0.5579090118408203125; - static const double p[] = { - 0.00628057170626964891937, - 0.0175389834052493308818, - -0.212652252872804219852, - -0.687717681153649930619, - -2.5518551727311523996, - -3.22729451764143718517, - -2.8175401114513378771, - }; - static const double q[] = { - 1, - 2.79257750980575282228, - 11.0567237927800161565, - 15.930646027911794143, - 22.9367376522880577224, - 13.5064170191802889145, - 5.48409182238641741584, - }; - result = y + ff_eval_poly(p, FF_ARRAY_ELEMS(p), 1 / z) / ff_eval_poly(q, FF_ARRAY_ELEMS(q), 1 / z); - result *= exp(-z * z) / z; - return 1 - result; - } - /* handle the nan case, but don't use isnan for max portability */ - else if (z != z) - return z; - /* finally return saturated result */ - else - return 1; -} -#endif /* HAVE_ERF */ - -#if !HAVE_EXPF -#undef expf -#define expf(x) ((float)exp(x)) -#endif /* HAVE_EXPF */ - -#if !HAVE_EXP2 -#undef exp2 -#define exp2(x) exp((x) * M_LN2) -#endif /* HAVE_EXP2 */ - -#if !HAVE_EXP2F -#undef exp2f -#define exp2f(x) ((float)exp2(x)) -#endif /* HAVE_EXP2F */ - -#if !HAVE_ISINF -#undef isinf -/* Note: these do not follow the BSD/Apple/GNU convention of returning -1 for --Inf, +1 for Inf, 0 otherwise, but merely follow the POSIX/ISO mandated spec of -returning a non-zero value for +/-Inf, 0 otherwise. */ -static av_always_inline av_const int avpriv_isinff(float x) -{ - uint32_t v = av_float2int(x); - if ((v & 0x7f800000) != 0x7f800000) - return 0; - return !(v & 0x007fffff); -} - -static av_always_inline av_const int avpriv_isinf(double x) -{ - uint64_t v = av_double2int(x); - if ((v & 0x7ff0000000000000) != 0x7ff0000000000000) - return 0; - return !(v & 0x000fffffffffffff); -} - -#define isinf(x) \ - (sizeof(x) == sizeof(float) \ - ? avpriv_isinff(x) \ - : avpriv_isinf(x)) -#endif /* HAVE_ISINF */ - -#if !HAVE_ISNAN -static av_always_inline av_const int avpriv_isnanf(float x) -{ - uint32_t v = av_float2int(x); - if ((v & 0x7f800000) != 0x7f800000) - return 0; - return v & 0x007fffff; -} - -static av_always_inline av_const int avpriv_isnan(double x) -{ - uint64_t v = av_double2int(x); - if ((v & 0x7ff0000000000000) != 0x7ff0000000000000) - return 0; - return (v & 0x000fffffffffffff) && 1; -} - -#define isnan(x) \ - (sizeof(x) == sizeof(float) \ - ? avpriv_isnanf(x) \ - : avpriv_isnan(x)) -#endif /* HAVE_ISNAN */ - -#if !HAVE_ISFINITE -static av_always_inline av_const int avpriv_isfinitef(float x) -{ - uint32_t v = av_float2int(x); - return (v & 0x7f800000) != 0x7f800000; -} - -static av_always_inline av_const int avpriv_isfinite(double x) -{ - uint64_t v = av_double2int(x); - return (v & 0x7ff0000000000000) != 0x7ff0000000000000; -} - -#define isfinite(x) \ - (sizeof(x) == sizeof(float) \ - ? avpriv_isfinitef(x) \ - : avpriv_isfinite(x)) -#endif /* HAVE_ISFINITE */ - -#if !HAVE_LDEXPF -#undef ldexpf -#define ldexpf(x, exp) ((float)ldexp(x, exp)) -#endif /* HAVE_LDEXPF */ - -#if !HAVE_LLRINT -#undef llrint -#define llrint(x) ((long long)rint(x)) -#endif /* HAVE_LLRINT */ - -#if !HAVE_LLRINTF -#undef llrintf -#define llrintf(x) ((long long)rint(x)) -#endif /* HAVE_LLRINT */ - -#if !HAVE_LOG2 -#undef log2 -#define log2(x) (log(x) * 1.44269504088896340736) -#endif /* HAVE_LOG2 */ - -#if !HAVE_LOG2F -#undef log2f -#define log2f(x) ((float)log2(x)) -#endif /* HAVE_LOG2F */ - -#if !HAVE_LOG10F -#undef log10f -#define log10f(x) ((float)log10(x)) -#endif /* HAVE_LOG10F */ - -#if !HAVE_SINF -#undef sinf -#define sinf(x) ((float)sin(x)) -#endif /* HAVE_SINF */ - -#if !HAVE_RINT -static inline double rint(double x) -{ - return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5); -} -#endif /* HAVE_RINT */ - -#if !HAVE_LRINT -static av_always_inline av_const long int lrint(double x) -{ - return rint(x); -} -#endif /* HAVE_LRINT */ - -#if !HAVE_LRINTF -static av_always_inline av_const long int lrintf(float x) -{ - return (int)(rint(x)); -} -#endif /* HAVE_LRINTF */ - -#if !HAVE_ROUND -static av_always_inline av_const double round(double x) -{ - return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); -} -#endif /* HAVE_ROUND */ - -#if !HAVE_ROUNDF -static av_always_inline av_const float roundf(float x) -{ - return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); -} -#endif /* HAVE_ROUNDF */ - -#if !HAVE_TRUNC -static av_always_inline av_const double trunc(double x) -{ - return (x > 0) ? floor(x) : ceil(x); -} -#endif /* HAVE_TRUNC */ - -#if !HAVE_TRUNCF -static av_always_inline av_const float truncf(float x) -{ - return (x > 0) ? floor(x) : ceil(x); -} -#endif /* HAVE_TRUNCF */ - -#endif /* AVUTIL_LIBM_H */ diff --git a/ext/at3_standalone/log.h b/ext/at3_standalone/log.h index 2bf9af03aa..c85a078fb1 100644 --- a/ext/at3_standalone/log.h +++ b/ext/at3_standalone/log.h @@ -24,7 +24,6 @@ #include #include "avutil.h" #include "compat.h" -#include "version.h" typedef enum { AV_CLASS_CATEGORY_NA = 0, diff --git a/ext/at3_standalone/mathematics.c b/ext/at3_standalone/mathematics.c index 3db29ad300..0e5a0af793 100644 --- a/ext/at3_standalone/mathematics.c +++ b/ext/at3_standalone/mathematics.c @@ -29,7 +29,6 @@ #include "mathematics.h" #include "intmath.h" #include "common.h" -#include "version.h" /* Stein's binary GCD algorithm: * https://en.wikipedia.org/wiki/Binary_GCD_algorithm */ diff --git a/ext/at3_standalone/mdct_template.c b/ext/at3_standalone/mdct_template.c index 6176cd3de8..02d4677655 100644 --- a/ext/at3_standalone/mdct_template.c +++ b/ext/at3_standalone/mdct_template.c @@ -22,10 +22,8 @@ #include #include #include "common.h" -#include "libm.h" #include "mathematics.h" #include "fft.h" -#include "fft-internal.h" /** * @file @@ -45,7 +43,7 @@ /** * init MDCT or IMDCT computation. */ -av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) +int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) { int n, n4, i; double alpha, theta; @@ -82,13 +80,8 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) scale = sqrt(fabs(scale)); for(i=0;itcos[i*tstep] = lrint(-cos(alpha) * 2147483648.0); - s->tsin[i*tstep] = lrint(-sin(alpha) * 2147483648.0); -#else s->tcos[i*tstep] = FIX15(-cos(alpha) * scale); s->tsin[i*tstep] = FIX15(-sin(alpha) * scale); -#endif } return 0; fail: @@ -206,7 +199,7 @@ void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input) } } -av_cold void ff_mdct_end(FFTContext *s) +void ff_mdct_end(FFTContext *s) { av_freep(&s->tcos); ff_fft_end(s); diff --git a/ext/at3_standalone/mem.c b/ext/at3_standalone/mem.c index 6519a1df70..a880c2a59c 100644 --- a/ext/at3_standalone/mem.c +++ b/ext/at3_standalone/mem.c @@ -26,8 +26,6 @@ #define _XOPEN_SOURCE 600 -#include "config.h" - #include #include #include diff --git a/ext/at3_standalone/mem.h b/ext/at3_standalone/mem.h index 5568110edb..e622e4c058 100644 --- a/ext/at3_standalone/mem.h +++ b/ext/at3_standalone/mem.h @@ -28,9 +28,10 @@ #include #include +#include +#include #include "compat.h" -#include "error.h" #include "avutil.h" /** diff --git a/ext/at3_standalone/qsort.h b/ext/at3_standalone/qsort.h deleted file mode 100644 index 39b7a08852..0000000000 --- a/ext/at3_standalone/qsort.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * copyright (c) 2012 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 - */ - -#ifndef AVUTIL_QSORT_H -#define AVUTIL_QSORT_H - -#include "common.h" - - -/** - * Quicksort - * This sort is fast, and fully inplace but not stable and it is possible - * to construct input that requires O(n^2) time but this is very unlikely to - * happen with non constructed input. - */ -#define AV_QSORT(p, num, type, cmp) do {\ - void *stack[64][2];\ - int sp= 1;\ - stack[0][0] = p;\ - stack[0][1] = (p)+(num)-1;\ - while(sp){\ - type *start= stack[--sp][0];\ - type *end = stack[ sp][1];\ - while(start < end){\ - if(start < end-1) {\ - int checksort=0;\ - type *right = end-2;\ - type *left = start+1;\ - type *mid = start + ((end-start)>>1);\ - if(cmp(start, end) > 0) {\ - if(cmp( end, mid) > 0) FFSWAP(type, *start, *mid);\ - else FFSWAP(type, *start, *end);\ - }else{\ - if(cmp(start, mid) > 0) FFSWAP(type, *start, *mid);\ - else checksort= 1;\ - }\ - if(cmp(mid, end) > 0){ \ - FFSWAP(type, *mid, *end);\ - checksort=0;\ - }\ - if(start == end-2) break;\ - FFSWAP(type, end[-1], *mid);\ - while(left <= right){\ - while(left<=right && cmp(left, end-1) < 0)\ - left++;\ - while(left<=right && cmp(right, end-1) > 0)\ - right--;\ - if(left <= right){\ - FFSWAP(type, *left, *right);\ - left++;\ - right--;\ - }\ - }\ - FFSWAP(type, end[-1], *left);\ - if(checksort && (mid == left-1 || mid == left)){\ - mid= start;\ - while(mid 0)\ - FFSWAP(type, *start, *end);\ - break;\ - }\ - }\ - }\ -} while (0) - -/** - * Merge sort, this sort requires a temporary buffer and is stable, its worst - * case time is O(n log n) - * @param p must be a lvalue pointer, this function may exchange it with tmp - * @param tmp must be a lvalue pointer, this function may exchange it with p - */ -#define AV_MSORT(p, tmp, num, type, cmp) do {\ - unsigned i, j, step;\ - for(step=1; step<(num); step+=step){\ - for(i=0; i<(num); i+=2*step){\ - unsigned a[2] = {i, i+step};\ - unsigned end = FFMIN(i+2*step, (num));\ - for(j=i; a[0] 0;\ - tmp[j] = p[ a[idx]++ ];\ - }\ - if(a[0]>=i+step) a[0] = a[1];\ - for(; j -#include -#include - -typedef struct SampleFmtInfo { - char name[8]; - int bits; - int planar; - enum AVSampleFormat altform; ///< planar<->packed alternative form -} SampleFmtInfo; - -/** this table gives more information about formats */ -static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] = { - [AV_SAMPLE_FMT_U8] = { .name = "u8", .bits = 8, .planar = 0, .altform = AV_SAMPLE_FMT_U8P }, - [AV_SAMPLE_FMT_S16] = { .name = "s16", .bits = 16, .planar = 0, .altform = AV_SAMPLE_FMT_S16P }, - [AV_SAMPLE_FMT_S32] = { .name = "s32", .bits = 32, .planar = 0, .altform = AV_SAMPLE_FMT_S32P }, - [AV_SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32, .planar = 0, .altform = AV_SAMPLE_FMT_FLTP }, - [AV_SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64, .planar = 0, .altform = AV_SAMPLE_FMT_DBLP }, - [AV_SAMPLE_FMT_U8P] = { .name = "u8p", .bits = 8, .planar = 1, .altform = AV_SAMPLE_FMT_U8 }, - [AV_SAMPLE_FMT_S16P] = { .name = "s16p", .bits = 16, .planar = 1, .altform = AV_SAMPLE_FMT_S16 }, - [AV_SAMPLE_FMT_S32P] = { .name = "s32p", .bits = 32, .planar = 1, .altform = AV_SAMPLE_FMT_S32 }, - [AV_SAMPLE_FMT_FLTP] = { .name = "fltp", .bits = 32, .planar = 1, .altform = AV_SAMPLE_FMT_FLT }, - [AV_SAMPLE_FMT_DBLP] = { .name = "dblp", .bits = 64, .planar = 1, .altform = AV_SAMPLE_FMT_DBL }, -}; - -const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt) -{ - if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) - return NULL; - return sample_fmt_info[sample_fmt].name; -} - -enum AVSampleFormat av_get_sample_fmt(const char *name) -{ - int i; - - for (i = 0; i < AV_SAMPLE_FMT_NB; i++) - if (!strcmp(sample_fmt_info[i].name, name)) - return i; - return AV_SAMPLE_FMT_NONE; -} - -enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar) -{ - if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) - return AV_SAMPLE_FMT_NONE; - if (sample_fmt_info[sample_fmt].planar == planar) - return sample_fmt; - return sample_fmt_info[sample_fmt].altform; -} - -enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt) -{ - if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) - return AV_SAMPLE_FMT_NONE; - if (sample_fmt_info[sample_fmt].planar) - return sample_fmt_info[sample_fmt].altform; - return sample_fmt; -} - -enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt) -{ - if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) - return AV_SAMPLE_FMT_NONE; - if (sample_fmt_info[sample_fmt].planar) - return sample_fmt; - return sample_fmt_info[sample_fmt].altform; -} - -char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt) -{ - /* print header */ - if (sample_fmt < 0) - snprintf(buf, buf_size, "name " " depth"); - else if (sample_fmt < AV_SAMPLE_FMT_NB) { - SampleFmtInfo info = sample_fmt_info[sample_fmt]; - snprintf (buf, buf_size, "%-6s" " %2d ", info.name, info.bits); - } - - return buf; -} - -int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt) -{ - return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? - 0 : sample_fmt_info[sample_fmt].bits >> 3; -} - -int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt) -{ - if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) - return 0; - return sample_fmt_info[sample_fmt].planar; -} - -int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, - enum AVSampleFormat sample_fmt, int align) -{ - int line_size; - int sample_size = av_get_bytes_per_sample(sample_fmt); - int planar = av_sample_fmt_is_planar(sample_fmt); - - /* validate parameter ranges */ - if (!sample_size || nb_samples <= 0 || nb_channels <= 0) - return AVERROR(EINVAL); - - /* auto-select alignment if not specified */ - if (!align) { - if (nb_samples > INT_MAX - 31) - return AVERROR(EINVAL); - align = 1; - nb_samples = FFALIGN(nb_samples, 32); - } - - /* check for integer overflow */ - if (nb_channels > INT_MAX / align || - (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size) - return AVERROR(EINVAL); - - line_size = planar ? FFALIGN(nb_samples * sample_size, align) : - FFALIGN(nb_samples * sample_size * nb_channels, align); - if (linesize) - *linesize = line_size; - - return planar ? line_size * nb_channels : line_size; -} - -int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, - const uint8_t *buf, int nb_channels, int nb_samples, - enum AVSampleFormat sample_fmt, int align) -{ - int ch, planar, buf_size, line_size; - - planar = av_sample_fmt_is_planar(sample_fmt); - buf_size = av_samples_get_buffer_size(&line_size, nb_channels, nb_samples, - sample_fmt, align); - if (buf_size < 0) - return buf_size; - - audio_data[0] = (uint8_t *)buf; - for (ch = 1; planar && ch < nb_channels; ch++) - audio_data[ch] = audio_data[ch-1] + line_size; - - if (linesize) - *linesize = line_size; - - return buf_size; -} - -int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, - int nb_samples, enum AVSampleFormat sample_fmt, int align) -{ - uint8_t *buf; - int size = av_samples_get_buffer_size(NULL, nb_channels, nb_samples, - sample_fmt, align); - if (size < 0) - return size; - - buf = av_malloc(size); - if (!buf) - return AVERROR(ENOMEM); - - size = av_samples_fill_arrays(audio_data, linesize, buf, nb_channels, - nb_samples, sample_fmt, align); - if (size < 0) { - av_free(buf); - return size; - } - - av_samples_set_silence(audio_data, 0, nb_samples, nb_channels, sample_fmt); - - return size; -} - -int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset, - int src_offset, int nb_samples, int nb_channels, - enum AVSampleFormat sample_fmt) -{ - int planar = av_sample_fmt_is_planar(sample_fmt); - int planes = planar ? nb_channels : 1; - int block_align = av_get_bytes_per_sample(sample_fmt) * (planar ? 1 : nb_channels); - int data_size = nb_samples * block_align; - int i; - - dst_offset *= block_align; - src_offset *= block_align; - - if((dst[0] < src[0] ? src[0] - dst[0] : dst[0] - src[0]) >= data_size) { - for (i = 0; i < planes; i++) - memcpy(dst[i] + dst_offset, src[i] + src_offset, data_size); - } else { - for (i = 0; i < planes; i++) - memmove(dst[i] + dst_offset, src[i] + src_offset, data_size); - } - - return 0; -} - -int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, - int nb_channels, enum AVSampleFormat sample_fmt) -{ - int planar = av_sample_fmt_is_planar(sample_fmt); - int planes = planar ? nb_channels : 1; - int block_align = av_get_bytes_per_sample(sample_fmt) * (planar ? 1 : nb_channels); - int data_size = nb_samples * block_align; - int fill_char = (sample_fmt == AV_SAMPLE_FMT_U8 || - sample_fmt == AV_SAMPLE_FMT_U8P) ? 0x80 : 0x00; - int i; - - offset *= block_align; - - for (i = 0; i < planes; i++) - memset(audio_data[i] + offset, fill_char, data_size); - - return 0; -} diff --git a/ext/at3_standalone/samplefmt.h b/ext/at3_standalone/samplefmt.h deleted file mode 100644 index 632bb4e852..0000000000 --- a/ext/at3_standalone/samplefmt.h +++ /dev/null @@ -1,259 +0,0 @@ -/* - * 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 - */ - -#ifndef AVUTIL_SAMPLEFMT_H -#define AVUTIL_SAMPLEFMT_H - -#include - -#include "avutil.h" -#include "compat.h" - -/** - * @addtogroup lavu_audio - * @{ - * - * @defgroup lavu_sampfmts Audio sample formats - * - * Audio sample format enumeration and related convenience functions. - * @{ - * - */ - -/** - * Audio sample formats - * - * - The data described by the sample format is always in native-endian order. - * Sample values can be expressed by native C types, hence the lack of a signed - * 24-bit sample format even though it is a common raw audio data format. - * - * - The floating-point formats are based on full volume being in the range - * [-1.0, 1.0]. Any values outside this range are beyond full volume level. - * - * - The data layout as used in av_samples_fill_arrays() and elsewhere in FFmpeg - * (such as AVFrame in libavcodec) is as follows: - * - * @par - * For planar sample formats, each audio channel is in a separate data plane, - * and linesize is the buffer size, in bytes, for a single plane. All data - * planes must be the same size. For packed sample formats, only the first data - * plane is used, and samples for each channel are interleaved. In this case, - * linesize is the buffer size, in bytes, for the 1 plane. - * - */ -enum AVSampleFormat { - AV_SAMPLE_FMT_NONE = -1, - AV_SAMPLE_FMT_U8, ///< unsigned 8 bits - AV_SAMPLE_FMT_S16, ///< signed 16 bits - AV_SAMPLE_FMT_S32, ///< signed 32 bits - AV_SAMPLE_FMT_FLT, ///< float - AV_SAMPLE_FMT_DBL, ///< double - - AV_SAMPLE_FMT_U8P, ///< unsigned 8 bits, planar - AV_SAMPLE_FMT_S16P, ///< signed 16 bits, planar - AV_SAMPLE_FMT_S32P, ///< signed 32 bits, planar - AV_SAMPLE_FMT_FLTP, ///< float, planar - AV_SAMPLE_FMT_DBLP, ///< double, planar - - AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically -}; - -/** - * Return the name of sample_fmt, or NULL if sample_fmt is not - * recognized. - */ -const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt); - -/** - * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE - * on error. - */ -enum AVSampleFormat av_get_sample_fmt(const char *name); - -/** - * Return the planar<->packed alternative form of the given sample format, or - * AV_SAMPLE_FMT_NONE on error. If the passed sample_fmt is already in the - * requested planar/packed format, the format returned is the same as the - * input. - */ -enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar); - -/** - * Get the packed alternative form of the given sample format. - * - * If the passed sample_fmt is already in packed format, the format returned is - * the same as the input. - * - * @return the packed alternative form of the given sample format or - AV_SAMPLE_FMT_NONE on error. - */ -enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt); - -/** - * Get the planar alternative form of the given sample format. - * - * If the passed sample_fmt is already in planar format, the format returned is - * the same as the input. - * - * @return the planar alternative form of the given sample format or - AV_SAMPLE_FMT_NONE on error. - */ -enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt); - -/** - * Generate a string corresponding to the sample format with - * sample_fmt, or a header if sample_fmt is negative. - * - * @param buf the buffer where to write the string - * @param buf_size the size of buf - * @param sample_fmt the number of the sample format to print the - * corresponding info string, or a negative value to print the - * corresponding header. - * @return the pointer to the filled buffer or NULL if sample_fmt is - * unknown or in case of other errors - */ -char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); - -/** - * Return number of bytes per sample. - * - * @param sample_fmt the sample format - * @return number of bytes per sample or zero if unknown for the given - * sample format - */ -int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt); - -/** - * Check if the sample format is planar. - * - * @param sample_fmt the sample format to inspect - * @return 1 if the sample format is planar, 0 if it is interleaved - */ -int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt); - -/** - * Get the required buffer size for the given audio parameters. - * - * @param[out] linesize calculated linesize, may be NULL - * @param nb_channels the number of channels - * @param nb_samples the number of samples in a single channel - * @param sample_fmt the sample format - * @param align buffer size alignment (0 = default, 1 = no alignment) - * @return required buffer size, or negative error code on failure - */ -int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, - enum AVSampleFormat sample_fmt, int align); - -/** - * @} - * - * @defgroup lavu_sampmanip Samples manipulation - * - * Functions that manipulate audio samples - * @{ - */ - -/** - * Fill plane data pointers and linesize for samples with sample - * format sample_fmt. - * - * The audio_data array is filled with the pointers to the samples data planes: - * for planar, set the start point of each channel's data within the buffer, - * for packed, set the start point of the entire buffer only. - * - * The value pointed to by linesize is set to the aligned size of each - * channel's data buffer for planar layout, or to the aligned size of the - * buffer for all channels for packed layout. - * - * The buffer in buf must be big enough to contain all the samples - * (use av_samples_get_buffer_size() to compute its minimum size), - * otherwise the audio_data pointers will point to invalid data. - * - * @see enum AVSampleFormat - * The documentation for AVSampleFormat describes the data layout. - * - * @param[out] audio_data array to be filled with the pointer for each channel - * @param[out] linesize calculated linesize, may be NULL - * @param buf the pointer to a buffer containing the samples - * @param nb_channels the number of channels - * @param nb_samples the number of samples in a single channel - * @param sample_fmt the sample format - * @param align buffer size alignment (0 = default, 1 = no alignment) - * @return >=0 on success or a negative error code on failure - * @todo return minimum size in bytes required for the buffer in case - * of success at the next bump - */ -int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, - const uint8_t *buf, - int nb_channels, int nb_samples, - enum AVSampleFormat sample_fmt, int align); - -/** - * Allocate a samples buffer for nb_samples samples, and fill data pointers and - * linesize accordingly. - * The allocated samples buffer can be freed by using av_freep(&audio_data[0]) - * Allocated data will be initialized to silence. - * - * @see enum AVSampleFormat - * The documentation for AVSampleFormat describes the data layout. - * - * @param[out] audio_data array to be filled with the pointer for each channel - * @param[out] linesize aligned size for audio buffer(s), may be NULL - * @param nb_channels number of audio channels - * @param nb_samples number of samples per channel - * @param align buffer size alignment (0 = default, 1 = no alignment) - * @return >=0 on success or a negative error code on failure - * @todo return the size of the allocated buffer in case of success at the next bump - * @see av_samples_fill_arrays() - * @see av_samples_alloc_array_and_samples() - */ -int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, - int nb_samples, enum AVSampleFormat sample_fmt, int align); - -/** - * Copy samples from src to dst. - * - * @param dst destination array of pointers to data planes - * @param src source array of pointers to data planes - * @param dst_offset offset in samples at which the data will be written to dst - * @param src_offset offset in samples at which the data will be read from src - * @param nb_samples number of samples to be copied - * @param nb_channels number of audio channels - * @param sample_fmt audio sample format - */ -int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset, - int src_offset, int nb_samples, int nb_channels, - enum AVSampleFormat sample_fmt); - -/** - * Fill an audio buffer with silence. - * - * @param audio_data array of pointers to data planes - * @param offset offset in samples at which to start filling - * @param nb_samples number of samples to fill - * @param nb_channels number of audio channels - * @param sample_fmt audio sample format - */ -int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, - int nb_channels, enum AVSampleFormat sample_fmt); - -/** - * @} - * @} - */ -#endif /* AVUTIL_SAMPLEFMT_H */ diff --git a/ext/at3_standalone/sinewin.c b/ext/at3_standalone/sinewin.c index 4532dc7354..eec241f128 100644 --- a/ext/at3_standalone/sinewin.c +++ b/ext/at3_standalone/sinewin.c @@ -16,6 +16,44 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define USE_FIXED 0 +#define _USE_MATH_DEFINES +#include + +#include +#include "aac_defines.h" +#include "compat.h" +#include "common.h" + +#include "mem.h" +#include "aac_defines.h" + #include "sinewin.h" -#include "sinewin_tablegen.h" + +SINETABLE(32); +SINETABLE(64); +SINETABLE(128); +SINETABLE(256); +SINETABLE(512); +SINETABLE(1024); +SINETABLE(2048); +SINETABLE(4096); +SINETABLE(8192); + +float * const ff_sine_windows[] = { + NULL, NULL, NULL, NULL, NULL, // unused + ff_sine_32 , ff_sine_64, ff_sine_128, + ff_sine_256, ff_sine_512, ff_sine_1024, + ff_sine_2048,ff_sine_4096, ff_sine_8192 +}; + +// Generate a sine window. +void ff_sine_window_init(float *window, int n) { + int i; + for (i = 0; i < n; i++) + window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); +} + +void ff_init_ff_sine_windows(int index) { + assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows)); + ff_sine_window_init(ff_sine_windows[index], 1 << index); +} diff --git a/ext/at3_standalone/sinewin.h b/ext/at3_standalone/sinewin.h index 811b6bd243..bf2b2efc17 100644 --- a/ext/at3_standalone/sinewin.h +++ b/ext/at3_standalone/sinewin.h @@ -18,47 +18,31 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_SINEWIN_H -#define AVCODEC_SINEWIN_H - -#include "mem.h" -#include "aac_defines.h" - -#if CONFIG_HARDCODED_TABLES -# define SINETABLE_CONST const -#else -# define SINETABLE_CONST -#endif - -#ifndef USE_FIXED -#define USE_FIXED 0 -#endif +#pragma once #define SINETABLE(size) \ - SINETABLE_CONST DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size] + DECLARE_ALIGNED(32, float, ff_sine_##size)[size] -/** - * Generate a sine window. - * @param window pointer to half window - * @param n size of half window - */ -void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n); + /** + * Generate a sine window. + * @param window pointer to half window + * @param n size of half window + */ +void ff_sine_window_init(float *window, int n); /** * initialize the specified entry of ff_sine_windows */ -void AAC_RENAME(ff_init_ff_sine_windows)(int index); +void ff_init_ff_sine_windows(int index); -extern SINETABLE( 32); -extern SINETABLE( 64); -extern SINETABLE( 128); -extern SINETABLE( 256); -extern SINETABLE( 512); +extern SINETABLE(32); +extern SINETABLE(64); +extern SINETABLE(128); +extern SINETABLE(256); +extern SINETABLE(512); extern SINETABLE(1024); extern SINETABLE(2048); extern SINETABLE(4096); extern SINETABLE(8192); -extern SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[14]; - -#endif /* AVCODEC_SINEWIN_H */ +extern float * const ff_sine_windows[14]; diff --git a/ext/at3_standalone/sinewin_tablegen.c b/ext/at3_standalone/sinewin_tablegen.c deleted file mode 100644 index dd602668ee..0000000000 --- a/ext/at3_standalone/sinewin_tablegen.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Generate a header file for hardcoded sine windows - * - * Copyright (c) 2009 Reimar Döffinger - * - * 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 - */ - -#define USE_FIXED 0 -#include "sinewin_tablegen_template.c" diff --git a/ext/at3_standalone/sinewin_tablegen.h b/ext/at3_standalone/sinewin_tablegen.h deleted file mode 100644 index 36271fb39c..0000000000 --- a/ext/at3_standalone/sinewin_tablegen.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Header file for hardcoded sine windows - * - * Copyright (c) 2009 Reimar Döffinger - * - * 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 - */ - -#ifndef AVCODEC_SINEWIN_TABLEGEN_H -#define AVCODEC_SINEWIN_TABLEGEN_H - -#include -// do not use libavutil/libm.h since this is compiled both -// for the host and the target and config.h is only valid for the target -#include - -#include "aac_defines.h" -#include "compat.h" -#include "common.h" - -#if !CONFIG_HARDCODED_TABLES -SINETABLE( 32); -SINETABLE( 64); -SINETABLE( 128); -SINETABLE( 256); -SINETABLE( 512); -SINETABLE(1024); -SINETABLE(2048); -SINETABLE(4096); -SINETABLE(8192); -#else -#if USE_FIXED -#include "libavcodec/sinewin_fixed_tables.h" -#else -#include "libavcodec/sinewin_tables.h" -#endif -#endif - -#if USE_FIXED -#define SIN_FIX(a) (int)floor((a) * 0x80000000 + 0.5) -#else -#define SIN_FIX(a) a -#endif - -SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = { - NULL, NULL, NULL, NULL, NULL, // unused - AAC_RENAME(ff_sine_32) , AAC_RENAME(ff_sine_64), AAC_RENAME(ff_sine_128), - AAC_RENAME(ff_sine_256), AAC_RENAME(ff_sine_512), AAC_RENAME(ff_sine_1024), - AAC_RENAME(ff_sine_2048), AAC_RENAME(ff_sine_4096), AAC_RENAME(ff_sine_8192) -}; - -// Generate a sine window. -av_cold void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n) { - int i; - for(i = 0; i < n; i++) - window[i] = SIN_FIX(sinf((i + 0.5) * (M_PI / (2.0 * n)))); -} - -av_cold void AAC_RENAME(ff_init_ff_sine_windows)(int index) { - assert(index >= 0 && index < FF_ARRAY_ELEMS(AAC_RENAME(ff_sine_windows))); -#if !CONFIG_HARDCODED_TABLES - AAC_RENAME(ff_sine_window_init)(AAC_RENAME(ff_sine_windows)[index], 1 << index); -#endif -} - -#endif /* AVCODEC_SINEWIN_TABLEGEN_H */ diff --git a/ext/at3_standalone/util_internal.h b/ext/at3_standalone/util_internal.h deleted file mode 100644 index a796d15223..0000000000 --- a/ext/at3_standalone/util_internal.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * copyright (c) 2006 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 - */ - -/** - * @file - * common internal API header - */ - -#ifndef AVUTIL_INTERNAL_H -#define AVUTIL_INTERNAL_H - -#if !defined(DEBUG) && !defined(NDEBUG) -# define NDEBUG -#endif - -#include -#include - -#include "libm.h" - -extern const uint8_t ff_reverse[256]; - -#endif /* AVUTIL_INTERNAL_H */ diff --git a/ext/at3_standalone/utils.c b/ext/at3_standalone/utils.c deleted file mode 100644 index 3b77ffb4e7..0000000000 --- a/ext/at3_standalone/utils.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * utils for libavcodec - * Copyright (c) 2001 Fabrice Bellard - * Copyright (c) 2002-2004 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 - */ - -/** - * @file - * utils. - */ - -#include "util_internal.h" -#include "avcodec.h" -#include "compat.h" -#include "channel_layout.h" -#include "common.h" -#include "mathematics.h" -#include "samplefmt.h" -#include "avcodec.h" -#include "bytestream.h" -#include "version.h" -#include -#include -#include -#include - -int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, void **options) -{ - if ((codec && avctx->codec && codec != avctx->codec)) { - av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, " - "but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name); - return AVERROR(EINVAL); - } - if (!codec) - codec = avctx->codec; - - if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE) - return AVERROR(EINVAL); - - int ret = 0; - - if (codec->priv_data_size > 0) { - if (!avctx->priv_data) { - avctx->priv_data = av_mallocz(codec->priv_data_size); - if (!avctx->priv_data) { - ret = AVERROR(ENOMEM); - goto end; - } - if (codec->priv_class) { - *(const AVClass **)avctx->priv_data = codec->priv_class; - } - } - } else { - avctx->priv_data = NULL; - } - - if (avctx->channels > FF_SANE_NB_CHANNELS) { - ret = AVERROR(EINVAL); - goto free_and_end; - } - - avctx->codec = codec; - avctx->codec_id = codec->id; - - avctx->frame_number = 0; - - if (avctx->codec->init) { - ret = avctx->codec->init(avctx); - if (ret < 0) { - goto free_and_end; - } - } - - ret=0; - - /* validate channel layout from the decoder */ - if (avctx->channel_layout) { - int channels = av_get_channel_layout_nb_channels(avctx->channel_layout); - if (!avctx->channels) - avctx->channels = channels; - else if (channels != avctx->channels) { - char buf[512] = ""; - av_log(avctx, AV_LOG_WARNING, - "Channel layout '%s' with %d channels does not match specified number of channels %d: " - "ignoring specified channel layout\n", - buf, channels, avctx->channels); - avctx->channel_layout = 0; - } - } - if (avctx->channels && avctx->channels < 0 || - avctx->channels > FF_SANE_NB_CHANNELS) { - ret = AVERROR(EINVAL); - goto free_and_end; - } - if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) { - av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class); - } - -end: - - return ret; -free_and_end: - if (avctx->codec) - avctx->codec->close(avctx); - - av_freep(&avctx->priv_data); - avctx->codec = NULL; - goto end; -} - -av_cold int avcodec_close(AVCodecContext *avctx) -{ - int i; - - if (!avctx) - return 0; - - if (avctx->codec && avctx->codec->close) - avctx->codec->close(avctx); - av_freep(&avctx->priv_data); - avctx->codec = NULL; - return 0; -} - -void avcodec_flush_buffers(AVCodecContext *avctx) -{ - if (avctx->codec->flush) - avctx->codec->flush(avctx); -} diff --git a/ext/at3_standalone/version.h b/ext/at3_standalone/version.h deleted file mode 100644 index 62a77de4d4..0000000000 --- a/ext/at3_standalone/version.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * copyright (c) 2003 Fabrice Bellard - * - * 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 - */ - -#ifndef AVUTIL_VERSION_H -#define AVUTIL_VERSION_H - -#include "common.h" - -/** - * @addtogroup version_utils - * - * Useful to check and match library version in order to maintain - * backward compatibility. - * - * @{ - */ - -#define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c)) -#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c -#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) - -/** - * Extract version components from the full ::AV_VERSION_INT int as returned - * by functions like ::avformat_version() and ::avcodec_version() - */ -#define AV_VERSION_MAJOR(a) ((a) >> 16) -#define AV_VERSION_MINOR(a) (((a) & 0x00FF00) >> 8) -#define AV_VERSION_MICRO(a) ((a) & 0xFF) - -/** - * @} - */ - -/** - * @file - * @ingroup lavu - * Libavutil version macros - */ - - -/** - * @} - */ - -#endif /* AVUTIL_VERSION_H */