Skip to content

Commit

Permalink
Merge commit 'b4ef1af8e81c10f4b7164e3038f130a496ec8fda' as 'android-a…
Browse files Browse the repository at this point in the history
…ac-enc'
  • Loading branch information
sbosley committed May 11, 2012
2 parents 0f23787 + b4ef1af commit 8fc0c16
Show file tree
Hide file tree
Showing 371 changed files with 49,609 additions and 0 deletions.
9 changes: 9 additions & 0 deletions android-aac-enc/.classpath
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" path="libs/xom-1.2.7.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
3 changes: 3 additions & 0 deletions android-aac-enc/.gitignore
@@ -0,0 +1,3 @@
gen
bin
obj
33 changes: 33 additions & 0 deletions android-aac-enc/.project
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>aac-enc</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
28 changes: 28 additions & 0 deletions android-aac-enc/AndroidManifest.xml
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.todoroo.aacenc"
android:versionCode="1"
android:versionName="1.0" >

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET"/>


<uses-sdk android:minSdkVersion="7" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".Main" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
32 changes: 32 additions & 0 deletions android-aac-enc/README.md
@@ -0,0 +1,32 @@
Android AAC Encoder project
============================

Extraction of Android Stagefright VO AAC encoder with a nice Java API.

In addition, includes a patched [MP4Parser](http://code.google.com/p/mp4parser) Java library for wrapping AAC files in an MP4 container to produce M4A audio files playable by Google Chrome and Apple QuickTime.

This project is set up as a single Eclipse project with a Main.java example activity. AAC encoding logic is found in jni/aac-enc.c, which needs to be built with the [Android NDK](http://developer.android.com/sdk/ndk/index.html). I used NDK r7c, but any version should work.

Why?
----

- smaller code footprint than FFmpeg (< 500k compared to > 2M)
- less native code to compile = less work to support new architectures
- easiest way to make an M4A file


License
-------

This project is released under the [Apache License, version 2](http://www.apache.org/licenses/LICENSE-2.0)

Patents
-------

This project grants you no rights to any of the patents this technology may require. However, since Android version 4.0 and up ship with the Stagefright VO AAC encoder, it is my understanding that you can release code that depends on these libraries for any version of Android. Please note that I am not a lawyer.


Have changes?
-------------

Pull requests are accepted!
85 changes: 85 additions & 0 deletions android-aac-enc/build.xml
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Main" default="help">

<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />

<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />

<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />

<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>


<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
<target name="-pre-compile">
</target>
/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->

<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />

</project>
85 changes: 85 additions & 0 deletions android-aac-enc/jni/Android.mk
@@ -0,0 +1,85 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
include $(LOCAL_PATH)/Config.mk

LOCAL_MODULE := aac-encoder

ENC_SRC := src

LOCAL_C_INCLUDES := $(LOCAL_PATH)/inc

LOCAL_SRC_FILES = \
aac-enc.c \
$(ENC_SRC)/cmnMemory.c \
basic_op/basicop2.c \
basic_op/oper_32b.c \
$(ENC_SRC)/aac_rom.c \
$(ENC_SRC)/aacenc.c \
$(ENC_SRC)/aacenc_core.c \
$(ENC_SRC)/adj_thr.c \
$(ENC_SRC)/band_nrg.c \
$(ENC_SRC)/bit_cnt.c \
$(ENC_SRC)/bitbuffer.c \
$(ENC_SRC)/bitenc.c \
$(ENC_SRC)/block_switch.c \
$(ENC_SRC)/channel_map.c \
$(ENC_SRC)/dyn_bits.c \
$(ENC_SRC)/grp_data.c \
$(ENC_SRC)/interface.c \
$(ENC_SRC)/line_pe.c \
$(ENC_SRC)/memalign.c \
$(ENC_SRC)/ms_stereo.c \
$(ENC_SRC)/pre_echo_control.c \
$(ENC_SRC)/psy_configuration.c \
$(ENC_SRC)/psy_main.c \
$(ENC_SRC)/qc_main.c \
$(ENC_SRC)/quantize.c \
$(ENC_SRC)/sf_estim.c \
$(ENC_SRC)/spreading.c \
$(ENC_SRC)/stat_bits.c \
$(ENC_SRC)/tns.c \
$(ENC_SRC)/transform.c

ifeq ($(VOTT), v5)
LOCAL_SRC_FILES += \
$(ENC_SRC)/asm/ARMV5E/AutoCorrelation_v5.s \
$(ENC_SRC)/asm/ARMV5E/band_nrg_v5.s \
$(ENC_SRC)/asm/ARMV5E/CalcWindowEnergy_v5.s \
$(ENC_SRC)/asm/ARMV5E/PrePostMDCT_v5.s \
$(ENC_SRC)/asm/ARMV5E/R4R8First_v5.s \
$(ENC_SRC)/asm/ARMV5E/Radix4FFT_v5.s
endif

ifeq ($(VOTT), v7)
LOCAL_SRC_FILES += \
$(ENC_SRC)/asm/ARMV5E/AutoCorrelation_v5.s \
$(ENC_SRC)/asm/ARMV5E/band_nrg_v5.s \
$(ENC_SRC)/asm/ARMV5E/CalcWindowEnergy_v5.s \
$(ENC_SRC)/asm/ARMV7/PrePostMDCT_v7.s \
$(ENC_SRC)/asm/ARMV7/R4R8First_v7.s \
$(ENC_SRC)/asm/ARMV7/Radix4FFT_v7.s
endif

LOCAL_ARM_MODE := arm

LOCAL_LDLIBS := -llog

LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES :=

LOCAL_CFLAGS := $(VO_CFLAGS)

ifeq ($(VOTT), v5)
LOCAL_CFLAGS += -DARMV5E -DARM_INASM -DARMV5_INASM
LOCAL_C_INCLUDES += $(ENC_SRC)/asm/ARMV5E
endif

ifeq ($(VOTT), v7)
LOCAL_CFLAGS += -DARMV5E -DARMV7Neon -DARM_INASM -DARMV5_INASM -DARMV6_INASM
LOCAL_C_INCLUDES += $(ENC_SRC)/asm/ARMV5E
LOCAL_C_INCLUDES += $(ENC_SRC)/asm/ARMV7
endif

include $(BUILD_SHARED_LIBRARY)

24 changes: 24 additions & 0 deletions android-aac-enc/jni/Config.mk
@@ -0,0 +1,24 @@
#
# This configure file is just for Linux projects against Android
#

VOPRJ :=
VONJ :=

# WARNING:
# Using v7 breaks generic build
ifeq ($(TARGET_ARCH),arm)
VOTT := v5
else
VOTT := pc
endif

# Do we also need to check on ARCH_ARM_HAVE_ARMV7A? - probably not
ifeq ($(ARCH_ARM_HAVE_NEON),true)
VOTT := v7
endif

VOTEST := 0

VO_CFLAGS:=-DLINUX

0 comments on commit 8fc0c16

Please sign in to comment.