├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── scopes │ └── scope_settings.xml ├── dictionaries │ └── dan.xml ├── encodings.xml ├── vcs.xml ├── inspectionProfiles │ ├── profiles_settings.xml │ └── Project_Default.xml ├── libraries │ ├── mockable_android_22.xml │ ├── junit_4_12.xml │ ├── annotations_12_0.xml │ └── hamcrest_core_1_3.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── mp3decoders ├── .gitignore ├── src │ ├── main │ │ ├── jni │ │ │ ├── Android.mk │ │ │ ├── Application.mk │ │ │ ├── libmpg123 │ │ │ │ ├── synth_sse.S │ │ │ │ ├── synth_3dnowext.S │ │ │ │ ├── icy2utf8.h │ │ │ │ ├── true.h │ │ │ │ ├── equalizer.c │ │ │ │ ├── dither.h │ │ │ │ ├── check_neon.S │ │ │ │ ├── icy.c │ │ │ │ ├── icy.h │ │ │ │ ├── parse.h │ │ │ │ ├── getcpuflags_arm.c │ │ │ │ ├── testcpu.c │ │ │ │ ├── getcpuflags_x86_64.S │ │ │ │ ├── id3.h │ │ │ │ ├── abi_align.h │ │ │ │ ├── synths.h │ │ │ │ ├── equalizer_3dnow.S │ │ │ │ ├── feature.c │ │ │ │ ├── getcpuflags.h │ │ │ │ ├── synth_mono.h │ │ │ │ ├── index.h │ │ │ │ ├── synth_8bit.h │ │ │ │ ├── getcpuflags.S │ │ │ │ ├── getbits.h │ │ │ │ ├── Android.mk │ │ │ │ ├── synth_neon64_float.S │ │ │ │ ├── synth_neon.S │ │ │ │ ├── synth_neon64.S │ │ │ │ ├── dither.c │ │ │ │ ├── synth_mmx.S │ │ │ │ ├── mangle.h │ │ │ │ ├── synth_neon64_accurate.S │ │ │ │ ├── synth_neon64_s32.S │ │ │ │ ├── mpeghead.h │ │ │ │ ├── index.c │ │ │ │ ├── synth_neon_float.S │ │ │ │ ├── compat.c │ │ │ │ ├── synth_8bit.c │ │ │ │ ├── synth_neon_s32.S │ │ │ │ ├── ntom.c │ │ │ │ ├── gapless.h │ │ │ │ ├── synth_neon_accurate.S │ │ │ │ ├── Makefile.am │ │ │ │ ├── synth_stereo_neon.S │ │ │ │ └── dct64.c │ │ │ ├── podax-native │ │ │ │ └── Android.mk │ │ │ ├── wsola │ │ │ │ ├── errorcodes.h │ │ │ │ ├── Android.mk │ │ │ │ ├── wsola.h │ │ │ │ └── wsola-jni.c │ │ │ └── libvorbis │ │ │ │ ├── CHANGELOG │ │ │ │ ├── ogg │ │ │ │ ├── config_types.h │ │ │ │ └── os_types.h │ │ │ │ ├── Android.mk │ │ │ │ ├── block.h │ │ │ │ ├── config_types.h │ │ │ │ ├── window.h │ │ │ │ ├── COPYING │ │ │ │ ├── registry.h │ │ │ │ ├── mdct.h │ │ │ │ ├── registry.c │ │ │ │ ├── os.h │ │ │ │ ├── README │ │ │ │ ├── window.c │ │ │ │ ├── codec_internal.h │ │ │ │ ├── autogen.sh │ │ │ │ ├── codebook.h │ │ │ │ ├── synthesis.c │ │ │ │ └── backends.h │ │ ├── res │ │ │ ├── raw │ │ │ │ ├── loop1.mp3 │ │ │ │ └── loop1_ogg.ogg │ │ │ ├── drawable-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── styles.xml │ │ │ │ └── dimens.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── libs │ │ │ └── armeabi-v7a │ │ │ │ ├── libmpg123.so │ │ │ │ ├── libvorbis.so │ │ │ │ ├── libwsola.so │ │ │ │ └── libpodax-native.so │ │ ├── java │ │ │ └── com │ │ │ │ └── axelby │ │ │ │ └── mp3decoders │ │ │ │ ├── Native.java │ │ │ │ ├── IMediaDecoder.java │ │ │ │ ├── StreamSkipper.java │ │ │ │ ├── PatientFileInputStream.java │ │ │ │ ├── Vorbis.java │ │ │ │ ├── MPG123.java │ │ │ │ ├── StreamFeeder.java │ │ │ │ └── WSOLA.java │ │ └── AndroidManifest.xml │ └── test │ │ └── java │ │ └── com │ │ └── axelby │ │ └── mp3decoders │ │ └── MainActivityTest.java ├── proguard-rules.txt └── build.gradle ├── settings.gradle ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── MP3Decoders.iml └── gradlew.bat /.idea/.name: -------------------------------------------------------------------------------- 1 | MP3Decoders -------------------------------------------------------------------------------- /mp3decoders/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include 'mp3decoders' -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | include $(call all-subdir-makefiles) 2 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | #APP_ABI := armeabi armeabi-v7a x86 x86_64 2 | APP_ABI := armeabi-v7a 3 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | .DS_Store 5 | 6 | # Generated files 7 | build/ 8 | obj/ 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /mp3decoders/src/main/res/raw/loop1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/mp3decoders/src/main/res/raw/loop1.mp3 -------------------------------------------------------------------------------- /mp3decoders/src/main/res/raw/loop1_ogg.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/mp3decoders/src/main/res/raw/loop1_ogg.ogg -------------------------------------------------------------------------------- /mp3decoders/src/main/libs/armeabi-v7a/libmpg123.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/mp3decoders/src/main/libs/armeabi-v7a/libmpg123.so -------------------------------------------------------------------------------- /mp3decoders/src/main/libs/armeabi-v7a/libvorbis.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/mp3decoders/src/main/libs/armeabi-v7a/libvorbis.so -------------------------------------------------------------------------------- /mp3decoders/src/main/libs/armeabi-v7a/libwsola.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/mp3decoders/src/main/libs/armeabi-v7a/libwsola.so -------------------------------------------------------------------------------- /mp3decoders/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/mp3decoders/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /mp3decoders/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/mp3decoders/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /mp3decoders/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/mp3decoders/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mp3decoders/src/main/libs/armeabi-v7a/libpodax-native.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/mp3decoders/src/main/libs/armeabi-v7a/libpodax-native.so -------------------------------------------------------------------------------- /mp3decoders/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thasmin/android-mp3decoders/HEAD/mp3decoders/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/dictionaries/dan.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | vorbis 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_sse.S: -------------------------------------------------------------------------------- 1 | #include "mangle.h" 2 | #define MPL_DCT64 ASM_NAME(dct64_sse) 3 | #define SYNTH_NAME ASM_NAME(synth_1to1_sse_asm) 4 | #include "synth_sse3d.h" 5 | 6 | NONEXEC_STACK 7 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_3dnowext.S: -------------------------------------------------------------------------------- 1 | #include "mangle.h" 2 | #define MPL_DCT64 ASM_NAME(dct64_3dnowext) 3 | #define SYNTH_NAME ASM_NAME(synth_1to1_3dnowext_asm) 4 | #include "synth_sse3d.h" 5 | 6 | NONEXEC_STACK 7 | -------------------------------------------------------------------------------- /mp3decoders/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Podax Playground 5 | Settings 6 | 7 | 8 | -------------------------------------------------------------------------------- /mp3decoders/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /mp3decoders/src/main/java/com/axelby/mp3decoders/Native.java: -------------------------------------------------------------------------------- 1 | package com.axelby.mp3decoders; 2 | 3 | public class Native { 4 | protected static native void init(); 5 | 6 | static { 7 | System.loadLibrary("podax-native"); 8 | Native.init(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /mp3decoders/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Nov 26 16:56:09 CST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/icy2utf8.h: -------------------------------------------------------------------------------- 1 | /* You expect a license plate for _this_ file? */ 2 | #ifndef MPG123_ICY2UTF_H 3 | #define MPG123_ICY2UTF_H 4 | 5 | #ifndef NO_ICY 6 | /* (string, force conversion) */ 7 | char *icy2utf8(const char *, int); 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/podax-native/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_LDLIBS := -llog -lOpenSLES 6 | LOCAL_MODULE := podax-native 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_SRC_FILES := podax-native.c 9 | 10 | include $(BUILD_SHARED_LIBRARY) 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/mockable_android_22.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/wsola/errorcodes.h: -------------------------------------------------------------------------------- 1 | // 2 | // Slaut - Slamnig Audio Utilities project 3 | // 4 | // slauterror.h 5 | // 6 | // Error values 7 | // 8 | // Created: 2014/05/18 D.Slamnig 9 | // 10 | 11 | // values identical to SlautError.java: 12 | #define SUCCESS 0 13 | #define ERR_INVALIDPARAMS -1 14 | #define ERR_ALLOC -2 15 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/true.h: -------------------------------------------------------------------------------- 1 | /* 2 | true: a trivial truth 3 | 4 | copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http:#mpg123.org 6 | */ 7 | 8 | #ifndef MPG123_H_TRUE 9 | #define MPG123_H_TRUE 10 | 11 | #define FALSE 0 12 | #define TRUE 1 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/wsola/Android.mk: -------------------------------------------------------------------------------- 1 | # Slaut - Slamnig Audio Utilities project 2 | # Android.mk 3 | # Created: 2014/05/18 D.Slamnig 4 | 5 | LOCAL_PATH := $(call my-dir) 6 | 7 | include $(CLEAR_VARS) 8 | 9 | LOCAL_LDLIBS := -llog 10 | LOCAL_MODULE := wsola 11 | LOCAL_ARM_MODE := arm 12 | 13 | LOCAL_SRC_FILES := wsola-jni.c wsola.c 14 | 15 | include $(BUILD_SHARED_LIBRARY) 16 | 17 | -------------------------------------------------------------------------------- /mp3decoders/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/wsola/wsola.h: -------------------------------------------------------------------------------- 1 | // 2 | // Slaut - Slamnig Audio Utilities project 3 | // 4 | // wsola.h 5 | // 6 | // WSOLA audio time stretching function header 7 | // 8 | // Created: 2014/05/18 D.Slamnig 9 | // 10 | 11 | void WSOLA_Init(void); 12 | void WSOLA_Close(void); 13 | int WSOLA_TimeStretch(short *psInBuf, int nInBufLen, 14 | short *psOutBuf, int nOutBufLen, 15 | int nInRate, bool bStereo, float fSpeedRatio, int nDecimate); 16 | -------------------------------------------------------------------------------- /.idea/libraries/junit_4_12.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/equalizer.c: -------------------------------------------------------------------------------- 1 | /* 2 | equalizer.c: equalizer settings 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp 7 | */ 8 | 9 | 10 | #include "mpg123lib_intern.h" 11 | 12 | void do_equalizer(real *bandPtr,int channel, real equalizer[2][32]) 13 | { 14 | int i; 15 | for(i=0;i<32;i++) 16 | bandPtr[i] = REAL_MUL(bandPtr[i], equalizer[channel][i]); 17 | } 18 | -------------------------------------------------------------------------------- /.idea/libraries/annotations_12_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /mp3decoders/src/main/java/com/axelby/mp3decoders/IMediaDecoder.java: -------------------------------------------------------------------------------- 1 | package com.axelby.mp3decoders; 2 | 3 | public interface IMediaDecoder { 4 | void close(); 5 | int readFrame(short[] buffer); 6 | boolean skipFrame(); 7 | int seek(float offsetInSeconds); 8 | float getPosition(); 9 | int getNumChannels(); 10 | int getRate(); 11 | float getDuration(); 12 | 13 | // for streaming 14 | public int getSeekFrameOffset(float position); 15 | public void feed(byte[] buffer, int count); 16 | public void completeStream(); 17 | public boolean isStreamComplete(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/CHANGELOG: -------------------------------------------------------------------------------- 1 | *** 20020517: 1.0.2 *** 2 | 3 | Playback bugfix to floor1; mode mistakenly used for sizing instead 4 | of blockflag 5 | 6 | *** 20020515: 1.0.1 *** 7 | 8 | Added complete API documentation to source tarball. No code 9 | changes. 10 | 11 | *** 20020412: 1.0.1 *** 12 | 13 | Fixed a clipping bug that affected ARM processors; negative 14 | overflows were being properly clipped, but then clobbered to 15 | positive by the positive overflow chec (asm_arm.h:CLIP_TO_15) 16 | 17 | *** 20020403: 1.0.0 *** 18 | 19 | Initial version -------------------------------------------------------------------------------- /.idea/libraries/hamcrest_core_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/ogg/config_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_TYPES_H__ 2 | #define __CONFIG_TYPES_H__ 3 | 4 | /* these are filled in by configure */ 5 | #define INCLUDE_INTTYPES_H 1 6 | #define INCLUDE_STDINT_H 1 7 | #define INCLUDE_SYS_TYPES_H 1 8 | 9 | #if INCLUDE_INTTYPES_H 10 | # include 11 | #endif 12 | #if INCLUDE_STDINT_H 13 | # include 14 | #endif 15 | #if INCLUDE_SYS_TYPES_H 16 | # include 17 | #endif 18 | 19 | typedef int16_t ogg_int16_t; 20 | typedef uint16_t ogg_uint16_t; 21 | typedef int32_t ogg_int32_t; 22 | typedef uint32_t ogg_uint32_t; 23 | typedef int64_t ogg_int64_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/dither.h: -------------------------------------------------------------------------------- 1 | /* 2 | dither: Generate noise for dithering / noise shaping. 3 | 4 | copyright 2009 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Monma 7 | */ 8 | 9 | #ifndef MPG123_DITHER_H 10 | #define MPG123_DITHER_H 11 | 12 | #define DITHERSIZE 65536 13 | enum mpg123_noise_type 14 | { 15 | mpg123_white_noise = 0 16 | ,mpg123_tpdf_noise 17 | ,mpg123_highpass_tpdf_noise 18 | }; 19 | 20 | void mpg123_noise(float* table, size_t count, enum mpg123_noise_type noisetype); 21 | void dither_table_init(float *dithertable); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/check_neon.S: -------------------------------------------------------------------------------- 1 | /* 2 | check_neon: check NEON availability 3 | 4 | copyright 1995-2014 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Momma 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | #ifndef __aarch64__ 12 | .code 32 13 | #ifndef __APPLE__ 14 | .fpu neon 15 | #endif 16 | #endif 17 | 18 | .text 19 | .globl ASM_NAME(check_neon) 20 | #ifdef __ELF__ 21 | .type ASM_NAME(check_neon), %function 22 | #endif 23 | ALIGN4 24 | ASM_NAME(check_neon): 25 | #ifdef __aarch64__ 26 | orr v0.16b, v0.16b, v0.16b 27 | ret 28 | #else 29 | vorr d0, d0, d0 30 | bx lr 31 | #endif 32 | 33 | NONEXEC_STACK 34 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /mp3decoders/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | -dontwarn javazoom.jl.player.* 20 | -------------------------------------------------------------------------------- /mp3decoders/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/icy.c: -------------------------------------------------------------------------------- 1 | /* 2 | icy: Puny code to pretend for a serious ICY data structure. 3 | 4 | copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis 7 | */ 8 | 9 | #include "icy.h" 10 | 11 | void init_icy(struct icy_meta *icy) 12 | { 13 | icy->data = NULL; 14 | } 15 | 16 | void clear_icy(struct icy_meta *icy) 17 | { 18 | if(icy->data != NULL) free(icy->data); 19 | init_icy(icy); 20 | } 21 | 22 | void reset_icy(struct icy_meta *icy) 23 | { 24 | clear_icy(icy); 25 | init_icy(icy); 26 | } 27 | /*void set_icy(struct icy_meta *icy, char* new_data) 28 | { 29 | if(icy->data) free(icy->data); 30 | icy->data = new_data; 31 | icy->changed = 1; 32 | }*/ 33 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /mp3decoders/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | dependencies { 4 | compile 'com.intellij:annotations:+@jar' 5 | testCompile 'junit:junit:4.12' 6 | } 7 | 8 | android { 9 | compileSdkVersion 22 10 | buildToolsVersion "22.0.1" 11 | defaultConfig { 12 | minSdkVersion 16 13 | targetSdkVersion 22 14 | versionCode 1 15 | versionName "1.0" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled true 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt' 21 | } 22 | } 23 | 24 | /* preferably use the ndkbuild step of gradle but it doesn't work */ 25 | sourceSets.main { 26 | jni.srcDirs = [] 27 | jniLibs.srcDir 'src/main/libs' 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/icy.h: -------------------------------------------------------------------------------- 1 | /* 2 | icy: support for SHOUTcast ICY meta info, an attempt to keep it organized 3 | 4 | copyright 2006-7 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis and modelled after patch by Honza 7 | */ 8 | #ifndef MPG123_ICY_H 9 | #define MPG123_ICY_H 10 | 11 | #ifndef NO_ICY 12 | 13 | #include "compat.h" 14 | #include "mpg123.h" 15 | 16 | struct icy_meta 17 | { 18 | char* data; 19 | off_t interval; 20 | off_t next; 21 | }; 22 | 23 | void init_icy(struct icy_meta *); 24 | void clear_icy(struct icy_meta *); 25 | void reset_icy(struct icy_meta *); 26 | 27 | #else 28 | 29 | #undef init_icy 30 | #define init_icy(a) 31 | #undef clear_icy 32 | #define clear_icy(a) 33 | #undef reset_icy 34 | #define reset_icy(a) 35 | 36 | #endif /* NO_ICY */ 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /mp3decoders/src/main/java/com/axelby/mp3decoders/StreamSkipper.java: -------------------------------------------------------------------------------- 1 | package com.axelby.mp3decoders; 2 | 3 | public class StreamSkipper { 4 | private final IMediaDecoder _decoder; 5 | private final Thread _thread; 6 | private boolean _isDone = false; 7 | 8 | public StreamSkipper(IMediaDecoder fullDecoder) { 9 | Runnable _runnable = new Runnable() { 10 | @Override 11 | public void run() { 12 | try { 13 | while (!_decoder.isStreamComplete()) 14 | if (!_decoder.skipFrame()) 15 | Thread.sleep(50); 16 | } catch (InterruptedException ignored) { 17 | } finally { 18 | _isDone = true; 19 | } 20 | } 21 | }; 22 | 23 | _decoder = fullDecoder; 24 | _thread = new Thread(_runnable, "StreamSkipper"); 25 | _thread.start(); 26 | } 27 | 28 | public boolean isDone() { return _isDone; } 29 | 30 | public void close() { 31 | _thread.interrupt(); 32 | try { 33 | _thread.join(); 34 | } catch (InterruptedException ignored) { 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | parse: spawned from common; clustering around stream/frame parsing 3 | 4 | copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp & Thomas Orgis 7 | */ 8 | 9 | #ifndef MPG123_PARSE_H 10 | #define MPG123_PARSE_H 11 | 12 | #include "frame.h" 13 | 14 | int read_frame_init(mpg123_handle* fr); 15 | int frame_bitrate(mpg123_handle *fr); 16 | long frame_freq(mpg123_handle *fr); 17 | int read_frame_recover(mpg123_handle* fr); /* dead? */ 18 | int read_frame(mpg123_handle *fr); 19 | void set_pointer(mpg123_handle *fr, long backstep); 20 | int position_info(mpg123_handle* fr, unsigned long no, long buffsize, unsigned long* frames_left, double* current_seconds, double* seconds_left); 21 | double compute_bpf(mpg123_handle *fr); 22 | long time_to_frame(mpg123_handle *fr, double seconds); 23 | int get_songlen(mpg123_handle *fr,int no); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/getcpuflags_arm.c: -------------------------------------------------------------------------------- 1 | /* 2 | getcpuflags_arm: get cpuflags for ARM 3 | 4 | copyright 1995-2014 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Momma 7 | */ 8 | 9 | #include 10 | #include 11 | #include "mpg123lib_intern.h" 12 | #include "getcpuflags.h" 13 | 14 | extern void check_neon(void); 15 | 16 | static sigjmp_buf jmpbuf; 17 | 18 | static void mpg123_arm_catch_sigill(int sig) 19 | { 20 | siglongjmp(jmpbuf, 1); 21 | } 22 | 23 | unsigned int getcpuflags(struct cpuflags* cf) 24 | { 25 | struct sigaction act, act_old; 26 | act.sa_handler = mpg123_arm_catch_sigill; 27 | act.sa_flags = SA_RESTART; 28 | sigemptyset(&act.sa_mask); 29 | sigaction(SIGILL, &act, &act_old); 30 | 31 | cf->has_neon = 0; 32 | 33 | if(!sigsetjmp(jmpbuf, 1)) { 34 | check_neon(); 35 | cf->has_neon = 1; 36 | } 37 | 38 | sigaction(SIGILL, &act_old, NULL); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /MP3Decoders.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_C_INCLUDES := $(LOCAL_PATH) 5 | LOCAL_MODULE := vorbis 6 | LOCAL_ARM_MODE := arm 7 | LOCAL_LDLIBS := -llog 8 | 9 | ifeq ($(TARGET_ARCH),arm) 10 | LOCAL_CFLAGS := -D_ARM_ASSEM_ \ 11 | -Wno-int-to-pointer-cast \ 12 | -Wno-pointer-to-int-cast 13 | endif 14 | ifeq ($(TARGET_ARCH),x86) 15 | LOCAL_CFLAGS := -Wno-int-to-pointer-cast \ 16 | -Wno-pointer-to-int-cast 17 | endif 18 | 19 | LOCAL_SRC_FILES := podax_Vorbis.c 20 | LOCAL_SRC_FILES += block.c 21 | LOCAL_SRC_FILES += codebook.c 22 | LOCAL_SRC_FILES += floor0.c 23 | LOCAL_SRC_FILES += floor1.c 24 | LOCAL_SRC_FILES += info.c 25 | LOCAL_SRC_FILES += mapping0.c 26 | LOCAL_SRC_FILES += mdct.c 27 | LOCAL_SRC_FILES += registry.c 28 | LOCAL_SRC_FILES += res012.c 29 | LOCAL_SRC_FILES += sharedbook.c 30 | LOCAL_SRC_FILES += synthesis.c 31 | LOCAL_SRC_FILES += vorbisfile.c 32 | LOCAL_SRC_FILES += window.c 33 | LOCAL_SRC_FILES += ogg/framing.c 34 | LOCAL_SRC_FILES += ogg/bitwise.c 35 | 36 | include $(BUILD_SHARED_LIBRARY) 37 | 38 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/testcpu.c: -------------------------------------------------------------------------------- 1 | /* 2 | testcpu: standalone CPU flags tester 3 | 4 | copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis 7 | */ 8 | 9 | #include 10 | #include "getcpuflags.h" 11 | 12 | int main() 13 | { 14 | int family; 15 | struct cpuflags flags; 16 | if(!getcpuflags(&flags)){ printf("CPU won't do cpuid (some old i386 or i486)\n"); return 0; } 17 | family = (flags.id & 0xf00)>>8; 18 | printf("family: %i\n", family); 19 | printf("stdcpuflags: 0x%08x\n", flags.std); 20 | printf("std2cpuflags: 0x%08x\n", flags.std2); 21 | printf("extcpuflags: 0x%08x\n", flags.ext); 22 | if(cpu_i586(flags)) 23 | { 24 | printf("A i586 or better cpu with:"); 25 | if(cpu_mmx(flags)) printf(" mmx"); 26 | if(cpu_3dnow(flags)) printf(" 3dnow"); 27 | if(cpu_3dnowext(flags)) printf(" 3dnowext"); 28 | if(cpu_sse(flags)) printf(" sse"); 29 | if(cpu_sse2(flags)) printf(" sse2"); 30 | if(cpu_sse3(flags)) printf(" sse3"); 31 | printf("\n"); 32 | } 33 | else printf("I guess you have some i486\n"); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/block.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2008 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: shared block functions 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_BLOCK_ 19 | #define _V_BLOCK_ 20 | 21 | extern void _vorbis_block_ripcord(vorbis_block *vb); 22 | extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/getcpuflags_x86_64.S: -------------------------------------------------------------------------------- 1 | /* 2 | getcpuflags_x86_64: get cpuflags for x86-64 3 | 4 | copyright 1995-2013 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Monma 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | .text 12 | ALIGN4 13 | .globl ASM_NAME(getcpuflags) 14 | ASM_NAME(getcpuflags): 15 | push %rbp 16 | mov %rsp, %rbp 17 | push %rbx 18 | 19 | #ifdef IS_MSABI 20 | push %rdi 21 | mov %rcx, %rdi 22 | #endif 23 | 24 | movl $0, 12(%rdi) 25 | movl $0, 16(%rdi) 26 | 27 | mov $0x80000000, %eax 28 | cpuid 29 | cmp $0x80000001, %eax 30 | jb 1f 31 | mov $0x80000001, %eax 32 | cpuid 33 | movl %edx, 12(%rdi) 34 | 1: 35 | mov $0x00000001, %eax 36 | cpuid 37 | movl %eax, (%rdi) 38 | movl %ecx, 4(%rdi) 39 | movl %edx, 8(%rdi) 40 | test $0x04000000, %ecx 41 | jz 2f 42 | test $0x08000000, %ecx 43 | jz 2f 44 | xor %ecx, %ecx 45 | .byte 0x0f, 0x01, 0xd0 /* xgetbv instruction */ 46 | movl %eax, 16(%rdi) 47 | movl (%rdi), %eax 48 | 2: 49 | #ifdef IS_MSABI 50 | pop %rdi 51 | #endif 52 | pop %rbx 53 | mov %rbp, %rsp 54 | pop %rbp 55 | ret 56 | 57 | NONEXEC_STACK 58 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/config_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: #ifdef jail to whip a few platforms into the UNIX ideal. 15 | 16 | ********************************************************************/ 17 | #ifndef _OS_CVTYPES_H 18 | #define _OS_CVTYPES_H 19 | 20 | typedef long long ogg_int64_t; 21 | typedef int ogg_int32_t; 22 | typedef unsigned int ogg_uint32_t; 23 | typedef short ogg_int16_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/window.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: window functions 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_WINDOW_ 19 | #define _V_WINDOW_ 20 | 21 | extern const void *_vorbis_window(int type,int left); 22 | extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2], 23 | long *blocksizes, 24 | int lW,int W,int nW); 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/id3.h: -------------------------------------------------------------------------------- 1 | /* 2 | id3: ID3v2.3 and ID3v2.4 parsing (a relevant subset) 3 | 4 | copyright 2006-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis 7 | */ 8 | 9 | #ifndef MPG123_ID3_H 10 | #define MPG123_ID3_H 11 | 12 | /* really need it _here_! */ 13 | #include "frame.h" 14 | 15 | #ifdef NO_ID3V2 16 | # ifdef init_id3 17 | # undef init_id3 18 | # endif 19 | # define init_id3(fr) 20 | # ifdef exit_id3 21 | # undef exit_id3 22 | # endif 23 | # define exit_id3(fr) 24 | # ifdef reset_id3 25 | # undef reset_id3 26 | # endif 27 | # define reset_id3(fr) 28 | # ifdef id3_link 29 | # undef id3_link 30 | # endif 31 | # define id3_link(fr) 32 | #else 33 | void init_id3(mpg123_handle *fr); 34 | void exit_id3(mpg123_handle *fr); 35 | void reset_id3(mpg123_handle *fr); 36 | void id3_link(mpg123_handle *fr); 37 | #endif 38 | int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes); 39 | /* Convert text from some ID3 encoding to UTf-8. 40 | On error, sb->fill is 0. The noquiet flag enables warning/error messages. */ 41 | void id3_to_utf8(mpg123_string *sb, unsigned char encoding, const unsigned char *source, size_t source_size, int noquiet); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/abi_align.h: -------------------------------------------------------------------------------- 1 | /* 2 | mpg123lib_intern: Common non-public stuff for libmpg123 3 | 4 | copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | 7 | derived from the old mpg123.h 8 | */ 9 | 10 | #ifndef MPG123_H_ABI_ALIGN 11 | #define MPG123_H_ABI_ALIGN 12 | 13 | #include "config.h" 14 | 15 | /* ABI conformance for other compilers. 16 | mpg123 needs 16byte-aligned stack for SSE and friends. 17 | gcc provides that, but others don't necessarily. */ 18 | #ifdef ABI_ALIGN_FUN 19 | #ifndef attribute_align_arg 20 | #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__>1) 21 | # define attribute_align_arg __attribute__((force_align_arg_pointer)) 22 | /* The gcc that can align the stack does not need the check... nor does it work with gcc 4.3+, anyway. */ 23 | #else 24 | 25 | # define attribute_align_arg 26 | /* Other compilers get code to catch misaligned stack. 27 | Well, except Sun Studio, which accepts the aligned attribute but does not honor it. */ 28 | #if !defined(__SUNPRO_C) 29 | # define NEED_ALIGNCHECK 30 | #endif 31 | 32 | #endif 33 | #endif 34 | #else 35 | #define attribute_align_arg 36 | /* We won't try the align check... */ 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synths.h: -------------------------------------------------------------------------------- 1 | #ifndef MPG123_SYNTH_H 2 | #define MPG123_SYNTH_H 3 | 4 | /* This is included inside frame.h, which is included in mpg123lib_intern.h, 5 | at the appropriate place. 6 | Explicit header inclusions here would cause circular dependencies. */ 7 | 8 | /* The handle needs these types for selecting the decoding routine at runtime. 9 | Not just for optimization, mainly for XtoY, mono/stereo. */ 10 | typedef int (*func_synth)(real *,int, mpg123_handle *,int ); 11 | typedef int (*func_synth_mono)(real *, mpg123_handle *); 12 | typedef int (*func_synth_stereo)(real *, real *, mpg123_handle *); 13 | enum synth_channel { c_plain=0, c_stereo, c_m2s, c_mono, c_limit }; 14 | enum synth_resample 15 | { 16 | r_none=-1 17 | ,r_1to1=0 18 | # ifndef NO_DOWNSAMPLE 19 | ,r_2to1 20 | ,r_4to1 21 | # endif 22 | # ifndef NO_NTOM 23 | ,r_ntom 24 | # endif 25 | ,r_limit 26 | }; 27 | enum synth_format 28 | { 29 | f_none=-1 30 | # ifndef NO_16BIT 31 | ,f_16 32 | # endif 33 | # ifndef NO_8BIT 34 | ,f_8 35 | # endif 36 | # ifndef NO_REAL 37 | ,f_real 38 | # endif 39 | # ifndef NO_32BIT 40 | ,f_32 41 | # endif 42 | ,f_limit 43 | }; 44 | struct synth_s 45 | { 46 | func_synth plain[r_limit][f_limit]; 47 | func_synth_stereo stereo[r_limit][f_limit]; 48 | func_synth_mono mono2stereo[r_limit][f_limit]; 49 | func_synth_mono mono[r_limit][f_limit]; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/wsola/wsola-jni.c: -------------------------------------------------------------------------------- 1 | //Slaut - Slamnig Audio Utilities project 2 | // podax-jni.c 3 | // JNI code 4 | // Created: 2014/05/18 D.Slamnig 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "wsola.h" 12 | #include "errorcodes.h" 13 | 14 | JNIEXPORT void JNICALL 15 | Java_com_axelby_podax_player_WSOLA_init(JNIEnv* env, jobject thiz) 16 | { 17 | WSOLA_Init(); 18 | } 19 | 20 | JNIEXPORT void JNICALL 21 | Java_com_axelby_podax_player_WSOLA_close(JNIEnv* env, jobject thiz) 22 | { 23 | WSOLA_Close(); 24 | } 25 | 26 | JNIEXPORT jint JNICALL 27 | Java_com_axelby_podax_player_WSOLA_wsolaStretchJNI(JNIEnv* env, jobject thiz, 28 | jshortArray plainBuffer, jshortArray stretchBuffer, 29 | jint sampleRate, jboolean stereo, jfloat speedRatio, jint quality) 30 | { 31 | short *inBuf, *outBuf; 32 | int inSize, outSize; 33 | int errCode = ERR_INVALIDPARAMS; 34 | 35 | if ((inBuf = (*env)->GetShortArrayElements(env, plainBuffer, NULL)) != NULL) { 36 | inSize = (*env)->GetArrayLength(env, plainBuffer); 37 | if ((outBuf = (*env)->GetShortArrayElements(env, stretchBuffer, NULL)) != NULL) { 38 | outSize = (*env)->GetArrayLength(env, stretchBuffer); 39 | 40 | errCode = WSOLA_TimeStretch(inBuf, inSize, outBuf, outSize, 41 | sampleRate, stereo, speedRatio, quality); 42 | 43 | (*env)->ReleaseShortArrayElements(env, stretchBuffer, outBuf, 0); 44 | } 45 | (*env)->ReleaseShortArrayElements(env, plainBuffer, inBuf, 0); 46 | } 47 | 48 | return errCode; 49 | } 50 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002, Xiph.org Foundation 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | - Neither the name of the Xiph.org Foundation nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION 22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/registry.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: registry for time, floor, res backends and channel mappings 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_REG_H_ 19 | #define _V_REG_H_ 20 | 21 | #define VI_TRANSFORMB 1 22 | #define VI_WINDOWB 1 23 | #define VI_TIMEB 1 24 | #define VI_FLOORB 2 25 | #define VI_RESB 3 26 | #define VI_MAPB 1 27 | 28 | #include "backends.h" 29 | 30 | #if defined(_WIN32) && defined(VORBISDLL_IMPORT) 31 | # define EXTERN __declspec(dllimport) extern 32 | #else 33 | # define EXTERN extern 34 | #endif 35 | 36 | EXTERN vorbis_func_floor *_floor_P[]; 37 | EXTERN vorbis_func_residue *_residue_P[]; 38 | EXTERN vorbis_func_mapping *_mapping_P[]; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/mdct.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: modified discrete cosine transform prototypes 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _OGG_mdct_H_ 19 | #define _OGG_mdct_H_ 20 | 21 | #include "ivorbiscodec.h" 22 | #include "misc.h" 23 | 24 | #define DATA_TYPE ogg_int32_t 25 | #define REG_TYPE register ogg_int32_t 26 | 27 | #ifdef _LOW_ACCURACY_ 28 | #define cPI3_8 (0x0062) 29 | #define cPI2_8 (0x00b5) 30 | #define cPI1_8 (0x00ed) 31 | #else 32 | #define cPI3_8 (0x30fbc54d) 33 | #define cPI2_8 (0x5a82799a) 34 | #define cPI1_8 (0x7641af3d) 35 | #endif 36 | 37 | extern void mdct_forward(int n, DATA_TYPE *in, DATA_TYPE *out); 38 | extern void mdct_backward(int n, DATA_TYPE *in, DATA_TYPE *out); 39 | 40 | #endif 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/equalizer_3dnow.S: -------------------------------------------------------------------------------- 1 | /* 2 | equalizer_3dnow: 3DNow! optimized do_equalizer() 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by KIMURA Takuhiro 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | .text 12 | ALIGN4 13 | .globl ASM_NAME(do_equalizer_3dnow) 14 | /* .type ASM_NAME(do_equalizer_3dnow),@function */ 15 | /* void do_equalizer(real *bandPtr,int channel, real equalizer[2][32]); */ 16 | ASM_NAME(do_equalizer_3dnow): 17 | pushl %esi 18 | pushl %ebx 19 | /* bandPtr */ 20 | movl 12(%esp),%ebx 21 | /* channel */ 22 | movl 16(%esp),%ecx 23 | xorl %edx,%edx 24 | /* equalizer */ 25 | movl 20(%esp),%esi 26 | sall $7,%ecx 27 | ALIGN4 28 | .L9: 29 | movq (%ebx,%edx),%mm0 30 | pfmul (%esi,%ecx),%mm0 31 | 32 | movq 8(%ebx,%edx),%mm1 33 | pfmul 8(%esi,%ecx),%mm1 34 | movq %mm0,(%ebx,%edx) 35 | 36 | movq 16(%ebx,%edx),%mm0 37 | pfmul 16(%esi,%ecx),%mm0 38 | movq %mm1,8(%ebx,%edx) 39 | 40 | movq 24(%ebx,%edx),%mm1 41 | pfmul 24(%esi,%ecx),%mm1 42 | movq %mm0,16(%ebx,%edx) 43 | 44 | movq 32(%ebx,%edx),%mm0 45 | pfmul 32(%esi,%ecx),%mm0 46 | movq %mm1,24(%ebx,%edx) 47 | 48 | movq 40(%ebx,%edx),%mm1 49 | pfmul 40(%esi,%ecx),%mm1 50 | movq %mm0,32(%ebx,%edx) 51 | 52 | movq 48(%ebx,%edx),%mm0 53 | pfmul 48(%esi,%ecx),%mm0 54 | movq %mm1,40(%ebx,%edx) 55 | 56 | movq 56(%ebx,%edx),%mm1 57 | pfmul 56(%esi,%ecx),%mm1 58 | movq %mm0,48(%ebx,%edx) 59 | movq %mm1,56(%ebx,%edx) 60 | 61 | addl $64,%edx 62 | addl $32,%ecx 63 | cmpl $124,%edx 64 | jle .L9 65 | ALIGN4 66 | popl %ebx 67 | popl %esi 68 | ret 69 | 70 | NONEXEC_STACK 71 | -------------------------------------------------------------------------------- /mp3decoders/src/main/java/com/axelby/mp3decoders/PatientFileInputStream.java: -------------------------------------------------------------------------------- 1 | package com.axelby.mp3decoders; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.io.File; 6 | import java.io.FileDescriptor; 7 | import java.io.FileInputStream; 8 | import java.io.FileNotFoundException; 9 | import java.io.IOException; 10 | 11 | /** 12 | * file input stream that waits for more data if there are none available 13 | * call interrupt or interrupt thread to stop 14 | */ 15 | public class PatientFileInputStream extends FileInputStream { 16 | protected boolean _interrupted = false; 17 | 18 | public PatientFileInputStream(File file) throws FileNotFoundException { 19 | super(file); 20 | } 21 | 22 | @SuppressWarnings("unused") 23 | public PatientFileInputStream(FileDescriptor fd) { 24 | super(fd); 25 | } 26 | 27 | @SuppressWarnings("unused") 28 | public PatientFileInputStream(String path) throws FileNotFoundException { 29 | super(path); 30 | } 31 | 32 | @SuppressWarnings("unused") 33 | public void interrupt() { _interrupted = true; } 34 | 35 | // keep thread sleeping until 36 | private void waitForAvailable() throws IOException { 37 | while (!_interrupted && available() <= 0) { 38 | try { 39 | Thread.sleep(100); 40 | } catch (InterruptedException e) { 41 | return; 42 | } 43 | } 44 | } 45 | 46 | @Override 47 | public int read() throws IOException { 48 | waitForAvailable(); 49 | return super.read(); 50 | } 51 | 52 | @Override 53 | public int read(@NotNull byte[] buffer, int byteOffset, int byteCount) throws IOException { 54 | waitForAvailable(); 55 | return super.read(buffer, byteOffset, byteCount); 56 | } 57 | 58 | @Override 59 | public int read(@NotNull byte[] buffer) throws IOException { 60 | waitForAvailable(); 61 | return super.read(buffer); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /mp3decoders/src/main/java/com/axelby/mp3decoders/Vorbis.java: -------------------------------------------------------------------------------- 1 | package com.axelby.mp3decoders; 2 | 3 | public class Vorbis implements IMediaDecoder { 4 | static { 5 | System.loadLibrary("vorbis"); 6 | } 7 | 8 | private static native long openFile(String filename); 9 | private static native void delete(long handle); 10 | private static native int readFrame(long handle, short[] buffer); 11 | private static native boolean skipFrame(long handle); 12 | private static native int seek(long handle, float offset); 13 | private static native float getPosition(long handle); 14 | private static native int getNumChannels(long handle); 15 | private static native int getRate(long handle); 16 | private static native float getDuration(long handle); 17 | 18 | protected boolean _streamComplete = false; 19 | 20 | long _handle = 0; 21 | public Vorbis(String filename) { _handle = openFile(filename); _streamComplete = true; } 22 | 23 | @Override 24 | public void close() { 25 | if (_handle != 0) 26 | Vorbis.delete(_handle); 27 | } 28 | 29 | @Override public int readFrame(short[] buffer) { return Vorbis.readFrame(_handle, buffer); } 30 | @Override public boolean skipFrame() { return Vorbis.skipFrame(_handle); } 31 | @Override public int seek(float offset) { return Vorbis.seek(_handle, offset); } 32 | @Override public float getPosition() { return Vorbis.getPosition(_handle); } 33 | @Override public int getNumChannels() { return Vorbis.getNumChannels(_handle); } 34 | @Override public int getRate() { return Vorbis.getRate(_handle); } 35 | @Override public float getDuration() { return Vorbis.getDuration(_handle); } 36 | @Override public int getSeekFrameOffset(float position) { return 0; } 37 | @Override public void feed(byte[] buffer, int count) { } 38 | @Override public void completeStream() { _streamComplete = true; } 39 | @Override public boolean isStreamComplete() { return _streamComplete; } 40 | } 41 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/registry.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: registry for floor, res backends and channel mappings 15 | 16 | ********************************************************************/ 17 | 18 | #include "ivorbiscodec.h" 19 | #include "codec_internal.h" 20 | #include "registry.h" 21 | #include "misc.h" 22 | 23 | 24 | /* seems like major overkill now; the backend numbers will grow into 25 | the infrastructure soon enough */ 26 | 27 | extern vorbis_func_floor floor0_exportbundle; 28 | extern vorbis_func_floor floor1_exportbundle; 29 | extern vorbis_func_residue residue0_exportbundle; 30 | extern vorbis_func_residue residue1_exportbundle; 31 | extern vorbis_func_residue residue2_exportbundle; 32 | extern vorbis_func_mapping mapping0_exportbundle; 33 | 34 | vorbis_func_floor *_floor_P[]={ 35 | &floor0_exportbundle, 36 | &floor1_exportbundle, 37 | }; 38 | 39 | vorbis_func_residue *_residue_P[]={ 40 | &residue0_exportbundle, 41 | &residue1_exportbundle, 42 | &residue2_exportbundle, 43 | }; 44 | 45 | vorbis_func_mapping *_mapping_P[]={ 46 | &mapping0_exportbundle, 47 | }; 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /mp3decoders/src/test/java/com/axelby/mp3decoders/MainActivityTest.java: -------------------------------------------------------------------------------- 1 | package com.axelby.mp3decoders; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import java.io.File; 7 | import java.io.FileWriter; 8 | import java.io.IOException; 9 | 10 | public class MainActivityTest { 11 | 12 | @Test 13 | public void testReadStreamedFile() throws IOException, InterruptedException { 14 | final File f = File.createTempFile("test", "txt"); 15 | 16 | Thread writer = new Thread(new Runnable() { 17 | @Override 18 | public void run() { 19 | FileWriter out = null; 20 | try { 21 | out = new FileWriter(f); 22 | out.write("123"); 23 | Thread.sleep(1000); 24 | out.write("abc"); 25 | } catch (IOException | InterruptedException e) { 26 | Assert.fail("writer thread fail: " + e.getMessage()); 27 | } finally { 28 | try { 29 | if (out != null) 30 | out.close(); 31 | } catch (IOException e) { 32 | e.printStackTrace(); 33 | } 34 | } 35 | 36 | } 37 | }); 38 | writer.start(); 39 | 40 | Thread reader = new Thread(new Runnable() { 41 | @Override 42 | public void run() { 43 | 44 | byte[] b = new byte[3]; 45 | int read = 0; 46 | PatientFileInputStream in = null; 47 | try { 48 | in = new PatientFileInputStream(f); 49 | 50 | while (read < 6) { 51 | read += in.read(b); 52 | if (read == 3) { 53 | Assert.assertArrayEquals("first read 123", new byte[]{'1', '2', '3'}, b); 54 | } else if (read == 6) { 55 | Assert.assertArrayEquals("second read abc", new byte[]{'a', 'b', 'c'}, b); 56 | } else { 57 | Assert.fail("read wrong number of bytes"); 58 | } 59 | } 60 | } catch (IOException e) { 61 | Assert.fail("reader thread fail: " + e.getMessage()); 62 | } finally { 63 | if (in != null) 64 | try { 65 | in.close(); 66 | } catch (IOException e) { 67 | e.printStackTrace(); 68 | } 69 | } 70 | 71 | } 72 | 73 | }); 74 | reader.start(); 75 | 76 | writer.join(); 77 | reader.join(); 78 | } 79 | } -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/os.h: -------------------------------------------------------------------------------- 1 | #ifndef _OS_H 2 | #define _OS_H 3 | /******************************************************************** 4 | * * 5 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 6 | * * 7 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 8 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 9 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 10 | * * 11 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 12 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 13 | * * 14 | ******************************************************************** 15 | 16 | function: #ifdef jail to whip a few platforms into the UNIX ideal. 17 | 18 | ********************************************************************/ 19 | 20 | #include 21 | #include 22 | 23 | #define BIG_ENDIAN 0 24 | #define LITTLE_ENDIAN 1 25 | 26 | #ifndef _V_IFDEFJAIL_H_ 27 | # define _V_IFDEFJAIL_H_ 28 | 29 | # ifdef __GNUC__ 30 | # define STIN static __inline__ 31 | # elif _WIN32 32 | # define STIN static __inline 33 | # endif 34 | #else 35 | # define STIN static 36 | #endif 37 | 38 | #ifndef M_PI 39 | # define M_PI (3.1415926536f) 40 | #endif 41 | 42 | #ifdef _WIN32 43 | # include 44 | # define rint(x) (floor((x)+0.5f)) 45 | # define NO_FLOAT_MATH_LIB 46 | # define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b)) 47 | # define LITTLE_ENDIAN 1 48 | # define BYTE_ORDER LITTLE_ENDIAN 49 | #endif 50 | 51 | #ifdef HAVE_ALLOCA_H 52 | # include 53 | #endif 54 | 55 | #ifdef USE_MEMORY_H 56 | # include 57 | #endif 58 | 59 | #ifndef min 60 | # define min(x,y) ((x)>(y)?(y):(x)) 61 | #endif 62 | 63 | #ifndef max 64 | # define max(x,y) ((x)<(y)?(y):(x)) 65 | #endif 66 | 67 | #endif /* _OS_H */ 68 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/README: -------------------------------------------------------------------------------- 1 | This README covers the Ogg Vorbis 'Tremor' integer playback codec 2 | source as of date 2002 09 02, version 1.0.0. 3 | 4 | ****** 5 | 6 | The C source in this package will build on any ANSI C compiler and 7 | function completely and properly on any platform. The included build 8 | system assumes GNU build system and make tools (m4, automake, 9 | autoconf, libtool and gmake). GCC is not required, although GCC is 10 | the most tested compiler. To build using GNU tools, type in the 11 | source directory: 12 | 13 | ./autogen.sh 14 | make 15 | 16 | Currently, the source implements playback in pure C on all platforms 17 | except ARM, where a [currently] small amount of assembly (see 18 | asm_arm.h) is used to implement 64 bit math operations and fast LSP 19 | computation. If building on ARM without the benefit of GNU build 20 | system tools, be sure that '_ARM_ASSEM_' is #defined by the build 21 | system if this assembly is desired, else the resulting library will 22 | use whatever 64 bit math builtins the compiler implements. 23 | 24 | No math library is required by this source. No floating point 25 | operations are used at any point in either setup or decode. This 26 | decoder library will properly decode any past, current or future 27 | Vorbis I file or stream. 28 | 29 | ******** 30 | 31 | The build system produces a static and [when supported by the OS] 32 | dynamic library named 'libvorbisidec'. This library exposes an API 33 | nearly identical to the BSD reference library's 'libvorbisfile', 34 | including all the features familiar to users of vorbisfile. This API 35 | is similar enough that the proper header file to include is named 36 | 'ivorbisfile.h' [included in the source build directory]. Lower level 37 | libvorbis-style headers and structures are in 'ivorbiscodec.h' 38 | [included in the source build directory]. A simple example program, 39 | ivorbisfile_example.c, can be built with 'make example'. 40 | 41 | ******** 42 | 43 | Detailed Tremor API Documentation begins at doc/index.html 44 | 45 | Monty 46 | xiph.org 47 | -------------------------------------------------------------------------------- /mp3decoders/src/main/java/com/axelby/mp3decoders/MPG123.java: -------------------------------------------------------------------------------- 1 | package com.axelby.mp3decoders; 2 | 3 | public class MPG123 implements IMediaDecoder { 4 | static { 5 | System.loadLibrary("mpg123"); 6 | MPG123.init(); 7 | } 8 | 9 | protected static native int init(); 10 | protected static native long openFile(String filename); 11 | protected static native void delete(long handle); 12 | protected static native boolean skipFrame(long handle); 13 | protected static native int seek(long handle, float offsetInSeconds); 14 | protected static native float getPosition(long handle); 15 | protected static native int getNumChannels(long handle); 16 | protected static native int getRate(long handle); 17 | protected static native float getDuration(long handle); 18 | 19 | protected static native long openStream(); 20 | protected static native void feed(long handle, byte[] buffer, int count); 21 | protected static native int readFrame(long handle, short[] buffer); 22 | protected static native int getSeekFrameOffset(long handle, float position); 23 | 24 | protected boolean _streamComplete = false; 25 | 26 | protected long _handle = 0; 27 | public MPG123() { _handle = openStream(); } 28 | public MPG123(String filename) { _handle = openFile(filename); _streamComplete = true; } 29 | 30 | public void close() { 31 | if (_handle != 0) 32 | MPG123.delete(_handle); 33 | } 34 | 35 | public int readFrame(short[] buffer) { return MPG123.readFrame(_handle, buffer); } 36 | public boolean skipFrame() { return MPG123.skipFrame(_handle); } 37 | public int seek(float offset) { return MPG123.seek(_handle, offset); } 38 | public float getPosition() { return MPG123.getPosition(_handle); } 39 | public int getNumChannels() { return MPG123.getNumChannels(_handle); } 40 | public int getRate() { return MPG123.getRate(_handle); } 41 | public float getDuration() { return MPG123.getDuration(_handle); } 42 | public int getSeekFrameOffset(float position) { return MPG123.getSeekFrameOffset(_handle, position); } 43 | public void feed(byte[] buffer, int count) { MPG123.feed(_handle, buffer, count); } 44 | public void completeStream() { _streamComplete = true; } 45 | public boolean isStreamComplete() { return _streamComplete; } 46 | } 47 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/feature.c: -------------------------------------------------------------------------------- 1 | #include "mpg123lib_intern.h" 2 | 3 | int mpg123_feature(const enum mpg123_feature_set key) 4 | { 5 | switch(key) 6 | { 7 | case MPG123_FEATURE_ABI_UTF8OPEN: 8 | #ifdef WANT_WIN32_UNICODE 9 | return 1; 10 | #else 11 | return 0; 12 | #endif /* WANT_WIN32_UNICODE */ 13 | 14 | case MPG123_FEATURE_OUTPUT_8BIT: 15 | #ifdef NO_8BIT 16 | return 0; 17 | #else 18 | return 1; 19 | #endif /* mpg123_output_8bit */ 20 | 21 | case MPG123_FEATURE_OUTPUT_16BIT: 22 | #ifdef NO_16BIT 23 | return 0; 24 | #else 25 | return 1; 26 | #endif /* mpg123_output_16bit */ 27 | 28 | case MPG123_FEATURE_OUTPUT_32BIT: 29 | #ifdef NO_32BIT 30 | return 0; 31 | #else 32 | return 1; 33 | #endif /* mpg123_output_32bit */ 34 | 35 | case MPG123_FEATURE_PARSE_ID3V2: 36 | #ifdef NO_ID3V2 37 | return 0; 38 | #else 39 | return 1; 40 | #endif /* NO_ID3V2 */ 41 | 42 | case MPG123_FEATURE_DECODE_LAYER1: 43 | #ifdef NO_LAYER1 44 | return 0; 45 | #else 46 | return 1; 47 | #endif /* NO_LAYER1 */ 48 | 49 | case MPG123_FEATURE_DECODE_LAYER2: 50 | #ifdef NO_LAYER2 51 | return 0; 52 | #else 53 | return 1; 54 | #endif /* NO_LAYER2 */ 55 | 56 | case MPG123_FEATURE_DECODE_LAYER3: 57 | #ifdef NO_LAYER3 58 | return 0; 59 | #else 60 | return 1; 61 | #endif /* NO_LAYER3 */ 62 | 63 | case MPG123_FEATURE_DECODE_ACCURATE: 64 | #ifdef ACCURATE_ROUNDING 65 | return 1; 66 | #else 67 | return 0; 68 | #endif /* ACCURATE_ROUNDING */ 69 | 70 | case MPG123_FEATURE_DECODE_DOWNSAMPLE: 71 | #ifdef NO_DOWNSAMPLE 72 | return 0; 73 | #else 74 | return 1; 75 | #endif /* NO_DOWNSAMPLE */ 76 | 77 | case MPG123_FEATURE_DECODE_NTOM: 78 | #ifdef NO_NTOM 79 | return 0; 80 | #else 81 | return 1; 82 | #endif /* NO_NTOM */ 83 | 84 | case MPG123_FEATURE_PARSE_ICY: 85 | #ifdef NO_ICY 86 | return 0; 87 | #else 88 | return 1; 89 | #endif /* NO_ICY */ 90 | 91 | case MPG123_FEATURE_INDEX: 92 | #ifdef FRAME_INDEX 93 | return 1; 94 | #else 95 | return 0; 96 | #endif /* FRAME_INDEX */ 97 | case MPG123_FEATURE_TIMEOUT_READ: 98 | #ifdef TIMEOUT_READ 99 | return 1; 100 | #else 101 | return 0; 102 | #endif 103 | 104 | default: return 0; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/getcpuflags.h: -------------------------------------------------------------------------------- 1 | /* 2 | getcpucpuflags: get cpuflags for ia32 3 | 4 | copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http:#mpg123.org 6 | initially written by KIMURA Takuhiro (for 3DNow!) 7 | extended for general use by Thomas Orgis 8 | */ 9 | 10 | #ifndef MPG123_H_GETCPUFLAGS 11 | #define MPG123_H_GETCPUFLAGS 12 | 13 | /* standard level flags part 1 (ECX)*/ 14 | #define FLAG_SSE3 0x00000001 15 | #define FLAG_SSSE3 0x00000200 16 | #define FLAG_AVX 0x1C000000 17 | /* standard level flags part 2 (EDX) */ 18 | #define FLAG2_MMX 0x00800000 19 | #define FLAG2_SSE 0x02000000 20 | #define FLAG2_SSE2 0x04000000 21 | #define FLAG2_FPU 0x00000001 22 | /* cpuid extended level 1 (AMD) */ 23 | #define XFLAG_MMX 0x00800000 24 | #define XFLAG_3DNOW 0x80000000 25 | #define XFLAG_3DNOWEXT 0x40000000 26 | /* eXtended Control Register 0 */ 27 | #define XCR0FLAG_AVX 0x00000006 28 | 29 | 30 | struct cpuflags 31 | { 32 | #if defined(OPT_ARM) || defined(OPT_NEON) || defined(OPT_NEON64) 33 | unsigned int has_neon; 34 | #else 35 | unsigned int id; 36 | unsigned int std; 37 | unsigned int std2; 38 | unsigned int ext; 39 | unsigned int xcr0_lo; 40 | #endif 41 | }; 42 | 43 | unsigned int getcpuflags(struct cpuflags* cf); 44 | 45 | /* checks the family */ 46 | #define cpu_i586(s) ( ((s.id & 0xf00)>>8) == 0 || ((s.id & 0xf00)>>8) > 4 ) 47 | /* checking some flags... */ 48 | #define cpu_fpu(s) (FLAG2_FPU & s.std2) 49 | #define cpu_mmx(s) (FLAG2_MMX & s.std2 || XFLAG_MMX & s.ext) 50 | #define cpu_3dnow(s) (XFLAG_3DNOW & s.ext) 51 | #define cpu_3dnowext(s) (XFLAG_3DNOWEXT & s.ext) 52 | #define cpu_sse(s) (FLAG2_SSE & s.std2) 53 | #define cpu_sse2(s) (FLAG2_SSE2 & s.std2) 54 | #define cpu_sse3(s) (FLAG_SSE3 & s.std) 55 | #define cpu_avx(s) ((FLAG_AVX & s.std) == FLAG_AVX && (XCR0FLAG_AVX & s.xcr0_lo) == XCR0FLAG_AVX) 56 | #define cpu_fast_sse(s) ((((s.id & 0xf00)>>8) == 6 && FLAG_SSSE3 & s.std) /* for Intel/VIA; family 6 CPUs with SSSE3 */ || \ 57 | (((s.id & 0xf00)>>8) == 0xf && (((s.id & 0x0ff00000)>>20) > 0 && ((s.id & 0x0ff00000)>>20) != 5))) /* for AMD; family > 0xF CPUs except Bobcat */ 58 | #define cpu_neon(s) (s.has_neon) 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_mono.h: -------------------------------------------------------------------------------- 1 | /* 2 | monosynth.h: generic mono related synth functions 3 | 4 | copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp, generalized by Thomas Orgis 7 | 8 | This header is used multiple times to create different variants of these functions. 9 | See decode.c and synth.h . 10 | Hint: BLOCK, MONO_NAME, MONO2STEREO_NAME, SYNTH_NAME and SAMPLE_T do vary. 11 | 12 | Thomas looked closely at the decode_1to1, decode_2to1 and decode_4to1 contents, seeing that they are too similar to be separate files. 13 | This is what resulted... 14 | 15 | Reason to separate this from synth.h: 16 | There are decoders that have a special synth_1to1 but still can use these generic derivations for the mono stuff. 17 | It generally makes a good deal of sense to set SYNTH_NAME to opt_synth_1to1(fr) (or opt_synth_2to1(fr), etc.). 18 | */ 19 | 20 | /* Mono synth, wrapping over SYNTH_NAME */ 21 | int MONO_NAME(real *bandPtr, mpg123_handle *fr) 22 | { 23 | SAMPLE_T samples_tmp[BLOCK]; 24 | SAMPLE_T *tmp1 = samples_tmp; 25 | int i,ret; 26 | 27 | /* save buffer stuff, trick samples_tmp into there, decode, restore */ 28 | unsigned char *samples = fr->buffer.data; 29 | int pnt = fr->buffer.fill; 30 | fr->buffer.data = (unsigned char*) samples_tmp; 31 | fr->buffer.fill = 0; 32 | ret = SYNTH_NAME(bandPtr, 0, fr, 0); /* decode into samples_tmp */ 33 | fr->buffer.data = samples; /* restore original value */ 34 | 35 | /* now append samples from samples_tmp */ 36 | samples += pnt; /* just the next mem in frame buffer */ 37 | for(i=0;i<(BLOCK/2);i++) 38 | { 39 | *( (SAMPLE_T *)samples) = *tmp1; 40 | samples += sizeof(SAMPLE_T); 41 | tmp1 += 2; 42 | } 43 | fr->buffer.fill = pnt + (BLOCK/2)*sizeof(SAMPLE_T); 44 | 45 | return ret; 46 | } 47 | 48 | /* Mono to stereo synth, wrapping over SYNTH_NAME */ 49 | int MONO2STEREO_NAME(real *bandPtr, mpg123_handle *fr) 50 | { 51 | int i,ret; 52 | unsigned char *samples = fr->buffer.data; 53 | 54 | ret = SYNTH_NAME(bandPtr,0,fr,1); 55 | samples += fr->buffer.fill - BLOCK*sizeof(SAMPLE_T); 56 | 57 | for(i=0;i<(BLOCK/2);i++) 58 | { 59 | ((SAMPLE_T *)samples)[1] = ((SAMPLE_T *)samples)[0]; 60 | samples+=2*sizeof(SAMPLE_T); 61 | } 62 | 63 | return ret; 64 | } 65 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/index.h: -------------------------------------------------------------------------------- 1 | #ifndef MPG123_H_INDEX 2 | #define MPG123_H_INDEX 3 | 4 | /* 5 | index: frame index data structure and functions 6 | 7 | This is for keeping track of frame positions for accurate seeking. 8 | Now in it's own file, with initial code from frame.c and parse.c . 9 | 10 | The idea of the index with a certain amount of entries is to cover 11 | all yet-encountered frame positions with minimal coarseness. 12 | Meaning: At first every frame position is recorded, then, when 13 | the index is full, every second position is trown away to make 14 | space. Next time it is full, the same happens. And so on. 15 | In this manner we maintain a good resolution with the given 16 | maximum index size while covering the whole stream. 17 | 18 | copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1 19 | see COPYING and AUTHORS files in distribution or http://mpg123.org 20 | initially written by Thomas Orgis 21 | */ 22 | 23 | #include "config.h" 24 | #include "compat.h" 25 | 26 | struct frame_index 27 | { 28 | off_t *data; /* actual data, the frame positions */ 29 | off_t step; /* advancement in frame number per index point */ 30 | off_t next; /* frame offset supposed to come next into the index */ 31 | size_t size; /* total number of possible entries */ 32 | size_t fill; /* number of used entries */ 33 | size_t grow_size; /* if > 0: index allowed to grow on need with these steps, instead of lowering resolution */ 34 | }; 35 | 36 | /* The condition for a framenum to be appended to the index. 37 | if(FI_NEXT(fr->index, fr->num)) fi_add(offset); */ 38 | #define FI_NEXT(fi, framenum) ((fi).size && framenum == (fi).next) 39 | 40 | /* Initialize stuff, set things to zero and NULL... */ 41 | void fi_init(struct frame_index *fi); 42 | /* Deallocate/zero things. */ 43 | void fi_exit(struct frame_index *fi); 44 | 45 | /* Prepare a given size, preserving current fill, if possible. 46 | If the new size is smaller than fill, the entry density is reduced. 47 | Return 0 on success. */ 48 | int fi_resize(struct frame_index *fi, size_t newsize); 49 | 50 | /* Append a frame position, reducing index density if needed. */ 51 | void fi_add(struct frame_index *fi, off_t pos); 52 | 53 | /* Replace the frame index */ 54 | int fi_set(struct frame_index *fi, off_t *offsets, off_t step, size_t fill); 55 | 56 | /* Empty the index (setting fill=0 and step=1), but keep current size. */ 57 | void fi_reset(struct frame_index *fi); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/window.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: window functions 15 | 16 | ********************************************************************/ 17 | 18 | #include 19 | #include 20 | #include "misc.h" 21 | #include "window.h" 22 | #include "window_lookup.h" 23 | 24 | const void *_vorbis_window(int type, int left){ 25 | 26 | switch(type){ 27 | case 0: 28 | 29 | switch(left){ 30 | case 32: 31 | return vwin64; 32 | case 64: 33 | return vwin128; 34 | case 128: 35 | return vwin256; 36 | case 256: 37 | return vwin512; 38 | case 512: 39 | return vwin1024; 40 | case 1024: 41 | return vwin2048; 42 | case 2048: 43 | return vwin4096; 44 | case 4096: 45 | return vwin8192; 46 | default: 47 | return(0); 48 | } 49 | break; 50 | default: 51 | return(0); 52 | } 53 | } 54 | 55 | void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2], 56 | long *blocksizes, 57 | int lW,int W,int nW){ 58 | 59 | LOOKUP_T *window[2]={window_p[0],window_p[1]}; 60 | long n=blocksizes[W]; 61 | long ln=blocksizes[lW]; 62 | long rn=blocksizes[nW]; 63 | 64 | long leftbegin=n/4-ln/4; 65 | long leftend=leftbegin+ln/2; 66 | 67 | long rightbegin=n/2+n/4-rn/4; 68 | long rightend=rightbegin+rn/2; 69 | 70 | int i,p; 71 | 72 | for(i=0;ibuffer.data; 20 | int pnt = fr->buffer.fill; 21 | fr->buffer.data = (unsigned char*) samples_tmp; 22 | fr->buffer.fill = 0; 23 | ret = BASE_SYNTH_NAME(bandPtr, channel, fr , 0); 24 | fr->buffer.data = samples; 25 | 26 | samples += channel + pnt; 27 | for(i=0;i<(BLOCK/2);i++) 28 | { 29 | *samples = fr->conv16to8[*tmp1>>AUSHIFT]; 30 | samples += 2; 31 | tmp1 += 2; 32 | } 33 | fr->buffer.fill = pnt + (final ? BLOCK : 0 ); 34 | 35 | return ret; 36 | } 37 | 38 | int MONO_NAME(real *bandPtr, mpg123_handle *fr) 39 | { 40 | short samples_tmp[BLOCK]; 41 | short *tmp1 = samples_tmp; 42 | int i,ret; 43 | 44 | unsigned char *samples = fr->buffer.data; 45 | int pnt = fr->buffer.fill; 46 | fr->buffer.data = (unsigned char*) samples_tmp; 47 | fr->buffer.fill = 0; 48 | ret = BASE_SYNTH_NAME(bandPtr, 0, fr, 0); 49 | fr->buffer.data = samples; 50 | 51 | samples += pnt; 52 | for(i=0;i<(BLOCK/2);i++) 53 | { 54 | *samples++ = fr->conv16to8[*tmp1>>AUSHIFT]; 55 | tmp1+=2; 56 | } 57 | fr->buffer.fill = pnt + BLOCK/2; 58 | 59 | return ret; 60 | } 61 | 62 | int MONO2STEREO_NAME(real *bandPtr, mpg123_handle *fr) 63 | { 64 | short samples_tmp[BLOCK]; 65 | short *tmp1 = samples_tmp; 66 | int i,ret; 67 | 68 | unsigned char *samples = fr->buffer.data; 69 | int pnt = fr->buffer.fill; 70 | fr->buffer.data = (unsigned char*) samples_tmp; 71 | fr->buffer.fill = 0; 72 | ret = BASE_SYNTH_NAME(bandPtr, 0, fr, 0); 73 | fr->buffer.data = samples; 74 | 75 | samples += pnt; 76 | for(i=0;i<(BLOCK/2);i++) 77 | { 78 | *samples++ = fr->conv16to8[*tmp1>>AUSHIFT]; 79 | *samples++ = fr->conv16to8[*tmp1>>AUSHIFT]; 80 | tmp1 += 2; 81 | } 82 | fr->buffer.fill = pnt + BLOCK; 83 | 84 | return ret; 85 | } 86 | 87 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /mp3decoders/src/main/java/com/axelby/mp3decoders/StreamFeeder.java: -------------------------------------------------------------------------------- 1 | package com.axelby.mp3decoders; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.File; 6 | import java.io.FileNotFoundException; 7 | import java.io.IOException; 8 | import java.io.RandomAccessFile; 9 | import java.util.ArrayList; 10 | 11 | /** 12 | * pipes data from a file to the decoder 13 | */ 14 | public class StreamFeeder { 15 | final String _filename; 16 | final IMediaDecoder _decoder; 17 | 18 | Thread _feederThread = null; 19 | long _fileOffset = 0; 20 | 21 | private static ArrayList _doneFiles = new ArrayList<>(2); 22 | public static void doneStreamingFile(String filename) { if (!_doneFiles.contains(filename)) _doneFiles.add(filename); } 23 | public static void clearDoneFiles() { _doneFiles.clear(); } 24 | public static boolean isFileDone(String filename) { return _doneFiles.contains(filename); } 25 | 26 | public StreamFeeder(String filename, IMediaDecoder decoder) throws FileNotFoundException { 27 | this(filename, decoder, 0); 28 | } 29 | 30 | public StreamFeeder(String filename, IMediaDecoder decoder, long initialOffset) throws FileNotFoundException { 31 | _filename = filename; 32 | _decoder = decoder; 33 | _fileOffset = initialOffset; 34 | _feederThread = new Thread(_feederRunnable, "feeder"); 35 | _feederThread.start(); 36 | } 37 | 38 | public String getFilename() { return _filename; } 39 | 40 | public void finish() { 41 | _feederThread.interrupt(); 42 | try { 43 | _feederThread.join(); 44 | } catch (InterruptedException ignored) {} 45 | } 46 | 47 | Runnable _feederRunnable = new Runnable() { 48 | @Override 49 | public void run() { 50 | RandomAccessFile file = null; 51 | try { 52 | // make sure the file exists 53 | if (!new File(_filename).exists()) { 54 | Thread.sleep(50); 55 | } 56 | file = new RandomAccessFile(_filename, "r"); 57 | 58 | file.seek(_fileOffset); 59 | while (file.getFilePointer() != _fileOffset) 60 | Thread.sleep(50); 61 | 62 | while (true) { 63 | // read the available bytes from the file and feed them to the mp3 decoder 64 | long length = file.length(); 65 | int size = (int) (length - file.getFilePointer()); 66 | if (size == 0 && _doneFiles.contains(_filename)) 67 | break; 68 | if (size == 0) { 69 | Thread.sleep(50); 70 | continue; 71 | } 72 | 73 | byte[] c = new byte[size]; 74 | int read = file.read(c); 75 | if (read > 0) 76 | _decoder.feed(c, read); 77 | 78 | Thread.sleep(50); 79 | } 80 | 81 | _decoder.completeStream(); 82 | } catch (IOException e) { 83 | Log.e("mp3decoders", "unable to feed decoder", e); 84 | } catch (InterruptedException ignored) { 85 | } finally { 86 | try { 87 | if (file != null) 88 | file.close(); 89 | } catch (IOException e) { 90 | Log.e("mp3decoders", "unable to close feed decoder file", e); 91 | } 92 | } 93 | } 94 | }; 95 | } 96 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/getcpuflags.S: -------------------------------------------------------------------------------- 1 | /* 2 | getcpucpuflags: get cpuflags for ia32 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http:#mpg123.org 6 | initially written by KIMURA Takuhiro (for 3DNow!) 7 | extended for general use by Thomas Orgis 8 | 9 | extern int getcpuid(struct cpuflags*) 10 | or just 11 | extern int getcpuid(unsigned int*) 12 | where there is memory for 4 ints 13 | -> the first set of idflags (basic cpu family info) 14 | and the idflags, stdflags, std2flags, extflags written to the parameter 15 | -> 0x00000000 (CPUID instruction not supported) 16 | */ 17 | 18 | #include "mangle.h" 19 | 20 | .text 21 | ALIGN4 22 | 23 | .globl ASM_NAME(getcpuflags) 24 | /* .type ASM_NAME(getcpuflags),@function */ 25 | ASM_NAME(getcpuflags): 26 | pushl %ebp 27 | movl %esp,%ebp 28 | pushl %edx 29 | pushl %ecx 30 | pushl %ebx 31 | pushl %esi 32 | /* get the int pointer for storing the flags */ 33 | movl 8(%ebp), %esi 34 | /* does that one make sense? */ 35 | movl $0x80000000,%eax 36 | /* now save the flags and do a check for cpuid availability */ 37 | pushfl 38 | pushfl 39 | popl %eax 40 | movl %eax,%ebx 41 | /* set that bit... */ 42 | xorl $0x00200000,%eax 43 | pushl %eax 44 | popfl 45 | /* ...and read back the flags to see if it is understood */ 46 | pushfl 47 | popl %eax 48 | popfl 49 | cmpl %ebx,%eax 50 | je .Lnocpuid 51 | /* In principle, I would have to check the CPU's identify first to be sure how to interpret the extended flags. */ 52 | /* now get the info, first extended */ 53 | movl $0x0, 12(%esi) /* clear value */ 54 | movl $0x0, 16(%esi) /* clear value */ 55 | /* only if supported... */ 56 | movl $0x80000000, %eax 57 | cpuid 58 | /* IDT CPUs should not change EAX, generally I hope that non-3DNow cpus do not set a bogus support level here. */ 59 | cmpl $0x80000001, %eax 60 | jb .Lnoextended /* Skip ext check without minimal support level. */ 61 | /* is supported, get flags value */ 62 | movl $0x80000001,%eax 63 | cpuid 64 | movl %edx,12(%esi) 65 | .Lnoextended: 66 | /* then the other ones, called last to get the id flags in %eax for ret */ 67 | movl $0x00000001,%eax 68 | cpuid 69 | movl %eax, (%esi) 70 | movl %ecx, 4(%esi) 71 | movl %edx, 8(%esi) 72 | /* check if xgetbv instruction is available */ 73 | test $0x04000000, %ecx 74 | jz .Lend 75 | test $0x08000000, %ecx 76 | jz .Lend 77 | xor %ecx, %ecx 78 | .byte 0x0f, 0x01, 0xd0 /* xgetbv instruction */ 79 | movl %eax, 16(%esi) 80 | movl (%esi), %eax 81 | jmp .Lend 82 | ALIGN4 83 | .Lnocpuid: 84 | /* error: set everything to zero */ 85 | movl $0, %eax 86 | movl $0, (%esi) 87 | movl $0, 4(%esi) 88 | movl $0, 8(%esi) 89 | movl $0, 12(%esi) 90 | movl $0, 16(%esi) 91 | ALIGN4 92 | .Lend: 93 | /* return value are the id flags, still stored in %eax */ 94 | popl %esi 95 | popl %ebx 96 | popl %ecx 97 | popl %edx 98 | movl %ebp,%esp 99 | popl %ebp 100 | ret 101 | 102 | NONEXEC_STACK 103 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/getbits.h: -------------------------------------------------------------------------------- 1 | /* 2 | getbits 3 | 4 | copyright ?-2009 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp 7 | 8 | All code is in the header to suggest/force inlining of these small often-used functions. 9 | This indeed has some impact on performance. 10 | */ 11 | 12 | #ifndef _MPG123_GETBITS_H_ 13 | #define _MPG123_GETBITS_H_ 14 | 15 | #include "mpg123lib_intern.h" 16 | 17 | #define backbits(fr,nob) ((void)( \ 18 | fr->bitindex -= nob, \ 19 | fr->wordpointer += (fr->bitindex>>3), \ 20 | fr->bitindex &= 0x7 )) 21 | 22 | #define getbitoffset(fr) ((-fr->bitindex)&0x7) 23 | #define getbyte(fr) (*fr->wordpointer++) 24 | 25 | /* There is something wrong with that macro... the function below works also for the layer1 test case. */ 26 | #define macro_getbits(fr, nob) ( \ 27 | fr->ultmp = fr->wordpointer[0],\ 28 | fr->ultmp <<= 8, \ 29 | fr->ultmp |= fr->wordpointer[1], \ 30 | fr->ultmp <<= 8, \ 31 | fr->ultmp |= fr->wordpointer[2], \ 32 | fr->ultmp <<= fr->bitindex, \ 33 | fr->ultmp &= 0xffffff, \ 34 | fr->bitindex += nob, \ 35 | fr->ultmp >>= (24-nob), \ 36 | fr->wordpointer += (fr->bitindex>>3), \ 37 | fr->bitindex &= 7, \ 38 | fr->ultmp) 39 | 40 | static unsigned int getbits(mpg123_handle *fr, int number_of_bits) 41 | { 42 | unsigned long rval; 43 | 44 | #ifdef DEBUG_GETBITS 45 | fprintf(stderr,"g%d",number_of_bits); 46 | #endif 47 | 48 | /* This is actually slow: if(!number_of_bits) 49 | return 0; */ 50 | 51 | #if 0 52 | check_buffer_range(number_of_bits+fr->bitindex); 53 | #endif 54 | 55 | { 56 | rval = fr->wordpointer[0]; 57 | rval <<= 8; 58 | rval |= fr->wordpointer[1]; 59 | rval <<= 8; 60 | rval |= fr->wordpointer[2]; 61 | 62 | rval <<= fr->bitindex; 63 | rval &= 0xffffff; 64 | 65 | fr->bitindex += number_of_bits; 66 | 67 | rval >>= (24-number_of_bits); 68 | 69 | fr->wordpointer += (fr->bitindex>>3); 70 | fr->bitindex &= 7; 71 | } 72 | 73 | #ifdef DEBUG_GETBITS 74 | fprintf(stderr,":%lx\n",rval); 75 | #endif 76 | 77 | return rval; 78 | } 79 | 80 | 81 | #define skipbits(fr, nob) fr->ultmp = ( \ 82 | fr->ultmp = fr->wordpointer[0], fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[1], \ 83 | fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[2], fr->ultmp <<= fr->bitindex, \ 84 | fr->ultmp &= 0xffffff, fr->bitindex += nob, \ 85 | fr->ultmp >>= (24-nob), fr->wordpointer += (fr->bitindex>>3), \ 86 | fr->bitindex &= 7 ) 87 | 88 | #define getbits_fast(fr, nob) ( \ 89 | fr->ultmp = (unsigned char) (fr->wordpointer[0] << fr->bitindex), \ 90 | fr->ultmp |= ((unsigned long) fr->wordpointer[1]<bitindex)>>8, \ 91 | fr->ultmp <<= nob, fr->ultmp >>= 8, \ 92 | fr->bitindex += nob, fr->wordpointer += (fr->bitindex>>3), \ 93 | fr->bitindex &= 7, fr->ultmp ) 94 | 95 | #define get1bit(fr) ( \ 96 | fr->uctmp = *fr->wordpointer << fr->bitindex, fr->bitindex++, \ 97 | fr->wordpointer += (fr->bitindex>>3), fr->bitindex &= 7, fr->uctmp>>7 ) 98 | 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /mp3decoders/src/main/java/com/axelby/mp3decoders/WSOLA.java: -------------------------------------------------------------------------------- 1 | package com.axelby.mp3decoders; 2 | 3 | // Slamnig Audio Utilities project 4 | // Created: 2014/05/18 D.Slamnig 5 | 6 | public class WSOLA 7 | { 8 | public static class Error { 9 | public static final int SUCCESS = 0; 10 | public static final int ERR_INVALIDPARAMS = -1; 11 | public static final int ERR_ALLOC = -2; 12 | 13 | public int code; 14 | 15 | public String toString(){ 16 | switch(code){ 17 | case 0: 18 | return "Success"; 19 | case -1: 20 | return "Invalid parameters"; 21 | case -2: 22 | return "Allocation error"; 23 | } 24 | return "Unknown error"; 25 | } 26 | } 27 | 28 | public WSOLA() { 29 | // initialize NDK part: 30 | init(); 31 | } 32 | 33 | // wsolaStretch 34 | // 35 | // Checks parameters, allocates the output buffer and calls the NDK: 36 | // 37 | // Parameters: 38 | // ----------- 39 | // short[] audioBuffer - 16-bit input PCM audio data, stereo or mono. 40 | // If stereo, has to be frame bounded. One stereo frame is 2 shorts, L and R channel. 41 | // int sampleRate - Input sample rate in samples/second. 42 | // boolean stereo - Stereo flag. 43 | // float speedRatio - Output playback speed multiplier. 44 | // int quality - WSOLA processing quality. Less is better, 1 is best. Maximum is about 50 for 44.1 kHz. 45 | // SlautError err - err.code is returned error code, or SUCCESS. 46 | // 47 | // Returns: 48 | // -------- 49 | // On success, returns a short array with time-stretched audio data. The length of the output array is input length / speedRatio. 50 | // On failure, returns null. The err parameter holds error information. 51 | // 52 | public short[] stretch(short[] audioBuffer, int sampleRate, boolean stereo, float speedRatio, int quality, Error err) { 53 | short[] stretchBuffer; 54 | int plainSize; 55 | int stretchSize; 56 | int errCode; 57 | 58 | if (audioBuffer == null 59 | || (plainSize = audioBuffer.length) == 0 60 | || sampleRate <= 0 61 | || speedRatio <= 0.0f) { 62 | if (err != null) 63 | err.code = Error.ERR_INVALIDPARAMS; 64 | return null; 65 | } 66 | 67 | if (quality < 1) 68 | quality = 1; 69 | 70 | stretchSize = (int)Math.floor((float)plainSize / speedRatio + 0.5f); 71 | 72 | if (stereo) 73 | stretchSize = (stretchSize / 2) * 2; 74 | 75 | if ((stretchBuffer = new short[stretchSize]) == null) { 76 | if (err != null) 77 | err.code = Error.ERR_ALLOC; 78 | return null; 79 | } 80 | 81 | errCode = wsolaStretchJNI(audioBuffer, stretchBuffer, sampleRate, stereo, speedRatio, quality); 82 | 83 | if (errCode != Error.SUCCESS) 84 | stretchBuffer = null; 85 | 86 | if (err != null) 87 | err.code = errCode; 88 | 89 | return stretchBuffer; 90 | } 91 | 92 | // Initalizes the NDK part: 93 | public native void init(); 94 | // Frees NDK allocated buffers - call when done using the library: 95 | public native void close(); 96 | 97 | // NDK WSOLA time-stretch function: 98 | private native int wsolaStretchJNI(short[] plainBuffer, short[] stretchBuffer, 99 | int sampleRate, boolean stereo, float speedRatio, int quality); 100 | 101 | static { 102 | System.loadLibrary("wsola"); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_C_INCLUDES := $(LOCAL_PATH) 5 | LOCAL_MODULE := mpg123 6 | LOCAL_ARM_MODE := arm 7 | LOCAL_LDLIBS := -llog 8 | 9 | LOCAL_SRC_FILES := podax_MPG123.c 10 | LOCAL_SRC_FILES += libmpg123.c 11 | LOCAL_SRC_FILES += compat.c 12 | LOCAL_SRC_FILES += frame.c 13 | LOCAL_SRC_FILES += id3.c 14 | LOCAL_SRC_FILES += format.c 15 | LOCAL_SRC_FILES += stringbuf.c 16 | LOCAL_SRC_FILES += readers.c 17 | LOCAL_SRC_FILES += icy.c icy2utf8.c 18 | LOCAL_SRC_FILES += index.c 19 | LOCAL_SRC_FILES += layer1.c layer2.c layer3.c 20 | LOCAL_SRC_FILES += parse.c 21 | LOCAL_SRC_FILES += optimize.c 22 | LOCAL_SRC_FILES += synth.c synth_8bit.c 23 | LOCAL_SRC_FILES += ntom.c 24 | LOCAL_SRC_FILES += dct64.c 25 | LOCAL_SRC_FILES += equalizer.c 26 | LOCAL_SRC_FILES += tabinit.c 27 | LOCAL_SRC_FILES += feature.c 28 | 29 | ifeq ($(TARGET_ARCH_ABI),armeabi) 30 | LOCAL_CFLAGS := -DACCURATE_ROUNDING \ 31 | -DOPT_ARM \ 32 | -DREAL_IS_FIXED \ 33 | -DNO_REAL \ 34 | -DNO_32BIT \ 35 | -DHAVE_STRERROR \ 36 | -DASMALIGN_BYTE \ 37 | -Wno-int-to-pointer-cast \ 38 | -Wno-pointer-to-int-cast \ 39 | -ffast-math -O3 40 | LOCAL_SRC_FILES += synth_arm.S synth_arm_accurate.S 41 | endif 42 | 43 | ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 44 | #LOCAL_CFLAGS := -DACCURATE_ROUNDING \ 45 | # -DOPT_NEON \ 46 | # -DHAVE_STRERROR \ 47 | # -Wno-int-to-pointer-cast \ 48 | # -Wno-pointer-to-int-cast \ 49 | # -ffast-math -O3 50 | #LOCAL_SRC_FILES += synth_real.c synth_s32.c 51 | #LOCAL_SRC_FILES += synth_neon.S synth_neon_accurate.S synth_neon_float.S synth_neon_s32.S 52 | #LOCAL_SRC_FILES += dct36_neon.S dct64_neon_float.S synth_stereo_neon_accurate.S synth_stereo_neon_float.S synth_stereo_neon_s32.S 53 | LOCAL_CFLAGS := -DACCURATE_ROUNDING \ 54 | -DOPT_ARM \ 55 | -DREAL_IS_FIXED \ 56 | -DNO_REAL \ 57 | -DNO_32BIT \ 58 | -DHAVE_STRERROR \ 59 | -DASMALIGN_BYTE \ 60 | -Wno-int-to-pointer-cast \ 61 | -Wno-pointer-to-int-cast \ 62 | -ffast-math -O3 63 | LOCAL_SRC_FILES += synth_arm.S synth_arm_accurate.S 64 | endif 65 | 66 | ifeq ($(TARGET_ARCH_ABI),x86) 67 | LOCAL_CFLAGS := -DACCURATE_ROUNDING \ 68 | -DHAVE_STRERROR \ 69 | -DOPT_SSE \ 70 | -Wno-int-to-pointer-cast \ 71 | -Wno-pointer-to-int-cast \ 72 | -ffast-math -O3 73 | LOCAL_SRC_FILES += synth_real.c synth_s32.c 74 | LOCAL_SRC_FILES += synth_sse.S synth_sse_accurate.S synth_sse_float.S synth_sse_s32.S 75 | LOCAL_SRC_FILES += synth_stereo_sse_accurate.S synth_stereo_sse_float.S synth_stereo_sse_s32.S 76 | LOCAL_SRC_FILES += dct64_i386.c dct36_sse.S dct64_sse.S dct64_sse_float.S 77 | LOCAL_SRC_FILES += tabinit_mmx.S 78 | endif 79 | 80 | ifeq ($(TARGET_ARCH_ABI),x86_64) 81 | LOCAL_CFLAGS := -DACCURATE_ROUNDING \ 82 | -DHAVE_STRERROR \ 83 | -DOPT_X86_64 \ 84 | -Wno-int-to-pointer-cast \ 85 | -Wno-pointer-to-int-cast \ 86 | -ffast-math -O3 87 | LOCAL_SRC_FILES += synth_real.c synth_s32.c 88 | LOCAL_SRC_FILES += getcpuflags_x86_64.S 89 | LOCAL_SRC_FILES += synth_x86_64.S synth_x86_64_s32.S synth_x86_64_accurate.S synth_x86_64_float.S 90 | LOCAL_SRC_FILES += synth_stereo_x86_64_float.S synth_stereo_x86_64.S synth_stereo_x86_64_s32.S synth_stereo_x86_64_accurate.S 91 | LOCAL_SRC_FILES += dct36_x86_64.S dct64_x86_64.S dct64_x86_64_float.S 92 | endif 93 | 94 | 95 | include $(BUILD_SHARED_LIBRARY) 96 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_neon64_float.S: -------------------------------------------------------------------------------- 1 | /* 2 | synth_neon64_float: NEON optimized synth for AArch64 (float output version) 3 | 4 | copyright 1995-2014 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Monma 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | #ifndef __APPLE__ 12 | .section .rodata 13 | #else 14 | .data 15 | #endif 16 | ALIGN16 17 | scale: 18 | .word 939524096 19 | .text 20 | ALIGN4 21 | .globl ASM_NAME(synth_1to1_real_neon64_asm) 22 | #ifdef __ELF__ 23 | .type ASM_NAME(synth_1to1_real_neon64_asm), %function 24 | #endif 25 | ASM_NAME(synth_1to1_real_neon64_asm): 26 | add x0, x0, #64 27 | sub x0, x0, x3, lsl #2 28 | adrp x5, AARCH64_PCREL_HI(scale) 29 | add x5, x5, AARCH64_PCREL_LO(scale) 30 | ld1r {v28.4s}, [x5] 31 | 32 | mov w4, #4 33 | mov x5, #128 34 | 1: 35 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 36 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 37 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], #64 38 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], #64 39 | 40 | fmul v24.4s, v0.4s, v16.4s 41 | fmul v25.4s, v4.4s, v20.4s 42 | fmla v24.4s, v1.4s, v17.4s 43 | fmla v25.4s, v5.4s, v21.4s 44 | fmla v24.4s, v2.4s, v18.4s 45 | fmla v25.4s, v6.4s, v22.4s 46 | fmla v24.4s, v3.4s, v19.4s 47 | fmla v25.4s, v7.4s, v23.4s 48 | 49 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 50 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 51 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], #64 52 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], #64 53 | 54 | fmul v26.4s, v0.4s, v16.4s 55 | fmul v27.4s, v4.4s, v20.4s 56 | fmla v26.4s, v1.4s, v17.4s 57 | fmla v27.4s, v5.4s, v21.4s 58 | fmla v26.4s, v2.4s, v18.4s 59 | fmla v27.4s, v6.4s, v22.4s 60 | fmla v26.4s, v3.4s, v19.4s 61 | fmla v27.4s, v7.4s, v23.4s 62 | 63 | faddp v0.4s, v24.4s, v25.4s 64 | faddp v1.4s, v26.4s, v27.4s 65 | faddp v0.4s, v0.4s, v1.4s 66 | ld2 {v4.4s,v5.4s}, [x2] 67 | fmul v4.4s, v0.4s, v28.4s 68 | st2 {v4.4s,v5.4s}, [x2], #32 69 | 70 | subs w4, w4, #1 71 | b.ne 1b 72 | 73 | mov w4, #4 74 | mov x6, #-64 75 | 2: 76 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 77 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 78 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], x6 79 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], x6 80 | 81 | fmul v24.4s, v0.4s, v16.4s 82 | fmul v25.4s, v4.4s, v20.4s 83 | fmla v24.4s, v1.4s, v17.4s 84 | fmla v25.4s, v5.4s, v21.4s 85 | fmla v24.4s, v2.4s, v18.4s 86 | fmla v25.4s, v6.4s, v22.4s 87 | fmla v24.4s, v3.4s, v19.4s 88 | fmla v25.4s, v7.4s, v23.4s 89 | 90 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 91 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 92 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], x6 93 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], x6 94 | 95 | fmul v26.4s, v0.4s, v16.4s 96 | fmul v27.4s, v4.4s, v20.4s 97 | fmla v26.4s, v1.4s, v17.4s 98 | fmla v27.4s, v5.4s, v21.4s 99 | fmla v26.4s, v2.4s, v18.4s 100 | fmla v27.4s, v6.4s, v22.4s 101 | fmla v26.4s, v3.4s, v19.4s 102 | fmla v27.4s, v7.4s, v23.4s 103 | 104 | faddp v0.4s, v24.4s, v25.4s 105 | faddp v1.4s, v26.4s, v27.4s 106 | faddp v0.4s, v0.4s, v1.4s 107 | ld2 {v4.4s,v5.4s}, [x2] 108 | fmul v4.4s, v0.4s, v28.4s 109 | st2 {v4.4s,v5.4s}, [x2], #32 110 | 111 | subs w4, w4, #1 112 | b.ne 2b 113 | 114 | eor w0, w0, w0 115 | 116 | ret 117 | 118 | NONEXEC_STACK 119 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/codec_internal.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: libvorbis codec headers 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_CODECI_H_ 19 | #define _V_CODECI_H_ 20 | 21 | #include "codebook.h" 22 | 23 | typedef void vorbis_look_mapping; 24 | typedef void vorbis_look_floor; 25 | typedef void vorbis_look_residue; 26 | typedef void vorbis_look_transform; 27 | 28 | /* mode ************************************************************/ 29 | typedef struct { 30 | int blockflag; 31 | int windowtype; 32 | int transformtype; 33 | int mapping; 34 | } vorbis_info_mode; 35 | 36 | typedef void vorbis_info_floor; 37 | typedef void vorbis_info_residue; 38 | typedef void vorbis_info_mapping; 39 | 40 | typedef struct private_state { 41 | /* local lookup storage */ 42 | const void *window[2]; 43 | 44 | /* backend lookups are tied to the mode, not the backend or naked mapping */ 45 | int modebits; 46 | vorbis_look_mapping **mode; 47 | 48 | ogg_int64_t sample_count; 49 | 50 | } private_state; 51 | 52 | /* codec_setup_info contains all the setup information specific to the 53 | specific compression/decompression mode in progress (eg, 54 | psychoacoustic settings, channel setup, options, codebook 55 | etc). 56 | *********************************************************************/ 57 | 58 | typedef struct codec_setup_info { 59 | 60 | /* Vorbis supports only short and long blocks, but allows the 61 | encoder to choose the sizes */ 62 | 63 | long blocksizes[2]; 64 | 65 | /* modes are the primary means of supporting on-the-fly different 66 | blocksizes, different channel mappings (LR or M/A), 67 | different residue backends, etc. Each mode consists of a 68 | blocksize flag and a mapping (along with the mapping setup */ 69 | 70 | int modes; 71 | int maps; 72 | int times; 73 | int floors; 74 | int residues; 75 | int books; 76 | 77 | vorbis_info_mode *mode_param[64]; 78 | int map_type[64]; 79 | vorbis_info_mapping *map_param[64]; 80 | int time_type[64]; 81 | int floor_type[64]; 82 | vorbis_info_floor *floor_param[64]; 83 | int residue_type[64]; 84 | vorbis_info_residue *residue_param[64]; 85 | static_codebook *book_param[256]; 86 | codebook *fullbooks; 87 | 88 | int passlimit[32]; /* iteration limit per couple/quant pass */ 89 | int coupling_passes; 90 | } codec_setup_info; 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_neon.S: -------------------------------------------------------------------------------- 1 | /* 2 | synth_neon: ARM NEON optimized synth 3 | 4 | copyright 1995-2010 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Monma 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | #define WINDOW r0 12 | #define B0 r1 13 | #define SAMPLES r2 14 | 15 | /* 16 | int synth_1to1_neon_asm(short *window, short *b0, short *samples, int bo1); 17 | return value: number of clipped samples 18 | */ 19 | 20 | .code 32 21 | #ifndef __APPLE__ 22 | .fpu neon 23 | #endif 24 | 25 | .text 26 | .globl ASM_NAME(synth_1to1_neon_asm) 27 | #ifdef __ELF__ 28 | .type ASM_NAME(synth_1to1_neon_asm), %function 29 | #endif 30 | ALIGN4 31 | ASM_NAME(synth_1to1_neon_asm): 32 | push {r4-r5, lr} 33 | vpush {q4-q7} 34 | 35 | add WINDOW, WINDOW, #32 36 | sub WINDOW, WINDOW, r3, lsl #1 37 | 38 | mov r3, #4 39 | mov r4, #64 40 | 1: 41 | vld1.16 {d0-d3}, [WINDOW], r4 42 | vld1.16 {d4-d7}, [B0, :128]! 43 | vld1.16 {d8-d11}, [WINDOW], r4 44 | vswp d1, d4 45 | vld1.16 {d12-d15}, [B0, :128]! 46 | vld1.16 {d16-d19}, [WINDOW], r4 47 | vld1.16 {d20-d23}, [B0, :128]! 48 | vswp d9, d12 49 | vld1.16 {d24-d27}, [WINDOW], r4 50 | vld1.16 {d28-d31}, [B0, :128]! 51 | vswp d17, d20 52 | vswp d25, d28 53 | vmull.s16 q0, d0, d1 54 | vmull.s16 q4, d8, d9 55 | vmull.s16 q8, d16, d17 56 | vmull.s16 q12, d24, d25 57 | vmlal.s16 q0, d4, d5 58 | vmlal.s16 q4, d12, d13 59 | vmlal.s16 q8, d20, d21 60 | vmlal.s16 q12, d28, d29 61 | vmlal.s16 q0, d2, d6 62 | vmlal.s16 q4, d10, d14 63 | vmlal.s16 q8, d18, d22 64 | vmlal.s16 q12, d26, d30 65 | vmlal.s16 q0, d3, d7 66 | vmlal.s16 q4, d11, d15 67 | vmlal.s16 q8, d19, d23 68 | vmlal.s16 q12, d27, d31 69 | vpadd.i32 d0, d0, d1 70 | vpadd.i32 d8, d8, d9 71 | vpadd.i32 d16, d16, d17 72 | vpadd.i32 d24, d24, d25 73 | vpadd.i32 d0, d0, d8 74 | vpadd.i32 d1, d16, d24 75 | 76 | vld2.16 {d2,d3}, [SAMPLES] 77 | vqrshrn.s32 d1, q0, #13 78 | vst2.16 {d1,d3}, [SAMPLES]! 79 | 80 | subs r3, r3, #1 81 | bne 1b 82 | 83 | mov r3, #4 84 | mov r5, #-32 85 | 1: 86 | vld1.16 {d0-d3}, [WINDOW], r4 87 | vld1.16 {d4-d7}, [B0, :128], r5 88 | vld1.16 {d8-d11}, [WINDOW], r4 89 | vswp d1, d4 90 | vld1.16 {d12-d15}, [B0, :128], r5 91 | vld1.16 {d16-d19}, [WINDOW], r4 92 | vld1.16 {d20-d23}, [B0, :128], r5 93 | vswp d9, d12 94 | vld1.16 {d24-d27}, [WINDOW], r4 95 | vld1.16 {d28-d31}, [B0, :128], r5 96 | vswp d17, d20 97 | vswp d25, d28 98 | vmull.s16 q0, d0, d1 99 | vmull.s16 q4, d8, d9 100 | vmull.s16 q8, d16, d17 101 | vmull.s16 q12, d24, d25 102 | vmlal.s16 q0, d4, d5 103 | vmlal.s16 q4, d12, d13 104 | vmlal.s16 q8, d20, d21 105 | vmlal.s16 q12, d28, d29 106 | vmlal.s16 q0, d2, d6 107 | vmlal.s16 q4, d10, d14 108 | vmlal.s16 q8, d18, d22 109 | vmlal.s16 q12, d26, d30 110 | vmlal.s16 q0, d3, d7 111 | vmlal.s16 q4, d11, d15 112 | vmlal.s16 q8, d19, d23 113 | vmlal.s16 q12, d27, d31 114 | vpadd.i32 d0, d0, d1 115 | vpadd.i32 d8, d8, d9 116 | vpadd.i32 d16, d16, d17 117 | vpadd.i32 d24, d24, d25 118 | vpadd.i32 d0, d0, d8 119 | vpadd.i32 d1, d16, d24 120 | 121 | vld2.16 {d2,d3}, [SAMPLES] 122 | vqrshrn.s32 d1, q0, #13 123 | vst2.16 {d1,d3}, [SAMPLES]! 124 | 125 | subs r3, r3, #1 126 | bne 1b 127 | 128 | mov r0, #0 129 | 130 | vpop {q4-q7} 131 | pop {r4-r5, pc} 132 | 133 | NONEXEC_STACK 134 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_neon64.S: -------------------------------------------------------------------------------- 1 | /* 2 | synth_neon64: NEON optimized synth for AArch64 3 | 4 | copyright 1995-2014 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Monma 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | #ifndef __APPLE__ 12 | .section .rodata 13 | #else 14 | .data 15 | #endif 16 | ALIGN16 17 | maxmin_s16: 18 | .word 32767 19 | .word -32768 20 | .text 21 | ALIGN4 22 | .globl ASM_NAME(synth_1to1_neon64_asm) 23 | #ifdef __ELF__ 24 | .type ASM_NAME(synth_1to1_neon64_asm), %function 25 | #endif 26 | ASM_NAME(synth_1to1_neon64_asm): 27 | add x0, x0, #32 28 | sub x0, x0, x3, lsl #1 29 | eor v31.16b, v31.16b, v31.16b 30 | adrp x5, AARCH64_PCREL_HI(maxmin_s16) 31 | add x5, x5, AARCH64_PCREL_LO(maxmin_s16) 32 | ld2r {v28.4s,v29.4s}, [x5] 33 | 34 | mov w4, #4 35 | mov x5, #64 36 | 1: 37 | ld1 {v0.8h,v1.8h}, [x0], x5 38 | ld1 {v2.8h,v3.8h}, [x0], x5 39 | ld1 {v4.8h,v5.8h}, [x0], x5 40 | ld1 {v6.8h,v7.8h}, [x0], x5 41 | ld1 {v16.8h,v17.8h,v18.8h,v19.8h}, [x1], #64 42 | ld1 {v20.8h,v21.8h,v22.8h,v23.8h}, [x1], #64 43 | 44 | smull v24.4s, v0.4h, v16.4h 45 | smull v25.4s, v2.4h, v18.4h 46 | smull v26.4s, v4.4h, v20.4h 47 | smull v27.4s, v6.4h, v22.4h 48 | smlal2 v24.4s, v0.8h, v16.8h 49 | smlal2 v25.4s, v2.8h, v18.8h 50 | smlal2 v26.4s, v4.8h, v20.8h 51 | smlal2 v27.4s, v6.8h, v22.8h 52 | smlal v24.4s, v1.4h, v17.4h 53 | smlal v25.4s, v3.4h, v19.4h 54 | smlal v26.4s, v5.4h, v21.4h 55 | smlal v27.4s, v7.4h, v23.4h 56 | smlal2 v24.4s, v1.8h, v17.8h 57 | smlal2 v25.4s, v3.8h, v19.8h 58 | smlal2 v26.4s, v5.8h, v21.8h 59 | smlal2 v27.4s, v7.8h, v23.8h 60 | 61 | addp v0.4s, v24.4s, v25.4s 62 | addp v1.4s, v26.4s, v27.4s 63 | addp v0.4s, v0.4s, v1.4s 64 | ld2 {v4.4h,v5.4h}, [x2] 65 | sqrshrn v4.4h, v0.4s, #13 66 | cmgt v2.4s, v0.4s, v28.4s 67 | cmgt v3.4s, v29.4s, v0.4s 68 | add v2.4s, v2.4s, v3.4s 69 | add v31.4s, v31.4s, v2.4s 70 | st2 {v4.4h,v5.4h}, [x2], #16 71 | 72 | subs w4, w4, #1 73 | b.ne 1b 74 | 75 | mov w4, #4 76 | mov x6, #-32 77 | 2: 78 | ld1 {v0.8h,v1.8h}, [x0], x5 79 | ld1 {v2.8h,v3.8h}, [x0], x5 80 | ld1 {v4.8h,v5.8h}, [x0], x5 81 | ld1 {v6.8h,v7.8h}, [x0], x5 82 | ld1 {v16.8h,v17.8h}, [x1], x6 83 | ld1 {v18.8h,v19.8h}, [x1], x6 84 | ld1 {v20.8h,v21.8h}, [x1], x6 85 | ld1 {v22.8h,v23.8h}, [x1], x6 86 | 87 | smull v24.4s, v0.4h, v16.4h 88 | smull v25.4s, v2.4h, v18.4h 89 | smull v26.4s, v4.4h, v20.4h 90 | smull v27.4s, v6.4h, v22.4h 91 | smlal2 v24.4s, v0.8h, v16.8h 92 | smlal2 v25.4s, v2.8h, v18.8h 93 | smlal2 v26.4s, v4.8h, v20.8h 94 | smlal2 v27.4s, v6.8h, v22.8h 95 | smlal v24.4s, v1.4h, v17.4h 96 | smlal v25.4s, v3.4h, v19.4h 97 | smlal v26.4s, v5.4h, v21.4h 98 | smlal v27.4s, v7.4h, v23.4h 99 | smlal2 v24.4s, v1.8h, v17.8h 100 | smlal2 v25.4s, v3.8h, v19.8h 101 | smlal2 v26.4s, v5.8h, v21.8h 102 | smlal2 v27.4s, v7.8h, v23.8h 103 | 104 | addp v0.4s, v24.4s, v25.4s 105 | addp v1.4s, v26.4s, v27.4s 106 | addp v0.4s, v0.4s, v1.4s 107 | ld2 {v4.4h,v5.4h}, [x2] 108 | sqrshrn v4.4h, v0.4s, #13 109 | cmgt v2.4s, v0.4s, v28.4s 110 | cmgt v3.4s, v29.4s, v0.4s 111 | add v2.4s, v2.4s, v3.4s 112 | add v31.4s, v31.4s, v2.4s 113 | st2 {v4.4h,v5.4h}, [x2], #16 114 | 115 | subs w4, w4, #1 116 | b.ne 2b 117 | 118 | AARCH64_DUP_2D(v0, v31, 1) 119 | add v0.4s, v0.4s, v31.4s 120 | AARCH64_DUP_4S(v1, v0, 1) 121 | add v0.4s, v0.4s, v1.4s 122 | umov w0, v0.s[0] 123 | neg w0, w0 124 | 125 | ret 126 | 127 | NONEXEC_STACK 128 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/dither.c: -------------------------------------------------------------------------------- 1 | /* 2 | dither: Generate shaped noise for dithering 3 | 4 | copyright 2009 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Monma 7 | */ 8 | 9 | #include "config.h" 10 | #include "compat.h" 11 | #include "dither.h" 12 | 13 | static const uint32_t init_seed = 2463534242UL; 14 | 15 | #define LAP 100 16 | 17 | /* 18 | xorshift random number generator, with output scaling to [-0.5, 0.5] 19 | This is the white noise... 20 | See http://www.jstatsoft.org/v08/i14/paper on XOR shift random number generators. 21 | */ 22 | static float rand_xorshift32(uint32_t *seed) 23 | { 24 | union 25 | { 26 | uint32_t i; 27 | float f; 28 | } fi; 29 | 30 | fi.i = *seed; 31 | fi.i ^= (fi.i<<13); 32 | fi.i ^= (fi.i>>17); 33 | fi.i ^= (fi.i<<5); 34 | *seed = fi.i; 35 | 36 | /* scale the number to [-0.5, 0.5] */ 37 | #ifdef IEEE_FLOAT 38 | fi.i = (fi.i>>9)|0x3f800000; 39 | fi.f -= 1.5f; 40 | #else 41 | fi.f = (double)fi.i / 4294967295.0; 42 | fi.f -= 0.5f; 43 | #endif 44 | return fi.f; 45 | } 46 | 47 | static void white_noise(float *table, size_t count) 48 | { 49 | size_t i; 50 | uint32_t seed = init_seed; 51 | 52 | for(i=0; i 2*LAP ? LAP : count/2; 71 | 72 | float input_noise; 73 | float xv[9], yv[9]; 74 | 75 | for(i=0;i<9;i++) 76 | { 77 | xv[i] = yv[i] = 0.0f; 78 | } 79 | 80 | for(i=0;i=lap) table[i-lap] = yv[8] * 3.0f; 100 | } 101 | } 102 | 103 | void mpg123_noise(float* table, size_t count, enum mpg123_noise_type noisetype) 104 | { 105 | switch(noisetype) 106 | { 107 | case mpg123_white_noise: white_noise(table, count); break; 108 | case mpg123_tpdf_noise: tpdf_noise(table, count); break; 109 | case mpg123_highpass_tpdf_noise: 110 | highpass_tpdf_noise(table, count); 111 | break; 112 | } 113 | } 114 | 115 | /* Generate white noise and shape it with a high pass filter. */ 116 | void dither_table_init(float *dithertable) 117 | { 118 | highpass_tpdf_noise(dithertable, DITHERSIZE); 119 | } 120 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_mmx.S: -------------------------------------------------------------------------------- 1 | /* 2 | decode_MMX.s: MMX optimized synth 3 | 4 | copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by the mysterious higway (apparently) 7 | 8 | Thomas' words about a note: 9 | Initially, I found the note "this code comes under GPL" in this file. 10 | After asking Michael about legal status of the MMX files, he said that he got them without any comment and thus I believe that the GPL comment was made by Michael, since he made mpg123 GPL at some time - and marked some files that way, but not all. 11 | Based on that thought, I now consider this file along with the other parts of higway's MMX optimization to be licensed under LGPL 2.1 by Michael's decision. 12 | */ 13 | 14 | #include "mangle.h" 15 | 16 | .text 17 | 18 | .globl ASM_NAME(synth_1to1_MMX) 19 | /* int synth_1to1_MMX(real *bandPtr, int channel, short *out, short *buffs, int *bo, float *decwins); */ 20 | ASM_NAME(synth_1to1_MMX): 21 | pushl %ebp 22 | pushl %edi 23 | pushl %esi 24 | pushl %ebx 25 | /* stack: 0=ebx, 4=esi, 8=edi, 12=ebp, 16=back, 20=bandPtr, 24=channel, 28=out, 32=buffs, 36=bo, 40=decwins */ 26 | movl 24(%esp),%ecx 27 | movl 28(%esp),%edi 28 | movl $15,%ebx 29 | movl 36(%esp),%edx 30 | leal (%edi,%ecx,2),%edi 31 | decl %ecx 32 | movl 32(%esp),%esi 33 | movl (%edx),%eax 34 | jecxz 1f 35 | decl %eax 36 | andl %ebx,%eax 37 | leal 1088(%esi),%esi 38 | movl %eax,(%edx) 39 | 1: 40 | leal (%esi,%eax,2),%edx 41 | movl %eax,%ebp 42 | incl %eax 43 | pushl 20(%esp) 44 | andl %ebx,%eax 45 | leal 544(%esi,%eax,2),%ecx 46 | incl %ebx 47 | testl $1, %eax 48 | jnz 2f 49 | xchgl %edx,%ecx 50 | incl %ebp 51 | leal 544(%esi),%esi 52 | 2: 53 | pushl %edx 54 | pushl %ecx 55 | call ASM_NAME(dct64_MMX) 56 | addl $12,%esp 57 | /* stack like before, pushed 3, incremented again */ 58 | leal 1(%ebx), %ecx 59 | subl %ebp,%ebx 60 | pushl %eax 61 | movl 44(%esp),%eax /* decwins */ 62 | leal (%eax,%ebx,2), %edx 63 | popl %eax 64 | 3: 65 | movq (%edx),%mm0 66 | pmaddwd (%esi),%mm0 67 | movq 8(%edx),%mm1 68 | pmaddwd 8(%esi),%mm1 69 | movq 16(%edx),%mm2 70 | pmaddwd 16(%esi),%mm2 71 | movq 24(%edx),%mm3 72 | pmaddwd 24(%esi),%mm3 73 | paddd %mm1,%mm0 74 | paddd %mm2,%mm0 75 | paddd %mm3,%mm0 76 | movq %mm0,%mm1 77 | psrlq $32,%mm1 78 | paddd %mm1,%mm0 79 | psrad $13,%mm0 80 | packssdw %mm0,%mm0 81 | movd %mm0,%eax 82 | movw %ax, (%edi) 83 | 84 | leal 32(%esi),%esi 85 | leal 64(%edx),%edx 86 | leal 4(%edi),%edi 87 | loop 3b 88 | 89 | 90 | subl $64,%esi 91 | movl $15,%ecx 92 | 4: 93 | movq (%edx),%mm0 94 | pmaddwd (%esi),%mm0 95 | movq 8(%edx),%mm1 96 | pmaddwd 8(%esi),%mm1 97 | movq 16(%edx),%mm2 98 | pmaddwd 16(%esi),%mm2 99 | movq 24(%edx),%mm3 100 | pmaddwd 24(%esi),%mm3 101 | paddd %mm1,%mm0 102 | paddd %mm2,%mm0 103 | paddd %mm3,%mm0 104 | movq %mm0,%mm1 105 | psrlq $32,%mm1 106 | paddd %mm0,%mm1 107 | psrad $13,%mm1 108 | packssdw %mm1,%mm1 109 | psubd %mm0,%mm0 110 | psubsw %mm1,%mm0 111 | movd %mm0,%eax 112 | movw %ax,(%edi) 113 | 114 | subl $32,%esi 115 | addl $64,%edx 116 | leal 4(%edi),%edi 117 | loop 4b 118 | emms 119 | popl %ebx 120 | popl %esi 121 | popl %edi 122 | popl %ebp 123 | ret 124 | 125 | NONEXEC_STACK 126 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/mangle.h: -------------------------------------------------------------------------------- 1 | /* 2 | mangle: support defines for preprocessed assembler 3 | 4 | copyright 1995-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | 7 | This once started out as mangle.h from MPlayer, but you can't really call it derived work... the small part that in principle stems from MPlayer also being not very special (once you decided to use such a header at all, it's quite obvious material). 8 | */ 9 | 10 | #ifndef __MANGLE_H 11 | #define __MANGLE_H 12 | 13 | #include "config.h" 14 | #include "intsym.h" 15 | 16 | #ifdef CCALIGN 17 | #define MOVUAPS movaps 18 | #else 19 | #define MOVUAPS movups 20 | #endif 21 | 22 | /* 23 | ALIGNX: align to X bytes 24 | This differs per compiler/platform in taking the byte count or an exponent for base 2. 25 | A way out is balign, if the assembler supports it (gas extension). 26 | */ 27 | 28 | #ifdef ASMALIGN_BALIGN 29 | 30 | #define ALIGN4 .balign 4 31 | #define ALIGN8 .balign 8 32 | #define ALIGN16 .balign 16 33 | #define ALIGN32 .balign 32 34 | #define ALIGN64 .balign 64 35 | 36 | #else 37 | 38 | #ifdef ASMALIGN_EXP 39 | #define ALIGN4 .align 2 40 | #define ALIGN8 .align 3 41 | #define ALIGN16 .align 4 42 | #define ALIGN32 .align 5 43 | #define ALIGN64 .align 6 44 | #else 45 | #ifdef ASMALIGN_BYTE 46 | #define ALIGN4 .align 4 47 | #define ALIGN8 .align 8 48 | #define ALIGN16 .align 16 49 | #define ALIGN32 .align 32 50 | #define ALIGN64 .align 64 51 | #else 52 | #error "Dunno how assembler alignment works. Please specify." 53 | #endif 54 | #endif 55 | 56 | #endif 57 | 58 | #define MANGLE_MACROCAT_REALLY(a, b) a ## b 59 | #define MANGLE_MACROCAT(a, b) MANGLE_MACROCAT_REALLY(a, b) 60 | /* Feel free to add more to the list, eg. a.out IMO */ 61 | #if defined(__USER_LABEL_PREFIX__) 62 | #define ASM_NAME(a) MANGLE_MACROCAT(__USER_LABEL_PREFIX__,a) 63 | #define ASM_VALUE(a) MANGLE_MACROCAT($,ASM_NAME(a)) 64 | #elif defined(__CYGWIN__) || defined(_WIN32) && !defined (_WIN64) || defined(__OS2__) || \ 65 | (defined(__OpenBSD__) && !defined(__ELF__)) || defined(__APPLE__) 66 | #define ASM_NAME(a) MANGLE_MACROCAT(_,a) 67 | #define ASM_VALUE(a) MANGLE_MACROCAT($_,a) 68 | #else 69 | #define ASM_NAME(a) a 70 | #define ASM_VALUE(a) MANGLE_MACROCAT($,a) 71 | #endif 72 | 73 | #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__) 74 | #define COMM(a,b,c) .comm a,b 75 | #else 76 | #define COMM(a,b,c) .comm a,b,c 77 | #endif 78 | /* more hacks for macosx; no .bss ... */ 79 | #ifdef __APPLE__ 80 | #define BSS .data 81 | #else 82 | #define BSS .bss 83 | #endif 84 | 85 | /* Mark non-executable stack. 86 | It's mainly for GNU on Linux... who else does (not) like this? */ 87 | #if !defined(__SUNPRO_C) && defined(__linux__) && defined(__ELF__) 88 | #if defined(__arm__) 89 | #define NONEXEC_STACK .section .note.GNU-stack,"",%progbits 90 | #else 91 | #define NONEXEC_STACK .section .note.GNU-stack,"",@progbits 92 | #endif 93 | #else 94 | #define NONEXEC_STACK 95 | #endif 96 | 97 | #if defined(__x86_64__) && (defined(_WIN64) || defined (__CYGWIN__)) 98 | #define IS_MSABI 1 /* Not using SYSV */ 99 | #endif 100 | 101 | /* Macros for +-4GiB PC-relative addressing on AArch64 */ 102 | #ifdef __APPLE__ 103 | #define AARCH64_PCREL_HI(label) label@PAGE 104 | #define AARCH64_PCREL_LO(label) label@PAGEOFF 105 | #else 106 | #define AARCH64_PCREL_HI(label) label 107 | #define AARCH64_PCREL_LO(label) :lo12:label 108 | #endif 109 | 110 | #ifdef __APPLE__ 111 | #define AARCH64_DUP_4S(dst, src, elem) dup.4s dst, src[elem] 112 | #define AARCH64_DUP_2D(dst, src, elem) dup.2d dst, src[elem] 113 | #define AARCH64_SQXTN2_8H(dst, src) sqxtn2.8h dst, src 114 | #else 115 | #define AARCH64_DUP_4S(dst, src, elem) dup dst.4s, src.s[elem] 116 | #define AARCH64_DUP_2D(dst, src, elem) dup dst.2d, src.d[elem] 117 | #define AARCH64_SQXTN2_8H(dst, src) sqxtn2 dst.8h, src.4s 118 | #endif 119 | 120 | #endif /* !__MANGLE_H */ 121 | 122 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_neon64_accurate.S: -------------------------------------------------------------------------------- 1 | /* 2 | synth_neon64_accurate: NEON optimized synth for AArch64 (MPEG compliant 16-bit output version) 3 | 4 | copyright 1995-2014 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Monma 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | #ifndef __APPLE__ 12 | .section .rodata 13 | #else 14 | .data 15 | #endif 16 | ALIGN16 17 | maxmin_s16: 18 | .word 1191181824 19 | .word -956301312 20 | .text 21 | ALIGN4 22 | .globl ASM_NAME(synth_1to1_neon64_accurate_asm) 23 | #ifdef __ELF__ 24 | .type ASM_NAME(synth_1to1_neon64_accurate_asm), %function 25 | #endif 26 | ASM_NAME(synth_1to1_neon64_accurate_asm): 27 | add x0, x0, #64 28 | sub x0, x0, x3, lsl #2 29 | eor v31.16b, v31.16b, v31.16b 30 | adrp x5, AARCH64_PCREL_HI(maxmin_s16) 31 | add x5, x5, AARCH64_PCREL_LO(maxmin_s16) 32 | ld2r {v28.4s,v29.4s}, [x5] 33 | 34 | mov w4, #4 35 | mov x5, #128 36 | 1: 37 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 38 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 39 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], #64 40 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], #64 41 | 42 | fmul v24.4s, v0.4s, v16.4s 43 | fmul v25.4s, v4.4s, v20.4s 44 | fmla v24.4s, v1.4s, v17.4s 45 | fmla v25.4s, v5.4s, v21.4s 46 | fmla v24.4s, v2.4s, v18.4s 47 | fmla v25.4s, v6.4s, v22.4s 48 | fmla v24.4s, v3.4s, v19.4s 49 | fmla v25.4s, v7.4s, v23.4s 50 | 51 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 52 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 53 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], #64 54 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], #64 55 | 56 | fmul v26.4s, v0.4s, v16.4s 57 | fmul v27.4s, v4.4s, v20.4s 58 | fmla v26.4s, v1.4s, v17.4s 59 | fmla v27.4s, v5.4s, v21.4s 60 | fmla v26.4s, v2.4s, v18.4s 61 | fmla v27.4s, v6.4s, v22.4s 62 | fmla v26.4s, v3.4s, v19.4s 63 | fmla v27.4s, v7.4s, v23.4s 64 | 65 | faddp v0.4s, v24.4s, v25.4s 66 | faddp v1.4s, v26.4s, v27.4s 67 | faddp v0.4s, v0.4s, v1.4s 68 | ld2 {v4.4h,v5.4h}, [x2] 69 | fcvtns v1.4s, v0.4s 70 | fcmgt v2.4s, v0.4s, v28.4s 71 | fcmgt v3.4s, v29.4s, v0.4s 72 | sqxtn v4.4h, v1.4s 73 | add v2.4s, v2.4s, v3.4s 74 | add v31.4s, v31.4s, v2.4s 75 | st2 {v4.4h,v5.4h}, [x2], #16 76 | 77 | subs w4, w4, #1 78 | b.ne 1b 79 | 80 | mov w4, #4 81 | mov x6, #-64 82 | 2: 83 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 84 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 85 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], x6 86 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], x6 87 | 88 | fmul v24.4s, v0.4s, v16.4s 89 | fmul v25.4s, v4.4s, v20.4s 90 | fmla v24.4s, v1.4s, v17.4s 91 | fmla v25.4s, v5.4s, v21.4s 92 | fmla v24.4s, v2.4s, v18.4s 93 | fmla v25.4s, v6.4s, v22.4s 94 | fmla v24.4s, v3.4s, v19.4s 95 | fmla v25.4s, v7.4s, v23.4s 96 | 97 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 98 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 99 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], x6 100 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], x6 101 | 102 | fmul v26.4s, v0.4s, v16.4s 103 | fmul v27.4s, v4.4s, v20.4s 104 | fmla v26.4s, v1.4s, v17.4s 105 | fmla v27.4s, v5.4s, v21.4s 106 | fmla v26.4s, v2.4s, v18.4s 107 | fmla v27.4s, v6.4s, v22.4s 108 | fmla v26.4s, v3.4s, v19.4s 109 | fmla v27.4s, v7.4s, v23.4s 110 | 111 | faddp v0.4s, v24.4s, v25.4s 112 | faddp v1.4s, v26.4s, v27.4s 113 | faddp v0.4s, v0.4s, v1.4s 114 | ld2 {v4.4h,v5.4h}, [x2] 115 | fcvtns v1.4s, v0.4s 116 | fcmgt v2.4s, v0.4s, v28.4s 117 | fcmgt v3.4s, v29.4s, v0.4s 118 | sqxtn v4.4h, v1.4s 119 | add v2.4s, v2.4s, v3.4s 120 | add v31.4s, v31.4s, v2.4s 121 | st2 {v4.4h,v5.4h}, [x2], #16 122 | 123 | subs w4, w4, #1 124 | b.ne 2b 125 | 126 | AARCH64_DUP_2D(v0, v31, 1) 127 | add v0.4s, v0.4s, v31.4s 128 | AARCH64_DUP_4S(v1, v0, 1) 129 | add v0.4s, v0.4s, v1.4s 130 | umov w0, v0.s[0] 131 | neg w0, w0 132 | 133 | ret 134 | 135 | NONEXEC_STACK 136 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_neon64_s32.S: -------------------------------------------------------------------------------- 1 | /* 2 | synth_neon64_s32: NEON optimized synth for AArch64 (32-bit output version) 3 | 4 | copyright 1995-2014 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Monma 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | #ifndef __APPLE__ 12 | .section .rodata 13 | #else 14 | .data 15 | #endif 16 | ALIGN16 17 | maxmin_s32: 18 | .word 1191182335 19 | .word -956301312 20 | .word 1199570944 21 | .text 22 | ALIGN4 23 | .globl ASM_NAME(synth_1to1_s32_neon64_asm) 24 | #ifdef __ELF__ 25 | .type ASM_NAME(synth_1to1_s32_neon64_asm), %function 26 | #endif 27 | ASM_NAME(synth_1to1_s32_neon64_asm): 28 | add x0, x0, #64 29 | sub x0, x0, x3, lsl #2 30 | eor v31.16b, v31.16b, v31.16b 31 | adrp x5, AARCH64_PCREL_HI(maxmin_s32) 32 | add x5, x5, AARCH64_PCREL_LO(maxmin_s32) 33 | ld3r {v28.4s,v29.4s,v30.4s}, [x5] 34 | 35 | mov w4, #4 36 | mov x5, #128 37 | 1: 38 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 39 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 40 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], #64 41 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], #64 42 | 43 | fmul v24.4s, v0.4s, v16.4s 44 | fmul v25.4s, v4.4s, v20.4s 45 | fmla v24.4s, v1.4s, v17.4s 46 | fmla v25.4s, v5.4s, v21.4s 47 | fmla v24.4s, v2.4s, v18.4s 48 | fmla v25.4s, v6.4s, v22.4s 49 | fmla v24.4s, v3.4s, v19.4s 50 | fmla v25.4s, v7.4s, v23.4s 51 | 52 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 53 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 54 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], #64 55 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], #64 56 | 57 | fmul v26.4s, v0.4s, v16.4s 58 | fmul v27.4s, v4.4s, v20.4s 59 | fmla v26.4s, v1.4s, v17.4s 60 | fmla v27.4s, v5.4s, v21.4s 61 | fmla v26.4s, v2.4s, v18.4s 62 | fmla v27.4s, v6.4s, v22.4s 63 | fmla v26.4s, v3.4s, v19.4s 64 | fmla v27.4s, v7.4s, v23.4s 65 | 66 | faddp v0.4s, v24.4s, v25.4s 67 | faddp v1.4s, v26.4s, v27.4s 68 | faddp v0.4s, v0.4s, v1.4s 69 | fmul v1.4s, v0.4s, v30.4s 70 | ld2 {v4.4s,v5.4s}, [x2] 71 | fcvtns v4.4s, v1.4s 72 | fcmgt v2.4s, v0.4s, v28.4s 73 | fcmgt v3.4s, v29.4s, v0.4s 74 | add v2.4s, v2.4s, v3.4s 75 | add v31.4s, v31.4s, v2.4s 76 | st2 {v4.4s,v5.4s}, [x2], #32 77 | 78 | subs w4, w4, #1 79 | b.ne 1b 80 | 81 | mov w4, #4 82 | mov x6, #-64 83 | 2: 84 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 85 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 86 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], x6 87 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], x6 88 | 89 | fmul v24.4s, v0.4s, v16.4s 90 | fmul v25.4s, v4.4s, v20.4s 91 | fmla v24.4s, v1.4s, v17.4s 92 | fmla v25.4s, v5.4s, v21.4s 93 | fmla v24.4s, v2.4s, v18.4s 94 | fmla v25.4s, v6.4s, v22.4s 95 | fmla v24.4s, v3.4s, v19.4s 96 | fmla v25.4s, v7.4s, v23.4s 97 | 98 | ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x0], x5 99 | ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x0], x5 100 | ld1 {v16.4s,v17.4s,v18.4s,v19.4s}, [x1], x6 101 | ld1 {v20.4s,v21.4s,v22.4s,v23.4s}, [x1], x6 102 | 103 | fmul v26.4s, v0.4s, v16.4s 104 | fmul v27.4s, v4.4s, v20.4s 105 | fmla v26.4s, v1.4s, v17.4s 106 | fmla v27.4s, v5.4s, v21.4s 107 | fmla v26.4s, v2.4s, v18.4s 108 | fmla v27.4s, v6.4s, v22.4s 109 | fmla v26.4s, v3.4s, v19.4s 110 | fmla v27.4s, v7.4s, v23.4s 111 | 112 | faddp v0.4s, v24.4s, v25.4s 113 | faddp v1.4s, v26.4s, v27.4s 114 | faddp v0.4s, v0.4s, v1.4s 115 | fmul v1.4s, v0.4s, v30.4s 116 | ld2 {v4.4s,v5.4s}, [x2] 117 | fcvtns v4.4s, v1.4s 118 | fcmgt v2.4s, v0.4s, v28.4s 119 | fcmgt v3.4s, v29.4s, v0.4s 120 | add v2.4s, v2.4s, v3.4s 121 | add v31.4s, v31.4s, v2.4s 122 | st2 {v4.4s,v5.4s}, [x2], #32 123 | 124 | subs w4, w4, #1 125 | b.ne 2b 126 | 127 | AARCH64_DUP_2D(v0, v31, 1) 128 | add v0.4s, v0.4s, v31.4s 129 | AARCH64_DUP_4S(v1, v0, 1) 130 | add v0.4s, v0.4s, v1.4s 131 | umov w0, v0.s[0] 132 | neg w0, w0 133 | 134 | ret 135 | 136 | NONEXEC_STACK 137 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/mpeghead.h: -------------------------------------------------------------------------------- 1 | /* 2 | mpeghead: the bits of an MPEG frame header 3 | 4 | copyright ?-2011 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp & Thomas Orgis (from parse.c) 7 | */ 8 | #ifndef MPG123_MPEGHEAD_H 9 | #define MPG123_MPEGHEAD_H 10 | 11 | /* 12 | Avoid human error, let perl do the work of dissecting an MPEG header into parts. 13 | To be clear: Never edit the following definitions by hand, modify the code block inside this comment and run it through perl instead! 14 | 15 | $head = "AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM"; 16 | %parts = qw(A sync B version C layer D crc E bitrate F samplerate G padding H private I channel J chanex K copyright L original M emphasis); 17 | for(sort keys %parts) 18 | { 19 | $name = uc($parts{$_}); 20 | $bits = $head; 21 | $bits =~ s/$_/1/g; 22 | $bits =~ s/[^1 ]/0/g; 23 | print "\/\* $bits \*\/\n"; 24 | $bits =~ s/\s//g; 25 | print "#define HDR_$name".(" " x (18-length($name))).sprintf("0x%08x", eval("0b$bits"))."\n"; 26 | $bits =~ m/(0*)$/; 27 | print "#define HDR_${name}_VAL(h)".(" " x (11-length($name)))."(((h)\&HDR_$name) >> ".length($1).")\n"; 28 | } 29 | */ 30 | 31 | /* 11111111 11100000 00000000 00000000 */ 32 | #define HDR_SYNC 0xffe00000 33 | #define HDR_SYNC_VAL(h) (((h)&HDR_SYNC) >> 21) 34 | /* 00000000 00011000 00000000 00000000 */ 35 | #define HDR_VERSION 0x00180000 36 | #define HDR_VERSION_VAL(h) (((h)&HDR_VERSION) >> 19) 37 | /* 00000000 00000110 00000000 00000000 */ 38 | #define HDR_LAYER 0x00060000 39 | #define HDR_LAYER_VAL(h) (((h)&HDR_LAYER) >> 17) 40 | /* 00000000 00000001 00000000 00000000 */ 41 | #define HDR_CRC 0x00010000 42 | #define HDR_CRC_VAL(h) (((h)&HDR_CRC) >> 16) 43 | /* 00000000 00000000 11110000 00000000 */ 44 | #define HDR_BITRATE 0x0000f000 45 | #define HDR_BITRATE_VAL(h) (((h)&HDR_BITRATE) >> 12) 46 | /* 00000000 00000000 00001100 00000000 */ 47 | #define HDR_SAMPLERATE 0x00000c00 48 | #define HDR_SAMPLERATE_VAL(h) (((h)&HDR_SAMPLERATE) >> 10) 49 | /* 00000000 00000000 00000010 00000000 */ 50 | #define HDR_PADDING 0x00000200 51 | #define HDR_PADDING_VAL(h) (((h)&HDR_PADDING) >> 9) 52 | /* 00000000 00000000 00000001 00000000 */ 53 | #define HDR_PRIVATE 0x00000100 54 | #define HDR_PRIVATE_VAL(h) (((h)&HDR_PRIVATE) >> 8) 55 | /* 00000000 00000000 00000000 11000000 */ 56 | #define HDR_CHANNEL 0x000000c0 57 | #define HDR_CHANNEL_VAL(h) (((h)&HDR_CHANNEL) >> 6) 58 | /* 00000000 00000000 00000000 00110000 */ 59 | #define HDR_CHANEX 0x00000030 60 | #define HDR_CHANEX_VAL(h) (((h)&HDR_CHANEX) >> 4) 61 | /* 00000000 00000000 00000000 00001000 */ 62 | #define HDR_COPYRIGHT 0x00000008 63 | #define HDR_COPYRIGHT_VAL(h) (((h)&HDR_COPYRIGHT) >> 3) 64 | /* 00000000 00000000 00000000 00000100 */ 65 | #define HDR_ORIGINAL 0x00000004 66 | #define HDR_ORIGINAL_VAL(h) (((h)&HDR_ORIGINAL) >> 2) 67 | /* 00000000 00000000 00000000 00000011 */ 68 | #define HDR_EMPHASIS 0x00000003 69 | #define HDR_EMPHASIS_VAL(h) (((h)&HDR_EMPHASIS) >> 0) 70 | 71 | /* 72 | A generic mask for telling if a header is somewhat valid for the current stream. 73 | Meaning: Most basic info is not allowed to change. 74 | Checking of channel count needs to be done, too, though. So, 75 | if channel count matches, frames are decoded the same way: frame buffers and decoding 76 | routines can stay the same, especially frame buffers (think spf * channels!). 77 | */ 78 | #define HDR_CMPMASK (HDR_SYNC|HDR_VERSION|HDR_LAYER|HDR_SAMPLERATE) 79 | 80 | /* A stricter mask, for matching free format headers. */ 81 | #define HDR_SAMEMASK (HDR_SYNC|HDR_VERSION|HDR_LAYER|HDR_BITRATE|HDR_SAMPLERATE|HDR_CHANNEL|HDR_CHANEX) 82 | 83 | /* Free format headers have zero bitrate value. */ 84 | #define HDR_FREE_FORMAT(head) (!(head & HDR_BITRATE)) 85 | 86 | /* A mask for changed sampling rate (version or rate bits). */ 87 | #define HDR_SAMPMASK (HDR_VERSION|HDR_SAMPLERATE) 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run this to set up the build system: configure, makefiles, etc. 3 | # (based on the version in enlightenment's cvs) 4 | 5 | package="vorbisdec" 6 | 7 | olddir=`pwd` 8 | srcdir=`dirname $0` 9 | test -z "$srcdir" && srcdir=. 10 | 11 | cd "$srcdir" 12 | DIE=0 13 | 14 | echo "checking for autoconf... " 15 | (autoconf --version) < /dev/null > /dev/null 2>&1 || { 16 | echo 17 | echo "You must have autoconf installed to compile $package." 18 | echo "Download the appropriate package for your distribution," 19 | echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" 20 | DIE=1 21 | } 22 | 23 | VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9]\.[0-9]\).*/\1/" 24 | VERSIONMKINT="sed -e s/[^0-9]//" 25 | 26 | # do we need automake? 27 | if test -r Makefile.am; then 28 | AM_OPTIONS=`fgrep AUTOMAKE_OPTIONS Makefile.am` 29 | AM_NEEDED=`echo $AM_OPTIONS | $VERSIONGREP` 30 | if test x"$AM_NEEDED" = "x$AM_OPTIONS"; then 31 | AM_NEEDED="" 32 | fi 33 | if test -z $AM_NEEDED; then 34 | echo -n "checking for automake... " 35 | AUTOMAKE=automake 36 | ACLOCAL=aclocal 37 | if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then 38 | echo "yes" 39 | else 40 | echo "no" 41 | AUTOMAKE= 42 | fi 43 | else 44 | echo -n "checking for automake $AM_NEEDED or later... " 45 | for am in automake-$AM_NEEDED automake$AM_NEEDED automake; do 46 | ($am --version < /dev/null > /dev/null 2>&1) || continue 47 | ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT` 48 | verneeded=`echo $AM_NEEDED | $VERSIONMKINT` 49 | if test $ver -ge $verneeded; then 50 | AUTOMAKE=$am 51 | echo $AUTOMAKE 52 | break 53 | fi 54 | done 55 | test -z $AUTOMAKE && echo "no" 56 | echo -n "checking for aclocal $AM_NEEDED or later... " 57 | for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED aclocal; do 58 | ($ac --version < /dev/null > /dev/null 2>&1) || continue 59 | ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT` 60 | verneeded=`echo $AM_NEEDED | $VERSIONMKINT` 61 | if test $ver -ge $verneeded; then 62 | ACLOCAL=$ac 63 | echo $ACLOCAL 64 | break 65 | fi 66 | done 67 | test -z $ACLOCAL && echo "no" 68 | fi 69 | test -z $AUTOMAKE || test -z $ACLOCAL && { 70 | echo 71 | echo "You must have automake installed to compile $package." 72 | echo "Download the appropriate package for your distribution," 73 | echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" 74 | exit 1 75 | } 76 | fi 77 | 78 | echo -n "checking for libtool... " 79 | for LIBTOOLIZE in libtoolize glibtoolize nope; do 80 | ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 && break 81 | done 82 | if test x$LIBTOOLIZE = xnope; then 83 | echo "nope." 84 | LIBTOOLIZE=libtoolize 85 | else 86 | echo $LIBTOOLIZE 87 | fi 88 | ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || { 89 | echo 90 | echo "You must have libtool installed to compile $package." 91 | echo "Download the appropriate package for your system," 92 | echo "or get the source from one of the GNU ftp sites" 93 | echo "listed in http://www.gnu.org/order/ftp.html" 94 | DIE=1 95 | } 96 | 97 | if test "$DIE" -eq 1; then 98 | exit 1 99 | fi 100 | 101 | if test -z "$*"; then 102 | echo "I am going to run ./configure with no arguments - if you wish " 103 | echo "to pass any to it, please specify them on the $0 command line." 104 | fi 105 | 106 | echo "Generating configuration files for $package, please wait...." 107 | 108 | echo " $ACLOCAL $ACLOCAL_FLAGS" 109 | $ACLOCAL $ACLOCAL_FLAGS || exit 1 110 | echo " $LIBTOOLIZE --automake" 111 | $LIBTOOLIZE --automake || exit 1 112 | echo " autoheader" 113 | autoheader || exit 1 114 | echo " $AUTOMAKE --add-missing $AUTOMAKE_FLAGS" 115 | $AUTOMAKE --add-missing $AUTOMAKE_FLAGS || exit 1 116 | echo " autoconf" 117 | autoconf || exit 1 118 | 119 | cd $olddir 120 | $srcdir/configure --enable-maintainer-mode "$@" && echo 121 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/index.c: -------------------------------------------------------------------------------- 1 | /* 2 | index: frame index data structure and functions 3 | 4 | copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Thomas Orgis 7 | */ 8 | 9 | #include "index.h" 10 | #include "debug.h" 11 | 12 | /* The next expected frame offset, one step ahead. */ 13 | static off_t fi_next(struct frame_index *fi) 14 | { 15 | return (off_t)fi->fill*fi->step; 16 | } 17 | 18 | /* Shrink down the used index to the half. 19 | Be careful with size = 1 ... there's no shrinking possible there. */ 20 | static void fi_shrink(struct frame_index *fi) 21 | { 22 | if(fi->fill < 2) return; /* Won't shrink below 1. */ 23 | else 24 | { /* Double the step, half the fill. Should work as well for fill%2 = 1 */ 25 | size_t c; 26 | debug2("shrink index with fill %lu and step %lu", (unsigned long)fi->fill, (unsigned long)fi->step); 27 | fi->step *= 2; 28 | fi->fill /= 2; 29 | /* Move the data down. */ 30 | for(c = 0; c < fi->fill; ++c) 31 | fi->data[c] = fi->data[2*c]; 32 | } 33 | 34 | fi->next = fi_next(fi); 35 | } 36 | 37 | void fi_init(struct frame_index *fi) 38 | { 39 | fi->data = NULL; 40 | fi->step = 1; 41 | fi->fill = 0; 42 | fi->size = 0; 43 | fi->grow_size = 0; 44 | fi->next = fi_next(fi); 45 | } 46 | 47 | void fi_exit(struct frame_index *fi) 48 | { 49 | debug2("fi_exit: %p and %lu", (void*)fi->data, (unsigned long)fi->size); 50 | if(fi->size && fi->data != NULL) free(fi->data); 51 | 52 | fi_init(fi); /* Be prepared for further fun, still. */ 53 | } 54 | 55 | int fi_resize(struct frame_index *fi, size_t newsize) 56 | { 57 | off_t *newdata = NULL; 58 | if(newsize == fi->size) return 0; 59 | 60 | if(newsize > 0 && newsize < fi->size) 61 | { /* When we reduce buffer size a bit, shrink stuff. */ 62 | while(fi->fill > newsize){ fi_shrink(fi); } 63 | } 64 | 65 | newdata = safe_realloc(fi->data, newsize*sizeof(off_t)); 66 | if(newsize == 0 || newdata != NULL) 67 | { 68 | fi->data = newdata; 69 | fi->size = newsize; 70 | if(fi->fill > fi->size) fi->fill = fi->size; 71 | 72 | fi->next = fi_next(fi); 73 | debug2("new index of size %lu at %p", (unsigned long)fi->size, (void*)fi->data); 74 | return 0; 75 | } 76 | else 77 | { 78 | error("failed to resize index!"); 79 | return -1; 80 | } 81 | } 82 | 83 | void fi_add(struct frame_index *fi, off_t pos) 84 | { 85 | debug3("wanting to add to fill %lu, step %lu, size %lu", (unsigned long)fi->fill, (unsigned long)fi->step, (unsigned long)fi->size); 86 | if(fi->fill == fi->size) 87 | { /* Index is full, we need to shrink... or grow. */ 88 | /* Store the current frame number to check later if we still want it. */ 89 | off_t framenum = fi->fill*fi->step; 90 | /* If we want not / cannot grow, we shrink. */ 91 | if( !(fi->grow_size && fi_resize(fi, fi->size+fi->grow_size)==0) ) 92 | fi_shrink(fi); 93 | 94 | /* Now check if we still want to add this frame (could be that not, because of changed step). */ 95 | if(fi->next != framenum) return; 96 | } 97 | /* When we are here, we want that frame. */ 98 | if(fi->fill < fi->size) /* safeguard for size=1, or just generally */ 99 | { 100 | debug1("adding to index at %p", (void*)(fi->data+fi->fill)); 101 | fi->data[fi->fill] = pos; 102 | ++fi->fill; 103 | fi->next = fi_next(fi); 104 | debug3("added pos %li to index with fill %lu and step %lu", (long) pos, (unsigned long)fi->fill, (unsigned long)fi->step); 105 | } 106 | } 107 | 108 | int fi_set(struct frame_index *fi, off_t *offsets, off_t step, size_t fill) 109 | { 110 | if(fi_resize(fi, fill) == -1) return -1; 111 | fi->step = step; 112 | if(offsets != NULL) 113 | { 114 | memcpy(fi->data, offsets, fill*sizeof(off_t)); 115 | fi->fill = fill; 116 | } 117 | else 118 | { 119 | /* allocation only, no entries in index yet */ 120 | fi->fill = 0; 121 | } 122 | fi->next = fi_next(fi); 123 | debug3("set new index of fill %lu, size %lu at %p", 124 | (unsigned long)fi->fill, (unsigned long)fi->size, (void*)fi->data); 125 | return 0; 126 | } 127 | 128 | void fi_reset(struct frame_index *fi) 129 | { 130 | debug1("reset with size %"SIZE_P, (size_p)fi->size); 131 | fi->fill = 0; 132 | fi->step = 1; 133 | fi->next = fi_next(fi); 134 | } 135 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_neon_float.S: -------------------------------------------------------------------------------- 1 | /* 2 | synth_neon_float: ARM NEON optimized synth (float output version) 3 | 4 | copyright 1995-2010 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Monma 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | #define WINDOW r0 12 | #define B0 r1 13 | #define SAMPLES r2 14 | 15 | /* 16 | int synth_1to1_real_neon_asm(real *window, real *b0, real *samples, int bo1); 17 | return value: number of clipped samples (0) 18 | */ 19 | 20 | .code 32 21 | #ifndef __APPLE__ 22 | .fpu neon 23 | #endif 24 | 25 | .text 26 | .globl ASM_NAME(synth_1to1_real_neon_asm) 27 | #ifdef __ELF__ 28 | .type ASM_NAME(synth_1to1_real_neon_asm), %function 29 | #endif 30 | ALIGN4 31 | ASM_NAME(synth_1to1_real_neon_asm): 32 | push {r4-r5, lr} 33 | vpush {q4-q7} 34 | 35 | add WINDOW, WINDOW, #64 36 | sub WINDOW, WINDOW, r3, lsl #2 37 | 38 | mov r3, #4 39 | mov r4, #128 40 | mov r5, #64 41 | 1: 42 | vld1.32 {q0,q1}, [WINDOW], r4 43 | vld1.32 {q2,q3}, [WINDOW], r4 44 | vld1.32 {q4,q5}, [WINDOW], r4 45 | vld1.32 {q6,q7}, [WINDOW] 46 | sub WINDOW, WINDOW, #352 47 | vld1.32 {q8,q9}, [B0, :128], r5 48 | vld1.32 {q10,q11}, [B0, :128], r5 49 | vld1.32 {q12,q13}, [B0, :128], r5 50 | vld1.32 {q14,q15}, [B0, :128] 51 | vswp q1, q4 52 | vswp q3, q6 53 | sub B0, B0, #160 54 | vmul.f32 q0, q0, q8 55 | vmul.f32 q2, q2, q10 56 | vmul.f32 q1, q1, q12 57 | vmul.f32 q3, q3, q14 58 | vmla.f32 q0, q4, q9 59 | vmla.f32 q2, q6, q11 60 | vmla.f32 q1, q5, q13 61 | vmla.f32 q3, q7, q15 62 | vld1.32 {q4,q5}, [WINDOW], r4 63 | vld1.32 {q6,q7}, [WINDOW], r4 64 | vld1.32 {q8,q9}, [WINDOW], r4 65 | vld1.32 {q10,q11}, [B0, :128], r5 66 | vld1.32 {q12,q13}, [B0, :128], r5 67 | vld1.32 {q14,q15}, [B0, :128], r5 68 | vswp q5, q6 69 | vswp q11, q12 70 | vmla.f32 q0, q4, q10 71 | vmla.f32 q2, q5, q11 72 | vmla.f32 q1, q8, q14 73 | vld1.32 {q4,q5}, [WINDOW] 74 | vld1.32 {q10,q11}, [B0, :128]! 75 | add WINDOW, WINDOW, #96 76 | vmla.f32 q3, q4, q10 77 | vmla.f32 q0, q6, q12 78 | vmla.f32 q2, q7, q13 79 | vmla.f32 q1, q9, q15 80 | vmla.f32 q3, q5, q11 81 | vld2.32 {q4,q5}, [SAMPLES] 82 | vpadd.f32 d0, d0, d1 83 | vpadd.f32 d4, d4, d5 84 | vpadd.f32 d2, d2, d3 85 | vpadd.f32 d6, d6, d7 86 | vpadd.f32 d0, d0, d4 87 | vpadd.f32 d1, d2, d6 88 | 89 | vmov.i32 q1, #0x38000000 90 | vmul.f32 q4, q0, q1 91 | vst2.32 {q4,q5}, [SAMPLES]! 92 | 93 | subs r3, r3, #1 94 | bne 1b 95 | 96 | mov r3, #4 97 | mov r5, #-64 98 | 1: 99 | vld1.32 {q0,q1}, [WINDOW], r4 100 | vld1.32 {q2,q3}, [WINDOW], r4 101 | vld1.32 {q4,q5}, [WINDOW], r4 102 | vld1.32 {q6,q7}, [WINDOW] 103 | sub WINDOW, WINDOW, #352 104 | vld1.32 {q8,q9}, [B0, :128], r5 105 | vld1.32 {q10,q11}, [B0, :128], r5 106 | vld1.32 {q12,q13}, [B0, :128], r5 107 | vld1.32 {q14,q15}, [B0, :128] 108 | vswp q1, q4 109 | vswp q3, q6 110 | add B0, B0, #224 111 | vmul.f32 q0, q0, q8 112 | vmul.f32 q2, q2, q10 113 | vmul.f32 q1, q1, q12 114 | vmul.f32 q3, q3, q14 115 | vmla.f32 q0, q4, q9 116 | vmla.f32 q2, q6, q11 117 | vmla.f32 q1, q5, q13 118 | vmla.f32 q3, q7, q15 119 | vld1.32 {q4,q5}, [WINDOW], r4 120 | vld1.32 {q6,q7}, [WINDOW], r4 121 | vld1.32 {q8,q9}, [WINDOW], r4 122 | vld1.32 {q10,q11}, [B0, :128], r5 123 | vld1.32 {q12,q13}, [B0, :128], r5 124 | vld1.32 {q14,q15}, [B0, :128], r5 125 | vswp q5, q6 126 | vswp q11, q12 127 | vmla.f32 q0, q4, q10 128 | vmla.f32 q2, q5, q11 129 | vmla.f32 q1, q8, q14 130 | vld1.32 {q4,q5}, [WINDOW] 131 | vld1.32 {q10,q11}, [B0, :128] 132 | add WINDOW, WINDOW, #96 133 | sub B0, B0, #96 134 | vmla.f32 q3, q4, q10 135 | vmla.f32 q0, q6, q12 136 | vmla.f32 q2, q7, q13 137 | vmla.f32 q1, q9, q15 138 | vmla.f32 q3, q5, q11 139 | vld2.32 {q4,q5}, [SAMPLES] 140 | vpadd.f32 d0, d0, d1 141 | vpadd.f32 d4, d4, d5 142 | vpadd.f32 d2, d2, d3 143 | vpadd.f32 d6, d6, d7 144 | vpadd.f32 d0, d0, d4 145 | vpadd.f32 d1, d2, d6 146 | 147 | vmov.i32 q1, #0x38000000 148 | vmul.f32 q4, q0, q1 149 | vst2.32 {q4,q5}, [SAMPLES]! 150 | 151 | subs r3, r3, #1 152 | bne 1b 153 | 154 | mov r0, #0 155 | 156 | vpop {q4-q7} 157 | pop {r4-r5, pc} 158 | 159 | NONEXEC_STACK 160 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/compat.c: -------------------------------------------------------------------------------- 1 | /* 2 | compat: Some compatibility functions. 3 | 4 | The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX. 5 | So anything possibly somewhat advanced should be considered to be put here, with proper #ifdef;-) 6 | 7 | copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1 8 | see COPYING and AUTHORS files in distribution or http://mpg123.org 9 | initially written by Thomas Orgis, Windows Unicode stuff by JonY. 10 | */ 11 | 12 | #include "config.h" 13 | #include "compat.h" 14 | 15 | #ifdef _MSC_VER 16 | #include 17 | #else 18 | #include 19 | #endif 20 | #include 21 | 22 | #ifdef WANT_WIN32_UNICODE 23 | #include 24 | #include 25 | #include 26 | #endif 27 | 28 | #include "debug.h" 29 | 30 | /* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */ 31 | void *safe_realloc(void *ptr, size_t size) 32 | { 33 | if(ptr == NULL) return malloc(size); 34 | else return realloc(ptr, size); 35 | } 36 | 37 | #ifndef HAVE_STRERROR 38 | const char *strerror(int errnum) 39 | { 40 | extern int sys_nerr; 41 | extern char *sys_errlist[]; 42 | 43 | return (errnum < sys_nerr) ? sys_errlist[errnum] : ""; 44 | } 45 | #endif 46 | 47 | #ifndef HAVE_STRDUP 48 | char *strdup(const char *src) 49 | { 50 | char *dest; 51 | 52 | if (!(dest = (char *) malloc(strlen(src)+1))) 53 | return NULL; 54 | else 55 | return strcpy(dest, src); 56 | } 57 | #endif 58 | 59 | int compat_open(const char *filename, int flags) 60 | { 61 | int ret; 62 | #if defined (WANT_WIN32_UNICODE) 63 | wchar_t *frag = NULL; 64 | 65 | ret = win32_utf8_wide(filename, &frag, NULL); 66 | if ((frag == NULL) || (ret == 0)) goto fallback; /* Fallback to plain open when ucs-2 conversion fails */ 67 | 68 | ret = _wopen(frag, flags); /*Try _wopen */ 69 | if (ret != -1 ) goto open_ok; /* msdn says -1 means failure */ 70 | 71 | fallback: 72 | #endif 73 | 74 | #if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ 75 | ret = _open(filename, flags); /* Try plain old _open(), if it fails, do nothing */ 76 | #else 77 | /* On UNIX, we always add a default permission mask in case flags|O_CREAT. */ 78 | ret = open(filename, flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); 79 | #endif 80 | 81 | #if defined (WANT_WIN32_UNICODE) 82 | open_ok: 83 | free ((void *)frag); /* Freeing a NULL should be OK */ 84 | #endif 85 | 86 | return ret; 87 | } 88 | 89 | int compat_close(int infd) 90 | { 91 | #if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ 92 | return _close(infd); 93 | #else 94 | return close(infd); 95 | #endif 96 | } 97 | 98 | /* Windows Unicode stuff */ 99 | 100 | #ifdef WANT_WIN32_UNICODE 101 | int win32_wide_utf8(const wchar_t * const wptr, char **mbptr, size_t * buflen) 102 | { 103 | size_t len; 104 | char *buf; 105 | int ret = 0; 106 | 107 | len = WideCharToMultiByte(CP_UTF8, 0, wptr, -1, NULL, 0, NULL, NULL); /* Get utf-8 string length */ 108 | buf = calloc(len + 1, sizeof (char)); /* Can we assume sizeof char always = 1? */ 109 | 110 | if(!buf) len = 0; 111 | else { 112 | if (len != 0) ret = WideCharToMultiByte(CP_UTF8, 0, wptr, -1, buf, len, NULL, NULL); /*Do actual conversion*/ 113 | buf[len] = '0'; /* Must terminate */ 114 | } 115 | *mbptr = buf; /* Set string pointer to allocated buffer */ 116 | if(buflen != NULL) *buflen = (len) * sizeof (char); /* Give length of allocated memory if needed. */ 117 | return ret; 118 | } 119 | 120 | int win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen) 121 | { 122 | size_t len; 123 | wchar_t *buf; 124 | int ret = 0; 125 | 126 | len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, mbptr, -1, NULL, 0); /* Get converted size */ 127 | buf = calloc(len + 1, sizeof (wchar_t)); /* Allocate memory accordingly */ 128 | 129 | if(!buf) len = 0; 130 | else { 131 | if (len != 0) ret = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, mbptr, -1, buf, len); /* Do conversion */ 132 | buf[len] = L'0'; /* Must terminate */ 133 | } 134 | *wptr = buf; /* Set string pointer to allocated buffer */ 135 | if (buflen != NULL) *buflen = len * sizeof (wchar_t); /* Give length of allocated memory if needed. */ 136 | return ret; /* Number of characters written */ 137 | } 138 | #endif 139 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/codebook.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: basic shared codebook operations 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_CODEBOOK_H_ 19 | #define _V_CODEBOOK_H_ 20 | 21 | #include 22 | 23 | /* This structure encapsulates huffman and VQ style encoding books; it 24 | doesn't do anything specific to either. 25 | 26 | valuelist/quantlist are nonNULL (and q_* significant) only if 27 | there's entry->value mapping to be done. 28 | 29 | If encode-side mapping must be done (and thus the entry needs to be 30 | hunted), the auxiliary encode pointer will point to a decision 31 | tree. This is true of both VQ and huffman, but is mostly useful 32 | with VQ. 33 | 34 | */ 35 | 36 | typedef struct static_codebook{ 37 | long dim; /* codebook dimensions (elements per vector) */ 38 | long entries; /* codebook entries */ 39 | long *lengthlist; /* codeword lengths in bits */ 40 | 41 | /* mapping ***************************************************************/ 42 | int maptype; /* 0=none 43 | 1=implicitly populated values from map column 44 | 2=listed arbitrary values */ 45 | 46 | /* The below does a linear, single monotonic sequence mapping. */ 47 | long q_min; /* packed 32 bit float; quant value 0 maps to minval */ 48 | long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ 49 | int q_quant; /* bits: 0 < quant <= 16 */ 50 | int q_sequencep; /* bitflag */ 51 | 52 | long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map 53 | map == 2: list of dim*entries quantized entry vals 54 | */ 55 | } static_codebook; 56 | 57 | typedef struct codebook{ 58 | long dim; /* codebook dimensions (elements per vector) */ 59 | long entries; /* codebook entries */ 60 | long used_entries; /* populated codebook entries */ 61 | 62 | /* the below are ordered by bitreversed codeword and only used 63 | entries are populated */ 64 | int binarypoint; 65 | ogg_int32_t *valuelist; /* list of dim*entries actual entry values */ 66 | ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */ 67 | 68 | int *dec_index; 69 | char *dec_codelengths; 70 | ogg_uint32_t *dec_firsttable; 71 | int dec_firsttablen; 72 | int dec_maxlength; 73 | 74 | long q_min; /* packed 32 bit float; quant value 0 maps to minval */ 75 | long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ 76 | 77 | } codebook; 78 | 79 | extern void vorbis_staticbook_destroy(static_codebook *b); 80 | extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); 81 | 82 | extern void vorbis_book_clear(codebook *b); 83 | extern long _book_maptype1_quantvals(const static_codebook *b); 84 | 85 | extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b); 86 | 87 | extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); 88 | extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, 89 | oggpack_buffer *b,int n,int point); 90 | extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, 91 | oggpack_buffer *b,int n,int point); 92 | extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a, 93 | oggpack_buffer *b,int n,int point); 94 | extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a, 95 | long off,int ch, 96 | oggpack_buffer *b,int n,int point); 97 | 98 | extern int _ilog(unsigned int v); 99 | 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libvorbis/synthesis.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: single-block PCM synthesis 15 | last mod: $Id: synthesis.c,v 1.4 2003/03/29 03:07:21 xiphmont Exp $ 16 | 17 | ********************************************************************/ 18 | 19 | #include 20 | #include 21 | #include "ivorbiscodec.h" 22 | #include "codec_internal.h" 23 | #include "registry.h" 24 | #include "misc.h" 25 | #include "block.h" 26 | 27 | static int _vorbis_synthesis1(vorbis_block *vb,ogg_packet *op,int decodep){ 28 | vorbis_dsp_state *vd= vb ? vb->vd : 0; 29 | private_state *b= vd ? (private_state *)vd->backend_state: 0; 30 | vorbis_info *vi= vd ? vd->vi : 0; 31 | codec_setup_info *ci= vi ? (codec_setup_info *)vi->codec_setup : 0; 32 | oggpack_buffer *opb=vb ? &vb->opb : 0; 33 | int type,mode,i; 34 | 35 | if (!vd || !b || !vi || !ci || !opb) { 36 | return OV_EBADPACKET; 37 | } 38 | 39 | /* first things first. Make sure decode is ready */ 40 | _vorbis_block_ripcord(vb); 41 | oggpack_readinit(opb,op->packet,op->bytes); 42 | 43 | /* Check the packet type */ 44 | if(oggpack_read(opb,1)!=0){ 45 | /* Oops. This is not an audio data packet */ 46 | return(OV_ENOTAUDIO); 47 | } 48 | 49 | /* read our mode and pre/post windowsize */ 50 | mode=oggpack_read(opb,b->modebits); 51 | if(mode==-1)return(OV_EBADPACKET); 52 | 53 | vb->mode=mode; 54 | if(!ci->mode_param[mode]){ 55 | return(OV_EBADPACKET); 56 | } 57 | 58 | vb->W=ci->mode_param[mode]->blockflag; 59 | if(vb->W){ 60 | vb->lW=oggpack_read(opb,1); 61 | vb->nW=oggpack_read(opb,1); 62 | if(vb->nW==-1) return(OV_EBADPACKET); 63 | }else{ 64 | vb->lW=0; 65 | vb->nW=0; 66 | } 67 | 68 | /* more setup */ 69 | vb->granulepos=op->granulepos; 70 | vb->sequence=op->packetno-3; /* first block is third packet */ 71 | vb->eofflag=op->e_o_s; 72 | 73 | if(decodep){ 74 | /* alloc pcm passback storage */ 75 | vb->pcmend=ci->blocksizes[vb->W]; 76 | vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); 77 | for(i=0;ichannels;i++) 78 | vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); 79 | 80 | /* unpack_header enforces range checking */ 81 | type=ci->map_type[ci->mode_param[mode]->mapping]; 82 | 83 | return(_mapping_P[type]->inverse(vb,b->mode[mode])); 84 | }else{ 85 | /* no pcm */ 86 | vb->pcmend=0; 87 | vb->pcm=NULL; 88 | 89 | return(0); 90 | } 91 | } 92 | 93 | int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ 94 | return _vorbis_synthesis1(vb,op,1); 95 | } 96 | 97 | /* used to track pcm position without actually performing decode. 98 | Useful for sequential 'fast forward' */ 99 | int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){ 100 | return _vorbis_synthesis1(vb,op,0); 101 | } 102 | 103 | long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ 104 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; 105 | oggpack_buffer opb; 106 | int mode; 107 | 108 | oggpack_readinit(&opb,op->packet,op->bytes); 109 | 110 | /* Check the packet type */ 111 | if(oggpack_read(&opb,1)!=0){ 112 | /* Oops. This is not an audio data packet */ 113 | return(OV_ENOTAUDIO); 114 | } 115 | 116 | { 117 | int modebits=0; 118 | int v=ci->modes; 119 | while(v>1){ 120 | modebits++; 121 | v>>=1; 122 | } 123 | 124 | /* read our mode and pre/post windowsize */ 125 | mode=oggpack_read(&opb,modebits); 126 | } 127 | if(mode==-1)return(OV_EBADPACKET); 128 | return(ci->blocksizes[ci->mode_param[mode]->blockflag]); 129 | } 130 | 131 | 132 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_8bit.c: -------------------------------------------------------------------------------- 1 | /* 2 | synth_8bit.c: The functions for synthesizing 8bit samples, at the end of decoding. 3 | 4 | copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp, heavily dissected and rearranged by Thomas Orgis 7 | */ 8 | 9 | #include "mpg123lib_intern.h" 10 | #include "sample.h" 11 | #include "debug.h" 12 | 13 | /* 14 | Part 2: All synth functions that produce 8bit output. 15 | What we need is just a special WRITE_SAMPLE. For the generic and i386 functions, that is. 16 | For the rather optimized synth_1to1, we will need the postprocessing 8bit converters from synth_8bit.h . 17 | */ 18 | 19 | #define SAMPLE_T unsigned char 20 | #define WRITE_SAMPLE(samples,sum,clip) WRITE_8BIT_SAMPLE(samples,sum,clip) 21 | 22 | /* Part 2a: All straight 1to1 decoding functions */ 23 | #define BLOCK 0x40 /* One decoding block is 64 samples. */ 24 | 25 | #define SYNTH_NAME synth_1to1_8bit 26 | #include "synth.h" 27 | #undef SYNTH_NAME 28 | 29 | /* Mono-related synths; they wrap over _some_ synth_1to1_8bit (could be generic, could be i386). */ 30 | #define SYNTH_NAME fr->synths.plain[r_1to1][f_8] 31 | #define MONO_NAME synth_1to1_8bit_mono 32 | #define MONO2STEREO_NAME synth_1to1_8bit_m2s 33 | #include "synth_mono.h" 34 | #undef SYNTH_NAME 35 | #undef MONO_NAME 36 | #undef MONO2STEREO_NAME 37 | 38 | #ifdef OPT_X86 39 | #define NO_AUTOINCREMENT 40 | #define SYNTH_NAME synth_1to1_8bit_i386 41 | #include "synth.h" 42 | #undef SYNTH_NAME 43 | /* i386 uses the normal mono functions. */ 44 | #undef NO_AUTOINCREMENT 45 | #endif 46 | 47 | /* But now, we need functions that take the 16bit output of optimized synth_1to1 and convert it. 48 | I suppose that is still faster than dropping the optimization altogether! */ 49 | 50 | #define BASE_SYNTH_NAME fr->synths.plain[r_1to1][f_16] 51 | #define SYNTH_NAME synth_1to1_8bit_wrap 52 | #define MONO_NAME synth_1to1_8bit_wrap_mono 53 | #define MONO2STEREO_NAME synth_1to1_8bit_wrap_m2s 54 | #include "synth_8bit.h" 55 | #undef BASE_SYNTH_NAME 56 | #undef SYNTH_NAME 57 | #undef MONO_NAME 58 | #undef MONO2STEREO_NAME 59 | 60 | #undef BLOCK 61 | 62 | #ifndef NO_DOWNSAMPLE 63 | 64 | /* 65 | Part 2b: 2to1 synth. Only generic and i386. 66 | */ 67 | #define BLOCK 0x20 /* One decoding block is 32 samples. */ 68 | 69 | #define SYNTH_NAME synth_2to1_8bit 70 | #include "synth.h" 71 | #undef SYNTH_NAME 72 | 73 | /* Mono-related synths; they wrap over _some_ synth_2to1_8bit (could be generic, could be i386). */ 74 | #define SYNTH_NAME fr->synths.plain[r_2to1][f_8] 75 | #define MONO_NAME synth_2to1_8bit_mono 76 | #define MONO2STEREO_NAME synth_2to1_8bit_m2s 77 | #include "synth_mono.h" 78 | #undef SYNTH_NAME 79 | #undef MONO_NAME 80 | #undef MONO2STEREO_NAME 81 | 82 | #ifdef OPT_X86 83 | #define NO_AUTOINCREMENT 84 | #define SYNTH_NAME synth_2to1_8bit_i386 85 | #include "synth.h" 86 | #undef SYNTH_NAME 87 | /* i386 uses the normal mono functions. */ 88 | #undef NO_AUTOINCREMENT 89 | #endif 90 | 91 | #undef BLOCK 92 | 93 | /* 94 | Part 2c: 4to1 synth. Only generic and i386. 95 | */ 96 | #define BLOCK 0x10 /* One decoding block is 16 samples. */ 97 | 98 | #define SYNTH_NAME synth_4to1_8bit 99 | #include "synth.h" 100 | #undef SYNTH_NAME 101 | 102 | /* Mono-related synths; they wrap over _some_ synth_4to1_8bit (could be generic, could be i386). */ 103 | #define SYNTH_NAME fr->synths.plain[r_4to1][f_8] 104 | #define MONO_NAME synth_4to1_8bit_mono 105 | #define MONO2STEREO_NAME synth_4to1_8bit_m2s 106 | #include "synth_mono.h" 107 | #undef SYNTH_NAME 108 | #undef MONO_NAME 109 | #undef MONO2STEREO_NAME 110 | 111 | #ifdef OPT_X86 112 | #define NO_AUTOINCREMENT 113 | #define SYNTH_NAME synth_4to1_8bit_i386 114 | #include "synth.h" 115 | #undef SYNTH_NAME 116 | /* i386 uses the normal mono functions. */ 117 | #undef NO_AUTOINCREMENT 118 | #endif 119 | 120 | #undef BLOCK 121 | 122 | #endif /* NO_DOWNSAMPLE */ 123 | 124 | #ifndef NO_NTOM 125 | /* 126 | Part 2d: ntom synth. 127 | Same procedure as above... Just no extra play anymore, straight synth that may use an optimized dct64. 128 | */ 129 | 130 | /* These are all in one header, there's no flexibility to gain. */ 131 | #define SYNTH_NAME synth_ntom_8bit 132 | #define MONO_NAME synth_ntom_8bit_mono 133 | #define MONO2STEREO_NAME synth_ntom_8bit_m2s 134 | #include "synth_ntom.h" 135 | #undef SYNTH_NAME 136 | #undef MONO_NAME 137 | #undef MONO2STEREO_NAME 138 | 139 | #endif 140 | 141 | #undef SAMPLE_T 142 | #undef WRITE_SAMPLE 143 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/synth_neon_s32.S: -------------------------------------------------------------------------------- 1 | /* 2 | synth_neon_s32: ARM NEON optimized synth (32-bit output version) 3 | 4 | copyright 1995-2010 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Taihei Monma 7 | */ 8 | 9 | #include "mangle.h" 10 | 11 | #define WINDOW r0 12 | #define B0 r1 13 | #define SAMPLES r2 14 | 15 | /* 16 | int synth_1to1_s32_neon_asm(real *window, real *b0, int *samples, int bo1); 17 | return value: number of clipped samples (0) 18 | */ 19 | 20 | .code 32 21 | #ifndef __APPLE__ 22 | .fpu neon 23 | #endif 24 | 25 | .text 26 | .globl ASM_NAME(synth_1to1_s32_neon_asm) 27 | #ifdef __ELF__ 28 | .type ASM_NAME(synth_1to1_s32_neon_asm), %function 29 | #endif 30 | ALIGN4 31 | ASM_NAME(synth_1to1_s32_neon_asm): 32 | push {r4-r6, lr} 33 | vpush {q4-q7} 34 | mov r6, sp 35 | sub sp, sp, #16 36 | bic sp, #0xff 37 | 38 | add WINDOW, WINDOW, #64 39 | sub WINDOW, WINDOW, r3, lsl #2 40 | 41 | mov r3, #4 42 | mov r4, #128 43 | mov r5, #64 44 | 1: 45 | vld1.32 {q0,q1}, [WINDOW], r4 46 | vld1.32 {q2,q3}, [WINDOW], r4 47 | vld1.32 {q4,q5}, [WINDOW], r4 48 | vld1.32 {q6,q7}, [WINDOW] 49 | sub WINDOW, WINDOW, #352 50 | vld1.32 {q8,q9}, [B0, :128], r5 51 | vld1.32 {q10,q11}, [B0, :128], r5 52 | vld1.32 {q12,q13}, [B0, :128], r5 53 | vld1.32 {q14,q15}, [B0, :128] 54 | vswp q1, q4 55 | vswp q3, q6 56 | sub B0, B0, #160 57 | vmul.f32 q0, q0, q8 58 | vmul.f32 q2, q2, q10 59 | vmul.f32 q1, q1, q12 60 | vmul.f32 q3, q3, q14 61 | vmla.f32 q0, q4, q9 62 | vmla.f32 q2, q6, q11 63 | vmla.f32 q1, q5, q13 64 | vmla.f32 q3, q7, q15 65 | vld1.32 {q4,q5}, [WINDOW], r4 66 | vld1.32 {q6,q7}, [WINDOW], r4 67 | vld1.32 {q8,q9}, [WINDOW], r4 68 | vld1.32 {q10,q11}, [B0, :128], r5 69 | vld1.32 {q12,q13}, [B0, :128], r5 70 | vld1.32 {q14,q15}, [B0, :128], r5 71 | vswp q5, q6 72 | vswp q11, q12 73 | vmla.f32 q0, q4, q10 74 | vmla.f32 q2, q5, q11 75 | vmla.f32 q1, q8, q14 76 | vld1.32 {q4,q5}, [WINDOW] 77 | vld1.32 {q10,q11}, [B0, :128]! 78 | add WINDOW, WINDOW, #96 79 | vmla.f32 q3, q4, q10 80 | vmla.f32 q0, q6, q12 81 | vmla.f32 q2, q7, q13 82 | vmla.f32 q1, q9, q15 83 | vmla.f32 q3, q5, q11 84 | vmvn.i32 q5, #0xb9000000 85 | vpadd.f32 d0, d0, d1 86 | vpadd.f32 d4, d4, d5 87 | vpadd.f32 d2, d2, d3 88 | vpadd.f32 d6, d6, d7 89 | vld1.32 {q6}, [sp, :128] 90 | vpadd.f32 d0, d0, d4 91 | vpadd.f32 d1, d2, d6 92 | 93 | vcvt.s32.f32 q3, q0, #16 94 | vacgt.f32 q5, q0, q5 95 | vld2.32 {q1,q2}, [SAMPLES] 96 | vshr.u32 q5, q5, #31 97 | vmov q1, q3 98 | vst2.32 {q1,q2}, [SAMPLES]! 99 | vadd.i32 q5, q5, q6 100 | vst1.32 {q5}, [sp, :128] 101 | 102 | subs r3, r3, #1 103 | bne 1b 104 | 105 | mov r3, #4 106 | mov r5, #-64 107 | 1: 108 | vld1.32 {q0,q1}, [WINDOW], r4 109 | vld1.32 {q2,q3}, [WINDOW], r4 110 | vld1.32 {q4,q5}, [WINDOW], r4 111 | vld1.32 {q6,q7}, [WINDOW] 112 | sub WINDOW, WINDOW, #352 113 | vld1.32 {q8,q9}, [B0, :128], r5 114 | vld1.32 {q10,q11}, [B0, :128], r5 115 | vld1.32 {q12,q13}, [B0, :128], r5 116 | vld1.32 {q14,q15}, [B0, :128] 117 | vswp q1, q4 118 | vswp q3, q6 119 | add B0, B0, #224 120 | vmul.f32 q0, q0, q8 121 | vmul.f32 q2, q2, q10 122 | vmul.f32 q1, q1, q12 123 | vmul.f32 q3, q3, q14 124 | vmla.f32 q0, q4, q9 125 | vmla.f32 q2, q6, q11 126 | vmla.f32 q1, q5, q13 127 | vmla.f32 q3, q7, q15 128 | vld1.32 {q4,q5}, [WINDOW], r4 129 | vld1.32 {q6,q7}, [WINDOW], r4 130 | vld1.32 {q8,q9}, [WINDOW], r4 131 | vld1.32 {q10,q11}, [B0, :128], r5 132 | vld1.32 {q12,q13}, [B0, :128], r5 133 | vld1.32 {q14,q15}, [B0, :128], r5 134 | vswp q5, q6 135 | vswp q11, q12 136 | vmla.f32 q0, q4, q10 137 | vmla.f32 q2, q5, q11 138 | vmla.f32 q1, q8, q14 139 | vld1.32 {q4,q5}, [WINDOW] 140 | vld1.32 {q10,q11}, [B0, :128] 141 | add WINDOW, WINDOW, #96 142 | sub B0, B0, #96 143 | vmla.f32 q3, q4, q10 144 | vmla.f32 q0, q6, q12 145 | vmla.f32 q2, q7, q13 146 | vmla.f32 q1, q9, q15 147 | vmla.f32 q3, q5, q11 148 | vmvn.i32 q5, #0xb9000000 149 | vpadd.f32 d0, d0, d1 150 | vpadd.f32 d4, d4, d5 151 | vpadd.f32 d2, d2, d3 152 | vpadd.f32 d6, d6, d7 153 | vld1.32 {q6}, [sp, :128] 154 | vpadd.f32 d0, d0, d4 155 | vpadd.f32 d1, d2, d6 156 | 157 | vcvt.s32.f32 q3, q0, #16 158 | vacgt.f32 q5, q0, q5 159 | vld2.32 {q1,q2}, [SAMPLES] 160 | vshr.u32 q5, q5, #31 161 | vmov q1, q3 162 | vst2.32 {q1,q2}, [SAMPLES]! 163 | vadd.i32 q5, q5, q6 164 | vst1.32 {q5}, [sp, :128] 165 | 166 | subs r3, r3, #1 167 | bne 1b 168 | 169 | vld1.32 {q0}, [sp, :128] 170 | vpadd.i32 d0, d0, d1 171 | vpadd.i32 d0, d0, d0 172 | vmov.32 r0, d0[0] 173 | 174 | mov sp, r6 175 | vpop {q4-q7} 176 | pop {r4-r6, pc} 177 | 178 | NONEXEC_STACK 179 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/ntom.c: -------------------------------------------------------------------------------- 1 | /* 2 | ntom.c: N->M down/up sampling; the setup code. 3 | 4 | copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | initially written by Michael Hipp 7 | */ 8 | 9 | #define SAFE_NTOM /* Do not depend on off_t*off_t with big values still being in the range... */ 10 | #include "mpg123lib_intern.h" 11 | #include "debug.h" 12 | 13 | int synth_ntom_set_step(mpg123_handle *fr) 14 | { 15 | long m,n; 16 | m = frame_freq(fr); 17 | n = fr->af.rate; 18 | if(VERBOSE2) 19 | fprintf(stderr,"Init rate converter: %ld->%ld\n",m,n); 20 | 21 | if(n > NTOM_MAX_FREQ || m > NTOM_MAX_FREQ || m <= 0 || n <= 0) { 22 | if(NOQUIET) error("NtoM converter: illegal rates"); 23 | fr->err = MPG123_BAD_RATE; 24 | return -1; 25 | } 26 | 27 | n *= NTOM_MUL; 28 | fr->ntom_step = (unsigned long) n / m; 29 | 30 | if(fr->ntom_step > (unsigned long)NTOM_MAX*NTOM_MUL) { 31 | if(NOQUIET) error3("max. 1:%i conversion allowed (%lu vs %lu)!", NTOM_MAX, fr->ntom_step, (unsigned long)8*NTOM_MUL); 32 | fr->err = MPG123_BAD_RATE; 33 | return -1; 34 | } 35 | 36 | fr->ntom_val[0] = fr->ntom_val[1] = ntom_val(fr, fr->num); 37 | return 0; 38 | } 39 | 40 | /* 41 | The SAFE_NTOM does iterative loops instead of straight multiplication. 42 | The safety is not just about the algorithm closely mimicking the decoder instead of applying some formula, 43 | it is more about avoiding multiplication of possibly big sample offsets (a 32bit off_t could overflow too easily). 44 | */ 45 | 46 | unsigned long ntom_val(mpg123_handle *fr, off_t frame) 47 | { 48 | off_t ntm; 49 | #ifdef SAFE_NTOM /* Carry out the loop, without the threatening integer overflow. */ 50 | off_t f; 51 | ntm = NTOM_MUL>>1; /* for frame 0 */ 52 | for(f=0; f 0 */ 53 | { 54 | ntm += fr->spf*fr->ntom_step; 55 | ntm -= (ntm/NTOM_MUL)*NTOM_MUL; 56 | } 57 | #else /* Just make one computation with overall sample offset. */ 58 | ntm = (NTOM_MUL>>1) + fr->spf*frame*fr->ntom_step; 59 | ntm -= (ntm/NTOM_MUL)*NTOM_MUL; 60 | #endif 61 | return (unsigned long) ntm; 62 | } 63 | 64 | /* Set the ntom value for next expected frame to be decoded. 65 | This is for keeping output consistent across seeks. */ 66 | void ntom_set_ntom(mpg123_handle *fr, off_t num) 67 | { 68 | fr->ntom_val[1] = fr->ntom_val[0] = ntom_val(fr, num); 69 | } 70 | 71 | /* Carry out the ntom sample count operation for this one frame. 72 | No fear of integer overflow here. */ 73 | off_t ntom_frame_outsamples(mpg123_handle *fr) 74 | { 75 | /* The do this before decoding the separate channels, so there is only one common ntom value. */ 76 | int ntm = fr->ntom_val[0]; 77 | ntm += fr->spf*fr->ntom_step; 78 | return ntm/NTOM_MUL; 79 | } 80 | 81 | /* Convert frame offset to unadjusted output sample offset. */ 82 | off_t ntom_frmouts(mpg123_handle *fr, off_t frame) 83 | { 84 | #ifdef SAFE_NTOM 85 | off_t f; 86 | #endif 87 | off_t soff = 0; 88 | off_t ntm = ntom_val(fr,0); 89 | #ifdef SAFE_NTOM 90 | if(frame <= 0) return 0; 91 | for(f=0; fspf*fr->ntom_step; 94 | soff += ntm/NTOM_MUL; 95 | ntm -= (ntm/NTOM_MUL)*NTOM_MUL; 96 | } 97 | #else 98 | soff = (ntm + frame*(off_t)fr->spf*(off_t)fr->ntom_step)/(off_t)NTOM_MUL; 99 | #endif 100 | return soff; 101 | } 102 | 103 | /* Convert input samples to unadjusted output samples. */ 104 | off_t ntom_ins2outs(mpg123_handle *fr, off_t ins) 105 | { 106 | off_t soff = 0; 107 | off_t ntm = ntom_val(fr,0); 108 | #ifdef SAFE_NTOM 109 | { 110 | off_t block = fr->spf; 111 | if(ins <= 0) return 0; 112 | do 113 | { 114 | off_t nowblock = ins > block ? block : ins; 115 | ntm += nowblock*fr->ntom_step; 116 | soff += ntm/NTOM_MUL; 117 | ntm -= (ntm/NTOM_MUL)*NTOM_MUL; 118 | ins -= nowblock; 119 | } while(ins > 0); 120 | } 121 | #else 122 | /* Beware of overflows: when off_t is 32bits, the multiplication blows too easily. 123 | Of course, it blows for 64bits, too, in theory, but that's for _really_ large files. */ 124 | soff = ((off_t)ntm + (off_t)ins*(off_t)fr->ntom_step)/(off_t)NTOM_MUL; 125 | #endif 126 | return soff; 127 | } 128 | 129 | /* Determine frame offset from unadjusted output sample offset. */ 130 | off_t ntom_frameoff(mpg123_handle *fr, off_t soff) 131 | { 132 | off_t ioff = 0; /* frames or samples */ 133 | off_t ntm = ntom_val(fr,0); 134 | #ifdef SAFE_NTOM 135 | if(soff <= 0) return 0; 136 | for(ioff=0; 1; ++ioff) 137 | { 138 | ntm += fr->spf*fr->ntom_step; 139 | if(ntm/NTOM_MUL > soff) break; 140 | soff -= ntm/NTOM_MUL; 141 | ntm -= (ntm/NTOM_MUL)*NTOM_MUL; 142 | } 143 | return ioff; 144 | #else 145 | ioff = (soff*(off_t)NTOM_MUL-ntm)/(off_t)fr->ntom_step; 146 | return ioff/(off_t)fr->spf; 147 | #endif 148 | } 149 | -------------------------------------------------------------------------------- /mp3decoders/src/main/jni/libmpg123/gapless.h: -------------------------------------------------------------------------------- 1 | /* 2 | sampleadjust: gapless sample offset math 3 | 4 | copyright 1995-2012 by the mpg123 project - free software under the terms of the LGPL 2.1 5 | see COPYING and AUTHORS files in distribution or http://mpg123.org 6 | 7 | This is no stand-alone header, precisely to be able to fool it into using fake handle types for testing the math. 8 | */ 9 | 10 | #include "debug.h" 11 | 12 | #ifdef GAPLESS 13 | /* From internal sample number to external. */ 14 | static off_t sample_adjust(mpg123_handle *mh, off_t x) 15 | { 16 | off_t s; 17 | if(mh->p.flags & MPG123_GAPLESS) 18 | { 19 | /* It's a bit tricky to do this computation for the padding samples. 20 | They are not there on the outside. */ 21 | if(x > mh->end_os) 22 | { 23 | if(x < mh->fullend_os) 24 | s = mh->end_os - mh->begin_os; 25 | else 26 | s = x - (mh->fullend_os - mh->end_os + mh->begin_os); 27 | } 28 | else 29 | s = x - mh->begin_os; 30 | } 31 | else 32 | s = x; 33 | 34 | return s; 35 | } 36 | 37 | /* from external samples to internal */ 38 | static off_t sample_unadjust(mpg123_handle *mh, off_t x) 39 | { 40 | off_t s; 41 | if(mh->p.flags & MPG123_GAPLESS) 42 | { 43 | s = x + mh->begin_os; 44 | /* There is a hole; we don't create sample positions in there. 45 | Jump from the end of the gapless track directly to after the padding. */ 46 | if(s >= mh->end_os) 47 | s += mh->fullend_os - mh->end_os; 48 | } 49 | else s = x; 50 | 51 | return s; 52 | } 53 | 54 | /* 55 | Take the buffer after a frame decode (strictly: it is the data from frame fr->num!) and cut samples out. 56 | fr->buffer.fill may then be smaller than before... 57 | */ 58 | static void frame_buffercheck(mpg123_handle *fr) 59 | { 60 | /* When we have no accurate position, gapless code does not make sense. */ 61 | if(!(fr->state_flags & FRAME_ACCURATE)) return; 62 | 63 | /* Get a grip on dirty streams that start with a gapless header. 64 | Simply accept all data from frames that are too much, 65 | they are supposedly attached to the stream after the fact. */ 66 | if(fr->gapless_frames > 0 && fr->num >= fr->gapless_frames) return; 67 | 68 | /* Important: We first cut samples from the end, then cut from beginning (including left-shift of the buffer). 69 | This order works also for the case where firstframe == lastframe. */ 70 | 71 | /* The last interesting (planned) frame: Only use some leading samples. 72 | Note a difference from the below: The last frame and offset are unchanges by seeks. 73 | The lastoff keeps being valid. */ 74 | if(fr->lastframe > -1 && fr->num >= fr->lastframe) 75 | { 76 | /* There can be more than one frame of padding at the end, so we ignore the whole frame if we are beyond lastframe. */ 77 | off_t byteoff = (fr->num == fr->lastframe) ? samples_to_bytes(fr, fr->lastoff) : 0; 78 | if((off_t)fr->buffer.fill > byteoff) 79 | { 80 | fr->buffer.fill = byteoff; 81 | } 82 | if(VERBOSE3) fprintf(stderr, "\nNote: Cut frame %"OFF_P" buffer on end of stream to %"OFF_P" samples, fill now %"SIZE_P" bytes.\n", (off_p)fr->num, (off_p)(fr->num == fr->lastframe ? fr->lastoff : 0), (size_p)fr->buffer.fill); 83 | } 84 | 85 | /* The first interesting frame: Skip some leading samples. */ 86 | if(fr->firstoff && fr->num == fr->firstframe) 87 | { 88 | off_t byteoff = samples_to_bytes(fr, fr->firstoff); 89 | if((off_t)fr->buffer.fill > byteoff) 90 | { 91 | fr->buffer.fill -= byteoff; 92 | /* buffer.p != buffer.data only for own buffer */ 93 | debug6("cutting %li samples/%li bytes on begin, own_buffer=%i at %p=%p, buf[1]=%i", 94 | (long)fr->firstoff, (long)byteoff, fr->own_buffer, (void*)fr->buffer.p, (void*)fr->buffer.data, ((short*)fr->buffer.p)[2]); 95 | if(fr->own_buffer) fr->buffer.p = fr->buffer.data + byteoff; 96 | else memmove(fr->buffer.data, fr->buffer.data + byteoff, fr->buffer.fill); 97 | debug3("done cutting, buffer at %p =? %p, buf[1]=%i", 98 | (void*)fr->buffer.p, (void*)fr->buffer.data, ((short*)fr->buffer.p)[2]); 99 | } 100 | else fr->buffer.fill = 0; 101 | 102 | if(VERBOSE3) fprintf(stderr, "\nNote: Cut frame %"OFF_P" buffer on beginning of stream by %"OFF_P" samples, fill now %"SIZE_P" bytes.\n", (off_p)fr->num, (off_p)fr->firstoff, (size_p)fr->buffer.fill); 103 | /* We can only reach this frame again by seeking. And on seeking, firstoff will be recomputed. 104 | So it is safe to null it here (and it makes the if() decision abort earlier). */ 105 | fr->firstoff = 0; 106 | } 107 | } 108 | 109 | #define SAMPLE_ADJUST(mh,x) sample_adjust(mh,x) 110 | #define SAMPLE_UNADJUST(mh,x) sample_unadjust(mh,x) 111 | #define FRAME_BUFFERCHECK(mh) frame_buffercheck(mh) 112 | 113 | #else /* no gapless code included */ 114 | 115 | #define SAMPLE_ADJUST(mh,x) (x) 116 | #define SAMPLE_UNADJUST(mh,x) (x) 117 | #define FRAME_BUFFERCHECK(mh) 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /mp3decoders/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 15 | 16 | 21 | 22 | 26 | 27 |