21 | * --replaygain-fast compute RG fast but slightly inaccurately (default)
22 | * --replaygain-accurate compute RG more accurately and find the peak sample
23 | * --noreplaygain disable ReplayGain analysis
24 | * --clipdetect enable --replaygain-accurate and print a message whether
25 | * clipping occurs and how far the waveform is from full scale
26 | * --flush flush output stream as soon as possible
27 | * --freeformat produce a free format bitstream
28 | * --decode input=mp3 file, output=wav
29 | * -t disable writing wav header when using --decode
30 | *
31 | * @author Victor Chiu
32 | */
33 |
34 | public class OperationalOptions {
35 |
36 | @IntDef({MODE_JOINT, MODE_SIMPLE, MODE_FORCE, MODE_DUAL_MONO,
37 | MODE_MONO, MODE_LEFT, MODE_RIGHT})
38 | @Retention(RetentionPolicy.SOURCE)
39 | public @interface Mode {
40 | }
41 |
42 | public static final int MODE_JOINT = 1;
43 | public static final int MODE_SIMPLE = 2;
44 | public static final int MODE_FORCE = 3;
45 | public static final int MODE_DUAL_MONO = 4;
46 | public static final int MODE_MONO = 5;
47 | public static final int MODE_LEFT = 6;
48 | public static final int MODE_RIGHT = 7;
49 |
50 | @IntDef({TYPE_MEDIUM, TYPE_STANDARD, TYPE_EXTREME, TYPE_INSANE})
51 | @Retention(RetentionPolicy.SOURCE)
52 | public @interface Type {
53 | }
54 |
55 | public static final int TYPE_MEDIUM = 1;
56 | public static final int TYPE_STANDARD = 2;
57 | public static final int TYPE_EXTREME = 3;
58 | public static final int TYPE_INSANE = 4;
59 |
60 | @IntDef({REPLAY_GAIN_FAST, REPLAY_GAIN_ACCURATE, REPLAY_GAIN_NO})
61 | @Retention(RetentionPolicy.SOURCE)
62 | public @interface ReplayGain {
63 | }
64 |
65 | public static final int REPLAY_GAIN_FAST = 1;
66 | public static final int REPLAY_GAIN_ACCURATE = 2;
67 | public static final int REPLAY_GAIN_NO = 3;
68 |
69 | /**
70 | * 编码模式
71 | *
72 | * @see #MODE_JOINT
73 | * @see #MODE_SIMPLE
74 | * @see #MODE_FORCE
75 | * @see #MODE_DUAL_MONO
76 | * @see #MODE_MONO
77 | * @see #MODE_LEFT
78 | * @see #MODE_RIGHT
79 | */
80 | private int mode = -1;
81 | /**
82 | * 使用预设
83 | *
84 | * @see #TYPE_MEDIUM
85 | * @see #TYPE_STANDARD
86 | * @see #TYPE_EXTREME
87 | * @see #TYPE_INSANE
88 | */
89 | private int preset;
90 | /**
91 | * 压缩率
92 | */
93 | private float ratio;
94 | /**
95 | * 回放增益
96 | *
97 | * @see #REPLAY_GAIN_FAST
98 | * @see #REPLAY_GAIN_ACCURATE
99 | * @see #REPLAY_GAIN_NO
100 | */
101 | private int replayGain;
102 | /**
103 | * 尽快清空输出流
104 | */
105 | private boolean flush;
106 | /**
107 | * 生成自由格式的比特流(bitstream),而不是标准格式,
108 | * 支持8到640kbps之间的比特率。但解码器提供的支持不足。
109 | */
110 | private boolean freeFormat;
111 | /**
112 | * 输入为mp3文件,输出wav文件。
113 | */
114 | private boolean decode;
115 | /**
116 | * 使用decode时禁止写入wav header
117 | */
118 | private boolean writingWavHeader;
119 |
120 |
121 | public OperationalOptions mode(@Mode int mode) {
122 | this.mode = mode;
123 | return this;
124 | }
125 |
126 | public OperationalOptions preset(@Type int type) {
127 | this.preset = type;
128 | return this;
129 | }
130 |
131 | public OperationalOptions ratio(int ratio) {
132 | this.ratio = ratio;
133 | return this;
134 | }
135 |
136 | public OperationalOptions replayGain(@ReplayGain int replayGain) {
137 | this.replayGain = replayGain;
138 | return this;
139 | }
140 |
141 | public OperationalOptions flush(boolean flush) {
142 | this.flush = flush;
143 | return this;
144 | }
145 |
146 | public OperationalOptions freeFormat(boolean freeFormat) {
147 | this.freeFormat = freeFormat;
148 | return this;
149 | }
150 |
151 | public OperationalOptions decode(boolean decode) {
152 | this.decode = decode;
153 | return this;
154 | }
155 |
156 | public OperationalOptions writingWavHeader(boolean writingWavHeader) {
157 | this.writingWavHeader = writingWavHeader;
158 | return this;
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/ame/src/main/java/io/auxo/ame/options/RawPcmInputOptions.java:
--------------------------------------------------------------------------------
1 | package io.auxo.ame.options;
2 |
3 | import android.support.annotation.IntDef;
4 |
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 |
8 | /**
9 | * Input options for RAW PCM:
10 | * -r input is raw pcm
11 | * -s sfreq sampling frequency of input file (kHz) - default 44.1 kHz
12 | * --signed input is signed (default)
13 | * --unsigned input is unsigned
14 | * --bitwidth w input bit width is w (default 16)
15 | * -x force byte-swapping of input
16 | * --little-endian input is little-endian (default)
17 | * --big-endian input is big-endian
18 | * -a downmix from stereo to mono file for mono encoding
19 | *
20 | * @author Victor Chiu
21 | */
22 |
23 | public class RawPcmInputOptions {
24 |
25 | @IntDef({LITTLE_ENDIAN, BIG_ENDIAN})
26 | @Retention(RetentionPolicy.SOURCE)
27 | public @interface Endian {
28 | }
29 |
30 | public static final int LITTLE_ENDIAN = 1;
31 | public static final int BIG_ENDIAN = 2;
32 |
33 | /**
34 | * 输入文件为原始PCM数据
35 | */
36 | private boolean rawPcm;
37 | /**
38 | * 采样率(单位Khz)(默认44.1Khz)
39 | */
40 | private float sampleRate;
41 | /**
42 | * 输入源数据为有符号(默认)或无符号
43 | */
44 | private boolean signed = true;
45 | /**
46 | * 输入源数据位宽(默认16)
47 | */
48 | private int bitWidth;
49 | /**
50 | * 是否强制进行字节交换
51 | */
52 | private boolean forceByteSwapping;
53 | /**
54 | * 输入源数据的字节存储机制
55 | *
56 | * @see #LITTLE_ENDIAN
57 | * @see #BIG_ENDIAN
58 | */
59 | private int endian;
60 | /**
61 | * 是否从立体声(stereo)下混音(downmix)到单声道(mono)以进行单声道编码
62 | */
63 | private boolean downmix;
64 |
65 | public RawPcmInputOptions rawPcm(boolean rawPcm) {
66 | this.rawPcm = rawPcm;
67 | return this;
68 | }
69 |
70 | public RawPcmInputOptions forceByteSwapping(boolean forceByteSwapping) {
71 | this.forceByteSwapping = forceByteSwapping;
72 | return this;
73 | }
74 |
75 | public RawPcmInputOptions sampleRate(float sampleRate) {
76 | this.sampleRate = sampleRate;
77 | return this;
78 | }
79 |
80 | public RawPcmInputOptions bitWidth(int bitWidth) {
81 | this.bitWidth = bitWidth;
82 | return this;
83 | }
84 |
85 | public RawPcmInputOptions signed(boolean signed) {
86 | this.signed = signed;
87 | return this;
88 | }
89 |
90 | public RawPcmInputOptions endian(@Endian int endian) {
91 | this.endian = endian;
92 | return this;
93 | }
94 |
95 | public RawPcmInputOptions downmix(boolean downmix) {
96 | this.downmix = downmix;
97 | return this;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/ame/src/main/java/io/auxo/ame/options/VbrOptions.java:
--------------------------------------------------------------------------------
1 | package io.auxo.ame.options;
2 |
3 | import android.support.annotation.FloatRange;
4 | import android.support.annotation.IntDef;
5 |
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 |
9 | /**
10 | * VBR options:
11 | * -V n quality setting for VBR. default n=%i
12 | * . 0=high quality,bigger files. 9=smaller files
13 | * -v the same as -V 4
14 | * --vbr-old use old variable bitrate (VBR) routine
15 | * --vbr-new use new variable bitrate (VBR) routine (default)
16 | * -Y lets LAME ignore noise in sfb21, like in CBR
17 | * . (Default for V3 to V9.999)
18 | * -b specify minimum allowed bitrate, default 32 kbps
19 | * -B specify maximum allowed bitrate, default 320 kbps
20 | * -F strictly enforce the -b option, for use with players that
21 | * . do not support low bitrate mp3
22 | * -t disable writing LAME Tag
23 | * -T enable and force writing LAME Tag);
24 | *
25 | * @author Victor Chiu
26 | */
27 | public class VbrOptions {
28 |
29 | @IntDef({VBR_OFF, VBR_MT, VBR_RH, VBR_ABR, VBR_MTRH, VBR_MAX_INDICATOR})
30 | @Retention(RetentionPolicy.SOURCE)
31 | public @interface VbrMode {
32 | }
33 |
34 | public static final int VBR_OFF = 0;
35 | public static final int VBR_MT = 1;
36 | public static final int VBR_RH = 2;
37 | public static final int VBR_ABR = 3;
38 | public static final int VBR_MTRH = 4;
39 | public static final int VBR_MAX_INDICATOR = 5;
40 |
41 | /**
42 | * VBR的质量设置。默认quality=4.
43 | * 可以指定Decima类型的值, 如:4.51
44 | * 0=最高质量,生成的文件较大;
45 | * 9.999=最低质量,生成的文件较小。
46 | */
47 | private double quality = -1;
48 | /**
49 | * VBR模式
50 | */
51 | private int vbrMode = -1;
52 | private boolean ignoreNoise = false;
53 | /**
54 | * 可接受的最低比特率,默认32kbps
55 | */
56 | private int minBitrate = -1;
57 | /**
58 | * 可接受的最高比特率,默认320kbps
59 | */
60 | private int maxBitrate = -1;
61 | /**
62 | * 严格限制最低比特率
63 | */
64 | private boolean strictlyEnforceMinBitrate = false;
65 | /**
66 | * 写入LAME标签
67 | */
68 | private boolean writingLameTag = false;
69 |
70 | public VbrOptions quality(@FloatRange(from = 0, to = 10, toInclusive = false) float quality) {
71 | this.quality = quality;
72 | return this;
73 | }
74 |
75 | public VbrOptions mode(@VbrMode int mode) {
76 | this.vbrMode = mode;
77 | return this;
78 | }
79 |
80 | public VbrOptions ignoreNoise() {
81 | this.ignoreNoise = true;
82 | return this;
83 | }
84 |
85 | public VbrOptions minBitrate(int min) {
86 | this.minBitrate = min;
87 | return this;
88 | }
89 |
90 | public VbrOptions maxBitrate(int max) {
91 | this.maxBitrate = max;
92 | return this;
93 | }
94 |
95 | public VbrOptions strictlyEnforceMinBitrate() {
96 | this.strictlyEnforceMinBitrate = true;
97 | return this;
98 | }
99 |
100 | public VbrOptions writingLameTag() {
101 | this.writingLameTag = true;
102 | return this;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/ame/src/test/java/io/auxo/ame/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package io.auxo.ame;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 |
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.1.0'
12 | }
13 |
14 | ext.versions = [
15 | 'minSdk' : 14,
16 | 'compileSdk' : 27,
17 |
18 | 'supportLibrary': '27.1.0',
19 |
20 | 'mp3lame' : '3.100',
21 | 'ame' : '0',
22 | 'ame_lite' : '0.1'
23 | ]
24 |
25 | ext.deps = [
26 | 'support': [
27 | 'appcompat' : "com.android.support:appcompat-v7:$versions.supportLibrary",
28 | 'annotations': "com.android.support:support-annotations:$versions.supportLibrary"
29 | ],
30 | 'junit' : 'junit:junit:4.12',
31 | 'test' : [
32 | 'runner' : 'com.android.support.test:runner:1.0.1',
33 | 'espresso': 'com.android.support.test.espresso:espresso-core:3.0.1'
34 | ]
35 | ]
36 | }
37 |
38 | allprojects {
39 | repositories {
40 | google()
41 | jcenter()
42 | }
43 | }
44 |
45 | task clean(type: Delete) {
46 | delete rootProject.buildDir
47 | }
48 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | MAVEN_REPO_GROUP=io.auxo.ame
15 | MAVEN_REPO_USERNAME=
16 | MAVEN_REPO_PASSWORD=
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Apr 02 09:19:19 CST 2018
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-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/mavenUpload.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven'
2 |
3 | def VERSION_NAME = android.getDefaultConfig().versionName
4 |
5 | def isSnapshotBuild = VERSION_NAME.contains("SNAPSHOT")
6 |
7 | task sourcesJar(type: Jar) {
8 | from android.sourceSets.main.java.srcDirs
9 | classifier = 'sources'
10 | }
11 |
12 | task javadoc(type: Javadoc) {
13 | failOnError = false
14 | options.encoding = "UTF-8"
15 | source = android.sourceSets.main.java.srcDirs
16 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
17 | }
18 |
19 | task javadocJar(type: Jar, dependsOn: javadoc) {
20 | classifier = 'javadoc'
21 | from javadoc.destinationDir
22 | }
23 |
24 | artifacts {
25 | if (!isSnapshotBuild) {
26 | archives javadocJar
27 | archives sourcesJar
28 | }
29 | }
30 |
31 | uploadArchives {
32 | repositories {
33 | mavenDeployer {
34 | snapshotRepository(url: MAVEN_REPO_SNAPSHOT) {
35 | authentication(userName: MAVEN_REPO_USERNAME, password: MAVEN_REPO_PASSWORD)
36 | }
37 | repository(url: MAVEN_REPO_RELEASE) {
38 | authentication(userName: MAVEN_REPO_USERNAME, password: MAVEN_REPO_PASSWORD)
39 | }
40 | pom.project {
41 | groupId MAVEN_REPO_GROUP
42 | artifactId MAVEN_REPO_ARTIFACT
43 | version VERSION_NAME
44 | packaging 'aar'
45 | }
46 |
47 | println 'Group Id:' + MAVEN_REPO_GROUP
48 | println 'Artifact:' + MAVEN_REPO_ARTIFACT
49 | println 'Version:' + VERSION_NAME
50 | println 'Maven Repository:' + (isSnapshotBuild ? MAVEN_REPO_SNAPSHOT : MAVEN_REPO_RELEASE)
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/mp3lame/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | *.so
--------------------------------------------------------------------------------
/mp3lame/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion versions.compileSdk
5 |
6 | defaultConfig {
7 | minSdkVersion versions.minSdk
8 | targetSdkVersion versions.compileSdk
9 | versionName versions.mp3lame
10 |
11 | externalNativeBuild {
12 | cmake {
13 | cFlags "-DSTDC_HEADERS"
14 | targets 'mp3lame'
15 | }
16 | }
17 |
18 | ndk {
19 | abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64", "mips", "mips64"
20 | }
21 | }
22 |
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 |
30 | externalNativeBuild {
31 | cmake {
32 | path "src/main/cpp/CMakeLists.txt"
33 | }
34 | }
35 | }
36 |
37 | apply from: "../mavenUpload.gradle"
--------------------------------------------------------------------------------
/mp3lame/gradle.properties:
--------------------------------------------------------------------------------
1 | MAVEN_REPO_RELEASE=https://api.bintray.com/maven/4332weizi/Android/mp3lame/;publish=1
2 | MAVEN_REPO_SNAPSHOT=
3 | MAVEN_REPO_ARTIFACT=mp3lame
--------------------------------------------------------------------------------
/mp3lame/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/mp3lame/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.4.1)
2 |
3 | set( DIST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dist )
4 |
5 | # 添加mp3lame源文件
6 | aux_source_directory( ${CMAKE_HOME_DIRECTORY} LAME_SRC_LIST )
7 | aux_source_directory( ${CMAKE_HOME_DIRECTORY}/vector LAME_VECTOR_SRC_LIST )
8 |
9 | add_library( mp3lame
10 | SHARED
11 | ${LAME_SRC_LIST}
12 | ${LAME_VECTOR_SRC_LIST} )
13 |
14 | # 设定动态链接库输出路径
15 | set_target_properties( mp3lame
16 | PROPERTIES
17 | LIBRARY_OUTPUT_DIRECTORY
18 | "${DIST_DIR}/mp3lame/lib/${ANDROID_ABI}" )
19 |
20 | # 拷贝头文件到分发路径
21 | add_custom_command(TARGET mp3lame POST_BUILD
22 | COMMAND "${CMAKE_COMMAND}" -E
23 | copy "${CMAKE_CURRENT_SOURCE_DIR}/lame.h"
24 | "${DIST_DIR}/mp3lame/include/lame.h"
25 | COMMENT "Copying lame to output directory" )
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/VbrTag.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Xing VBR tagging for LAME.
3 | *
4 | * Copyright (c) 1999 A.L. Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_VRBTAG_H
23 | #define LAME_VRBTAG_H
24 |
25 |
26 | /* -----------------------------------------------------------
27 | * A Vbr header may be present in the ancillary
28 | * data field of the first frame of an mp3 bitstream
29 | * The Vbr header (optionally) contains
30 | * frames total number of audio frames in the bitstream
31 | * bytes total number of bytes in the bitstream
32 | * toc table of contents
33 |
34 | * toc (table of contents) gives seek points
35 | * for random access
36 | * the ith entry determines the seek point for
37 | * i-percent duration
38 | * seek point in bytes = (toc[i]/256.0) * total_bitstream_bytes
39 | * e.g. half duration seek point = (toc[50]/256.0) * total_bitstream_bytes
40 | */
41 |
42 |
43 | #define FRAMES_FLAG 0x0001
44 | #define BYTES_FLAG 0x0002
45 | #define TOC_FLAG 0x0004
46 | #define VBR_SCALE_FLAG 0x0008
47 |
48 | #define NUMTOCENTRIES 100
49 |
50 | #ifndef lame_internal_flags_defined
51 | #define lame_internal_flags_defined
52 | struct lame_internal_flags;
53 | typedef struct lame_internal_flags lame_internal_flags;
54 | #endif
55 |
56 |
57 | /*structure to receive extracted header */
58 | /* toc may be NULL*/
59 | typedef struct {
60 | int h_id; /* from MPEG header, 0=MPEG2, 1=MPEG1 */
61 | int samprate; /* determined from MPEG header */
62 | int flags; /* from Vbr header data */
63 | int frames; /* total bit stream frames from Vbr header data */
64 | int bytes; /* total bit stream bytes from Vbr header data */
65 | int vbr_scale; /* encoded vbr scale from Vbr header data */
66 | unsigned char toc[NUMTOCENTRIES]; /* may be NULL if toc not desired */
67 | int headersize; /* size of VBR header, in bytes */
68 | int enc_delay; /* encoder delay */
69 | int enc_padding; /* encoder paddign added at end of stream */
70 | } VBRTAGDATA;
71 |
72 | int GetVbrTag(VBRTAGDATA * pTagData, const unsigned char *buf);
73 |
74 | int InitVbrTag(lame_global_flags * gfp);
75 | int PutVbrTag(lame_global_flags const *gfp, FILE * fid);
76 | void AddVbrFrame(lame_internal_flags * gfc);
77 | void UpdateMusicCRC(uint16_t * crc, const unsigned char *buffer, int size);
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/bitstream.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MP3 bitstream Output interface for LAME
3 | *
4 | * Copyright (c) 1999 Takehiro TOMINAGA
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_BITSTREAM_H
23 | #define LAME_BITSTREAM_H
24 |
25 | int getframebits(const lame_internal_flags * gfc);
26 |
27 | int format_bitstream(lame_internal_flags * gfc);
28 |
29 | void flush_bitstream(lame_internal_flags * gfc);
30 | void add_dummy_byte(lame_internal_flags * gfc, unsigned char val, unsigned int n);
31 |
32 | int copy_buffer(lame_internal_flags * gfc, unsigned char *buffer, int buffer_size,
33 | int update_crc);
34 | void init_bit_stream_w(lame_internal_flags * gfc);
35 | void CRC_writeheader(lame_internal_flags const *gfc, char *buffer);
36 | int compute_flushbits(const lame_internal_flags * gfp, int *nbytes);
37 |
38 | int get_max_frame_buffer_size_by_constraint(SessionConfig_t const * cfg, int constraint);
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/encoder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * encoder.h include file
3 | *
4 | * Copyright (c) 2000 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 |
23 | #ifndef LAME_ENCODER_H
24 | #define LAME_ENCODER_H
25 |
26 | /***********************************************************************
27 | *
28 | * encoder and decoder delays
29 | *
30 | ***********************************************************************/
31 |
32 | /*
33 | * layer III enc->dec delay: 1056 (1057?) (observed)
34 | * layer II enc->dec delay: 480 (481?) (observed)
35 | *
36 | * polyphase 256-16 (dec or enc) = 240
37 | * mdct 256+32 (9*32) (dec or enc) = 288
38 | * total: 512+16
39 | *
40 | * My guess is that delay of polyphase filterbank is actualy 240.5
41 | * (there are technical reasons for this, see postings in mp3encoder).
42 | * So total Encode+Decode delay = ENCDELAY + 528 + 1
43 | */
44 |
45 | /*
46 | * ENCDELAY The encoder delay.
47 | *
48 | * Minimum allowed is MDCTDELAY (see below)
49 | *
50 | * The first 96 samples will be attenuated, so using a value less than 96
51 | * will result in corrupt data for the first 96-ENCDELAY samples.
52 | *
53 | * suggested: 576
54 | * set to 1160 to sync with FhG.
55 | */
56 |
57 | #define ENCDELAY 576
58 |
59 |
60 |
61 | /*
62 | * make sure there is at least one complete frame after the
63 | * last frame containing real data
64 | *
65 | * Using a value of 288 would be sufficient for a
66 | * a very sophisticated decoder that can decode granule-by-granule instead
67 | * of frame by frame. But lets not assume this, and assume the decoder
68 | * will not decode frame N unless it also has data for frame N+1
69 | *
70 | */
71 | /*#define POSTDELAY 288*/
72 | #define POSTDELAY 1152
73 |
74 |
75 |
76 | /*
77 | * delay of the MDCT used in mdct.c
78 | * original ISO routines had a delay of 528!
79 | * Takehiro's routines:
80 | */
81 |
82 | #define MDCTDELAY 48
83 | #define FFTOFFSET (224+MDCTDELAY)
84 |
85 | /*
86 | * Most decoders, including the one we use, have a delay of 528 samples.
87 | */
88 |
89 | #define DECDELAY 528
90 |
91 |
92 | /* number of subbands */
93 | #define SBLIMIT 32
94 |
95 | /* parition bands bands */
96 | #define CBANDS 64
97 |
98 | /* number of critical bands/scale factor bands where masking is computed*/
99 | #define SBPSY_l 21
100 | #define SBPSY_s 12
101 |
102 | /* total number of scalefactor bands encoded */
103 | #define SBMAX_l 22
104 | #define SBMAX_s 13
105 | #define PSFB21 6
106 | #define PSFB12 6
107 |
108 |
109 |
110 | /* FFT sizes */
111 | #define BLKSIZE 1024
112 | #define HBLKSIZE (BLKSIZE/2 + 1)
113 | #define BLKSIZE_s 256
114 | #define HBLKSIZE_s (BLKSIZE_s/2 + 1)
115 |
116 |
117 | /* #define switch_pe 1800 */
118 | #define NORM_TYPE 0
119 | #define START_TYPE 1
120 | #define SHORT_TYPE 2
121 | #define STOP_TYPE 3
122 |
123 | /*
124 | * Mode Extention:
125 | * When we are in stereo mode, there are 4 possible methods to store these
126 | * two channels. The stereo modes -m? are using a subset of them.
127 | *
128 | * -ms: MPG_MD_LR_LR
129 | * -mj: MPG_MD_LR_LR and MPG_MD_MS_LR
130 | * -mf: MPG_MD_MS_LR
131 | * -mi: all
132 | */
133 | #if 0
134 | #define MPG_MD_LR_LR 0
135 | #define MPG_MD_LR_I 1
136 | #define MPG_MD_MS_LR 2
137 | #define MPG_MD_MS_I 3
138 | #endif
139 | enum MPEGChannelMode
140 | { MPG_MD_LR_LR = 0
141 | , MPG_MD_LR_I = 1
142 | , MPG_MD_MS_LR = 2
143 | , MPG_MD_MS_I = 3
144 | };
145 |
146 | #ifndef lame_internal_flags_defined
147 | #define lame_internal_flags_defined
148 | struct lame_internal_flags;
149 | typedef struct lame_internal_flags lame_internal_flags;
150 | #endif
151 |
152 | int lame_encode_mp3_frame(lame_internal_flags * gfc,
153 | sample_t const *inbuf_l,
154 | sample_t const *inbuf_r, unsigned char *mp3buf, int mp3buf_size);
155 |
156 | #endif /* LAME_ENCODER_H */
157 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/fft.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Fast Fourier Transform include file
3 | *
4 | * Copyright (c) 2000 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_FFT_H
23 | #define LAME_FFT_H
24 |
25 | void fft_long(lame_internal_flags const *const gfc, FLOAT x_real[BLKSIZE],
26 | int chn, const sample_t *const data[2]);
27 |
28 | void fft_short(lame_internal_flags const *const gfc, FLOAT x_real[3][BLKSIZE_s],
29 | int chn, const sample_t *const data[2]);
30 |
31 | void init_fft(lame_internal_flags * const gfc);
32 |
33 | #endif
34 |
35 | /* End of fft.h */
36 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/gain_analysis.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ReplayGainAnalysis - analyzes input samples and give the recommended dB change
3 | * Copyright (C) 2001 David Robinson and Glen Sawyer
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * concept and filter values by David Robinson (David@Robinson.org)
20 | * -- blame him if you think the idea is flawed
21 | * coding by Glen Sawyer (mp3gain@hotmail.com) 735 W 255 N, Orem, UT 84057-4505 USA
22 | * -- blame him if you think this runs too slowly, or the coding is otherwise flawed
23 | *
24 | * For an explanation of the concepts and the basic algorithms involved, go to:
25 | * http://www.replaygain.org/
26 | */
27 |
28 | #ifndef GAIN_ANALYSIS_H
29 | #define GAIN_ANALYSIS_H
30 |
31 | #ifdef HAVE_INTTYPES_H
32 | # include
33 | #else
34 | # ifdef HAVE_STDINT_H
35 | # include
36 | # endif
37 | #endif
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 |
44 | typedef sample_t Float_t; /* Type used for filtering */
45 |
46 |
47 | #define PINK_REF 64.82 /* 298640883795 */ /* calibration value for 89dB */
48 |
49 |
50 | #define YULE_ORDER 10
51 | #define BUTTER_ORDER 2
52 | #define YULE_FILTER filterYule
53 | #define BUTTER_FILTER filterButter
54 | #define RMS_PERCENTILE 0.95 /* percentile which is louder than the proposed level */
55 | #define MAX_SAMP_FREQ 48000L /* maximum allowed sample frequency [Hz] */
56 | #define RMS_WINDOW_TIME_NUMERATOR 1L
57 | #define RMS_WINDOW_TIME_DENOMINATOR 20L /* numerator / denominator = time slice size [s] */
58 | #define STEPS_per_dB 100 /* Table entries per dB */
59 | #define MAX_dB 120 /* Table entries for 0...MAX_dB (normal max. values are 70...80 dB) */
60 |
61 | enum { GAIN_NOT_ENOUGH_SAMPLES = -24601, GAIN_ANALYSIS_ERROR = 0, GAIN_ANALYSIS_OK =
62 | 1, INIT_GAIN_ANALYSIS_ERROR = 0, INIT_GAIN_ANALYSIS_OK = 1
63 | };
64 |
65 | enum { MAX_ORDER = (BUTTER_ORDER > YULE_ORDER ? BUTTER_ORDER : YULE_ORDER)
66 | , MAX_SAMPLES_PER_WINDOW = ((MAX_SAMP_FREQ * RMS_WINDOW_TIME_NUMERATOR) / RMS_WINDOW_TIME_DENOMINATOR + 1) /* max. Samples per Time slice */
67 | };
68 |
69 | struct replaygain_data {
70 | Float_t linprebuf[MAX_ORDER * 2];
71 | Float_t *linpre; /* left input samples, with pre-buffer */
72 | Float_t lstepbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
73 | Float_t *lstep; /* left "first step" (i.e. post first filter) samples */
74 | Float_t loutbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
75 | Float_t *lout; /* left "out" (i.e. post second filter) samples */
76 | Float_t rinprebuf[MAX_ORDER * 2];
77 | Float_t *rinpre; /* right input samples ... */
78 | Float_t rstepbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
79 | Float_t *rstep;
80 | Float_t routbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
81 | Float_t *rout;
82 | long sampleWindow; /* number of samples required to reach number of milliseconds required for RMS window */
83 | long totsamp;
84 | double lsum;
85 | double rsum;
86 | int freqindex;
87 | int first;
88 | uint32_t A[STEPS_per_dB * MAX_dB];
89 | uint32_t B[STEPS_per_dB * MAX_dB];
90 |
91 | };
92 | #ifndef replaygain_data_defined
93 | #define replaygain_data_defined
94 | typedef struct replaygain_data replaygain_t;
95 | #endif
96 |
97 |
98 |
99 |
100 | int InitGainAnalysis(replaygain_t * rgData, long samplefreq);
101 | int AnalyzeSamples(replaygain_t * rgData, const Float_t * left_samples,
102 | const Float_t * right_samples, size_t num_samples, int num_channels);
103 | Float_t GetTitleGain(replaygain_t * rgData);
104 |
105 |
106 | #ifdef __cplusplus
107 | }
108 | #endif
109 | #endif /* GAIN_ANALYSIS_H */
110 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/id3tag.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAME_ID3_H
3 | #define LAME_ID3_H
4 |
5 |
6 | #define CHANGED_FLAG (1U << 0)
7 | #define ADD_V2_FLAG (1U << 1)
8 | #define V1_ONLY_FLAG (1U << 2)
9 | #define V2_ONLY_FLAG (1U << 3)
10 | #define SPACE_V1_FLAG (1U << 4)
11 | #define PAD_V2_FLAG (1U << 5)
12 |
13 | enum {
14 | MIMETYPE_NONE = 0,
15 | MIMETYPE_JPEG,
16 | MIMETYPE_PNG,
17 | MIMETYPE_GIF
18 | };
19 |
20 | typedef struct FrameDataNode {
21 | struct FrameDataNode *nxt;
22 | uint32_t fid; /* Frame Identifier */
23 | char lng[4]; /* 3-character language descriptor */
24 | struct {
25 | union {
26 | char *l; /* ptr to Latin-1 chars */
27 | unsigned short *u; /* ptr to UCS-2 text */
28 | unsigned char *b; /* ptr to raw bytes */
29 | } ptr;
30 | size_t dim;
31 | int enc; /* 0:Latin-1, 1:UCS-2, 2:RAW */
32 | } dsc , txt;
33 | } FrameDataNode;
34 |
35 |
36 | typedef struct id3tag_spec {
37 | /* private data members */
38 | unsigned int flags;
39 | int year;
40 | char *title;
41 | char *artist;
42 | char *album;
43 | char *comment;
44 | int track_id3v1;
45 | int genre_id3v1;
46 | unsigned char *albumart;
47 | unsigned int albumart_size;
48 | unsigned int padding_size;
49 | int albumart_mimetype;
50 | char language[4]; /* the language of the frame's content, according to ISO-639-2 */
51 | FrameDataNode *v2_head, *v2_tail;
52 | } id3tag_spec;
53 |
54 |
55 | /* write tag into stream at current position */
56 | extern int id3tag_write_v2(lame_global_flags * gfp);
57 | extern int id3tag_write_v1(lame_global_flags * gfp);
58 | /*
59 | * NOTE: A version 2 tag will NOT be added unless one of the text fields won't
60 | * fit in a version 1 tag (e.g. the title string is longer than 30 characters),
61 | * or the "id3tag_add_v2" or "id3tag_v2_only" functions are used.
62 | */
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/l3side.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Layer 3 side include file
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_L3SIDE_H
23 | #define LAME_L3SIDE_H
24 |
25 | /* max scalefactor band, max(SBMAX_l, SBMAX_s*3, (SBMAX_s-3)*3+8) */
26 | #define SFBMAX (SBMAX_s*3)
27 |
28 | /* Layer III side information. */
29 | typedef struct {
30 | int l[1 + SBMAX_l];
31 | int s[1 + SBMAX_s];
32 | int psfb21[1 + PSFB21];
33 | int psfb12[1 + PSFB12];
34 | } scalefac_struct;
35 |
36 |
37 | typedef struct {
38 | FLOAT l[SBMAX_l];
39 | FLOAT s[SBMAX_s][3];
40 | } III_psy_xmin;
41 |
42 | typedef struct {
43 | III_psy_xmin thm;
44 | III_psy_xmin en;
45 | } III_psy_ratio;
46 |
47 | typedef struct {
48 | FLOAT xr[576];
49 | int l3_enc[576];
50 | int scalefac[SFBMAX];
51 | FLOAT xrpow_max;
52 |
53 | int part2_3_length;
54 | int big_values;
55 | int count1;
56 | int global_gain;
57 | int scalefac_compress;
58 | int block_type;
59 | int mixed_block_flag;
60 | int table_select[3];
61 | int subblock_gain[3 + 1];
62 | int region0_count;
63 | int region1_count;
64 | int preflag;
65 | int scalefac_scale;
66 | int count1table_select;
67 |
68 | int part2_length;
69 | int sfb_lmax;
70 | int sfb_smin;
71 | int psy_lmax;
72 | int sfbmax;
73 | int psymax;
74 | int sfbdivide;
75 | int width[SFBMAX];
76 | int window[SFBMAX];
77 | int count1bits;
78 | /* added for LSF */
79 | const int *sfb_partition_table;
80 | int slen[4];
81 |
82 | int max_nonzero_coeff;
83 | char energy_above_cutoff[SFBMAX];
84 | } gr_info;
85 |
86 | typedef struct {
87 | gr_info tt[2][2];
88 | int main_data_begin;
89 | int private_bits;
90 | int resvDrain_pre;
91 | int resvDrain_post;
92 | int scfsi[2][4];
93 | } III_side_info_t;
94 |
95 | #endif
96 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/lame-analysis.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GTK plotting routines source file
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_GTKANAL_H
23 | #define LAME_GTKANAL_H
24 |
25 |
26 | #define READ_AHEAD 40 /* number of frames to read ahead */
27 | #define MAXMPGLAG READ_AHEAD /* if the mpg123 lag becomes bigger than this
28 | we have to stop */
29 | #define NUMBACK 6 /* number of frames we can back up */
30 | #define NUMPINFO (NUMBACK+READ_AHEAD+1)
31 |
32 |
33 |
34 | struct plotting_data {
35 | int frameNum; /* current frame number */
36 | int frameNum123;
37 | int num_samples; /* number of pcm samples read for this frame */
38 | double frametime; /* starting time of frame, in seconds */
39 | double pcmdata[2][1600];
40 | double pcmdata2[2][1152 + 1152 - DECDELAY];
41 | double xr[2][2][576];
42 | double mpg123xr[2][2][576];
43 | double ms_ratio[2];
44 | double ms_ener_ratio[2];
45 |
46 | /* L,R, M and S values */
47 | double energy_save[4][BLKSIZE]; /* psymodel is one ahead */
48 | double energy[2][4][BLKSIZE];
49 | double pe[2][4];
50 | double thr[2][4][SBMAX_l];
51 | double en[2][4][SBMAX_l];
52 | double thr_s[2][4][3 * SBMAX_s];
53 | double en_s[2][4][3 * SBMAX_s];
54 | double ers_save[4]; /* psymodel is one ahead */
55 | double ers[2][4];
56 |
57 | double sfb[2][2][SBMAX_l];
58 | double sfb_s[2][2][3 * SBMAX_s];
59 | double LAMEsfb[2][2][SBMAX_l];
60 | double LAMEsfb_s[2][2][3 * SBMAX_s];
61 |
62 | int LAMEqss[2][2];
63 | int qss[2][2];
64 | int big_values[2][2];
65 | int sub_gain[2][2][3];
66 |
67 | double xfsf[2][2][SBMAX_l];
68 | double xfsf_s[2][2][3 * SBMAX_s];
69 |
70 | int over[2][2];
71 | double tot_noise[2][2];
72 | double max_noise[2][2];
73 | double over_noise[2][2];
74 | int over_SSD[2][2];
75 | int blocktype[2][2];
76 | int scalefac_scale[2][2];
77 | int preflag[2][2];
78 | int mpg123blocktype[2][2];
79 | int mixed[2][2];
80 | int mainbits[2][2];
81 | int sfbits[2][2];
82 | int LAMEmainbits[2][2];
83 | int LAMEsfbits[2][2];
84 | int framesize, stereo, js, ms_stereo, i_stereo, emph, bitrate, sampfreq, maindata;
85 | int crc, padding;
86 | int scfsi[2], mean_bits, resvsize;
87 | int totbits;
88 | };
89 | #ifndef plotting_data_defined
90 | #define plotting_data_defined
91 | typedef struct plotting_data plotting_data;
92 | #endif
93 | #if 0
94 | extern plotting_data *pinfo;
95 | #endif
96 | #endif
97 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/lameerror.h:
--------------------------------------------------------------------------------
1 | /*
2 | * A collection of LAME Error Codes
3 | *
4 | * Please use the constants defined here instead of some arbitrary
5 | * values. Currently the values starting at -10 to avoid intersection
6 | * with the -1, -2, -3 and -4 used in the current code.
7 | *
8 | * May be this should be a part of the include/lame.h.
9 | */
10 |
11 | typedef enum {
12 | LAME_OKAY = 0,
13 | LAME_NOERROR = 0,
14 | LAME_GENERICERROR = -1,
15 | LAME_NOMEM = -10,
16 | LAME_BADBITRATE = -11,
17 | LAME_BADSAMPFREQ = -12,
18 | LAME_INTERNALERROR = -13,
19 |
20 | FRONTEND_READERROR = -80,
21 | FRONTEND_WRITEERROR = -81,
22 | FRONTEND_FILETOOLARGE = -82,
23 |
24 | } lame_errorcodes_t;
25 |
26 | /* end of lameerror.h */
27 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/machine.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Machine dependent defines/includes for LAME.
3 | *
4 | * Copyright (c) 1999 A.L. Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_MACHINE_H
23 | #define LAME_MACHINE_H
24 |
25 | #include "version.h"
26 |
27 | #include
28 | #include
29 |
30 | #ifdef STDC_HEADERS
31 | # include
32 | # include
33 | #else
34 | # ifndef HAVE_STRCHR
35 | # define strchr index
36 | # define strrchr rindex
37 | # endif
38 | char *strchr(), *strrchr();
39 | # ifndef HAVE_MEMCPY
40 | # define memcpy(d, s, n) bcopy ((s), (d), (n))
41 | # define memmove(d, s, n) bcopy ((s), (d), (n))
42 | # endif
43 | #endif
44 |
45 | #if defined(__riscos__) && defined(FPA10)
46 | # include "ymath.h"
47 | #else
48 | # include
49 | #endif
50 | #include
51 |
52 | #include
53 |
54 | #ifdef HAVE_ERRNO_H
55 | # include
56 | #endif
57 | #ifdef HAVE_FCNTL_H
58 | # include
59 | #endif
60 |
61 | #if defined(macintosh)
62 | # include
63 | # include
64 | #else
65 | # include
66 | # include
67 | #endif
68 |
69 | #ifdef HAVE_INTTYPES_H
70 | # include
71 | #else
72 | # ifdef HAVE_STDINT_H
73 | # include
74 | # endif
75 | #endif
76 |
77 | #ifdef WITH_DMALLOC
78 | #include
79 | #endif
80 |
81 | /*
82 | * 3 different types of pow() functions:
83 | * - table lookup
84 | * - pow()
85 | * - exp() on some machines this is claimed to be faster than pow()
86 | */
87 |
88 | #define POW20(x) (assert(0 <= (x+Q_MAX2) && x < Q_MAX), pow20[x+Q_MAX2])
89 | /*#define POW20(x) pow(2.0,((double)(x)-210)*.25) */
90 | /*#define POW20(x) exp( ((double)(x)-210)*(.25*LOG2) ) */
91 |
92 | #define IPOW20(x) (assert(0 <= x && x < Q_MAX), ipow20[x])
93 | /*#define IPOW20(x) exp( -((double)(x)-210)*.1875*LOG2 ) */
94 | /*#define IPOW20(x) pow(2.0,-((double)(x)-210)*.1875) */
95 |
96 | /* in case this is used without configure */
97 | #ifndef inline
98 | # define inline
99 | #endif
100 |
101 | #if defined(_MSC_VER)
102 | # undef inline
103 | # define inline _inline
104 | #elif defined(__SASC) || defined(__GNUC__) || defined(__ICC) || defined(__ECC)
105 | /* if __GNUC__ we always want to inline, not only if the user requests it */
106 | # undef inline
107 | # define inline __inline
108 | #endif
109 |
110 | #if defined(_MSC_VER)
111 | # pragma warning( disable : 4244 )
112 | /*# pragma warning( disable : 4305 ) */
113 | #endif
114 |
115 | /*
116 | * FLOAT for variables which require at least 32 bits
117 | * FLOAT8 for variables which require at least 64 bits
118 | *
119 | * On some machines, 64 bit will be faster than 32 bit. Also, some math
120 | * routines require 64 bit float, so setting FLOAT=float will result in a
121 | * lot of conversions.
122 | */
123 |
124 | #if ( defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) )
125 | # define WIN32_LEAN_AND_MEAN
126 | # include
127 | # include
128 | # define FLOAT_MAX FLT_MAX
129 | #else
130 | # ifndef FLOAT
131 | typedef float FLOAT;
132 | # ifdef FLT_MAX
133 | # define FLOAT_MAX FLT_MAX
134 | # else
135 | # define FLOAT_MAX 1e37 /* approx */
136 | # endif
137 | # endif
138 | #endif
139 |
140 | #ifndef FLOAT8
141 | typedef double FLOAT8;
142 | # ifdef DBL_MAX
143 | # define FLOAT8_MAX DBL_MAX
144 | # else
145 | # define FLOAT8_MAX 1e99 /* approx */
146 | # endif
147 | #else
148 | # ifdef FLT_MAX
149 | # define FLOAT8_MAX FLT_MAX
150 | # else
151 | # define FLOAT8_MAX 1e37 /* approx */
152 | # endif
153 | #endif
154 |
155 | /* sample_t must be floating point, at least 32 bits */
156 | typedef FLOAT sample_t;
157 |
158 | #define dimension_of(array) (sizeof(array)/sizeof(array[0]))
159 | #define beyond(array) (array+dimension_of(array))
160 | #define compiletime_assert(expression) enum{static_assert_##FILE##_##LINE = 1/((expression)?1:0)}
161 | #define lame_calloc(TYPE, COUNT) ((TYPE*)calloc(COUNT, sizeof(TYPE)))
162 | #define multiple_of(CHUNK, COUNT) (\
163 | ( (COUNT) < 1 || (CHUNK) < 1 || (COUNT) % (CHUNK) == 0 ) \
164 | ? (COUNT) \
165 | : ((COUNT) + (CHUNK) - (COUNT) % (CHUNK)) \
166 | )
167 |
168 | #if 1
169 | #define EQ(a,b) (\
170 | (fabs(a) > fabs(b)) \
171 | ? (fabs((a)-(b)) <= (fabs(a) * 1e-6f)) \
172 | : (fabs((a)-(b)) <= (fabs(b) * 1e-6f)))
173 | #else
174 | #define EQ(a,b) (fabs((a)-(b))<1E-37)
175 | #endif
176 |
177 | #define NEQ(a,b) (!EQ(a,b))
178 |
179 | #ifdef _MSC_VER
180 | # if _MSC_VER < 1400
181 | # define fabsf fabs
182 | # define powf pow
183 | # define log10f log10
184 | # endif
185 | #endif
186 |
187 | #endif
188 |
189 | /* end of machine.h */
190 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/newmdct.h:
--------------------------------------------------------------------------------
1 | /*
2 | * New Modified DCT include file
3 | *
4 | * Copyright (c) 1999 Takehiro TOMINAGA
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_NEWMDCT_H
23 | #define LAME_NEWMDCT_H
24 |
25 | void mdct_sub48(lame_internal_flags * gfc, const sample_t * w0, const sample_t * w1);
26 |
27 | #endif /* LAME_NEWMDCT_H */
28 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/psymodel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * psymodel.h
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_PSYMODEL_H
23 | #define LAME_PSYMODEL_H
24 |
25 |
26 | int L3psycho_anal_ns(lame_internal_flags * gfc,
27 | const sample_t *const buffer[2], int gr,
28 | III_psy_ratio ratio[2][2],
29 | III_psy_ratio MS_ratio[2][2],
30 | FLOAT pe[2], FLOAT pe_MS[2], FLOAT ener[2], int blocktype_d[2]);
31 |
32 | int L3psycho_anal_vbr(lame_internal_flags * gfc,
33 | const sample_t *const buffer[2], int gr,
34 | III_psy_ratio ratio[2][2],
35 | III_psy_ratio MS_ratio[2][2],
36 | FLOAT pe[2], FLOAT pe_MS[2], FLOAT ener[2], int blocktype_d[2]);
37 |
38 |
39 | int psymodel_init(lame_global_flags const* gfp);
40 |
41 |
42 | #define rpelev 2
43 | #define rpelev2 16
44 | #define rpelev_s 2
45 | #define rpelev2_s 16
46 |
47 | /* size of each partition band, in barks: */
48 | #define DELBARK .34
49 |
50 |
51 | /* tuned for output level (sensitive to energy scale) */
52 | #define VO_SCALE (1./( 14752*14752 )/(BLKSIZE/2))
53 |
54 | #define temporalmask_sustain_sec 0.01
55 |
56 | #define NS_PREECHO_ATT0 0.8
57 | #define NS_PREECHO_ATT1 0.6
58 | #define NS_PREECHO_ATT2 0.3
59 |
60 | #define NS_MSFIX 3.5
61 | #define NSATTACKTHRE 4.4
62 | #define NSATTACKTHRE_S 25
63 |
64 | #endif /* LAME_PSYMODEL_H */
65 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/quantize.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MP3 quantization
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_QUANTIZE_H
23 | #define LAME_QUANTIZE_H
24 |
25 | void CBR_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
26 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
27 |
28 | void VBR_old_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
29 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
30 |
31 | void VBR_new_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
32 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
33 |
34 | void ABR_iteration_loop(lame_internal_flags * gfc, const FLOAT pe[2][2],
35 | const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
36 |
37 |
38 | #endif /* LAME_QUANTIZE_H */
39 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/quantize_pvt.h:
--------------------------------------------------------------------------------
1 | /*
2 | * quantize_pvt include file
3 | *
4 | * Copyright (c) 1999 Takehiro TOMINAGA
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_QUANTIZE_PVT_H
23 | #define LAME_QUANTIZE_PVT_H
24 |
25 | #define IXMAX_VAL 8206 /* ix always <= 8191+15. see count_bits() */
26 |
27 | /* buggy Winamp decoder cannot handle values > 8191 */
28 | /* #define IXMAX_VAL 8191 */
29 |
30 | #define PRECALC_SIZE (IXMAX_VAL+2)
31 |
32 |
33 | extern const int nr_of_sfb_block[6][3][4];
34 | extern const int pretab[SBMAX_l];
35 | extern const int slen1_tab[16];
36 | extern const int slen2_tab[16];
37 |
38 | extern const scalefac_struct sfBandIndex[9];
39 |
40 | extern FLOAT pow43[PRECALC_SIZE];
41 | #ifdef TAKEHIRO_IEEE754_HACK
42 | extern FLOAT adj43asm[PRECALC_SIZE];
43 | #else
44 | extern FLOAT adj43[PRECALC_SIZE];
45 | #endif
46 |
47 | #define Q_MAX (256+1)
48 | #define Q_MAX2 116 /* minimum possible number of
49 | -cod_info->global_gain
50 | + ((scalefac[] + (cod_info->preflag ? pretab[sfb] : 0))
51 | << (cod_info->scalefac_scale + 1))
52 | + cod_info->subblock_gain[cod_info->window[sfb]] * 8;
53 |
54 | for long block, 0+((15+3)<<2) = 18*4 = 72
55 | for short block, 0+(15<<2)+7*8 = 15*4+56 = 116
56 | */
57 |
58 | extern FLOAT pow20[Q_MAX + Q_MAX2 + 1];
59 | extern FLOAT ipow20[Q_MAX];
60 |
61 | typedef struct calc_noise_result_t {
62 | FLOAT over_noise; /* sum of quantization noise > masking */
63 | FLOAT tot_noise; /* sum of all quantization noise */
64 | FLOAT max_noise; /* max quantization noise */
65 | int over_count; /* number of quantization noise > masking */
66 | int over_SSD; /* SSD-like cost of distorted bands */
67 | int bits;
68 | } calc_noise_result;
69 |
70 |
71 | /**
72 | * allows re-use of previously
73 | * computed noise values
74 | */
75 | typedef struct calc_noise_data_t {
76 | int global_gain;
77 | int sfb_count1;
78 | int step[39];
79 | FLOAT noise[39];
80 | FLOAT noise_log[39];
81 | } calc_noise_data;
82 |
83 |
84 | int on_pe(lame_internal_flags * gfc, const FLOAT pe[2][2],
85 | int targ_bits[2], int mean_bits, int gr, int cbr);
86 |
87 | void reduce_side(int targ_bits[2], FLOAT ms_ener_ratio, int mean_bits, int max_bits);
88 |
89 |
90 | void iteration_init(lame_internal_flags * gfc);
91 |
92 |
93 | int calc_xmin(lame_internal_flags const *gfc,
94 | III_psy_ratio const *const ratio, gr_info * const cod_info, FLOAT * l3_xmin);
95 |
96 | int calc_noise(const gr_info * const cod_info,
97 | const FLOAT * l3_xmin,
98 | FLOAT * distort, calc_noise_result * const res, calc_noise_data * prev_noise);
99 |
100 | void set_frame_pinfo(lame_internal_flags * gfc, const III_psy_ratio ratio[2][2]);
101 |
102 |
103 |
104 |
105 | /* takehiro.c */
106 |
107 | int count_bits(lame_internal_flags const *const gfc, const FLOAT * const xr,
108 | gr_info * const cod_info, calc_noise_data * prev_noise);
109 | int noquant_count_bits(lame_internal_flags const *const gfc,
110 | gr_info * const cod_info, calc_noise_data * prev_noise);
111 |
112 |
113 | void best_huffman_divide(const lame_internal_flags * const gfc, gr_info * const cod_info);
114 |
115 | void best_scalefac_store(const lame_internal_flags * gfc, const int gr, const int ch,
116 | III_side_info_t * const l3_side);
117 |
118 | int scale_bitcount(const lame_internal_flags * gfc, gr_info * cod_info);
119 |
120 | void huffman_init(lame_internal_flags * const gfc);
121 |
122 | void init_xrpow_core_init(lame_internal_flags * const gfc);
123 |
124 | FLOAT athAdjust(FLOAT a, FLOAT x, FLOAT athFloor, float ATHfixpoint);
125 |
126 | #define LARGE_BITS 100000
127 |
128 | #endif /* LAME_QUANTIZE_PVT_H */
129 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/reservoir.h:
--------------------------------------------------------------------------------
1 | /*
2 | * bit reservoir include file
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_RESERVOIR_H
23 | #define LAME_RESERVOIR_H
24 |
25 | int ResvFrameBegin(lame_internal_flags * gfc, int *mean_bits);
26 | void ResvMaxBits(lame_internal_flags * gfc, int mean_bits, int *targ_bits, int *max_bits,
27 | int cbr);
28 | void ResvAdjust(lame_internal_flags * gfc, gr_info const *gi);
29 | void ResvFrameEnd(lame_internal_flags * gfc, int mean_bits);
30 |
31 | #endif /* LAME_RESERVOIR_H */
32 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/set_get.h:
--------------------------------------------------------------------------------
1 | /*
2 | * set_get.h -- Internal set/get definitions
3 | *
4 | * Copyright (C) 2003 Gabriel Bouvigne / Lame project
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19 | */
20 |
21 | #ifndef __SET_GET_H__
22 | #define __SET_GET_H__
23 |
24 | #include "lame.h"
25 |
26 | #if defined(__cplusplus)
27 | extern "C" {
28 | #endif
29 |
30 | /* select psychoacoustic model */
31 |
32 | /* manage short blocks */
33 | int CDECL lame_set_short_threshold(lame_global_flags *, float, float);
34 | int CDECL lame_set_short_threshold_lrm(lame_global_flags *, float);
35 | float CDECL lame_get_short_threshold_lrm(const lame_global_flags *);
36 | int CDECL lame_set_short_threshold_s(lame_global_flags *, float);
37 | float CDECL lame_get_short_threshold_s(const lame_global_flags *);
38 |
39 |
40 | int CDECL lame_set_maskingadjust(lame_global_flags *, float);
41 | float CDECL lame_get_maskingadjust(const lame_global_flags *);
42 |
43 | int CDECL lame_set_maskingadjust_short(lame_global_flags *, float);
44 | float CDECL lame_get_maskingadjust_short(const lame_global_flags *);
45 |
46 | /* select ATH formula 4 shape */
47 | int CDECL lame_set_ATHcurve(lame_global_flags *, float);
48 | float CDECL lame_get_ATHcurve(const lame_global_flags *);
49 |
50 | int CDECL lame_set_preset_notune(lame_global_flags *, int);
51 |
52 | /* substep shaping method */
53 | int CDECL lame_set_substep(lame_global_flags *, int);
54 | int CDECL lame_get_substep(const lame_global_flags *);
55 |
56 | /* scalefactors scale */
57 | int CDECL lame_set_sfscale(lame_global_flags *, int);
58 | int CDECL lame_get_sfscale(const lame_global_flags *);
59 |
60 | /* subblock gain */
61 | int CDECL lame_set_subblock_gain(lame_global_flags *, int);
62 | int CDECL lame_get_subblock_gain(const lame_global_flags *);
63 |
64 |
65 |
66 | /*presets*/
67 | int apply_preset(lame_global_flags *, int preset, int enforce);
68 |
69 | void CDECL lame_set_tune(lame_t, float); /* FOR INTERNAL USE ONLY */
70 | void CDECL lame_set_msfix(lame_t gfp, double msfix);
71 |
72 |
73 | #if defined(__cplusplus)
74 | }
75 | #endif
76 | #endif
77 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/tables.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MPEG layer 3 tables include file
3 | *
4 | * Copyright (c) 1999 Albert L Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_TABLES_H
23 | #define LAME_TABLES_H
24 |
25 | #if 0
26 | typedef struct {
27 | unsigned char no;
28 | unsigned char width;
29 | unsigned char minval_2;
30 | float quiet_thr;
31 | float norm;
32 | float bark;
33 | } type1_t;
34 |
35 | typedef struct {
36 | unsigned char no;
37 | unsigned char width;
38 | float quiet_thr;
39 | float norm;
40 | float SNR;
41 | float bark;
42 | } type2_t;
43 |
44 | typedef struct {
45 | unsigned int no:5;
46 | unsigned int cbw:3;
47 | unsigned int bu:6;
48 | unsigned int bo:6;
49 | unsigned int w1_576:10;
50 | unsigned int w2_576:10;
51 | } type34_t;
52 |
53 | typedef struct {
54 | size_t len1;
55 | const type1_t *const tab1;
56 | size_t len2;
57 | const type2_t *const tab2;
58 | size_t len3;
59 | const type34_t *const tab3;
60 | size_t len4;
61 | const type34_t *const tab4;
62 | } type5_t;
63 |
64 | extern const type5_t table5[6];
65 |
66 | #endif
67 |
68 | #define HTN 34
69 |
70 | struct huffcodetab {
71 | const unsigned int xlen; /* max. x-index+ */
72 | const unsigned int linmax; /* max number to be stored in linbits */
73 | const uint16_t *table; /* pointer to array[xlen][ylen] */
74 | const uint8_t *hlen; /* pointer to array[xlen][ylen] */
75 | };
76 |
77 | extern const struct huffcodetab ht[HTN];
78 | /* global memory block */
79 | /* array of all huffcodtable headers */
80 | /* 0..31 Huffman code table 0..31 */
81 | /* 32,33 count1-tables */
82 |
83 | extern const uint8_t t32l[];
84 | extern const uint8_t t33l[];
85 |
86 | extern const uint32_t largetbl[16 * 16];
87 | extern const uint32_t table23[3 * 3];
88 | extern const uint32_t table56[4 * 4];
89 |
90 | extern const int scfsi_band[5];
91 |
92 | extern const int bitrate_table [3][16];
93 | extern const int samplerate_table [3][ 4];
94 |
95 | #endif /* LAME_TABLES_H */
96 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/vbrquantize.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MP3 VBR quantization
3 | *
4 | * Copyright (c) 1999 Mark Taylor
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_VBRQUANTIZE_H
23 | #define LAME_VBRQUANTIZE_H
24 |
25 | int VBR_encode_frame(lame_internal_flags * gfc, const FLOAT xr34orig[2][2][576],
26 | const FLOAT l3_xmin[2][2][SFBMAX], const int maxbits[2][2]);
27 |
28 | #endif /* LAME_VBRQUANTIZE_H */
29 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/vector/lame_intrin.h:
--------------------------------------------------------------------------------
1 | /*
2 | * lame_intrin.h include file
3 | *
4 | * Copyright (c) 2006 Gabriel Bouvigne
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 |
23 | #ifndef LAME_INTRIN_H
24 | #define LAME_INTRIN_H
25 |
26 |
27 | void
28 | init_xrpow_core_sse(gr_info * const cod_info, FLOAT xrpow[576], int upper, FLOAT * sum);
29 |
30 | void
31 | fht_SSE2(FLOAT* , int);
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/version.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Version numbering for LAME.
3 | *
4 | * Copyright (c) 1999 A.L. Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | /*!
23 | \file version.c
24 | \brief Version numbering for LAME.
25 |
26 | Contains functions which describe the version of LAME.
27 |
28 | \author A.L. Faber
29 | \version \$Id: version.c,v 1.34 2011/11/18 09:51:02 robert Exp $
30 | \ingroup libmp3lame
31 | */
32 |
33 |
34 | #ifdef HAVE_CONFIG_H
35 | # include
36 | #endif
37 |
38 |
39 | #include "lame.h"
40 | #include "machine.h"
41 |
42 | #include "version.h" /* macros of version numbers */
43 |
44 |
45 |
46 |
47 |
48 | /*! Get the LAME version string. */
49 | /*!
50 | \param void
51 | \return a pointer to a string which describes the version of LAME.
52 | */
53 | const char *
54 | get_lame_version(void)
55 | { /* primary to write screen reports */
56 | /* Here we can also add informations about compile time configurations */
57 |
58 | #if LAME_ALPHA_VERSION
59 | static /*@observer@ */ const char *const str =
60 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
61 | "(alpha " STR(LAME_PATCH_VERSION) ", " __DATE__ " " __TIME__ ")";
62 | #elif LAME_BETA_VERSION
63 | static /*@observer@ */ const char *const str =
64 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " "
65 | "(beta " STR(LAME_PATCH_VERSION) ", " __DATE__ ")";
66 | #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
67 | static /*@observer@ */ const char *const str =
68 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION);
69 | #else
70 | static /*@observer@ */ const char *const str =
71 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION);
72 | #endif
73 |
74 | return str;
75 | }
76 |
77 |
78 | /*! Get the short LAME version string. */
79 | /*!
80 | It's mainly for inclusion into the MP3 stream.
81 |
82 | \param void
83 | \return a pointer to the short version of the LAME version string.
84 | */
85 | const char *
86 | get_lame_short_version(void)
87 | {
88 | /* adding date and time to version string makes it harder for output
89 | validation */
90 |
91 | #if LAME_ALPHA_VERSION
92 | static /*@observer@ */ const char *const str =
93 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (alpha " STR(LAME_PATCH_VERSION) ")";
94 | #elif LAME_BETA_VERSION
95 | static /*@observer@ */ const char *const str =
96 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) " (beta " STR(LAME_PATCH_VERSION) ")";
97 | #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
98 | static /*@observer@ */ const char *const str =
99 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) "." STR(LAME_PATCH_VERSION);
100 | #else
101 | static /*@observer@ */ const char *const str =
102 | STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION);
103 | #endif
104 |
105 | return str;
106 | }
107 |
108 | /*! Get the _very_ short LAME version string. */
109 | /*!
110 | It's used in the LAME VBR tag only.
111 |
112 | \param void
113 | \return a pointer to the short version of the LAME version string.
114 | */
115 | const char *
116 | get_lame_very_short_version(void)
117 | {
118 | /* adding date and time to version string makes it harder for output
119 | validation */
120 | #if LAME_ALPHA_VERSION
121 | #define P "a"
122 | #elif LAME_BETA_VERSION
123 | #define P "b"
124 | #elif LAME_RELEASE_VERSION && (LAME_PATCH_VERSION > 0)
125 | #define P "r"
126 | #else
127 | #define P " "
128 | #endif
129 | static /*@observer@ */ const char *const str =
130 | #if (LAME_PATCH_VERSION > 0)
131 | "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P STR(LAME_PATCH_VERSION)
132 | #else
133 | "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
134 | #endif
135 | ;
136 | return str;
137 | }
138 |
139 | /*! Get the _very_ short LAME version string. */
140 | /*!
141 | It's used in the LAME VBR tag only, limited to 9 characters max.
142 | Due to some 3rd party HW/SW decoders, it has to start with LAME.
143 |
144 | \param void
145 | \return a pointer to the short version of the LAME version string.
146 | */
147 | const char*
148 | get_lame_tag_encoder_short_version(void)
149 | {
150 | static /*@observer@ */ const char *const str =
151 | /* FIXME: new scheme / new version counting / drop versioning here ? */
152 | "LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P
153 | ;
154 | return str;
155 | }
156 |
157 | /*! Get the version string for GPSYCHO. */
158 | /*!
159 | \param void
160 | \return a pointer to a string which describes the version of GPSYCHO.
161 | */
162 | const char *
163 | get_psy_version(void)
164 | {
165 | #if PSY_ALPHA_VERSION > 0
166 | static /*@observer@ */ const char *const str =
167 | STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION)
168 | " (alpha " STR(PSY_ALPHA_VERSION) ", " __DATE__ " " __TIME__ ")";
169 | #elif PSY_BETA_VERSION > 0
170 | static /*@observer@ */ const char *const str =
171 | STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION)
172 | " (beta " STR(PSY_BETA_VERSION) ", " __DATE__ ")";
173 | #else
174 | static /*@observer@ */ const char *const str =
175 | STR(PSY_MAJOR_VERSION) "." STR(PSY_MINOR_VERSION);
176 | #endif
177 |
178 | return str;
179 | }
180 |
181 |
182 | /*! Get the URL for the LAME website. */
183 | /*!
184 | \param void
185 | \return a pointer to a string which is a URL for the LAME website.
186 | */
187 | const char *
188 | get_lame_url(void)
189 | {
190 | static /*@observer@ */ const char *const str = LAME_URL;
191 |
192 | return str;
193 | }
194 |
195 |
196 | /*! Get the numerical representation of the version. */
197 | /*!
198 | Writes the numerical representation of the version of LAME and
199 | GPSYCHO into lvp.
200 |
201 | \param lvp
202 | */
203 | void
204 | get_lame_version_numerical(lame_version_t * lvp)
205 | {
206 | static /*@observer@ */ const char *const features = ""; /* obsolete */
207 |
208 | /* generic version */
209 | lvp->major = LAME_MAJOR_VERSION;
210 | lvp->minor = LAME_MINOR_VERSION;
211 | #if LAME_ALPHA_VERSION
212 | lvp->alpha = LAME_PATCH_VERSION;
213 | lvp->beta = 0;
214 | #elif LAME_BETA_VERSION
215 | lvp->alpha = 0;
216 | lvp->beta = LAME_PATCH_VERSION;
217 | #else
218 | lvp->alpha = 0;
219 | lvp->beta = 0;
220 | #endif
221 |
222 | /* psy version */
223 | lvp->psy_major = PSY_MAJOR_VERSION;
224 | lvp->psy_minor = PSY_MINOR_VERSION;
225 | lvp->psy_alpha = PSY_ALPHA_VERSION;
226 | lvp->psy_beta = PSY_BETA_VERSION;
227 |
228 | /* compile time features */
229 | /*@-mustfree@ */
230 | lvp->features = features;
231 | /*@=mustfree@ */
232 | }
233 |
234 |
235 | const char *
236 | get_lame_os_bitness(void)
237 | {
238 | static /*@observer@ */ const char *const strXX = "";
239 | static /*@observer@ */ const char *const str32 = "32bits";
240 | static /*@observer@ */ const char *const str64 = "64bits";
241 |
242 | switch (sizeof(void *)) {
243 | case 4:
244 | return str32;
245 |
246 | case 8:
247 | return str64;
248 |
249 | default:
250 | return strXX;
251 | }
252 | }
253 |
254 | /* end of version.c */
255 |
--------------------------------------------------------------------------------
/mp3lame/src/main/cpp/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Version numbering for LAME.
3 | *
4 | * Copyright (c) 1999 A.L. Faber
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Library General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Library General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Library General Public
17 | * License along with this library; if not, write to the
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 | * Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #ifndef LAME_VERSION_H
23 | #define LAME_VERSION_H
24 |
25 |
26 | /*
27 | * To make a string from a token, use the # operator:
28 | */
29 | #ifndef STR
30 | # define __STR(x) #x
31 | # define STR(x) __STR(x)
32 | #endif
33 |
34 | # define LAME_URL "http://lame.sf.net"
35 |
36 |
37 | # define LAME_MAJOR_VERSION 3 /* Major version number */
38 | # define LAME_MINOR_VERSION 100 /* Minor version number */
39 | # define LAME_TYPE_VERSION 2 /* 0:alpha 1:beta 2:release */
40 | # define LAME_PATCH_VERSION 0 /* Patch level */
41 | # define LAME_ALPHA_VERSION (LAME_TYPE_VERSION==0)
42 | # define LAME_BETA_VERSION (LAME_TYPE_VERSION==1)
43 | # define LAME_RELEASE_VERSION (LAME_TYPE_VERSION==2)
44 |
45 | # define PSY_MAJOR_VERSION 1 /* Major version number */
46 | # define PSY_MINOR_VERSION 0 /* Minor version number */
47 | # define PSY_ALPHA_VERSION 0 /* Set number if this is an alpha version, otherwise zero */
48 | # define PSY_BETA_VERSION 0 /* Set number if this is a beta version, otherwise zero */
49 |
50 | #if LAME_ALPHA_VERSION
51 | #define LAME_PATCH_LEVEL_STRING " alpha " STR(LAME_PATCH_VERSION)
52 | #endif
53 | #if LAME_BETA_VERSION
54 | #define LAME_PATCH_LEVEL_STRING " beta " STR(LAME_PATCH_VERSION)
55 | #endif
56 | #if LAME_RELEASE_VERSION
57 | #if LAME_PATCH_VERSION
58 | #define LAME_PATCH_LEVEL_STRING " release " STR(LAME_PATCH_VERSION)
59 | #else
60 | #define LAME_PATCH_LEVEL_STRING ""
61 | #endif
62 | #endif
63 |
64 | # define LAME_VERSION_STRING STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) LAME_PATCH_LEVEL_STRING
65 |
66 | #endif /* LAME_VERSION_H */
67 |
68 | /* End of version.h */
69 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion versions.compileSdk
5 |
6 | defaultConfig {
7 | applicationId "io.auxo.ame.sample"
8 | minSdkVersion versions.minSdk
9 | targetSdkVersion versions.compileSdk
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | signingConfig signingConfigs.debug
15 | }
16 |
17 | buildTypes {
18 | debug {
19 | debuggable true
20 | }
21 | release {
22 | debuggable true
23 | minifyEnabled false
24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 |
28 | sourceSets {
29 | main {
30 | jniLibs.srcDirs = [
31 | '../dist/mp3lame/lib',
32 | "../dist/ame/lib",
33 | "../dist/ame-lite/lib"
34 | ]
35 | }
36 | }
37 | }
38 |
39 | dependencies {
40 |
41 | implementation fileTree(include: ['*.jar'], dir: 'libs')
42 |
43 | testImplementation deps.junit
44 | androidTestImplementation deps.test.runner
45 | androidTestImplementation deps.test.espresso
46 |
47 | api deps.support.appcompat
48 |
49 | implementation 'pub.devrel:easypermissions:1.2.0'
50 | implementation 'com.github.warkiz.widget:indicatorseekbar:1.2.9'
51 |
52 | implementation project(':ame')
53 | implementation project(':ame-lite')
54 | }
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sample/src/androidTest/java/io/auxo/ame/sample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package io.auxo.ame.sample;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("io.auxo.ame.sample", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/java/io/auxo/ame/sample/AmeActivity.java:
--------------------------------------------------------------------------------
1 | package io.auxo.ame.sample;
2 |
3 | import android.os.Bundle;
4 | import android.os.Environment;
5 | import android.support.v7.app.ActionBar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.util.Log;
8 |
9 | import io.auxo.ame.Mp3Encoder;
10 |
11 | public class AmeActivity extends AppCompatActivity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_ame);
17 |
18 | ActionBar actionBar = getSupportActionBar();
19 | actionBar.setTitle("Ame");
20 | actionBar.setSubtitle("LAME:" + new Mp3Encoder().getLameVersion());
21 |
22 | new Thread(new Runnable() {
23 | @Override
24 | public void run() {
25 | Mp3Encoder.Callback callback = new Mp3Encoder.Callback() {
26 | @Override
27 | public void onStart() {
28 | Log.i("AmeLiteActivity", "onStart");
29 | }
30 |
31 | @Override
32 | public void onProgress(int total, int current) {
33 | Log.i("AmeLiteActivity", "onProgress: total->" + total + " current->" + current);
34 | }
35 |
36 | @Override
37 | public void onComplete() {
38 | Log.i("AmeLiteActivity", "onComplete");
39 | }
40 |
41 | @Override
42 | public void onError() {
43 | Log.i("AmeLiteActivity", "onError");
44 | }
45 | };
46 | Mp3Encoder.encode(Environment.getExternalStorageDirectory().getAbsolutePath() + "/test.wav",
47 | Environment.getExternalStorageDirectory().getAbsolutePath() + "/test.mp3", callback);
48 | }
49 | }).start();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/sample/src/main/java/io/auxo/ame/sample/AmeLiteActivity.java:
--------------------------------------------------------------------------------
1 | package io.auxo.ame.sample;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.os.Message;
7 | import android.support.v7.app.ActionBar;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.util.Log;
10 | import android.view.View;
11 | import android.widget.Button;
12 | import android.widget.CheckBox;
13 | import android.widget.LinearLayout;
14 | import android.widget.ProgressBar;
15 | import android.widget.RadioGroup;
16 | import android.widget.Toast;
17 |
18 | import com.warkiz.widget.IndicatorSeekBar;
19 |
20 | import java.io.File;
21 |
22 | import io.auxo.ame.lite.Mp3Encoder;
23 |
24 | public class AmeLiteActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener,
25 | View.OnClickListener {
26 |
27 | private final String TAG = "AmeLiteActivity";
28 |
29 | private LinearLayout mBitrateGroup;
30 | private LinearLayout mQualityGroup;
31 |
32 | private RadioGroup mTarget;
33 | private RadioGroup mEngineQuality;
34 | private RadioGroup mVbrMode;
35 |
36 | private CheckBox mMonoEncoding;
37 | private CheckBox mForceCbr;
38 |
39 | private IndicatorSeekBar mBitrate;
40 | private IndicatorSeekBar mVbrQuality;
41 |
42 | private Button mEncode;
43 |
44 | private ProgressBar mProgressBar;
45 |
46 | @Override
47 | protected void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | setContentView(R.layout.activity_ame_lite);
50 |
51 | ActionBar actionBar = getSupportActionBar();
52 | actionBar.setTitle("Ame-Lite");
53 | actionBar.setSubtitle("LAME:" + Mp3Encoder.getLameVersion());
54 |
55 | mBitrateGroup = findViewById(R.id.ame_lite_bitrate_group);
56 | mQualityGroup = findViewById(R.id.ame_lite_vbr_quality_group);
57 |
58 | mTarget = findViewById(R.id.ame_lite_target);
59 | mEngineQuality = findViewById(R.id.ame_lite_engine_quality);
60 | mVbrMode = findViewById(R.id.ame_lite_vbr_mode);
61 |
62 | mMonoEncoding = findViewById(R.id.ame_lite_mono);
63 | mForceCbr = findViewById(R.id.ame_lite_force_cbr);
64 |
65 | mBitrate = findViewById(R.id.ame_lite_bitrate);
66 | mVbrQuality = findViewById(R.id.ame_lite_vbr_quality);
67 |
68 | mEncode = findViewById(R.id.ame_lite_encode);
69 |
70 | mProgressBar = findViewById(R.id.ame_lite_encode_progress_bar);
71 |
72 | mTarget.setOnCheckedChangeListener(this);
73 | mEngineQuality.setOnCheckedChangeListener(this);
74 | mVbrMode.setOnCheckedChangeListener(this);
75 |
76 | mEncode.setOnClickListener(this);
77 |
78 | mProgressBar.setVisibility(View.GONE);
79 | }
80 |
81 | @Override
82 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
83 | super.onActivityResult(requestCode, resultCode, data);
84 | String file = FileChooser.onActivityResult(this, requestCode, resultCode, data);
85 | if (file != null) {
86 | decodeFile(file);
87 | }
88 | }
89 |
90 | @Override
91 | public void onCheckedChanged(RadioGroup group, int checkedId) {
92 | switch (checkedId) {
93 | case R.id.ame_lite_target_bitrate:
94 | mBitrateGroup.setVisibility(View.VISIBLE);
95 | mQualityGroup.setVisibility(View.GONE);
96 | break;
97 | case R.id.ame_lite_target_quality:
98 | mBitrateGroup.setVisibility(View.GONE);
99 | mQualityGroup.setVisibility(View.VISIBLE);
100 | break;
101 | }
102 | }
103 |
104 | @Override
105 | public void onClick(View v) {
106 | switch (v.getId()) {
107 | case R.id.ame_lite_encode:
108 | FileChooser.choose(this, FileChooser.TYPE_AUDIO);
109 | break;
110 | default:
111 | break;
112 | }
113 | }
114 |
115 | protected void decodeFile(final String file) {
116 | File fin = new File(file);
117 | if (fin.exists() && !fin.isDirectory()) {
118 | final String out = file.substring(0, file.lastIndexOf(".")) + ".mp3";
119 | new EncodeThread(file, out).start();
120 | }
121 | }
122 |
123 | protected Mp3Encoder.Options getOptions() {
124 | Mp3Encoder.Options options = new Mp3Encoder.Options();
125 | switch (mEngineQuality.getCheckedRadioButtonId()) {
126 | case R.id.ame_lite_engine_quality_fast:
127 | options.quality(9);
128 | break;
129 | case R.id.ame_lite_engine_quality_standard:
130 | options.quality(5);
131 | break;
132 | case R.id.ame_lite_engine_quality_high:
133 | options.quality(0);
134 | break;
135 | default:
136 | break;
137 | }
138 | if (mMonoEncoding.isChecked()) {
139 | options.mode(Mp3Encoder.Options.MONO);
140 | options.numChannels(1);
141 | }
142 | if (mTarget.getCheckedRadioButtonId() == R.id.ame_lite_target_bitrate) {
143 | options.bitrate(mBitrate.getProgress());
144 | if (mForceCbr.isChecked()) {
145 | options.vbrMode(Mp3Encoder.Options.VBR_OFF);
146 | }
147 | } else {
148 | options.vbrQuality(mVbrQuality.getProgress());
149 | if (mVbrMode.getCheckedRadioButtonId() == R.id.ame_lite_vbr_standard) {
150 | options.vbrQuality(0);
151 | } else if (mVbrMode.getCheckedRadioButtonId() == R.id.ame_lite_vbr_fast) {
152 | options.vbrQuality(9);
153 | }
154 | }
155 | return options;
156 | }
157 |
158 | protected final int MESSAGE_START = 0;
159 | protected final int MESSAGE_PROGRESS = 1;
160 | protected final int MESSAGE_COMPLETE = 2;
161 | protected final int MESSAGE_ERROR = 3;
162 |
163 | protected Handler mEncodeHandler = new Handler() {
164 | @Override
165 | public void handleMessage(Message msg) {
166 | super.handleMessage(msg);
167 | switch (msg.what) {
168 | case MESSAGE_START:
169 | mProgressBar.setVisibility(View.VISIBLE);
170 | mProgressBar.setProgress(0);
171 | mEncode.setEnabled(false);
172 | break;
173 | case MESSAGE_PROGRESS:
174 | mProgressBar.setMax(msg.arg1);
175 | mProgressBar.setProgress(msg.arg2);
176 | mEncode.setText(msg.arg2 / 1000000f + "M/" + msg.arg1 / 1000000f + "M");
177 | break;
178 | case MESSAGE_COMPLETE:
179 | Toast.makeText(getApplicationContext(), "转码完成", Toast.LENGTH_LONG).show();
180 | case MESSAGE_ERROR:
181 | mProgressBar.setVisibility(View.GONE);
182 | mEncode.setEnabled(true);
183 | mEncode.setText("encode file");
184 | break;
185 | default:
186 | break;
187 | }
188 | }
189 | };
190 |
191 | protected class EncodeThread extends Thread implements Mp3Encoder.Callback {
192 |
193 | private String input;
194 | private String output;
195 |
196 | public EncodeThread(String input, String output) {
197 | this.input = input;
198 | this.output = output;
199 | }
200 |
201 | @Override
202 | public void run() {
203 | super.run();
204 | Mp3Encoder.encode(input, output, getOptions(), this);
205 | }
206 |
207 | @Override
208 | public void onStart() {
209 | Log.i(TAG, "onStart");
210 | mEncodeHandler.sendEmptyMessage(MESSAGE_START);
211 | }
212 |
213 | @Override
214 | public void onProgress(final int total, final int current) {
215 | Log.i(TAG, "onProgress total -> " + total + " current -> " + current);
216 | Message msg = mEncodeHandler.obtainMessage(MESSAGE_PROGRESS);
217 | msg.arg1 = total;
218 | msg.arg2 = current;
219 | mEncodeHandler.sendMessage(msg);
220 | }
221 |
222 | @Override
223 | public void onComplete() {
224 | Log.i(TAG, "onComplete");
225 | mEncodeHandler.sendEmptyMessage(MESSAGE_COMPLETE);
226 | }
227 |
228 | @Override
229 | public void onError() {
230 | Log.e(TAG, "onError");
231 | mEncodeHandler.sendEmptyMessage(MESSAGE_ERROR);
232 | }
233 | }
234 |
235 | }
236 |
--------------------------------------------------------------------------------
/sample/src/main/java/io/auxo/ame/sample/FileChooser.java:
--------------------------------------------------------------------------------
1 | package io.auxo.ame.sample;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Activity;
5 | import android.content.ContentUris;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.database.Cursor;
9 | import android.net.Uri;
10 | import android.os.Build;
11 | import android.os.Environment;
12 | import android.provider.DocumentsContract;
13 | import android.provider.MediaStore;
14 |
15 | public class FileChooser {
16 |
17 | protected static int REQUEST_CODE = 1;
18 |
19 | /**
20 | * 选择图片
21 | */
22 | public static final String TYPE_IMAGE = "image/*";
23 | /**
24 | * 选择音频
25 | */
26 | public static final String TYPE_AUDIO = "audio/*";
27 | /**
28 | * 选择视频 (mp4 3gp 是android支持的视频格式)
29 | */
30 | public static final String TYPE_VIDEO = "video/*";
31 | //intent.setType(“video/*;image/*”);//同时选择视频和图片
32 | /**
33 | * 无类型限制
34 | */
35 | public static final String TYPE_ALL = "*/*";
36 |
37 | public static void choose(Activity activity, String type) {
38 | Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
39 | intent.setType(type);
40 | intent.addCategory(Intent.CATEGORY_OPENABLE);
41 | activity.startActivityForResult(intent, REQUEST_CODE);
42 | }
43 |
44 | public static String onActivityResult(Context context, int requestCode, int resultCode, Intent data) {
45 | if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
46 | String path;
47 | Uri uri = data.getData();
48 | if ("file".equalsIgnoreCase(uri.getScheme())) {
49 | //使用第三方应用打开
50 | path = uri.getPath();
51 | return path;
52 | }
53 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
54 | //4.4以后
55 | path = getPath(context, uri);
56 | } else {//4.4以下下系统调用方法
57 | path = getRealPathFromURI(context, uri);
58 | }
59 | return path;
60 | }
61 | return null;
62 | }
63 |
64 | protected static String getRealPathFromURI(Context context, Uri contentUri) {
65 | String res = null;
66 | String[] proj = {MediaStore.Images.Media.DATA};
67 | Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
68 | if (null != cursor && cursor.moveToFirst()) {
69 | ;
70 | int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
71 | res = cursor.getString(column_index);
72 | cursor.close();
73 | }
74 | return res;
75 | }
76 |
77 | @SuppressLint("NewApi")
78 | protected static String getPath(Context context, final Uri uri) {
79 |
80 | final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
81 |
82 | // DocumentProvider
83 | if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
84 | // ExternalStorageProvider
85 | if (isExternalStorageDocument(uri)) {
86 | final String docId = DocumentsContract.getDocumentId(uri);
87 | final String[] split = docId.split(":");
88 | final String type = split[0];
89 |
90 | if ("primary".equalsIgnoreCase(type)) {
91 | return Environment.getExternalStorageDirectory() + "/" + split[1];
92 | }
93 | }
94 | // DownloadsProvider
95 | else if (isDownloadsDocument(uri)) {
96 |
97 | final String id = DocumentsContract.getDocumentId(uri);
98 | final Uri contentUri = ContentUris.withAppendedId(
99 | Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
100 |
101 | return getDataColumn(context, contentUri, null, null);
102 | }
103 | // MediaProvider
104 | else if (isMediaDocument(uri)) {
105 | final String docId = DocumentsContract.getDocumentId(uri);
106 | final String[] split = docId.split(":");
107 | final String type = split[0];
108 |
109 | Uri contentUri = null;
110 | if ("image".equals(type)) {
111 | contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
112 | } else if ("video".equals(type)) {
113 | contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
114 | } else if ("audio".equals(type)) {
115 | contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
116 | }
117 |
118 | final String selection = "_id=?";
119 | final String[] selectionArgs = new String[]{split[1]};
120 |
121 | return getDataColumn(context, contentUri, selection, selectionArgs);
122 | }
123 | }
124 | // MediaStore (and general)
125 | else if ("content".equalsIgnoreCase(uri.getScheme())) {
126 | return getDataColumn(context, uri, null, null);
127 | }
128 | // File
129 | else if ("file".equalsIgnoreCase(uri.getScheme())) {
130 | return uri.getPath();
131 | }
132 | return null;
133 | }
134 |
135 | protected static String getDataColumn(Context context, Uri uri, String selection,
136 | String[] selectionArgs) {
137 |
138 | Cursor cursor = null;
139 | final String column = "_data";
140 | final String[] projection = {column};
141 |
142 | try {
143 | cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
144 | null);
145 | if (cursor != null && cursor.moveToFirst()) {
146 | final int column_index = cursor.getColumnIndexOrThrow(column);
147 | return cursor.getString(column_index);
148 | }
149 | } finally {
150 | if (cursor != null) {
151 | cursor.close();
152 | }
153 | }
154 | return null;
155 | }
156 |
157 | protected static boolean isExternalStorageDocument(Uri uri) {
158 | return "com.android.externalstorage.documents".equals(uri.getAuthority());
159 | }
160 |
161 | protected static boolean isDownloadsDocument(Uri uri) {
162 | return "com.android.providers.downloads.documents".equals(uri.getAuthority());
163 | }
164 |
165 | protected static boolean isMediaDocument(Uri uri) {
166 | return "com.android.providers.media.documents".equals(uri.getAuthority());
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/sample/src/main/java/io/auxo/ame/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package io.auxo.ame.sample;
2 |
3 | import android.Manifest;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.Button;
9 |
10 | import pub.devrel.easypermissions.AfterPermissionGranted;
11 | import pub.devrel.easypermissions.EasyPermissions;
12 |
13 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
14 |
15 | protected final int REQUEST_PERMISSIONS = 1;
16 |
17 | private Button mAmeLite;
18 | private Button mAme;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_main);
24 |
25 | mAmeLite = findViewById(R.id.main_ame_lite);
26 | mAme = findViewById(R.id.main_ame);
27 |
28 | mAmeLite.setOnClickListener(this);
29 | mAme.setOnClickListener(this);
30 |
31 | requestPermissions();
32 | }
33 |
34 | @AfterPermissionGranted(REQUEST_PERMISSIONS)
35 | protected void requestPermissions() {
36 | String[] perms = {Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
37 | if (EasyPermissions.hasPermissions(this, perms)) {
38 | mAme.setEnabled(true);
39 | mAmeLite.setEnabled(true);
40 | } else {
41 | EasyPermissions.requestPermissions(this, "Mp3 Encoder需要读写权限",
42 | REQUEST_PERMISSIONS, perms);
43 | mAme.setEnabled(false);
44 | mAmeLite.setEnabled(false);
45 | }
46 | }
47 |
48 | @Override
49 | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
50 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
51 | EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
52 | }
53 |
54 | @Override
55 | public void onClick(View v) {
56 | switch (v.getId()) {
57 | case R.id.main_ame_lite:
58 | startActivity(new Intent(this, AmeLiteActivity.class));
59 | break;
60 | case R.id.main_ame:
61 | startActivity(new Intent(this, AmeActivity.class));
62 | break;
63 | default:
64 | break;
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_ame.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4332weizi/AME/e6823c837ead9e6e71e2b8a844fdefb6770d7e91/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AME
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/test/java/io/auxo/ame/sample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package io.auxo.ame.sample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':mp3lame', ':ame', ':ame-lite'
--------------------------------------------------------------------------------