diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2024-06-17 20:12:45 +0000 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2024-06-17 22:21:52 +0200 |
commit | 23a4e5f1dd7ce24f65a2af0598d1f92af4b5c424 (patch) | |
tree | 8a259ca8363c5b15fd3605b760518cb37e6ac63c /src | |
parent | 73dbd1609445a0142e1e138b6b44ec6d1925cbb8 (diff) | |
download | atracdenc-23a4e5f1dd7ce24f65a2af0598d1f92af4b5c424.tar.gz |
[refactoring] move some libraries in to library directory
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 9 | ||||
-rw-r--r-- | src/atrac/atrac1.h | 3 | ||||
-rw-r--r-- | src/atrac/atrac1_bitalloc.cpp | 2 | ||||
-rw-r--r-- | src/atrac/atrac1_bitalloc.h | 1 | ||||
-rw-r--r-- | src/atrac/atrac3_bitstream.cpp | 2 | ||||
-rw-r--r-- | src/atrac/atrac3plus_pqf/atrac3plus_pqf.c | 2 | ||||
-rw-r--r-- | src/atrac/atrac_scale.h | 1 | ||||
-rw-r--r-- | src/atrac1denc.h | 2 | ||||
-rw-r--r-- | src/lib/bitstream/bitstream.cpp (renamed from src/bitstream/bitstream.cpp) | 0 | ||||
-rw-r--r-- | src/lib/bitstream/bitstream.h (renamed from src/bitstream/bitstream.h) | 0 | ||||
-rw-r--r-- | src/lib/bitstream/bitstream_ut.cpp (renamed from src/bitstream/bitstream_ut.cpp) | 0 | ||||
-rw-r--r-- | src/lib/liboma/include/oma.h (renamed from src/oma/liboma/include/oma.h) | 0 | ||||
-rw-r--r-- | src/lib/liboma/src/liboma.c (renamed from src/oma/liboma/src/liboma.c) | 6 | ||||
-rw-r--r-- | src/lib/liboma/src/tools/omacp.c (renamed from src/oma/liboma/src/tools/omacp.c) | 0 | ||||
-rw-r--r-- | src/lib/liboma/src/tools/omainfo.c (renamed from src/oma/liboma/src/tools/omainfo.c) | 0 | ||||
-rw-r--r-- | src/lib/mdct/common.h (renamed from src/mdct/common.h) | 0 | ||||
-rw-r--r-- | src/lib/mdct/dct.h (renamed from src/mdct/dct.h) | 0 | ||||
-rw-r--r-- | src/lib/mdct/mdct.cpp (renamed from src/mdct/mdct.cpp) | 0 | ||||
-rw-r--r-- | src/lib/mdct/mdct.h (renamed from src/mdct/mdct.h) | 4 | ||||
-rw-r--r-- | src/lib/mdct/mdct_ut.cpp (renamed from src/mdct/mdct_ut.cpp) | 0 | ||||
-rw-r--r-- | src/mdct/vorbis_impl/mdct.c | 544 | ||||
-rw-r--r-- | src/mdct/vorbis_impl/mdct.h | 95 | ||||
-rw-r--r-- | src/oma.h | 2 | ||||
-rw-r--r-- | src/oma/liboma/src/oma_internal.h | 36 |
24 files changed, 19 insertions, 690 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70fbd32..0411a88 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,14 +56,15 @@ if (${BIGENDIAN}) endif() include_directories( + "." "lib" - "oma/liboma/include" + "lib/liboma/include" ) set(SOURCE_FFT_LIB fft/kissfft_impl/kiss_fft.c) set_source_files_properties(fft/kissfft_impl/kiss_fft.c PROPERTIES COMPILE_FLAGS -Dkiss_fft_scalar=double) -set(SOURCE_OMA_LIB oma/liboma/src/liboma.c) -set(SOURCE_BITSTREAM_LIB bitstream/bitstream.cpp) +set(SOURCE_OMA_LIB lib/liboma/src/liboma.c) +set(SOURCE_BITSTREAM_LIB lib/bitstream/bitstream.cpp) set(SOURCE_ATRACDENC_IMPL wav.cpp aea.cpp @@ -81,7 +82,7 @@ set(SOURCE_ATRACDENC_IMPL atrac3denc.cpp atrac/atrac3.cpp atrac/atrac3_bitstream.cpp - mdct/mdct.cpp + lib/mdct/mdct.cpp ) add_library(fft_impl STATIC ${SOURCE_FFT_LIB}) diff --git a/src/atrac/atrac1.h b/src/atrac/atrac1.h index 45d1bdf..e0d8161 100644 --- a/src/atrac/atrac1.h +++ b/src/atrac/atrac1.h @@ -21,8 +21,7 @@ #include <array> #include <map> #include <math.h> -#include "../bitstream/bitstream.h" -#include "../config.h" +#include "config.h" namespace NAtracDEnc { namespace NAtrac1 { diff --git a/src/atrac/atrac1_bitalloc.cpp b/src/atrac/atrac1_bitalloc.cpp index 01bc83c..69485db 100644 --- a/src/atrac/atrac1_bitalloc.cpp +++ b/src/atrac/atrac1_bitalloc.cpp @@ -22,7 +22,7 @@ #include "atrac1.h" #include <math.h> #include <cassert> -#include "../bitstream/bitstream.h" +#include "bitstream/bitstream.h" #include "../env.h" namespace NAtracDEnc { diff --git a/src/atrac/atrac1_bitalloc.h b/src/atrac/atrac1_bitalloc.h index 87f317b..411bece 100644 --- a/src/atrac/atrac1_bitalloc.h +++ b/src/atrac/atrac1_bitalloc.h @@ -18,7 +18,6 @@ #pragma once #include "atrac_scale.h" -#include "../bitstream/bitstream.h" #include "../aea.h" #include "../atrac/atrac1.h" #include <vector> diff --git a/src/atrac/atrac3_bitstream.cpp b/src/atrac/atrac3_bitstream.cpp index 08800d5..78ecaac 100644 --- a/src/atrac/atrac3_bitstream.cpp +++ b/src/atrac/atrac3_bitstream.cpp @@ -18,7 +18,7 @@ #include "atrac3_bitstream.h" #include "atrac_psy_common.h" -#include "../bitstream/bitstream.h" +#include "bitstream/bitstream.h" #include "../util.h" #include <algorithm> #include <iostream> diff --git a/src/atrac/atrac3plus_pqf/atrac3plus_pqf.c b/src/atrac/atrac3plus_pqf/atrac3plus_pqf.c index 151e0e8..0742469 100644 --- a/src/atrac/atrac3plus_pqf/atrac3plus_pqf.c +++ b/src/atrac/atrac3plus_pqf/atrac3plus_pqf.c @@ -30,7 +30,7 @@ #include "atrac3plus_pqf.h" #include "atrac3plus_pqf_data.h" -#include "../../mdct/dct.h" +#include "lib/mdct/dct.h" /* * Number of subbands to split input signal diff --git a/src/atrac/atrac_scale.h b/src/atrac/atrac_scale.h index eadb6bd..855010e 100644 --- a/src/atrac/atrac_scale.h +++ b/src/atrac/atrac_scale.h @@ -22,6 +22,7 @@ #include <cstdint> #include "atrac1.h" +#include "lib/bitstream/bitstream.h" #include "../config.h" namespace NAtracDEnc { diff --git a/src/atrac1denc.h b/src/atrac1denc.h index e898788..5752f22 100644 --- a/src/atrac1denc.h +++ b/src/atrac1denc.h @@ -23,7 +23,7 @@ #include "atrac/atrac1.h" #include "atrac/atrac1_qmf.h" #include "atrac/atrac_scale.h" -#include "mdct/mdct.h" +#include "lib/mdct/mdct.h" #include <assert.h> #include <vector> diff --git a/src/bitstream/bitstream.cpp b/src/lib/bitstream/bitstream.cpp index ddff907..ddff907 100644 --- a/src/bitstream/bitstream.cpp +++ b/src/lib/bitstream/bitstream.cpp diff --git a/src/bitstream/bitstream.h b/src/lib/bitstream/bitstream.h index cfba790..cfba790 100644 --- a/src/bitstream/bitstream.h +++ b/src/lib/bitstream/bitstream.h diff --git a/src/bitstream/bitstream_ut.cpp b/src/lib/bitstream/bitstream_ut.cpp index a426e7c..a426e7c 100644 --- a/src/bitstream/bitstream_ut.cpp +++ b/src/lib/bitstream/bitstream_ut.cpp diff --git a/src/oma/liboma/include/oma.h b/src/lib/liboma/include/oma.h index 857b0a7..857b0a7 100644 --- a/src/oma/liboma/include/oma.h +++ b/src/lib/liboma/include/oma.h diff --git a/src/oma/liboma/src/liboma.c b/src/lib/liboma/src/liboma.c index 6efff72..e957bd4 100644 --- a/src/oma/liboma/src/liboma.c +++ b/src/lib/liboma/src/liboma.c @@ -17,7 +17,6 @@ */ #include "../include/oma.h" -#include "oma_internal.h" #include <endian_tools.h> @@ -30,6 +29,11 @@ #define OMA_HEADER_SIZE 96 +struct omafile_ctx { + FILE* file; + oma_info_t info; +}; + static const int liboma_samplerates[8] = { 32000, 44100, 48000, 88200, 96000, 0 }; static const char* codec_name[6] = { "ATRAC3", "ATRAC3PLUS", "MPEG1LAYER3", "LPCM", "", "OMAC_ID_WMA" }; static char ea3_str[] = {'E', 'A', '3'}; diff --git a/src/oma/liboma/src/tools/omacp.c b/src/lib/liboma/src/tools/omacp.c index b938f04..b938f04 100644 --- a/src/oma/liboma/src/tools/omacp.c +++ b/src/lib/liboma/src/tools/omacp.c diff --git a/src/oma/liboma/src/tools/omainfo.c b/src/lib/liboma/src/tools/omainfo.c index 1edee98..1edee98 100644 --- a/src/oma/liboma/src/tools/omainfo.c +++ b/src/lib/liboma/src/tools/omainfo.c diff --git a/src/mdct/common.h b/src/lib/mdct/common.h index 9b3c893..9b3c893 100644 --- a/src/mdct/common.h +++ b/src/lib/mdct/common.h diff --git a/src/mdct/dct.h b/src/lib/mdct/dct.h index 55b81a9..55b81a9 100644 --- a/src/mdct/dct.h +++ b/src/lib/mdct/dct.h diff --git a/src/mdct/mdct.cpp b/src/lib/mdct/mdct.cpp index 74b6d91..74b6d91 100644 --- a/src/mdct/mdct.cpp +++ b/src/lib/mdct/mdct.cpp diff --git a/src/mdct/mdct.h b/src/lib/mdct/mdct.h index b80d5e0..59b9af7 100644 --- a/src/mdct/mdct.h +++ b/src/lib/mdct/mdct.h @@ -18,8 +18,8 @@ #pragma once -#include "../config.h" -#include "../fft/kissfft_impl/kiss_fft.h" +#include "config.h" +#include "fft/kissfft_impl/kiss_fft.h" #include <vector> #include <type_traits> diff --git a/src/mdct/mdct_ut.cpp b/src/lib/mdct/mdct_ut.cpp index 31f6f81..31f6f81 100644 --- a/src/mdct/mdct_ut.cpp +++ b/src/lib/mdct/mdct_ut.cpp diff --git a/src/mdct/vorbis_impl/mdct.c b/src/mdct/vorbis_impl/mdct.c deleted file mode 100644 index 384cf5c..0000000 --- a/src/mdct/vorbis_impl/mdct.c +++ /dev/null @@ -1,544 +0,0 @@ -/** - * - * This file is derived from libvorbis - * Copyright (c) 2002, Xiph.org Foundation - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of the Xiph.org Foundation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file mdct.c - * Modified Discrete Cosine Transform - */ - -#include "mdct.h" -#include <alloca.h> - -/** - * Allocates and initializes lookup tables in the MDCT context. - * @param mdct The MDCT context - * @param n Number of time-domain samples used in the MDCT transform - * @param scale Multiplier - */ -void -mdct_ctx_init(MDCTContext *mdct, int n, FLOAT scale) -{ - int *bitrev = malloc((n/4) * sizeof(int)); - FLOAT *trig = malloc((n+n/4) * sizeof(FLOAT)); - int i; - int n2 = (n >> 1); - int log2n = mdct->log2n = round(log((float)n)/log(2.f)); - mdct->n = n; - mdct->trig = trig; - mdct->bitrev = bitrev; - - // trig lookups - for (i = 0; i < n/4; i++) { - trig[i*2] = AFT_COS((M_PI/n)*(4*i)); - trig[i*2+1] = -AFT_SIN((M_PI/n)*(4*i)); - trig[n2+i*2] = AFT_COS((M_PI/(2*n))*(2*i+1)); - trig[n2+i*2+1] = AFT_SIN((M_PI/(2*n))*(2*i+1)); - } - for (i = 0; i < n/8; i++) { - trig[n+i*2] = AFT_COS((M_PI/n)*(4*i+2))*FCONST(0.5); - trig[n+i*2+1] = -AFT_SIN((M_PI/n)*(4*i+2))*FCONST(0.5); - } - - // bitreverse lookup - { - int j, acc; - int mask = (1 << (log2n-1)) - 1; - int msb = (1 << (log2n-2)); - for (i = 0; i < n/8; i++) { - acc = 0; - for (j = 0; msb>>j; j++) { - if ((msb>>j) & i) - acc |= (1 << j); - } - bitrev[i*2]= ((~acc) & mask) - 1; - bitrev[i*2+1] = acc; - } - } - mdct->scale = scale / (FLOAT)n; -} - -/** Deallocates memory use by the lookup tables in the MDCT context. */ -void -mdct_ctx_close(MDCTContext *mdct) -{ - if (mdct) { - if (mdct->trig) - free(mdct->trig); - if (mdct->bitrev) - free(mdct->bitrev); - memset(mdct, 0, sizeof(MDCTContext)); - } -} - -/** 8 point butterfly (in place, 4 register) */ -static inline void -mdct_butterfly_8(FLOAT *x) { - FLOAT r0 = x[6] + x[2]; - FLOAT r1 = x[6] - x[2]; - FLOAT r2 = x[4] + x[0]; - FLOAT r3 = x[4] - x[0]; - - x[6] = r0 + r2; - x[4] = r0 - r2; - - r0 = x[5] - x[1]; - r2 = x[7] - x[3]; - x[0] = r1 + r0; - x[2] = r1 - r0; - - r0 = x[5] + x[1]; - r1 = x[7] + x[3]; - x[3] = r2 + r3; - x[1] = r2 - r3; - x[7] = r1 + r0; - x[5] = r1 - r0; -} - -/** 16 point butterfly (in place, 4 register) */ -static inline void -mdct_butterfly_16(FLOAT *x) { - FLOAT r0 = x[1] - x[9]; - FLOAT r1 = x[0] - x[8]; - - x[8] += x[0]; - x[9] += x[1]; - x[0] = ((r0 + r1) * AFT_PI2_8); - x[1] = ((r0 - r1) * AFT_PI2_8); - - r0 = x[3] - x[11]; - r1 = x[10] - x[2]; - x[10] += x[2]; - x[11] += x[3]; - x[2] = r0; - x[3] = r1; - - r0 = x[12] - x[4]; - r1 = x[13] - x[5]; - x[12] += x[4]; - x[13] += x[5]; - x[4] = ((r0 - r1) * AFT_PI2_8); - x[5] = ((r0 + r1) * AFT_PI2_8); - - r0 = x[14] - x[6]; - r1 = x[15] - x[7]; - x[14] += x[6]; - x[15] += x[7]; - x[6] = r0; - x[7] = r1; - - mdct_butterfly_8(x); - mdct_butterfly_8(x+8); -} - -/** 32 point butterfly (in place, 4 register) */ -static inline void -mdct_butterfly_32(FLOAT *x) { - FLOAT r0 = x[30] - x[14]; - FLOAT r1 = x[31] - x[15]; - - x[30] += x[14]; - x[31] += x[15]; - x[14] = r0; - x[15] = r1; - - r0 = x[28] - x[12]; - r1 = x[29] - x[13]; - x[28] += x[12]; - x[29] += x[13]; - x[12] = (r0 * AFT_PI1_8 - r1 * AFT_PI3_8); - x[13] = (r0 * AFT_PI3_8 + r1 * AFT_PI1_8); - - r0 = x[26] - x[10]; - r1 = x[27] - x[11]; - x[26] += x[10]; - x[27] += x[11]; - x[10] = ((r0 - r1) * AFT_PI2_8); - x[11] = ((r0 + r1) * AFT_PI2_8); - - r0 = x[24] - x[8]; - r1 = x[25] - x[9]; - x[24] += x[8]; - x[25] += x[9]; - x[8] = (r0 * AFT_PI3_8 - r1 * AFT_PI1_8); - x[9] = (r1 * AFT_PI3_8 + r0 * AFT_PI1_8); - - r0 = x[22] - x[6]; - r1 = x[7] - x[23]; - x[22] += x[6]; - x[23] += x[7]; - x[6] = r1; - x[7] = r0; - - r0 = x[4] - x[20]; - r1 = x[5] - x[21]; - x[20] += x[4]; - x[21] += x[5]; - x[4] = (r1 * AFT_PI1_8 + r0 * AFT_PI3_8); - x[5] = (r1 * AFT_PI3_8 - r0 * AFT_PI1_8); - - r0 = x[2] - x[18]; - r1 = x[3] - x[19]; - x[18] += x[2]; - x[19] += x[3]; - x[2] = ((r1 + r0) * AFT_PI2_8); - x[3] = ((r1 - r0) * AFT_PI2_8); - - r0 = x[0] - x[16]; - r1 = x[1] - x[17]; - x[16] += x[0]; - x[17] += x[1]; - x[0] = (r1 * AFT_PI3_8 + r0 * AFT_PI1_8); - x[1] = (r1 * AFT_PI1_8 - r0 * AFT_PI3_8); - - mdct_butterfly_16(x); - mdct_butterfly_16(x+16); -} - -/** N-point first stage butterfly (in place, 2 register) */ -static inline void -mdct_butterfly_first(FLOAT *trig, FLOAT *x, int points) -{ - FLOAT *x1 = x + points - 8; - FLOAT *x2 = x + (points>>1) - 8; - FLOAT r0; - FLOAT r1; - - do { - r0 = x1[6] - x2[6]; - r1 = x1[7] - x2[7]; - x1[6] += x2[6]; - x1[7] += x2[7]; - x2[6] = (r1 * trig[1] + r0 * trig[0]); - x2[7] = (r1 * trig[0] - r0 * trig[1]); - - r0 = x1[4] - x2[4]; - r1 = x1[5] - x2[5]; - x1[4] += x2[4]; - x1[5] += x2[5]; - x2[4] = (r1 * trig[5] + r0 * trig[4]); - x2[5] = (r1 * trig[4] - r0 * trig[5]); - - r0 = x1[2] - x2[2]; - r1 = x1[3] - x2[3]; - x1[2] += x2[2]; - x1[3] += x2[3]; - x2[2] = (r1 * trig[9] + r0 * trig[8]); - x2[3] = (r1 * trig[8] - r0 * trig[9]); - - r0 = x1[0] - x2[0]; - r1 = x1[1] - x2[1]; - x1[0] += x2[0]; - x1[1] += x2[1]; - x2[0] = (r1 * trig[13] + r0 * trig[12]); - x2[1] = (r1 * trig[12] - r0 * trig[13]); - - x1 -= 8; - x2 -= 8; - trig += 16; - } while (x2 >= x); -} - -/** N/stage point generic N stage butterfly (in place, 2 register) */ -static inline void -mdct_butterfly_generic(FLOAT *trig, FLOAT *x, int points, int trigint) -{ - FLOAT *x1 = x + points - 8; - FLOAT *x2 = x + (points>>1) - 8; - FLOAT r0; - FLOAT r1; - - do { - r0 = x1[6] - x2[6]; - r1 = x1[7] - x2[7]; - x1[6] += x2[6]; - x1[7] += x2[7]; - x2[6] = (r1 * trig[1] + r0 * trig[0]); - x2[7] = (r1 * trig[0] - r0 * trig[1]); - - trig += trigint; - - r0 = x1[4] - x2[4]; - r1 = x1[5] - x2[5]; - x1[4] += x2[4]; - x1[5] += x2[5]; - x2[4] = (r1 * trig[1] + r0 * trig[0]); - x2[5] = (r1 * trig[0] - r0 * trig[1]); - - trig += trigint; - - r0 = x1[2] - x2[2]; - r1 = x1[3] - x2[3]; - x1[2] += x2[2]; - x1[3] += x2[3]; - x2[2] = (r1 * trig[1] + r0 * trig[0]); - x2[3] = (r1 * trig[0] - r0 * trig[1]); - - trig += trigint; - - r0 = x1[0] - x2[0]; - r1 = x1[1] - x2[1]; - x1[0] += x2[0]; - x1[1] += x2[1]; - x2[0] = (r1 * trig[1] + r0 * trig[0]); - x2[1] = (r1 * trig[0] - r0 * trig[1]); - - trig += trigint; - x1 -= 8; - x2 -= 8; - } while (x2 >= x); -} - -static inline void -mdct_butterflies(MDCTContext *mdct, FLOAT *x, int points) -{ - FLOAT *trig = mdct->trig; - int stages = mdct->log2n-5; - int i, j; - - if (--stages > 0) - mdct_butterfly_first(trig, x, points); - - for (i = 1; --stages > 0; i++) - for (j = 0; j < (1<<i); j++) - mdct_butterfly_generic(trig, x+(points>>i)*j, points>>i, 4<<i); - - for (j = 0; j < points; j += 32) - mdct_butterfly_32(x+j); -} - -static inline void -mdct_bitreverse(MDCTContext *mdct, FLOAT *x) -{ - int n = mdct->n; - int *bit = mdct->bitrev; - FLOAT *w0 = x; - FLOAT *w1 = x = w0+(n>>1); - FLOAT *trig = mdct->trig+n; - - do { - FLOAT *x0 = x+bit[0]; - FLOAT *x1 = x+bit[1]; - - FLOAT r0 = x0[1]- x1[1]; - FLOAT r1 = x0[0]+ x1[0]; - FLOAT r2 = (r1 * trig[0] + r0 * trig[1]); - FLOAT r3 = (r1 * trig[1] - r0 * trig[0]); - - w1 -= 4; - - r0 = (x0[1] + x1[1]) * FCONST(0.5); - r1 = (x0[0] - x1[0]) * FCONST(0.5); - - w0[0] = r0 + r2; - w1[2] = r0 - r2; - w0[1] = r1 + r3; - w1[3] = r3 - r1; - - x0 = x+bit[2]; - x1 = x+bit[3]; - - r0 = x0[1] - x1[1]; - r1 = x0[0] + x1[0]; - r2 = (r1 * trig[2] + r0 * trig[3]); - r3 = (r1 * trig[3] - r0 * trig[2]); - - r0 = (x0[1] + x1[1]) * FCONST(0.5); - r1 = (x0[0] - x1[0]) * FCONST(0.5); - - w0[2] = r0 + r2; - w1[0] = r0 - r2; - w0[3] = r1 + r3; - w1[1] = r3 - r1; - - trig += 4; - bit += 4; - w0 += 4; - } while (w0 < w1); -} - -void -mdct(MDCTContext *mdct, FLOAT *out, FLOAT *in) -{ - int n = mdct->n; - int n2 = n>>1; - int n4 = n>>2; - int n8 = n>>3; - FLOAT *w = alloca(n*sizeof(*w)); - FLOAT *w2 = w+n2; - - FLOAT *x0 = in+n2+n4; - FLOAT *x1 = x0+1; - FLOAT *trig = mdct->trig + n2; - FLOAT r0; - FLOAT r1; - int i; - - for (i = 0; i < n8; i += 2) { - x0 -= 4; - trig -= 2; - r0 = x0[2] + x1[0]; - r1 = x0[0] + x1[2]; - w2[i] = (r1*trig[1] + r0*trig[0]); - w2[i+1] = (r1*trig[0] - r0*trig[1]); - x1 += 4; - } - - x1 = in+1; - for (; i < n2-n8; i += 2) { - trig -= 2; - x0 -= 4; - r0 = x0[2] - x1[0]; - r1 = x0[0] - x1[2]; - w2[i] = (r1*trig[1] + r0*trig[0]); - w2[i+1] = (r1*trig[0] - r0*trig[1]); - x1 += 4; - } - - x0 = in+n; - for (; i < n2; i += 2) { - trig -= 2; - x0 -= 4; - r0 = -x0[2] - x1[0]; - r1 = -x0[0] - x1[2]; - w2[i] = (r1*trig[1] + r0*trig[0]); - w2[i+1] = (r1*trig[0] - r0*trig[1]); - x1 += 4; - } - - mdct_butterflies(mdct, w2, n2); - mdct_bitreverse(mdct, w); - - trig = mdct->trig+n2; - x0 = out+n2; - for (i = 0; i < n4; i++) { - x0--; - out[i] = ((w[0]*trig[0]+w[1]*trig[1])*mdct->scale); - x0[0] = ((w[0]*trig[1]-w[1]*trig[0])*mdct->scale); - w += 2; - trig += 2; - } -} - -void -midct(MDCTContext *mdct, FLOAT *out, FLOAT *in) -{ - int n = mdct->n; - int n2 = n>>1; - int n4 = n>>2; - - FLOAT *iX = in+n2-7; - FLOAT *oX = out+n2+n4; - FLOAT *T = mdct->trig+n4; - do { - oX -= 4; - oX[0] = (-iX[2] * T[3] - iX[0] * T[2]); - oX[1] = (iX[0] * T[3] - iX[2] * T[2]); - oX[2] = (-iX[6] * T[1] - iX[4] * T[0]); - oX[3] = (iX[4] * T[1] - iX[6] * T[0]); - iX -= 8; - T += 4; - } while (iX >= in); - - iX = in+n2-8; - oX = out+n2+n4; - T = mdct->trig+n4; - - do { - T -= 4; - oX[0] = (iX[4] * T[3] + iX[6] * T[2]); - oX[1] = (iX[4] * T[2] - iX[6] * T[3]); - oX[2] = (iX[0] * T[1] + iX[2] * T[0]); - oX[3] = (iX[0] * T[0] - iX[2] * T[1]); - iX -= 8; - oX += 4; - } while (iX >= in); - - mdct_butterflies(mdct, out+n2, n2); - mdct_bitreverse(mdct, out); - - /* roatate + window */ - - { - FLOAT *oX1= out + n2 + n4; - FLOAT *oX2= out + n2 + n4; - FLOAT *iX = out; - T = mdct->trig + n2; - - do { - oX1-=4; - oX1[3] = (iX[0] * T[1] - iX[1] * T[0]); - oX2[0] = -(iX[0] * T[0] + iX[1] * T[1]); - - oX1[2] = (iX[2] * T[3] - iX[3] * T[2]); - oX2[1] = -(iX[2] * T[2] + iX[3] * T[3]); - - oX1[1] = (iX[4] * T[5] - iX[5] * T[4]); - oX2[2] = -(iX[4] * T[4] + iX[5] * T[5]); - - oX1[0] = (iX[6] * T[7] - iX[7] * T[6]); - oX2[3] = -(iX[6] * T[6] + iX[7] * T[7]); - - oX2 += 4; - iX += 8; - T += 8; - } while (iX < oX1); - - iX = out + n2 + n4; - oX1 = out + n4; - oX2 = oX1; - - do{ - oX1-=4; - iX-=4; - oX2[0] = -(oX1[3] = iX[3]); - oX2[1] = -(oX1[2] = iX[2]); - oX2[2] = -(oX1[1] = iX[1]); - oX2[3] = -(oX1[0] = iX[0]); - oX2+=4; - } while (oX2 < iX); - - iX=out+n2+n4; - oX1=out+n2+n4; - oX2=out+n2; - - do{ - oX1-=4; - oX1[0]= iX[3]; - oX1[1]= iX[2]; - oX1[2]= iX[1]; - oX1[3]= iX[0]; - iX+=4; - } while (oX1 > oX2); - } - -} diff --git a/src/mdct/vorbis_impl/mdct.h b/src/mdct/vorbis_impl/mdct.h deleted file mode 100644 index de415af..0000000 --- a/src/mdct/vorbis_impl/mdct.h +++ /dev/null @@ -1,95 +0,0 @@ -/** - * - * This file is derived from libvorbis - * Copyright (c) 2002, Xiph.org Foundation - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of the Xiph.org Foundation nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file mdct.h - * MDCT header - */ - -#ifndef MDCT_H -#define MDCT_H - -#include "../common.h" - -#if defined(HAVE_MMX) || defined(HAVE_SSE) -#include "x86/mdct.h" -#endif -#ifdef HAVE_ALTIVEC -#include "ppc/mdct.h" -#endif - -#define ONE FCONST(1.0) -#define TWO FCONST(2.0) -#define AFT_PI3_8 FCONST(0.38268343236508977175) -#define AFT_PI2_8 FCONST(0.70710678118654752441) -#define AFT_PI1_8 FCONST(0.92387953251128675613) - -struct A52Context; -struct A52ThreadContext; - -typedef struct MDCTContext { - void (*mdct)(struct A52ThreadContext *ctx, FLOAT *out, FLOAT *in); - void (*mdct_bitreverse)(struct MDCTContext *mdct, FLOAT *x); - void (*mdct_butterfly_generic)(struct MDCTContext *mdct, FLOAT *x, int points, int trigint); - void (*mdct_butterfly_first)(FLOAT *trig, FLOAT *x, int points); - void (*mdct_butterfly_32)(FLOAT *x); - FLOAT *trig; -#ifndef CONFIG_DOUBLE -#ifdef HAVE_SSE - FLOAT *trig_bitreverse; - FLOAT *trig_forward; - FLOAT *trig_butterfly_first; - FLOAT *trig_butterfly_generic8; - FLOAT *trig_butterfly_generic16; - FLOAT *trig_butterfly_generic32; - FLOAT *trig_butterfly_generic64; -#endif -#endif /* CONFIG_DOUBLE */ - int *bitrev; - FLOAT scale; - int n; - int log2n; -} MDCTContext; - -#ifdef __cplusplus -extern "C" { -#endif -void mdct_ctx_init(MDCTContext *mdct, int n, FLOAT scale); -void mdct_ctx_close(MDCTContext *mdct); -void mdct(MDCTContext *mdct, FLOAT *out, FLOAT *in); -void midct(MDCTContext *mdct, FLOAT *out, FLOAT *in); -#ifdef __cplusplus -} - -#endif -#endif /* MDCT_H */ @@ -20,7 +20,7 @@ #include "compressed_io.h" -#include "oma/liboma/include/oma.h" +#include "lib/liboma/include/oma.h" class TOma : public ICompressedOutput { OMAFILE* File; diff --git a/src/oma/liboma/src/oma_internal.h b/src/oma/liboma/src/oma_internal.h deleted file mode 100644 index 1334080..0000000 --- a/src/oma/liboma/src/oma_internal.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of AtracDEnc. - * - * AtracDEnc 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. - * - * AtracDEnc 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 AtracDEnc; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef OMA_INTERNAL_H -#define OMA_INTERNAL_H - -#include <stdio.h> -#include "oma.h" - -struct omafile_ctx { - FILE* file; - oma_info_t info; -}; - - - -//static inline uint16_t read_big16(void *x) { -// return (((const uint8_t*)x)[0] << 8) | ((const uint8_t)x); -//} - -#endif /* OMA_INTERNAL_H */ |