├── .gitignore
├── README.md
├── app
├── .gitignore
├── CMakeLists.txt
├── build.gradle
├── key02.keystore
├── proguard-rules.pro
├── src
│ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── convert
│ │ │ └── mymp3convert
│ │ │ └── ExampleInstrumentedTest.java
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── convert
│ │ │ │ └── mymp3convert
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── MainActivity2.kt
│ │ │ │ ├── Mp3ConvertUtil.class
│ │ │ │ ├── Mp3ConvertUtil.java
│ │ │ │ ├── Mp3ConvertUtilHelper.java
│ │ │ │ ├── MyTest.class
│ │ │ │ ├── MyTest.java
│ │ │ │ └── test
│ │ │ │ └── Demo.java
│ │ ├── jni
│ │ │ ├── NativeMp3ConvertUtil.cpp
│ │ │ ├── NativeMp3ConvertUtil.cpp.bak
│ │ │ ├── NativeMp3ConvertUtil.h
│ │ │ ├── NativeMyTest.cpp
│ │ │ ├── com_convert_mymp3convert_Mp3ConvertUtil.h
│ │ │ ├── com_convert_mymp3convert_MyTest.h
│ │ │ └── libmp3lame
│ │ │ │ ├── VbrTag.c
│ │ │ │ ├── VbrTag.h
│ │ │ │ ├── bitstream.c
│ │ │ │ ├── bitstream.h
│ │ │ │ ├── encoder.c
│ │ │ │ ├── encoder.h
│ │ │ │ ├── fft.c
│ │ │ │ ├── fft.h
│ │ │ │ ├── gain_analysis.c
│ │ │ │ ├── gain_analysis.h
│ │ │ │ ├── id3tag.c
│ │ │ │ ├── id3tag.h
│ │ │ │ ├── l3side.h
│ │ │ │ ├── lame-analysis.h
│ │ │ │ ├── lame.c
│ │ │ │ ├── lame.h
│ │ │ │ ├── lame_global_flags.h
│ │ │ │ ├── lameerror.h
│ │ │ │ ├── machine.h
│ │ │ │ ├── mpglib_interface.c
│ │ │ │ ├── newmdct.c
│ │ │ │ ├── newmdct.h
│ │ │ │ ├── presets.c
│ │ │ │ ├── psymodel.c
│ │ │ │ ├── psymodel.h
│ │ │ │ ├── quantize.c
│ │ │ │ ├── quantize.h
│ │ │ │ ├── quantize_pvt.c
│ │ │ │ ├── quantize_pvt.h
│ │ │ │ ├── reservoir.c
│ │ │ │ ├── reservoir.h
│ │ │ │ ├── set_get.c
│ │ │ │ ├── set_get.h
│ │ │ │ ├── tables.c
│ │ │ │ ├── tables.h
│ │ │ │ ├── takehiro.c
│ │ │ │ ├── util.c
│ │ │ │ ├── util.h
│ │ │ │ ├── vbrquantize.c
│ │ │ │ ├── vbrquantize.h
│ │ │ │ ├── version.c
│ │ │ │ └── version.h
│ │ ├── library
│ │ │ └── AndroidManifest.xml
│ │ └── res
│ │ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── drawable
│ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout
│ │ │ ├── activity_main.xml
│ │ │ └── activity_main2.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── values-night
│ │ │ └── themes.xml
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── themes.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── convert
│ │ └── mymp3convert
│ │ └── ExampleUnitTest.java
└── 说明 .txt
├── build.gradle
├── demo
├── .gitignore
├── build.gradle
├── libs
│ └── app-release.aar
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── convert
│ │ └── demo
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── convert
│ │ │ └── demo
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── convert
│ └── demo
│ └── ExampleUnitTest.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | .idea/
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | .cxx
10 | local.properties
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MyMp3Convert
2 | mp3Convert
3 | 一个mp3转换库,基于lame3来实现
4 |
5 | 模块简介:
6 | ================================================
7 | 主要实现了wav格式向mp3格式的转投;
8 | 只需要关注3个方法就好;
9 | 为了项目简单直观实用,节省代码空间,本模块遵循单一职责原则,只做格式转换,把wav格式音频转换成mp3格式
10 |
11 | 使用场景:
12 | ================================================
13 | 用于在客户端需要把编辑好的wav转换成mp3格式,这样可以在不过大损失音频效果的同时有效节省空间,通常情况下,10M大小的wav文件通过转换后可以生成1M大小的mp3文件;
14 | 比如:用户在客户端录制好pcm音频文件,并由该文件编辑得到了可播放的wav文件,又需要把wav文件上传服务器,或者存在本地,但是wav文件过大,需要占用过大网络,在增加耗电量的同时,也给了服务器带来了压力,这个时候可以把文件转换成mp3格式文件(至于pcm到wav格式的转换,wav文件的编辑、剪切、拼接、混音合成可以使用另一模块来实现 链接:https://github.com/fanyuan/AudioUtil )
15 |
16 |
17 | 使用:
18 | ================================================
19 | 只需要调用Mp3ConvertUtilHelper里的3个公开方法即可;
20 | 使用很简单,只要把本module下载后以Android studio导入工程项目,设为library估其他module依赖就好
21 | 对于和native c语言的交互已在Mp3ConvertUtil中封装好,采用了外观模式;
22 | 使用时只需要调用Mp3ConvertUtilHelper类的相3个关公开方法
23 |
24 | =====================华丽丽的分割线========================
25 |
26 | 3个相关方法如下:
27 | ================================================
28 |
29 | /**
30 | * wav转换成mp3
31 | * @param wavInPath 需要转换的wav源文件输入路径
32 | * @param mp3OutPath 转换完成后的mp3目标文件输出路径
33 | */
34 | public static void convertmp3(String wavInPath, String mp3OutPath)
35 |
36 | /**
37 | * wav转换成mp3
38 | * @param wavInPath 需要转换的wav源文件输入路径
39 | * @param mp3OutPath 转换完成后的mp3目标文件输出路径
40 | * @param callback 转换相关的回调
41 | */
42 | public static void convertmp3(String wavInPath, String mp3OutPath, Mp3ConvertUtil.ConvertListener callback)}
43 |
44 | /**
45 | * 获取转换进度
46 | * @param outPath 在多个任务并行时以输出路径为token来查询相关转换文件的转换进度
47 | * @return
48 | */
49 | public static int getProgress(String outPath)
50 |
51 | =====================华丽丽的分割线==========================
52 |
53 | 使用示例如下:
54 |
55 | 温馨提示:使用时请在子线程中使用,为了演示方便直观就不过多封装了
56 |
57 | 不带转换回调的使用示例:
58 | ================================================
59 | new Thread(){
60 | @Override
61 | public void run() {
62 |
63 | String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/姑娘我爱你convert.wav";//"temp/test123.wav";
64 | String pathTaret = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/姑娘我爱你out123.mp3";
65 | Mp3ConvertUtilHelper.convertmp3(path,pathTaret);
66 |
67 | }
68 | }.start();
69 |
70 | 不带回调的获取转换进度的方式:
71 | ================================================
72 | String pathTaret = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/姑娘我爱你out123.mp3";
73 |
74 | int progress = Mp3ConvertUtilHelper.getProgress(pathTaret);
75 |
76 | 带转换回调的使用示例:
77 | ================================================
78 | new Thread(){
79 | @Override
80 | public void run() {
81 |
82 | String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/out测试.wav";//"temp/test123.wav";
83 | String pathTaret = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/out测试789.mp3";
84 | Mp3ConvertUtilHelper.convertmp3(path, pathTaret, new Mp3ConvertUtil.ConvertListener() {
85 | @Override
86 | public void notifyConvertProgress(int progress) {
87 | Log.d("ddebug","convertByHelper02 --- notifyConvertProgress = " + progress);
88 | }
89 |
90 | @Override
91 | public void convertFinish() {
92 | Log.d("ddebug","convertByHelper02 --- convertFinish");
93 | }
94 |
95 | @Override
96 | public void convertError(String errorMsg) {
97 | Log.d("ddebug","convertByHelper02 --- convertError --- " + errorMsg);
98 | }
99 | });
100 |
101 |
102 | }
103 |
104 | }.start();
105 |
106 |
107 |
108 | 简单实用^_^
109 |
110 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | #指定CMake构建本地库时所需的最小版本
3 | cmake_minimum_required(VERSION 3.4.1)
4 |
5 | #该变量为真时会创建完整版本的Makefile
6 | set(CMAKE_VERBOSE_MAKEFILE on)
7 | set(LAME_LIBMP3_DIR ${CMAKE_SOURCE_DIR}/src/main/jni/libmp3lame)
8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLOGTEST")
9 | include_directories(${CMAKE_SOURCE_DIR}/src/main/jni/libmp3lame)
10 | include_directories(${CMAKE_SOURCE_DIR}/src/main/jni)
11 |
12 | include_directories(E/work/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include)
13 | add_library( # Sets the name of the library. 将资源文件生成动态链接库(so文件)的库名称(文件名称:“lib" +设置的名称)
14 | hello
15 |
16 | # Sets the library as a shared library.
17 | SHARED
18 |
19 | # Provides a relative path to your source file(s).资源文件(C或C++)的相对位置
20 | src/main/jni/NativeMp3ConvertUtil.cpp
21 | src/main/jni/NativeMyTest.cpp)
22 | # 这里用来添加一个库
23 | add_library(# 这里设置so库的名称为native-lib
24 | libmp3lame
25 | # 这里设置该库为共享
26 | SHARED
27 | #源码文件
28 | ${LAME_LIBMP3_DIR}/bitstream.c
29 | ${LAME_LIBMP3_DIR}/encoder.c
30 | ${LAME_LIBMP3_DIR}/fft.c
31 | ${LAME_LIBMP3_DIR}/gain_analysis.c
32 | ${LAME_LIBMP3_DIR}/id3tag.c
33 | ${LAME_LIBMP3_DIR}/lame.c
34 | ${LAME_LIBMP3_DIR}/mpglib_interface.c
35 | ${LAME_LIBMP3_DIR}/newmdct.c
36 | ${LAME_LIBMP3_DIR}/presets.c
37 | ${LAME_LIBMP3_DIR}/psymodel.c
38 | ${LAME_LIBMP3_DIR}/quantize.c
39 | ${LAME_LIBMP3_DIR}/quantize_pvt.c
40 | ${LAME_LIBMP3_DIR}/reservoir.c
41 | ${LAME_LIBMP3_DIR}/set_get.c
42 | ${LAME_LIBMP3_DIR}/tables.c
43 | ${LAME_LIBMP3_DIR}/takehiro.c
44 | ${LAME_LIBMP3_DIR}/util.c
45 | ${LAME_LIBMP3_DIR}/vbrquantize.c
46 | ${LAME_LIBMP3_DIR}/VbrTag.c
47 | ${LAME_LIBMP3_DIR}/version.c
48 | )
49 | find_library( # Sets the name of the path variable.
50 | log-lib
51 |
52 | # Specifies the name of the NDK library that
53 | # you want CMake to locate.
54 | log )
55 |
56 | target_link_libraries( # Specifies the target library.将所有的add_library中的库链接起来,有多少个add_library成的库就将其添加到这里
57 | hello #这个和add_library中的指定的so库名称一致
58 | libmp3lame
59 | # Links the target library to the log library
60 | # included in the NDK.
61 | ${log-lib} )
62 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | //plugins {
2 | // id 'com.android.application'
3 | //}
4 | if(isAppLibrary.toBoolean()){
5 | apply plugin: 'com.android.library'
6 | }else {
7 | apply plugin: 'com.android.application'
8 | }
9 | apply plugin: 'kotlin-android'
10 | android {
11 | externalNativeBuild { cmake { version "3.10.2" } }
12 | compileSdkVersion 30
13 | buildToolsVersion "30.0.3"
14 |
15 | defaultConfig {
16 |
17 | if(!isAppLibrary.toBoolean()){
18 | applicationId "com.convert.mymp3convert"
19 | }
20 |
21 | minSdkVersion 18
22 | targetSdkVersion 30
23 | versionCode 1
24 | versionName "1.0"
25 |
26 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
27 | externalNativeBuild {
28 | cmake {
29 | // 指定一些编译选项
30 | cppFlags "-std=c++11 -frtti -fexceptions"
31 | cFlags "-DSTDC_HEADERS"
32 | abiFilters 'armeabi-v7a','arm64-v8a','x86'//'armeabi',
33 | }
34 | }
35 | ndk{
36 | //moduleName"hello" //生成的so文件名字,调用C程序的代码中会用到该名字
37 | abiFilters 'armeabi-v7a','arm64-v8a' , 'x86'//,'arm64-v8a', 'x86_64'//'armeabi',
38 | }
39 | signingConfigs {
40 | release {
41 | storeFile file("key02.keystore")
42 | storePassword "1qazxsw2"
43 | keyAlias "key02"
44 | keyPassword "1qazxsw2"
45 | v1SigningEnabled true
46 | v2SigningEnabled true
47 | }
48 | }
49 | }
50 | externalNativeBuild {
51 | cmake {
52 | path "CMakeLists.txt"
53 | }
54 | }
55 | signingConfigs {
56 | dev {
57 | storeFile file('E:\\work\\keyStore\\demo\\key02.keystore')
58 | storePassword '1qazxsw2'
59 | keyAlias 'key02'
60 | keyPassword '1qazxsw2'
61 | }
62 | }
63 | sourceSets{
64 | main{
65 | if(isAppLibrary.toBoolean()){
66 | manifest.srcFile 'src/main/library/AndroidManifest.xml'
67 | }else {
68 | manifest.srcFile 'src/main/AndroidManifest.xml'
69 | }
70 |
71 | }
72 | }
73 | buildTypes {
74 | release {
75 | minifyEnabled false
76 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
77 | jniDebuggable true
78 | signingConfig signingConfigs.release
79 | }
80 | dev {
81 | minifyEnabled false
82 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
83 | jniDebuggable true
84 | debuggable true
85 | signingConfig signingConfigs.release
86 | }
87 | }
88 | compileOptions {
89 | sourceCompatibility JavaVersion.VERSION_1_8
90 | targetCompatibility JavaVersion.VERSION_1_8
91 | }
92 | }
93 |
94 | dependencies {
95 |
96 | implementation 'androidx.appcompat:appcompat:1.2.0'
97 | implementation 'com.google.android.material:material:1.2.1'
98 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
99 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
100 | testImplementation 'junit:junit:4.+'
101 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
102 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
103 | }
--------------------------------------------------------------------------------
/app/key02.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/key02.keystore
--------------------------------------------------------------------------------
/app/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
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/convert/mymp3convert/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.convert.mymp3convert;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.convert.mymp3convert", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/convert/mymp3convert/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.convert.mymp3convert;
2 |
3 | import android.Manifest;
4 | import android.os.Bundle;
5 | import android.os.Environment;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.TextView;
9 |
10 | import androidx.appcompat.app.AppCompatActivity;
11 | import androidx.core.app.ActivityCompat;
12 |
13 | import java.io.File;
14 |
15 | public class MainActivity extends AppCompatActivity {
16 |
17 | TextView tv;
18 | String [] perms = {Manifest.permission.MODIFY_AUDIO_SETTINGS,Manifest.permission.RECORD_AUDIO,
19 | Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE};
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_main);
24 | tv = findViewById(R.id.tv);
25 | String msg = Mp3ConvertUtil.hello("test");
26 | tv.setText(msg);
27 | Log.d("ddebug","hello jni = " + msg);
28 |
29 | ActivityCompat.requestPermissions(this, perms, 123);
30 | }
31 | public void test(View v){
32 | String str = MyTest.test();
33 | tv.append("\n"+str);
34 | Log.d("ddebug","test str = " + "str" + "----" + Mp3ConvertUtil.getLameVer());
35 | //Mp3ConvertUtil.convertmp3("test.wav","demo.mp3");
36 | }
37 | public void convert(View v){
38 | String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/out.wav";//"temp/test123.wav";
39 | String pathTaret = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/out123.mp3";
40 | Mp3ConvertUtil.convertmp3(path,pathTaret);
41 | }
42 | public void convertByHelper01(View v){
43 | // String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/out.wav";//"temp/test123.wav";
44 | // String pathTaret = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/out456.mp3";
45 | // Mp3ConvertUtilHelper.convertmp3(path,pathTaret);
46 |
47 | new Thread(){
48 | @Override
49 | public void run() {
50 |
51 | String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/姑娘我爱你convert.wav";//"temp/test123.wav";
52 | String pathTaret = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/姑娘我爱你out123.mp3";
53 | Mp3ConvertUtilHelper.convertmp3(path,pathTaret);
54 |
55 | }
56 | }.start();
57 | }
58 | public void convertByHelper02(View v){
59 | new Thread(){
60 | @Override
61 | public void run() {
62 |
63 | String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/out测试.wav";//"temp/test123.wav";
64 | String pathTaret = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp/out测试789.mp3";
65 | Mp3ConvertUtilHelper.convertmp3(path, pathTaret, new Mp3ConvertUtil.ConvertListener() {
66 | @Override
67 | public void notifyConvertProgress(int progress) {
68 | Log.d("ddebug","convertByHelper02 --- notifyConvertProgress = " + progress);
69 | }
70 |
71 | @Override
72 | public void convertFinish() {
73 | Log.d("ddebug","convertByHelper02 --- convertFinish");
74 | }
75 |
76 | @Override
77 | public void convertError(String errorMsg) {
78 | Log.d("ddebug","convertByHelper02 --- convertError --- " + errorMsg);
79 | }
80 | });
81 |
82 | }
83 | }.start();
84 |
85 | }
86 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/convert/mymp3convert/MainActivity2.kt:
--------------------------------------------------------------------------------
1 | package com.convert.mymp3convert
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 |
6 | class MainActivity2 : AppCompatActivity() {
7 | override fun onCreate(savedInstanceState: Bundle?) {
8 | super.onCreate(savedInstanceState)
9 | setContentView(R.layout.activity_main2)
10 | }
11 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/convert/mymp3convert/Mp3ConvertUtil.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/java/com/convert/mymp3convert/Mp3ConvertUtil.class
--------------------------------------------------------------------------------
/app/src/main/java/com/convert/mymp3convert/Mp3ConvertUtil.java:
--------------------------------------------------------------------------------
1 | package com.convert.mymp3convert;
2 |
3 | import android.util.Log;
4 |
5 | import java.util.concurrent.ConcurrentHashMap;
6 |
7 | public class Mp3ConvertUtil {
8 | static {
9 | System.loadLibrary("hello");
10 | System.loadLibrary("libmp3lame");
11 | }
12 |
13 | public static native String hello(String msg);
14 | /**
15 | * 获取LAME的版本信息
16 | *
17 | * @return
18 | */
19 | public static native String getLameVer();
20 | /**
21 | * wav转换成mp3的本地方法
22 | *
23 | * @param wav
24 | * @param mp3
25 | */
26 | public static native void convertmp3(String wav, String mp3);
27 |
28 | /**
29 | * 转换接口回调
30 | */
31 | public interface ConvertListener{
32 | public void notifyConvertProgress(int progress);
33 | /**
34 | * 转换完成回调
35 | */
36 | public void convertFinish();
37 |
38 | /**
39 | * 转换完成回调
40 | * @param errorMsg
41 | */
42 | public void convertError(String errorMsg);
43 | }
44 |
45 | /**
46 | * 提供的一个空实现
47 | */
48 | public static class SimpleConvertListener implements ConvertListener{
49 |
50 | @Override
51 | public void notifyConvertProgress(int progress) {
52 |
53 | }
54 |
55 | @Override
56 | public void convertFinish() {
57 |
58 | }
59 |
60 | @Override
61 | public void convertError(String errorMsg) {
62 |
63 | }
64 | }
65 | /**
66 | * 保存进度的地方
67 | */
68 | static ConcurrentHashMap mConvertCallbacks;
69 | /**
70 | * 保存进度的地方
71 | */
72 | static ConcurrentHashMap mProgresses;
73 |
74 |
75 | /**
76 | * 注册转换回调类
77 | * @param mp3TargetPath
78 | * @param callback
79 | */
80 | protected static void registerCallback(String mp3TargetPath,ConvertListener callback){
81 | if(mConvertCallbacks == null){
82 | mConvertCallbacks = new ConcurrentHashMap();
83 | }
84 | mConvertCallbacks.put(mp3TargetPath,callback);
85 | }
86 |
87 | /**
88 | * 移除转换回调类
89 | * @param mp3TargetPath
90 | */
91 | private static void removeCallback(String mp3TargetPath){
92 | if(mConvertCallbacks == null){
93 | return;
94 | }
95 | if(mConvertCallbacks.containsKey(mp3TargetPath)){
96 | mConvertCallbacks.remove(mp3TargetPath);
97 | }
98 | }
99 | /**
100 | * 设置进度的方法
101 | * @param outPath
102 | */
103 | private static void setProgress(String outPath,int progress){
104 | if(mProgresses == null){
105 | mProgresses = new ConcurrentHashMap();
106 | }
107 | mProgresses.put(outPath,progress);
108 | Log.d("ddebug","---setProgress---" + outPath + "=" + progress);
109 | }
110 | /**
111 | * 获取进度的方法
112 | * @param outPath
113 | * @return
114 | */
115 | protected static int getProgress(String outPath){
116 | if(mProgresses == null){
117 | return -1;
118 | }
119 | if(!mProgresses.containsKey(outPath)){
120 | return -1;
121 | }
122 | int progress = mProgresses.get(outPath);
123 | Log.d("ddebug","---getProgress---" + outPath + "=" + progress);
124 | return progress;
125 | }
126 |
127 | /**
128 | * 移除相关进度条目的方法
129 | *
130 | * @param outPath
131 | */
132 | private static void removeProgress(String outPath){
133 | if(mProgresses == null){
134 | return;
135 | }
136 | mProgresses.remove(outPath);
137 | Log.d("ddebug","---removeProgress---" + outPath);
138 | }
139 | /**
140 | * 日志打印方法,提供给C语言调用
141 | *
142 | * @param
143 | */
144 | public static void nativeLog(String logTag,String logMsg) {
145 | Log.d(logTag,"java nativeLog:" + logMsg);
146 | }
147 | /**
148 | * 设置进度条的进度,提供给C语言调用
149 | *
150 | * @param progress
151 | */
152 | public static void setConvertProgress(int progress,String outPath) {
153 | setProgress(outPath,progress);
154 | if(mConvertCallbacks == null){
155 | mConvertCallbacks = new ConcurrentHashMap();
156 | }
157 | if(mConvertCallbacks.containsKey(outPath)){
158 | mConvertCallbacks.get(outPath).notifyConvertProgress(progress);
159 | }
160 | Log.d("ddebug","转换进度为:"+ progress);
161 | }
162 | /**
163 | * 转换完成回调,提供给C语言调用
164 | *
165 | * @param outPath
166 | */
167 | public static void convertFinish(String outPath) {
168 | removeProgress(outPath);
169 | if(mConvertCallbacks == null){
170 | return;
171 | }
172 | if(mConvertCallbacks.containsKey(outPath)){
173 | mConvertCallbacks.get(outPath).convertFinish();
174 | removeCallback(outPath);
175 | }
176 | Log.d("ddebug","转换完成 convertFinish:"+ outPath);
177 | }
178 | /**
179 | * 转换完成回调,提供给C语言调用
180 | *
181 | * @param outPath
182 | */
183 | public static void convertError(String errorMsg,String outPath) {
184 | removeProgress(outPath);
185 |
186 | if(mConvertCallbacks == null){
187 | return;
188 | }
189 | if(mConvertCallbacks.containsKey(outPath)){
190 | mConvertCallbacks.get(outPath).convertError(errorMsg);
191 | removeCallback(outPath);
192 | }
193 | Log.d("ddebug","java convertError:" + errorMsg + " --- " + outPath);
194 | }
195 |
196 | }
197 |
--------------------------------------------------------------------------------
/app/src/main/java/com/convert/mymp3convert/Mp3ConvertUtilHelper.java:
--------------------------------------------------------------------------------
1 | package com.convert.mymp3convert;
2 |
3 | public class Mp3ConvertUtilHelper {
4 | /**
5 | * 获取版本号
6 | * @return
7 | */
8 | public static String getVer(){
9 | return Mp3ConvertUtil.getLameVer();
10 | }
11 |
12 | /**
13 | * wav转换成mp3
14 | * @param wavInPath 需要转换的wav源文件输入路径
15 | * @param mp3OutPath 转换完成后的mp3目标文件输出路径
16 | */
17 | public static void convertmp3(String wavInPath, String mp3OutPath){
18 | Mp3ConvertUtil.convertmp3(wavInPath,mp3OutPath);
19 | }
20 |
21 | /**
22 | * wav转换成mp3
23 | * @param wavInPath 需要转换的wav源文件输入路径
24 | * @param mp3OutPath 转换完成后的mp3目标文件输出路径
25 | * @param callback 转换相关的回调
26 | */
27 | public static void convertmp3(String wavInPath, String mp3OutPath, Mp3ConvertUtil.ConvertListener callback){
28 | Mp3ConvertUtil.registerCallback(mp3OutPath,callback);
29 | Mp3ConvertUtil.convertmp3(wavInPath,mp3OutPath);
30 | }
31 | /**
32 | * 获取转换进度
33 | * @param outPath 在多个任务并行时以输出路径为token来查询相关转换文件的转换进度
34 | * @return
35 | */
36 | public static int getProgress(String outPath){
37 | return Mp3ConvertUtil.getProgress(outPath);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/convert/mymp3convert/MyTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/java/com/convert/mymp3convert/MyTest.class
--------------------------------------------------------------------------------
/app/src/main/java/com/convert/mymp3convert/MyTest.java:
--------------------------------------------------------------------------------
1 | package com.convert.mymp3convert;
2 |
3 | public class MyTest {
4 | public static native String test();
5 | }
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/convert/mymp3convert/test/Demo.java:
--------------------------------------------------------------------------------
1 | package com.convert.mymp3convert.test;
2 |
3 | import com.convert.mymp3convert.Mp3ConvertUtil;
4 |
5 | public class Demo {
6 | private void test(){
7 | //Mp3ConvertUtil.registerCallback("",null);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/jni/NativeMp3ConvertUtil.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by shaomingfa on 2021/1/14.
3 | //
4 |
5 | #include
6 | #include "libmp3lame/lame.h"
7 |
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include "libmp3lame/lame.h"
15 | #include
16 | #include
17 | #include
18 |
19 |
20 | #include "NativeMp3ConvertUtil.h"
21 | #include "com_convert_mymp3convert_Mp3ConvertUtil.h"
22 | #define LOG_TAG "System.out.c"
23 | /**
24 | * 日志打印tag
25 | */
26 | #define CONVERT_LOG_TAG "nativeTag"
27 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
28 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
29 |
30 |
31 |
32 | #ifndef com_convert_mymp3convert_Mp3ConvertUtil
33 | #define com_convert_mymp3convert_Mp3ConvertUtil
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | /**
39 | * 返回值 char* 这个代表char数组的首地址
40 | * Jstring2CStr 把java中的jstring的类型转化成一个c语言中的char 字符串
41 | */
42 | char* Jstring2CStr(JNIEnv *env, jstring jstr) {
43 | char* rtn = NULL;
44 | jclass clsstring = (*env).FindClass( "java/lang/String"); //String
45 | jstring strencode = (*env).NewStringUTF( "GB2312"); // 得到一个java字符串 "GB2312"
46 | jmethodID mid = (*env).GetMethodID(clsstring, "getBytes",
47 | "(Ljava/lang/String;)[B"); //[ String.getBytes("gb2312");
48 | jbyteArray barr = (jbyteArray)(*env).CallObjectMethod(jstr, mid,
49 | strencode); // String .getByte("GB2312");
50 | jsize alen = (*env).GetArrayLength( barr); // byte数组的长度
51 | jbyte* ba = (*env).GetByteArrayElements( barr, JNI_FALSE);
52 | if (alen > 0) {
53 | rtn = (char*) malloc(alen + 1); //"\0"
54 | memcpy(rtn, ba, alen);
55 | rtn[alen] = 0;
56 | }
57 | (*env).ReleaseByteArrayElements(barr, ba, 0); //
58 | (*env).DeleteLocalRef(strencode);
59 | return rtn;
60 | }
61 | /**==============================================================================================================================================*/
62 | /**
63 | * 调用java代码 更新程序的进度条
64 | */
65 | void publishJavaProgress(JNIEnv * env, jobject obj, jint progress,jstring outPath) {
66 | //1.找到java的LameUtils的class com/example/myjnidemo/
67 | jclass clazz = (*env).FindClass("com/convert/mymp3convert/Mp3ConvertUtil");
68 | if (clazz == 0) {
69 | LOGI("can't find clazz");
70 | return;
71 | }
72 | LOGI(" convert progress %d" , progress);
73 |
74 | //2 找到class 里面的方法定义
75 |
76 | jmethodID methodid = (*env).GetStaticMethodID(clazz,"setConvertProgress","(ILjava/lang/String;)V");//jmethodID methodid = (*env).GetMethodID(clazz, "setConvertProgress","(I)V");
77 | if (methodid == 0) {
78 | LOGI("can't find methodid");
79 | return;
80 | }
81 | LOGI(" find methodid");
82 |
83 | //3 .调用方法
84 | (*env).CallStaticVoidMethod(clazz, methodid, progress,outPath);//(*env).CallVoidMethod(obj, methodid, progress);
85 | //env -> CallVoidMethod(obj,methodid,progress);
86 | env->DeleteLocalRef(clazz);
87 | //env->DeleteLocalRef(methodid);
88 | }
89 | /**
90 | * 调用java代码 更新程序的进度条
91 | */
92 | void convertFinish(JNIEnv * env, jstring mp3Path) {
93 | //1.找到java的LameUtils的class com/example/myjnidemo/
94 | jclass clazz = (*env).FindClass("com/convert/mymp3convert/Mp3ConvertUtil");
95 | if (clazz == 0) {
96 | LOGI("can't find clazz");
97 | return;
98 | }
99 | const char *c = env->GetStringUTFChars(mp3Path, JNI_FALSE);
100 | LOGI(" convert finished %s" , c);
101 | env->ReleaseStringUTFChars(mp3Path,c);
102 |
103 | //2 找到class 里面的方法定义
104 | jmethodID methodid = (*env).GetStaticMethodID(clazz,"convertFinish","(Ljava/lang/String;)V");
105 | if (methodid == 0) {
106 | LOGI("can't find methodid");
107 | return;
108 | }
109 | LOGI(" find convertFinish methodid");
110 |
111 | //3 .调用方法
112 | env -> CallStaticVoidMethod(clazz,methodid,mp3Path);
113 | env->DeleteLocalRef(clazz);
114 | }
115 | /**
116 | * 调用java代码 转换失败时调用
117 | */
118 | void convertError(JNIEnv * env,jstring msg,jstring mp3Path) {
119 | //1.找到java的LameUtils的class com/example/myjnidemo/
120 | jclass clazz = (*env).FindClass("com/convert/mymp3convert/Mp3ConvertUtil");
121 | if (clazz == 0) {
122 | LOGI("can't find clazz");
123 | return;
124 | }
125 |
126 | const char *c = (*env).GetStringUTFChars(mp3Path, JNI_FALSE);
127 | LOGI(" convert error %s" , c);
128 | (*env).ReleaseStringUTFChars(mp3Path,c);
129 |
130 | //2 找到class 里面的方法定义
131 |
132 | jmethodID methodid = (*env).GetStaticMethodID(clazz,"convertError",
133 | "(Ljava/lang/String;Ljava/lang/String;)V");
134 | if (methodid == 0) {
135 | LOGI("can't find methodid");
136 | return;
137 | }
138 | LOGI(" find methodid");
139 |
140 | //3 .调用方法
141 | env -> CallStaticVoidMethod(clazz,methodid,msg,mp3Path);
142 | env->DeleteLocalRef(clazz);
143 | }
144 | /**
145 | * 调用java代码 打印日志时调用
146 | */
147 | void nativeLog(JNIEnv * env, jstring msg) {
148 | //1.找到java的LameUtils的class com/example/myjnidemo/
149 | jclass clazz = (*env).FindClass("com/convert/mymp3convert/Mp3ConvertUtil");
150 | if (clazz == 0) {
151 | LOGI("can't find clazz");
152 | return;
153 | }
154 | //2 找到class 里面的方法定义
155 | jmethodID methodid = (*env).GetStaticMethodID(clazz,"nativeLog",
156 | "(Ljava/lang/String;Ljava/lang/String;)V");
157 | if (methodid == 0) {
158 | LOGI("can't find methodid");
159 | return;
160 | }
161 | LOGI(" find methodid");
162 | jstring logTag = env->NewStringUTF(CONVERT_LOG_TAG);
163 | //3 .调用方法
164 | env -> CallStaticVoidMethod(clazz,methodid,logTag,msg);
165 | env->DeleteLocalRef(logTag);
166 | env->DeleteLocalRef(clazz);
167 | }
168 | /**
169 | * 字符串拼接
170 | * @param env
171 | * @param cstr
172 | * @param jstr
173 | * @return
174 | */
175 | jstring jstrCat(JNIEnv *env,char * cstr,jstring jstr){
176 | char *c =(char *)(*env).GetStringUTFChars(jstr,JNI_FALSE);
177 | char * bf = new char[strlen(cstr) + strlen(c) +1];
178 | memcpy(bf, cstr, strlen(cstr) + 1);
179 | strcat(bf, c);
180 | jstring js = env->NewStringUTF(bf);
181 | delete [] bf;
182 | (*env).ReleaseStringUTFChars(jstr,c);
183 | return js;
184 | }
185 | /**
186 | * 获取文件的大小
187 | * @param filename
188 | * @return
189 | */
190 | long long file_size(char* filename){
191 | struct stat statbuf;
192 | stat(filename,&statbuf);
193 | return statbuf.st_size;
194 | }
195 | /*
196 | * Class: com_convert_mymp3convert_Mp3ConvertUtil
197 | * Method: hello
198 | * Signature: (Ljava/lang/String;)Ljava/lang/String;
199 | */
200 | JNIEXPORT jstring JNICALL Java_com_convert_mymp3convert_Mp3ConvertUtil_hello
201 | (JNIEnv *env, jclass obj, jstring str){
202 |
203 | jstring js = env->NewStringUTF("/sd/mp3");
204 | publishJavaProgress(env,obj,123,js);
205 | env->DeleteLocalRef(js);
206 |
207 | jstring jstr = env->NewStringUTF("/sd/m/mp3");
208 | convertFinish(env,jstr);
209 | env->DeleteLocalRef(jstr);
210 |
211 | jstring msg = env->NewStringUTF("xxx原因导致了未转换成功");
212 | convertError(env, msg, msg);
213 | env->DeleteLocalRef(msg);
214 |
215 | LOGD("lame ver = %s",get_lame_very_short_version());
216 | LOGI("convertmp3 %S === %S","wav","mp3");
217 | LOGD("CONVERT %S","test");
218 | return env->NewStringUTF("Hello From JNI!");//
219 | }
220 | /*
221 | * Class: com_convert_mymp3convert_Mp3ConvertUtil
222 | * Method: getLameVer
223 | * Signature: ()Ljava/lang/String;
224 | */
225 | JNIEXPORT jstring JNICALL
226 | Java_com_convert_mymp3convert_Mp3ConvertUtil_getLameVer(JNIEnv *env, jclass obj) {
227 | LOGD("CONVERT 123321 测试 S ");
228 | LOGD("CONVERT 123321 测试 S --- %d",123);
229 | LOGD("CONVERT 123321 测试 S --- %s","test");
230 | return (*env).NewStringUTF(get_lame_version());
231 | }
232 | //int flag = 0;
233 | /**
234 | *wav转换mp3
235 | * @param env
236 | * @param obj
237 | * @param wav
238 | * @param mp3
239 | */
240 | /*
241 | * Class: com_convert_mymp3convert_Mp3ConvertUtil
242 | * Method: convertmp3
243 | * Signature: (Ljava/lang/String;Ljava/lang/String;)V
244 | */
245 | JNIEXPORT void JNICALL
246 | Java_com_convert_mymp3convert_Mp3ConvertUtil_convertmp3(JNIEnv *env, jclass obj, jstring wav,jstring mp3) {
247 |
248 | char* cwav = const_cast(env->GetStringUTFChars(wav, JNI_FALSE));//Jstring2CStr(env,wav) ;
249 | char* cmp3= const_cast(env->GetStringUTFChars(mp3, JNI_FALSE));//Jstring2CStr(env,mp3);
250 | LOGI("wav = %s", cwav);
251 | LOGI("mp3 = %s", cmp3);
252 |
253 | char buf[2048] = {};
254 | sprintf(buf, "source:%s,target:%s ", cwav,cmp3);
255 | LOGD(buf,NULL);
256 |
257 | if(access(cwav,F_OK) == -1){
258 | free(cwav);
259 | free(cmp3);
260 | LOGD("转换源文件不存在");
261 | jstring msg = jstrCat(env,"转换源文件不存在:",mp3);
262 | nativeLog(env, msg);
263 | convertError(env,msg,mp3);
264 | env->DeleteLocalRef(msg);
265 | return;
266 | }
267 | long long fileSize = file_size(cwav);
268 | if (fileSize == 0) {
269 | free(cwav);
270 | free(cmp3);
271 | jstring msg = jstrCat(env,"转换源文件大小为0:",mp3);
272 | nativeLog(env, msg);
273 | convertError(env,msg,mp3);
274 | env->DeleteLocalRef(msg);
275 | return;
276 | }
277 | //1.打开 wav,MP3文件
278 | FILE* fwav = fopen(cwav,"rb");
279 | FILE* fmp3 = fopen(cmp3,"wb");
280 |
281 | short int wav_buffer[8192*2]= {};
282 | unsigned char mp3_buffer[8192] = {};
283 |
284 | //1.初始化lame的编码器
285 | lame_t lame = lame_init();
286 | //2. 设置lame mp3编码的采样率
287 | lame_set_in_samplerate(lame , 44100);
288 | lame_set_num_channels(lame,2);
289 | // 3. 设置MP3的编码方式
290 | lame_set_VBR(lame, vbr_default);
291 | lame_init_params(lame);
292 | LOGI("lame init finish");
293 |
294 | int read ; int write; //代表读了多少个次 和写了多少次
295 | long long total=0; // 当前读的wav文件的byte数目
296 |
297 | LOGD("FILE SIZE = %d",fileSize);
298 | int progress = 0;
299 | do{
300 | // if(flag==404){
301 | // return;
302 | // }
303 | read = fread(wav_buffer,sizeof(short int)*2, 8192,fwav);
304 | total += read* sizeof(short int)*2;
305 | LOGI("converting ....%d", total);
306 | int tmpProgress = (total*100)/fileSize;
307 | LOGD("converting size = %d",tmpProgress);
308 |
309 | if(tmpProgress != progress){
310 | progress = tmpProgress;
311 | publishJavaProgress(env,obj,progress,mp3);
312 | }
313 |
314 | // 调用java代码 完成进度条的更新
315 | if(read!=0){
316 | write = lame_encode_buffer_interleaved(lame,wav_buffer,read,mp3_buffer,8192);
317 | //把转化后的mp3数据写到文件里
318 | fwrite(mp3_buffer,sizeof(unsigned char),write,fmp3);
319 | }
320 | if(read==0){
321 | write = lame_encode_flush(lame,mp3_buffer,8192);
322 | fwrite(mp3_buffer,sizeof(unsigned char),write,fmp3);
323 | }
324 | }while(read!=0);
325 |
326 | lame_close(lame);
327 | fclose(fwav);
328 | fclose(fmp3);
329 | env->ReleaseStringUTFChars(wav,cwav);
330 | env->ReleaseStringUTFChars(mp3,cmp3);
331 |
332 | convertFinish(env,mp3);
333 | LOGI("convert finish");
334 |
335 | }
336 |
337 |
338 | #ifdef __cplusplus
339 | }
340 | #endif
341 | #endif
342 |
--------------------------------------------------------------------------------
/app/src/main/jni/NativeMp3ConvertUtil.cpp.bak:
--------------------------------------------------------------------------------
1 | //
2 | // Created by shaomingfa on 2021/1/14.
3 | //
4 |
5 | #include
6 | #include "libmp3lame/lame.h"
7 |
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include "libmp3lame/lame.h"
15 | #include
16 | #include
17 | #include
18 |
19 |
20 | #include "NativeMp3ConvertUtil.h"
21 | #include "com_convert_mymp3convert_Mp3ConvertUtil.h"
22 | #define LOG_TAG "System.out.c"
23 | /**
24 | * 日志打印tag
25 | */
26 | #define CONVERT_LOG_TAG "nativeTag"
27 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
28 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
29 |
30 |
31 |
32 | #ifndef com_convert_mymp3convert_Mp3ConvertUtil
33 | #define com_convert_mymp3convert_Mp3ConvertUtil
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | /**
39 | * 返回值 char* 这个代表char数组的首地址
40 | * Jstring2CStr 把java中的jstring的类型转化成一个c语言中的char 字符串
41 | */
42 | char* Jstring2CStr(JNIEnv *env, jstring jstr) {
43 | char* rtn = NULL;
44 | jclass clsstring = (*env).FindClass( "java/lang/String"); //String
45 | jstring strencode = (*env).NewStringUTF( "GB2312"); // 得到一个java字符串 "GB2312"
46 | jmethodID mid = (*env).GetMethodID(clsstring, "getBytes",
47 | "(Ljava/lang/String;)[B"); //[ String.getBytes("gb2312");
48 | jbyteArray barr = (jbyteArray)(*env).CallObjectMethod(jstr, mid,
49 | strencode); // String .getByte("GB2312");
50 | jsize alen = (*env).GetArrayLength( barr); // byte数组的长度
51 | jbyte* ba = (*env).GetByteArrayElements( barr, JNI_FALSE);
52 | if (alen > 0) {
53 | rtn = (char*) malloc(alen + 1); //"\0"
54 | memcpy(rtn, ba, alen);
55 | rtn[alen] = 0;
56 | }
57 | (*env).ReleaseByteArrayElements(barr, ba, 0); //
58 | (*env).DeleteLocalRef(strencode);
59 | return rtn;
60 | }
61 | /**==============================================================================================================================================*/
62 | /**
63 | * 调用java代码 更新程序的进度条
64 | */
65 | void publishJavaProgress(JNIEnv * env, jobject obj, jint progress,jstring outPath) {
66 | //1.找到java的LameUtils的class com/example/myjnidemo/
67 | jclass clazz = (*env).FindClass("com/convert/mymp3convert/Mp3ConvertUtil");
68 | if (clazz == 0) {
69 | LOGI("can't find clazz");
70 | return;
71 | }
72 | LOGI(" convert progress %d" , progress);
73 |
74 | //2 找到class 里面的方法定义
75 |
76 | jmethodID methodid = (*env).GetStaticMethodID(clazz,"setConvertProgress","(ILjava/lang/String;)V");//jmethodID methodid = (*env).GetMethodID(clazz, "setConvertProgress","(I)V");
77 | if (methodid == 0) {
78 | LOGI("can't find methodid");
79 | return;
80 | }
81 | LOGI(" find methodid");
82 |
83 | //3 .调用方法
84 | (*env).CallStaticVoidMethod(clazz, methodid, progress,outPath);//(*env).CallVoidMethod(obj, methodid, progress);
85 | //env -> CallVoidMethod(obj,methodid,progress);
86 | env->DeleteLocalRef(clazz);
87 | //env->DeleteLocalRef(methodid);
88 | }
89 | /**
90 | * 调用java代码 更新程序的进度条
91 | */
92 | void convertFinish(JNIEnv * env, jstring mp3Path) {
93 | //1.找到java的LameUtils的class com/example/myjnidemo/
94 | jclass clazz = (*env).FindClass("com/convert/mymp3convert/Mp3ConvertUtil");
95 | if (clazz == 0) {
96 | LOGI("can't find clazz");
97 | return;
98 | }
99 | const char *c = env->GetStringUTFChars(mp3Path, JNI_FALSE);
100 | LOGI(" convert finished %s" , c);
101 | env->ReleaseStringUTFChars(mp3Path,c);
102 |
103 | //2 找到class 里面的方法定义
104 | jmethodID methodid = (*env).GetStaticMethodID(clazz,"convertFinish","(Ljava/lang/String;)V");
105 | if (methodid == 0) {
106 | LOGI("can't find methodid");
107 | return;
108 | }
109 | LOGI(" find convertFinish methodid");
110 |
111 | //3 .调用方法
112 | env -> CallStaticVoidMethod(clazz,methodid,mp3Path);
113 | env->DeleteLocalRef(clazz);
114 | }
115 | /**
116 | * 调用java代码 转换失败时调用
117 | */
118 | void convertError(JNIEnv * env,jstring msg,jstring mp3Path) {
119 | //1.找到java的LameUtils的class com/example/myjnidemo/
120 | jclass clazz = (*env).FindClass("com/convert/mymp3convert/Mp3ConvertUtil");
121 | if (clazz == 0) {
122 | LOGI("can't find clazz");
123 | return;
124 | }
125 |
126 | const char *c = (*env).GetStringUTFChars(mp3Path, JNI_FALSE);
127 | LOGI(" convert error %s" , c);
128 | (*env).ReleaseStringUTFChars(mp3Path,c);
129 |
130 | //2 找到class 里面的方法定义
131 |
132 | jmethodID methodid = (*env).GetStaticMethodID(clazz,"convertError",
133 | "(Ljava/lang/String;Ljava/lang/String;)V");
134 | if (methodid == 0) {
135 | LOGI("can't find methodid");
136 | return;
137 | }
138 | LOGI(" find methodid");
139 |
140 | //3 .调用方法
141 | env -> CallStaticVoidMethod(clazz,methodid,msg,mp3Path);
142 | env->DeleteLocalRef(clazz);
143 | }
144 | /**
145 | * 调用java代码 打印日志时调用
146 | */
147 | void nativeLog(JNIEnv * env, jstring msg) {
148 | //1.找到java的LameUtils的class com/example/myjnidemo/
149 | jclass clazz = (*env).FindClass("com/convert/mymp3convert/Mp3ConvertUtil");
150 | if (clazz == 0) {
151 | LOGI("can't find clazz");
152 | return;
153 | }
154 | //2 找到class 里面的方法定义
155 | jmethodID methodid = (*env).GetStaticMethodID(clazz,"nativeLog",
156 | "(Ljava/lang/String;Ljava/lang/String;)V");
157 | if (methodid == 0) {
158 | LOGI("can't find methodid");
159 | return;
160 | }
161 | LOGI(" find methodid");
162 | jstring logTag = env->NewStringUTF(CONVERT_LOG_TAG);
163 | //3 .调用方法
164 | env -> CallStaticVoidMethod(clazz,methodid,logTag,msg);
165 | env->DeleteLocalRef(logTag);
166 | env->DeleteLocalRef(clazz);
167 | }
168 | /**
169 | * 字符串拼接
170 | * @param env
171 | * @param cstr
172 | * @param jstr
173 | * @return
174 | */
175 | jstring jstrCat(JNIEnv *env,char * cstr,jstring jstr){
176 | char *c =(char *)(*env).GetStringUTFChars(jstr,JNI_FALSE);
177 | char * bf = new char[strlen(cstr) + strlen(c) +1];
178 | memcpy(bf, cstr, strlen(cstr) + 1);
179 | strcat(bf, c);
180 | jstring js = env->NewStringUTF(bf);
181 | delete [] bf;
182 | (*env).ReleaseStringUTFChars(jstr,c);
183 | return js;
184 | }
185 | /**
186 | * 获取文件的大小
187 | * @param filename
188 | * @return
189 | */
190 | long long file_size(char* filename){
191 | struct stat statbuf;
192 | stat(filename,&statbuf);
193 | return statbuf.st_size;
194 | }
195 | /*
196 | * Class: com_convert_mymp3convert_Mp3ConvertUtil
197 | * Method: hello
198 | * Signature: (Ljava/lang/String;)Ljava/lang/String;
199 | */
200 | JNIEXPORT jstring JNICALL Java_com_convert_mymp3convert_Mp3ConvertUtil_hello
201 | (JNIEnv *env, jclass obj, jstring str){
202 |
203 | jstring js = env->NewStringUTF("/sd/mp3");
204 | publishJavaProgress(env,obj,123,js);
205 | env->DeleteLocalRef(js);
206 |
207 | jstring jstr = env->NewStringUTF("/sd/m/mp3");
208 | convertFinish(env,jstr);
209 | env->DeleteLocalRef(jstr);
210 |
211 | jstring msg = env->NewStringUTF("xxx原因导致了未转换成功");
212 | convertError(env, msg, msg);
213 | env->DeleteLocalRef(msg);
214 |
215 | LOGD("lame ver = %s",get_lame_very_short_version());
216 | LOGI("convertmp3 %S === %S","wav","mp3");
217 | LOGD("CONVERT %S","test");
218 | return env->NewStringUTF("Hello From JNI!");//
219 | }
220 | /*
221 | * Class: com_convert_mymp3convert_Mp3ConvertUtil
222 | * Method: getLameVer
223 | * Signature: ()Ljava/lang/String;
224 | */
225 | JNIEXPORT jstring JNICALL
226 | Java_com_convert_mymp3convert_Mp3ConvertUtil_getLameVer(JNIEnv *env, jclass obj) {
227 | LOGD("CONVERT 123321 测试 S ");
228 | LOGD("CONVERT 123321 测试 S --- %d",123);
229 | LOGD("CONVERT 123321 测试 S --- %s","test");
230 | return (*env).NewStringUTF(get_lame_version());
231 | }
232 | //int flag = 0;
233 | /**
234 | *wav转换mp3
235 | * @param env
236 | * @param obj
237 | * @param wav
238 | * @param mp3
239 | */
240 | /*
241 | * Class: com_convert_mymp3convert_Mp3ConvertUtil
242 | * Method: convertmp3
243 | * Signature: (Ljava/lang/String;Ljava/lang/String;)V
244 | */
245 | JNIEXPORT void JNICALL
246 | Java_com_convert_mymp3convert_Mp3ConvertUtil_convertmp3(JNIEnv *env, jclass obj, jstring wav,jstring mp3) {
247 |
248 | char* cwav = const_cast(env->GetStringUTFChars(wav, JNI_FALSE));//Jstring2CStr(env,wav) ;
249 | char* cmp3= const_cast(env->GetStringUTFChars(mp3, JNI_FALSE));//Jstring2CStr(env,mp3);
250 | LOGI("wav = %s", cwav);
251 | LOGI("mp3 = %s", cmp3);
252 |
253 | char buf[2048] = {};
254 | sprintf(buf, "source:%s,target:%s ", cwav,cmp3);
255 | LOGD(buf,NULL);
256 |
257 | if(access(cwav,F_OK) == -1){
258 | free(cwav);
259 | free(cmp3);
260 | LOGD("转换源文件不存在");
261 | jstring msg = jstrCat(env,"转换源文件不存在:",mp3);
262 | nativeLog(env, msg);
263 | convertError(env,msg,mp3);
264 | env->DeleteLocalRef(msg);
265 | return;
266 | }
267 | long long fileSize = file_size(cwav);
268 | if (fileSize == 0) {
269 | free(cwav);
270 | free(cmp3);
271 | jstring msg = jstrCat(env,"转换源文件大小为0:",mp3);
272 | nativeLog(env, msg);
273 | convertError(env,msg,mp3);
274 | env->DeleteLocalRef(msg);
275 | return;
276 | }
277 | //1.打开 wav,MP3文件
278 | FILE* fwav = fopen(cwav,"rb");
279 | FILE* fmp3 = fopen(cmp3,"wb");
280 |
281 | short int wav_buffer[8192*2]= {};
282 | unsigned char mp3_buffer[8192] = {};
283 |
284 | //1.初始化lame的编码器
285 | lame_t lame = lame_init();
286 | //2. 设置lame mp3编码的采样率
287 | lame_set_in_samplerate(lame , 44100);
288 | lame_set_num_channels(lame,2);
289 | // 3. 设置MP3的编码方式
290 | lame_set_VBR(lame, vbr_default);
291 | lame_init_params(lame);
292 | LOGI("lame init finish");
293 |
294 | int read ; int write; //代表读了多少个次 和写了多少次
295 | long long total=0; // 当前读的wav文件的byte数目
296 |
297 | LOGD("FILE SIZE = %d",fileSize);
298 | int progress = 0;
299 | do{
300 | // if(flag==404){
301 | // return;
302 | // }
303 | read = fread(wav_buffer,sizeof(short int)*2, 8192,fwav);
304 | total += read* sizeof(short int)*2;
305 | LOGI("converting ....%d", total);
306 | int tmpProgress = (total*100)/fileSize;
307 | LOGD("converting size = %d",tmpProgress);
308 |
309 | if(tmpProgress != progress){
310 | progress = tmpProgress;
311 | publishJavaProgress(env,obj,progress,mp3);
312 | }
313 |
314 | // 调用java代码 完成进度条的更新
315 | if(read!=0){
316 | write = lame_encode_buffer_interleaved(lame,wav_buffer,read,mp3_buffer,8192);
317 | //把转化后的mp3数据写到文件里
318 | fwrite(mp3_buffer,sizeof(unsigned char),write,fmp3);
319 | }
320 | if(read==0){
321 | write = lame_encode_flush(lame,mp3_buffer,8192);
322 | fwrite(mp3_buffer,sizeof(unsigned char),write,fmp3);
323 | }
324 | }while(read!=0);
325 |
326 | lame_close(lame);
327 | fclose(fwav);
328 | fclose(fmp3);
329 | env->ReleaseStringUTFChars(wav,cwav);
330 | env->ReleaseStringUTFChars(mp3,cmp3);
331 |
332 | convertFinish(env,mp3);
333 | LOGI("convert finish");
334 |
335 | }
336 |
337 |
338 | #ifdef __cplusplus
339 | }
340 | #endif
341 | #endif
342 |
--------------------------------------------------------------------------------
/app/src/main/jni/NativeMp3ConvertUtil.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by shaomingfa on 2021/1/14.
3 | //
4 | #include
5 | #ifndef MYMP3CONVERT_NATIVEMP3CONVERTUTIL_H
6 | #define MYMP3CONVERT_NATIVEMP3CONVERTUTIL_H
7 |
8 |
9 | class NativeMp3ConvertUtil {
10 |
11 | };
12 |
13 |
14 | #endif //MYMP3CONVERT_NATIVEMP3CONVERTUTIL_H
15 |
--------------------------------------------------------------------------------
/app/src/main/jni/NativeMyTest.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by shaomingfa on 2021/1/14.
3 | //
4 | #include
5 | #include
6 | #include "com_convert_mymp3convert_MyTest.h"
7 | #include "libmp3lame/lame.h"
8 | /**
9 | * 字符串拼接
10 | * @param env
11 | * @param cstr
12 | * @param jstr
13 | * @return
14 | */
15 | jstring jstrCat(JNIEnv *env,char * cstr,jstring jstr){
16 | char *c =(char *)(*env).GetStringUTFChars(jstr,JNI_FALSE);
17 | char * bf = new char[strlen(cstr) + strlen(c) +1];
18 | memcpy(bf, cstr, strlen(cstr) + 1);
19 | strcat(bf, c);
20 | jstring js = env->NewStringUTF(bf);
21 | delete [] bf;
22 | (*env).ReleaseStringUTFChars(jstr,c);
23 | return js;
24 | }
25 | /*
26 | * Class: com_convert_mymp3convert_MyTest
27 | * Method: test
28 | * Signature: ()Ljava/lang/String;
29 | */
30 | extern "C" JNIEXPORT jstring JNICALL Java_com_convert_mymp3convert_MyTest_test
31 | (JNIEnv *env, jclass clazz){
32 |
33 | //1、直接使用GetStringUTFChars方法将传递过来的jstring转为char*
34 | char *c1 = "即将转换:";
35 | jstring mp3 = env->NewStringUTF("mp3");
36 | char *c2 = (char *) (env->GetStringUTFChars(mp3, JNI_FALSE));
37 | env->ReleaseStringUTFChars(mp3,c2);
38 | //2、再使用本地函数strcat 拼接两个char*对象,然后NewStringUTF转为jstring返回去
39 | jstring res = jstrCat(env,c1,mp3);//strcat(c1, c2);
40 | jstring jstr = res;//env->NewStringUTF(res);
41 | //convertLog(env,jstr);
42 | env->DeleteLocalRef(jstr);
43 |
44 | return env->NewStringUTF(get_lame_very_short_version());
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/jni/com_convert_mymp3convert_Mp3ConvertUtil.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class com_convert_mymp3convert_Mp3ConvertUtil */
4 |
5 | #ifndef _Included_com_convert_mymp3convert_Mp3ConvertUtil
6 | #define _Included_com_convert_mymp3convert_Mp3ConvertUtil
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: com_convert_mymp3convert_Mp3ConvertUtil
12 | * Method: hello
13 | * Signature: (Ljava/lang/String;)Ljava/lang/String;
14 | */
15 | JNIEXPORT jstring JNICALL Java_com_convert_mymp3convert_Mp3ConvertUtil_hello
16 | (JNIEnv *, jclass, jstring);
17 |
18 | /*
19 | * Class: com_convert_mymp3convert_Mp3ConvertUtil
20 | * Method: getLameVer
21 | * Signature: ()Ljava/lang/String;
22 | */
23 | JNIEXPORT jstring JNICALL Java_com_convert_mymp3convert_Mp3ConvertUtil_getLameVer
24 | (JNIEnv *, jclass);
25 |
26 | /*
27 | * Class: com_convert_mymp3convert_Mp3ConvertUtil
28 | * Method: convertmp3
29 | * Signature: (Ljava/lang/String;Ljava/lang/String;)V
30 | */
31 | JNIEXPORT void JNICALL Java_com_convert_mymp3convert_Mp3ConvertUtil_convertmp3
32 | (JNIEnv *, jclass, jstring, jstring);
33 |
34 | #ifdef __cplusplus
35 | }
36 | #endif
37 | #endif
38 |
--------------------------------------------------------------------------------
/app/src/main/jni/com_convert_mymp3convert_MyTest.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | /* Header for class com_convert_mymp3convert_MyTest */
3 |
4 | #pragma once
5 | #include
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 | /*
10 | * Class: com_convert_mymp3convert_MyTest
11 | * Method: test
12 | * Signature: ()Ljava/lang/String;
13 | */
14 | JNIEXPORT jstring JNICALL Java_com_convert_mymp3convert_MyTest_test
15 | (JNIEnv *, jclass);
16 |
17 | #ifdef __cplusplus
18 | }
19 | #endif
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/fft.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** FFT and FHT routines
3 | ** Copyright 1988, 1993; Ron Mayer
4 | ** Copyright (c) 1999-2000 Takehiro Tominaga
5 | **
6 | ** fht(fz,n);
7 | ** Does a hartley transform of "n" points in the array "fz".
8 | **
9 | ** NOTE: This routine uses at least 2 patented algorithms, and may be
10 | ** under the restrictions of a bunch of different organizations.
11 | ** Although I wrote it completely myself; it is kind of a derivative
12 | ** of a routine I once authored and released under the GPL, so it
13 | ** may fall under the free software foundation's restrictions;
14 | ** it was worked on as a Stanford Univ project, so they claim
15 | ** some rights to it; it was further optimized at work here, so
16 | ** I think this company claims parts of it. The patents are
17 | ** held by R. Bracewell (the FHT algorithm) and O. Buneman (the
18 | ** trig generator), both at Stanford Univ.
19 | ** If it were up to me, I'd say go do whatever you want with it;
20 | ** but it would be polite to give credit to the following people
21 | ** if you use this anywhere:
22 | ** Euler - probable inventor of the fourier transform.
23 | ** Gauss - probable inventor of the FFT.
24 | ** Hartley - probable inventor of the hartley transform.
25 | ** Buneman - for a really cool trig generator
26 | ** Mayer(me) - for authoring this particular version and
27 | ** including all the optimizations in one package.
28 | ** Thanks,
29 | ** Ron Mayer; mayer@acuson.com
30 | ** and added some optimization by
31 | ** Mather - idea of using lookup table
32 | ** Takehiro - some dirty hack for speed up
33 | */
34 |
35 | /* $Id: fft.c,v 1.38 2009/04/20 21:48:00 robert Exp $ */
36 |
37 | #ifdef HAVE_CONFIG_H
38 | # include
39 | #endif
40 |
41 | #include "lame.h"
42 | #include "machine.h"
43 | #include "encoder.h"
44 | #include "util.h"
45 | #include "fft.h"
46 |
47 | //#include "vector/lame_intrin.h"
48 |
49 |
50 |
51 | #define TRI_SIZE (5-1) /* 1024 = 4**5 */
52 |
53 | /* fft.c */
54 | static FLOAT window[BLKSIZE], window_s[BLKSIZE_s / 2];
55 |
56 | static const FLOAT costab[TRI_SIZE * 2] = {
57 | 9.238795325112867e-01, 3.826834323650898e-01,
58 | 9.951847266721969e-01, 9.801714032956060e-02,
59 | 9.996988186962042e-01, 2.454122852291229e-02,
60 | 9.999811752826011e-01, 6.135884649154475e-03
61 | };
62 |
63 | static void
64 | fht(FLOAT * fz, int n)
65 | {
66 | const FLOAT *tri = costab;
67 | int k4;
68 | FLOAT *fi, *gi;
69 | FLOAT const *fn;
70 |
71 | n <<= 1; /* to get BLKSIZE, because of 3DNow! ASM routine */
72 | fn = fz + n;
73 | k4 = 4;
74 | do {
75 | FLOAT s1, c1;
76 | int i, k1, k2, k3, kx;
77 | kx = k4 >> 1;
78 | k1 = k4;
79 | k2 = k4 << 1;
80 | k3 = k2 + k1;
81 | k4 = k2 << 1;
82 | fi = fz;
83 | gi = fi + kx;
84 | do {
85 | FLOAT f0, f1, f2, f3;
86 | f1 = fi[0] - fi[k1];
87 | f0 = fi[0] + fi[k1];
88 | f3 = fi[k2] - fi[k3];
89 | f2 = fi[k2] + fi[k3];
90 | fi[k2] = f0 - f2;
91 | fi[0] = f0 + f2;
92 | fi[k3] = f1 - f3;
93 | fi[k1] = f1 + f3;
94 | f1 = gi[0] - gi[k1];
95 | f0 = gi[0] + gi[k1];
96 | f3 = SQRT2 * gi[k3];
97 | f2 = SQRT2 * gi[k2];
98 | gi[k2] = f0 - f2;
99 | gi[0] = f0 + f2;
100 | gi[k3] = f1 - f3;
101 | gi[k1] = f1 + f3;
102 | gi += k4;
103 | fi += k4;
104 | } while (fi < fn);
105 | c1 = tri[0];
106 | s1 = tri[1];
107 | for (i = 1; i < kx; i++) {
108 | FLOAT c2, s2;
109 | c2 = 1 - (2 * s1) * s1;
110 | s2 = (2 * s1) * c1;
111 | fi = fz + i;
112 | gi = fz + k1 - i;
113 | do {
114 | FLOAT a, b, g0, f0, f1, g1, f2, g2, f3, g3;
115 | b = s2 * fi[k1] - c2 * gi[k1];
116 | a = c2 * fi[k1] + s2 * gi[k1];
117 | f1 = fi[0] - a;
118 | f0 = fi[0] + a;
119 | g1 = gi[0] - b;
120 | g0 = gi[0] + b;
121 | b = s2 * fi[k3] - c2 * gi[k3];
122 | a = c2 * fi[k3] + s2 * gi[k3];
123 | f3 = fi[k2] - a;
124 | f2 = fi[k2] + a;
125 | g3 = gi[k2] - b;
126 | g2 = gi[k2] + b;
127 | b = s1 * f2 - c1 * g3;
128 | a = c1 * f2 + s1 * g3;
129 | fi[k2] = f0 - a;
130 | fi[0] = f0 + a;
131 | gi[k3] = g1 - b;
132 | gi[k1] = g1 + b;
133 | b = c1 * g2 - s1 * f3;
134 | a = s1 * g2 + c1 * f3;
135 | gi[k2] = g0 - a;
136 | gi[0] = g0 + a;
137 | fi[k3] = f1 - b;
138 | fi[k1] = f1 + b;
139 | gi += k4;
140 | fi += k4;
141 | } while (fi < fn);
142 | c2 = c1;
143 | c1 = c2 * tri[0] - s1 * tri[1];
144 | s1 = c2 * tri[1] + s1 * tri[0];
145 | }
146 | tri += 2;
147 | } while (k4 < n);
148 | }
149 |
150 |
151 | static const unsigned char rv_tbl[] = {
152 | 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
153 | 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
154 | 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
155 | 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
156 | 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
157 | 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
158 | 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
159 | 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
160 | 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
161 | 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
162 | 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
163 | 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
164 | 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
165 | 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
166 | 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
167 | 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe
168 | };
169 |
170 | #define ch01(index) (buffer[chn][index])
171 |
172 | #define ml00(f) (window[i ] * f(i))
173 | #define ml10(f) (window[i + 0x200] * f(i + 0x200))
174 | #define ml20(f) (window[i + 0x100] * f(i + 0x100))
175 | #define ml30(f) (window[i + 0x300] * f(i + 0x300))
176 |
177 | #define ml01(f) (window[i + 0x001] * f(i + 0x001))
178 | #define ml11(f) (window[i + 0x201] * f(i + 0x201))
179 | #define ml21(f) (window[i + 0x101] * f(i + 0x101))
180 | #define ml31(f) (window[i + 0x301] * f(i + 0x301))
181 |
182 | #define ms00(f) (window_s[i ] * f(i + k))
183 | #define ms10(f) (window_s[0x7f - i] * f(i + k + 0x80))
184 | #define ms20(f) (window_s[i + 0x40] * f(i + k + 0x40))
185 | #define ms30(f) (window_s[0x3f - i] * f(i + k + 0xc0))
186 |
187 | #define ms01(f) (window_s[i + 0x01] * f(i + k + 0x01))
188 | #define ms11(f) (window_s[0x7e - i] * f(i + k + 0x81))
189 | #define ms21(f) (window_s[i + 0x41] * f(i + k + 0x41))
190 | #define ms31(f) (window_s[0x3e - i] * f(i + k + 0xc1))
191 |
192 |
193 | void
194 | fft_short(lame_internal_flags const *const gfc,
195 | FLOAT x_real[3][BLKSIZE_s], int chn, const sample_t *const buffer[2])
196 | {
197 | int i;
198 | int j;
199 | int b;
200 |
201 | for (b = 0; b < 3; b++) {
202 | FLOAT *x = &x_real[b][BLKSIZE_s / 2];
203 | short const k = (576 / 3) * (b + 1);
204 | j = BLKSIZE_s / 8 - 1;
205 | do {
206 | FLOAT f0, f1, f2, f3, w;
207 |
208 | i = rv_tbl[j << 2];
209 |
210 | f0 = ms00(ch01);
211 | w = ms10(ch01);
212 | f1 = f0 - w;
213 | f0 = f0 + w;
214 | f2 = ms20(ch01);
215 | w = ms30(ch01);
216 | f3 = f2 - w;
217 | f2 = f2 + w;
218 |
219 | x -= 4;
220 | x[0] = f0 + f2;
221 | x[2] = f0 - f2;
222 | x[1] = f1 + f3;
223 | x[3] = f1 - f3;
224 |
225 | f0 = ms01(ch01);
226 | w = ms11(ch01);
227 | f1 = f0 - w;
228 | f0 = f0 + w;
229 | f2 = ms21(ch01);
230 | w = ms31(ch01);
231 | f3 = f2 - w;
232 | f2 = f2 + w;
233 |
234 | x[BLKSIZE_s / 2 + 0] = f0 + f2;
235 | x[BLKSIZE_s / 2 + 2] = f0 - f2;
236 | x[BLKSIZE_s / 2 + 1] = f1 + f3;
237 | x[BLKSIZE_s / 2 + 3] = f1 - f3;
238 | } while (--j >= 0);
239 |
240 | gfc->fft_fht(x, BLKSIZE_s / 2);
241 | /* BLKSIZE_s/2 because of 3DNow! ASM routine */
242 | }
243 | }
244 |
245 | void
246 | fft_long(lame_internal_flags const *const gfc,
247 | FLOAT x[BLKSIZE], int chn, const sample_t *const buffer[2])
248 | {
249 | int i;
250 | int jj = BLKSIZE / 8 - 1;
251 | x += BLKSIZE / 2;
252 |
253 | do {
254 | FLOAT f0, f1, f2, f3, w;
255 |
256 | i = rv_tbl[jj];
257 | f0 = ml00(ch01);
258 | w = ml10(ch01);
259 | f1 = f0 - w;
260 | f0 = f0 + w;
261 | f2 = ml20(ch01);
262 | w = ml30(ch01);
263 | f3 = f2 - w;
264 | f2 = f2 + w;
265 |
266 | x -= 4;
267 | x[0] = f0 + f2;
268 | x[2] = f0 - f2;
269 | x[1] = f1 + f3;
270 | x[3] = f1 - f3;
271 |
272 | f0 = ml01(ch01);
273 | w = ml11(ch01);
274 | f1 = f0 - w;
275 | f0 = f0 + w;
276 | f2 = ml21(ch01);
277 | w = ml31(ch01);
278 | f3 = f2 - w;
279 | f2 = f2 + w;
280 |
281 | x[BLKSIZE / 2 + 0] = f0 + f2;
282 | x[BLKSIZE / 2 + 2] = f0 - f2;
283 | x[BLKSIZE / 2 + 1] = f1 + f3;
284 | x[BLKSIZE / 2 + 3] = f1 - f3;
285 | } while (--jj >= 0);
286 |
287 | gfc->fft_fht(x, BLKSIZE / 2);
288 | /* BLKSIZE/2 because of 3DNow! ASM routine */
289 | }
290 |
291 | #ifdef HAVE_NASM
292 | extern void fht_3DN(FLOAT * fz, int n);
293 | extern void fht_SSE(FLOAT * fz, int n);
294 | #endif
295 |
296 | void
297 | init_fft(lame_internal_flags * const gfc)
298 | {
299 | int i;
300 |
301 | /* The type of window used here will make no real difference, but */
302 | /* in the interest of merging nspsytune stuff - switch to blackman window */
303 | for (i = 0; i < BLKSIZE; i++)
304 | /* blackman window */
305 | window[i] = 0.42 - 0.5 * cos(2 * PI * (i + .5) / BLKSIZE) +
306 | 0.08 * cos(4 * PI * (i + .5) / BLKSIZE);
307 |
308 | for (i = 0; i < BLKSIZE_s / 2; i++)
309 | window_s[i] = 0.5 * (1.0 - cos(2.0 * PI * (i + 0.5) / BLKSIZE_s));
310 |
311 | gfc->fft_fht = fht;
312 | #ifdef HAVE_NASM
313 | if (gfc->CPU_features.AMD_3DNow) {
314 | gfc->fft_fht = fht_3DN;
315 | }
316 | else if (gfc->CPU_features.SSE) {
317 | gfc->fft_fht = fht_SSE;
318 | }
319 | else {
320 | gfc->fft_fht = fht;
321 | }
322 | #else
323 | #ifdef HAVE_XMMINTRIN_H
324 | #ifdef MIN_ARCH_SSE
325 | gfc->fft_fht = fht_SSE2;
326 | #endif
327 | #endif
328 | #endif
329 | }
330 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 | FrameDataNode *v2_head, *v2_tail;
51 | } id3tag_spec;
52 |
53 |
54 | /* write tag into stream at current position */
55 | extern int id3tag_write_v2(lame_global_flags * gfp);
56 | extern int id3tag_write_v1(lame_global_flags * gfp);
57 | /*
58 | * NOTE: A version 2 tag will NOT be added unless one of the text fields won't
59 | * fit in a version 1 tag (e.g. the title string is longer than 30 characters),
60 | * or the "id3tag_add_v2" or "id3tag_v2_only" functions are used.
61 | */
62 |
63 | #endif
64 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/lame_global_flags.h:
--------------------------------------------------------------------------------
1 | #ifndef LAME_GLOBAL_FLAGS_H
2 | #define LAME_GLOBAL_FLAGS_H
3 |
4 | #ifndef lame_internal_flags_defined
5 | #define lame_internal_flags_defined
6 | struct lame_internal_flags;
7 | typedef struct lame_internal_flags lame_internal_flags;
8 | #endif
9 |
10 |
11 | typedef enum short_block_e {
12 | short_block_not_set = -1, /* allow LAME to decide */
13 | short_block_allowed = 0, /* LAME may use them, even different block types for L/R */
14 | short_block_coupled, /* LAME may use them, but always same block types in L/R */
15 | short_block_dispensed, /* LAME will not use short blocks, long blocks only */
16 | short_block_forced /* LAME will not use long blocks, short blocks only */
17 | } short_block_t;
18 |
19 | /***********************************************************************
20 | *
21 | * Control Parameters set by User. These parameters are here for
22 | * backwards compatibility with the old, non-shared lib API.
23 | * Please use the lame_set_variablename() functions below
24 | *
25 | *
26 | ***********************************************************************/
27 | struct lame_global_struct {
28 | unsigned int class_id;
29 |
30 | /* input description */
31 | unsigned long num_samples; /* number of samples. default=2^32-1 */
32 | int num_channels; /* input number of channels. default=2 */
33 | int samplerate_in; /* input_samp_rate in Hz. default=44.1 kHz */
34 | int samplerate_out; /* output_samp_rate.
35 | default: LAME picks best value
36 | at least not used for MP3 decoding:
37 | Remember 44.1 kHz MP3s and AC97 */
38 | float scale; /* scale input by this amount before encoding
39 | at least not used for MP3 decoding */
40 | float scale_left; /* scale input of channel 0 (left) by this
41 | amount before encoding */
42 | float scale_right; /* scale input of channel 1 (right) by this
43 | amount before encoding */
44 |
45 | /* general control params */
46 | int analysis; /* collect data for a MP3 frame analyzer? */
47 | int write_lame_tag; /* add Xing VBR tag? */
48 | int decode_only; /* use lame/mpglib to convert mp3 to wav */
49 | int quality; /* quality setting 0=best, 9=worst default=5 */
50 | MPEG_mode mode; /* see enum in lame.h
51 | default = LAME picks best value */
52 | int force_ms; /* force M/S mode. requires mode=1 */
53 | int free_format; /* use free format? default=0 */
54 | int findReplayGain; /* find the RG value? default=0 */
55 | int decode_on_the_fly; /* decode on the fly? default=0 */
56 | int write_id3tag_automatic; /* 1 (default) writes ID3 tags, 0 not */
57 |
58 | int nogap_total;
59 | int nogap_current;
60 |
61 | int substep_shaping;
62 | int noise_shaping;
63 | int subblock_gain; /* 0 = no, 1 = yes */
64 | int use_best_huffman; /* 0 = no. 1=outside loop 2=inside loop(slow) */
65 |
66 | /*
67 | * set either brate>0 or compression_ratio>0, LAME will compute
68 | * the value of the variable not set.
69 | * Default is compression_ratio = 11.025
70 | */
71 | int brate; /* bitrate */
72 | float compression_ratio; /* sizeof(wav file)/sizeof(mp3 file) */
73 |
74 |
75 | /* frame params */
76 | int copyright; /* mark as copyright. default=0 */
77 | int original; /* mark as original. default=1 */
78 | int extension; /* the MP3 'private extension' bit.
79 | Meaningless */
80 | int emphasis; /* Input PCM is emphased PCM (for
81 | instance from one of the rarely
82 | emphased CDs), it is STRONGLY not
83 | recommended to use this, because
84 | psycho does not take it into account,
85 | and last but not least many decoders
86 | don't care about these bits */
87 | int error_protection; /* use 2 bytes per frame for a CRC
88 | checksum. default=0 */
89 | int strict_ISO; /* enforce ISO spec as much as possible */
90 |
91 | int disable_reservoir; /* use bit reservoir? */
92 |
93 | /* quantization/noise shaping */
94 | int quant_comp;
95 | int quant_comp_short;
96 | int experimentalY;
97 | int experimentalZ;
98 | int exp_nspsytune;
99 |
100 | int preset;
101 |
102 | /* VBR control */
103 | vbr_mode VBR;
104 | float VBR_q_frac; /* Range [0,...,1[ */
105 | int VBR_q; /* Range [0,...,9] */
106 | int VBR_mean_bitrate_kbps;
107 | int VBR_min_bitrate_kbps;
108 | int VBR_max_bitrate_kbps;
109 | int VBR_hard_min; /* strictly enforce VBR_min_bitrate
110 | normaly, it will be violated for analog
111 | silence */
112 |
113 |
114 | /* resampling and filtering */
115 | int lowpassfreq; /* freq in Hz. 0=lame choses.
116 | -1=no filter */
117 | int highpassfreq; /* freq in Hz. 0=lame choses.
118 | -1=no filter */
119 | int lowpasswidth; /* freq width of filter, in Hz
120 | (default=15%) */
121 | int highpasswidth; /* freq width of filter, in Hz
122 | (default=15%) */
123 |
124 |
125 |
126 | /*
127 | * psycho acoustics and other arguments which you should not change
128 | * unless you know what you are doing
129 | */
130 | float maskingadjust;
131 | float maskingadjust_short;
132 | int ATHonly; /* only use ATH */
133 | int ATHshort; /* only use ATH for short blocks */
134 | int noATH; /* disable ATH */
135 | int ATHtype; /* select ATH formula */
136 | float ATHcurve; /* change ATH formula 4 shape */
137 | float ATH_lower_db; /* lower ATH by this many db */
138 | int athaa_type; /* select ATH auto-adjust scheme */
139 | float athaa_sensitivity; /* dB, tune active region of auto-level */
140 | short_block_t short_blocks;
141 | int useTemporal; /* use temporal masking effect */
142 | float interChRatio;
143 | float msfix; /* Naoki's adjustment of Mid/Side maskings */
144 |
145 | int tune; /* 0 off, 1 on */
146 | float tune_value_a; /* used to pass values for debugging and stuff */
147 |
148 | float attackthre; /* attack threshold for L/R/M channel */
149 | float attackthre_s; /* attack threshold for S channel */
150 |
151 |
152 | struct {
153 | void (*msgf) (const char *format, va_list ap);
154 | void (*debugf) (const char *format, va_list ap);
155 | void (*errorf) (const char *format, va_list ap);
156 | } report;
157 |
158 | /************************************************************************/
159 | /* internal variables, do not set... */
160 | /* provided because they may be of use to calling application */
161 | /************************************************************************/
162 |
163 | int lame_allocated_gfp; /* is this struct owned by calling
164 | program or lame? */
165 |
166 |
167 |
168 | /**************************************************************************/
169 | /* more internal variables are stored in this structure: */
170 | /**************************************************************************/
171 | lame_internal_flags *internal_flags;
172 |
173 |
174 | struct {
175 | int mmx;
176 | int amd3dnow;
177 | int sse;
178 |
179 | } asm_optimizations;
180 | };
181 |
182 | int is_lame_global_flags_valid(const lame_global_flags * gfp);
183 |
184 | #endif /* LAME_GLOBAL_FLAGS_H */
185 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 | #if (LAME_RELEASE_VERSION == 0)
28 | #undef NDEBUG
29 | #endif
30 |
31 | #include
32 | #include
33 |
34 | #ifdef STDC_HEADERS
35 | # include
36 | # include
37 | #else
38 | # ifndef HAVE_STRCHR
39 | # define strchr index
40 | # define strrchr rindex
41 | # endif
42 | char *strchr(), *strrchr();
43 | # ifndef HAVE_MEMCPY
44 | # define memcpy(d, s, n) bcopy ((s), (d), (n))
45 | # define memmove(d, s, n) bcopy ((s), (d), (n))
46 | # endif
47 | #endif
48 |
49 | #if defined(__riscos__) && defined(FPA10)
50 | # include "ymath.h"
51 | #else
52 | # include
53 | #endif
54 | #include
55 |
56 | #include
57 |
58 | #ifdef HAVE_ERRNO_H
59 | # include
60 | #endif
61 | #ifdef HAVE_FCNTL_H
62 | # include
63 | #endif
64 |
65 | #if defined(macintosh)
66 | # include
67 | # include
68 | #else
69 | # include
70 | # include
71 | #endif
72 |
73 | #ifdef HAVE_INTTYPES_H
74 | # include
75 | #else
76 | # ifdef HAVE_STDINT_H
77 | # include
78 | # endif
79 | #endif
80 |
81 | #ifdef WITH_DMALLOC
82 | #include
83 | #endif
84 |
85 | /*
86 | * 3 different types of pow() functions:
87 | * - table lookup
88 | * - pow()
89 | * - exp() on some machines this is claimed to be faster than pow()
90 | */
91 |
92 | #define POW20(x) (assert(0 <= (x+Q_MAX2) && x < Q_MAX), pow20[x+Q_MAX2])
93 | /*#define POW20(x) pow(2.0,((double)(x)-210)*.25) */
94 | /*#define POW20(x) exp( ((double)(x)-210)*(.25*LOG2) ) */
95 |
96 | #define IPOW20(x) (assert(0 <= x && x < Q_MAX), ipow20[x])
97 | /*#define IPOW20(x) exp( -((double)(x)-210)*.1875*LOG2 ) */
98 | /*#define IPOW20(x) pow(2.0,-((double)(x)-210)*.1875) */
99 |
100 | /* in case this is used without configure */
101 | #ifndef inline
102 | # define inline
103 | #endif
104 |
105 | #if defined(_MSC_VER)
106 | # undef inline
107 | # define inline _inline
108 | #elif defined(__SASC) || defined(__GNUC__) || defined(__ICC) || defined(__ECC)
109 | /* if __GNUC__ we always want to inline, not only if the user requests it */
110 | # undef inline
111 | # define inline __inline
112 | #endif
113 |
114 | #if defined(_MSC_VER)
115 | # pragma warning( disable : 4244 )
116 | /*# pragma warning( disable : 4305 ) */
117 | #endif
118 |
119 | /*
120 | * FLOAT for variables which require at least 32 bits
121 | * FLOAT8 for variables which require at least 64 bits
122 | *
123 | * On some machines, 64 bit will be faster than 32 bit. Also, some math
124 | * routines require 64 bit float, so setting FLOAT=float will result in a
125 | * lot of conversions.
126 | */
127 |
128 | #if ( defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) )
129 | # define WIN32_LEAN_AND_MEAN
130 | # include
131 | # include
132 | # define FLOAT_MAX FLT_MAX
133 | #else
134 | # ifndef FLOAT
135 | typedef float FLOAT;
136 | # ifdef FLT_MAX
137 | # define FLOAT_MAX FLT_MAX
138 | # else
139 | # define FLOAT_MAX 1e37 /* approx */
140 | # endif
141 | # endif
142 | #endif
143 |
144 | #ifndef FLOAT8
145 | typedef double FLOAT8;
146 | # ifdef DBL_MAX
147 | # define FLOAT8_MAX DBL_MAX
148 | # else
149 | # define FLOAT8_MAX 1e99 /* approx */
150 | # endif
151 | #else
152 | # ifdef FLT_MAX
153 | # define FLOAT8_MAX FLT_MAX
154 | # else
155 | # define FLOAT8_MAX 1e37 /* approx */
156 | # endif
157 | #endif
158 |
159 | /* sample_t must be floating point, at least 32 bits */
160 | typedef FLOAT sample_t;
161 |
162 | #define dimension_of(array) (sizeof(array)/sizeof(array[0]))
163 | #define beyond(array) (array+dimension_of(array))
164 | #define compiletime_assert(expression) extern char static_assert_##FILE##_##LINE[expression?1:0]
165 |
166 | #if 1
167 | #define EQ(a,b) (\
168 | (fabs(a) > fabs(b)) \
169 | ? (fabs((a)-(b)) <= (fabs(a) * 1e-6f)) \
170 | : (fabs((a)-(b)) <= (fabs(b) * 1e-6f)))
171 | #else
172 | #define EQ(a,b) (fabs((a)-(b))<1E-37)
173 | #endif
174 |
175 | #define NEQ(a,b) (!EQ(a,b))
176 |
177 | #endif
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 |
188 | /* end of machine.h */
189 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/mpglib_interface.c:
--------------------------------------------------------------------------------
1 | /* -*- mode: C; mode: fold -*- */
2 | /*
3 | * LAME MP3 encoding engine
4 | *
5 | * Copyright (c) 1999-2000 Mark Taylor
6 | * Copyright (c) 2003 Olcios
7 | * Copyright (c) 2008 Robert Hegemann
8 | *
9 | * This library is free software; you can redistribute it and/or
10 | * modify it under the terms of the GNU Library General Public
11 | * License as published by the Free Software Foundation; either
12 | * version 2 of the License, or (at your option) any later version.
13 | *
14 | * This library is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | * Library General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Library General Public
20 | * License along with this library; if not, write to the
21 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 | * Boston, MA 02111-1307, USA.
23 | */
24 |
25 | /* $Id: mpglib_interface.c,v 1.42 2011/05/07 16:05:17 rbrito Exp $ */
26 |
27 | #ifdef HAVE_CONFIG_H
28 | # include
29 | #endif
30 |
31 | #ifdef HAVE_MPGLIB
32 | #define hip_global_struct mpstr_tag
33 | #include "lame.h"
34 | #include "machine.h"
35 | #include "encoder.h"
36 | #include "interface.h"
37 |
38 | #include "util.h"
39 |
40 |
41 |
42 | #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
43 | /*
44 | * OBSOLETE:
45 | * - kept to let it link
46 | * - forward declaration to silence compiler
47 | */
48 | int CDECL lame_decode_init(void);
49 | int CDECL lame_decode(
50 | unsigned char * mp3buf,
51 | int len,
52 | short pcm_l[],
53 | short pcm_r[] );
54 | int CDECL lame_decode_headers(
55 | unsigned char* mp3buf,
56 | int len,
57 | short pcm_l[],
58 | short pcm_r[],
59 | mp3data_struct* mp3data );
60 | int CDECL lame_decode1(
61 | unsigned char* mp3buf,
62 | int len,
63 | short pcm_l[],
64 | short pcm_r[] );
65 | int CDECL lame_decode1_headers(
66 | unsigned char* mp3buf,
67 | int len,
68 | short pcm_l[],
69 | short pcm_r[],
70 | mp3data_struct* mp3data );
71 | int CDECL lame_decode1_headersB(
72 | unsigned char* mp3buf,
73 | int len,
74 | short pcm_l[],
75 | short pcm_r[],
76 | mp3data_struct* mp3data,
77 | int *enc_delay,
78 | int *enc_padding );
79 | int CDECL lame_decode_exit(void);
80 | #endif
81 |
82 |
83 | static MPSTR mp;
84 |
85 | int
86 | lame_decode_exit(void)
87 | {
88 | ExitMP3(&mp);
89 | return 0;
90 | }
91 |
92 |
93 | int
94 | lame_decode_init(void)
95 | {
96 | (void) InitMP3(&mp);
97 | return 0;
98 | }
99 |
100 |
101 |
102 |
103 | /* copy mono samples */
104 | #define COPY_MONO(DST_TYPE, SRC_TYPE) \
105 | DST_TYPE *pcm_l = (DST_TYPE *)pcm_l_raw; \
106 | SRC_TYPE const *p_samples = (SRC_TYPE const *)p; \
107 | for (i = 0; i < processed_samples; i++) \
108 | *pcm_l++ = (DST_TYPE)(*p_samples++);
109 |
110 | /* copy stereo samples */
111 | #define COPY_STEREO(DST_TYPE, SRC_TYPE) \
112 | DST_TYPE *pcm_l = (DST_TYPE *)pcm_l_raw, *pcm_r = (DST_TYPE *)pcm_r_raw; \
113 | SRC_TYPE const *p_samples = (SRC_TYPE const *)p; \
114 | for (i = 0; i < processed_samples; i++) { \
115 | *pcm_l++ = (DST_TYPE)(*p_samples++); \
116 | *pcm_r++ = (DST_TYPE)(*p_samples++); \
117 | }
118 |
119 |
120 |
121 | /*
122 | * For lame_decode: return code
123 | * -1 error
124 | * 0 ok, but need more data before outputing any samples
125 | * n number of samples output. either 576 or 1152 depending on MP3 file.
126 | */
127 |
128 | static int
129 | decode1_headersB_clipchoice(PMPSTR pmp, unsigned char *buffer, int len,
130 | char pcm_l_raw[], char pcm_r_raw[], mp3data_struct * mp3data,
131 | int *enc_delay, int *enc_padding,
132 | char *p, size_t psize, int decoded_sample_size,
133 | int (*decodeMP3_ptr) (PMPSTR, unsigned char *, int, char *, int,
134 | int *))
135 | {
136 | static const int smpls[2][4] = {
137 | /* Layer I II III */
138 | {0, 384, 1152, 1152}, /* MPEG-1 */
139 | {0, 384, 1152, 576} /* MPEG-2(.5) */
140 | };
141 |
142 | int processed_bytes;
143 | int processed_samples; /* processed samples per channel */
144 | int ret;
145 | int i;
146 |
147 | mp3data->header_parsed = 0;
148 |
149 | ret = (*decodeMP3_ptr) (pmp, buffer, len, p, (int) psize, &processed_bytes);
150 | /* three cases:
151 | * 1. headers parsed, but data not complete
152 | * pmp->header_parsed==1
153 | * pmp->framesize=0
154 | * pmp->fsizeold=size of last frame, or 0 if this is first frame
155 | *
156 | * 2. headers, data parsed, but ancillary data not complete
157 | * pmp->header_parsed==1
158 | * pmp->framesize=size of frame
159 | * pmp->fsizeold=size of last frame, or 0 if this is first frame
160 | *
161 | * 3. frame fully decoded:
162 | * pmp->header_parsed==0
163 | * pmp->framesize=0
164 | * pmp->fsizeold=size of frame (which is now the last frame)
165 | *
166 | */
167 | if (pmp->header_parsed || pmp->fsizeold > 0 || pmp->framesize > 0) {
168 | mp3data->header_parsed = 1;
169 | mp3data->stereo = pmp->fr.stereo;
170 | mp3data->samplerate = freqs[pmp->fr.sampling_frequency];
171 | mp3data->mode = pmp->fr.mode;
172 | mp3data->mode_ext = pmp->fr.mode_ext;
173 | mp3data->framesize = smpls[pmp->fr.lsf][pmp->fr.lay];
174 |
175 | /* free format, we need the entire frame before we can determine
176 | * the bitrate. If we haven't gotten the entire frame, bitrate=0 */
177 | if (pmp->fsizeold > 0) /* works for free format and fixed, no overrun, temporal results are < 400.e6 */
178 | mp3data->bitrate = 8 * (4 + pmp->fsizeold) * mp3data->samplerate /
179 | (1.e3 * mp3data->framesize) + 0.5;
180 | else if (pmp->framesize > 0)
181 | mp3data->bitrate = 8 * (4 + pmp->framesize) * mp3data->samplerate /
182 | (1.e3 * mp3data->framesize) + 0.5;
183 | else
184 | mp3data->bitrate = tabsel_123[pmp->fr.lsf][pmp->fr.lay - 1][pmp->fr.bitrate_index];
185 |
186 |
187 |
188 | if (pmp->num_frames > 0) {
189 | /* Xing VBR header found and num_frames was set */
190 | mp3data->totalframes = pmp->num_frames;
191 | mp3data->nsamp = mp3data->framesize * pmp->num_frames;
192 | *enc_delay = pmp->enc_delay;
193 | *enc_padding = pmp->enc_padding;
194 | }
195 | }
196 |
197 | switch (ret) {
198 | case MP3_OK:
199 | switch (pmp->fr.stereo) {
200 | case 1:
201 | processed_samples = processed_bytes / decoded_sample_size;
202 | if (decoded_sample_size == sizeof(short)) {
203 | COPY_MONO(short, short)
204 | }
205 | else {
206 | COPY_MONO(sample_t, FLOAT)
207 | }
208 | break;
209 | case 2:
210 | processed_samples = (processed_bytes / decoded_sample_size) >> 1;
211 | if (decoded_sample_size == sizeof(short)) {
212 | COPY_STEREO(short, short)
213 | }
214 | else {
215 | COPY_STEREO(sample_t, FLOAT)
216 | }
217 | break;
218 | default:
219 | processed_samples = -1;
220 | assert(0);
221 | break;
222 | }
223 | break;
224 |
225 | case MP3_NEED_MORE:
226 | processed_samples = 0;
227 | break;
228 |
229 | case MP3_ERR:
230 | processed_samples = -1;
231 | break;
232 |
233 | default:
234 | processed_samples = -1;
235 | assert(0);
236 | break;
237 | }
238 |
239 | /*fprintf(stderr,"ok, more, err: %i %i %i\n", MP3_OK, MP3_NEED_MORE, MP3_ERR ); */
240 | /*fprintf(stderr,"ret = %i out=%i\n", ret, processed_samples ); */
241 | return processed_samples;
242 | }
243 |
244 |
245 | #define OUTSIZE_CLIPPED (4096*sizeof(short))
246 |
247 | int
248 | lame_decode1_headersB(unsigned char *buffer,
249 | int len,
250 | short pcm_l[], short pcm_r[], mp3data_struct * mp3data,
251 | int *enc_delay, int *enc_padding)
252 | {
253 | static char out[OUTSIZE_CLIPPED];
254 |
255 | return decode1_headersB_clipchoice(&mp, buffer, len, (char *) pcm_l, (char *) pcm_r, mp3data,
256 | enc_delay, enc_padding, out, OUTSIZE_CLIPPED,
257 | sizeof(short), decodeMP3);
258 | }
259 |
260 |
261 |
262 |
263 |
264 | /*
265 | * For lame_decode: return code
266 | * -1 error
267 | * 0 ok, but need more data before outputing any samples
268 | * n number of samples output. Will be at most one frame of
269 | * MPEG data.
270 | */
271 |
272 | int
273 | lame_decode1_headers(unsigned char *buffer,
274 | int len, short pcm_l[], short pcm_r[], mp3data_struct * mp3data)
275 | {
276 | int enc_delay, enc_padding;
277 | return lame_decode1_headersB(buffer, len, pcm_l, pcm_r, mp3data, &enc_delay, &enc_padding);
278 | }
279 |
280 |
281 | int
282 | lame_decode1(unsigned char *buffer, int len, short pcm_l[], short pcm_r[])
283 | {
284 | mp3data_struct mp3data;
285 |
286 | return lame_decode1_headers(buffer, len, pcm_l, pcm_r, &mp3data);
287 | }
288 |
289 |
290 | /*
291 | * For lame_decode: return code
292 | * -1 error
293 | * 0 ok, but need more data before outputing any samples
294 | * n number of samples output. a multiple of 576 or 1152 depending on MP3 file.
295 | */
296 |
297 | int
298 | lame_decode_headers(unsigned char *buffer,
299 | int len, short pcm_l[], short pcm_r[], mp3data_struct * mp3data)
300 | {
301 | int ret;
302 | int totsize = 0; /* number of decoded samples per channel */
303 |
304 | for (;;) {
305 | switch (ret = lame_decode1_headers(buffer, len, pcm_l + totsize, pcm_r + totsize, mp3data)) {
306 | case -1:
307 | return ret;
308 | case 0:
309 | return totsize;
310 | default:
311 | totsize += ret;
312 | len = 0; /* future calls to decodeMP3 are just to flush buffers */
313 | break;
314 | }
315 | }
316 | }
317 |
318 |
319 | int
320 | lame_decode(unsigned char *buffer, int len, short pcm_l[], short pcm_r[])
321 | {
322 | mp3data_struct mp3data;
323 |
324 | return lame_decode_headers(buffer, len, pcm_l, pcm_r, &mp3data);
325 | }
326 |
327 |
328 |
329 |
330 | hip_t hip_decode_init(void)
331 | {
332 | hip_t hip = calloc(1, sizeof(hip_global_flags));
333 | InitMP3(hip);
334 | return hip;
335 | }
336 |
337 |
338 | int hip_decode_exit(hip_t hip)
339 | {
340 | if (hip) {
341 | ExitMP3(hip);
342 | free(hip);
343 | }
344 | return 0;
345 | }
346 |
347 |
348 | /* we forbid input with more than 1152 samples per channel for output in the unclipped mode */
349 | #define OUTSIZE_UNCLIPPED (1152*2*sizeof(FLOAT))
350 |
351 | int
352 | hip_decode1_unclipped(hip_t hip, unsigned char *buffer, size_t len, sample_t pcm_l[], sample_t pcm_r[])
353 | {
354 | static char out[OUTSIZE_UNCLIPPED];
355 | mp3data_struct mp3data;
356 | int enc_delay, enc_padding;
357 |
358 | if (hip) {
359 | return decode1_headersB_clipchoice(hip, buffer, len, (char *) pcm_l, (char *) pcm_r, &mp3data,
360 | &enc_delay, &enc_padding, out, OUTSIZE_UNCLIPPED,
361 | sizeof(FLOAT), decodeMP3_unclipped);
362 | }
363 | return 0;
364 | }
365 |
366 | /*
367 | * For hip_decode: return code
368 | * -1 error
369 | * 0 ok, but need more data before outputing any samples
370 | * n number of samples output. Will be at most one frame of
371 | * MPEG data.
372 | */
373 |
374 | int
375 | hip_decode1_headers(hip_t hip, unsigned char *buffer,
376 | size_t len, short pcm_l[], short pcm_r[], mp3data_struct * mp3data)
377 | {
378 | int enc_delay, enc_padding;
379 | return hip_decode1_headersB(hip, buffer, len, pcm_l, pcm_r, mp3data, &enc_delay, &enc_padding);
380 | }
381 |
382 |
383 | int
384 | hip_decode1(hip_t hip, unsigned char *buffer, size_t len, short pcm_l[], short pcm_r[])
385 | {
386 | mp3data_struct mp3data;
387 | return hip_decode1_headers(hip, buffer, len, pcm_l, pcm_r, &mp3data);
388 | }
389 |
390 |
391 | /*
392 | * For hip_decode: return code
393 | * -1 error
394 | * 0 ok, but need more data before outputing any samples
395 | * n number of samples output. a multiple of 576 or 1152 depending on MP3 file.
396 | */
397 |
398 | int
399 | hip_decode_headers(hip_t hip, unsigned char *buffer,
400 | size_t len, short pcm_l[], short pcm_r[], mp3data_struct * mp3data)
401 | {
402 | int ret;
403 | int totsize = 0; /* number of decoded samples per channel */
404 |
405 | for (;;) {
406 | switch (ret = hip_decode1_headers(hip, buffer, len, pcm_l + totsize, pcm_r + totsize, mp3data)) {
407 | case -1:
408 | return ret;
409 | case 0:
410 | return totsize;
411 | default:
412 | totsize += ret;
413 | len = 0; /* future calls to decodeMP3 are just to flush buffers */
414 | break;
415 | }
416 | }
417 | }
418 |
419 |
420 | int
421 | hip_decode(hip_t hip, unsigned char *buffer, size_t len, short pcm_l[], short pcm_r[])
422 | {
423 | mp3data_struct mp3data;
424 | return hip_decode_headers(hip, buffer, len, pcm_l, pcm_r, &mp3data);
425 | }
426 |
427 |
428 | int
429 | hip_decode1_headersB(hip_t hip, unsigned char *buffer,
430 | size_t len,
431 | short pcm_l[], short pcm_r[], mp3data_struct * mp3data,
432 | int *enc_delay, int *enc_padding)
433 | {
434 | static char out[OUTSIZE_CLIPPED];
435 | if (hip) {
436 | return decode1_headersB_clipchoice(hip, buffer, len, (char *) pcm_l, (char *) pcm_r, mp3data,
437 | enc_delay, enc_padding, out, OUTSIZE_CLIPPED,
438 | sizeof(short), decodeMP3);
439 | }
440 | return -1;
441 | }
442 |
443 |
444 | void hip_set_pinfo(hip_t hip, plotting_data* pinfo)
445 | {
446 | if (hip) {
447 | hip->pinfo = pinfo;
448 | }
449 | }
450 |
451 |
452 |
453 | void hip_set_errorf(hip_t hip, lame_report_function func)
454 | {
455 | if (hip) {
456 | hip->report_err = func;
457 | }
458 | }
459 |
460 | void hip_set_debugf(hip_t hip, lame_report_function func)
461 | {
462 | if (hip) {
463 | hip->report_dbg = func;
464 | }
465 | }
466 |
467 | void hip_set_msgf (hip_t hip, lame_report_function func)
468 | {
469 | if (hip) {
470 | hip->report_msg = func;
471 | }
472 | }
473 |
474 | #endif
475 |
476 | /* end of mpglib_interface.c */
477 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/reservoir.c:
--------------------------------------------------------------------------------
1 | /*
2 | * bit reservoir source file
3 | *
4 | * Copyright (c) 1999-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 | /* $Id: reservoir.c,v 1.45 2011/05/07 16:05:17 rbrito Exp $ */
23 |
24 | #ifdef HAVE_CONFIG_H
25 | # include
26 | #endif
27 |
28 |
29 | #include "lame.h"
30 | #include "machine.h"
31 | #include "encoder.h"
32 | #include "util.h"
33 | #include "reservoir.h"
34 |
35 | #include "bitstream.h"
36 | #include "lame-analysis.h"
37 | #include "lame_global_flags.h"
38 |
39 |
40 | /*
41 | ResvFrameBegin:
42 | Called (repeatedly) at the beginning of a frame. Updates the maximum
43 | size of the reservoir, and checks to make sure main_data_begin
44 | was set properly by the formatter
45 | */
46 |
47 | /*
48 | * Background information:
49 | *
50 | * This is the original text from the ISO standard. Because of
51 | * sooo many bugs and irritations correcting comments are added
52 | * in brackets []. A '^W' means you should remove the last word.
53 | *
54 | * 1) The following rule can be used to calculate the maximum
55 | * number of bits used for one granule [^W frame]:
56 | * At the highest possible bitrate of Layer III (320 kbps
57 | * per stereo signal [^W^W^W], 48 kHz) the frames must be of
58 | * [^W^W^W are designed to have] constant length, i.e.
59 | * one buffer [^W^W the frame] length is:
60 | *
61 | * 320 kbps * 1152/48 kHz = 7680 bit = 960 byte
62 | *
63 | * This value is used as the maximum buffer per channel [^W^W] at
64 | * lower bitrates [than 320 kbps]. At 64 kbps mono or 128 kbps
65 | * stereo the main granule length is 64 kbps * 576/48 kHz = 768 bit
66 | * [per granule and channel] at 48 kHz sampling frequency.
67 | * This means that there is a maximum deviation (short time buffer
68 | * [= reservoir]) of 7680 - 2*2*768 = 4608 bits is allowed at 64 kbps.
69 | * The actual deviation is equal to the number of bytes [with the
70 | * meaning of octets] denoted by the main_data_end offset pointer.
71 | * The actual maximum deviation is (2^9-1)*8 bit = 4088 bits
72 | * [for MPEG-1 and (2^8-1)*8 bit for MPEG-2, both are hard limits].
73 | * ... The xchange of buffer bits between the left and right channel
74 | * is allowed without restrictions [exception: dual channel].
75 | * Because of the [constructed] constraint on the buffer size
76 | * main_data_end is always set to 0 in the case of bit_rate_index==14,
77 | * i.e. data rate 320 kbps per stereo signal [^W^W^W]. In this case
78 | * all data are allocated between adjacent header [^W sync] words
79 | * [, i.e. there is no buffering at all].
80 | */
81 |
82 | int
83 | ResvFrameBegin(lame_internal_flags * gfc, int *mean_bits)
84 | {
85 | SessionConfig_t const *const cfg = &gfc->cfg;
86 | EncStateVar_t *const esv = &gfc->sv_enc;
87 | int fullFrameBits;
88 | int resvLimit;
89 | int maxmp3buf;
90 | III_side_info_t *const l3_side = &gfc->l3_side;
91 | int frameLength;
92 | int meanBits;
93 |
94 | frameLength = getframebits(gfc);
95 | meanBits = (frameLength - cfg->sideinfo_len * 8) / cfg->mode_gr;
96 |
97 | /*
98 | * Meaning of the variables:
99 | * resvLimit: (0, 8, ..., 8*255 (MPEG-2), 8*511 (MPEG-1))
100 | * Number of bits can be stored in previous frame(s) due to
101 | * counter size constaints
102 | * maxmp3buf: ( ??? ... 8*1951 (MPEG-1 and 2), 8*2047 (MPEG-2.5))
103 | * Number of bits allowed to encode one frame (you can take 8*511 bit
104 | * from the bit reservoir and at most 8*1440 bit from the current
105 | * frame (320 kbps, 32 kHz), so 8*1951 bit is the largest possible
106 | * value for MPEG-1 and -2)
107 | *
108 | * maximum allowed granule/channel size times 4 = 8*2047 bits.,
109 | * so this is the absolute maximum supported by the format.
110 | *
111 | *
112 | * fullFrameBits: maximum number of bits available for encoding
113 | * the current frame.
114 | *
115 | * mean_bits: target number of bits per granule.
116 | *
117 | * frameLength:
118 | *
119 | * gfc->ResvMax: maximum allowed reservoir
120 | *
121 | * gfc->ResvSize: current reservoir size
122 | *
123 | * l3_side->resvDrain_pre:
124 | * ancillary data to be added to previous frame:
125 | * (only usefull in VBR modes if it is possible to have
126 | * maxmp3buf < fullFrameBits)). Currently disabled,
127 | * see #define NEW_DRAIN
128 | * 2010-02-13: RH now enabled, it seems to be needed for CBR too,
129 | * as there exists one example, where the FhG decoder
130 | * can't decode a -b320 CBR file anymore.
131 | *
132 | * l3_side->resvDrain_post:
133 | * ancillary data to be added to this frame:
134 | *
135 | */
136 |
137 | /* main_data_begin has 9 bits in MPEG-1, 8 bits MPEG-2 */
138 | resvLimit = (8 * 256) * cfg->mode_gr - 8;
139 |
140 | /* maximum allowed frame size. dont use more than this number of
141 | bits, even if the frame has the space for them: */
142 | maxmp3buf = cfg->buffer_constraint;
143 | esv->ResvMax = maxmp3buf - frameLength;
144 | if (esv->ResvMax > resvLimit)
145 | esv->ResvMax = resvLimit;
146 | if (esv->ResvMax < 0 || cfg->disable_reservoir)
147 | esv->ResvMax = 0;
148 |
149 | fullFrameBits = meanBits * cfg->mode_gr + Min(esv->ResvSize, esv->ResvMax);
150 |
151 | if (fullFrameBits > maxmp3buf)
152 | fullFrameBits = maxmp3buf;
153 |
154 | assert(0 == esv->ResvMax % 8);
155 | assert(esv->ResvMax >= 0);
156 |
157 | l3_side->resvDrain_pre = 0;
158 |
159 | if (gfc->pinfo != NULL) {
160 | gfc->pinfo->mean_bits = meanBits / 2; /* expected bits per channel per granule [is this also right for mono/stereo, MPEG-1/2 ?] */
161 | gfc->pinfo->resvsize = esv->ResvSize;
162 | }
163 | *mean_bits = meanBits;
164 | return fullFrameBits;
165 | }
166 |
167 |
168 | /*
169 | ResvMaxBits
170 | returns targ_bits: target number of bits to use for 1 granule
171 | extra_bits: amount extra available from reservoir
172 | Mark Taylor 4/99
173 | */
174 | void
175 | ResvMaxBits(lame_internal_flags * gfc, int mean_bits, int *targ_bits, int *extra_bits, int cbr)
176 | {
177 | SessionConfig_t const *const cfg = &gfc->cfg;
178 | EncStateVar_t *const esv = &gfc->sv_enc;
179 | int add_bits, targBits, extraBits;
180 | int ResvSize = esv->ResvSize, ResvMax = esv->ResvMax;
181 |
182 | /* conpensate the saved bits used in the 1st granule */
183 | if (cbr)
184 | ResvSize += mean_bits;
185 |
186 | if (gfc->sv_qnt.substep_shaping & 1)
187 | ResvMax *= 0.9;
188 |
189 | targBits = mean_bits;
190 |
191 | /* extra bits if the reservoir is almost full */
192 | if (ResvSize * 10 > ResvMax * 9) {
193 | add_bits = ResvSize - (ResvMax * 9) / 10;
194 | targBits += add_bits;
195 | gfc->sv_qnt.substep_shaping |= 0x80;
196 | }
197 | else {
198 | add_bits = 0;
199 | gfc->sv_qnt.substep_shaping &= 0x7f;
200 | /* build up reservoir. this builds the reservoir a little slower
201 | * than FhG. It could simple be mean_bits/15, but this was rigged
202 | * to always produce 100 (the old value) at 128kbs */
203 | /* *targ_bits -= (int) (mean_bits/15.2); */
204 | if (!cfg->disable_reservoir && !(gfc->sv_qnt.substep_shaping & 1))
205 | targBits -= .1 * mean_bits;
206 | }
207 |
208 |
209 | /* amount from the reservoir we are allowed to use. ISO says 6/10 */
210 | extraBits = (ResvSize < (esv->ResvMax * 6) / 10 ? ResvSize : (esv->ResvMax * 6) / 10);
211 | extraBits -= add_bits;
212 |
213 | if (extraBits < 0)
214 | extraBits = 0;
215 |
216 | *targ_bits = targBits;
217 | *extra_bits = extraBits;
218 | }
219 |
220 | /*
221 | ResvAdjust:
222 | Called after a granule's bit allocation. Readjusts the size of
223 | the reservoir to reflect the granule's usage.
224 | */
225 | void
226 | ResvAdjust(lame_internal_flags * gfc, gr_info const *gi)
227 | {
228 | gfc->sv_enc.ResvSize -= gi->part2_3_length + gi->part2_length;
229 | }
230 |
231 |
232 | /*
233 | ResvFrameEnd:
234 | Called after all granules in a frame have been allocated. Makes sure
235 | that the reservoir size is within limits, possibly by adding stuffing
236 | bits.
237 | */
238 | void
239 | ResvFrameEnd(lame_internal_flags * gfc, int mean_bits)
240 | {
241 | SessionConfig_t const *const cfg = &gfc->cfg;
242 | EncStateVar_t *const esv = &gfc->sv_enc;
243 | III_side_info_t *const l3_side = &gfc->l3_side;
244 | int stuffingBits;
245 | int over_bits;
246 |
247 | esv->ResvSize += mean_bits * cfg->mode_gr;
248 | stuffingBits = 0;
249 | l3_side->resvDrain_post = 0;
250 | l3_side->resvDrain_pre = 0;
251 |
252 | /* we must be byte aligned */
253 | if ((over_bits = esv->ResvSize % 8) != 0)
254 | stuffingBits += over_bits;
255 |
256 |
257 | over_bits = (esv->ResvSize - stuffingBits) - esv->ResvMax;
258 | if (over_bits > 0) {
259 | assert(0 == over_bits % 8);
260 | assert(over_bits >= 0);
261 | stuffingBits += over_bits;
262 | }
263 |
264 |
265 | /* NOTE: enabling the NEW_DRAIN code fixes some problems with FhG decoder
266 | shipped with MS Windows operating systems. Using this, it is even
267 | possible to use Gabriel's lax buffer consideration again, which
268 | assumes, any decoder should have a buffer large enough
269 | for a 320 kbps frame at 32 kHz sample rate.
270 |
271 | old drain code:
272 | lame -b320 BlackBird.wav ---> does not play with GraphEdit.exe using FhG decoder V1.5 Build 50
273 |
274 | new drain code:
275 | lame -b320 BlackBird.wav ---> plays fine with GraphEdit.exe using FhG decoder V1.5 Build 50
276 |
277 | Robert Hegemann, 2010-02-13.
278 | */
279 | /* drain as many bits as possible into previous frame ancillary data
280 | * In particular, in VBR mode ResvMax may have changed, and we have
281 | * to make sure main_data_begin does not create a reservoir bigger
282 | * than ResvMax mt 4/00*/
283 | {
284 | int mdb_bytes = Min(l3_side->main_data_begin * 8, stuffingBits) / 8;
285 | l3_side->resvDrain_pre += 8 * mdb_bytes;
286 | stuffingBits -= 8 * mdb_bytes;
287 | esv->ResvSize -= 8 * mdb_bytes;
288 | l3_side->main_data_begin -= mdb_bytes;
289 | }
290 | /* drain the rest into this frames ancillary data */
291 | l3_side->resvDrain_post += stuffingBits;
292 | esv->ResvSize -= stuffingBits;
293 | }
294 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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.32.2.2 2011/11/18 09:18:28 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 |
--------------------------------------------------------------------------------
/app/src/main/jni/libmp3lame/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 99 /* Minor version number */
39 | # define LAME_TYPE_VERSION 2 /* 0:alpha 1:beta 2:release */
40 | # define LAME_PATCH_VERSION 5 /* 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 |
--------------------------------------------------------------------------------
/app/src/main/library/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/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 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
25 |
31 |
37 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main2.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MyMp3Convert
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/test/java/com/convert/mymp3convert/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.convert.mymp3convert;
2 |
3 | import org.junit.Test;
4 |
5 | import java.util.concurrent.ConcurrentHashMap;
6 |
7 | import static org.junit.Assert.*;
8 |
9 | /**
10 | * Example local unit test, which will execute on the development machine (host).
11 | *
12 | * @see Testing documentation
13 | */
14 | public class ExampleUnitTest {
15 | @Test
16 | public void addition_isCorrect() {
17 | assertEquals(4, 2 + 2);
18 | }
19 | @Test
20 | public void test(){
21 | ConcurrentHashMap map = new ConcurrentHashMap();
22 | map.put("m1",1);
23 | map.put("m2",2);
24 | map.put("m3",3);
25 | map.put("m4",4);
26 | map.put("m5",5);
27 | map.put("m6",6);
28 | System.out.println(map);
29 | map.remove("m1");
30 | System.out.println(map);
31 | System.out.println(map.contains(2));
32 | System.out.println(map.containsValue(2));
33 | System.out.println(map.containsKey("m2"));
34 | System.out.println(map.contains(1));
35 | System.out.println(map.containsValue(1));
36 | System.out.println(map.containsKey("m1"));
37 | System.out.println(map.get("m1"));
38 | map.put("m3",100);
39 | System.out.println(map.get("m3"));
40 | System.out.println(map);
41 | }
42 | }
--------------------------------------------------------------------------------
/app/说明 .txt:
--------------------------------------------------------------------------------
1 | G:\e\work\test\MyJniDemo\app\src\main\java>javac com\example\myjnidemo\LameUtils.java
2 |
3 | G:\e\work\test\MyJniDemo\app\src\main\java>javap -s -p com.example.myjnidemo.LameUtils
4 | Compiled from "LameUtils.java"
5 | public class com.example.myjnidemo.LameUtils {
6 | public com.example.myjnidemo.LameUtils();
7 | descriptor: ()V
8 |
9 | public static native void convertmp3(java.lang.String, java.lang.String);
10 | descriptor: (Ljava/lang/String;Ljava/lang/String;)V
11 |
12 | public static native java.lang.String getLameVersion();
13 | descriptor: ()Ljava/lang/String;
14 |
15 | public static void setConvertProgress(int);
16 | descriptor: (I)V
17 |
18 | public static void convertFinish(java.lang.String);
19 | descriptor: (Ljava/lang/String;)V
20 | }
21 |
22 | G:\e\work\test\MyJniDemo\app\src\main\java>
23 |
24 |
25 | E:\work\test\MyMp3Convert\app\src\main\java>javah -classpath . com.convert.mp3.ConvertUtil
26 |
27 |
28 | E:\work\test\MyMp3Convert\app\src\main\java>javac -encoding UTF-8 com\convert\mp3\Mp3ConvertUtil.java
29 |
30 | E:\work\test\MyMp3Convert\app\src\main\java>javap -s -p com\convert\mymp3convert\Mp3ConvertUtil.class
31 | Compiled from "Mp3ConvertUtil.java"
32 | public class com.convert.mymp3convert.Mp3ConvertUtil {
33 | public com.convert.mymp3convert.Mp3ConvertUtil();
34 | descriptor: ()V
35 |
36 | public static native java.lang.String hello(java.lang.String);
37 | descriptor: (Ljava/lang/String;)Ljava/lang/String;
38 |
39 | public static native java.lang.String getLameVer();
40 | descriptor: ()Ljava/lang/String;
41 |
42 | public static native void convertmp3(java.lang.String, java.lang.String);
43 | descriptor: (Ljava/lang/String;Ljava/lang/String;)V
44 |
45 | public static void setConvertProgress(int);
46 | descriptor: (I)V
47 |
48 | public static void convertFinish(java.lang.String);
49 | descriptor: (Ljava/lang/String;)V
50 |
51 | public static void convertError(java.lang.String);
52 | descriptor: (Ljava/lang/String;)V
53 |
54 | static {};
55 | descriptor: ()V
56 | }
57 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | ext {
4 | kotlin_version = '1.4.21'
5 | }
6 | repositories {
7 | google()
8 | jcenter()
9 | }
10 | dependencies {
11 | classpath "com.android.tools.build:gradle:4.1.0"
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
--------------------------------------------------------------------------------
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/demo/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 | compileSdkVersion 30
7 | buildToolsVersion "30.0.3"
8 |
9 | defaultConfig {
10 | applicationId "com.convert.demo"
11 | minSdkVersion 18
12 | targetSdkVersion 30
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 | repositories {
19 | flatDir {
20 | dirs 'libs'
21 | }
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_1_8
31 | targetCompatibility JavaVersion.VERSION_1_8
32 | }
33 | }
34 |
35 | dependencies {
36 |
37 | implementation 'androidx.appcompat:appcompat:1.2.0'
38 | implementation 'com.google.android.material:material:1.2.1'
39 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
40 | testImplementation 'junit:junit:4.+'
41 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
42 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
43 |
44 | implementation(name:'app-release', ext: 'aar')
45 |
46 | }
--------------------------------------------------------------------------------
/demo/libs/app-release.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/libs/app-release.aar
--------------------------------------------------------------------------------
/demo/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
--------------------------------------------------------------------------------
/demo/src/androidTest/java/com/convert/demo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.convert.demo;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.convert.demo", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/demo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/convert/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.convert.demo;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.TextView;
9 |
10 | import com.convert.mymp3convert.Mp3ConvertUtil;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 | TextView tv;
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | tv = findViewById(R.id.tv);
19 | }
20 | public void click(View v){
21 | Log.d("ddebug",Mp3ConvertUtil.getLameVer());
22 | tv.append("\n " + Mp3ConvertUtil.hello("hello"));
23 | }
24 | }
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/demo/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 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
25 |
26 |
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | demo
3 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/demo/src/test/java/com/convert/demo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.convert.demo;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/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=-Xmx2048m -Dfile.encoding=UTF-8
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 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | #isAppLibrary=false
21 | isAppLibrary=false
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanyuan/mp3Convert/3c25cbd543da0e1c26bab147c967814e2269f559/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jan 14 21:57:53 CST 2021
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-6.5-bin.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':demo'
2 | include ':app'
3 | rootProject.name = "MyMp3Convert"
--------------------------------------------------------------------------------