diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2c78ad7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*~ +.gradle +build +decoder/build +decoder/src/main/libs +decoder/src/main/obj +player/build diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..17c411e --- /dev/null +++ b/build.gradle @@ -0,0 +1,18 @@ +buildscript { + repositories { + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:1.0.0' + classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.1.1' + } +} + +allprojects { + repositories { + jcenter() + mavenLocal() + } +} + diff --git a/build.xml b/build.xml deleted file mode 100644 index f03e9de..0000000 --- a/build.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/decoder/AndroidManifest.xml b/decoder/AndroidManifest.xml deleted file mode 100644 index f51007d..0000000 --- a/decoder/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/decoder/build.gradle b/decoder/build.gradle new file mode 100644 index 0000000..ea905aa --- /dev/null +++ b/decoder/build.gradle @@ -0,0 +1,45 @@ +import org.apache.tools.ant.taskdefs.condition.Os + +apply plugin: 'com.android.library' +apply plugin: 'maven' + +android { + compileSdkVersion 23 + buildToolsVersion '23.0.1' + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 23 + versionCode 10 + versionName "0.8" + group = 'com.spoledge.aacdecoder' + version = '0.8-SNAPSHOT' + ndk { stl "gnustl_static" } + } + + sourceSets.main { + jniLibs.srcDir 'src/main/libs' + jni.srcDirs = [] + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } + + task ndkBuild(type: Exec) { + def ndkDir = project.plugins.findPlugin('com.android.library').getNdkFolder() + + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine "$ndkDir/ndk-build.cmd", '-C', file('src/main/jni').absolutePath + } else { + commandLine "$ndkDir/ndk-build", '-C', file('src/main/jni').absolutePath + } + } + + tasks.withType(JavaCompile) { + compileTask -> compileTask.dependsOn ndkBuild + } +} diff --git a/decoder/build.xml b/decoder/build.xml deleted file mode 100644 index 6c4327d..0000000 --- a/decoder/build.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - Missing property. - The property 'sdk.dir' is not set. It should point to Android SDK home dir. - Please add it to your '.ant.properties' file. - - - - Missing property. - The property 'ndk.home' is not set. It should point to Android NDK home dir. - Please add it to your '.ant.properties' file. - - - - Missing property. - The property 'opencore-top.dir' is not set. It should contain the location - of android-opencore library source. - Please add it to your '.ant.properties' file. - - - - Missing property. - The property 'jni.loglevel' is not set. It should contain the target loglevel. - Please add it to your '.ant.properties' file. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/decoder/pom.xml b/decoder/pom.xml deleted file mode 100644 index 0c938df..0000000 --- a/decoder/pom.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - 4.0.0 - - - com.spoledge.aacdecoder - aacdecoder - 0.8-SNAPSHOT - - - aacdecoder-lib - - apklib - - AAC Decoder for Android - Library - - - - - com.google.android - android - provided - - - - - - src - - - - maven-clean-plugin - - - - libs - - - obj - - - - - - - maven-antrun-plugin - 1.7 - - - - - com.sun - tools - 1.5.0 - system - ${java.home}/../lib/tools.jar - - - - - compile - - - - - - - run - - - - - - - - - - - com.jayway.maven.plugins.android.generation2 - android-maven-plugin - - true - true - false - NDK_TOOLCHAIN="" - - false - - - true - - - - ndk-build - - - true - - - - - - diff --git a/decoder/src/main/AndroidManifest.xml b/decoder/src/main/AndroidManifest.xml new file mode 100644 index 0000000..96db5ec --- /dev/null +++ b/decoder/src/main/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + diff --git a/decoder/src/com/spoledge/aacdecoder/AACPlayer.java b/decoder/src/main/java/com/spoledge/aacdecoder/AACPlayer.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/AACPlayer.java rename to decoder/src/main/java/com/spoledge/aacdecoder/AACPlayer.java diff --git a/decoder/src/com/spoledge/aacdecoder/BufferReader.java b/decoder/src/main/java/com/spoledge/aacdecoder/BufferReader.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/BufferReader.java rename to decoder/src/main/java/com/spoledge/aacdecoder/BufferReader.java diff --git a/decoder/src/com/spoledge/aacdecoder/Decoder.java b/decoder/src/main/java/com/spoledge/aacdecoder/Decoder.java similarity index 93% rename from decoder/src/com/spoledge/aacdecoder/Decoder.java rename to decoder/src/main/java/com/spoledge/aacdecoder/Decoder.java index 205793a..c27756c 100644 --- a/decoder/src/com/spoledge/aacdecoder/Decoder.java +++ b/decoder/src/main/java/com/spoledge/aacdecoder/Decoder.java @@ -19,6 +19,7 @@ */ package com.spoledge.aacdecoder; +import android.util.Log; /** * The decoder which calls native implementation(s). @@ -143,14 +144,14 @@ public void setFirstSamples( short[] firstSamples ) { * This is by default 0 - which means that the OpenCORE aacdec decoder is used. * Otherwise it must be set to a valid C pointer to a AACDDecoder struct. */ - protected int decoder; + protected long decoder; /** * The decoding context pointer. * This is used between calls to C functions to kkep pointer to a C struct. */ - protected int aacdw; + protected long aacdw; /** @@ -169,7 +170,7 @@ public void setFirstSamples( short[] firstSamples ) { // Constructors //////////////////////////////////////////////////////////////////////////// - protected Decoder( int decoder ) { + protected Decoder(long decoder ) { this.decoder = decoder; } @@ -206,7 +207,7 @@ public static Decoder create() { public static Decoder createByName( String name ) { loadLibrary(); - int aacdw = nativeDecoderGetByName( name ); + long aacdw = nativeDecoderGetByName( name ); return aacdw != 0 ? create( aacdw ) : null; } @@ -217,7 +218,7 @@ public static Decoder createByName( String name ) { * @param decoder the poiter to a C struct AACDDecoder. 0 means that the default OpenCORE aacdec * decoder will be used. */ - public static synchronized Decoder create( int decoder ) { + public static synchronized Decoder create( long decoder ) { loadLibrary(); return new Decoder( decoder ); @@ -294,7 +295,7 @@ protected void finalize() { * @param decoder the pointer to the C struct AACDDecoder or NULL * @return the pointer to the C struct */ - protected native int nativeStart( int decoder, BufferReader reader, Info info ); + protected native long nativeStart(long decoder, BufferReader reader, Info info ); /** @@ -302,21 +303,21 @@ protected void finalize() { * Calls back Java method BufferReader.next() when additional input is needed. * @param aacdw the pointer to the C struct */ - protected native int nativeDecode( int aacdw, short[] samples, int outLen ); + protected native long nativeDecode( long aacdw, short[] samples, int outLen ); /** * Actually stops decoding - releases all resources. * @param aacdw the pointer to the C struct */ - protected native void nativeStop( int aacdw ); + protected native void nativeStop( long aacdw ); /** * Returns the decoder pointer struct or NULL. * @param name the name of the decoder */ - protected static native int nativeDecoderGetByName( String name ); + protected static native long nativeDecoderGetByName( String name ); } diff --git a/decoder/src/com/spoledge/aacdecoder/FlashAACInputStream.java b/decoder/src/main/java/com/spoledge/aacdecoder/FlashAACInputStream.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/FlashAACInputStream.java rename to decoder/src/main/java/com/spoledge/aacdecoder/FlashAACInputStream.java diff --git a/decoder/src/com/spoledge/aacdecoder/FlashAACPlayer.java b/decoder/src/main/java/com/spoledge/aacdecoder/FlashAACPlayer.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/FlashAACPlayer.java rename to decoder/src/main/java/com/spoledge/aacdecoder/FlashAACPlayer.java diff --git a/decoder/src/com/spoledge/aacdecoder/IcyInputStream.java b/decoder/src/main/java/com/spoledge/aacdecoder/IcyInputStream.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/IcyInputStream.java rename to decoder/src/main/java/com/spoledge/aacdecoder/IcyInputStream.java diff --git a/decoder/src/com/spoledge/aacdecoder/IcyURLConnection.java b/decoder/src/main/java/com/spoledge/aacdecoder/IcyURLConnection.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/IcyURLConnection.java rename to decoder/src/main/java/com/spoledge/aacdecoder/IcyURLConnection.java diff --git a/decoder/src/com/spoledge/aacdecoder/IcyURLStreamHandler.java b/decoder/src/main/java/com/spoledge/aacdecoder/IcyURLStreamHandler.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/IcyURLStreamHandler.java rename to decoder/src/main/java/com/spoledge/aacdecoder/IcyURLStreamHandler.java diff --git a/decoder/src/com/spoledge/aacdecoder/MP3Player.java b/decoder/src/main/java/com/spoledge/aacdecoder/MP3Player.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/MP3Player.java rename to decoder/src/main/java/com/spoledge/aacdecoder/MP3Player.java diff --git a/decoder/src/com/spoledge/aacdecoder/MultiPlayer.java b/decoder/src/main/java/com/spoledge/aacdecoder/MultiPlayer.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/MultiPlayer.java rename to decoder/src/main/java/com/spoledge/aacdecoder/MultiPlayer.java diff --git a/decoder/src/com/spoledge/aacdecoder/PCMFeed.java b/decoder/src/main/java/com/spoledge/aacdecoder/PCMFeed.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/PCMFeed.java rename to decoder/src/main/java/com/spoledge/aacdecoder/PCMFeed.java diff --git a/decoder/src/com/spoledge/aacdecoder/PlayerCallback.java b/decoder/src/main/java/com/spoledge/aacdecoder/PlayerCallback.java similarity index 100% rename from decoder/src/com/spoledge/aacdecoder/PlayerCallback.java rename to decoder/src/main/java/com/spoledge/aacdecoder/PlayerCallback.java diff --git a/decoder/jni/Android.mk b/decoder/src/main/jni/Android.mk similarity index 67% rename from decoder/jni/Android.mk rename to decoder/src/main/jni/Android.mk index fa02957..a584616 100644 --- a/decoder/jni/Android.mk +++ b/decoder/src/main/jni/Android.mk @@ -1,16 +1,13 @@ mydir := $(call my-dir) -# -# Include the user's properties: -# -include $(mydir)/../../.ant.properties +opencore-top.dir=./android-opencore-20120628-patch-stereo +jni.loglevel=info -PV_TOP := $(opencore-top.dir) +PV_TOP := $(opencore-top.dir) OPENCORE_DIR := $(opencore-top.dir)/codecs_v2/audio/aac/dec OPENCORE_MP3 := $(opencore-top.dir)/codecs_v2/audio/mp3/dec -OSCL_DIR := $(opencore-top.dir)/oscl/oscl -LOGLEVEL := $(jni.loglevel) - +OSCL_DIR := $(opencore-top.dir)/oscl/oscl +LOGLEVEL := debug include $(mydir)/aac-decoder/Android.mk include $(mydir)/opencore-aacdec/Android.mk diff --git a/decoder/jni/Application.mk b/decoder/src/main/jni/Application.mk similarity index 100% rename from decoder/jni/Application.mk rename to decoder/src/main/jni/Application.mk diff --git a/decoder/jni/Makefile b/decoder/src/main/jni/Makefile similarity index 100% rename from decoder/jni/Makefile rename to decoder/src/main/jni/Makefile diff --git a/decoder/jni/aac-decoder/Android.mk b/decoder/src/main/jni/aac-decoder/Android.mk similarity index 93% rename from decoder/jni/aac-decoder/Android.mk rename to decoder/src/main/jni/aac-decoder/Android.mk index 746f3fc..f0d1950 100644 --- a/decoder/jni/aac-decoder/Android.mk +++ b/decoder/src/main/jni/aac-decoder/Android.mk @@ -27,7 +27,7 @@ cflags_loglevels := $(foreach ll,$(LOGLEVELS),-DAACD_LOGLEVEL_$(ll)) # Final library: LOCAL_MODULE := aacdecoder LOCAL_SRC_FILES := aac-decoder.c -LOCAL_CFLAGS := $(cflags_loglevels) +LOCAL_CFLAGS := -Wall -std=c99 $(cflags_loglevels) LOCAL_LDLIBS := -llog LOCAL_STATIC_LIBRARIES := decoder-opencore-aacdec decoder-opencore-mp3dec libpv_aac_dec libpv_mp3_dec include $(BUILD_SHARED_LIBRARY) diff --git a/decoder/jni/aac-decoder/aac-common.h b/decoder/src/main/jni/aac-decoder/aac-common.h similarity index 100% rename from decoder/jni/aac-decoder/aac-common.h rename to decoder/src/main/jni/aac-decoder/aac-common.h diff --git a/decoder/jni/aac-decoder/aac-decoder.c b/decoder/src/main/jni/aac-decoder/aac-decoder.c similarity index 96% rename from decoder/jni/aac-decoder/aac-decoder.c rename to decoder/src/main/jni/aac-decoder/aac-decoder.c index d304ec7..32c4a0a 100644 --- a/decoder/jni/aac-decoder/aac-decoder.c +++ b/decoder/src/main/jni/aac-decoder/aac-decoder.c @@ -326,7 +326,8 @@ static void aacd_decode( AACDInfo *info, jshort *samples, jint outLen ) // check if input buffer is filled: if (info->bytesleft <= info->frame_max_bytesconsumed) { - AACD_TRACE( "decode() reading input buffer" ); + AACD_DEBUG("bytes left/consumed: %d/%d", info->bytesleft, info->frame_max_bytesconsumed); + AACD_TRACE("decode() reading input buffer" ); aacd_read_buffer( info ); if (info->bytesleft <= info->frame_max_bytesconsumed) @@ -409,10 +410,11 @@ static void aacd_decode( AACDInfo *info, jshort *samples, jint outLen ) * Method: nativeStart * Signature: (ILcom/spoledge/aacdecoder/BufferReader;Lcom/spoledge/aacdecoder/Decoder/Info;)I */ -JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeStart - (JNIEnv *env, jobject thiz, jint decoder, jobject jreader, jobject aacInfo) +JNIEXPORT jlong JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeStart + (JNIEnv *env, jobject thiz, jlong decoder, jobject jreader, jobject aacInfo) { AACDDecoder *dec = decoder != 0 ? ((AACDDecoder*)decoder) : &aacd_opencore_decoder; + AACDInfo *info = aacd_start( env, dec, jreader, aacInfo ); info->env = env; @@ -455,7 +457,7 @@ JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeStart info->env = NULL; - return (jint) info; + return (jlong) info; } @@ -464,8 +466,8 @@ JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeStart * Method: nativeDecode * Signature: (I[SI)I */ -JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecode - (JNIEnv *env, jobject thiz, jint jinfo, jshortArray outBuf, jint outLen) +JNIEXPORT jlong JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecode + (JNIEnv *env, jobject thiz, jlong jinfo, jshortArray outBuf, jint outLen) { AACDInfo *info = (AACDInfo*) jinfo; info->env = env; @@ -482,7 +484,7 @@ JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecode info->env = NULL; - return (jint) info->round_samples; + return (jlong) info->round_samples; } @@ -492,7 +494,7 @@ JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecode * Signature: (I)V */ JNIEXPORT void JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeStop - (JNIEnv *env, jobject thiz, jint jinfo) + (JNIEnv *env, jobject thiz, jlong jinfo) { AACDInfo *info = (AACDInfo*) jinfo; info->env = env; @@ -505,7 +507,7 @@ JNIEXPORT void JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeStop * Method: nativeDecoderGetByName * Signature: (Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecoderGetByName +JNIEXPORT jlong JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecoderGetByName (JNIEnv *env, jclass clazzDecoder, jstring jname) { int i; @@ -526,7 +528,7 @@ JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecoderGetByNa (*env)->ReleaseStringUTFChars( env, jname, name ); - return (jint) ret; + return (jlong) ret; } diff --git a/decoder/jni/aac-decoder/aac-decoder.h b/decoder/src/main/jni/aac-decoder/aac-decoder.h similarity index 82% rename from decoder/jni/aac-decoder/aac-decoder.h rename to decoder/src/main/jni/aac-decoder/aac-decoder.h index d207161..fca9d23 100644 --- a/decoder/jni/aac-decoder/aac-decoder.h +++ b/decoder/src/main/jni/aac-decoder/aac-decoder.h @@ -33,16 +33,16 @@ extern "C" { * Method: nativeStart * Signature: (ILcom/spoledge/aacdecoder/BufferReader;Lcom/spoledge/aacdecoder/Decoder/Info;)I */ -JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeStart - (JNIEnv *, jobject, jint, jobject, jobject); +JNIEXPORT jlong JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeStart + (JNIEnv *, jobject, jlong, jobject, jobject); /* * Class: com_spoledge_aacdecoder_Decoder * Method: nativeDecode * Signature: (I[SI)I */ -JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecode - (JNIEnv *, jobject, jint, jshortArray, jint); +JNIEXPORT jlong JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecode + (JNIEnv *, jobject, jlong, jshortArray, jint); /* * Class: com_spoledge_aacdecoder_Decoder @@ -50,14 +50,14 @@ JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecode * Signature: (I)V */ JNIEXPORT void JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeStop - (JNIEnv *, jobject, jint); + (JNIEnv *, jobject, jlong); /* * Class: com_spoledge_aacdecoder_Decoder * Method: nativeDecoderGetByName * Signature: (Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecoderGetByName +JNIEXPORT jlong JNICALL Java_com_spoledge_aacdecoder_Decoder_nativeDecoderGetByName (JNIEnv *, jclass, jstring); #ifdef __cplusplus diff --git a/decoder/jni/aac-decoder/aac-opencore-decoder.c b/decoder/src/main/jni/aac-decoder/aac-opencore-decoder.c similarity index 100% rename from decoder/jni/aac-decoder/aac-opencore-decoder.c rename to decoder/src/main/jni/aac-decoder/aac-opencore-decoder.c diff --git a/decoder/jni/aac-decoder/decoder-opencore-aacdec.mk b/decoder/src/main/jni/aac-decoder/decoder-opencore-aacdec.mk similarity index 100% rename from decoder/jni/aac-decoder/decoder-opencore-aacdec.mk rename to decoder/src/main/jni/aac-decoder/decoder-opencore-aacdec.mk diff --git a/decoder/jni/aac-decoder/decoder-opencore-mp3dec.mk b/decoder/src/main/jni/aac-decoder/decoder-opencore-mp3dec.mk similarity index 100% rename from decoder/jni/aac-decoder/decoder-opencore-mp3dec.mk rename to decoder/src/main/jni/aac-decoder/decoder-opencore-mp3dec.mk diff --git a/decoder/jni/aac-decoder/mp3-opencore-decoder.c b/decoder/src/main/jni/aac-decoder/mp3-opencore-decoder.c similarity index 100% rename from decoder/jni/aac-decoder/mp3-opencore-decoder.c rename to decoder/src/main/jni/aac-decoder/mp3-opencore-decoder.c diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/Android.mk new file mode 100644 index 0000000..477b6ba --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/Android.mk @@ -0,0 +1,54 @@ +ifneq ($(BUILD_WITHOUT_PV),true) +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +# Set up the PV variables +include $(LOCAL_PATH)/Config.mk + +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_common.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_sharedlibrary.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_avcdec_sharedlibrary.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_m4vdec_sharedlibrary.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_aacdec_sharedlibrary.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_amrdec_sharedlibrary.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_mp3dec_sharedlibrary.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_avcenc_sharedlibrary.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_m4venc_sharedlibrary.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_amrenc_sharedlibrary.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_net_support.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_player.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_downloadreg.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_download.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_streamingreg.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_streaming.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_mp4localreg.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_mp4local.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_pvoma1passthru.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_rtsp.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_pvrtspunicast_streaming.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_pvrtspunicast_streamingreg.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_pvrtsptunicast_streaming.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_pvrtsptunicast_streamingreg.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_author.mk +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_pvme.mk +ifeq ($(BUILD_PV_2WAY),1) +include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_2way.mk +endif +include $(PV_TOP)/oscl/unit_test/Android.mk + include $(PV_TOP)/oscl/unit_test_utils/Android.mk + include $(PV_TOP)/fileformats/avi/parser/Android.mk + include $(PV_TOP)/pvmi/media_io/pvmi_mio_avi_wav_fileinput/Android.mk +ifeq ($(BUILD_PV_TEST_APPS),1) +include $(PV_TOP)/engines/player/test/Android.mk +include $(PV_TOP)/engines/author/test/Android.mk +include $(PV_TOP)/engines/2way/sample_app/command_line/Android.mk +include $(PV_TOP)/codecs_v2/omx/omx_testapp/Android.mk +include $(PV_TOP)/codecs_v2/omx/omx_testapp_enc/Android.mk +include $(PV_TOP)/engines/pvme/test/Android.mk +ifeq ($(BUILD_PV_2WAY),1) +include $(PV_TOP)/engines/2way/test/Android.mk +endif +endif +-include $(PV_TOP)/extern_libs_v2/android/extended_features/Android.mk + +endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/Android_system_extras.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/Android_system_extras.mk new file mode 100644 index 0000000..a4f5de4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/Android_system_extras.mk @@ -0,0 +1,9 @@ + +LOCAL_LDLIBS := -lpthread + +ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true) +LOCAL_LDLIBS += -ldl -lrt +endif +ifneq ($(TARGET_SIMULATOR),true) +LOCAL_SHARED_LIBRARIES += libdl +endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/CHANGES.txt b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/CHANGES.txt new file mode 100644 index 0000000..a535994 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/CHANGES.txt @@ -0,0 +1,29 @@ +CHANGES +======= + +------------------------------------------------------------------------------ +2012-06-28 by Vaclav Bartacek + Fixed Parametric Stereo initialization bug. + All HE-AAC+ streams played mono. + + Bugfix(1) - if PS extension is found in the first frame, then the PS + decoder is initialized, but the stream type was not correctly set + to MP4AUDIO_PS (remained MP4AUDIO_SBR) + + Bugfix(2) - if PS extension was not found in the first frame, then PS + decoder was not initialized at all. + + Files: + codecs_v2/audio/aac/dec/src/sbr_applied.cpp + +------------------------------------------------------------------------------ +2012-06-16 by Vaclav Bartacek + Applied patch found in standard Android branch. + Bugfix - when enabled Parametric Stereo, then crashing. + + Files: + codecs_v2/audio/aac/dec/src/sbr_dec.cpp + +------------------------------------------------------------------------------ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/ChangeLog b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/ChangeLog new file mode 100644 index 0000000..4558f96 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/ChangeLog @@ -0,0 +1,1328 @@ +=============================================================================== +2010-06-25 OpenCORE 2.50 + +New Features +- Mediascanner-albumart support +- Add new player engine test case for HTTP streaming transfer mode +- Adding BGR support for CC16 in codecs +- Provide a runtime setting to prioritize SW codecs over HW codecs in the case +of thumbnail retrieval. +- Addition of DLNA specific 'byte-seek' support for Pause/Resume and Seek cases. +- Player engine test configuration modifications +- Add profiling capability to OMX AVC/MPEG4/AAC encoder components. +- Add support for the PSSH Atom to the mp4 composer, as specified in the +Protected Interoperable File Format (PIFF) Specification +- Timestamp smoothing for incoming audio timestamps +- Add support for the boxes 'enca', 'encv', 'enct', 'sinf' and 'frma' to the +mp4 composer +- Add SetParameter as an extension command to Android MediaPlayer +- Adding support of forward playback with rendering only I-frames +- Modify the mp4 composer to verify the existence of entries in the mfra box +before rendering it. +- Updates to DRM interfaces and test cases +- Initialize iSkipToIDR to false for OMX AVC decoder. +- Gapless and playlist support for MP4, MP3, and WMA +- Framework support for MPEG-2 FF Parser +- Changes at the PE Node and mp4 parser node to support PDL random position of +fragmented clips with out-of-band mfra information +- Allowing scrubbing inside playerengine +- MP4 Parser/composer mods to improve metadata support +- Graceful degradation phase 1 (Key-frame-only mode in case of many late frames) +- Makefile feature to build static aggregate +- Add support for building against Android eclair +- Add integration support for 3rd party audio library +- AAC lib - Add new message that signals back change of Mode (new PCE) +- Allow reconfig of MIOs for playlist scenarios +- Android makefile segment separation / refactoring +- Addition of new event PVMFInfoSourceFormatUpdated +- Support for AAC multichannel contents to be partially decoded (output +only 2 channels). +- Implement PVMFOMXEncNode::GetProfileAndLevel() to query for the final +profile/level after intialize. +- Add support for changing bit rate/frame rate/intra refresh rate to OMXEncNode. +- Allow local.mk file for applications to define steps for running target +- Support for m4b file format +- New ARM macros in build make system. +- Add a target in module level unit test to display the list of available +targets +- Support M4V bitstream with short header mode. +- Support the PIFF Enhancements in the mp4 parser library +- Metadata updates for mp3 parser +- Added an utility function to set RTSP proxy server information +(https://review.source.android.com/#change,14369) +- Build changes to support a restricted Main Profile AVC decoder optimized for +ARMv6 +- Adding scaling support for YUV422toYUV420. +- When initialization error occurs to one of the selected tracks, allow the +playback of remaining tracks without a complete shut down. +- Add progressive playback support in MP4 movie fragment playback +- Add stdout from engine unit test output to junit xml logs +- Large File Support in MP4 PDL and PPB +- Added the test cases in PVME and FMU for protected test content +- New Common Parser Node for AMR and WAV + +Improvements +- H264 raw support for PVMI MIO file input / output +- Retrieve "duration" metadata in mediascanner through metadataretriever +- Fix for compiler warnings in mediaoutputnode and player engine test app. +- Base node should add itself to Scheduler only in a valid Created state. +- Codesize reduction for FMU +- Implemented additional APIs in CPM plugin. +- AAC lib - Enable redundant PCE syntax element on a raw bitstream +- Add metadata support for aac, amr, awb and wav files. +- Change logger levels to appropriate values in android video mio and jb node +for certain log statements +- H264 raw support for PVMI MIO file input / output +- Add Extended Atom types to the mp4 composer +- Add test for receiving data in 2way engine unit tests. +- Remove unused KVPs from engine and codecs +- Changes made to API of a CPM plugin. +- OMXConfigParser is modified to differentiate VC1 component from WMV component +so that WMV7 and WMV8 get rejected by VC1 component. +- OMX Encoder node needs to save SPS/PPS for its possible query in the case of +H264_RAW format +- If the encoder node marks the frame as keyframe, there is no need to sniff +the bitstream +- Update source duration for video playlists +- Build OMX wrappers in thumb mode in Android +- Add a new 2way engine unit test. +- Port File Output node to new base node interface design. +- Removal of 2way VideoParser Node +- Copyright date in OpenCORE source code should reflect the last time the file +was modified +- Deprecate support for platforms without native 64-bit functionality. +- Modify media layer node to use the base node framework +- Add full metadata support for OMX MPEG4/H263 decoders - +profile/level/post-processing +- Replace numeric values in code with enum +- Add command line configurable timeout for pvplayer_engine_test +- Some CML2 rules related to so_name can create errors with "n" symbol used as +module name +- Watchdog timer to monitor start of data reception +- Update the priority of some log messages +- Use parseID3Tag for aac files +- Node commands should succeed if the node is already in the resultant state in +the base node. +- Miscellaneous DRM-related modifications +- Modify jitter buffer node to use the base node framework +- Refactor Media Output node +- Remove linker warnings w.r.t. libopencore_player and libopencore_net_support +- PVMFMediaClock takes care of device latency. Remove the device latency +processing in AMIO. +- Port PVMP4FFComposerNode with the new Node Interface +- Port Protocol Engine node to new node design +- Refactor Media Output node to use new node interface +- Changes to a DRM utility +- Deprecate (and defunct) support for non-OMX nodes and builds +- Introduce authoring clock for recording AV sync +- Allow a single MIO to act as both compressed and uncompressed for the author +engine +- Separating registration of ClockStateObserver and the latency in +PVMFMediaClock +- Add API in PVMp4H263EncExtensionInterface to set H.263 GOB header interval +- New constructor and parse method overloads for node interface implementation +- OMX call error handling +- Handle end of track event in player engine testcase for I-frame mode playback +- Add RTSP return error code to the PVMF status return code +- Remove PVMFDummyFileOutputNode +- Clear the playback intent in PVME to avoid incorrect consumption of rights +- Based on most recent Khronos clarifications - partially consumed buffers are +not allowed in OMX +- Modify socket node to use the base node framework +- Adding support for RTSPT tests for new server +- Addition of Large File Support in MP4 Parser Library +- Dynamically calculate omx encoder output buffer sizes instead of hard-coding +the size +- Cleanup of 2way engine code. +- Add warning logger message in the NegotiateComponentParameters functions for +2-way +- Update OMX test app to test creation/destruction of the same component +multiple times in a row (especially useful for dynamic loading) +- Remove dependency of fileoutputnode on pvPlayer SDK +- cleanup of old Keys from MIOs +- Remove API QueryUUID from all interfaces +- Remove usage of USE_CML2_CONFIG since all the builds have been converted to +CML2 +- Change MPEG4 encoder OMX component to generate VOL header before getting +any input frames. +- Fix gcc 4.4.1 compiler warnings +- Remove unnecessary makefile templates from OpenCORE +- Support for raw compressed headers in track meta data +- Add a 2way engine unit test for when buffers are provided by MIO. +- Remove dependency on oscl string from oscl_uuid. +- Cleanup of 2way engine code. +- NDEBUG and OSCL_RELEASE_BUILD macro consolidation +- Use GetEventExtensionInterface to pass indication details from pv2way +- Bypass pasp atom box in mp4 parser +(https://review.source.android.com/#change,12330) +- CPM cleanup +- Add mp3 track support in mp4 parser +(https://review.source.android.com/#change,12329) +- Separate variable XCFLAGS to hold C-compiler flags +- Use openssl crypto library within pvcrypto +- Process the config data in the omx decoder components even if there are no +output buffers available +- Add support for multichannel aac clips with no channel distribution +information +- Add test duration to junit-like XML log output from test framework +- Makefile update for new module +- Change component library name in makefile +- Move amr and avc common libraries from opencore_common into omx_sharedlibrary +- Move libpvmioaviwavfileinput.a libavifileparser.a out of libopencore_common.so +- Deprecate GetMetadataKeys, GetNodeMetadataKeys, GetNumMetadataKeys, and +ReleaseNodeMetadataKeys APIs. +- Improvement in an internal build and the export of some additional methods +- Move amr_common and avc_common lib to libomx_sharedlibrary.so +- Print out time taken to complete each OMX test case. +- Check for INTRA frames in the MPPTYPE box when the H263 frames are using the +extended PTYPE header +- Introduce new KVP string +- Improve the check for GLOBAL_CPU_ARCH_VERSION in codecs lib makefile to make +it scalable to higher version of ARM architecture. +- Move ResetData() function in android surface output inside Reset() +- Improve buffer negotiation with 3rd party omx components, as it will let +them have the final say in the number of buffers. +- Set release level logging to 1 for all platforms +- Sending position status update before SetPlaybackRange command completion. +- Improving the current logic in player engine for video scrubbing +- Improve color conversion unit test +- Remove unnecessary check in PEUT PS and SS testcases for the number of +buffering complete events. +- Improved error reporting in DRM plugin. +- Added player test cases for DRM +- Changes to deal with use-cases when sdcard/phone memory gets full while +recording +- Reset PaddingFrameInfo in MP3 parser after retrieving frame data +- Cleaned up DRM plugin interface +- PEUT for shoutcast shall check playback session to verify if it is valid +shoutcast session. +- Modify AVCConfigParser to handle multiple SPSs/PPSs, AUD and SEI NALs. +- Add profile and channel metadata support in AAC and AMR parsers +- Modified CPM plugin data structure +- Modify AVCConfigParser to handle multiple SPSs/PPSs, AUD and SEI NALs. +- Fix for repositioning large offsets during MP4 PS +- Add more metadata support in MP3 Parser and ID3 Parcom + +Bugs Fixed +- Unit test fixes for CPM plugin +- Improved handling of some MP4 Poison clips +- Modify MP4 parser to not send EOS if duration available from content is 0 +- Fix for deadlock between player engine and OMX component threads caused by a +mismatched queue depth and number of new output AVC buffers during port +reconfiguration +- Player hangs on normal playback under certain test conditions +- Adjust the AVC decoder to handle non-compliant bitstreams which have a +non-zero frame_num for IDRs +- Failure in InitNextValidClipInPlaylist( ) should report a command failure. +- Change to support additional argument in constructor of base node interface +implementation +- Initialization of display width and display height in the mp4 parser node +- Reset PaddingFrameInfo in MP3 parser after retrieving frame data +- Handle PVMFErrProcessing condition in case wrong URL is specified in PS or +shoutcast +- New CommonParserPort needs to derive from +PvmiCapabilityAndConfigPortFormatImpl +- Fix for proper handling of MP4 clips with invalid edit list atoms +- Audio timestamp was not initialized properly for LATM case. +- Fix for test PEUT 425 by making sure that the state transition in the test +code from STATE_UPDATEDATASOURCE to STATE_GETMETADATAVALUESLIST is serialized. +- Separate clock for rendering MIOs for 2way lipsync +- This work fixes infinite loop when OMX InitDecoder fails +- MP4 recognizer has been modified to further check the brand information +inside "ftyp" atom and not declare OMA2 DCF files as mp4. +- If the AVC decoder reports an error in the last frame of a sequence, the +OpenMAX component does not flush the decoder's output +- MP3 http playback reports error for low bitrate connection. +- Fix for running a test number multiple times in makefile target for running +parallel player engine tests +- Fixed OMX base dec node to handle 0 sample size and updated FMU to retrieve +metadata for new file extension +- MediaOutputNode module unit test failure +- Add dependency of librt to Android x86 builds +- Data type inconsistency in code of OMX test app +- Wrong thumbnails retrieved for Mp4 contents +- Incorrect time stamps with B frames in H264 high profile +- Conditionally support -Wno-psabi compiler flag for Android simulator +- For AVC clips with more number of SPS/PPS than the number of buffers +allocated, the node returns error and the clip cannot be played. +- Specific test mp3 content cannot be played on streaming with HTTP Progressive +protocol +- Inconsistent Keep-Alive timer during RTSP streaming +- Adding the missing Metadata functionality in the omx audio dec node. +- Memory leak in 2way proxy adapter +- Use clock_gettime(MONOTONIC) instead of gettimeofday() on linux platform to +have a consistent clock +- Fix for playback progress not being reported correctly for sessions in which +the duration is not known upfront. +- MP3 duration is not calculated when there is a CPM plugin +- Seek on Mp3 PS for contents without having any XING or VBRI headers results +in No-op +- Add support of "YUV 420 Semi Planer" in Encoder Node. +- Completely eliminate logging from omx proxy and omx component unless +explicitly enabled +- Fix for hang in player engine test case 862 +- Issue with seek sample number when repositioning near the beginning of a +recorded file. +- Disable setting OMX_Video_ControlRateMax to OmxComponent +- Unreleased array causing memory leaks in mp4 parser node +- MP3 parser does not recover from invalid frame embedded on mp3 stream +- Disabling outgoing skew indication messages +- AVC Sample entry not parsed correctly for picture parameter set +- Fix Assert failure in player engine TC 941 +- Fix memory leak in Android extension media player APIs +- Add OMX AVC support to 2way +- Set pre-defined VOL header for PV2Way +- Logic to detect end of track for Mp4 FF having moof atoms need to modified +- Fix get_ISO8601_str_time api on certain platforms +- parseMP4() in mediascanner.cpp couldn't detect unknown type correctly. +- RTSP streaming start time always start from zero +- Failure in PlayerEngine Unit testcase +- EOS Timestamp is invalid from mp3 source node +- Support for multiple frames in a single data block of AAC ADTS parser +- Check for NULL ptr access in CPV324m2Way::HandleNodeErrorEvent +- Fix seek failure when seek to almost end of one mp4 content +- Protocol engine node download auto resume algorithm simplification +- Conditionally convert compiler warnings to errors in android folder +- Fix for possible race condition in FMU's thumbnail retrieval +- PS/MP3 unable to set start playback time when duration is unknown +- Fix for out-of-bound array access in m4v config parser function. +- Fix for thumbnail retrieval when using file handle in Android +- Remove unnecessary code from android logger config +- Bug for Size limitation in case of streaming +- Change ParseM4VFSI to be more lenient to profile/level error and add SPL4a +and SPL5 support to m4vencoder. +- Set/GetDataSinkFormatType +- Thumbnail loading take much more time in all video content +- memory access violation occurs -3g2 content containing moof atom +- OMX Decoder Node Scheduling may be affected due to node refactoring change +- Close the MetadataDriver semaphore to prevent an assert. +- Fix an RTSP tunneling url problem +- Choppy audio after pausing and resuming 2way call +- EOS message being overwritten by BOS in the mediaoutputnode +- Do not access iTimestampVec.back() if the vector is empty. +- 2way's h223LCtest and h223test are failing. +- Use config parser information to configure OMX AAC component. Still expect to +get Port settings changed event in case of implicit AAC+ +- Calling UpdateDataSource before calling AddDataSource() could result in a +crash +- Allow SDKINFO Header to use environment variables if set +- Fix 2way unit test assertion failure. +- Fix socket communication scenario for 2way +- Out of bounds access during CPM Register Content for MP4 and MP3 clips +- Fix MP3 gapless playback EOC message iFramesToFollowEOC calculation +- Removed OsclThread::EnableKill, added OsclThread::CanTerminate +- Delaying the release of a source node until after the engine command completes +- PVMFInfoStartOfData and PVMFInfoEndOfData events need to be serialized at the +mediaoutputnode during clip transition +- Ensure that PVOMXRegistry calls OsclSharedLibrary LoadLib and Close only once. +- Fix player engine test cases 48 and 49 +- Datasource being removed prematurely +- Change some of the time related variables in M4venc and AmrEnc OMX component +from uint32 to OMX_TICKS or int64. +- Fix for incorrect display dimensions under certain conditions. +- Add a new testcase for Pause - Skip - Resume +- Use Wno-psabi flag when building against eclair SDK +- In OMX decoder node - In case of an invalid input NAL or empty input +message, input OMX buffer needs to be released +- Music app crashes and gallery application is not present on android-2.1_r1 +emulator +- Bug in ColorConvert lib (RGB16 to yuv420 conversion) +- Memory access violation occurs +- Player engine changes to add a log line and remove regular decoder node +reference +- Incoming user input messages are not passed to application +- Check semaphore before closing +- Timed Text file playback issue +- Fix pv_config_selected.mk in opencore_value_add for 2way changes. +- Add stub definitions to fix korg master branch build for newly declared +functions +- MP4 Fileformat Edit List storing offset in wrong timescale. +- AAC lib - colored noise produced when decoding file with clipped levels +- ReleaseMetadataValues resulting in a hang when called without GetMetadataKeys +- Update the thread safe queue to handle events from multiple threads +- Fix MP4 source node metadata retrieval for playlist +- Fix PEUT TC 400-455 playlist input file path +- Make audio MIOs for gapless tests active so that samples are not dropped for +being late +- Fix problem with using external buffers for OMX encoder for 2way. +- Check if CPM object exists before creating one in MP4 parser node +- PVME unable to retrieve metadata for DRM protected content +- Cleanup 2way local.mk +- OMX audio dec node should process multiple BOS (BOC/EOC) messages correctly +in case of LATM format +- Multiplexed data gets corrupted when is there is no data in logical channel +- Prevent redundant oscl file cache writeupdate calls when closing file +- OSCL SetSize() implementation +- Changed logfile appenders to take boolean flag indicating whether or not +(default) to flush after every write. Add 'fsync' to linux oscl file +implementation +- Fix broken build due to pvmedia_io_fileoutput +- Move implementation of some 2-way methods from header file into C file +- Player engine not using the source node capconfig interface for all engine +capconfig calls +- Fix for TC 21 on MP3 clips +- TC 414 (FullPlaylistPauseSkipToNextTrackResumeTest) failing with full logging +turned ON +- Handling for packets received after RTSP PLAY response with timestamps less +than the advertised rtpbase +- Modify the AMR Enc OMX component to take timestamp from the OMX client and +remove logic to detect gaps or overlaps. +- Sometimes cancelall command is not executed on all the data sinks in +cancellation process by the engine. +- AAC lib - Fix for random crash under certain test condition +- Additional changes in the AAC lib to support redundant PCE +- Memory leaks when using PVMP4FF_USE_EXTN_UDTA mode in MP4 Composer library +- If the ERecognizerStart command is canceled, do not queue a ERecognizerClose. +- Fix issue where an RTSP server returns a start NPT that is non-zero despite +the application's request for a zero NPT +- MP4 parser node fixes for retrieving key-value pairs without a track index in +the input string +- Re-issue commands in 2way engine to be run later. +- correct rtpinfo was not used while deciding ts +- OMX Decoder Node Scheduling may be affected due to node refactoring change +- Duration was not converted to millisec timescale properly +- Remove unneeded dependency on header files in mediaoutputnode +- Linux oscl time converts time differrently depending on whether or not zulu +is set +- Add check to prevent engine clock from starting if engine is not in started +state +- Protect oscl file native seek and read operations on the same file handle +- A flag needs to be initialized correctly for decoder node codec config data +not to be affected by inserting a pause command +- Fix for eAAC clips seek resulting in wrong speed +- AAC lib - Audio artifacts when decoding clip with continue saturated levels +- Missing metadata key "writer" in metadatadriver.cpp +- TARGET_ARCH_VERSION missing from Config.mk +- AAC-lib Compiler bug on Android build creates the wrong assembly code +- Disconnect-Seek mode support for pause/resume +- Fix for MP3 parser returning incorrect value for bitrate key +- When outgoing user input message is deleted, VT crashes +- Fixing media scanner inappropriate removal of media files +(https://review.source.android.com/#change,14161) +- Change to return engine state as prepared (not started) if the engine +has moved into auto_pause after prepare state, without being started. +- Updating out-of-order packets handling logic +- Added support to handle multiple 'elst' entries in MP4 FF. That improved AV +sync while playing the content which has multiple edit list. +- Remove empty OSCL source files and add comment to empty 2way makefile +- This record fixed a streaming module unit test problem +- PVME test crashes while running .mp4 files +- Oscl file cache read error for large block sizes +- Update the mp3ffparser node to handle the cancel command in init. +- Null-terminate the string sent as part of PVMFInfoSourceFormatUpdated event +- PV_CFLAGS set to wrong value in Config.mk +- OMX unit test modifications +- AAC recognizer - fails by qualifying valid extension-less MP3 clip as AAC +- Fix parsing of certain HTTP URLs. +- Initialize _currentPlaybackSampleTimestamp to zero in +SampleTableAtom::resetTrackByTime() +- Use threadsafe callback AO in camera input MIO to reschedule the AO +- Modified PVME to handle the failures from SetSourceInitializationData in +SourceNode +- Check EOS buffer flag if in the middle of partial frame assembly in omx +component +- Fix for AAC silence insertion for the mono case and the AAC+ case +- Disable filewriter thread in composer node +- test_adts_x.pcm +- Peeking samples from an mp4 fragmented files may return wrong information +- Fixed timestamp conversion for B-frames. +- Fix live RTSP streaming issue +- MP4 Source node doesnt resets FirstValidClip's index after Stop/Reset +- OMX AVCDec output buffer calculation for cropped output could be smaller than +required. Hence, the buffer calculation part must be modified. +- Fix an assert involving iStride and iSliceHeight in omx video decoder node +- A 64-bit overflow when computing energy levels was incorrectly saturated with +a 32-bit max., instead of a 64-bit max in the AAC decoder +- Fix live RTSP streaming issue +- Passing the call ReleaseNodeMetadataValues from the source node to the CPM +plugin. +- Add robustness to AAC SBR with silence insertion. +- Fix BOS and EOS timestamps for MP3 +- Fix player engine playlist unit test 414 +- Change implementation of XML escape() for memory leak analysis +- Improvements at the Download Manager, PE Node and mp4 parser in order to +accomodate new Progressive Streaming protocols. +- Incorrect duration for AAC ADIF file +- Call failure when two TCS are received +- Allow repositioning in mp4 files without stss atoms +- Update the description of setParametersSync API +- Fix multiple repositioning usecases with MP3 gapless playlists +- Audio distortion heard in AMR-NB audio clip +- AAC multichannel decoder robustness improvement to prevent crash. +- Export GetRemoteCodecCapability method for 2-way +- Fix logical error in error handling +- Corrected intialization of ParserObject and ClipIndex for Metadata parsing in +MP3FF. +- resolve player engine test RELEASE Linux build compilation errors on gcc 4.3 +- Recognizer fails to recognize file but file is larger than minimum needed. +- Improvements at the Download Manager, Protocol Engine node in order to +accomodate new Progressive Streaming protocols +- Error events from the audio thread are not handled correctly +- OSCL Unicode to UTF8 modification +- Fix deadlock in mp3 parser and node for mp3 files that are smaller than the +minimum desired for recognition +- Fix parsing of certain RTSP URLs. +- VT TC-58 failure +- OsclMemPoolResizableAllocator does not allocate memory in a circular way, +causes fragmentation. +- Fix out-of-bounds array index issue in 2way-stack. +- Changed bitmask in oscl_UTF8ToUnicode function so sign extension with 32-bit +wchars is handled properly. +- cleanup of old Keys from MIOs +- Fixed memory leak on file trackfragmentatom.cpp +- Corrected SkipMediaTS calculation and FrameDuration for Backward playback +- Node shall not set async flag for sync command on CPM. +- Follow-on RIO-7292 to fix PV_CPU_ARCH_VERSION value in Android.mk files. +- Handle PVMFInfoErrorHandlingComplete info events in the FMU +- Fixed track fragment atom parsing to allow UUID atom +- BaseNode shall use the logger tag supplied by node and enable complete node +logging. +- Incorrect handling of INSUFFICIENT_DATA error when parsing mp4 movie fragment +clip +- Fixed bug in player engine error-handling code. +- Media Output Node sync margins are not being set for video tracks + + +=============================================================================== +2009-12-08 OpenCORE 2.07 + +New Features +- Support 3GPP fast content switch +- Player engine changes and new interfaces for gapless playback +- Player unit test additions +- Add KVP mechanism to set max/min UDP port number +- Support PE node feature selection for static builds +- SetFSIParam( ) extension interface is implemented. It was previously stubbed +out. FSI (VOL header or SPS/PPS) is sent to the encoder as preferred encoding +parameters. +- Introduce ASM and condition support for arm in tool generated project files. +- GetActualAACConfig - add mime type as input to process properly RFC 3016 type +streams +- Updates to player engine and media output node for gapless playback +- Implement support for I-frame request in OMX encoder node +- Add support for AAC Dual Mono +- Add a new KVP to control audio output in trickplay mode. +- CPM changes and new player engine unit test cases. +- Add Track ID as input parameter to the addTrack mp4 composer API + +Improvements +- Added pvlogger_empty_layout.h as an optional logger output string format that +appends nothing to the output string. +- Code cleanup in MP4 decoder vop code +- AAC lib - improve ADTS searching capabilities - needed for applications not +using aac parser +- Change to use audio output buffer size calculation to be based on time as in +the OMX audio dec node rather than based on a fixed number of samples as in the +OMX components default. +- Handle more non-standard OMX component state transition errors +- Removal of 2way VideoParser Node +- Update MediaIONodeRepositionDuringPreparedTest test case to run till EOS +- Improve FillBufferDoneProcessing and ParseAVCFullFrameIntoNALs in OMX encoder +nodes +- Add support for linking against eclair-specific libraries +- Adding a new api to turn silence insertion logic on or off (engine->omx +decoder node->omx audio component). +- Introduce -Wno-psabi into android makefiles +- Modify logging in PVME Test so that it's consistent with the other logging +- Cleanup in the android folder (logging, whitespace, etc) +- Changes in android folder to sync-up with eclair changes +- Removed unused code oscl_mempool_allocator.h/.cpp +- Include pvlogger library in oscl build +- Updating run_ae_test make target for logging +- Minor bug fix to support movie fragments MP4 files with empty sample +description tables and common PE Node code refactoring + +Bugs Fixed +- Video and timer gets stuck on repositioning while the audio continues +- A/V Sync Issue on Simple playback and timer goes beyond the limit with Video +playback only (Audio Stops) +- Fix for redundant rule to copy getactualaacconfig.h +- MP4 file parser and parser node modified to support a very large value of +timescale +- Improvements in AAC file parser for ADTS recognition +- Code cleanup in pvmf_node_interface +- Failures in Java-based mediaframework unit test cases. +- Fix for failure on resumption from long pauses during RTSP streaming. +- Remove an extra call of ResetData from ThreadLogoff in AndroidSurfaceOutput +- Mp4 composer node File writer hang issue +- Typo in the OMX node log statements +- Uninitialized variable iPlayElementIndex of structure PVPPlaybackPosition +causing repositioning problems +- In AAC and AMR parser nodes, UsageComplete should be called only when the +content is protected +- MP4 parser node returning the same command twice +- Hang in Player engine when cancel called in prepare +- Use clock_gettime(MONOTONIC) instead of gettimeofday() on linux platform to +have a consistent clock +- In PVPlayerEngine::DoVerifyAndSetPlayerParameter, hard-coded enum value is +wrong +- OMX encoder node bug in processing SPS PPS for components that produce NAL +start codes +- Classes with virtual methods should have virtual destructors too +- Fix for crash in AAC Decoder unit test app +- Map key 'track-info/track-number' to 'tracknumber' for Android MediaScanner +to recognize the key. +- MP3 FF parser should not pass the Xing/LAME header frame to dec node +- AMR file parser improvements +- Removed parsing support for WMF AMR tracks from MP4 file parser. +- Improvements in OMX test application +- Fix crash in 2way stack unit test +- Change in oscl statfs to accomodate blank paths +- Add Error handling at buffer memory allocation error +- Fix rebuffering after PVMFInfoBufferingComplete at mp4 PPB +- AVC configuration modifications +- Using sample duration in addition to timestamp for syncronization +- FMU video MIO does not set video subformat type correctly +- Fix uninitialized memory in 2way engine unit tests +- Updated PVPlayerEngine::ReleaseMetadataValues to properly handle clip index +argument +- Fix for running a test number multiple times in makefile target for running +parallel player engine tests +- OMX Encoder node returns failure if OMX components returns Failure for +"OMX_IndexConfigCommonRotate" parameter +- Remove tests not applicable for OpenCORE +- MediaScanner has some API calls which are missing the interface +- Cap lower bound player engine watchdog timer duration to default value +- Enable File-writer for Mp4 composer node +- Early and Late Sync Margins changed for better AV Sync + + +=============================================================================== +2009-11-08 OpenCORE 2.06 + +New Features +- Add support for the PLS playlist file format for use with Shoutcast +- Adding code to benchmark encoding/decoding operation in the OMX component +- Add support for junit-like XML log output to test framework +- AAC utility getaacaudioinfo - add support for adts clips parsing +- Add support in playerdriver for RTSP streaming based on an input SDP file. +- Player engine unit test needs to support a list of test case ranges +- Add support for authoring btrt atom in mp4 composer to record bitrate +information. +- Unit test logger option unification +- Add SetDuration capability and new command status code in the base node +- Add build macro for turning compiler warnings into errors in Android.mk files +- New color conversion library suite for YUV420 to YUV422 conversion; supports +basic conversion as well as 90 and 270 degree rotation +- Add communication between OMXEncNode and Composer node for MaxBitRate and +DecodingBufferDB +- Support PVMF_MIME_H264_RAW where decoder config info is not always available +before the actual decoding start +- Support for YUV422 to OMX encoder components (M4V and AVC) +- Enable track selection helper to choose the OMX component used for each track +- Changes in PlayerEngine, FMU, and source nodes to allow retrieval of +thumbnails for protected content +- Gapless audio support at the file format and source node level + +Improvements +- Change the default behavior of the local makefiles to flag compiler warnings +as errors and provide a new flag to disable it +- AMR-NB modifications from AOSP +https://review.source.android.com/10904 +https://review.source.android.com/10905 +https://review.source.android.com/10906 +- Eliminate memcopies of output buffers in omx components (where possible) +- Move helper functions ( MoveCmdToCurrentQueue and MoveCmdToCancelQueue ) to +base node +- Add logic to the OMX encoder to choose another component if one fails +- Update the logic in the encoder node when choosing an OMX encoder +- Track selection metadata ("track-info/selected") needs to be added in AAC/AMR + and MP3 nodes +- Code size reduction +- Ignore pause and seek for live streaming +- New player engine test content +- Add API to 2Way engine to support selection of codecs and their preference +order +- Port OMXBaseNode, OMXVideoNode and OMXAudioNode to new Node Interface +- Build system support for ARM_GCC_V4 from AOSP +https://review.source.android.com/9668 +- Add ID3V2 metadata support in mp4 parser libary defined by 3GPP Rel 7. Move +all metadata related operations from MP4 PN to library +- Variable _mp4ErrorCode to UNSUPPORTED_FILE_TYPE for any brand type in +mpeg4file.cpp should not be set +- Encoder nodes should be added only for uncompressed MIO in 2way engine +- PV OMX component returns invalid supported profile/level pair +- Removing memory leaks in MDBS +- Create Generic 2Way Pause/Resume unit test +- Add insert_element() and clear() methods to OSCL linked list +- Update Player developers guide for CancelCommand and CancelAllCommands error +return values +- Remove a check in sliding_window_process to make avc decoder tolerate an +error condition and continue decoding +- Remove YUV buffer alignment calculations from the OMX decoder node. This is +currently done in the OMX components +- Add the ability to report info and error events from the author MIOs +- Modifying current command queue and cancel command queue to a single command +in the base node +- Refactor RTSP client engine node for cleaner interfacing with streaming +manager node +- Adding support for configuring the number of output buffers as a part of +dynamic port reconfiguration in omx test app +- Refactor MP3FFParserNode to use the base node implementation +- Refactor DownloadManager Node to use the base node implementation +- Refactor MP4 FF Parser Node to use the base node implementation +- Add CallNativeSetSize() API for OSCL File +- Change H.263 encoding default GOB header interval to 0 + +Bugs Fixed +- Track IDs are huge in particular mp4 clip causing crash +- Source node's handling of CPM cmds in Reset is incorrect +- [PDL] Download resume doesn't work if server response doesn't include the +Content-Length header. +- Android_camera_input.cpp method statusUpdate returns unhandled exception +- Hardcoded values in mp4a atom in the composer. (2030968) +- Download manager node uses shoutcast support by default +- atom 'meta' is not skipped +- Video playback is distorted (not normal) during playback for somes clips +- Need the ability to disable CPM in source nodes +- Crash in OsclTimer +- Nodes getting schedule extra number of times +- Update Android MIO to use authoring clock to achieve better AV sync in +encoding +- Implementation of trick play support +- Modify player engine's QueryInterface implementation +- Not able to play InValidId3Tags.mp3 content +- Fixes for building OpenCORE on android-x86 +- Streaming Manager node modification to make feature specific plugins +dynamically loadable +- Memory leak in video telephony engine +- OsclMemPoolResizableAllocator has been modified to take into account the +size specified via setMaxSzForNewMemPoolBuffer while expanding the mempool +- OMX AMR component fixed to support 3 Role strings properly +- Crash in video telephony engine +- PVAuthor Developer's Guide has been updated to clarify 3GP vs MP4 file +authoring +- RTSP amr-nb streaming can not start playback, need to seek then playback +start +- Fix the issues in Table of Contents implementation in Mp3 Parser +- Hang in one accepted/negotiated format 2way engine unit test +- Fix a problem where a node based on the base node implementation was not +getting resheduled to process the next command when multiple commands +(RequestPort in this case) were queued. +- PVMFRecognizer improvements, including multi-pass recognition etc. +- Send correct YUV format to the VMIO instead of PVMF_MIME_FORMAT_UNKNOWN +- By default, use current system time as creation & modification date in MP4 +composer node +- Audio issue in RTSP streaming caused by AMR decoder problem. +- Fix an issue where PVPlayerEngine::Prepare() never completes. If server +sends OPTIONS request to the PVPlayer, PVPlayer does not send SETUP request +to the server and PVPlayerEngine::Prepare() never completes +- Fix for reading from files using a file descriptor with an non-zero offset +- Fix potential crash during streaming session with multiple frames per packet +- Minor refactoring of integer datatype use +- Fix issue where an incorrect VOL header for MPEG4 video content results in +no video playback +- Add an extra condition for the multi-line check in an HTTP response header +- Move inlined code from header to cpp file for pvmf_event_handling +- Update the omx decoder node to reject a component if +iOMXComponentUsesFullAVCFrames is false +- Crash in video telephony engine cleanup +- Report a more appropriate failure status via the author engine when +underlying node commands fails +- Fix the fileoutput MIO to take into account the 422 UYVY format +- Fix for opening shared asset file handles multiple times +- Fileformat parser changes to support some specific mp4 content +- Limit the max size of album art to 3MB +- Changes in sending the Buffering Status +- Adding support for authoring moof clips for live sessions in mp4 composer +library +- PVPlayer crashes when trying to do Progressive Streaming of a specific +MP4 Clip +- Incorrect mime string comparision in pv2way datapath +- Fix for memory leak in mp4 local playback at GetMetaDataValue +- Implement HandleExtensionAPICommands for OMXDecNode +- Change OMX enc node Reset() to return success even OMX comp GetState() +fails or returns bad states +- Treat OMX_EventError with OMX_ErrorInvalidState as if OMX client get an +OMX_EventCmdComplete indicating state transition failure +- Add CTOR in RepositionRequestStruct to init the members +- Fix for testcase 805 with local content +- Logging in PVME Test not working properly for threaded mode +- Thumbnail extraction when no sample present in stss atom +- MP3 frames may have different sampling rate or number of channels. So, +in the omx mp3 component, logic has been added to ensure that only decoding of +consistent frames is sent as output and silence will replace mismatched frames +- Content truncated while seeking specific YouTube clip +- Player Engine should not fail playback if the Source node does not support +Playback control interface +- Cleanup test input and output filenames used in 2way tests +- Error in video display while playing minimum size content (48*48) +- Valgrind error fixes +- Fix a bug in SPS length calculation +- PVME doesn't retrieve metadata properly if file has an invalid extension +- Wrong sequence numbers from video parser node +- Using RTCP SR reports to perform AV sync once, if server does not provide +rtp-info in PLAY response. +- Mp3 parsernode should pass source context to CPM plugins + + +=============================================================================== +2009-08-06 OpenCORE 2.05 + +New Features +- Helper function to retrieve extended messages from command responses. +- Support for eAAC+ encode in the pvAuthor engine. +- Add conversion operations to OSCL_String classes. +- RTSPT support (3GPP streaming over TCP). To test, replace "rtsp" with "rtspt" +in the control URL (in source URL or SDP file). It is assumed that the user has +access to a server with TCP streaming capability. +- PV Metadata Engine (ME). This engine is targeted at applications that want +to retrieve metadata for any given clip in a generic manner. Typically, a lot +of these applications would like to scan large batches of content. Since ME +is mainly targeted at apps like mediascanner, where speed is the most important +factor, thumbnail extraction is not supported. For applications that do want +to extract thumbnails in a generic manner along with the metadata, PV's +FrameAndMetadata Utility (FMU) is recommended instead. +- 2way Lip-Sync unit test cases. + +Improvements +- A new base node implementation is introduced for the purpose of + refactoring and consolidating common logic in the nodes. The changes + will improve maintainability and make it easier to create new nodes. + Further documentation will be released in the future providing guidelines + for authoring nodes. +- The following existing nodes were refactored to utilize the base node + implementation mentioned above: AAC, AMR, and WAV parser nodes. +- Replace CodecSpecifier with PVMFFormatType. +- Move EventHandlerProcessing method to PVMFOMXBaseDecNode class. +- Change method type from "protected" to "private" in OMX derived classes +(videodec node and audiodec node). +- Adding robustness to avcdecoder to verify PPS and SPS parameters. +- Display status of every test case after it finishes in 2way unit test app. +- Add support to H.245 version 10. +- OMX node - Implement interleaved NAL sizes (to replace NAL start codes) in +omx buffers carrying AVC frames. +- AMR-WB contributions to enable building in "C": +https://review.source.android.com/10014 +https://review.source.android.com/10015 +https://review.source.android.com/10016 +https://review.source.android.com/10017 +https://review.source.android.com/10018 +- AMR-NB contributions to enable building in "C": +https://review.source.android.com/10297 +https://review.source.android.com/10301 +https://review.source.android.com/10302 +https://review.source.android.com/10303 +- Update OsclFileStats to track total time taken instead of only the +maximum time per operation. +- Rename OMX master core methods to avoid linking conflicts. +- Pass key MOUT_VIDEO_SUBFORMAT_KEY to the video MIO of FMU. +- Remove Direct Render Mode from mp4 composer library. +- AMR-NB and AMR-WB inline assembly is being re-enabled after a bug +in the QEMU assembly translation has been fixed. +- Modification of MIOs to take all configuration parameters at once. +- Move OMX input and output buffer ctrl structure away from data buffers. +- Enable byte-stream (H264-RAW) format decoding in OMX dec node. +- PVMFInfoTrackDisable information event should be report to java application. +- Retrieve the PLATFORM version at run time for the Android UserAgent string. +- OMX audio and video dec nodes need to be able to handle PortSettingsChanged +event with argument OMX_ALL. +- PVMFMediaClock latency handling improvement. +- AAC decoder creates artifacts when decoding clip. +- Modify MP4 composer node to do sample adds to mp4 composer lib in a separate +thread. +- Add support for VIDEO_ENCODER_H264 in authordriver. +- Author major brand "3gp5" if 3gp clip has TIMED-TEXT track. +- No interleaving of mp4 files for just one track. +https://review.source.android.com/10510 +- Return non-zero code when we detect a memory leak during unit tests. +- Add "3g2a", "3g2b" and "3g2c" as compatible branch in all content authored +by PvAuthor SDK. +- Add support for OMX_COLOR_FormatYCbYCr. +- Remove unneeded libraries being linked against individual shared libraries. +- Exclude empty directories and unncessary build files from OpenCORE. +- In OMX base node, turn the InputBufCtrlStruct from a struct into a class +- Updates to pvmf_return_codes.pdf, pvplayer_developers_guide.pdf, +omx_decoder_test_app_guide.pdf, and omx_encoder_test_app_guide.pdf. + +Bugs Fixed +- Repositioning takes a long time for YouTube videos after a few +repositions. +- Crash in CPVH223Multiplex::Stop(). +- PlayerEngine cannot finish a playback session after repeated pause +and resume near EndOfStream. +- Allow file path to be passed to the pvPlayer SDK on Android. +- Add a new constructor for the AVCSampleEntry to be used when parsing the +encv atom +https://review.source.android.com/9683 +- MP3 DurationCalcAO logic needs to moved to a place during Prepare and not +Init. +- Change PV_GET_ROW definition in M4V decoder. +- Player Engine unit test TC 55 and 56 has memory leaks +- Crash in authordriver if InitializeForThread fails. +- Crash in playerdriver if InitializeForThread fails. +- Potential memory leak in OMX encoder node. +- Memory leaks in AAC file parser node & lib +- FindFirst returns wrong element type when find a directory in android +- Intermittent timeouts on 2way unit tests +- Incorrect DeBlocking logic +- AVC Clip Specific Issue: (Play till EOS) OR (Reposition to near EOS) The +video gets stuck at near EOS +- iTunes genre is not parsed correctly +- Youtube : AV sync is lost after a seek when playing youtube contents +- Crash after recording one minute of Video when duration is specified +- Tracknumber metadata key string should be consistent through out all nodes +- Possible race condition in singleton lock in omx_init +- CPV2WayDatapath::GetPortFormatType() selects least preferred type +- AAC OMX decoder component needs to process whole audio config buffer +- Modify MP3Parser to make seek to 0 a special case and do not use XING header +for calculating file offset +- AAC Decoder should not try decode any AAC+ clip whose final sampling freq +is > 48 KHz. Should default to AAC in these cases. +- Update OMX encoder node to calculate the correct output buffer size in case +the encoder has multiple roles. +- OMX Encoder MPEG4 unit test fix +- Setting AMR_NB bitrate to GSM_AMR_4_75 will fail prepare. +- AuthorEngine should return Success incase Stop is called in +PVAE_STATE_INITIALIZED state. +- OMX M4V encoding drops the first I-frame +- VIDEO_INTERLEAVE_BUFFER_SIZE is too short for some buffers when encoding +D1 resolutions +- Occasional audio glitch in MP3 parser during repositioning +- OMX tests for AMR give seg fault on android +- pvPlayer sends incorrect HTTP Range header +http://code.google.com/p/android/issues/detail?id=3031 +- PDL/PS - Fix the Mp4 Parser node to pass the correct timestamp to PE node +in RequestResumeNotification during Underflow condition +- H.245 TerminalCapabilitySet (TCS) and MasterSlaveDetermination (MSD) +requests must be sent before any other H.245 messages. +- Logic to set iKeepDroppingMsgsUntilMarkerBit to false in AMR RTSP streaming +- 2way tests hanging when run in Android emulator +- Sound Recorder: Incorrect Duration of clip sometimes observed when sdcard is +full +- Memory leak in PV2WayMIO +- Playerengine needs to be updated to return success even if there are no keys +for GetMetadataValue +- Correct the Android RTSP UserAgent string +- Author Engine : Don't access the queue element without checking its queue +size +- If SSRC is not provided in setup response, then pvplayer cleint doesn't send +firewall packets to the server +- GetMetadataValues returns invalid number of entries +- Modify AUT to parse authored files and validate the files as much as possible +- Eliminate media layer node in case of RTSP streaming +- AAC timestamps provided to OMX component may be wrong +- Clean up warnings and some negotiate parameter changes from omx dec & enc +test apps +- Fix valgrind issue reported with android simulator in omx base node +- Add more supported rate control types in pv_video_encnode_extension.h +- Memory leak in player engine test case 807 +- Addressed compiler warnings in PVME +- nBufferAlignment of OMX_PARAM_PORTDEFINITIONTYPE is initialized to negative +value when playing clip on android using qcom decoders +- MP3 parser crash +- pvplayer_engine_test is detecting 'rtspt_test.sdp' as a url instead a local +file +- Count of command line arguments being read in PVME Test App is incorrect +- Player engine test case 1307 fails when run with a mp4 file containing 3GPP +timed text track +- PVMFInfoDataReady event being sent to the engine after the unit test calls +stop +- PlayerEngine doesn't free reference to PVMFDataSourceNodeRegistryInitInterface +- Combine the AMR if statement in pv_omxmastercore.cpp +- Player Engine unit test case 154 fails on execution +- Author Engine unit test cases 101-105 fail +- Add new return code PVMFErrContentInvalidForProgressivePlayback for a +NOT_PROGRESSIVE_STREAMABLE content +- Add USE (AL2, AL3) to 2way test files +- H223 2way test not being run +- Avoid calling CCYUV422toYUV420::New() for each thumbnail +- Author engine unit test case 101 fails +- Ignore encoding flaw, which generates aspec_ratio of value 0 in file +codecs_v2\video\m4v_h263\dec\src +- Memory leaks in pvmf_mio_fileinput.cpp and performance improvement in mp4 +composer node +- Do not cancel Init() immediately in case of 3gpp streaming +- Transferring MP3 with invalid ID2 tags crashes mediaScanner + + +=============================================================================== +2009-05-17 OpenCORE 2.04 + +New Features +- Create external download datastream An external download datastream is +introduced to allow for an external entity to pass a datastream interface +to the player SDK. The external entity is responsible for doing the actual +download of the media data. Full support in Android is not complete until +playerdriver changes and more unit testing is done. +- Fixed cache option in Oscl_File +Adding an option to configure the Oscl file cache to use one or more fixed +caches in addition to the movable cache. +- Modify author engine to contain a notion of "authoring clock" +Author engine has the option to pass an "authoring clock" to media input +components so that they can use this to sync audio and video timestamps. +Author engine has been modified to own a PVMFMediaClock. Author engine +provides a pointer to its to data source node (media input node typically) +at the end of author engine Init cycle, using PVMF_AUTHORING_CLOCK_KEY. +No media input component changes were done. All media input components +used in author engine unit test currently operate from a file and have no +need for such a clock, but some device media input components can make use +of the clock if needed in the future, since author engine will pass the +clock pointer all the time to data sources. +- Shoutcast (of MP3) support +Shoutcast support of MP3 and internet radio streaming is added. +- Enable AAC PDL Support +More robust support of PDL of AAC content, including underflow handling. +- Add support for 3GPP2 speech (EVRC, QCELP etc) in MP4 FF library +Support for the 3GPP2 speech codecs is added at the file format library +level. No 3GPP2 speech codecs are added. +- OpenMAX encoder and decoder unit test suite +- Use external filehandle in Android +- Introduce new macro to android makefiles to enable 2way + +Improvements +- Add support for "all" metadata key in CPM plugins. This feature provides + a single key to request that all available metadata be returned. +- Add support for OMX_ColorFormatCbYCrY +- OMX video dec node now sets the codec parameters (width/height etc.) in the + output port of the omx component. +- A loadable module for the OMA1 passthru CPM plugin now exists. It serves + as an example for creating a loadable CPM plugin. +- Compressed testcases have been added in Authior Engine unit tests to + author 3gp file from AVC and M4V and AAC bitstreams +- Added checks to verify that the PCM output of the mp3 frame will not exceed + the output buffer size, so the mp3 decoder / OMX component is nore robust. +- Removed unnecessary "ComponentGetRolesOfComponent" methods from OMX + components. +- Restored "/x-pvmf/ff-mux/mp4" MIME Type in Author engine. +- Modified the Initial AVC buffers so that the image that appears initially + is black (not green/pink) if I-frame is missing. +- Fixed the IFrameInterval setting in the OpenMAX video encoder node. +- Added the ability to pass a peer PvmiCapabilityAndConfig interface to + the Media I/O (MIO) components using the Capability Exchange. The purpose + is to allow the MIO components to set and get parameters (i.e., drive the + process) rather than on relying on the media output node to do it. +- Added checks to the OMX components to verify that the buffer size + (in allocate/use buffer) (nAllocLen) is adequate (i.e. >= than nBufferSize) +- Updated OMX components so that standard component roles can be queried as + well as set. +- AMR-NB common library modified to mark the proper symbol exports and moved + some functions to encoder and decoder libraries instead of common. +- Updated h264 decoder to take advantage of the fact that there will be no + in-band SPS/PPS NALs for the mime Video dec node prevents in-band SPS/PPS + for the format PVMF_MIME_H264_VIDEO_MP4 +- Add macro for enabling build of pv test engine executables in Android +- Remove 12-bit, 24-bit, and 32-bit routines from Android libraries +- Modified OMX timestamps to be in in microseconds rather than milliseconds + as specified in the OMX spec 1.1.2. +- Improvements and workarounds for non-compliant OMX components +- Replace OPEN_FILE_ONCE_PER_TRACK macro with member variable +aOpenFileOncePerTrack in mp4ffparser lib +- 2way: send data fragment by fragment from parser side +- Added a new function to convert PVMFStatus to human friendly strings +- Implement logic to choose correct OMX component when decoding streaming +H264 +- OMX dec nodes should report error and not even call config parser if +config data is missing (but is required by the format) +- Update playerdriver.cpp to send "disable-firewall-packets" KVP key based +on system Android property + +Bugs Fixed +- Moov atom is not being written into .3gp file if Author driver does not + close file handle. +- omx mp4 component in no-marker-bit mode crashes when playing a certain clip +- Error handling incase of input other then 8K AMR +- Add PVReleaseInterface method to OMX shared library interfaces + (components + main) +- pull sdcard while recording causes media server to crash +- Changes to buffering status notifications while streaming +- OMX nodes should not send repositioning request to OMX component until + config data has been processed by OMX components +- Crash in the author SDK as part of engine Reset +- If SSRC is not provided in setup response, then pvplayer client doesn't + send firewall packets to the server +- PVAuthorEngineNodeUtility::NodeCommandCompleted does not check whether + iCmdQueue is empty +- AMR Local Playback -> FF to EOS when repeat song is on will cause a force + crash +- some source nodes will put same timestamp for DataTS in old stream id + and DiscardTS +- Change pv omx encoder node to default iOMXComponentNeedsNALStartCodes to + false and do sanity check +- When reconfig happen,SinkNode should send reconfig notification with + FormatSpecificInfo to MIO +- Race condition - If port settings event and node stop command arrive + simultaneously - omx component may fail port flush command +- Mp3FFParserNode: Memory leak in Duration Calculator +- Playback clock starts even before PlayerEngine Start( ) is issued +- Clip plays beyond EOS. Fixed setting of the actual normal play time (NPT) + when repositioning. +- Modified OSCL and player driver handling of external file handles in the + player. +- MP3 PS - Repositioning is not working properly +- MP3 Parser needs to validate consecutive mp3 headers before parsing starts +- Crash in MIO component due to setPeer(NULL) is not called +- Improvements and robustness in thumbnail generation from normal and + corrupted clips +- Improvements in stability of Author Engine Unit tests when using OMX + encoder node +- Modify OSCL Mempool to assert when a buffer is deallocated back to + mempool twice in a row +- Fix a possible race condition in omx proxy threads. +- H263 decoder (OMX version) needs to remove the DEFAULT width-height + initialization +- Oscl file cache assert when reading binary file in text mode +- AAC and MP3 decoders have ARMv4 incorrect defines on normalization routines. + (see https://review.source.android.com/Gerrit#change,9668) +- AMR component roles do not distinguish between AMR_NB and AMR_WB +- OSCL shared library avoid dlopen() leaking in case of failure(dlsym() fails) +- Mp3 Clip hangs for some time when repositioned near to the end +- PV_atof will return a value that is larger than it should be if the input +string has a CR at the end +- Sequence number rollover in RTP info param during prolonged RTSP streaming + + +=============================================================================== +2009-03-31 OpenCORE 2.03 + +Improvements +- Enable OpenCORE on master - part 2 + +=============================================================================== +2009-03-10 OpenCORE 2.02 + +******** + There is minor version number nomenclature change where the + minor version is now two digits. So the previous releases + in the new nomenclature are 2.00 (2.0) and 2.01 (2.1). The + new release is 2.02, which is a minor version increment beyond + the previous release. +******** + +New Features +- AMR-WB support added to the OMX encoder node so that it can utilize + an OMX AMR-WB encoder component if it is part of the OMX core. +- Buffer allocator mechanism allowing the Media I/O components to + supply buffers to the OMX decoders. This method is especially useful + as an alternative way to allocate video buffers. Details can be + found in the new document "Guide to Supplying Decoder Buffers from + the MIO Component" in the file mio_decoder_buffer_allocation_guide.pdf + in the top-level doc directory. + +Improvements +- Resolution of Valgrind and static analysis warnings in player and author +- Improvements in support for .mov files in MP4 FF Parser(relaxed some checks). +- Modified OMX encoder node to allow setting the AMR bitrate + based on an extension interface value. +- Fix inconsistencies in OSCL find method related to inclusion of the + directory name with the filename. +- Improvement in PVMFInfoErrorHandlingComplete in the player datapath +- Refactor of the Protocol Engine node to support a plugin architecture. + This improves extensibility of the module for new features in the future. +- Introduce QueryInterfaceSync in PVMFNodeInterface and "all" metadata key +- AMR NB and WB have conflicting meaning for frame_type and mode elements +- Change the default settings related to caching for Oscl_File when + using PVFile within the fileformat parsers. +- Replace test.mp4 with interop clip +- Update of tests for support for progressive download of AMR +- OMX Khronos header files (Omx_Core.h, Omx_Component.h) capitalization + changed to match that from the Khronos (previously they were all lowercase). + +Bugs Fixed +- Memory leak when running GCF TC212 (2way-related) +- MediaClockConverter divided by zero caused by timescale 0 +- MP4 composer node destructor memory corruption fixed. +- Fix for intermittent crash in player engine TC 105 +- OMX dec node did not reset all the internal state during + Reset processing. + + +=============================================================================== +2009-02-26 OpenCORE 2.1 (2.01) + +New Features +* OpenMAX Codec-related: + - Introduced the OMXConfigParser API to help in determining + which OpenMAX components can support the input bitstream. + It is used to narrow the list of candidate OpenMAX components + to be used for playback. See the OpenMAX Core Integration Guide + document in the doc directory for more information. + - Added OMX AAC encoder support in the OMX encoder. + - Modified to use separate component roles for AMR-NB and AMR-WB as + described in the OpenMAX IL spec version 1.1.2. + - Added support for a new buffer format for H.264/AVC decode and + encode to allow passing multiple NALs in a single buffer. + The format uses OMX_OTHER_EXTRADATA structure defined in + section 4.2.33 of the OpenMAX IL spec version 1.1.2 to pass + NAL lengths. See the OpenMAX Core Integration Guide document + in the doc directory for more information. +* Author-related: + - Added support for authoring files with AAC audio. + - Added support for authoring AMR-WB audio to MP4/3GP files and + IETF storage format. + - Added support for writing to an open file descriptor as an option + instead of simply providing a filename. The file descriptor + option is useful for cases where another process needs to open + the file because of permissions. +* Added large file support in OSCL (i.e., 64-bit file size/offset + support) to handle files greater than 2 GiB on filesystems that + support it. +* Added rotation support in the 32-bit color-conversion class. + +Improvements +* Removed dynamically loaded modules from the prelink map to avoid + clutter and to make both the prelink map and loadable modules + easier to manage. There may be an issue if a single instance of + a process tries to load libraries not in the prelink map more than + 256 times + (See http://code.google.com/p/android/issues/detail?id=2042). +* Update to the MP3 Decoder to fix security issue (oCERT_2009-002, + CVE-2009-0475) +* Renamed the OSCL config directory linux_nj to android to match the + platform name. Replaced all references of nj with android in the + codebase. +* General security improvements found from static analysis in the + following areas: + - Buffer and type overruns and underruns + - Null pointer references +* Refactored the jitter buffer node into a more modular architecture + for better support of different streaming use-cases and protocols. +* Fixed an issue in the MP3 decoder when decoding for very of long + durations (over 2 GiB of data). +* General improvements found during 3GPP packet-switched streaming + interoperability testing. +* General improvements and resolution of issues found from module + level and engine (player, author, 2-way) level unit testing. + +New APIs / Behaviors +* Added support in the player engine to cancel a single pending + command using the CancelCommand API. See the player engine API + document for details. +* Renumbered the author test cases to avoid issues with + preprocessor conditionals changing the test numbers based on + settings. Now the test numbers shouldn't change. +* In the case of 3rd party OMX components that support multiple roles, + returns an error if the component cannot set the role parameter +* OMX components need to explicitly set nPortIndex parameter for + all appropriate parameters +* Added fix for buffering percentage notification in streaming + scenario (see https://review.source.android.com/Gerrit#change,8699) +* Updated omx shared library build configuration to separate component + registration from component build +* Added methods in baselibs to serialize and deserialize the UTF-16, + UTF-16LE, UTF-16BE strings +* Removed the iUseCPMPluginRegistry flag from the source data that was + previously used to enable the content policy manager. + Since the CPM pluginsare dynamically loaded, the flag is not + needed and was removed. See the playerdriver.cpp for details + of the change. + + +=============================================================================== +2009-01-26 OpenCORE 2.0 (2.00) + +New Features +- Consolidation of the clock logic into a common clock object + (PVMFMediaClock). More details will be provided in a + Tech note at a later time. +- Refactor MP4 Composer library +- omx component refactoring (Introducing base omx component class) +- OMX Encoder Support +- Check URIs for illegal characters and run escaping algorithm if any + are found. +- Support for 3GPP AssetInfo Metadata in Author SDK +- MP3 Dynamic TOC Construction +- Modify MPEG4/H.263 node/library to support arbitrary Decoder + Configuration Information (DCI) +- backward playback support for MP4 +- Refactoring Colorconversion from mpeg4 encoder and adding support + for YUV420SemiPlanar +- Refactor streaming manager node into feature specifc plugins +- Thread Safe Player Engine APIs and Thread Safe queue +- Adding capability to turn off AC prediction and change + IntraDCVlcThreshold for MPEG4 encoder library +- Dynamically populate recognizer registry +- add 2way support for OpenCORE +- Combine OMX audio dec node and Video Dec node +- OMX MasterCore +- Apply new RGB to YUV color conversion libraries to OMX encoder + components +- Use loadable modules in CPM +- Adding support for YUV420Semiplanar to avc encoder, m4v encoder and + author +- introduce dynamic loading of individual omx components + +Improvements +- Removal of all compiler warnings reported by Android compiler + Exception: unit test app code +- Module-level unit test fixes +- Various Valgrind errors and fixes +- Various Codesonar warnings and fixes +- various security audit and fixes +- various memory leak fixes +- various crash, hang fixes for specific test content or test cases +- Re-work Oscl Scheduler semaphore & lock +- Author Engine Error Handling Robustness +- Player Engine Error Handling Robustness +- Add capability of assembling partial frames and inserting NAL start + codes to OMX node +- The media I/O component configuration process needs to be improved. +- Fundamental change in behavior of repositioning during 3GPP + streaming +- Improvements to the PV FrameMetadataUtility [FMU] +- mp3 parser - duration calculation by walking file in background +- IOT merges from 2-way team +- Longevity issues with live streaming +- Local Playback MP3 file does not display attached art work +- Issues with Oscl Leave, Panic, and Assert +- Modify allocators to not leave in case of an alloc failure, but + instead have them return OsclErrNoMemory +- Conversion of strcmp and strstr usage to strncmp for non null + terminated Strings +- Change Oscl memory auditing from TLS-based to Singleton-based +- Buffer status report in a periodical manner to improve the app + awareness about how engine is running in low bandwidth for PDL/PS +- AVC Encoder Improved Rate Control +- State Transition: Remove implicit ThreadLogoff() from Nodes +- Include aac recognizer for Android +- Audit MP4 parser against new iTunes spec +- Replace PVMFSMSharedBufferAllocWithReSize allocator with + OsclMemPoolResizableAllocator +- Player Engine registry re-work + +New KVPs / APIs / API behaviors +- Change Download Manager Stop Command to Stop Download +- Add a KVP to configure jitter buffer inactivity run time from the + app +- OSCL Critical Error Handling +- Adding kvp in SM node to set rtsp_timeout timer in rtsp engine node +- Get rid of "getTrackOTIType" API in parser lib and switch mp4 parser + node to use "getTrackMIMEType". +- Adding capability to turn off AC prediction and change + IntraDCVlcThreshold for MPEG4 encoder library +- Deprecate PVMFCPMPluginLocalSyncAccessInterface +- Introduce new API in Engine to Release MetaData Values +- Use of PVMF format types in player registries +- Introduce new kvp key to set jitter buffer size +- Add a new meta data key to Mp3ParserNode to support channel mode + retrieval +- Support for taking in video bitrate and other params from a config + file, for uncompressed AVI test cases. +- Deprecate TLS-based memory audit +- Use KVP "nodedataqueuing_timeout" instead of compile time tuneable + "SYNC_POINT_DIFF_THRESHOLD" +- Please apply "mode=" for "x-pvmf/net/user-agent;valtype=char*" key. +- Change libpv*.so to libopencore_*.so +- Singleton and lock/unlock mechanism needed for OMX master core + globals +- In case of 3rd party OMX components that support multiple roles - + input dec format and output enc format needs to be specified +- OMX Core plugin code (for 3rd party omx cores integration) + +Known Issues +- Had to temporarily remove the doc directory because of conflicts + with Gerrit and PDF files. These will be uploaded again now that + Gerrit is updated. +- Additional documentation will be released as soon as possible. +- The OpenMAX encoder node is configuring the OpenMAX component with + the wrong format for AMR. It is using + OMX_AUDIO_AMRFrameFormatRTPPayload when it should be + OMX_AUDIO_AMRFrameFormatFSF. +- The OpenMAX encoder node is not handling Reset correctly in all + cases. + +=============================================================================== +2008-10-21 OpenCORE 1.0 (1.00) + +OpenCORE 1.0 is the initial contribution to AOSP. It has both release-1.0 +and android-1.0 tags. diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/Config.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/Config.mk new file mode 100644 index 0000000..e6f78f3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/Config.mk @@ -0,0 +1,98 @@ +ifneq ($(strip $(EXTERNAL_OPENCORE_CONFIG_ONCE)),true) + # This is the first attempt to include this file + EXTERNAL_OPENCORE_CONFIG_ONCE := true + + PV_TOP := $(my-dir) + + PV_CFLAGS := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 + ifeq ($(PLATFORM_VERSION),1.5) + else ifeq ($(PLATFORM_VERSION),1.6) + else ifeq ($(PLATFORM_VERSION),2.1) + ifeq ($(PV_WERROR),1) + PV_CFLAGS += -Wno-psabi + endif + else + ifeq ($(PV_WERROR),1) + PV_CFLAGS += -Wno-psabi + endif + endif + + ifeq ($(PV_WERROR),1) + PV_CFLAGS += -Werror + endif + ifeq ($(TARGET_ARCH),arm) + PV_CFLAGS += -DPV_COMPILER=1 + ifeq ($(TARGET_ARCH_VERSION),armv7) + GLOBAL_CPU_ARCH_VERSION :=7 + else ifeq ($(TARGET_ARCH_VERSION),armv7-a) + GLOBAL_CPU_ARCH_VERSION :=7 + else ifeq ($(TARGET_ARCH_VERSION),armv7-r) + GLOBAL_CPU_ARCH_VERSION :=7 + else ifeq ($(TARGET_ARCH_VERSION),armv7-m) + GLOBAL_CPU_ARCH_VERSION :=7 + else ifeq ($(TARGET_ARCH_VERSION),armv6) + GLOBAL_CPU_ARCH_VERSION :=6 + else ifeq ($(TARGET_ARCH_VERSION),armv6j) + GLOBAL_CPU_ARCH_VERSION :=6 + else ifeq ($(TARGET_ARCH_VERSION),armv6t2) + GLOBAL_CPU_ARCH_VERSION :=6 + else ifeq ($(TARGET_ARCH_VERSION),armv6z) + GLOBAL_CPU_ARCH_VERSION :=6 + else ifeq ($(TARGET_ARCH_VERSION),armv6zk) + GLOBAL_CPU_ARCH_VERSION :=6 + else ifeq ($(TARGET_ARCH_VERSION),armv6-m) + GLOBAL_CPU_ARCH_VERSION :=6 + else ifeq ($(TARGET_ARCH_VERSION),armv5e) + GLOBAL_CPU_ARCH_VERSION :=5 + else ifeq ($(TARGET_ARCH_VERSION),armv5te) + GLOBAL_CPU_ARCH_VERSION :=5 + else + GLOBAL_CPU_ARCH_VERSION :=5 + endif + PV_CFLAGS += -DPV_CPU_ARCH_VERSION=$(GLOBAL_CPU_ARCH_VERSION) + endif + + FORMAT := android + + PV_COPY_HEADERS_TO := libpv + + PV_CFLAGS_MINUS_VISIBILITY := $(PV_CFLAGS) + PV_CFLAGS += -fvisibility=hidden + + PV_INCLUDES := \ + $(PV_TOP)/android \ + $(PV_TOP)/../sqlite/dist \ + $(PV_TOP)/../openssl/include \ + $(PV_TOP)/../../frameworks/base/core/jni \ + $(JNI_H_INCLUDE) \ + $(PV_TOP)/extern_libs_v2/khronos/openmax/include \ + $(PV_TOP)/engines/common/include \ + $(PV_TOP)/engines/player/config/android \ + $(PV_TOP)/engines/player/include \ + $(PV_TOP)/nodes/pvmediaoutputnode/include \ + $(PV_TOP)/pvmi/pvmf/include \ + $(PV_TOP)/fileformats/mp4/parser/config/opencore \ + $(PV_TOP)/oscl/oscl/config/android \ + $(PV_TOP)/oscl/oscl/config/shared \ + $(PV_TOP)/engines/author/include \ + $(PV_TOP)/android/drm/oma1/src \ + $(PV_TOP)/build_config/opencore_dynamic \ + $(TARGET_OUT_HEADERS)/$(PV_COPY_HEADERS_TO) + + # Stash these values for the next include of this file + OPENCORE.PV_TOP := $(PV_TOP) + OPENCORE.PV_CFLAGS := $(PV_CFLAGS) + OPENCORE.PV_CFLAGS_MINUS_VISIBILITY := $(PV_CFLAGS_MINUS_VISIBILITY) + OPENCORE.FORMAT := $(FORMAT) + OPENCORE.PV_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + OPENCORE.PV_INCLUDES := $(PV_INCLUDES) +else + # This file has already been included by someone, so we can + # use the precomputed values. + PV_TOP := $(OPENCORE.PV_TOP) + PV_CFLAGS := $(OPENCORE.PV_CFLAGS) + PV_CFLAGS_MINUS_VISIBILITY := $(OPENCORE.PV_CFLAGS_MINUS_VISIBILITY) + FORMAT := $(OPENCORE.FORMAT) + PV_COPY_HEADERS_TO := $(OPENCORE.PV_COPY_HEADERS_TO) + PV_INCLUDES := $(OPENCORE.PV_INCLUDES) +endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/NOTICE.txt b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/NOTICE.txt new file mode 100644 index 0000000..9d5d01c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/NOTICE.txt @@ -0,0 +1,269 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +Portions of the PacketVideo supplied code contain contributions which may be +covered by the following copyright statements: + + +/* ------------------------------------------------------------------- * + * MPEG-4 Simple Profile Video Decoder + * ------------------------------------------------------------------- * + * + * This software module was originally developed and/or edited by + * + * Paulo Nunes (IST / ACTS-MoMuSyS) + * Robert Danielsen (Telenor / ACTS-MoMuSyS) + * Luis Ducla-Soares (IST / ACTS-MoMuSys). + * Cor Quist (KPN / ACTS-MoMuSys). + * Minhua Zhou (HHI / ACTS-MoMuSys). + * + * in the course of development of the MPEG-4 Video (ISO/IEC 14496-2) standard. + * This software module is an implementation of a part of one or more MPEG-4 + * Video (ISO/IEC 14496-2) tools as specified by the MPEG-4 Video (ISO/IEC + * 14496-2) standard. + * + * ISO/IEC gives users of the MPEG-4 Video (ISO/IEC 14496-2) standard free + * license to this software module or modifications thereof for use in hardware + * or software products claiming conformance to the MPEG-4 Video (ISO/IEC + * 14496-2) standard. + * + * Those intending to use this software module in hardware or software products + * are advised that its use may infringe existing patents. The original + * developer of this software module and his/her company, the subsequent + * editors and their companies, and ISO/IEC have no liability for use of this + * software module or modifications thereof in an implementation. Copyright is + * not released for non MPEG-4 Video (ISO/IEC 14496-2) Standard conforming + * products. + * + * ACTS-MoMuSys partners retain full right to use the code for his/her own + * purpose, assign or donate the code to a third party and to inhibit third + * parties from using the code for non MPEG-4 Video (ISO/IEC 14496-2) Standard + * conforming products. This copyright notice must be included in all copies or + * derivative works. + * + * Copyright (c) 1996, 1997 + * + *****************************************************************************/ + + + +/**************************************************************************** + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +*******************************************************************************/ + + +/************************************************************************** + +This software module was originally developed by + +Mikko Suonio (Nokia) + +in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard +ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an +implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools +as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives +users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this +software module or modifications thereof for use in hardware or +software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio +standards. Those intending to use this software module in hardware or +software products are advised that this use may infringe existing +patents. The original developer of this software module and his/her +company, the subsequent editors and their companies, and ISO/IEC have +no liability for use of this software module or modifications thereof +in an implementation. Copyright is not released for non MPEG-2 +NBC/MPEG-4 Audio conforming products. The original developer retains +full right to use the code for his/her own purpose, assign or donate +the code to a third party and to inhibit third party from using the +code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This +copyright notice must be included in all copies or derivative works. + +Copyright (c) 1997. + +***************************************************************************/ + + +/************************************************************************** + +This software module was originally developed by +Nokia in the course of development of the MPEG-2 AAC/MPEG-4 +Audio standard ISO/IEC13818-7, 14496-1, 2 and 3. +This software module is an implementation of a part +of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the +MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC gives users of the +MPEG-2aac/MPEG-4 Audio standards free license to this software module +or modifications thereof for use in hardware or software products +claiming conformance to the MPEG-2 aac/MPEG-4 Audio standards. Those +intending to use this software module in hardware or software products +are advised that this use may infringe existing patents. The original +developer of this software module, the subsequent +editors and their companies, and ISO/IEC have no liability for use of +this software module or modifications thereof in an +implementation. Copyright is not released for non MPEG-2 aac/MPEG-4 +Audio conforming products. The original developer retains full right to +use the code for the developer's own purpose, assign or donate the code to a +third party and to inhibit third party from using the code for non +MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice +must be included in all copies or derivative works. +Copyright (c)1997. + +***************************************************************************/ + + +------------------------------------------------------------------------------ + +MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + + +/* + * snprintf.c - a portable implementation of snprintf + * + * AUTHOR + * Mark Martinec , April 1999. + * + * Copyright 1999, Mark Martinec. All rights reserved. + * + * TERMS AND CONDITIONS + * This program is free software; you can redistribute it and/or modify + * it under the terms of the "Frontier Artistic License" which comes + * with this Kit. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Frontier Artistic License for more details. + * + * + */ + +The "Frontier Artistic License" may be found at + http://www.spinwardstars.com/frontier/fal.html + + +/*---------------------------------------------------------------------------*/ + +/* + * Copyright (c) 2005 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +/*---------------------------------------------------------------------------*/ + +/**@@@+++@@@@****************************************************************** +** +** Microsoft Windows Media +** Copyright (C) Microsoft Corporation. All rights reserved. +** +***@@@---@@@@****************************************************************** +*/ + + +------------------------------------------------------------------------------- +Portions of this file are derived from the following 3GPP standard: + + 3GPP TS 26.073 + ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec + Available from http://www.3gpp.org + +(C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC) +Permission to distribute, modify and use this file under the standard license +terms listed above has been obtained from the copyright holder. +------------------------------------------------------------------------------- + + +------------------------------------------------------------------------------- +Portions of this file are derived from the following 3GPP standard: + + 3GPP TS 26.173 + ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec + Available from http://www.3gpp.org + +(C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC) +Permission to distribute, modify and use this file under the standard license +terms listed above has been obtained from the copyright holder. +------------------------------------------------------------------------------- + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/README.txt b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/README.txt new file mode 100644 index 0000000..d63d0f9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/README.txt @@ -0,0 +1,60 @@ + Welcome to OpenCORE + + http://www.opencore.net/ + +OpenCORE is the multimedia framework of Android originally contributed by +PacketVideo. It provides an extensible framework for multimedia rendering and +authoring and video telephony (3G-324M). + +The following an overview of the directory structure which includes a list of +the top-level directories along with a brief note describing the contents. + +__ + |-- android [Contains the components the interface OpenCORE with + | other parts of Android] + |-- baselibs [Contains basic libraries for data containers, MIME string + | handling, messaging across thread boundaries, etc] + |-- build_config [Contains top-level build files used to build the libraries + | outside of Android] + |-- codecs_v2 [Contains the implementations of PV's audio and video + | codecs as well as the OpenMax IL interface layer] + |-- doc [Contains the documentation required to interface with + | OpenCORE] + |-- engines [Contains the implementation of the player and author + | engines as well as a utility for metadata] + |-- extern_libs_v2 [Contains 3rd-party libraries used by OpenCORE. + | Currently this directory contains header files + | defining the Khronos OpenMax IL interface] + |-- extern_tools_v2 [Contains 3rd-party tools used to build OpenCORE + | indpendently of the Android build system] + |-- fileformats [Contains the libraries for parsing a variety of + | fileformats including mp4/3gp,mp3,wav,aac] + |-- modules [Contains build files for aggregating low-level libraries] + |-- nodes [Contains the OpenCORE framework "nodes", which is + | the abstraction used to implement independent multimedia + | processing units that can be connected in a flow graph] + |-- oscl [This is the Operating System Compatibility Layer which + | provides the mapping OS APIs as well as some basic + | data structures and utilities] + |-- protocols [Contains parsers and composers for a variety of network + | protocols such as HTTP, RTP/RTCP, RTSP, and SDP] + |-- pvmi [Contains fundamental definitions that make up OpenCORE. + | The directory name is an abbreviation of PacketVideo + | Multimedia Infrastructure] + |-- tools_v2 [Contains tools used to build the libraries outside of Android] + +Within each library, the following directory structure, with a few exceptions, +is implemented to organize the files: + +__ + |-- build + |-- make <- makefile to build outside of Android is here + |-- doc <- directory for any documentation specific to this lib + |-- include <- header files that are part of the external interface go here + |-- src <- source and internal header files of the library + |-- test <- test code (follows a similar structure) + |-- build + |-- make + |-- include + |-- src + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_aacdec_sharedlibrary.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_aacdec_sharedlibrary.mk new file mode 100644 index 0000000..8943870 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_aacdec_sharedlibrary.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libomx_aac_component_lib \ + libpv_aac_dec + +LOCAL_MODULE := libomx_aacdec_sharedlibrary + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libomx_sharedlibrary libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/codecs_v2/omx/omx_aac/Android.mk +include $(PV_TOP)/codecs_v2/audio/aac/dec/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_amrdec_sharedlibrary.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_amrdec_sharedlibrary.mk new file mode 100644 index 0000000..818d3ac --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_amrdec_sharedlibrary.mk @@ -0,0 +1,22 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libomx_amr_component_lib \ + libpvdecoder_gsmamr \ + libpvamrwbdecoder + +LOCAL_MODULE := libomx_amrdec_sharedlibrary + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libomx_sharedlibrary libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/codecs_v2/omx/omx_amr/Android.mk +include $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/dec/Android.mk +include $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_amrenc_sharedlibrary.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_amrenc_sharedlibrary.mk new file mode 100644 index 0000000..292e9fe --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_amrenc_sharedlibrary.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libomx_amrenc_component_lib \ + libpvencoder_gsmamr + +LOCAL_MODULE := libomx_amrenc_sharedlibrary + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libomx_sharedlibrary libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/codecs_v2/omx/omx_amrenc/Android.mk +include $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/enc/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_avcdec_sharedlibrary.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_avcdec_sharedlibrary.mk new file mode 100644 index 0000000..21d5b85 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_avcdec_sharedlibrary.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libomx_avc_component_lib \ + libpvavcdecoder + +LOCAL_MODULE := libomx_avcdec_sharedlibrary + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libomx_sharedlibrary libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/codecs_v2/omx/omx_h264/Android.mk +include $(PV_TOP)/codecs_v2/video/avc_h264/dec/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_avcenc_sharedlibrary.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_avcenc_sharedlibrary.mk new file mode 100644 index 0000000..e9b7c91 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_avcenc_sharedlibrary.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libomx_avcenc_component_lib \ + libpvavch264enc + +LOCAL_MODULE := libomx_avcenc_sharedlibrary + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libomx_sharedlibrary libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/codecs_v2/omx/omx_h264enc/Android.mk +include $(PV_TOP)/codecs_v2/video/avc_h264/enc/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_m4vdec_sharedlibrary.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_m4vdec_sharedlibrary.mk new file mode 100644 index 0000000..6962391 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_m4vdec_sharedlibrary.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libomx_m4v_component_lib \ + libpvmp4decoder + +LOCAL_MODULE := libomx_m4vdec_sharedlibrary + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libomx_sharedlibrary libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/codecs_v2/omx/omx_m4v/Android.mk +include $(PV_TOP)/codecs_v2/video/m4v_h263/dec/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_m4venc_sharedlibrary.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_m4venc_sharedlibrary.mk new file mode 100644 index 0000000..1626efa --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_m4venc_sharedlibrary.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libomx_m4venc_component_lib \ + libpvm4vencoder + +LOCAL_MODULE := libomx_m4venc_sharedlibrary + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libomx_sharedlibrary libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/codecs_v2/omx/omx_m4venc/Android.mk +include $(PV_TOP)/codecs_v2/video/m4v_h263/enc/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_mp3dec_sharedlibrary.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_mp3dec_sharedlibrary.mk new file mode 100644 index 0000000..4519214 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_mp3dec_sharedlibrary.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libomx_mp3_component_lib \ + libpvmp3 + +LOCAL_MODULE := libomx_mp3dec_sharedlibrary + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libomx_sharedlibrary libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/codecs_v2/omx/omx_mp3/Android.mk +include $(PV_TOP)/codecs_v2/audio/mp3/dec/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_sharedlibrary.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_sharedlibrary.mk new file mode 100644 index 0000000..95b5e5c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_omx_sharedlibrary.mk @@ -0,0 +1,30 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libomx_common_lib \ + libomx_queue_lib \ + libpvomx_proxy_lib \ + libomx_baseclass_lib \ + libpv_omx_interface \ + libpv_avc_common_lib \ + libpv_amr_nb_common_lib + +LOCAL_MODULE := libomx_sharedlibrary + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/codecs_v2/omx/omx_common/Android.mk +include $(PV_TOP)/codecs_v2/omx/omx_queue/Android.mk +include $(PV_TOP)/codecs_v2/omx/omx_proxy/Android.mk +include $(PV_TOP)/codecs_v2/omx/omx_baseclass/Android.mk +include $(PV_TOP)/codecs_v2/omx/omx_sharedlibrary/interface/Android.mk +include $(PV_TOP)/codecs_v2/video/avc_h264/common/Android.mk +include $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_2way.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_2way.mk new file mode 100644 index 0000000..be8760e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_2way.mk @@ -0,0 +1,31 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpv2waysample \ + libpv2wayengine \ + libpv324m \ + libpvclientserversocketnode \ + libpvcommsionode \ + libpvmio_comm_loopback \ + libpvgeneraltools + +LOCAL_MODULE := libopencore_2way + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/engines/2way/sample_app/pv2waysample/Android.mk +include $(PV_TOP)/engines/2way/Android.mk +include $(PV_TOP)/protocols/systems/3g-324m_pvterminal/Android.mk +include $(PV_TOP)/nodes/pvclientserversocketnode/Android.mk +include $(PV_TOP)/nodes/pvcommsionode/Android.mk +include $(PV_TOP)/pvmi/media_io/pvmio_comm_loopback/Android.mk +include $(PV_TOP)/protocols/systems/common/Android.mk +include $(PV_TOP)/protocols/systems/tools/general/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_author.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_author.mk new file mode 100644 index 0000000..62f6d4d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_author.mk @@ -0,0 +1,32 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvmp4ffcomposer \ + libpvmp4ffcomposernode \ + libpvauthorengine + +LOCAL_WHOLE_STATIC_LIBRARIES += libandroidpvauthor + +LOCAL_MODULE := libopencore_author +ifeq ($(PLATFORM_VERSION),1.5) + LOCAL_SHARED_LIBRARIES := libutils libcutils libui libandroid_runtime libmedia liblog libicuuc +else ifeq ($(PLATFORM_VERSION),1.6) + LOCAL_SHARED_LIBRARIES := libutils libcutils libui libandroid_runtime libmedia liblog libicuuc +else ifeq ($(PLATFORM_VERSION),2.1) + LOCAL_SHARED_LIBRARIES := libutils libcutils libui libandroid_runtime libmedia liblog libicuuc libbinder +else + LOCAL_SHARED_LIBRARIES := libutils libcutils libui libandroid_runtime libmedia liblog libicuuc libbinder libsurfaceflinger_client libcamera_client +endif + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/fileformats/mp4/composer/Android.mk +include $(PV_TOP)/nodes/pvmp4ffcomposernode/Android.mk +include $(PV_TOP)/engines/author/Android.mk +include $(PV_TOP)/android/author/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_common.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_common.mk new file mode 100644 index 0000000..489d9f1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_common.mk @@ -0,0 +1,90 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +$(call add-prebuilt-files, ETC, pvplayer.cfg) +include $(CLEAR_VARS) + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + liboscllib \ + libpvlogger \ + libosclregcli \ + libosclregserv \ + libosclutil \ + libosclproc \ + libosclio \ + libosclmemory \ + libosclerror \ + libosclbase \ + libomx_mastercore_lib \ + libpvgsmamrparser \ + libgetactualaacconfig \ + libm4v_config \ + libpv_config_parser \ + libcolorconvert \ + libthreadsafe_callback_ao \ + libpvmediadatastruct \ + libpvmimeutils \ + libpvgendatastruct \ + libpvmf \ + libpvfileoutputnode \ + libpvmediainputnode \ + libpvomxencnode \ + libpvmiofileinput \ + libpvthreadmessaging \ + libpvmiofileoutput \ + libpvmediaoutputnode \ + libpvomxvideodecnode \ + libpvomxaudiodecnode \ + libpvomxbasedecnode \ + libpvlatmpayloadparser \ + libpvwav \ + libpvfileparserutils \ + libscsp + +LOCAL_MODULE := libopencore_common + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/oscl/oscl/oscllib/Android.mk +include $(PV_TOP)/oscl/pvlogger/Android.mk +include $(PV_TOP)/oscl/oscl/osclregcli/Android.mk +include $(PV_TOP)/oscl/oscl/osclregserv/Android.mk +include $(PV_TOP)/oscl/oscl/osclutil/Android.mk +include $(PV_TOP)/oscl/oscl/osclproc/Android.mk +include $(PV_TOP)/oscl/oscl/osclio/Android.mk +include $(PV_TOP)/oscl/oscl/osclmemory/Android.mk +include $(PV_TOP)/oscl/oscl/osclerror/Android.mk +include $(PV_TOP)/oscl/oscl/osclbase/Android.mk +include $(PV_TOP)/codecs_v2/omx/omx_mastercore/Android.mk +include $(PV_TOP)/codecs_v2/audio/gsm_amr/common/dec/Android.mk +include $(PV_TOP)/fileformats/rawgsmamr/parser/Android.mk +include $(PV_TOP)/codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk +include $(PV_TOP)/codecs_v2/utilities/m4v_config_parser/Android.mk +include $(PV_TOP)/codecs_v2/utilities/pv_config_parser/Android.mk +include $(PV_TOP)/codecs_v2/utilities/colorconvert/Android.mk +include $(PV_TOP)/baselibs/threadsafe_callback_ao/Android.mk +include $(PV_TOP)/baselibs/media_data_structures/Android.mk +include $(PV_TOP)/baselibs/pv_mime_utils/Android.mk +include $(PV_TOP)/baselibs/gen_data_structures/Android.mk +include $(PV_TOP)/pvmi/pvmf/Android.mk +include $(PV_TOP)/nodes/pvfileoutputnode/Android.mk +include $(PV_TOP)/nodes/pvmediainputnode/Android.mk +include $(PV_TOP)/nodes/pvomxencnode/Android.mk +include $(PV_TOP)/pvmi/media_io/pvmi_mio_fileinput/Android.mk +include $(PV_TOP)/baselibs/thread_messaging/Android.mk +include $(PV_TOP)/pvmi/media_io/pvmiofileoutput/Android.mk +include $(PV_TOP)/nodes/pvmediaoutputnode/Android.mk +include $(PV_TOP)/nodes/pvomxvideodecnode/Android.mk +include $(PV_TOP)/nodes/pvomxaudiodecnode/Android.mk +include $(PV_TOP)/nodes/pvomxbasedecnode/Android.mk +include $(PV_TOP)/protocols/rtp_payload_parser/util/build/Android.mk +include $(PV_TOP)/fileformats/wav/parser/Android.mk +include $(PV_TOP)/fileformats/common/parser/Android.mk +include $(PV_TOP)/fileformats/scsp/Android.mk +include $(PV_TOP)/nodes/common/Android.mk +include $(PV_TOP)/engines/common/Android.mk +include $(PV_TOP)/pvmi/content_policy_manager/plugins/common/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_download.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_download.mk new file mode 100644 index 0000000..207e953 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_download.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvdownloadmanagernode \ + libpvdownloadinterface + +LOCAL_MODULE := libopencore_download + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_net_support libopencore_player libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/nodes/pvdownloadmanagernode/Android.mk +include $(PV_TOP)/modules/linux_download/core/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_downloadreg.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_downloadreg.mk new file mode 100644 index 0000000..cdb42ae --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_downloadreg.mk @@ -0,0 +1,18 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvdownloadreginterface + +LOCAL_MODULE := libopencore_downloadreg + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/modules/linux_download/node_registry/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_mp4local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_mp4local.mk new file mode 100644 index 0000000..0455e9f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_mp4local.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvmp4interface \ + libpvmp4ffparsernode + +LOCAL_MODULE := libopencore_mp4local + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_common libopencore_player + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/modules/linux_mp4/core/Android.mk +include $(PV_TOP)/nodes/pvmp4ffparsernode/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_mp4localreg.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_mp4localreg.mk new file mode 100644 index 0000000..6c2c9f8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_mp4localreg.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvmp4reginterface \ + libpvmp4ffrecognizer + +LOCAL_MODULE := libopencore_mp4localreg + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_player libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/modules/linux_mp4/node_registry/Android.mk +include $(PV_TOP)/pvmi/recognizer/plugins/pvmp4ffrecognizer/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_net_support.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_net_support.mk new file mode 100644 index 0000000..c5ba75f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_net_support.mk @@ -0,0 +1,41 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvsocketnode \ + libpv_http_parcom \ + libprotocolenginenode_base \ + libprotocolenginenode_common \ + libprotocolenginenode_download_common \ + libprotocolenginenode_pdl \ + libprotocolenginenode_ps \ + libprotocolenginenode_shoutcast \ + libpvjitterbuffer \ + libpvjitterbuffernode \ + libpvsdpparser \ + librtprtcp + +LOCAL_MODULE := libopencore_net_support + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/nodes/pvsocketnode/Android.mk +include $(PV_TOP)/protocols/http_parcom/Android.mk +include $(PV_TOP)/nodes/pvprotocolenginenode/base/Android.mk +include $(PV_TOP)/nodes/pvprotocolenginenode/protocol_common/Android.mk +include $(PV_TOP)/nodes/pvprotocolenginenode/download_protocols/common/Android.mk +include $(PV_TOP)/nodes/pvprotocolenginenode/download_protocols/progressive_download/Android.mk +include $(PV_TOP)/nodes/pvprotocolenginenode/download_protocols/progressive_streaming/Android.mk +include $(PV_TOP)/nodes/pvprotocolenginenode/download_protocols/shoutcast/Android.mk +include $(PV_TOP)/nodes/streaming/jitterbuffernode/jitterbuffer/common/Android.mk +include $(PV_TOP)/nodes/streaming/jitterbuffernode/Android.mk +include $(PV_TOP)/protocols/sdp/parser/Android.mk +include $(PV_TOP)/protocols/sdp/common/Android.mk +include $(PV_TOP)/protocols/rtp/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_player.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_player.mk new file mode 100644 index 0000000..c2c2626 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_player.mk @@ -0,0 +1,72 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libcpm \ + libpvpvxparser \ + libpvid3parcom \ + libpvamrffparsernode \ + libpvamrffrecognizer \ + libpvplsffrecognizer \ + libpvmp3ff \ + libpvmp3ffparsernode \ + libpvmp3ffrecognizer \ + libpvmp4ff \ + libmp4recognizer_utility \ + libpvaacparser \ + libpvaacffparsernode \ + libpvaacffrecognizer \ + libpvwavffparsernode \ + libpvwavffrecognizer \ + libpvcommonparsernode \ + libaudioparser \ + libamrparser \ + libwavparser \ + libpvmfrecognizer \ + libpvframemetadatautility \ + libpvplayer_engine + +LOCAL_WHOLE_STATIC_LIBRARIES += libandroidpv + +LOCAL_MODULE := libopencore_player +ifeq ($(PLATFORM_VERSION),1.5) + LOCAL_SHARED_LIBRARIES := libutils libcutils libui libhardware libandroid_runtime libdrm1 libmedia libsgl libvorbisidec libsonivox liblog libicuuc +else ifeq ($(PLATFORM_VERSION),1.6) + LOCAL_SHARED_LIBRARIES := libutils libcutils libui libhardware libandroid_runtime libdrm1 libmedia libsgl libvorbisidec libsonivox liblog libicuuc +else ifeq ($(PLATFORM_VERSION),2.1) + LOCAL_SHARED_LIBRARIES := libutils libcutils libui libhardware libandroid_runtime libdrm1 libmedia libskia libvorbisidec libsonivox liblog libicuuc libbinder +else + LOCAL_SHARED_LIBRARIES := libutils libcutils libui libhardware libandroid_runtime libdrm1 libmedia libskia libvorbisidec libsonivox liblog libicuuc libbinder libsurfaceflinger_client libcamera_client +endif + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_common libopencore_net_support + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/pvmi/content_policy_manager/Android.mk +include $(PV_TOP)/fileformats/pvx/parser/Android.mk +include $(PV_TOP)/fileformats/id3parcom/Android.mk +include $(PV_TOP)/nodes/pvamrffparsernode/Android.mk +include $(PV_TOP)/pvmi/recognizer/plugins/pvamrffrecognizer/Android.mk +include $(PV_TOP)/pvmi/recognizer/plugins/pvplsffrecognizer/Android.mk +include $(PV_TOP)/fileformats/mp3/parser/Android.mk +include $(PV_TOP)/nodes/pvmp3ffparsernode/Android.mk +include $(PV_TOP)/pvmi/recognizer/plugins/pvmp3ffrecognizer/Android.mk +include $(PV_TOP)/fileformats/mp4/parser/Android.mk +include $(PV_TOP)/fileformats/mp4/parser/utils/mp4recognizer/Android.mk +include $(PV_TOP)/fileformats/rawaac/parser/Android.mk +include $(PV_TOP)/nodes/pvaacffparsernode/Android.mk +include $(PV_TOP)/pvmi/recognizer/plugins/pvaacffrecognizer/Android.mk +include $(PV_TOP)/nodes/pvwavffparsernode/Android.mk +include $(PV_TOP)/pvmi/recognizer/plugins/pvwavffrecognizer/Android.mk +include $(PV_TOP)/nodes/pvcommonparsernode/Android.mk +include $(PV_TOP)/fileformats/audioparser/common/Android.mk +include $(PV_TOP)/fileformats/audioparser/amr/Android.mk +include $(PV_TOP)/fileformats/audioparser/wav/Android.mk +include $(PV_TOP)/pvmi/recognizer/Android.mk +include $(PV_TOP)/engines/adapters/player/framemetadatautility/Android.mk +include $(PV_TOP)/engines/player/Android.mk +include $(PV_TOP)/android/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_pvme.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_pvme.mk new file mode 100644 index 0000000..620b9d1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_pvme.mk @@ -0,0 +1,18 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvmetadata_engine + +LOCAL_MODULE := libopencore_pvme + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_player libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/engines/pvme/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_rtsp.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_rtsp.mk new file mode 100644 index 0000000..ec70bd4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_rtsp.mk @@ -0,0 +1,24 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpv_rtsp_parcom \ + libpvrtsp_cli_eng_node \ + librtppayloadparser \ + libpvjitterbufferrtp + +LOCAL_MODULE := libopencore_rtsp + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_net_support libopencore_player libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/protocols/rtsp_parcom/Android.mk +include $(PV_TOP)/protocols/rtsp_client_engine/Android.mk +include $(PV_TOP)/protocols/rtp_payload_parser/Android.mk +include $(PV_TOP)/nodes/streaming/jitterbuffernode/jitterbuffer/rtp/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_streaming.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_streaming.mk new file mode 100644 index 0000000..8fb67c7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_streaming.mk @@ -0,0 +1,22 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvstreamingmanagernode \ + libpvsmfspcommon \ + libpvsminterface + +LOCAL_MODULE := libopencore_streaming + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_net_support libopencore_player libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/nodes/streaming/streamingmanager/Android.mk +include $(PV_TOP)/nodes/streaming/streamingmanager/plugins/common/Android.mk +include $(PV_TOP)/modules/linux_rtsp/core/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_streamingreg.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_streamingreg.mk new file mode 100644 index 0000000..00222db --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_opencore_streamingreg.mk @@ -0,0 +1,18 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvsmreginterface + +LOCAL_MODULE := libopencore_streamingreg + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/modules/linux_rtsp/node_registry/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvoma1passthru.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvoma1passthru.mk new file mode 100644 index 0000000..3ff7983 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvoma1passthru.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvoma1passthruplugin \ + libpvoma1passthruplugininterface + +LOCAL_MODULE := libpvoma1passthru + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_player libopencore_common + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/pvmi/content_policy_manager/plugins/oma1/passthru/Android.mk +include $(PV_TOP)/modules/cpm_oma1_passthru/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtsptunicast_streaming.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtsptunicast_streaming.mk new file mode 100644 index 0000000..91fa4e3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtsptunicast_streaming.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvsmrtsptstreamingplugin \ + libpvrtsptunicaststreamingmanager + +LOCAL_MODULE := libpvrtsptunicast_streaming + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_net_support libopencore_player libopencore_common libopencore_rtsp libopencore_streaming + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/modules/linux_rtsp/smplugins/tunneling/core/Android.mk +include $(PV_TOP)/nodes/streaming/streamingmanager/plugins/rtsptunicast/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtsptunicast_streamingreg.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtsptunicast_streamingreg.mk new file mode 100644 index 0000000..2c40d9e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtsptunicast_streamingreg.mk @@ -0,0 +1,18 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvsmrtsptstreamingpluginreg + +LOCAL_MODULE := libpvrtsptunicast_streamingreg + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_common libopencore_streaming + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/modules/linux_rtsp/smplugins/tunneling/registry/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtspunicast_streaming.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtspunicast_streaming.mk new file mode 100644 index 0000000..0bd20df --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtspunicast_streaming.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvrtspunicaststreamingmanager \ + libpvrtspsmplugininterface + +LOCAL_MODULE := libpvrtspunicast_streaming + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_net_support libopencore_player libopencore_common libopencore_rtsp libopencore_streaming + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/nodes/streaming/streamingmanager/plugins/rtspunicast/Android.mk +include $(PV_TOP)/modules/linux_rtsp/smplugins/unicast/core/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtspunicast_streamingreg.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtspunicast_streamingreg.mk new file mode 100644 index 0000000..8cfef51 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/Android_pvrtspunicast_streamingreg.mk @@ -0,0 +1,18 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + libpvrtspsmpluginreginterface + +LOCAL_MODULE := libpvrtspunicast_streamingreg + +LOCAL_PRELINK_MODULE := false + +-include $(PV_TOP)/Android_system_extras.mk + +LOCAL_SHARED_LIBRARIES += libopencore_common libopencore_streaming + +include $(BUILD_SHARED_LIBRARY) +include $(PV_TOP)/modules/linux_rtsp/smplugins/unicast/registry/Android.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/makefile b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/makefile new file mode 100644 index 0000000..545b0d2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/makefile @@ -0,0 +1,22 @@ + +include $(MK)/entry_point.mk + +FORMAT := android + +include $(CFG_DIR)/../common/local.mk + +TESTAPPS="pvplayer_engine_test test_pvauthorengine pv2way_engine_test pv2way_console_app test_omx_client test_omxenc_client pvme_test" +TESTAPP_DIR_pvplayer_engine_test="/engines/player/test/build/android" +TESTAPP_DIR_test_pvauthorengine="/engines/author/test/build/android" +TESTAPP_DIR_pv2way_engine_test="/engines/2way/test/build/make" +TESTAPP_DIR_pv2way_console_app="/engines/2way/sample_app/command_line/build/make" +TESTAPP_DIR_test_omx_client="/codecs_v2/omx/omx_testapp/build/android" +TESTAPP_DIR_test_omxenc_client="/codecs_v2/omx/omx_testapp_enc/build/android" +TESTAPP_DIR_pvme_test="/engines/pvme/test/build/make" + +opencore_common_PRELINK := true +opencore_player_PRELINK := true +opencore_author_PRELINK := true + +include $(MK)/cml2_parser.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pv_config.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pv_config.h new file mode 100644 index 0000000..0854d5b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pv_config.h @@ -0,0 +1,2014 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// +// Automatically generated, don't edit +// + +// +// PV Code Base Configuration System +// + +// +// Menu for selecting supported features +// +#define module_support 1 +#define PV_HAS_SHOUTCAST_SUPPORT_ENABLED 1 + + +// +// Menu for configuring modules +// +#define pv_so 0 +#define pvplayerservice_so 0 +#define pvsplit_so 1 +#define dynamic_loading_support 1 +#define download_support 1 +#define fasttrack_download_support 0 +#define mp4local_support 1 +#define mpeg2local_support 0 +#define divxlocal_support 0 +#define rmff_support 0 +#define flvlocal_support 0 +#define asflocal_support 0 +#define playready_support 0 +#define oma1_passthru_support 1 +#define wmdrmoemsettings_support 0 +#define pvdivxoemsettings_support 0 +#define divxdrm_support 0 +#define mtp_db_support 0 +#define pvdb_config_support 0 +#define mtp_config_support 0 +#define mtp_drmmanagerplugin_support 0 +#define usb_transport_support 0 +#define dtcp_support 0 + + +// +// Menu for configuring Baselibs +// +#define csprng_lib 0 +#define pvcrypto_lib 0 +#define pventropysrc_lib 0 +#define pvgendatastruct_lib m +#define pvmediadatastruct_lib m +#define pvmimeutils_lib m +#define threadsafe_callback_ao_lib m +#define pvthreadmessaging_lib m +#define secure_data_format_lib 0 + + +// +// Menu for configuring File Formats +// +#define pvasfff_lib 0 +#define pvmp3ff_lib m +#define pvmp4ffcomposer_lib 0 +#define pvmp4ffcomposeropencore_lib m +#define pvmp4ff_lib 0 +#define pvmp4ffopencore_lib m +#define mp4recognizer_utility_lib m +#define pvaacparser_lib m +#define pvgsmamrparser_lib m +#define pvrmff_lib 0 +#define pvrmffparser_lib 0 +#define pvfileparserutils_lib m +#define pvid3parcom_lib m +#define pvpvxparser_lib m +#define pvwav_lib m +#define pvasxparser_lib 0 +#define pvavifileparser_lib 1 +#define pvpvrff_lib 0 +#define asfrecognizer_utility_lib 0 +#define pv_divxfile_parser_lib 0 +#define scsp_lib m +#define divxrecognizer_utility_lib 0 +#define pvflvff_lib 0 +#define pvrmffrecognizer_utility_lib 0 +#define flvrecognizer_utility_lib 0 +#define pvmpeg2ff_lib 0 +#define mpeg2recognizer_utility_lib 0 +#define audioparser_lib m +#define amrparser_lib m +#define wavparser_lib m + + +// +// Menu for configuring Codecs +// + +// +// Menu for configuring OMX Support +// +#define omx_mastercore_lib m +#define MAX_NUMBER_OF_OMX_CORES 10 +#define MAX_NUMBER_OF_OMX_COMPONENTS 50 +#define USE_DYNAMIC_LOAD_OMX_COMPONENTS 1 +#define pv_omx 1 +#define omx_avc_component_lib m +#define omx_common_lib m +#define omx_m4v_component_lib m +#define omx_queue_lib m +#define omx_wmv_component_lib 0 +#define omx_rv_component_lib 0 +#define pvomx_proxy_lib m +#define omx_aac_component_lib m +#define omx_amr_component_lib m +#define omx_mp3_component_lib m +#define omx_wma_component_lib 0 +#define omx_ra_component_lib 0 +#define omx_amrenc_component_lib m +#define omx_m4venc_component_lib m +#define omx_avcenc_component_lib m +#define omx_aacenc_component_lib 0 +#define omx_baseclass_lib m + + +// +// Menu for configuring audio codecs +// +#define pv_aac_dec_lib m +#define pv_aac_enc_lib 0 +#define getactualaacconfig_lib m +#define getaacaudioinfo_lib 0 +#define pv_amr_nb_common_lib m +#define pvdecoder_gsmamr_lib m +#define pvencoder_gsmamr_lib m +#define pvamrwbdecoder_lib m +#define gsm_amr_headers_lib m +#define pvmp3_lib m +#define pvra8decoder_lib 0 +#define pv_srs_wowhd_lib 0 +#define wmadecoder_lib 0 +#define useoldwmadecoder 0 +#define usepv_one_segment_broadcast 0 +#define usemultichannlefriendly 0 +#define wma_audio_support m + +// +// WMA Audio library build configurations (see build_configuration.doc) +// +#define wma_build_cfg_std 0 +#define wma_build_cfg_stdprostereolbrv1 0 +#define wma_build_cfg_stdprostereolbr 0 +#define wma_build_cfg_stdprolbr 0 +#define wma_build_cfg_lsl 0 +#define wma_build_cfg_all 1 + +#define wmavoicedecoder_lib 0 +#define wma_voice_support m +#define wma_common_hdrs_lib 0 +#define pvg726decoder_lib 0 + + +// +// Menu for configuring video codecs +// +#define pv_avc_common_lib m +#define pvavcdecoder_lib m +#define pv_avc_mp_decoder_lib 0 +#define wmvdecoder_lib 0 +#define pvmp4decoder_lib m +#define M4VDEC_FLV_SUPPORT 0 +#define rvdecoder_lib 0 +#define pvm4vencoder_lib m +#define pvavch264enc_lib m + + +// +// Menu for configuring codecs utilities +// +#define m4v_config_lib m +#define pv_config_parser_lib m +#define colorconvert_lib m + +// +// Choose the YUYV format +// +#define UY0VY1 1 +#define Y1VY0U 0 +#define Y0VY1U 0 + + +// +// choose the RGB format +// +#define CC_RGB 1 +#define CC_BGR 0 + + +#define ENABLE_UNALIGNED_MEM_ACCESS_FLAG 0 + + +// +// Menu for configuring Nodes +// + +// +// Menu for configuring Streaming Plugins +// +#define mshttp_support 0 +#define rtspunicast_support m +#define rtsptunicast_support m +#define rtsptunicastwithreal_support 0 +#define broadcastpvr_support 0 +#define rtspunicastpvr_support 0 +#define fileplaybackpvr_support 0 + + +// +// Menu for configuring Download +// +#define pvdownloadmanagernode_lib m +#define pvdtcp_mbds_lib 0 + +// +// Menu for configuring downloadmanager features +// +#define PVMF_DOWNLOADMANAGER_SUPPORT_PPB 1 +#define PVMF_MEMORYBUFFERDATASTREAM_DTCP_PPB 0 +#define PVMF_DOWNLOADMANAGER_MIN_TCP_BUFFERS_FOR_PPB 39 +#define PVMF_DOWNLOADMANAGER_CACHE_SIZE_FOR_SC_IN_SECONDS 6 +#define PVMF_DOWNLOADMANAGER_MAX_BITRATE_FOR_SC 128 + + + +// +// Menu for configuring ProtocolEngine +// +#define penode_enabled m +#define penode_pdl_support 1 +#define penode_ps_support 1 +#define penode_ftdl_support 0 +#define penode_wmhttpstreaming_support 0 +#define penode_shoutcast_support 1 +#define penode_rtmp_support 0 +#define penode_smooth_streaming_support 0 +#define penode_apple_http_streaming_support 0 + +#define pvfileoutputnode_lib m +#define pvmediaoutputnode_lib m +#define pvsocketnode_lib m +#define pvwavffparsernode_lib m +#define pvomxencnode_lib m +#define pvomxaudiodecnode_lib m +#define pvomxbasedecnode_lib m +#define pvomxvideodecnode_lib m +#define pvaacffparsernode_lib m +#define pvamrffparsernode_lib m +#define pvasfffparsernode_lib 0 +#define pvmp3ffparsernode_lib m +#define pvmp4ffparsernode_lib 0 +#define pvmp4ffparsernodeopencore_lib m +#define pvrmffparsernode_lib 0 +#define pvrtppacketsourcenode_lib 0 +#define nodes_common_headers_lib m +#define pvmediainputnode_lib m +#define pvmp4ffcomposernode_lib 0 +#define pvmp4ffcomposernodeopencore_lib m +#define pvpvr_lib 0 +#define pvpvrnode_lib 0 +#define pvcommsionode_lib m +#define pvclientserversocketnode_lib m +#define pvloopbacknode_lib m +#define pvdivxffparsernode_lib 0 +#define pvstillimagenode_lib 0 +#define g726decnode_lib 0 +#define pvflvffparsernode_lib 0 +#define pvmpeg2ffparsernode_lib 0 +#define pvcommonparsernode_lib m + + +// +// Menu for configuring Oscl +// +#define build_oscl m +#define unit_test_lib 1 +#define unit_test_utils_lib 1 + + +// +// Menu for configuring Protocols +// + +// +// Menu for configuring Value Adds for 2way +// +#define twoway_value_add_config 1 +#define PV_2WAY_VALUE_ADD_NONE 1 + +#define pv_http_parcom_lib m +#define pv_http_retriever_lib 0 +#define pvlatmpayloadparser_lib m +#define rdt_parser_lib 0 +#define pv_rtsp_parcom_lib m +#define rtppayloadparser_lib m + +// +// Menu for rtppayload parser plugins +// +#define rfc_2429 1 +#define rfc_3016 1 +#define rfc_3267 1 +#define rfc_3640 1 +#define rfc_3984 1 + +#define asf_payload_lib 0 +#define realmedia_payload_lib 0 +#define rtprtcp_lib m +#define pv324m_lib m +#define pv_rtmp_parcom_lib 0 +#define pv_smooth_streaming_lib 0 +#define pv324m_common_headers_lib m +#define pvgeneraltools_lib m +#define pv_m3u_parser_lib 0 + + +// +// Menu for configuring Pvmi +// + +// +// Menu for configuring Recognizers +// +#define pvmfrecognizer_lib m +#define pvaacffrecognizer_lib m +#define pvamrffrecognizer_lib m +#define pvoma1ffrecognizer_lib 0 +#define pvasfffrecognizer_lib 0 +#define pvmp3ffrecognizer_lib m +#define pvmp4ffrecognizer_lib m +#define pvmpeg2ffrecognizer_lib 0 +#define pvwavffrecognizer_lib m +#define pvrmffrecognizer_lib 0 +#define pvdivxffrecognizer_lib 0 +#define pvplsffrecognizer_lib m +#define pvflvffrecognizer_lib 0 + + +// +// Menu for configuring Content Policy Manager +// +#define cpm_lib m +#define oma1_passthru_plugin_lib m +#define cpm_headers_lib m +#define pvoma1lockstream_lib 0 +#define pvplayreadyplugin_lib 0 +#define pvdivxdrmplugin_lib 0 +#define pvdtcpplugin_lib 0 + + +// +// Menu for configuring Media IO +// +#define pvmiofileinput_lib m +#define pvmiofileoutput_lib m +#define pvmioaviwavfileinput_lib 1 +#define pvmio_comm_loopback_lib m +#define pvaudiotrackmio_lib 0 + + +// +// Menu for configuring PacketSources +// +#define packetsources_default_lib 0 + +// +// Menu for configuring PacketSource Plugins +// +#define optimized_bcast_ps_support 0 +#define standard_bcast_ps_support 0 + + +#define pvmf_lib m +#define realaudio_deinterleaver_lib 0 +#define pvdbmanager_lib 0 +#define pvdb_recovery_utility_lib 0 + + +// +// Menu for configuring Engines +// + +// +// Menu for configuring Player +// +#define pvplayer_engine_lib m + +// +// Menu for player engine tunables +// +#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_EARLY_DEF -10 +#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_LATE_DEF 50 +#define VIDEO_DEC_NODE_LOW_PRIORITY 1 +#define PVPLAYERENGINE_SUPPORT_DTCP 1 + + +// +// Menu for configuring player registry +// +#define BUILD_OMX_VIDEO_DEC_NODE 1 +#define BUILD_OMX_AUDIO_DEC_NODE 1 +#define BUILD_G726_DEC_NODE 0 +#define BUILD_MP4_FF_PARSER_NODE 0 +#define BUILD_MPEG2_FF_PARSER_NODE 0 +#define BUILD_AMR_FF_PARSER_NODE 0 +#define BUILD_AAC_FF_PARSER_NODE 1 +#define BUILD_MP3_FF_PARSER_NODE 1 +#define BUILD_WAV_FF_PARSER_NODE 0 +#define BUILD_ASF_FF_PARSER_NODE 0 +#define BUILD_RM_FF_PARSER_NODE 0 +#define BUILD_STREAMING_MANAGER_NODE 0 +#define BUILD_DOWNLOAD_MANAGER_NODE 0 +#define BUILD_STILL_IMAGE_NODE 0 +#define BUILD_MP4_FF_REC 0 +#define BUILD_MPEG2_FF_REC 0 +#define BUILD_ASF_FF_REC 0 +#define BUILD_OMA1_FF_REC 0 +#define BUILD_AAC_FF_REC 1 +#define BUILD_RM_FF_REC 0 +#define BUILD_MP3_FF_REC 1 +#define BUILD_WAV_FF_REC 1 +#define BUILD_AMR_FF_REC 1 +#define BUILD_DIVX_FF_PARSER_NODE 0 +#define BUILD_DIVX_FF_REC 0 +#define BUILD_PLS_FF_REC 1 +#define BUILD_FLV_FF_PARSER_NODE 0 +#define BUILD_FLV_FF_REC 0 +#define BUILD_COMMON_PARSER_NODE 1 + + + +// +// Menu for configuring Author +// +#define pvauthorengine_lib m + + +// +// Menu for configuring pv2way +// +#define pv2wayengine_lib m +#define pv2waysample_lib m + +#define engines_common_headers_lib m +#define pvframemetadatautility_lib m +#define pvmetadata_engine_lib m +#define pvplayreadyutility_lib 0 +#define pvmp4eu_lib 0 + + +// +// Menu for configuring Extern_libs +// +#define pvmtp_engine_lib 0 +#define pvmtpip_engine_lib 0 +#define pviptransport_lib 0 +#define pvsqlite_lib 0 + +// +// Menu for configuring PlayReady wmdrm +// +#define pvwmdrmmd_lib 0 + +#define pvtinyxml_lib 0 +#define pvdivxdrm_lib 0 +#define pvdivxdrm_oem_settings_lib 0 + + +// +// That's all, folks! +// +// Derived symbols +// +#define pvfasttrack_download_link_type "loaded" +#define MODS_pvrtspunicast_streaming "-lopencore_net_support -lopencore_player -lopencore_common -lopencore_rtsp -lopencore_streaming" +#define pvtinyxml_m_lib "" +#define protocolenginenode_shoutcast_lib "-lprotocolenginenode_shoutcast" +#define pvstillimagenode_y_mk "" +#define pvmedialayernode_m_mk "" +#define pvpvr_y_mk "" +#define LIBDIR_engines_shared "/engines/player/build/make /engines/author/build/make /engines/2way/build/make /engines/2way/sample_app/pv2waysample/build/make /engines/common/build/make /engines/adapters/player/framemetadatautility/build/make /engines/pvme/build/make " +#define LIBDIR_oscl_static " /oscl/unit_test/build/make /oscl/unit_test_utils/build/make" +#define pvsqlite_aggregate_libtype "static" +#define opencore_author_aggregate_libtype "shared" +#define pvrmffparser_m_lib "" +#define pvm4vencoder_m_mk "/codecs_v2/video/m4v_h263/enc/build/make" +#define pvrtsptunicastforrm_streamingreg_aggregate_libtype "static" +#define pvframemetadatautility_m_mk "/engines/adapters/player/framemetadatautility/build/make" +#define pvmf_m_mk "/pvmi/pvmf/build/make" +#define pvrtsp_cli_eng_real_cloaking_node_y_mk "" +#define opencore_downloadreg_so_name "opencore_downloadreg" +#define pvasflocalpb_link_type "loaded" +#define LIBS_codecs_v2_static " " +#define pvmp3ffrecognizer_m_lib "-lpvmp3ffrecognizer" +#define pvmediainputnode_m_lib "-lpvmediainputnode" +#define pvmp4ff_m_mk "" +#define pvmshttpfsp_m_mk "" +#define pvrtsptunicast_streaming_so_name "pvrtsptunicast_streaming" +#define pvavifileparser_y_mk "/fileformats/avi/parser/build/make" +#define pvprotocolenginenode_wmhttpstreaming_plugin_m_lib "" +#define pvasflocalpbreg_so_name "" +#define pvasflocalpb_aggregate_libtype "static" +#define pv_avc_common_lib_y_mk "" +#define pvavcdecoder_m_mk "/codecs_v2/video/avc_h264/dec/build/make" +#define LIBDIR_extern_libs_shared " " +#define opencore_streamingreg_so_name "opencore_streamingreg" +#define wmadecoder_m_lib "" +#define pv_amr_nb_common_lib_y_lib "" +#define AGGREGATE_LIBDIRS_pvrmff_recognizer " " +#define pvmpeg2interface_m_lib "" +#define cpm_m_mk "/pvmi/content_policy_manager/build/make" +#define pvpvrcommonimp_y_mk "" +#define pvcommonparsernode_m_mk "/nodes/pvcommonparsernode/build/make" +#define pviptransport_aggregate_libtype "static" +#define pvmtp_engine_m_mk "" +#define realaudio_deinterleaver_y_lib "" +#define MODS_pvfasttrack_downloadreg "-lopencore_common -lopencore_net_support" +#define omx_amr_component_imp_m_lib "" +#define pvframemetadatautility_y_mk "" +#define WMA_BUILD_CFG_ALL_ENABLED 1 +#define sdp_common_m_mk "/protocols/sdp/common/build/make" +#define pvavcdecoder_m_lib "-lpvavcdecoder" +#define pvrtspbroadcastwithpvr_streaming_aggregate_libtype "static" +#define pviptransport_y_lib "" +#define pvdtcpplugin_m_mk "" +#define pvsdpparser_y_lib "" +#define pvrtspunicastfsp_m_mk "/nodes/streaming/streamingmanager/plugins/rtspunicast/build/make" +#define pvrfileplaybackpluginregpopulator_m_mk "" +#define pvasfcommon_aggregate_libtype "static" +#define pvmpeg2ffrecognizer_y_lib "" +#define pvrtsp_cli_eng_real_cloaking_node_m_lib "" +#define mpeg2recognizer_utility_y_mk "" +#define pvmp4ffcomposer_y_lib "" +#define MODS_pvdivxoemsettings "-lopencore_common" +#define pvdecoder_gsmamr_m_mk "/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make" +#define pvrtppacketsourcenode_y_lib "" +#define gsm_amr_headers_m_mk "/codecs_v2/audio/gsm_amr/common/dec/build/make" +#define pvrtspunicastfsp_m_lib "-lpvrtspunicaststreamingmanager" +#define pvmetadata_engine_m_lib "-lpvmetadata_engine" +#define pvasfcommon_so_name "" +#define pvmp3ffrecognizer_y_mk "" +#define WMA_BUILD_CFG_STDPROLBR_ENABLED 0 +#define pvwmdrmoemsettingsinterface_m_mk "" +#define LIBDIR_pvmi_shared "/pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make /pvmi/content_policy_manager/plugins/common/build/make /pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmio_comm_loopback/build/make /pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /pvmi/recognizer/plugins/pvplsffrecognizer/build/make /pvmi/pvmf/build/make " +#define csprng_y_mk "" +#define pvdivxffparsernode_y_lib "" +#define pv_rtmp_parcom_y_lib "" +#define AGGREGATE_LIBDIRS_pvrtsptunicast_streamingreg "/modules/linux_rtsp/smplugins/tunneling/registry/build/make" +#define pvprotocolenginenode_ftdl_plugin_m_lib "" +#define rdt_parser_y_lib "" +#define MODS_pvrtspbroadcastwithpvr_streaming "-lopencore_net_support -lopencore_player -lopencore_common -lpvpvrcommonimpl_streaming -lopencore_rtsp -lopencore_streaming" +#define pvmp4ff_y_lib "" +#define pvamrffparsernode_y_mk "" +#define pvmshttpfsp_y_mk "" +#define amrparser_y_mk "" +#define LIBS_omxenc_static " " +#define pvstreamingmanagernode_y_mk "" +#define smmshttpplugininterface_m_lib "" +#define MODS_pvdb "-lopencore_player -lopencore_common -lpvsqlite -lpvasfcommon -lpvasflocalpbreg -lopencore_pvme" +#define DYNAMIC_LOAD_OMX_WMV_COMPONENT 0 +#define pvrtsptunicast_streaming_aggregate_libtype "shared" +#define pvmtp_usb_transport_m_lib "" +#define MODS_pvdivxdrm "-lopencore_common" +#define pv_aac_enc_y_mk "" +#define opencore_mp4local_link_type "loaded" +#define pvjitterbufferasf_y_mk "" +#define pvrrtspunicastplugininterface_m_lib "" +#define AGGREGATE_LIBDIRS_pvasflocalpb " " +#define pvomxbasedecnode_y_mk "" +#define nodes_common_headers_y_mk "" +#define omx_wmvdec_sharedlibrary_link_type "loaded" +#define pvbroadcastwithpvrfsp_y_lib "" +#define pvflvparser_node_so_name "" +#define pvaudiotrackmio_m_mk "" +#define MODS_omx_mp3dec_sharedlibrary "-lomx_sharedlibrary -lopencore_common" +#define pvplayer_engine_y_lib "" +#define pvcommonparsernode_m_lib "-lpvcommonparsernode" +#define pvrtsp_cli_eng_node_m_mk "/protocols/rtsp_client_engine/build/make_segments" +#define standard_bcast_ps_mk "" +#define pv2waysample_m_mk "/engines/2way/sample_app/pv2waysample/build/make" +#define pvid3parcom_y_lib "" +#define twoway_config "2way_basic" +#define pv324m_y_mk "" +#define pvmp4ffrecognizer_y_mk "" +#define pvsmreginterface_m_mk "/modules/linux_rtsp/node_registry/build/make" +#define LIBDIR_omxencimp_shared "" +#define pvflvparser_node_aggregate_libtype "static" +#define smrtsptpluginregpopulator_m_lib "-lpvrtsptsmpluginreginterface" +#define pvmshttp_streamingreg_aggregate_libtype "static" +#define pvdownloadinterface_m_mk "/modules/linux_download/core/build/make" +#define pvoma1passthruplugin_y_lib "" +#define pvthreadmessaging_y_mk "" +#define AGGREGATE_LIBDIRS_pvrtspbroadcastwithpvr_streamingreg "" +#define pvmfrecognizer_m_mk "/pvmi/recognizer/build/make" +#define AGGREGATE_LIBDIRS_pvdb "" +#define LIBS_omxdecimp_shared "" +#define pvmtpconfigclass_aggregate_libtype "static" +#define omx_aacenc_component_m_lib "" +#define pvjitterbufferasf_y_lib "" +#define pvrtspunicastwithpvr_streaming_aggregate_libtype "static" +#define pvjitterbuffercommon_y_lib "" +#define AGGREGATE_LIBDIRS_opencore_download "/nodes/pvdownloadmanagernode/build/make /modules/linux_download/core/build/make" +#define pvmedialayernode_m_lib "" +#define pvclientserversocketnode_y_mk "" +#define pvdownloadmanagernode_y_lib "" +#define opencore_common_link_type "linked" +#define pvmshttpfsp_y_lib "" +#define omx_amr_component_imp_m_mk "" +#define pvgeneraltools_y_lib "" +#define pv_avc_common_imp_lib_m_lib "" +#define pvdivxffrecognizer_y_mk "" +#define pvdbmanager_m_mk "" +#define penode_any_selected 1 +#define wavparser_y_mk "" +#define USE_LOADABLE_MODULES 1 +#define pviptransport_m_lib "" +#define pvrmffparser_m_mk "" +#define protocolenginenode_asfstreaming_mk "" +#define pvdb_aggregate_libtype "static" +#define pvrmff_y_mk "" +#define pvmp4ffcomposernode_y_mk "" +#define pvgendatastruct_m_mk "/baselibs/gen_data_structures/build/make" +#define pv_aac_dec_m_lib "-lpv_aac_dec" +#define pvsocketnode_y_mk "" +#define DYNAMIC_LOAD_OMX_RV_COMPONENT 0 +#define MODS_pvasflocalpb "-lopencore_player -lopencore_common -lpvasfcommon" +#define pv_config_parser_m_mk "/codecs_v2/utilities/pv_config_parser/build/make" +#define pv_amr_nb_common_imp_lib_m_lib "" +#define pvwmdrmoemsettings_so_name "" +#define pvpvrcommonimpl_streaming_aggregate_libtype "static" +#define AGGREGATE_LIBDIRS_omx_m4vdec_sharedlibrary "/codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/video/m4v_h263/dec/build/make" +#define pvmimeutils_m_lib "-lpvmimeutils" +#define pv_rtmp_parcom_m_mk "" +#define AGGREGATE_LIBDIRS_opencore_downloadreg "/modules/linux_download/node_registry/build/make" +#define download_common_enabled 1 +#define AGGREGATE_LIBDIRS_opencore_mp4localreg "/modules/linux_mp4/node_registry/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make" +#define pvthreadmessaging_m_lib "-lpvthreadmessaging" +#define pvrtspunicastwithpvrfsp_y_mk "" +#define pvmiofileinput_m_lib "-lpvmiofileinput" +#define mpeg2recognizer_utility_y_lib "" +#define omx_avcenc_sharedlibrary_so_name "omx_avcenc_sharedlibrary" +#define pvwmdrmmd_m_mk "" +#define rtppayloadparser_plugins_opencore_rtsp "rfc_2429.mk rfc_3016.mk rfc_3267.mk rfc_3640.mk rfc_3984.mk" +#define omx_common_y_lib "" +#define pvpvrff_m_mk "" +#define pvpvrnode_m_mk "" +#define gsm_amr_headers_y_mk "" +#define AGGREGATE_LIBDIRS_pvmp4eu " " +#define pvmp3_imp_m_lib "" +#define LIBDIR_cpm_shared "/pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make /pvmi/content_policy_manager/plugins/common/build/make " +#define threadsafe_callback_ao_y_mk "" +#define MODS_opencore_pvme "-lopencore_player -lopencore_common" +#define WMA_BUILD_CFG_STDPROSTEREOLBR_ENABLED 0 +#define csprng_y_lib "" +#define LIBS_oscl_shared "-loscllib -lpvlogger -losclregcli -losclregserv -losclutil -losclproc -losclio -losclmemory -losclerror -losclbase " +#define pvframemetadatautility_m_lib "-lpvframemetadatautility" +#define omx_mastercore_y_lib "" +#define pvmfrecognizer_y_lib "" +#define rtppayloadparser_m_mk "/protocols/rtp_payload_parser/build/make" +#define flvrecognizer_utility_y_lib "" +#define pvjitterbuffercommon_m_mk "/nodes/streaming/jitterbuffernode/jitterbuffer/common/build/make" +#define pvsdpparser_m_lib "" +#define pvflvreginterface_m_mk "" +#define rtprtcp_m_mk "/protocols/rtp/build/make" +#define pvstillimagenode_m_lib "" +#define BUILD_FASTTRACK_DOWNLOAD_PLUGIN 0 +#define pvg726decoder_y_lib "" +#define MODS_omx_amrdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common" +#define csprng_m_mk "" +#define LIBS_video_static " " +#define opencore_common_aggregate_libtype "shared" +#define omx_avc_component_y_mk "" +#define pvdbmanager_y_lib "" +#define pvasxparser_m_lib "" +#define threadsafe_callback_ao_m_mk "/baselibs/threadsafe_callback_ao/build/make" +#define BUILD_STATIC_RTSPT 0 +#define pv_srs_wowhd_m_mk "" +#define pvdivxdrm_m_lib "" +#define pvamrffparsernode_m_lib "-lpvamrffparsernode" +#define pvflvinterface_m_lib "" +#define pvprotocolengine_asfstreamingreg_aggregate_libtype "static" +#define pvmp4ffcomposer_y_mk "" +#define LIBS_nodes_shared "-lpvfileoutputnode -lpvmediaoutputnode -lpvsocketnode -lprotocolenginenode_base -lprotocolenginenode_common -lprotocolenginenode_download_common -lprotocolenginenode_pdl -lprotocolenginenode_ps -lprotocolenginenode_shoutcast -lpvwavffparsernode -lpvomxencnode -lpvomxbasedecnode -lpvomxaudiodecnode -lpvomxvideodecnode -lpvaacffparsernode -lpvamrffparsernode -lpvmp3ffparsernode -lpvmp4ffparsernode -lpvmediainputnode -lpvmp4ffcomposernode -lpvdownloadmanagernode -lpvrtspunicaststreamingmanager -lpvrtsptunicaststreamingmanager -lpvsmfspcommon -lpvstreamingmanagernode -lpvrtspsmplugininterface -lpvrtspsmpluginreginterface -lpvrtsptsmplugininterface -lpvrtsptsmpluginreginterface -lpvjitterbuffer -lpvjitterbufferrtp -lpvjitterbuffernode -lpvcommsionode -lpvclientserversocketnode -lpvloopbacknode -lpvcommonparsernode" +#define pvloopbacknode_m_mk "/nodes/pvloopbacknode/build/make" +#define pvjitterbuffernode_m_mk "/nodes/streaming/jitterbuffernode/build/make" +#define pvmio_comm_loopback_y_lib "" +#define AGGREGATE_LIBDIRS_omx_amrenc_sharedlibrary "/codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make" +#define omx_aac_component_y_mk "" +#define omx_ra_component_y_mk "" +#define pvavcdecoder_y_lib "" +#define pvdb_recovery_utility_y_mk "" +#define pv_rtsp_parcom_m_lib "-lpv_rtsp_parcom" +#define pvrtsptunicastfsp_m_mk "/nodes/streaming/streamingmanager/plugins/rtsptunicast/build/make" +#define pventropysrc_m_mk "" +#define pvra8decoder_imp_m_lib "" +#define smrtspunicastpluginregpopulator_m_mk "/modules/linux_rtsp/smplugins/unicast/registry/build/make" +#define AGGREGATE_LIBDIRS_pvasflocalpbreg " " +#define pvdecoder_gsmamr_y_lib "" +#define omx_amrdec_sharedlibrary_so_name "omx_amrdec_sharedlibrary" +#define pvoma1lockstream_m_mk "" +#define pvmpeg2interface_m_mk "" +#define pv_amr_nb_common_lib_y_mk "" +#define cpm_headers_m_mk "/pvmi/content_policy_manager/plugins/common/build/make" +#define pvmp4ffrecognizer_m_mk "/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make" +#define pvrtsp_cli_eng_node_y_mk "" +#define pvmioaviwavfileinput_y_mk "/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make" +#define pvmp3_y_mk "" +#define pvasflocalpb_so_name "" +#define pvmp4decoder_y_lib "" +#define pv324m_m_mk "/protocols/systems/3g-324m_pvterminal/build/make/" +#define omx_mp3_component_y_lib "" +#define oscl_y_mk "" +#define pv_http_parcom_y_mk "" +#define LIBS_shared "-loscllib -lpvlogger -losclregcli -losclregserv -losclutil -losclproc -losclio -losclmemory -losclerror -losclbase -lpvgendatastruct -lpvmediadatastruct -lpvmimeutils -lthreadsafe_callback_ao -lpvthreadmessaging -lomx_avc_component_lib -lomx_m4v_component_lib -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib -lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib -lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3 -lpvencoder_gsmamr -lpv_avc_common_lib -lpvavcdecoder -lpvmp4decoder -lpvm4vencoder -lpvavch264enc -lm4v_config -lpv_config_parser -lcolorconvert -lpvfileparserutils -lpvid3parcom -lpvpvxparser -lpvwav -lpvmp3ff -lpvaacparser -lpvgsmamrparser -lmp4recognizer_utility -lpvmp4ff -lpvmp4ffcomposer -lscsp -laudioparser -lamrparser -lwavparser -lpv_http_parcom -lpvlatmpayloadparser -lpvsdpparser -lpv_rtsp_parcom -lpvrtsp_cli_eng_node -lrtppayloadparser -lrtprtcp -lpv324m -lpvgeneraltools -lcpm -lpvoma1passthruplugin -lpvmiofileoutput -lpvmiofileinput -lpvmio_comm_loopback -lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer -lpvplsffrecognizer -lpvmf -lpvfileoutputnode -lpvmediaoutputnode -lpvsocketnode -lprotocolenginenode_base -lprotocolenginenode_common -lprotocolenginenode_download_common -lprotocolenginenode_pdl -lprotocolenginenode_ps -lprotocolenginenode_shoutcast -lpvwavffparsernode -lpvomxencnode -lpvomxbasedecnode -lpvomxaudiodecnode -lpvomxvideodecnode -lpvaacffparsernode -lpvamrffparsernode -lpvmp3ffparsernode -lpvmp4ffparsernode -lpvmediainputnode -lpvmp4ffcomposernode -lpvdownloadmanagernode -lpvrtspunicaststreamingmanager -lpvrtsptunicaststreamingmanager -lpvsmfspcommon -lpvstreamingmanagernode -lpvrtspsmplugininterface -lpvrtspsmpluginreginterface -lpvrtsptsmplugininterface -lpvrtsptsmpluginreginterface -lpvjitterbuffer -lpvjitterbufferrtp -lpvjitterbuffernode -lpvcommsionode -lpvclientserversocketnode -lpvloopbacknode -lpvcommonparsernode -lpvplayer_engine -lpvauthorengine -lpv2wayengine -lpv2waysample -lpvframemetadatautility -lpvmetadata_engine -lpvsminterface -lpvsmreginterface -lpvrtspsmplugininterface -lpvrtspsmpluginreginterface -lpvrtsptsmplugininterface -lpvrtsptsmpluginreginterface -lpvdownloadinterface -lpvdownloadreginterface -lpvmp4interface -lpvmp4reginterface -lpvoma1passthruplugininterface " +#define pvmp4eu_aggregate_libtype "static" +#define rtppayloadparser_plugins "rfc_2429.mk rfc_3016.mk rfc_3267.mk rfc_3640.mk rfc_3984.mk" +#define omx_aacenc_component_y_mk "" +#define pvsdpparser_y_mk "" +#define pvfileoutputnode_y_lib "" +#define AGGREGATE_LIBDIRS_pvfileplaybackwithpvr_streamingreg "" +#define pvamrwbdecoder_imp_m_mk "" +#define pvmf_y_mk "" +#define pvwavffrecognizer_y_mk "" +#define pvtinyxml_m_mk "" +#define LIBS_protocols_shared "-lpv_http_parcom -lpvlatmpayloadparser -lpvsdpparser -lpv_rtsp_parcom -lpvrtsp_cli_eng_node -lrtppayloadparser -lrtprtcp -lpv324m -lpvgeneraltools " +#define DYNAMIC_LOAD_OMX_WMA_COMPONENT 0 +#define realaudio_deinterleaver_y_mk "" +#define pvjitterbufferrtp_y_mk "" +#define pvomxencnode_m_mk "/nodes/pvomxencnode/build/make" +#define pv_rtmp_parcom_m_lib "" +#define pvfileparserutils_m_mk "/fileformats/common/parser/build/make" +#define pvoma1passthru_aggregate_libtype "shared" +#define pvrtspunicast_streamingreg_aggregate_libtype "shared" +#define secure_data_format_m_lib "" +#define pvcommsionode_y_mk "" +#define pvmp4ffcomposeropencore_m_lib "-lpvmp4ffcomposer" +#define nodes_common_headers_m_mk "/nodes/common/build/make" +#define omx_avc_component_imp_m_lib "" +#define wmavoicedecoder_imp_m_mk "" +#define pvoma1lockstream_y_lib "" +#define LIBDIR_protocols_shared "/protocols/http_parcom/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make /protocols/rtsp_parcom/build/make /protocols/rtsp_client_engine/build/make_segments /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make " +#define pvdivxdrmplugin_y_mk "" +#define pvmfrecognizer_m_lib "-lpvmfrecognizer" +#define pvencoder_gsmamr_y_mk "" +#define pvoma1ffrecognizer_y_lib "" +#define wmadecoder_m_mk "" +#define AGGREGATE_LIBDIRS_pvmpeg2localreg " " +#define omx_rv_component_m_lib "" +#define wmvdecoder_y_lib "" +#define pvpvr_m_mk "" +#define pvrtsptwithrealfsp_y_lib "" +#define pvomx_proxy_m_lib "-lpvomx_proxy_lib" +#define omx_wma_component_m_mk "" +#define pvrtsptwithrealfsp_m_mk "" +#define wmavoicedecoder_m_lib "" +#define pvdivxdrm_oem_settings_m_mk "" +#define pv_avc_mp_decoder_imp_m_mk "" +#define pvmp3_imp_m_mk "" +#define secure_data_format_m_mk "" +#define rfc_3984_mk "rfc_3984.mk" +#define pvpvr_y_lib "" +#define pv2wayengine_y_lib "" +#define omx_aacenc_component_imp_m_lib "" +#define pv_aac_enc_m_lib "" +#define pvdivxdrm_y_mk "" +#define REGISTER_OMX_AAC_COMPONENT 1 +#define pvwavffparsernode_m_lib "-lpvwavffparsernode" +#define AGGREGATE_LIBDIRS_pvdivxoemsettings "" +#define rtppayloadparser_m_lib "-lrtppayloadparser" +#define DYNAMIC_LOAD_OMX_M4V_COMPONENT 1 +#define MODS_omx_avcenc_sharedlibrary "-lomx_sharedlibrary -lopencore_common " +#define pvaacparser_m_mk "/fileformats/rawaac/parser/build/make" +#define pvgsmamrparser_y_mk "" +#define opencore_download_link_type "loaded" +#define pvfileplaybackwithpvrfsp_y_lib "" +#define pvdivxdrm_oem_settings_m_lib "" +#define pvavcdecoder_imp_m_lib "" +#define pvmediadatastruct_y_lib "" +#define pvmshttp_streaming_link_type "loaded" +#define pvmpeg2ff_m_lib "" +#define LIBDIR_codecs_v2_static " " +#define pvstillimagenode_m_mk "" +#define MODS_omx_m4vdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common " +#define AGGREGATE_LIBDIRS_omx_m4venc_sharedlibrary "/codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/video/m4v_h263/enc/build/make" +#define pvmp4ff_m_lib "" +#define rvdecoder_y_lib "" +#define pvbroadcastwithpvrfsp_y_mk "" +#define getaacaudioinfo_y_mk "" +#define pvauthorengine_y_mk "" +#define pvasflocalpbreg_link_type "loaded" +#define omx_avc_component_y_lib "" +#define omx_m4vdec_sharedlibrary_link_type "loaded" +#define pvplayreadyplugin_y_mk "" +#define pvmiofileoutput_m_lib "-lpvmiofileoutput" +#define pvmediadatastruct_m_lib "-lpvmediadatastruct" +#define MODS_pvwmdrmoemsettings "-lopencore_common" +#define opencore_downloadreg_link_type "loaded" +#define flvrecognizer_utility_m_mk "" +#define AGGREGATE_LIBDIRS_pvrtspbroadcastwithpvr_streaming " " +#define MODS_pvmpeg2localreg "-lopencore_player -lopencore_common" +#define pvprotocolenginewmhttpstreaminginterface_m_lib "" +#define unit_test_utils_m_mk "" +#define omx_rvdec_sharedlibrary_aggregate_libtype "static" +#define pvrtppacketsourcenode_y_mk "" +#define wmavoicedecoder_y_lib "" +#define pvbroadcastwithpvrfsp_m_lib "" +#define opencore_download_so_name "opencore_download" +#define omx_avc_component_m_lib "-lomx_avc_component_lib" +#define pvaacffparsernode_y_mk "" +#define pvmp3ffparsernode_m_lib "-lpvmp3ffparsernode" +#define USING_OMX 1 +#define wmvdecoder_m_lib "" +#define pvdtcp_mbds_so_m_mk "" +#define BUILD_APPLE_HTTP_STREAMING_PLUGIN 0 +#define mp4recognizer_utility_y_mk "" +#define REGISTER_OMX_H263_COMPONENT 1 +#define pvmp4reginterface_m_lib "-lpvmp4reginterface" +#define pv324m_m_lib "-lpv324m" +#define pvpvrnode_y_lib "" +#define pvpvrff_y_lib "" +#define pvrtsptunicast_streamingreg_link_type "loaded" +#define pvmp4eu_y_lib "" +#define getactualaacconfig_imp_m_mk "/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make" +#define pv2wayengine_m_mk "/engines/2way/build/make" +#define rvdecoder_imp_m_lib "" +#define getactualaacconfig_for_static_m_mk "" +#define sdp_parser_mksegment_default "" +#define omx_wmv_component_y_mk "" +#define LIBS_video_shared "-lpv_avc_common_lib -lpvavcdecoder -lpvmp4decoder -lpvm4vencoder -lpvavch264enc" +#define pvmiofileinput_y_mk "" +#define pvplayreadyplugin_m_lib "" +#define omx_queue_y_mk "" +#define pvpvrcommonimp_m_mk "" +#define pvfileplaybackwithpvrfsp_m_mk "" +#define DYNAMIC_LOAD_OMX_AMRENC_COMPONENT 1 +#define omx_wma_component_imp_m_mk "" +#define pvflvff_y_mk "" +#define opencore_mp4local_so_name "opencore_mp4local" +#define pvwmdrmmd_aggregate_libtype "static" +#define omx_amrdec_sharedlibrary_link_type "loaded" +#define AGGREGATE_LIBDIRS_pvrtspunicast_streaming "/nodes/streaming/streamingmanager/plugins/rtspunicast/build/make /modules/linux_rtsp/smplugins/unicast/core/build/make" +#define MODS_pvsqlite "-lopencore_common" +#define omx_wma_component_m_lib "" +#define pv_avc_mp_decoder_y_mk "" +#define MODS_pvmtp "-lopencore_common -lpvdb" +#define pvgendatastruct_m_lib "-lpvgendatastruct" +#define pvjitterbuffercommon_y_mk "" +#define BUILD_STATIC_RTSPT_REALMEDIA 0 +#define audioparser_y_lib "" +#define LIBS_omxenc_shared "-lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib " +#define pvjitterbuffernode_y_mk "" +#define MODS_pvdivx_recognizer "-lopencore_common" +#define pvencoder_gsmamr_y_lib "" +#define smrtsptrmpluginregpopulator_m_mk "" +#define omx_amrenc_component_m_mk "/codecs_v2/omx/omx_amrenc/build/make_multithreaded" +#define pvprotocolenginewmhttpstreamingpluginreginterface_m_lib "" +#define sdp_parser_mksegment_opencore "sdp_opencore.mk" +#define scsp_m_lib "-lscsp" +#define BUILD_STATIC_RTSP_UNICAST_PVR 0 +#define smmshttpplugininterface_m_mk "" +#define getaacaudioinfo_y_lib "" +#define pvauthorengine_y_lib "" +#define AGGREGATE_LIBDIRS_omx_rvdec_sharedlibrary " " +#define omx_amrenc_component_m_lib "-lomx_amrenc_component_lib" +#define pvfileparserutils_y_mk "" +#define AGGREGATE_LIBDIRS_opencore_streaming "/nodes/streaming/streamingmanager/build/make /nodes/streaming/streamingmanager/plugins/common/build/make /modules/linux_rtsp/core/build/make" +#define pv_aac_dec_y_mk "" +#define pvmimeutils_y_lib "" +#define pvrtsp_cli_eng_playlist_node_y_mk "" +#define AGGREGATE_LIBDIRS_pvdtcp_mbds " " +#define g726decnode_m_mk "" +#define pvdtcp_mbds_m_mk "" +#define mp4recognizer_utility_m_lib "-lmp4recognizer_utility" +#define MODS_opencore_download "-lopencore_net_support -lopencore_player -lopencore_common" +#define pvoma1passthru_link_type "loaded" +#define pvrtspunicast_streamingreg_so_name "pvrtspunicast_streamingreg" +#define pv_divxfile_parser_y_lib "" +#define omx_avcenc_component_m_lib "-lomx_avcenc_component_lib" +#define omx_m4v_component_y_lib "" +#define MODS_opencore_mp4localreg "-lopencore_player -lopencore_common" +#define AGGREGATE_LIBDIRS_pvrtsptunicastforrm_streaming " " +#define pvomxbasedecnode_m_lib "-lpvomxbasedecnode" +#define pvmpeg2reginterface_m_lib "" +#define AGGREGATE_LIBDIRS_pvmtpip "" +#define m4v_config_m_mk "/codecs_v2/utilities/m4v_config_parser/build/make" +#define pvdivxreginterface_m_lib "" +#define pvrtspunicastwithpvrfsp_m_mk "" +#define asfrecognizer_utility_y_mk "" +#define LIBDIR_codecs_v2_shared "/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make /codecs_v2/video/m4v_h263/dec/build/make /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make" +#define MODS_opencore_player "-lopencore_common -lopencore_net_support" +#define omx_amrenc_component_imp_m_mk "" +#define pvdecoder_gsmamr_m_lib "-lpvdecoder_gsmamr" +#define pvfileoutputnode_y_mk "" +#define wavparser_m_lib "-lwavparser" +#define pvmp4ffcomposeropencore_m_mk "/fileformats/mp4/composer/build_opencore/make" +#define pvrtsp_cli_eng_playlist_node_y_lib "" +#define MODS_pvprotocolengine_asfstreamingreg "-lopencore_common -lopencore_net_support" +#define pvtinyxml_y_lib "" +#define pvamrffrecognizer_y_mk "" +#define pventropysrc_m_lib "" +#define smrtspunicastplugininterface_m_lib "-lpvrtspsmplugininterface" +#define LIBDIR_baselibs_shared " /baselibs/gen_data_structures/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/thread_messaging/build/make " +#define AGGREGATE_LIBDIRS_pvdbconfigclass "" +#define pvaacffrecognizer_y_lib "" +#define LIBS_omxencimp_shared "" +#define MODS_pvwmdrmmd "-lopencore_common" +#define pvdivxffrecognizer_m_lib "" +#define omx_avc_component_lib_plugins "omx_avc_dec_plugin.mk" +#define pvmp4ffopencore_m_lib "-lpvmp4ff" +#define pvprotocolenginefasttrackdownloadpluginreginterface_m_lib "" +#define sdp_common_y_mk "" +#define AGGREGATE_LIBDIRS_opencore_2way "/engines/2way/sample_app/pv2waysample/build/make /engines/2way/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /nodes/pvclientserversocketnode/build/make /nodes/pvcommsionode/build/make /pvmi/media_io/pvmio_comm_loopback/build/make /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make " +#define omx_amrenc_sharedlibrary_link_type "loaded" +#define pvmtpip_so_name "" +#define pvavifileparser_m_mk "" +#define pvrtsp_cli_eng_real_cloaking_node_y_lib "" +#define pvaacparser_y_mk "" +#define LIBS_extern_libs_shared " " +#define MODS_pvfileplaybackwithpvr_streaming "-lopencore_net_support -lopencore_player -lopencore_common -lpvpvrcommonimpl_streaming -lopencore_rtsp -lopencore_streaming" +#define getactualaacconfig_m_mk "/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make" +#define pvmp3ff_y_mk "" +#define pv_aac_dec_imp_m_lib "" +#define rfc_3016_mk "rfc_3016.mk" +#define pvasxparser_y_lib "" +#define pvmimeutils_y_mk "" +#define pvwavffrecognizer_m_lib "-lpvwavffrecognizer" +#define pvrtsp_cli_eng_node_y_lib "" +#define pvencoder_gsmamr_imp_m_lib "" +#define smrtsptplugininterface_m_lib "-lpvrtsptsmplugininterface" +#define pvdtcp_mbds_so_m_lib "" +#define pvmpeg2ffparsernode_y_lib "" +#define smrtsptrmpluginregpopulator_m_lib "" +#define omx_amr_component_y_lib "" +#define pvomxvideodecnode_m_lib "-lpvomxvideodecnode" +#define protocolenginenode_shoutcast_mk "/nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make" +#define REGISTER_OMX_RV_COMPONENT 0 +#define pvgeneraltools_y_mk "" +#define pvrealsupportcommon_so_name "" +#define omx_radec_sharedlibrary_aggregate_libtype "static" +#define omx_aacdec_sharedlibrary_aggregate_libtype "shared" +#define pvjitterbufferasf_m_lib "" +#define pvasxparser_m_mk "" +#define omx_m4venc_component_imp_m_mk "" +#define scsp_m_mk "/fileformats/scsp/build/make" +#define pvavcdecoder_imp_m_mk "" +#define pvdownloadinterface_m_lib "-lpvdownloadinterface" +#define pvwmdrmmd_m_lib "" +#define omx_queue_m_lib "-lomx_queue_lib" +#define MODS_opencore_streaming "-lopencore_net_support -lopencore_player -lopencore_common" +#define pvoma1passthru_so_name "pvoma1passthru" +#define amrparser_m_lib "-lamrparser" +#define omx_aac_component_y_lib "" +#define pvoma1lockstream_y_mk "" +#define pvplayreadyutility_y_lib "" +#define getaacaudioinfo_m_lib "" +#define pvauthorengine_m_lib "-lpvauthorengine" +#define pvdtcpplugin_y_lib "" +#define pvmediaoutputnode_y_lib "" +#define pvpvrcommonimpl_streaming_so_name "" +#define pvwavffparsernode_y_lib "" +#define DYNAMIC_LOAD_OMX_M4VENC_COMPONENT 1 +#define AGGREGATE_LIBDIRS_opencore_pvme "/engines/pvme/build/make" +#define AGGREGATE_LIBDIRS_omx_radec_sharedlibrary " " +#define LIBDIR_omxdec_static " " +#define MODS_omx_wmvdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common" +#define pvrtsptunicast_streamingregreg_so_name "pvrtsptunicast_streamingreg" +#define pvdtcp_mbds_m_lib "" +#define pvrrtspunicastpluginregpopulator_m_mk "" +#define pvwavffrecognizer_m_mk "/pvmi/recognizer/plugins/pvwavffrecognizer/build/make" +#define pvasfff_y_lib "" +#define pvjitterbuffernode_m_lib "-lpvjitterbuffernode" +#define pvwavffrecognizer_y_lib "" +#define MODS_pvdb_recovery_utility "-lopencore_common -lpvdb" +#define USE_OLD_WMA_DECODER 0 +#define AGGREGATE_LIBDIRS_pvplayerservice "/engines/player/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvfileoutputnode/build/make /nodes/pvwavffparsernode/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /fileformats/wav/parser/build/make /nodes/pvmp3ffparsernode/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /fileformats/mp3/parser/build/make /nodes/pvmp4ffparsernode/build_opencore/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /nodes/pvaacffparsernode/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /fileformats/rawaac/parser/build/make /nodes/pvamrffparsernode/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /fileformats/rawgsmamr/parser/build/make /pvmi/recognizer/build/make /nodes/pvcommonparsernode/build/make /fileformats/audioparser/common/build/make /fileformats/audioparser/amr/build/make /fileformats/audioparser/wav/build/make /pvmi/content_policy_manager/build/make /fileformats/scsp/build/make /fileformats/common/parser/build/make /fileformats/id3parcom/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxbasedecnode/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /protocols/rtp_payload_parser/util/build/latmparser/make /fileformats/scsp/build/make /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make /codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make /codecs_v2/utilities/colorconvert/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/mp3/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/media_data_structures/build/make /baselibs/gen_data_structures/build/make /pvmi/pvmf/build/make /baselibs/pv_mime_utils/build/make /codecs_v2/audio/gsm_amr/common/dec/build/make /nodes/common/build/make /engines/common/build/make /pvmi/content_policy_manager/plugins/common/build/make /oscl " +#define pvomx_proxy_m_mk "/codecs_v2/omx/omx_proxy/build/make" +#define pvra8decoder_imp_m_mk "" +#define pvrtsptunicastfsp_y_mk "" +#define unit_test_utils_m_lib "" +#define pvdecoder_gsmamr_imp_m_mk "" +#define pvomxencnode_m_lib "-lpvomxencnode" +#define pv_smooth_streaming_m_mk "" +#define pvsdpparser_m_mk "/protocols/sdp/parser/build/make" +#define pvsqlite_y_mk "" +#define pvmp4interface_m_lib "-lpvmp4interface" +#define pv_aac_enc_y_lib "" +#define pvrtspunicast_streaming_aggregate_libtype "shared" +#define MODS_pv "" +#define pvmpeg2ffrecognizer_m_mk "" +#define LIBS_audio_static " " +#define pvsmfspcommonimp_m_mk "/nodes/streaming/streamingmanager/plugins/common/build/make" +#define pvrtsp_cli_eng_node_m_lib "-lpvrtsp_cli_eng_node" +#define pvavch264enc_m_mk "/codecs_v2/video/avc_h264/enc/build/make" +#define pvplayreadyplugin_y_lib "" +#define pvm4vencoder_y_lib "" +#define LIBDIR_omxenc_static " " +#define asf_payload_parser_y_lib "" +#define pvrtsptwithrealfsp_y_mk "" +#define rtppayloadparser_y_mk "" +#define pvid3parcom_m_mk "/fileformats/id3parcom/build/make" +#define opencore_author_so_name "opencore_author" +#define pvdownloadreginterface_m_mk "/modules/linux_download/node_registry/build/make" +#define AGGREGATE_LIBDIRS_pvwmdrmoemsettings "" +#define omx_amr_component_m_mk "/codecs_v2/omx/omx_amr/build/make_multithreaded" +#define MODS_pvrmff_recognizer "-lopencore_common" +#define pvcrypto_m_mk "" +#define pvplayreadyplugininterface_m_lib "" +#define AGGREGATE_LIBDIRS_opencore_player " /pvmi/content_policy_manager/build/make /fileformats/pvx/parser/build/make /fileformats/id3parcom/build/make /nodes/pvamrffparsernode/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /pvmi/recognizer/plugins/pvplsffrecognizer/build/make /fileformats/mp3/parser/build/make /nodes/pvmp3ffparsernode/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/rawaac/parser/build/make /nodes/pvaacffparsernode/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /nodes/pvwavffparsernode/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /nodes/pvcommonparsernode/build/make /fileformats/audioparser/common/build/make /fileformats/audioparser/amr/build/make /fileformats/audioparser/wav/build/make /pvmi/recognizer/build/make /engines/adapters/player/framemetadatautility/build/make /engines/player/build/make" +#define pvfasttrack_downloadreg_so_name "" +#define pvfileplaybackwithpvr_streaming_aggregate_libtype "static" +#define pvrtspunicastwithpvr_streamingreg_aggregate_libtype "static" +#define MODS_pvmtpdrmmanagerplugin "-lopencore_common -lpvwmdrmmd" +#define pvflvffparsernode_m_mk "" +#define pvmpeg2ff_y_mk "" +#define pvaacffparsernode_m_lib "-lpvaacffparsernode" +#define pvprotocolenginenode_wmhttpstreaming_plugin_m_mk "" +#define MODS_pvplayready "-lopencore_common -lpvwmdrmmd" +#define pvjitterbufferrtp_y_lib "" +#define pvomxencnode_y_mk "" +#define AGGREGATE_LIBDIRS_opencore_common "/oscl /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/audio/gsm_amr/common/dec/build/make /fileformats/rawgsmamr/parser/build/make /codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/gen_data_structures/build/make /pvmi/pvmf/build/make /nodes/pvfileoutputnode/build/make /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvomxencnode/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /baselibs/thread_messaging/build/make /pvmi/media_io/pvmiofileoutput/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvomxvideodecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxbasedecnode/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /fileformats/wav/parser/build/make /fileformats/common/parser/build/make /fileformats/scsp/build/make /nodes/common/build/make /engines/common/build/make /pvmi/content_policy_manager/plugins/common/build/make" +#define pvflvffrecognizer_y_mk "" +#define omx_wmv_component_imp_m_mk "" +#define pvmtp_so_name "" +#define MODS_pvdbconfigclass "-lopencore_common" +#define pvmpeg2reginterface_m_mk "" +#define pvrtspunicastfsp_y_mk "" +#define pvrtppacketsourcenode_m_mk "" +#define omx_common_y_mk "" +#define MODS_omx_avcdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common" +#define BUILD_PROGRESSIVE_DOWNLOAD_PLUGIN 1 +#define pvasfffrecognizer_m_mk "" +#define pvfileplaybackwithpvr_streamingreg_aggregate_libtype "static" +#define pvlatmpayloadparser_y_lib "" +#define pvg726decoder_y_mk "" +#define pvmp4ffparsernode_m_mk "" +#define wmavoicedecoder_y_mk "" +#define pvmp4eu_m_lib "" +#define pvpvxparser_y_mk "" +#define pv_m3u_parser_y_lib "" +#define rfc_3640_mk "rfc_3640.mk" +#define pv_rtmp_parcom_y_mk "" +#define omx_m4venc_component_m_lib "-lomx_m4venc_component_lib" +#define pvmp4ffcomposernodeopencore_m_lib "-lpvmp4ffcomposernode" +#define rfc_3267_mk "rfc_3267.mk" +#define LIBS_media_io_shared "-lpvmiofileoutput -lpvmiofileinput -lpvmio_comm_loopback" +#define LIBS_audio_shared " -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3 -lpvencoder_gsmamr " +#define MODS_pvfasttrack_download "-lopencore_net_support -lopencore_common" +#define pvrmffrecognizer_y_lib "" +#define pvrrtspunicastplugininterface_m_mk "" +#define omx_amrdec_sharedlibrary_aggregate_libtype "shared" +#define pvplsffrecognizer_m_lib "-lpvplsffrecognizer" +#define audioparser_y_mk "" +#define pvmioaviwavfileinput_y_lib "-lpvmioaviwavfileinput" +#define pvfasttrack_downloadreg_link_type "loaded" +#define pvrtsp_cli_eng_real_cloaking_node_m_mk "" +#define WMA_BUILD_CFG_STD_ENABLED 0 +#define pvdb_recovery_utility_m_lib "" +#define pvsminterface_m_mk "/modules/linux_rtsp/core/build/make" +#define omx_avcenc_component_m_mk "/codecs_v2/omx/omx_h264enc/build/make_multithreaded" +#define omx_avcenc_component_imp_m_lib "" +#define pvmp4ffcomposernodeopencore_y_mk "" +#define wmavoicedecoder_imp_m_lib "" +#define pvsocketnode_m_lib "-lpvsocketnode" +#define pvgsmamrparser_m_mk "/fileformats/rawgsmamr/parser/build/make" +#define pvprotocolengine_asfstreamingreg_link_type "loaded" +#define rvdecoder_m_mk "" +#define pvmp4ffparsernodeopencore_m_mk "/nodes/pvmp4ffparsernode/build_opencore/make" +#define pvmtpdrmmanagerplugin_aggregate_libtype "static" +#define MODS_pvmshttp_streamingreg "-lopencore_common -lopencore_streaming" +#define pv324m_common_headers_m_mk "/protocols/systems/common/build/make/" +#define pvrtspunicastwithpvrfsp_y_lib "" +#define MODS_pvoma1passthru "-lopencore_player -lopencore_common" +#define REGISTER_OMX_MP3_COMPONENT 1 +#define asf_payload_parser_m_lib "" +#define LIBS_omxdec_shared "-lomx_avc_component_lib -lomx_m4v_component_lib -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib " +#define pvmp4interface_m_mk "/modules/linux_mp4/core/build/make" +#define REGISTER_OMX_AVC_COMPONENT 1 +#define pv_m3u_parser_y_mk "" +#define pvaacffparsernode_y_lib "" +#define protocolenginenode_ftdl_mk "" +#define omx_mp3_component_imp_m_mk "" +#define pvasfffparsernode_m_mk "" +#define m4v_config_y_lib "" +#define pvmp4ffparsernodeopencore_m_lib "-lpvmp4ffparsernode" +#define realmedia_payload_parser_y_lib "" +#define AGGREGATE_LIBDIRS_opencore_net_support "/nodes/pvsocketnode/build/make /protocols/http_parcom/build/make /nodes/pvprotocolenginenode/base/build/make /nodes/pvprotocolenginenode/protocol_common/build/make /nodes/pvprotocolenginenode/download_protocols/common/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make /nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/common/build/make /nodes/streaming/jitterbuffernode/build/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make /protocols/rtp/build/make" +#define pvavch264enc_m_lib "-lpvavch264enc" +#define AGGREGATE_LIBDIRS_opencore_mp4local "/modules/linux_mp4/core/build/make /nodes/pvmp4ffparsernode/build_opencore/make" +#define pvwmdrmoemsettingsinterface_m_lib "" +#define pvwavffparsernode_y_mk "" +#define pvdivxoemsettings_so_name "" +#define BUILD_STATIC_RTSP_BROADCAST_PVR 0 +#define pvplsffrecognizer_y_mk "" +#define pvrtspunicastwithpvr_streamingreg_so_name "" +#define omx_wmv_component_m_lib "" +#define pvwmdrmmd_y_lib "" +#define unit_test_utils_y_mk "/oscl/unit_test_utils/build/make" +#define AGGREGATE_LIBDIRS_pvoma1passthru "/pvmi/content_policy_manager/plugins/oma1/passthru/build/make /modules/cpm_oma1_passthru/build/make" +#define pvaacffrecognizer_m_mk "/pvmi/recognizer/plugins/pvaacffrecognizer/build/make" +#define pvrtsptunicastfsp_m_lib "-lpvrtsptunicaststreamingmanager" +#define pvrtspunicast_streaming_link_type "loaded" +#define omx_amr_component_m_lib "-lomx_amr_component_lib" +#define LIBDIR_omxdecimp_static "" +#define pvcommsionode_m_lib "-lpvcommsionode" +#define pvmiofileoutput_m_mk "/pvmi/media_io/pvmiofileoutput/build/make" +#define BUILD_RTMPSTREAMING_PLUGIN 0 +#define pvmediainputnode_y_lib "" +#define omx_aac_component_m_mk "/codecs_v2/omx/omx_aac/build/make_multithreaded" +#define omx_ra_component_m_mk "" +#define BUILD_STATIC_MSHTTP_ASF 0 +#define AGGREGATE_LIBDIRS_pvwmdrmmd " " +#define pv_aac_dec_y_lib "" +#define pvgsmamrparser_y_lib "" +#define pvoma1ffrecognizer_m_lib "" +#define pvdb_recovery_utility_so_name "" +#define protocolenginenode_pdl_mk "/nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make" +#define rtprtcp_y_lib "" +#define pvasfffparsernode_m_lib "" +#define secure_data_format_y_mk "" +#define LIBDIR_shared "/oscl /baselibs/gen_data_structures/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/thread_messaging/build/make /codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make /codecs_v2/video/m4v_h263/dec/build/make /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make /fileformats/common/parser/build/make /fileformats/id3parcom/build/make /fileformats/pvx/parser/build/make /fileformats/wav/parser/build/make /fileformats/mp3/parser/build/make /fileformats/rawaac/parser/build/make /fileformats/rawgsmamr/parser/build/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/composer/build_opencore/make /fileformats/scsp/build/make /fileformats/audioparser/common/build/make /fileformats/audioparser/amr/build/make /fileformats/audioparser/wav/build/make /protocols/http_parcom/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make /protocols/rtsp_parcom/build/make /protocols/rtsp_client_engine/build/make_segments /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make /pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make /pvmi/content_policy_manager/plugins/common/build/make /pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmio_comm_loopback/build/make /pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /pvmi/recognizer/plugins/pvplsffrecognizer/build/make /pvmi/pvmf/build/make /nodes/pvfileoutputnode/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvsocketnode/build/make /nodes/pvprotocolenginenode/base/build/make /nodes/pvprotocolenginenode/protocol_common/build/make /nodes/pvprotocolenginenode/download_protocols/common/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make /nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make /nodes/pvwavffparsernode/build/make /nodes/pvomxencnode/build/make /nodes/pvomxbasedecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxvideodecnode/build/make /nodes/pvaacffparsernode/build/make /nodes/pvamrffparsernode/build/make /nodes/pvmp3ffparsernode/build/make /nodes/pvmp4ffparsernode/build_opencore/make /nodes/common/build/make /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvmp4ffcomposernode/build_opencore/make /nodes/pvdownloadmanagernode/build/make /nodes/streaming/streamingmanager/plugins/rtspunicast/build/make /nodes/streaming/streamingmanager/plugins/rtsptunicast/build/make /nodes/streaming/streamingmanager/plugins/common/build/make /nodes/streaming/streamingmanager/build/make /modules/linux_rtsp/smplugins/unicast/core/build/make /modules/linux_rtsp/smplugins/unicast/registry/build/make /modules/linux_rtsp/smplugins/tunneling/core/build/make /modules/linux_rtsp/smplugins/tunneling/registry/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/common/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/rtp/build/make /nodes/streaming/jitterbuffernode/build/make /nodes/pvcommsionode/build/make /nodes/pvclientserversocketnode/build/make /nodes/pvloopbacknode/build/make /nodes/pvcommonparsernode/build/make /engines/player/build/make /engines/author/build/make /engines/2way/build/make /engines/2way/sample_app/pv2waysample/build/make /engines/common/build/make /engines/adapters/player/framemetadatautility/build/make /engines/pvme/build/make /modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make /modules/linux_rtsp/smplugins/unicast/core/build/make /modules/linux_rtsp/smplugins/unicast/registry/build/make /modules/linux_rtsp/smplugins/tunneling/core/build/make /modules/linux_rtsp/smplugins/tunneling/registry/build/make /modules/linux_download/core/build/make /modules/linux_download/node_registry/build/make /modules/linux_mp4/core/build/make /modules/linux_mp4/node_registry/build/make /modules/cpm_oma1_passthru/build/make " +#define omx_aac_component_imp_m_lib "" +#define omx_ra_component_imp_m_lib "" +#define divxrecognizer_utility_y_lib "" +#define protocolenginenode_ps_lib "-lprotocolenginenode_ps" +#define pvsmfspcommonimp_y_mk "" +#define pvmp3ffparsernode_y_lib "" +#define pvdivxinterface_m_mk "" +#define MODS_pvdivxparser_node "-lpvdivx_recognizer -lopencore_player -lopencore_common" +#define omx_wmadec_sharedlibrary_so_name "" +#define omx_ra_component_m_lib "" +#define omx_aac_component_m_lib "-lomx_aac_component_lib" +#define wmadecoderlibpath "/codecs_v2/audio/wma/dec/build/make" +#define pvmtpip_engine_y_lib "" +#define pvmp4decoder_m_lib "-lpvmp4decoder" +#define pvrmffparser_y_mk "" +#define opencore_player_aggregate_libtype "shared" +#define scsp_y_lib "" +#define pvrfileplaybackplugininterface_m_lib "" +#define omx_avcenc_component_y_mk "" +#define optimized_bcast_ps_mk "" +#define wmadecoder_y_lib "" +#define oscllib_lib "-loscllib" +#define pvclientserversocketnode_y_lib "" +#define pvrmff_m_lib "" +#define DYNAMIC_LOAD_OMX_AMR_COMPONENT 1 +#define pvavch264enc_imp_m_lib "" +#define pvasfff_m_lib "" +#define LIBS_omxdec_static " " +#define DYNAMIC_LOAD_OMX_AVCENC_COMPONENT 1 +#define AVC_MP_DECODER_ENABLED 0 +#define REGISTER_OMX_WMA_COMPONENT 0 +#define pv_http_parcom_m_lib "-lpv_http_parcom" +#define pvrbroadcastpluginregpopulator_m_mk "" +#define pv_rtsp_parcom_m_mk "/protocols/rtsp_parcom/build/make" +#define pvoma1passthruplugin_m_mk "/pvmi/content_policy_manager/plugins/oma1/passthru/build/make" +#define omx_wma_component_y_lib "" +#define pvrmffrecognizer_utility_m_mk "" +#define csprng_m_lib "" +#define smrtsptplugininterface_m_mk "/modules/linux_rtsp/smplugins/tunneling/core/build/make" +#define LIBS_fileformats_shared "-lpvfileparserutils -lpvid3parcom -lpvpvxparser -lpvwav -lpvmp3ff -lpvaacparser -lpvgsmamrparser -lmp4recognizer_utility -lpvmp4ff -lpvmp4ffcomposer -lscsp -laudioparser -lamrparser -lwavparser" +#define pvwmdrmoemsettings_aggregate_libtype "static" +#define LIBS_engines_static " " +#define pv_smooth_streaming_y_mk "" +#define pvmp3_m_lib "-lpvmp3" +#define opencore_download_aggregate_libtype "shared" +#define pvsdpparser_plugins " sdp_opencore.mk" +#define pvmimeutils_m_mk "/baselibs/pv_mime_utils/build/make" +#define AGGREGATE_LIBDIRS_pvprotocolengine_asfstreamingreg "" +#define protocolenginenode_segments_mk "/nodes/pvprotocolenginenode/base/build/make /nodes/pvprotocolenginenode/protocol_common/build/make /nodes/pvprotocolenginenode/download_protocols/common/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make /nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make" +#define omx_mp3dec_sharedlibrary_link_type "loaded" +#define pvsqlite_so_name "" +#define asf_payload_parser_m_mk "" +#define pv_http_retriever_y_lib "" +#define pvamrwbdecoder_imp_m_lib "" +#define oscl_m_lib "-lpvlogger -losclregcli -losclregserv -losclutil -losclproc -losclio -losclmemory -losclerror -losclbase" +#define pvasfffrecognizer_y_lib "" +#define pvmediainputnode_y_mk "" +#define pvdivxreginterface_m_mk "" +#define omx_common_m_lib "-lomx_common_lib" +#define pvprotocolenginefasttrackdownloadinterface_m_mk "" +#define pvwav_m_mk "/fileformats/wav/parser/build/make" +#define omx_m4venc_sharedlibrary_link_type "loaded" +#define pvrmffinterface_m_mk "" +#define pvflvffrecognizer_m_mk "" +#define AGGREGATE_LIBDIRS_pvrtspunicastwithpvr_streamingreg "" +#define pvmp4ffcomposeropencore_y_lib "" +#define pvmp4ffparsernodeopencore_y_lib "" +#define LIBS_baselibs_shared " -lpvgendatastruct -lpvmediadatastruct -lpvmimeutils -lthreadsafe_callback_ao -lpvthreadmessaging " +#define pvfileparserutils_m_lib "-lpvfileparserutils" +#define pvmshttp_streamingreg_so_name "" +#define pvlatmpayloadparser_m_mk "/protocols/rtp_payload_parser/util/build/latmparser/make" +#define pvid3parcom_m_lib "-lpvid3parcom" +#define pvdivxdrmplugininterface_m_lib "" +#define LIBDIR_fileformats_static " /fileformats/avi/parser/build/make " +#define LIBS_cpm_shared "-lcpm -lpvoma1passthruplugin " +#define secure_data_format_y_lib "" +#define omx_m4venc_sharedlibrary_aggregate_libtype "shared" +#define LIBS_pvmi_static " -lpvmioaviwavfileinput " +#define pv_amr_nb_common_lib_m_mk "/codecs_v2/audio/gsm_amr/amr_nb/common/build/make" +#define pvcrypto_y_lib "" +#define AGGREGATE_LIBDIRS_pvasfcommon " " +#define LIBDIR_cpm_static " " +#define opencore_pvme_so_name "opencore_pvme" +#define LIBDIR_omxjointimp_static "" +#define pvjitterbuffernode_y_lib "" +#define pvdownloadmanagernode_m_mk "/nodes/pvdownloadmanagernode/build/make" +#define pviptransport_m_mk "" +#define pvmediaoutputnode_y_mk "" +#define MODS_omx_aacdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common" +#define AGGREGATE_LIBDIRS_pvpvrcommonimpl_streaming "" +#define LIBS_packetsources_static "" +#define pvstreamingmanagernode_m_lib "-lpvstreamingmanagernode" +#define opencore_net_support_aggregate_libtype "shared" +#define pvfasttrack_downloadreg_aggregate_libtype "static" +#define pv_http_retriever_m_lib "" +#define opencore_mp4localreg_link_type "loaded" +#define AGGREGATE_LIBDIRS_pvmpeg2local " " +#define LIBDIR_omxdecimp_shared "" +#define pvmio_comm_loopback_m_mk "/pvmi/media_io/pvmio_comm_loopback/build/make" +#define opencore_streamingreg_aggregate_libtype "shared" +#define pvlatmpayloadparser_m_lib "-lpvlatmpayloadparser" +#define pv2wayengine_m_lib "-lpv2wayengine" +#define pvamrffrecognizer_m_lib "-lpvamrffrecognizer" +#define omx_wmv_component_m_mk "" +#define pvflvffrecognizer_y_lib "" +#define smrtsptpluginregpopulator_m_mk "/modules/linux_rtsp/smplugins/tunneling/registry/build/make" +#define AGGREGATE_LIBDIRS_omx_aacenc_sharedlibrary " " +#define LIBS_codecs_v2_shared "-lomx_avc_component_lib -lomx_m4v_component_lib -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib -lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib -lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3 -lpvencoder_gsmamr -lpv_avc_common_lib -lpvavcdecoder -lpvmp4decoder -lpvm4vencoder -lpvavch264enc -lm4v_config -lpv_config_parser -lcolorconvert" +#define opencore_pvme_aggregate_libtype "shared" +#define opencore_downloadreg_aggregate_libtype "shared" +#define pvdecoder_gsmamr_imp_m_lib "" +#define pvasflocalpbreg_aggregate_libtype "static" +#define pvdivxdrm_oem_settings_y_lib "" +#define omx_mastercore_m_mk "/codecs_v2/omx/omx_mastercore/build/make_multithreaded" +#define pvdivxparser_node_so_name "" +#define pvplayerservice_aggregate_libtype "static" +#define pvprotocolenginenode_ftdl_plugin_m_mk "" +#define omx_avc_component_m_mk "/codecs_v2/omx/omx_h264/build/make_multithreaded" +#define omx_aacenc_sharedlibrary_aggregate_libtype "static" +#define getactualaacconfig_imp_m_lib "-lgetactualaacconfig" +#define pvencoder_gsmamr_imp_m_mk "" +#define LIBDIR_recognizer_static " " +#define MODS_pvmpeg2local "-lopencore_common -lopencore_player -lpvmpeg2localreg" +#define cpm_m_lib "-lcpm" +#define pvrmff_recognizer_aggregate_libtype "static" +#define MODS_opencore_author "-lopencore_common" +#define wmvdecoder_imp_m_mk "" +#define pvdivxdrm_aggregate_libtype "static" +#define pvamrffparsernode_y_lib "" +#define pvmioaviwavfileinput_m_lib "" +#define pv324m_plugins "default_support.mk" +#define MODS_omx_wmadec_sharedlibrary "-lomx_sharedlibrary -lopencore_common" +#define divxrecognizer_utility_m_lib "" +#define LIBDIR_recognizer_shared "/pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /pvmi/recognizer/plugins/pvplsffrecognizer/build/make " +#define REGISTER_OMX_WMV_COMPONENT 0 +#define omx_m4v_component_m_lib "-lomx_m4v_component_lib" +#define pvmpeg2ffparsernode_m_lib "" +#define pvomxbasedecnode_y_lib "" +#define MODS_pvrtsptunicast_streaming "-lopencore_net_support -lopencore_player -lopencore_common -lopencore_rtsp -lopencore_streaming" +#define pvsocketnode_m_mk "/nodes/pvsocketnode/build/make" +#define omx_avcdec_sharedlibrary_so_name "omx_avcdec_sharedlibrary" +#define pvdivx_recognizer_aggregate_libtype "static" +#define pvdownloadmanagernode_m_lib "-lpvdownloadmanagernode" +#define amrparser_y_lib "" +#define packetsources_default_m_mk "" +#define pvrtspbroadcastwithpvr_streamingreg_so_name "" +#define pvmp4ffrecognizer_m_lib "-lpvmp4ffrecognizer" +#define pvprotocolenginefasttrackdownloadpluginreginterface_m_mk "" +#define pv2waysample_y_lib "" +#define smrtsptrmplugininterface_m_lib "" +#define pvmp4ffcomposer_m_lib "" +#define pvflv_recognizer_aggregate_libtype "static" +#define pvrtspbroadcastwithpvr_streaming_so_name "" +#define rdt_parser_m_mk "" +#define WMA_BUILD_CFG_STDPROSTEREOLBRV1_ENABLED 0 +#define pvencoder_gsmamr_m_mk "/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make" +#define pv_rtsp_parcom_y_mk "" +#define opencore_streamingreg_link_type "loaded" +#define pvmio_comm_loopback_m_lib "-lpvmio_comm_loopback" +#define omx_wmv_component_y_lib "" +#define smrtspunicastpluginregpopulator_m_lib "-lpvrtspsmpluginreginterface" +#define pvcommonparsernode_y_lib "" +#define omx_m4vdec_sharedlibrary_so_name "omx_m4vdec_sharedlibrary" +#define LIBDIR_media_io_static " /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make " +#define pvplayreadyutility_y_mk "" +#define pvrtspunicastwithpvr_streaming_so_name "" +#define AGGREGATE_LIBDIRS_omx_mp3dec_sharedlibrary "/codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/audio/mp3/dec/build/make" +#define AGGREGATE_LIBDIRS_pvrealsupportcommon "" +#define g726decnode_y_lib "" +#define pvasflocalpbinterface_m_mk "" +#define MODS_omx_rvdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common" +#define pvmp4decoder_m_mk "/codecs_v2/video/m4v_h263/dec/build/make" +#define pvmp4ffparsernode_y_mk "" +#define omx_aacenc_sharedlibrary_link_type "loaded" +#define pvdtcp_mbds_so_name "" +#define pvmpeg2localreg_so_name "" +#define BUILD_SMOOTHSTREAMING_PLUGIN 0 +#define omx_aacenc_component_m_mk "" +#define pv_http_retriever_m_mk "" +#define LIBDIR_protocols_static " " +#define pvtinyxml_y_mk "" +#define LIBDIR_codecs_utilities_shared "/codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make" +#define AGGREGATE_LIBDIRS_pvprotocolengine_asfstreaming " " +#define pvflvffparsernode_y_mk "" +#define pvdbconfigclass_link_type "loaded" +#define rtspbasedpluginselected_y_config 0 +#define pv_avc_common_lib_m_lib "-lpv_avc_common_lib" +#define pvrmffreginterface_m_lib "" +#define AGGREGATE_LIBDIRS_pvflv_recognizer " " +#define pvrmffparsernode_y_mk "" +#define LIBS_extern_libs_static " " +#define pvmp3ff_m_lib "-lpvmp3ff" +#define AGGREGATE_LIBDIRS_pviptransport "" +#define pvdivxparser_node_aggregate_libtype "static" +#define LIBDIR_extern_libs_static " " +#define pvmp3_y_lib "" +#define pvdivxdrmplugin_m_mk "" +#define protocolenginenode_base_lib "-lprotocolenginenode_base" +#define pvaacparser_y_lib "" +#define pvmpeg2ffparsernode_m_mk "" +#define omx_rv_component_imp_m_mk "" +#define MODS_opencore_rtsp "-lopencore_net_support -lopencore_player -lopencore_common" +#define pvdb_recovery_utility_aggregate_libtype "static" +#define REGISTER_OMX_AMR_COMPONENT 1 +#define pvmtp_aggregate_libtype "static" +#define BUILD_WMHTTPSTREAMING_PLUGIN 0 +#define MODS_pvrtspunicast_streamingreg "-lopencore_common -lopencore_streaming" +#define omx_aacdec_sharedlibrary_link_type "loaded" +#define omx_radec_sharedlibrary_link_type "loaded" +#define pv_avc_common_imp_lib_m_mk "" +#define engines_common_headers_m_mk "/engines/common/build/make" +#define pvoma1passthruplugin_y_mk "" +#define pvdivxdrm_so_name "" +#define pvdivxdrm_m_mk "" +#define pvflvff_y_lib "" +#define LIBDIR_omxencimp_static "" +#define pvrmffreginterface_m_mk "" +#define LIBDIR_packetsources_static "" +#define omx_amrenc_sharedlibrary_aggregate_libtype "shared" +#define MODS_omx_m4venc_sharedlibrary "-lomx_sharedlibrary -lopencore_common " +#define pvjitterbufferrtp_m_lib "-lpvjitterbufferrtp" +#define pvmp4ff_y_mk "" +#define pvmp4ffcomposernode_m_mk "" +#define LIBDIR_oscl_shared "/oscl " +#define realmedia_payload_parser_m_lib "" +#define AGGREGATE_LIBDIRS_pvfileplaybackwithpvr_streaming " " +#define cpm_headers_y_mk "" +#define audioparser_m_lib "-laudioparser" +#define pv_aac_dec_imp_m_mk "" +#define omx_wmv_component_imp_m_lib "" +#define DYNAMIC_LOAD_OMX_H263ENC_COMPONENT 1 +#define omx_m4v_component_imp_m_mk "" +#define protocolenginenode_common_mk "/nodes/pvprotocolenginenode/protocol_common/build/make" +#define LIBDIR_media_io_shared "/pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmio_comm_loopback/build/make" +#define pvflvinterface_m_mk "" +#define pvamrffparsernode_m_mk "/nodes/pvamrffparsernode/build/make" +#define pvmpeg2localreg_link_type "loaded" +#define pvasfffparsernode_y_mk "" +#define pv_avc_common_lib_m_mk "/codecs_v2/video/avc_h264/common/build/make" +#define pv_aac_dec_plugins "aacdec_util.mk" +#define pv_srs_wowhd_m_lib "" +#define pvfileplaybackwithpvr_streaming_so_name "" +#define realmedia_payload_parser_y_mk "" +#define colorconvert_m_mk "/codecs_v2/utilities/colorconvert/build/make" +#define threadsafe_callback_ao_m_lib "-lthreadsafe_callback_ao" +#define omx_wmadec_sharedlibrary_link_type "loaded" +#define opencore_rtsp_so_name "opencore_rtsp" +#define mpeg2recognizer_utility_m_lib "" +#define pvmpeg2ffrecognizer_m_lib "" +#define LIBDIR_codecs_utilities_static " " +#define pvpvrcommonimp_y_lib "" +#define pvmetadata_engine_m_mk "/engines/pvme/build/make" +#define pvauthorengine_m_mk "/engines/author/build/make" +#define getaacaudioinfo_m_mk "" +#define pvmshttpfsp_m_lib "" +#define pvomxvideodecnode_y_mk "" +#define opencore_streaming_link_type "loaded" +#define pvmediadatastruct_y_mk "" +#define pvasfffrecognizer_m_lib "" +#define pvplayreadyplugin_m_mk "" +#define protocolenginenode_download_common_mk "/nodes/pvprotocolenginenode/download_protocols/common/build/make" +#define pvrmffrecognizer_y_mk "" +#define pvavifileparser_m_lib "" +#define omx_avcenc_component_y_lib "" +#define rtprtcp_y_mk "" +#define pvmp4reginterface_m_mk "/modules/linux_mp4/node_registry/build/make" +#define omx_m4venc_component_y_mk "" +#define LIBDIR_module "/modules" +#define pvpvxparser_m_mk "/fileformats/pvx/parser/build/make" +#define protocolenginenode_common_lib "-lprotocolenginenode_common" +#define pv_omx_interface_m_lib "-lpv_omx_interface" +#define MODS_pvmshttp_streaming "-lopencore_net_support -lopencore_player -lopencore_common -lopencore_streaming -lpvasfcommon" +#define smmshttppluginregpopulator_m_mk "" +#define pvrmffrecognizer_m_lib "" +#define rtspbasedpluginselected_m_config 1 +#define pvrtsp_cli_eng_playlist_node_m_lib "" +#define pv_avc_mp_decoder_y_lib "" +#define mp4recognizer_utility_m_mk "/fileformats/mp4/parser/utils/mp4recognizer/build/make" +#define pvamrffrecognizer_m_mk "/pvmi/recognizer/plugins/pvamrffrecognizer/build/make" +#define pvasflocalpbreginterface_m_lib "" +#define colorconvert_m_lib "-lcolorconvert" +#define pvprotocolengine_asfstreaming_so_name "" +#define omx_baseclass_y_lib "" +#define pvrmffinterface_m_lib "" +#define wmvdecoder_imp_m_lib "" +#define pvmtp_engine_y_mk "" +#define LIBDIR_video_shared "/codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make /codecs_v2/video/m4v_h263/dec/build/make /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make" +#define mtpconfiginterface_m_lib "" +#define pvasfff_m_mk "" +#define pvaudiotrackmio_m_lib "" +#define DYNAMIC_LOAD_OMX_AAC_COMPONENT 1 +#define rvdecoder_imp_m_mk "" +#define pvdivxdrmplugin_y_lib "" +#define pvflvffparsernode_y_lib "" +#define pvgendatastruct_y_mk "" +#define pvmiofileoutput_y_lib "" +#define AGGREGATE_LIBDIRS_pvrtspunicastwithpvr_streaming " " +#define pvwmdrmmd_so_name "" +#define pvdownloadreginterface_m_lib "-lpvdownloadreginterface" +#define LIBS_static " -lunit_test -lunit_test_utils -lpvavifileparser -lpvmioaviwavfileinput " +#define REGISTER_OMX_M4V_COMPONENT 1 +#define MODS_opencore_net_support "-lopencore_common" +#define pvcrypto_y_mk "" +#define AGGREGATE_LIBDIRS_pvrtsptunicast_streaming "/modules/linux_rtsp/smplugins/tunneling/core/build/make /nodes/streaming/streamingmanager/plugins/rtsptunicast/build/make" +#define omx_aacenc_component_imp_m_mk "" +#define asfrecognizer_utility_y_lib "" +#define pv_aac_enc_m_mk "" +#define pvmp3ff_m_mk "/fileformats/mp3/parser/build/make" +#define pvplsffrecognizer_m_mk "/pvmi/recognizer/plugins/pvplsffrecognizer/build/make" +#define pvomx_proxy_y_lib "" +#define pvmiofileinput_m_mk "/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor" +#define pvfasttrack_download_aggregate_libtype "static" +#define oscl_y_lib "" +#define mtpconfiginterface_m_mk "" +#define MODS_omx_radec_sharedlibrary "-lomx_sharedlibrary -lopencore_common -lopencore_player -lpvrealsupportcommon" +#define pvrmffrecognizer_utility_y_mk "" +#define omx_rv_component_y_mk "" +#define wavparser_m_mk "/fileformats/audioparser/wav/build/make" +#define LIBS_protocols_static " " +#define MODS_pvmp4eu "-lopencore_common -lopencore_player -lopencore_author" +#define LIBDIR_audio_shared " /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make " +#define pvmtpdrmmanagerplugin_so_name "" +#define pvdivxdrm_link_type "loaded" +#define pvsdpparser_opencore_m_lib "-lpvsdpparser" +#define protocolenginenode_m_lib "-lprotocolenginenode_base -lprotocolenginenode_common -lprotocolenginenode_download_common -lprotocolenginenode_pdl -lprotocolenginenode_ps -lprotocolenginenode_shoutcast" +#define pvrmffparser_node_aggregate_libtype "static" +#define BUILD_SHOUTCAST_PLUGIN 1 +#define pvdb_recovery_utility_m_mk "" +#define pvomxaudiodecnode_m_lib "-lpvomxaudiodecnode" +#define pv324m_y_lib "" +#define pvflv_recognizer_so_name "" +#define BUILD_WOW_HD_AUDIO 0 +#define pvsocketnode_y_lib "" +#define unit_test_y_mk "/oscl/unit_test/build/make" +#define AGGREGATE_LIBDIRS_pv "/oscl /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/mp3/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/video/avc_h264/dec/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/enc/build/make /codecs_v2/video/m4v_h263/dec/build/make /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make /codecs_v2/utilities/colorconvert/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/gen_data_structures/build/make /pvmi/pvmf/build/make /pvmi/content_policy_manager/build/make /pvmi/media_io/pvmiofileoutput/build/make /fileformats/common/parser/build/make /fileformats/id3parcom/build/make /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/mp4/composer/build_opencore/make /nodes/pvmp4ffcomposernode/build_opencore/make /fileformats/pvx/parser/build/make /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvmediaoutputnode/build/make /nodes/pvfileoutputnode/build/make /fileformats/rawgsmamr/parser/build/make /nodes/pvamrffparsernode/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /fileformats/rawaac/parser/build/make /nodes/pvaacffparsernode/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /fileformats/mp3/parser/build/make /nodes/pvmp3ffparsernode/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /nodes/pvcommonparsernode/build/make /fileformats/audioparser/common/build/make /fileformats/audioparser/amr/build/make /fileformats/audioparser/wav/build/make /nodes/pvomxvideodecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxbasedecnode/build/make /nodes/pvwavffparsernode/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /pvmi/recognizer/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /engines/adapters/player/framemetadatautility/build/make /engines/player/build/make /engines/author/build/make /engines/2way/sample_app/pv2waysample/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /engines/2way/build/make /nodes/pvclientserversocketnode/build/make /baselibs/thread_messaging/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /fileformats/scsp/build/make" +#define PV_ONE_SEGMENT_BROADCAST 0 +#define getactualaacconfig_y_mk "" +#define AGGREGATE_LIBDIRS_pvmtp "" +#define protocolenginenode_base_mk "/nodes/pvprotocolenginenode/base/build/make" +#define pvmf_y_lib "" +#define pv_config_parser_y_lib "" +#define opencore_2way_aggregate_libtype "shared" +#define pvpvrcommonimp_m_lib "" +#define m4v_config_m_lib "-lm4v_config" +#define pvaacffrecognizer_m_lib "-lpvaacffrecognizer" +#define cpm_y_mk "" +#define MODS_pvrtsptunicast_streamingreg "-lopencore_common -lopencore_streaming" +#define pvrbroadcastplugininterface_m_lib "" +#define pvmtpdrmmanagerplugin_link_type "loaded" +#define wmvdecoder_y_mk "" +#define AGGREGATE_LIBDIRS_omx_aacdec_sharedlibrary "/codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/audio/aac/dec/build/make" +#define pvsmfspcommonimp_y_lib "" +#define opencore_mp4localreg_so_name "opencore_mp4localreg" +#define pvcommonparsernode_y_mk "" +#define pvmtpdrmmanagerplugin_m_lib "" +#define flvrecognizer_utility_y_mk "" +#define omx_radec_sharedlibrary_so_name "" +#define pv_avc_mp_decoder_m_lib "" +#define pvomxvideodecnode_m_mk "/nodes/pvomxvideodecnode/build/make" +#define pvmp4ffcomposernodeopencore_m_mk "/nodes/pvmp4ffcomposernode/build_opencore/make" +#define pvrtsp_cli_eng_playlist_node_m_mk "" +#define pvomxaudiodecnode_y_mk "" +#define pvra8decoder_y_mk "" +#define AGGREGATE_LIBDIRS_pvflvparser_node " " +#define AGGREGATE_LIBDIRS_opencore_rtsp "/protocols/rtsp_parcom/build/make /protocols/rtsp_client_engine/build/make_segments /protocols/rtp_payload_parser/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/rtp/build/make" +#define pvflvff_m_mk "" +#define m4v_config_y_mk "" +#define pvthreadmessaging_y_lib "" +#define pvthreadmessaging_m_mk "/baselibs/thread_messaging/build/make" +#define pvjitterbuffercommon_m_lib "-lpvjitterbuffer" +#define LIBS_tools_v2_shared "-lpvsminterface -lpvsmreginterface -lpvrtspsmplugininterface -lpvrtspsmpluginreginterface -lpvrtsptsmplugininterface -lpvrtsptsmpluginreginterface -lpvdownloadinterface -lpvdownloadreginterface -lpvmp4interface -lpvmp4reginterface -lpvoma1passthruplugininterface " +#define LIBS_pvmi_shared "-lcpm -lpvoma1passthruplugin -lpvmiofileoutput -lpvmiofileinput -lpvmio_comm_loopback -lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer -lpvplsffrecognizer -lpvmf " +#define pvcommsionode_m_mk "/nodes/pvcommsionode/build/make" +#define pvm4vencoder_imp_m_mk "" +#define g726decnode_m_lib "" +#define omx_mp3_component_imp_m_lib "" +#define pvstreamingmanagernode_m_mk "/nodes/streaming/streamingmanager/build/make" +#define pvplayreadyplugininterface_m_mk "" +#define mpeg2recognizer_utility_m_mk "" +#define DYNAMIC_LOAD_OMX_H263_COMPONENT 1 +#define pvomxencnode_y_lib "" +#define smrtsptrmplugininterface_m_mk "" +#define pvmetadata_engine_y_mk "" +#define omx_wma_component_imp_m_lib "" +#define wavparser_y_lib "" +#define pvpvxparser_y_lib "" +#define pvra8decoder_y_lib "" +#define pvdbconfiginterface_m_lib "" +#define MODS_pvasflocalpbreg "-lopencore_common -lpvasfcommon" +#define pvrmffparsernode_m_lib "" +#define MODS_pvplayerservice "" +#define pv_divxfile_parser_m_mk "" +#define LIBS_media_io_static " -lpvmioaviwavfileinput " +#define pv_amr_nb_common_imp_lib_m_mk "" +#define MODS_pvrmffparser_node "-lpvrmff_recognizer -lopencore_player -lopencore_common -lpvrealsupportcommon" +#define pvmp4eu_m_mk "" +#define pvrmff_y_lib "" +#define pvdtcp_mbds_y_lib "" +#define pvwmdrmoemsettings_link_type "loaded" +#define pvstillimagenode_y_lib "" +#define USE_OMX_ENC_NODE 1 +#define pvrtsptwithrealfsp_m_lib "" +#define mp4recognizer_utility_y_lib "" +#define asf_payload_parser_y_mk "" +#define pvm4vencoder_m_lib "-lpvm4vencoder" +#define LIBS_codecs_utilities_shared "-lm4v_config -lpv_config_parser -lcolorconvert" +#define opencore_2way_so_name "opencore_2way" +#define AGGREGATE_LIBDIRS_pvsqlite "" +#define pv2waysample_y_mk "" +#define omx_avcdec_sharedlibrary_aggregate_libtype "shared" +#define AGGREGATE_LIBDIRS_omx_wmadec_sharedlibrary " " +#define omx_wmvdec_sharedlibrary_so_name "" +#define pvdtcpplugin_y_mk "" +#define pvmshttp_streaming_so_name "" +#define AGGREGATE_LIBDIRS_omx_amrdec_sharedlibrary "/codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make" +#define getactualaacconfig_m_lib "-lgetactualaacconfig" +#define MODS_pvprotocolengine_asfstreaming "-lopencore_net_support -lopencore_common -lpvasfcommon" +#define pvprotocolengine_asfstreaming_link_type "loaded" +#define omx_amrenc_component_y_lib "" +#define MODS_pvrealsupportcommon "-lopencore_common" +#define AGGREGATE_LIBDIRS_pvrtsptunicastforrm_streamingreg "" +#define pvaacffparsernode_m_mk "/nodes/pvaacffparsernode/build/make" +#define pvm4vencoder_imp_m_lib "" +#define rtppayloadparser_y_lib "" +#define pvrmffparser_y_lib "" +#define wmvdecoder_m_mk "" +#define packetsources_default_m_lib "" +#define omx_amrenc_component_imp_m_lib "" +#define pvaacffrecognizer_y_mk "" +#define DYNAMIC_LOAD_OMX_AVC_COMPONENT 1 +#define REGISTER_OMX_RA_COMPONENT 0 +#define LIBS_omxdecimp_static "" +#define pvmtpip_aggregate_libtype "static" +#define pv_smooth_streaming_m_lib "" +#define WMA_BUILD_CFG_LSL_ENABLED 0 +#define pv_aac_enc_imp_m_lib "" +#define LIBDIR_nodes_static " " +#define smrtspunicastplugininterface_m_mk "/modules/linux_rtsp/smplugins/unicast/core/build/make" +#define pvmshttp_streaming_aggregate_libtype "static" +#define PV_MULTICHANNEL_FRIENDLY 0 +#define asfrecognizer_utility_m_mk "" +#define pvrmffparsernode_m_mk "" +#define realaudio_deinterleaver_m_mk "" +#define LIBDIR_baselibs_static " " +#define pvwav_m_lib "-lpvwav" +#define pvmp4decoder_imp_m_lib "" +#define pv_rtsp_parcom_y_lib "" +#define LIBDIR_static " /oscl/unit_test/build/make /oscl/unit_test_utils/build/make /fileformats/avi/parser/build/make /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make " +#define pvmp4decoder_y_mk "" +#define omx_mastercore_m_lib "-lomx_mastercore_lib" +#define omx_m4vdec_sharedlibrary_aggregate_libtype "shared" +#define pv_config_parser_y_mk "" +#define MODS_pvmtpconfigclass "-lopencore_common" +#define LIBS_oscl_static " -lunit_test -lunit_test_utils" +#define pvfileoutputnode_m_mk "/nodes/pvfileoutputnode/build/make" +#define wmadecoder_imp_m_lib "" +#define g726decnode_y_mk "" +#define oscl_m_mk "/oscl" +#define pvpvxparser_m_lib "-lpvpvxparser" +#define rtspbasedpluginselected 1 +#define pv_http_retriever_y_mk "" +#define MODS_pvrtsptunicastforrm_streaming "-lopencore_net_support -lopencore_player -lopencore_common -lpvrtsptunicast_streaming -lopencore_rtsp -lopencore_streaming -lpvwmdrmmd -lpvrealsupportcommon" +#define pvfileplaybackwithpvrfsp_m_lib "" +#define pvdivxdrm_y_lib "" +#define pvmtpconfigclass_link_type "loaded" +#define omx_m4venc_component_imp_m_lib "" +#define pvrmff_recognizer_so_name "" +#define pvdb_recovery_utility_y_lib "" +#define pvmetadata_engine_y_lib "" +#define pvamrffrecognizer_y_lib "" +#define LIBS_omxjointimp_shared "-lomx_mastercore_lib" +#define pvmediaoutputnode_m_mk "/nodes/pvmediaoutputnode/build/make" +#define pvm4vencoder_y_mk "" +#define pvbroadcastwithpvrfsp_m_mk "" +#define LIBDIR_omxjoint_shared "/codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make" +#define pvrmff_recognizer_link_type "loaded" +#define REGISTER_OMX_M4VENC_COMPONENT 1 +#define AGGREGATE_LIBDIRS_pvplayready " " +#define pvpvrff_y_mk "" +#define pvpvrnode_y_mk "" +#define omx_baseclass_y_mk "" +#define AGGREGATE_LIBDIRS_pvfasttrack_downloadreg "" +#define pvrtspunicastwithpvrfsp_m_lib "" +#define pvamrwbdecoder_m_mk "/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make" +#define pvplayready_so_name "" +#define pvplayer_engine_y_mk "" +#define pvamrwbdecoder_y_lib "" +#define pvsqlite_m_lib "" +#define LIBDIR_tools_v2_shared "/modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make /modules/linux_rtsp/smplugins/unicast/core/build/make /modules/linux_rtsp/smplugins/unicast/registry/build/make /modules/linux_rtsp/smplugins/tunneling/core/build/make /modules/linux_rtsp/smplugins/tunneling/registry/build/make /modules/linux_download/core/build/make /modules/linux_download/node_registry/build/make /modules/linux_mp4/core/build/make /modules/linux_mp4/node_registry/build/make /modules/cpm_oma1_passthru/build/make " +#define wmadecoder_y_mk "" +#define WMA_AUDIO_SUPPORT_ENABLED 1 +#define pvmtpip_engine_m_lib "" +#define pvrtsptunicastfsp_y_lib "" +#define protocolenginenode_m_mk "/nodes/pvprotocolenginenode/base/build/make /nodes/pvprotocolenginenode/protocol_common/build/make /nodes/pvprotocolenginenode/download_protocols/common/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make /nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make" +#define pvmedialayernode_y_lib "" +#define pvg726decoder_m_mk "" +#define pvdivxffrecognizer_m_mk "" +#define pvflvffparsernode_m_lib "" +#define pvmp4ffcomposernodeopencore_y_lib "" +#define scsp_y_mk "" +#define pvjitterbufferrtp_m_mk "/nodes/streaming/jitterbuffernode/jitterbuffer/rtp/build/make" +#define pvplayreadyutility_m_mk "" +#define pventropysrc_y_lib "" +#define pvdecoder_gsmamr_y_mk "" +#define pvplayerservice_so_name "" +#define pvmp4ffcomposernode_m_lib "" +#define pvplayready_aggregate_libtype "static" +#define pvloopbacknode_y_mk "" +#define pvfileplaybackwithpvr_streamingreg_so_name "" +#define AGGREGATE_LIBDIRS_pvdivxparser_node " " +#define pvdivxoemsettings_link_type "loaded" +#define pvrmffparser_node_link_type "loaded" +#define pvgsmamrparser_m_lib "-lpvgsmamrparser" +#define omx_mp3_component_m_mk "/codecs_v2/omx/omx_mp3/build/make_multithreaded" +#define MODS_pvflv_recognizer "-lopencore_common" +#define pv_divxfile_parser_m_lib "" +#define omx_mp3_component_m_lib "-lomx_mp3_component_lib" +#define pvaacparser_m_lib "-lpvaacparser" +#define pvwavffparsernode_m_mk "/nodes/pvwavffparsernode/build/make" +#define BUILD_STATIC_FILEPLAYBACK_PVR 0 +#define pvdivxoemsettings_m_lib "" +#define LIBS_omxencimp_static "" +#define MODS_opencore_2way "-lopencore_common" +#define pv_aggregate_libtype "static" +#define rvdecoder_m_lib "" +#define LIBDIR_fileformats_shared "/fileformats/common/parser/build/make /fileformats/id3parcom/build/make /fileformats/pvx/parser/build/make /fileformats/wav/parser/build/make /fileformats/mp3/parser/build/make /fileformats/rawaac/parser/build/make /fileformats/rawgsmamr/parser/build/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/composer/build_opencore/make /fileformats/scsp/build/make /fileformats/audioparser/common/build/make /fileformats/audioparser/amr/build/make /fileformats/audioparser/wav/build/make" +#define omx_queue_m_mk "/codecs_v2/omx/omx_queue/build/make" +#define omx_wmadec_sharedlibrary_aggregate_libtype "static" +#define protocolenginenode_ps_mk "/nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make" +#define pvplayreadyutility_m_lib "" +#define pv_http_parcom_m_mk "/protocols/http_parcom/build/make" +#define pvmshttp_streamingreg_link_type "loaded" +#define LIBDIR_packetsources_shared "" +#define pvrmffparser_node_so_name "" +#define LIBDIR_omxjoint_static " " +#define pv_amr_nb_common_lib_m_lib "-lpv_amr_nb_common_lib" +#define pvmiofileoutput_y_mk "" +#define MODS_opencore_mp4local "-lopencore_common -lopencore_player" +#define AGGREGATE_LIBDIRS_pvmshttp_streamingreg "" +#define pvrtspunicast_streamingreg_link_type "loaded" +#define pvmp3ff_y_lib "" +#define pvrrtspunicastpluginregpopulator_m_lib "" +#define pvmiofileinput_y_lib "" +#define LIBS_fileformats_static " -lpvavifileparser " +#define divxrecognizer_utility_y_mk "" +#define pvmp3ffparsernode_y_mk "" +#define pvavch264enc_y_mk "" +#define pvg726decoder_m_lib "" +#define AGGREGATE_LIBDIRS_pvrmffparser_node " " +#define LIBS_recognizer_shared "-lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer -lpvplsffrecognizer " +#define pvstreamingmanagernode_y_lib "" +#define pvdivxdrm_oem_settings_y_mk "" +#define pvrtsptunicastforrm_streaming_so_name "" +#define unit_test_utils_y_lib "-lunit_test_utils" +#define pvsqlite_y_lib "" +#define AGGREGATE_LIBDIRS_pvdivxdrm " " +#define pvmtpdrmmanagerplugin_m_mk "" +#define opencore_player_so_name "opencore_player" +#define omx_aacenc_sharedlibrary_so_name "" +#define rvdecoder_y_mk "" +#define colorconvert_y_mk "" +#define pvflvreginterface_m_lib "" +#define pv_m3u_parser_m_lib "" +#define pv_m3u_parser_m_mk "" +#define pvoma1ffrecognizer_m_mk "" +#define packetsources_default_y_lib "" +#define DYNAMIC_LOAD_OMX_AACENC_COMPONENT 0 +#define pvplayer_engine_m_lib "-lpvplayer_engine" +#define opencore_rtsp_aggregate_libtype "shared" +#define pvrmffrecognizer_utility_m_lib "" +#define pvdivxffparsernode_m_mk "" +#define pv_avc_mp_decoder_imp_m_lib "" +#define packetsources_default_y_mk "" +#define omx_amrenc_sharedlibrary_so_name "omx_amrenc_sharedlibrary" +#define pv2wayengine_y_mk "" +#define pvmpeg2ff_m_mk "" +#define pvrtspunicast_streaming_so_name "pvrtspunicast_streaming" +#define AGGREGATE_LIBDIRS_omx_avcdec_sharedlibrary "/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/video/avc_h264/dec/build/make " +#define pvmp4ffopencore_y_lib "" +#define omx_m4venc_component_y_lib "" +#define pvrtsptunicast_streaming_link_type "loaded" +#define pvpvrnode_m_lib "" +#define pvpvrff_m_lib "" +#define pvframemetadatautility_y_lib "" +#define omx_avcenc_component_imp_m_mk "" +#define omx_amr_component_y_mk "" +#define divxrecognizer_utility_m_mk "" +#define pvavch264enc_y_lib "" +#define pvclientserversocketnode_m_mk "/nodes/pvclientserversocketnode/build/make" +#define omx_rv_component_imp_m_lib "" +#define LIBDIR_nodes_shared "/nodes/pvfileoutputnode/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvsocketnode/build/make /nodes/pvprotocolenginenode/base/build/make /nodes/pvprotocolenginenode/protocol_common/build/make /nodes/pvprotocolenginenode/download_protocols/common/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make /nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make /nodes/pvwavffparsernode/build/make /nodes/pvomxencnode/build/make /nodes/pvomxbasedecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxvideodecnode/build/make /nodes/pvaacffparsernode/build/make /nodes/pvamrffparsernode/build/make /nodes/pvmp3ffparsernode/build/make /nodes/pvmp4ffparsernode/build_opencore/make /nodes/common/build/make /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvmp4ffcomposernode/build_opencore/make /nodes/pvdownloadmanagernode/build/make /nodes/streaming/streamingmanager/plugins/rtspunicast/build/make /nodes/streaming/streamingmanager/plugins/rtsptunicast/build/make /nodes/streaming/streamingmanager/plugins/common/build/make /nodes/streaming/streamingmanager/build/make /modules/linux_rtsp/smplugins/unicast/core/build/make /modules/linux_rtsp/smplugins/unicast/registry/build/make /modules/linux_rtsp/smplugins/tunneling/core/build/make /modules/linux_rtsp/smplugins/tunneling/registry/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/common/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/rtp/build/make /nodes/streaming/jitterbuffernode/build/make /nodes/pvcommsionode/build/make /nodes/pvclientserversocketnode/build/make /nodes/pvloopbacknode/build/make /nodes/pvcommonparsernode/build/make" +#define pvasfff_y_mk "" +#define getactualaacconfig_for_static_m_lib "" +#define pvmp3ffrecognizer_y_lib "" +#define AGGREGATE_LIBDIRS_pvfasttrack_download " " +#define AGGREGATE_LIBDIRS_pvdivx_recognizer " " +#define pvprotocolenginewmhttpstreamingpluginreginterface_m_mk "" +#define pvclientserversocketnode_m_lib "-lpvclientserversocketnode" +#define pvsqlite_m_mk "" +#define DYNAMIC_LOAD_OMX_MP3_COMPONENT 1 +#define pvavcdecoder_y_mk "" +#define pvrtsptunicastforrm_streamingreg_so_name "" +#define getactualaacconfig_y_lib "" +#define pvoma1passthruplugininterface_m_lib "-lpvoma1passthruplugininterface" +#define wma_common_hdrs_y_mk "" +#define omx_amrenc_component_y_mk "" +#define LIBS_omxjoint_static " " +#define pvmtpconfigclass_so_name "" +#define pvmio_comm_loopback_y_mk "" +#define pvmediaoutputnode_m_lib "-lpvmediaoutputnode" +#define BUILD_STATIC_RTSPUNICAST 0 +#define LIBDIR_audio_static " " +#define pvra8decoder_m_lib "" +#define pvdbconfigclass_so_name "" +#define omx_rv_component_y_lib "" +#define pvmtpip_engine_m_mk "" +#define pvlatmpayloadparser_y_mk "" +#define omx_m4v_component_m_mk "/codecs_v2/omx/omx_m4v/build/make_multithreaded" +#define packetsources_default_plugins " " +#define omx_queue_y_lib "" +#define protocolenginenode_pdl_lib "-lprotocolenginenode_pdl" +#define pvrfileplaybackpluginregpopulator_m_lib "" +#define pvpvr_m_lib "" +#define AGGREGATE_LIBDIRS_pvmtpdrmmanagerplugin "" +#define pvmp4ffcomposernode_y_lib "" +#define pvasxparser_y_mk "" +#define MODS_pvdtcp_mbds "-lopencore_download -lopencore_common" +#define pvmp3ffparsernode_m_mk "/nodes/pvmp3ffparsernode/build/make" +#define pvdivxffrecognizer_y_lib "" +#define pvmp4eu_y_mk "" +#define pvdownloadmanagernode_y_mk "" +#define omx_wmvdec_sharedlibrary_aggregate_libtype "static" +#define omx_sharedlibrary_so_name "omx_sharedlibrary" +#define omx_avc_component_imp_m_mk "" +#define unit_test_m_lib "" +#define MODS_pvasfcommon "-lopencore_common" +#define pvid3parcom_y_mk "" +#define pventropysrc_y_mk "" +#define pvrtsptunicastforrm_streaming_aggregate_libtype "static" +#define opencore_streaming_aggregate_libtype "shared" +#define pvomx_proxy_y_mk "" +#define pvdivxparser_node_link_type "loaded" +#define pvsmreginterface_m_lib "-lpvsmreginterface" +#define DYNAMIC_LOAD_OMX_RA_COMPONENT 0 +#define pvmediainputnode_m_mk "/nodes/pvmediainputnode/build/make_pvauthor" +#define pvoma1lockstream_m_lib "" +#define pvcommsionode_y_lib "" +#define pv_avc_common_lib_y_lib "" +#define pvomxaudiodecnode_y_lib "" +#define pvflvffrecognizer_m_lib "" +#define omx_wma_component_y_mk "" +#define pv_srs_wowhd_y_mk "" +#define omx_baseclass_m_lib "-lomx_baseclass_lib" +#define ss_or_als 0 +#define pvoma1ffrecognizer_y_mk "" +#define pvoma1passthruplugin_m_lib "-lpvoma1passthruplugin" +#define protocolenginenode_download_common_lib "-lprotocolenginenode_download_common" +#define pvwav_y_mk "" +#define pvwav_y_lib "" +#define pv_aac_enc_imp_m_mk "" +#define opencore_mp4localreg_aggregate_libtype "shared" +#define wmavoicedecoder_m_mk "" +#define pvmfrecognizer_y_mk "" +#define pvdbconfiginterface_m_mk "" +#define pvsdpparser_opencore_y_lib "" +#define protocolenginenode_y_lib "" +#define omx_m4venc_sharedlibrary_so_name "omx_m4venc_sharedlibrary" +#define pvmtp_usb_transport_m_mk "" +#define pvfileplaybackwithpvrfsp_y_mk "" +#define pv2waysample_m_lib "-lpv2waysample" +#define pvgeneraltools_m_mk "/protocols/systems/tools/general/build/make" +#define pv_aac_dec_m_mk "/codecs_v2/audio/aac/dec/build/make" +#define omx_aac_component_imp_m_mk "" +#define AGGREGATE_LIBDIRS_pvmshttp_streaming " " +#define pvamrwbdecoder_m_lib "-lpvamrwbdecoder" +#define pv_http_parcom_y_lib "" +#define LIBS_engines_shared "-lpvplayer_engine -lpvauthorengine -lpv2wayengine -lpv2waysample -lpvframemetadatautility -lpvmetadata_engine " +#define omx_mp3dec_sharedlibrary_so_name "omx_mp3dec_sharedlibrary" +#define pvsmfspcommonimp_m_lib "-lpvsmfspcommon" +#define LIBDIR_video_static " " +#define LIBDIR_omxenc_shared "/codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded " +#define opencore_net_support_so_name "opencore_net_support" +#define pvjitterbufferasf_m_mk "" +#define pvdivxdrmplugininterface_m_mk "" +#define LIBS_nodes_static " " +#define pvfileoutputnode_m_lib "-lpvfileoutputnode" +#define MODS_pvfileplaybackwithpvr_streamingreg "-lopencore_common -lopencore_streaming" +#define pvomxvideodecnode_y_lib "" +#define AGGREGATE_LIBDIRS_pvdb_recovery_utility "" +#define AGGREGATE_LIBDIRS_opencore_author " /fileformats/mp4/composer/build_opencore/make /nodes/pvmp4ffcomposernode/build_opencore/make /engines/author/build/make" +#define AGGREGATE_LIBDIRS_opencore_streamingreg "/modules/linux_rtsp/node_registry/build/make" +#define pvmtpip_engine_y_mk "" +#define MODS_omx_sharedlibrary "-lopencore_common" +#define pv_omx_interface_m_mk "/codecs_v2/omx/omx_sharedlibrary/interface/build/make" +#define pvavifileparser_y_lib "-lpvavifileparser" +#define pvrfileplaybackplugininterface_m_mk "" +#define pvoma1passthruplugininterface_m_mk "/modules/cpm_oma1_passthru/build/make" +#define audioparser_m_mk "/fileformats/audioparser/common/build/make" +#define protocolenginenode_ftdl_lib "" +#define LIBDIR_omxdec_shared "/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded " +#define omx_aacenc_component_y_lib "" +#define BUILD_PROGRESSIVE_STREAMING_PLUGIN 1 +#define pvfasttrack_download_so_name "" +#define MODS_pvpvrcommonimpl_streaming "-lopencore_net_support -lopencore_common -lopencore_rtsp -lopencore_streaming" +#define pvmp4decoder_imp_m_mk "" +#define omx_m4v_component_y_mk "" +#define rdt_parser_m_lib "" +#define pvprotocolenginewmhttpstreaminginterface_m_mk "" +#define pvprotocolengine_asfstreaming_aggregate_libtype "static" +#define pvdtcp_mbds_y_mk "" +#define pvloopbacknode_y_lib "" +#define realaudio_deinterleaver_m_lib "" +#define REGISTER_OMX_AMRENC_COMPONENT 1 +#define LIBS_cpm_static " " +#define pvrtsptunicastforrm_streamingreg_link_type "loaded" +#define rtprtcp_m_lib "-lrtprtcp" +#define pvdbmanager_m_lib "" +#define WMA_VOICE_SUPPORT_ENABLED 1 +#define pvmpeg2ff_y_lib "" +#define pv_smooth_streaming_y_lib "" +#define omx_mastercore_y_mk "" +#define omx_mp3dec_sharedlibrary_aggregate_libtype "shared" +#define pvmp4ffcomposer_m_mk "" +#define pvasflocalpbreginterface_m_mk "" +#define pvasflocalpbinterface_m_lib "" +#define omx_avcenc_sharedlibrary_aggregate_libtype "shared" +#define pvdivx_recognizer_link_type "loaded" +#define AGGREGATE_LIBDIRS_pvrtspunicast_streamingreg "/modules/linux_rtsp/smplugins/unicast/registry/build/make" +#define pvasfffrecognizer_y_mk "" +#define opencore_mp4local_aggregate_libtype "shared" +#define pvplayer_engine_m_mk "/engines/player/build/make" +#define LIBDIR_engines_static " " +#define LIBDIR_pvmi_static " /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make " +#define pv324m_common_headers_y_mk "" +#define AGGREGATE_LIBDIRS_omx_sharedlibrary "/codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_sharedlibrary/interface/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make" +#define pvwmdrmmd_y_mk "" +#define omx_ra_component_y_lib "" +#define pvrmffrecognizer_utility_y_lib "" +#define AGGREGATE_LIBDIRS_pvmtpconfigclass "" +#define pvrtppacketsourcenode_m_lib "" +#define pvrtspunicastfsp_y_lib "" +#define pvprotocolengine_asfstreamingreg_so_name "" +#define oscllib_mk "/oscl/oscl/oscllib/build/make" +#define asfrecognizer_utility_m_lib "" +#define threadsafe_callback_ao_y_lib "" +#define MODS_pvrtspbroadcastwithpvr_streamingreg "-lopencore_common -lopencore_streaming" +#define protocolenginenode_y_mk "" +#define REGISTER_OMX_H263ENC_COMPONENT 1 +#define omx_baseclass_m_mk "/codecs_v2/omx/omx_baseclass/build/make" +#define pvdtcp_mbds_aggregate_libtype "static" +#define MODS_pviptransport "-lopencore_common" +#define AGGREGATE_LIBDIRS_omx_avcenc_sharedlibrary "/codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/video/avc_h264/enc/build/make" +#define pv_avc_mp_decoder_m_mk "" +#define pvrtsptunicastforrm_streaming_link_type "loaded" +#define LIBS_baselibs_static " " +#define pvgendatastruct_y_lib "" +#define pv_config_parser_m_lib "-lpv_config_parser" +#define pvmpeg2local_so_name "" +#define pvmedialayernode_y_mk "" +#define pvdbmanager_y_mk "" +#define pvmtp_engine_y_lib "" +#define omx_avcenc_sharedlibrary_link_type "loaded" +#define opencore_common_so_name "opencore_common" +#define pv_divxfile_parser_y_mk "" +#define smmshttppluginregpopulator_m_lib "" +#define omx_mp3_component_y_mk "" +#define TARGET_aggregate " opencore_common omx_sharedlibrary omx_avcdec_sharedlibrary omx_m4vdec_sharedlibrary omx_aacdec_sharedlibrary omx_amrdec_sharedlibrary omx_mp3dec_sharedlibrary omx_avcenc_sharedlibrary omx_m4venc_sharedlibrary omx_amrenc_sharedlibrary opencore_net_support opencore_player opencore_downloadreg opencore_download opencore_streamingreg opencore_streaming opencore_mp4localreg opencore_mp4local pvoma1passthru opencore_rtsp pvrtspunicast_streaming pvrtspunicast_streamingreg pvrtsptunicast_streaming pvrtsptunicast_streamingreg opencore_author opencore_2way opencore_pvme" +#define rdt_parser_y_mk "" +#define pvmpeg2localreg_aggregate_libtype "static" +#define REGISTER_OMX_AVCENC_COMPONENT 1 +#define pvamrwbdecoder_y_mk "" +#define pvrmffparsernode_y_lib "" +#define pvmp4ffparsernodeopencore_y_mk "" +#define pvmp4ffopencore_y_mk "" +#define realmedia_payload_parser_m_mk "" +#define colorconvert_y_lib "" +#define pvmp4ffopencore_m_mk "/fileformats/mp4/parser/build_opencore/make" +#define pvencoder_gsmamr_m_lib "-lpvencoder_gsmamr" +#define pvra8decoder_m_mk "" +#define rfc_2429_mk "rfc_2429.mk" +#define pvdbconfigclass_aggregate_libtype "static" +#define omx_sharedlibrary_link_type "loaded" +#define MODS_pvrtspunicastwithpvr_streaming "-lopencore_net_support -lopencore_player -lopencore_common -lpvpvrcommonimpl_streaming -lopencore_rtsp -lopencore_streaming" +#define omx_aacdec_sharedlibrary_so_name "omx_aacdec_sharedlibrary" +#define pv_so_name "" +#define pvrmffrecognizer_m_mk "" +#define pvavch264enc_imp_m_mk "" +#define pvgeneraltools_m_lib "-lpvgeneraltools" +#define LIBS_omxjoint_shared "-lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface" +#define pviptransport_so_name "" +#define pvdivxoemsettings_m_mk "" +#define cpm_y_lib "" +#define pvplsffrecognizer_y_lib "" +#define MODS_pvrtsptunicastforrm_streamingreg "-lopencore_common -lopencore_streaming" +#define pvdivxdrmplugin_m_lib "" +#define omx_rvdec_sharedlibrary_link_type "loaded" +#define wmadecoder_imp_m_mk "" +#define MODS_opencore_downloadreg "-lopencore_common" +#define pvmp3ffrecognizer_m_mk "/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make" +#define omx_sharedlibrary_aggregate_libtype "shared" +#define protocolenginenode_asfstreaming_lib "" +#define pvmtp_engine_m_lib "" +#define pvdivxinterface_m_lib "" +#define MODS_omx_aacenc_sharedlibrary "-lomx_sharedlibrary -lopencore_common " +#define LIBS_omxjointimp_static "" +#define amrparser_m_mk "/fileformats/audioparser/amr/build/make" +#define pvdivx_recognizer_so_name "" +#define omx_m4v_component_imp_m_lib "" +#define pvmp4ffcomposeropencore_y_mk "" +#define pvrtspbroadcastwithpvr_streamingreg_aggregate_libtype "static" +#define pvdivxffparsernode_m_lib "" +#define AGGREGATE_LIBDIRS_omx_wmvdec_sharedlibrary " " +#define pv_srs_wowhd_y_lib "" +#define engines_common_headers_y_mk "" +#define pvmp4ffparsernode_y_lib "" +#define pvmioaviwavfileinput_m_mk "" +#define pvdb_so_name "" +#define pvmpeg2ffparsernode_y_mk "" +#define pvloopbacknode_m_lib "-lpvloopbacknode" +#define pvrbroadcastplugininterface_m_mk "" +#define pvmpeg2local_link_type "loaded" +#define protocolenginenode_segments_lib "-lprotocolenginenode_base -lprotocolenginenode_common -lprotocolenginenode_download_common -lprotocolenginenode_pdl -lprotocolenginenode_ps -lprotocolenginenode_shoutcast" +#define pvmf_m_lib "-lpvmf" +#define pvrealsupportcommon_aggregate_libtype "static" +#define pvdtcpplugin_m_lib "" +#define MODS_pvflvparser_node "-lpvflv_recognizer -lopencore_player -lopencore_common" +#define pvmp4eu_so_name "" +#define pvasfffparsernode_y_lib "" +#define LIBS_recognizer_static " " +#define omx_rvdec_sharedlibrary_so_name "" +#define opencore_streaming_so_name "opencore_streaming" +#define pvmp4ffrecognizer_y_lib "" +#define flvrecognizer_utility_m_lib "" +#define LIBS_packetsources_shared "" +#define omx_rv_component_m_mk "" +#define pviptransport_y_mk "" +#define pvomxbasedecnode_m_mk "/nodes/pvomxbasedecnode/build/make" +#define pvmp3_m_mk "/codecs_v2/audio/mp3/dec/build/make" +#define LIBS_codecs_utilities_static " " +#define LIBDIR_omxjointimp_shared "/codecs_v2/omx/omx_mastercore/build/make_multithreaded" +#define unit_test_y_lib "-lunit_test" +#define pvrbroadcastpluginregpopulator_m_lib "" +#define omx_ra_component_imp_m_mk "" +#define omx_m4venc_component_m_mk "/codecs_v2/omx/omx_m4venc/build/make_multithreaded" +#define MODS_opencore_streamingreg "-lopencore_common" +#define unit_test_m_mk "" +#define pvomxaudiodecnode_m_mk "/nodes/pvomxaudiodecnode/build/make" +#define pvprotocolenginefasttrackdownloadinterface_m_lib "" +#define MODS_pvrtspunicastwithpvr_streamingreg "-lopencore_common -lopencore_streaming" +#define omx_common_m_mk "/codecs_v2/omx/omx_common/build/make_multithreaded" +#define pvrtsptunicast_streamingreg_aggregate_libtype "shared" +#define REGISTER_OMX_AACENC_COMPONENT 0 +#define pvdivxffparsernode_y_mk "" +#define pvmediadatastruct_m_mk "/baselibs/media_data_structures/build/make" +#define pvsminterface_m_lib "-lpvsminterface" +#define MODS_omx_amrenc_sharedlibrary "-lomx_sharedlibrary -lopencore_common " +#define pvmp4ffparsernode_m_lib "" +#define pvfileparserutils_y_lib "" +#define MODS_pvmtpip "-lopencore_common -lpvdb" +#define omx_avcdec_sharedlibrary_link_type "loaded" +#define MODS_opencore_common "" +#define pvflvff_m_lib "" +#define pvcrypto_m_lib "" +#define pvplayready_link_type "loaded" +#define pvdivxoemsettings_aggregate_libtype "static" +#define pvmpeg2local_aggregate_libtype "static" +#define pvmpeg2ffrecognizer_y_mk "" +#define pvrmff_m_mk "" +// +// That's all, folks! diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pv_config_derived.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pv_config_derived.mk new file mode 100644 index 0000000..89320e6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pv_config_derived.mk @@ -0,0 +1,1520 @@ +# +# Derived symbols +# +pvfasttrack_download_link_type="loaded" +MODS_pvrtspunicast_streaming="-lopencore_net_support -lopencore_player -lopencore_common -lopencore_rtsp -lopencore_streaming" +pvtinyxml_m_lib="" +protocolenginenode_shoutcast_lib="-lprotocolenginenode_shoutcast" +pvstillimagenode_y_mk="" +pvmedialayernode_m_mk="" +pvpvr_y_mk="" +LIBDIR_engines_shared="/engines/player/build/make /engines/author/build/make /engines/2way/build/make /engines/2way/sample_app/pv2waysample/build/make /engines/common/build/make /engines/adapters/player/framemetadatautility/build/make /engines/pvme/build/make " +LIBDIR_oscl_static=" /oscl/unit_test/build/make /oscl/unit_test_utils/build/make" +pvsqlite_aggregate_libtype="static" +opencore_author_aggregate_libtype="shared" +pvrmffparser_m_lib="" +pvm4vencoder_m_mk="/codecs_v2/video/m4v_h263/enc/build/make" +pvrtsptunicastforrm_streamingreg_aggregate_libtype="static" +pvframemetadatautility_m_mk="/engines/adapters/player/framemetadatautility/build/make" +pvmf_m_mk="/pvmi/pvmf/build/make" +pvrtsp_cli_eng_real_cloaking_node_y_mk="" +opencore_downloadreg_so_name="opencore_downloadreg" +pvasflocalpb_link_type="loaded" +LIBS_codecs_v2_static=" " +pvmp3ffrecognizer_m_lib="-lpvmp3ffrecognizer" +pvmediainputnode_m_lib="-lpvmediainputnode" +pvmp4ff_m_mk="" +pvmshttpfsp_m_mk="" +pvrtsptunicast_streaming_so_name="pvrtsptunicast_streaming" +pvavifileparser_y_mk="/fileformats/avi/parser/build/make" +pvprotocolenginenode_wmhttpstreaming_plugin_m_lib="" +pvasflocalpbreg_so_name="" +pvasflocalpb_aggregate_libtype="static" +pv_avc_common_lib_y_mk="" +pvavcdecoder_m_mk="/codecs_v2/video/avc_h264/dec/build/make" +LIBDIR_extern_libs_shared=" " +opencore_streamingreg_so_name="opencore_streamingreg" +wmadecoder_m_lib="" +pv_amr_nb_common_lib_y_lib="" +AGGREGATE_LIBDIRS_pvrmff_recognizer=" " +pvmpeg2interface_m_lib="" +cpm_m_mk="/pvmi/content_policy_manager/build/make" +pvpvrcommonimp_y_mk="" +pvcommonparsernode_m_mk="/nodes/pvcommonparsernode/build/make" +pviptransport_aggregate_libtype="static" +pvmtp_engine_m_mk="" +realaudio_deinterleaver_y_lib="" +MODS_pvfasttrack_downloadreg="-lopencore_common -lopencore_net_support" +omx_amr_component_imp_m_lib="" +pvframemetadatautility_y_mk="" +WMA_BUILD_CFG_ALL_ENABLED=1 +sdp_common_m_mk="/protocols/sdp/common/build/make" +pvavcdecoder_m_lib="-lpvavcdecoder" +pvrtspbroadcastwithpvr_streaming_aggregate_libtype="static" +pviptransport_y_lib="" +pvdtcpplugin_m_mk="" +pvsdpparser_y_lib="" +pvrtspunicastfsp_m_mk="/nodes/streaming/streamingmanager/plugins/rtspunicast/build/make" +pvrfileplaybackpluginregpopulator_m_mk="" +pvasfcommon_aggregate_libtype="static" +pvmpeg2ffrecognizer_y_lib="" +pvrtsp_cli_eng_real_cloaking_node_m_lib="" +mpeg2recognizer_utility_y_mk="" +pvmp4ffcomposer_y_lib="" +MODS_pvdivxoemsettings="-lopencore_common" +pvdecoder_gsmamr_m_mk="/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make" +pvrtppacketsourcenode_y_lib="" +gsm_amr_headers_m_mk="/codecs_v2/audio/gsm_amr/common/dec/build/make" +pvrtspunicastfsp_m_lib="-lpvrtspunicaststreamingmanager" +pvmetadata_engine_m_lib="-lpvmetadata_engine" +pvasfcommon_so_name="" +pvmp3ffrecognizer_y_mk="" +WMA_BUILD_CFG_STDPROLBR_ENABLED=0 +pvwmdrmoemsettingsinterface_m_mk="" +LIBDIR_pvmi_shared="/pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make /pvmi/content_policy_manager/plugins/common/build/make /pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmio_comm_loopback/build/make /pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /pvmi/recognizer/plugins/pvplsffrecognizer/build/make /pvmi/pvmf/build/make " +csprng_y_mk="" +pvdivxffparsernode_y_lib="" +pv_rtmp_parcom_y_lib="" +AGGREGATE_LIBDIRS_pvrtsptunicast_streamingreg="/modules/linux_rtsp/smplugins/tunneling/registry/build/make" +pvprotocolenginenode_ftdl_plugin_m_lib="" +rdt_parser_y_lib="" +MODS_pvrtspbroadcastwithpvr_streaming="-lopencore_net_support -lopencore_player -lopencore_common -lpvpvrcommonimpl_streaming -lopencore_rtsp -lopencore_streaming" +pvmp4ff_y_lib="" +pvamrffparsernode_y_mk="" +pvmshttpfsp_y_mk="" +amrparser_y_mk="" +LIBS_omxenc_static=" " +pvstreamingmanagernode_y_mk="" +smmshttpplugininterface_m_lib="" +MODS_pvdb="-lopencore_player -lopencore_common -lpvsqlite -lpvasfcommon -lpvasflocalpbreg -lopencore_pvme" +DYNAMIC_LOAD_OMX_WMV_COMPONENT=0 +pvrtsptunicast_streaming_aggregate_libtype="shared" +pvmtp_usb_transport_m_lib="" +MODS_pvdivxdrm="-lopencore_common" +pv_aac_enc_y_mk="" +opencore_mp4local_link_type="loaded" +pvjitterbufferasf_y_mk="" +pvrrtspunicastplugininterface_m_lib="" +AGGREGATE_LIBDIRS_pvasflocalpb=" " +pvomxbasedecnode_y_mk="" +nodes_common_headers_y_mk="" +omx_wmvdec_sharedlibrary_link_type="loaded" +pvbroadcastwithpvrfsp_y_lib="" +pvflvparser_node_so_name="" +pvaudiotrackmio_m_mk="" +MODS_omx_mp3dec_sharedlibrary="-lomx_sharedlibrary -lopencore_common" +pvplayer_engine_y_lib="" +pvcommonparsernode_m_lib="-lpvcommonparsernode" +pvrtsp_cli_eng_node_m_mk="/protocols/rtsp_client_engine/build/make_segments" +standard_bcast_ps_mk="" +pv2waysample_m_mk="/engines/2way/sample_app/pv2waysample/build/make" +pvid3parcom_y_lib="" +twoway_config="2way_basic" +pv324m_y_mk="" +pvmp4ffrecognizer_y_mk="" +pvsmreginterface_m_mk="/modules/linux_rtsp/node_registry/build/make" +LIBDIR_omxencimp_shared="" +pvflvparser_node_aggregate_libtype="static" +smrtsptpluginregpopulator_m_lib="-lpvrtsptsmpluginreginterface" +pvmshttp_streamingreg_aggregate_libtype="static" +pvdownloadinterface_m_mk="/modules/linux_download/core/build/make" +pvoma1passthruplugin_y_lib="" +pvthreadmessaging_y_mk="" +AGGREGATE_LIBDIRS_pvrtspbroadcastwithpvr_streamingreg="" +pvmfrecognizer_m_mk="/pvmi/recognizer/build/make" +AGGREGATE_LIBDIRS_pvdb="" +LIBS_omxdecimp_shared="" +pvmtpconfigclass_aggregate_libtype="static" +omx_aacenc_component_m_lib="" +pvjitterbufferasf_y_lib="" +pvrtspunicastwithpvr_streaming_aggregate_libtype="static" +pvjitterbuffercommon_y_lib="" +AGGREGATE_LIBDIRS_opencore_download="/nodes/pvdownloadmanagernode/build/make /modules/linux_download/core/build/make" +pvmedialayernode_m_lib="" +pvclientserversocketnode_y_mk="" +pvdownloadmanagernode_y_lib="" +opencore_common_link_type="linked" +pvmshttpfsp_y_lib="" +omx_amr_component_imp_m_mk="" +pvgeneraltools_y_lib="" +pv_avc_common_imp_lib_m_lib="" +pvdivxffrecognizer_y_mk="" +pvdbmanager_m_mk="" +penode_any_selected=y +wavparser_y_mk="" +USE_LOADABLE_MODULES=1 +pviptransport_m_lib="" +pvrmffparser_m_mk="" +protocolenginenode_asfstreaming_mk="" +pvdb_aggregate_libtype="static" +pvrmff_y_mk="" +pvmp4ffcomposernode_y_mk="" +pvgendatastruct_m_mk="/baselibs/gen_data_structures/build/make" +pv_aac_dec_m_lib="-lpv_aac_dec" +pvsocketnode_y_mk="" +DYNAMIC_LOAD_OMX_RV_COMPONENT=0 +MODS_pvasflocalpb="-lopencore_player -lopencore_common -lpvasfcommon" +pv_config_parser_m_mk="/codecs_v2/utilities/pv_config_parser/build/make" +pv_amr_nb_common_imp_lib_m_lib="" +pvwmdrmoemsettings_so_name="" +pvpvrcommonimpl_streaming_aggregate_libtype="static" +AGGREGATE_LIBDIRS_omx_m4vdec_sharedlibrary="/codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/video/m4v_h263/dec/build/make" +pvmimeutils_m_lib="-lpvmimeutils" +pv_rtmp_parcom_m_mk="" +AGGREGATE_LIBDIRS_opencore_downloadreg="/modules/linux_download/node_registry/build/make" +download_common_enabled=y +AGGREGATE_LIBDIRS_opencore_mp4localreg="/modules/linux_mp4/node_registry/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make" +pvthreadmessaging_m_lib="-lpvthreadmessaging" +pvrtspunicastwithpvrfsp_y_mk="" +pvmiofileinput_m_lib="-lpvmiofileinput" +mpeg2recognizer_utility_y_lib="" +omx_avcenc_sharedlibrary_so_name="omx_avcenc_sharedlibrary" +pvwmdrmmd_m_mk="" +rtppayloadparser_plugins_opencore_rtsp="rfc_2429.mk rfc_3016.mk rfc_3267.mk rfc_3640.mk rfc_3984.mk" +omx_common_y_lib="" +pvpvrff_m_mk="" +pvpvrnode_m_mk="" +gsm_amr_headers_y_mk="" +AGGREGATE_LIBDIRS_pvmp4eu=" " +pvmp3_imp_m_lib="" +LIBDIR_cpm_shared="/pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make /pvmi/content_policy_manager/plugins/common/build/make " +threadsafe_callback_ao_y_mk="" +MODS_opencore_pvme="-lopencore_player -lopencore_common" +WMA_BUILD_CFG_STDPROSTEREOLBR_ENABLED=0 +csprng_y_lib="" +LIBS_oscl_shared="-loscllib -lpvlogger -losclregcli -losclregserv -losclutil -losclproc -losclio -losclmemory -losclerror -losclbase " +pvframemetadatautility_m_lib="-lpvframemetadatautility" +omx_mastercore_y_lib="" +pvmfrecognizer_y_lib="" +rtppayloadparser_m_mk="/protocols/rtp_payload_parser/build/make" +flvrecognizer_utility_y_lib="" +pvjitterbuffercommon_m_mk="/nodes/streaming/jitterbuffernode/jitterbuffer/common/build/make" +pvsdpparser_m_lib="" +pvflvreginterface_m_mk="" +rtprtcp_m_mk="/protocols/rtp/build/make" +pvstillimagenode_m_lib="" +BUILD_FASTTRACK_DOWNLOAD_PLUGIN=0 +pvg726decoder_y_lib="" +MODS_omx_amrdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common" +csprng_m_mk="" +LIBS_video_static=" " +opencore_common_aggregate_libtype="shared" +omx_avc_component_y_mk="" +pvdbmanager_y_lib="" +pvasxparser_m_lib="" +threadsafe_callback_ao_m_mk="/baselibs/threadsafe_callback_ao/build/make" +BUILD_STATIC_RTSPT=0 +pv_srs_wowhd_m_mk="" +pvdivxdrm_m_lib="" +pvamrffparsernode_m_lib="-lpvamrffparsernode" +pvflvinterface_m_lib="" +pvprotocolengine_asfstreamingreg_aggregate_libtype="static" +pvmp4ffcomposer_y_mk="" +LIBS_nodes_shared="-lpvfileoutputnode -lpvmediaoutputnode -lpvsocketnode -lprotocolenginenode_base -lprotocolenginenode_common -lprotocolenginenode_download_common -lprotocolenginenode_pdl -lprotocolenginenode_ps -lprotocolenginenode_shoutcast -lpvwavffparsernode -lpvomxencnode -lpvomxbasedecnode -lpvomxaudiodecnode -lpvomxvideodecnode -lpvaacffparsernode -lpvamrffparsernode -lpvmp3ffparsernode -lpvmp4ffparsernode -lpvmediainputnode -lpvmp4ffcomposernode -lpvdownloadmanagernode -lpvrtspunicaststreamingmanager -lpvrtsptunicaststreamingmanager -lpvsmfspcommon -lpvstreamingmanagernode -lpvrtspsmplugininterface -lpvrtspsmpluginreginterface -lpvrtsptsmplugininterface -lpvrtsptsmpluginreginterface -lpvjitterbuffer -lpvjitterbufferrtp -lpvjitterbuffernode -lpvcommsionode -lpvclientserversocketnode -lpvloopbacknode -lpvcommonparsernode" +pvloopbacknode_m_mk="/nodes/pvloopbacknode/build/make" +pvjitterbuffernode_m_mk="/nodes/streaming/jitterbuffernode/build/make" +pvmio_comm_loopback_y_lib="" +AGGREGATE_LIBDIRS_omx_amrenc_sharedlibrary="/codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make" +omx_aac_component_y_mk="" +omx_ra_component_y_mk="" +pvavcdecoder_y_lib="" +pvdb_recovery_utility_y_mk="" +pv_rtsp_parcom_m_lib="-lpv_rtsp_parcom" +pvrtsptunicastfsp_m_mk="/nodes/streaming/streamingmanager/plugins/rtsptunicast/build/make" +pventropysrc_m_mk="" +pvra8decoder_imp_m_lib="" +smrtspunicastpluginregpopulator_m_mk="/modules/linux_rtsp/smplugins/unicast/registry/build/make" +AGGREGATE_LIBDIRS_pvasflocalpbreg=" " +pvdecoder_gsmamr_y_lib="" +omx_amrdec_sharedlibrary_so_name="omx_amrdec_sharedlibrary" +pvoma1lockstream_m_mk="" +pvmpeg2interface_m_mk="" +pv_amr_nb_common_lib_y_mk="" +cpm_headers_m_mk="/pvmi/content_policy_manager/plugins/common/build/make" +pvmp4ffrecognizer_m_mk="/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make" +pvrtsp_cli_eng_node_y_mk="" +pvmioaviwavfileinput_y_mk="/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make" +pvmp3_y_mk="" +pvasflocalpb_so_name="" +pvmp4decoder_y_lib="" +pv324m_m_mk="/protocols/systems/3g-324m_pvterminal/build/make/" +omx_mp3_component_y_lib="" +oscl_y_mk="" +pv_http_parcom_y_mk="" +LIBS_shared="-loscllib -lpvlogger -losclregcli -losclregserv -losclutil -losclproc -losclio -losclmemory -losclerror -losclbase -lpvgendatastruct -lpvmediadatastruct -lpvmimeutils -lthreadsafe_callback_ao -lpvthreadmessaging -lomx_avc_component_lib -lomx_m4v_component_lib -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib -lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib -lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3 -lpvencoder_gsmamr -lpv_avc_common_lib -lpvavcdecoder -lpvmp4decoder -lpvm4vencoder -lpvavch264enc -lm4v_config -lpv_config_parser -lcolorconvert -lpvfileparserutils -lpvid3parcom -lpvpvxparser -lpvwav -lpvmp3ff -lpvaacparser -lpvgsmamrparser -lmp4recognizer_utility -lpvmp4ff -lpvmp4ffcomposer -lscsp -laudioparser -lamrparser -lwavparser -lpv_http_parcom -lpvlatmpayloadparser -lpvsdpparser -lpv_rtsp_parcom -lpvrtsp_cli_eng_node -lrtppayloadparser -lrtprtcp -lpv324m -lpvgeneraltools -lcpm -lpvoma1passthruplugin -lpvmiofileoutput -lpvmiofileinput -lpvmio_comm_loopback -lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer -lpvplsffrecognizer -lpvmf -lpvfileoutputnode -lpvmediaoutputnode -lpvsocketnode -lprotocolenginenode_base -lprotocolenginenode_common -lprotocolenginenode_download_common -lprotocolenginenode_pdl -lprotocolenginenode_ps -lprotocolenginenode_shoutcast -lpvwavffparsernode -lpvomxencnode -lpvomxbasedecnode -lpvomxaudiodecnode -lpvomxvideodecnode -lpvaacffparsernode -lpvamrffparsernode -lpvmp3ffparsernode -lpvmp4ffparsernode -lpvmediainputnode -lpvmp4ffcomposernode -lpvdownloadmanagernode -lpvrtspunicaststreamingmanager -lpvrtsptunicaststreamingmanager -lpvsmfspcommon -lpvstreamingmanagernode -lpvrtspsmplugininterface -lpvrtspsmpluginreginterface -lpvrtsptsmplugininterface -lpvrtsptsmpluginreginterface -lpvjitterbuffer -lpvjitterbufferrtp -lpvjitterbuffernode -lpvcommsionode -lpvclientserversocketnode -lpvloopbacknode -lpvcommonparsernode -lpvplayer_engine -lpvauthorengine -lpv2wayengine -lpv2waysample -lpvframemetadatautility -lpvmetadata_engine -lpvsminterface -lpvsmreginterface -lpvrtspsmplugininterface -lpvrtspsmpluginreginterface -lpvrtsptsmplugininterface -lpvrtsptsmpluginreginterface -lpvdownloadinterface -lpvdownloadreginterface -lpvmp4interface -lpvmp4reginterface -lpvoma1passthruplugininterface " +pvmp4eu_aggregate_libtype="static" +rtppayloadparser_plugins="rfc_2429.mk rfc_3016.mk rfc_3267.mk rfc_3640.mk rfc_3984.mk" +omx_aacenc_component_y_mk="" +pvsdpparser_y_mk="" +pvfileoutputnode_y_lib="" +AGGREGATE_LIBDIRS_pvfileplaybackwithpvr_streamingreg="" +pvamrwbdecoder_imp_m_mk="" +pvmf_y_mk="" +pvwavffrecognizer_y_mk="" +pvtinyxml_m_mk="" +LIBS_protocols_shared="-lpv_http_parcom -lpvlatmpayloadparser -lpvsdpparser -lpv_rtsp_parcom -lpvrtsp_cli_eng_node -lrtppayloadparser -lrtprtcp -lpv324m -lpvgeneraltools " +DYNAMIC_LOAD_OMX_WMA_COMPONENT=0 +realaudio_deinterleaver_y_mk="" +pvjitterbufferrtp_y_mk="" +pvomxencnode_m_mk="/nodes/pvomxencnode/build/make" +pv_rtmp_parcom_m_lib="" +pvfileparserutils_m_mk="/fileformats/common/parser/build/make" +pvoma1passthru_aggregate_libtype="shared" +pvrtspunicast_streamingreg_aggregate_libtype="shared" +secure_data_format_m_lib="" +pvcommsionode_y_mk="" +pvmp4ffcomposeropencore_m_lib="-lpvmp4ffcomposer" +nodes_common_headers_m_mk="/nodes/common/build/make" +omx_avc_component_imp_m_lib="" +wmavoicedecoder_imp_m_mk="" +pvoma1lockstream_y_lib="" +LIBDIR_protocols_shared="/protocols/http_parcom/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make /protocols/rtsp_parcom/build/make /protocols/rtsp_client_engine/build/make_segments /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make " +pvdivxdrmplugin_y_mk="" +pvmfrecognizer_m_lib="-lpvmfrecognizer" +pvencoder_gsmamr_y_mk="" +pvoma1ffrecognizer_y_lib="" +wmadecoder_m_mk="" +AGGREGATE_LIBDIRS_pvmpeg2localreg=" " +omx_rv_component_m_lib="" +wmvdecoder_y_lib="" +pvpvr_m_mk="" +pvrtsptwithrealfsp_y_lib="" +pvomx_proxy_m_lib="-lpvomx_proxy_lib" +omx_wma_component_m_mk="" +pvrtsptwithrealfsp_m_mk="" +wmavoicedecoder_m_lib="" +pvdivxdrm_oem_settings_m_mk="" +pv_avc_mp_decoder_imp_m_mk="" +pvmp3_imp_m_mk="" +secure_data_format_m_mk="" +rfc_3984_mk="rfc_3984.mk" +pvpvr_y_lib="" +pv2wayengine_y_lib="" +omx_aacenc_component_imp_m_lib="" +pv_aac_enc_m_lib="" +pvdivxdrm_y_mk="" +REGISTER_OMX_AAC_COMPONENT=1 +pvwavffparsernode_m_lib="-lpvwavffparsernode" +AGGREGATE_LIBDIRS_pvdivxoemsettings="" +rtppayloadparser_m_lib="-lrtppayloadparser" +DYNAMIC_LOAD_OMX_M4V_COMPONENT=1 +MODS_omx_avcenc_sharedlibrary="-lomx_sharedlibrary -lopencore_common " +pvaacparser_m_mk="/fileformats/rawaac/parser/build/make" +pvgsmamrparser_y_mk="" +opencore_download_link_type="loaded" +pvfileplaybackwithpvrfsp_y_lib="" +pvdivxdrm_oem_settings_m_lib="" +pvavcdecoder_imp_m_lib="" +pvmediadatastruct_y_lib="" +pvmshttp_streaming_link_type="loaded" +pvmpeg2ff_m_lib="" +LIBDIR_codecs_v2_static=" " +pvstillimagenode_m_mk="" +MODS_omx_m4vdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common " +AGGREGATE_LIBDIRS_omx_m4venc_sharedlibrary="/codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/video/m4v_h263/enc/build/make" +pvmp4ff_m_lib="" +rvdecoder_y_lib="" +pvbroadcastwithpvrfsp_y_mk="" +getaacaudioinfo_y_mk="" +pvauthorengine_y_mk="" +pvasflocalpbreg_link_type="loaded" +omx_avc_component_y_lib="" +omx_m4vdec_sharedlibrary_link_type="loaded" +pvplayreadyplugin_y_mk="" +pvmiofileoutput_m_lib="-lpvmiofileoutput" +pvmediadatastruct_m_lib="-lpvmediadatastruct" +MODS_pvwmdrmoemsettings="-lopencore_common" +opencore_downloadreg_link_type="loaded" +flvrecognizer_utility_m_mk="" +AGGREGATE_LIBDIRS_pvrtspbroadcastwithpvr_streaming=" " +MODS_pvmpeg2localreg="-lopencore_player -lopencore_common" +pvprotocolenginewmhttpstreaminginterface_m_lib="" +unit_test_utils_m_mk="" +omx_rvdec_sharedlibrary_aggregate_libtype="static" +pvrtppacketsourcenode_y_mk="" +wmavoicedecoder_y_lib="" +pvbroadcastwithpvrfsp_m_lib="" +opencore_download_so_name="opencore_download" +omx_avc_component_m_lib="-lomx_avc_component_lib" +pvaacffparsernode_y_mk="" +pvmp3ffparsernode_m_lib="-lpvmp3ffparsernode" +USING_OMX=1 +wmvdecoder_m_lib="" +pvdtcp_mbds_so_m_mk="" +BUILD_APPLE_HTTP_STREAMING_PLUGIN=0 +mp4recognizer_utility_y_mk="" +REGISTER_OMX_H263_COMPONENT=1 +pvmp4reginterface_m_lib="-lpvmp4reginterface" +pv324m_m_lib="-lpv324m" +pvpvrnode_y_lib="" +pvpvrff_y_lib="" +pvrtsptunicast_streamingreg_link_type="loaded" +pvmp4eu_y_lib="" +getactualaacconfig_imp_m_mk="/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make" +pv2wayengine_m_mk="/engines/2way/build/make" +rvdecoder_imp_m_lib="" +getactualaacconfig_for_static_m_mk="" +sdp_parser_mksegment_default="" +omx_wmv_component_y_mk="" +LIBS_video_shared="-lpv_avc_common_lib -lpvavcdecoder -lpvmp4decoder -lpvm4vencoder -lpvavch264enc" +pvmiofileinput_y_mk="" +pvplayreadyplugin_m_lib="" +omx_queue_y_mk="" +pvpvrcommonimp_m_mk="" +pvfileplaybackwithpvrfsp_m_mk="" +DYNAMIC_LOAD_OMX_AMRENC_COMPONENT=1 +omx_wma_component_imp_m_mk="" +pvflvff_y_mk="" +opencore_mp4local_so_name="opencore_mp4local" +pvwmdrmmd_aggregate_libtype="static" +omx_amrdec_sharedlibrary_link_type="loaded" +AGGREGATE_LIBDIRS_pvrtspunicast_streaming="/nodes/streaming/streamingmanager/plugins/rtspunicast/build/make /modules/linux_rtsp/smplugins/unicast/core/build/make" +MODS_pvsqlite="-lopencore_common" +omx_wma_component_m_lib="" +pv_avc_mp_decoder_y_mk="" +MODS_pvmtp="-lopencore_common -lpvdb" +pvgendatastruct_m_lib="-lpvgendatastruct" +pvjitterbuffercommon_y_mk="" +BUILD_STATIC_RTSPT_REALMEDIA=0 +audioparser_y_lib="" +LIBS_omxenc_shared="-lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib " +pvjitterbuffernode_y_mk="" +MODS_pvdivx_recognizer="-lopencore_common" +pvencoder_gsmamr_y_lib="" +smrtsptrmpluginregpopulator_m_mk="" +omx_amrenc_component_m_mk="/codecs_v2/omx/omx_amrenc/build/make_multithreaded" +pvprotocolenginewmhttpstreamingpluginreginterface_m_lib="" +sdp_parser_mksegment_opencore="sdp_opencore.mk" +scsp_m_lib="-lscsp" +BUILD_STATIC_RTSP_UNICAST_PVR=0 +smmshttpplugininterface_m_mk="" +getaacaudioinfo_y_lib="" +pvauthorengine_y_lib="" +AGGREGATE_LIBDIRS_omx_rvdec_sharedlibrary=" " +omx_amrenc_component_m_lib="-lomx_amrenc_component_lib" +pvfileparserutils_y_mk="" +AGGREGATE_LIBDIRS_opencore_streaming="/nodes/streaming/streamingmanager/build/make /nodes/streaming/streamingmanager/plugins/common/build/make /modules/linux_rtsp/core/build/make" +pv_aac_dec_y_mk="" +pvmimeutils_y_lib="" +pvrtsp_cli_eng_playlist_node_y_mk="" +AGGREGATE_LIBDIRS_pvdtcp_mbds=" " +g726decnode_m_mk="" +pvdtcp_mbds_m_mk="" +mp4recognizer_utility_m_lib="-lmp4recognizer_utility" +MODS_opencore_download="-lopencore_net_support -lopencore_player -lopencore_common" +pvoma1passthru_link_type="loaded" +pvrtspunicast_streamingreg_so_name="pvrtspunicast_streamingreg" +pv_divxfile_parser_y_lib="" +omx_avcenc_component_m_lib="-lomx_avcenc_component_lib" +omx_m4v_component_y_lib="" +MODS_opencore_mp4localreg="-lopencore_player -lopencore_common" +AGGREGATE_LIBDIRS_pvrtsptunicastforrm_streaming=" " +pvomxbasedecnode_m_lib="-lpvomxbasedecnode" +pvmpeg2reginterface_m_lib="" +AGGREGATE_LIBDIRS_pvmtpip="" +m4v_config_m_mk="/codecs_v2/utilities/m4v_config_parser/build/make" +pvdivxreginterface_m_lib="" +pvrtspunicastwithpvrfsp_m_mk="" +asfrecognizer_utility_y_mk="" +LIBDIR_codecs_v2_shared="/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make /codecs_v2/video/m4v_h263/dec/build/make /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make" +MODS_opencore_player="-lopencore_common -lopencore_net_support" +omx_amrenc_component_imp_m_mk="" +pvdecoder_gsmamr_m_lib="-lpvdecoder_gsmamr" +pvfileoutputnode_y_mk="" +wavparser_m_lib="-lwavparser" +pvmp4ffcomposeropencore_m_mk="/fileformats/mp4/composer/build_opencore/make" +pvrtsp_cli_eng_playlist_node_y_lib="" +MODS_pvprotocolengine_asfstreamingreg="-lopencore_common -lopencore_net_support" +pvtinyxml_y_lib="" +pvamrffrecognizer_y_mk="" +pventropysrc_m_lib="" +smrtspunicastplugininterface_m_lib="-lpvrtspsmplugininterface" +LIBDIR_baselibs_shared=" /baselibs/gen_data_structures/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/thread_messaging/build/make " +AGGREGATE_LIBDIRS_pvdbconfigclass="" +pvaacffrecognizer_y_lib="" +LIBS_omxencimp_shared="" +MODS_pvwmdrmmd="-lopencore_common" +pvdivxffrecognizer_m_lib="" +omx_avc_component_lib_plugins="omx_avc_dec_plugin.mk" +pvmp4ffopencore_m_lib="-lpvmp4ff" +pvprotocolenginefasttrackdownloadpluginreginterface_m_lib="" +sdp_common_y_mk="" +AGGREGATE_LIBDIRS_opencore_2way="/engines/2way/sample_app/pv2waysample/build/make /engines/2way/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /nodes/pvclientserversocketnode/build/make /nodes/pvcommsionode/build/make /pvmi/media_io/pvmio_comm_loopback/build/make /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make " +omx_amrenc_sharedlibrary_link_type="loaded" +pvmtpip_so_name="" +pvavifileparser_m_mk="" +pvrtsp_cli_eng_real_cloaking_node_y_lib="" +pvaacparser_y_mk="" +LIBS_extern_libs_shared=" " +MODS_pvfileplaybackwithpvr_streaming="-lopencore_net_support -lopencore_player -lopencore_common -lpvpvrcommonimpl_streaming -lopencore_rtsp -lopencore_streaming" +getactualaacconfig_m_mk="/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make" +pvmp3ff_y_mk="" +pv_aac_dec_imp_m_lib="" +rfc_3016_mk="rfc_3016.mk" +pvasxparser_y_lib="" +pvmimeutils_y_mk="" +pvwavffrecognizer_m_lib="-lpvwavffrecognizer" +pvrtsp_cli_eng_node_y_lib="" +pvencoder_gsmamr_imp_m_lib="" +smrtsptplugininterface_m_lib="-lpvrtsptsmplugininterface" +pvdtcp_mbds_so_m_lib="" +pvmpeg2ffparsernode_y_lib="" +smrtsptrmpluginregpopulator_m_lib="" +omx_amr_component_y_lib="" +pvomxvideodecnode_m_lib="-lpvomxvideodecnode" +protocolenginenode_shoutcast_mk="/nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make" +REGISTER_OMX_RV_COMPONENT=0 +pvgeneraltools_y_mk="" +pvrealsupportcommon_so_name="" +omx_radec_sharedlibrary_aggregate_libtype="static" +omx_aacdec_sharedlibrary_aggregate_libtype="shared" +pvjitterbufferasf_m_lib="" +pvasxparser_m_mk="" +omx_m4venc_component_imp_m_mk="" +scsp_m_mk="/fileformats/scsp/build/make" +pvavcdecoder_imp_m_mk="" +pvdownloadinterface_m_lib="-lpvdownloadinterface" +pvwmdrmmd_m_lib="" +omx_queue_m_lib="-lomx_queue_lib" +MODS_opencore_streaming="-lopencore_net_support -lopencore_player -lopencore_common" +pvoma1passthru_so_name="pvoma1passthru" +amrparser_m_lib="-lamrparser" +omx_aac_component_y_lib="" +pvoma1lockstream_y_mk="" +pvplayreadyutility_y_lib="" +getaacaudioinfo_m_lib="" +pvauthorengine_m_lib="-lpvauthorengine" +pvdtcpplugin_y_lib="" +pvmediaoutputnode_y_lib="" +pvpvrcommonimpl_streaming_so_name="" +pvwavffparsernode_y_lib="" +DYNAMIC_LOAD_OMX_M4VENC_COMPONENT=1 +AGGREGATE_LIBDIRS_opencore_pvme="/engines/pvme/build/make" +AGGREGATE_LIBDIRS_omx_radec_sharedlibrary=" " +LIBDIR_omxdec_static=" " +MODS_omx_wmvdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common" +pvrtsptunicast_streamingregreg_so_name="pvrtsptunicast_streamingreg" +pvdtcp_mbds_m_lib="" +pvrrtspunicastpluginregpopulator_m_mk="" +pvwavffrecognizer_m_mk="/pvmi/recognizer/plugins/pvwavffrecognizer/build/make" +pvasfff_y_lib="" +pvjitterbuffernode_m_lib="-lpvjitterbuffernode" +pvwavffrecognizer_y_lib="" +MODS_pvdb_recovery_utility="-lopencore_common -lpvdb" +USE_OLD_WMA_DECODER=0 +AGGREGATE_LIBDIRS_pvplayerservice="/engines/player/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvfileoutputnode/build/make /nodes/pvwavffparsernode/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /fileformats/wav/parser/build/make /nodes/pvmp3ffparsernode/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /fileformats/mp3/parser/build/make /nodes/pvmp4ffparsernode/build_opencore/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /nodes/pvaacffparsernode/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /fileformats/rawaac/parser/build/make /nodes/pvamrffparsernode/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /fileformats/rawgsmamr/parser/build/make /pvmi/recognizer/build/make /nodes/pvcommonparsernode/build/make /fileformats/audioparser/common/build/make /fileformats/audioparser/amr/build/make /fileformats/audioparser/wav/build/make /pvmi/content_policy_manager/build/make /fileformats/scsp/build/make /fileformats/common/parser/build/make /fileformats/id3parcom/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxbasedecnode/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /protocols/rtp_payload_parser/util/build/latmparser/make /fileformats/scsp/build/make /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make /codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make /codecs_v2/utilities/colorconvert/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/mp3/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/media_data_structures/build/make /baselibs/gen_data_structures/build/make /pvmi/pvmf/build/make /baselibs/pv_mime_utils/build/make /codecs_v2/audio/gsm_amr/common/dec/build/make /nodes/common/build/make /engines/common/build/make /pvmi/content_policy_manager/plugins/common/build/make /oscl " +pvomx_proxy_m_mk="/codecs_v2/omx/omx_proxy/build/make" +pvra8decoder_imp_m_mk="" +pvrtsptunicastfsp_y_mk="" +unit_test_utils_m_lib="" +pvdecoder_gsmamr_imp_m_mk="" +pvomxencnode_m_lib="-lpvomxencnode" +pv_smooth_streaming_m_mk="" +pvsdpparser_m_mk="/protocols/sdp/parser/build/make" +pvsqlite_y_mk="" +pvmp4interface_m_lib="-lpvmp4interface" +pv_aac_enc_y_lib="" +pvrtspunicast_streaming_aggregate_libtype="shared" +MODS_pv="" +pvmpeg2ffrecognizer_m_mk="" +LIBS_audio_static=" " +pvsmfspcommonimp_m_mk="/nodes/streaming/streamingmanager/plugins/common/build/make" +pvrtsp_cli_eng_node_m_lib="-lpvrtsp_cli_eng_node" +pvavch264enc_m_mk="/codecs_v2/video/avc_h264/enc/build/make" +pvplayreadyplugin_y_lib="" +pvm4vencoder_y_lib="" +LIBDIR_omxenc_static=" " +asf_payload_parser_y_lib="" +pvrtsptwithrealfsp_y_mk="" +rtppayloadparser_y_mk="" +pvid3parcom_m_mk="/fileformats/id3parcom/build/make" +opencore_author_so_name="opencore_author" +pvdownloadreginterface_m_mk="/modules/linux_download/node_registry/build/make" +AGGREGATE_LIBDIRS_pvwmdrmoemsettings="" +omx_amr_component_m_mk="/codecs_v2/omx/omx_amr/build/make_multithreaded" +MODS_pvrmff_recognizer="-lopencore_common" +pvcrypto_m_mk="" +pvplayreadyplugininterface_m_lib="" +AGGREGATE_LIBDIRS_opencore_player=" /pvmi/content_policy_manager/build/make /fileformats/pvx/parser/build/make /fileformats/id3parcom/build/make /nodes/pvamrffparsernode/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /pvmi/recognizer/plugins/pvplsffrecognizer/build/make /fileformats/mp3/parser/build/make /nodes/pvmp3ffparsernode/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/rawaac/parser/build/make /nodes/pvaacffparsernode/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /nodes/pvwavffparsernode/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /nodes/pvcommonparsernode/build/make /fileformats/audioparser/common/build/make /fileformats/audioparser/amr/build/make /fileformats/audioparser/wav/build/make /pvmi/recognizer/build/make /engines/adapters/player/framemetadatautility/build/make /engines/player/build/make" +pvfasttrack_downloadreg_so_name="" +pvfileplaybackwithpvr_streaming_aggregate_libtype="static" +pvrtspunicastwithpvr_streamingreg_aggregate_libtype="static" +MODS_pvmtpdrmmanagerplugin="-lopencore_common -lpvwmdrmmd" +pvflvffparsernode_m_mk="" +pvmpeg2ff_y_mk="" +pvaacffparsernode_m_lib="-lpvaacffparsernode" +pvprotocolenginenode_wmhttpstreaming_plugin_m_mk="" +MODS_pvplayready="-lopencore_common -lpvwmdrmmd" +pvjitterbufferrtp_y_lib="" +pvomxencnode_y_mk="" +AGGREGATE_LIBDIRS_opencore_common="/oscl /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/audio/gsm_amr/common/dec/build/make /fileformats/rawgsmamr/parser/build/make /codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/gen_data_structures/build/make /pvmi/pvmf/build/make /nodes/pvfileoutputnode/build/make /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvomxencnode/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /baselibs/thread_messaging/build/make /pvmi/media_io/pvmiofileoutput/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvomxvideodecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxbasedecnode/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /fileformats/wav/parser/build/make /fileformats/common/parser/build/make /fileformats/scsp/build/make /nodes/common/build/make /engines/common/build/make /pvmi/content_policy_manager/plugins/common/build/make" +pvflvffrecognizer_y_mk="" +omx_wmv_component_imp_m_mk="" +pvmtp_so_name="" +MODS_pvdbconfigclass="-lopencore_common" +pvmpeg2reginterface_m_mk="" +pvrtspunicastfsp_y_mk="" +pvrtppacketsourcenode_m_mk="" +omx_common_y_mk="" +MODS_omx_avcdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common" +BUILD_PROGRESSIVE_DOWNLOAD_PLUGIN=1 +pvasfffrecognizer_m_mk="" +pvfileplaybackwithpvr_streamingreg_aggregate_libtype="static" +pvlatmpayloadparser_y_lib="" +pvg726decoder_y_mk="" +pvmp4ffparsernode_m_mk="" +wmavoicedecoder_y_mk="" +pvmp4eu_m_lib="" +pvpvxparser_y_mk="" +pv_m3u_parser_y_lib="" +rfc_3640_mk="rfc_3640.mk" +pv_rtmp_parcom_y_mk="" +omx_m4venc_component_m_lib="-lomx_m4venc_component_lib" +pvmp4ffcomposernodeopencore_m_lib="-lpvmp4ffcomposernode" +rfc_3267_mk="rfc_3267.mk" +LIBS_media_io_shared="-lpvmiofileoutput -lpvmiofileinput -lpvmio_comm_loopback" +LIBS_audio_shared=" -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3 -lpvencoder_gsmamr " +MODS_pvfasttrack_download="-lopencore_net_support -lopencore_common" +pvrmffrecognizer_y_lib="" +pvrrtspunicastplugininterface_m_mk="" +omx_amrdec_sharedlibrary_aggregate_libtype="shared" +pvplsffrecognizer_m_lib="-lpvplsffrecognizer" +audioparser_y_mk="" +pvmioaviwavfileinput_y_lib="-lpvmioaviwavfileinput" +pvfasttrack_downloadreg_link_type="loaded" +pvrtsp_cli_eng_real_cloaking_node_m_mk="" +WMA_BUILD_CFG_STD_ENABLED=0 +pvdb_recovery_utility_m_lib="" +pvsminterface_m_mk="/modules/linux_rtsp/core/build/make" +omx_avcenc_component_m_mk="/codecs_v2/omx/omx_h264enc/build/make_multithreaded" +omx_avcenc_component_imp_m_lib="" +pvmp4ffcomposernodeopencore_y_mk="" +wmavoicedecoder_imp_m_lib="" +pvsocketnode_m_lib="-lpvsocketnode" +pvgsmamrparser_m_mk="/fileformats/rawgsmamr/parser/build/make" +pvprotocolengine_asfstreamingreg_link_type="loaded" +rvdecoder_m_mk="" +pvmp4ffparsernodeopencore_m_mk="/nodes/pvmp4ffparsernode/build_opencore/make" +pvmtpdrmmanagerplugin_aggregate_libtype="static" +MODS_pvmshttp_streamingreg="-lopencore_common -lopencore_streaming" +pv324m_common_headers_m_mk="/protocols/systems/common/build/make/" +pvrtspunicastwithpvrfsp_y_lib="" +MODS_pvoma1passthru="-lopencore_player -lopencore_common" +REGISTER_OMX_MP3_COMPONENT=1 +asf_payload_parser_m_lib="" +LIBS_omxdec_shared="-lomx_avc_component_lib -lomx_m4v_component_lib -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib " +pvmp4interface_m_mk="/modules/linux_mp4/core/build/make" +REGISTER_OMX_AVC_COMPONENT=1 +pv_m3u_parser_y_mk="" +pvaacffparsernode_y_lib="" +protocolenginenode_ftdl_mk="" +omx_mp3_component_imp_m_mk="" +pvasfffparsernode_m_mk="" +m4v_config_y_lib="" +pvmp4ffparsernodeopencore_m_lib="-lpvmp4ffparsernode" +realmedia_payload_parser_y_lib="" +AGGREGATE_LIBDIRS_opencore_net_support="/nodes/pvsocketnode/build/make /protocols/http_parcom/build/make /nodes/pvprotocolenginenode/base/build/make /nodes/pvprotocolenginenode/protocol_common/build/make /nodes/pvprotocolenginenode/download_protocols/common/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make /nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/common/build/make /nodes/streaming/jitterbuffernode/build/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make /protocols/rtp/build/make" +pvavch264enc_m_lib="-lpvavch264enc" +AGGREGATE_LIBDIRS_opencore_mp4local="/modules/linux_mp4/core/build/make /nodes/pvmp4ffparsernode/build_opencore/make" +pvwmdrmoemsettingsinterface_m_lib="" +pvwavffparsernode_y_mk="" +pvdivxoemsettings_so_name="" +BUILD_STATIC_RTSP_BROADCAST_PVR=0 +pvplsffrecognizer_y_mk="" +pvrtspunicastwithpvr_streamingreg_so_name="" +omx_wmv_component_m_lib="" +pvwmdrmmd_y_lib="" +unit_test_utils_y_mk="/oscl/unit_test_utils/build/make" +AGGREGATE_LIBDIRS_pvoma1passthru="/pvmi/content_policy_manager/plugins/oma1/passthru/build/make /modules/cpm_oma1_passthru/build/make" +pvaacffrecognizer_m_mk="/pvmi/recognizer/plugins/pvaacffrecognizer/build/make" +pvrtsptunicastfsp_m_lib="-lpvrtsptunicaststreamingmanager" +pvrtspunicast_streaming_link_type="loaded" +omx_amr_component_m_lib="-lomx_amr_component_lib" +LIBDIR_omxdecimp_static="" +pvcommsionode_m_lib="-lpvcommsionode" +pvmiofileoutput_m_mk="/pvmi/media_io/pvmiofileoutput/build/make" +BUILD_RTMPSTREAMING_PLUGIN=0 +pvmediainputnode_y_lib="" +omx_aac_component_m_mk="/codecs_v2/omx/omx_aac/build/make_multithreaded" +omx_ra_component_m_mk="" +BUILD_STATIC_MSHTTP_ASF=0 +AGGREGATE_LIBDIRS_pvwmdrmmd=" " +pv_aac_dec_y_lib="" +pvgsmamrparser_y_lib="" +pvoma1ffrecognizer_m_lib="" +pvdb_recovery_utility_so_name="" +protocolenginenode_pdl_mk="/nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make" +rtprtcp_y_lib="" +pvasfffparsernode_m_lib="" +secure_data_format_y_mk="" +LIBDIR_shared="/oscl /baselibs/gen_data_structures/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/thread_messaging/build/make /codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make /codecs_v2/video/m4v_h263/dec/build/make /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make /fileformats/common/parser/build/make /fileformats/id3parcom/build/make /fileformats/pvx/parser/build/make /fileformats/wav/parser/build/make /fileformats/mp3/parser/build/make /fileformats/rawaac/parser/build/make /fileformats/rawgsmamr/parser/build/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/composer/build_opencore/make /fileformats/scsp/build/make /fileformats/audioparser/common/build/make /fileformats/audioparser/amr/build/make /fileformats/audioparser/wav/build/make /protocols/http_parcom/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make /protocols/rtsp_parcom/build/make /protocols/rtsp_client_engine/build/make_segments /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make /pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make /pvmi/content_policy_manager/plugins/common/build/make /pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmio_comm_loopback/build/make /pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /pvmi/recognizer/plugins/pvplsffrecognizer/build/make /pvmi/pvmf/build/make /nodes/pvfileoutputnode/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvsocketnode/build/make /nodes/pvprotocolenginenode/base/build/make /nodes/pvprotocolenginenode/protocol_common/build/make /nodes/pvprotocolenginenode/download_protocols/common/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make /nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make /nodes/pvwavffparsernode/build/make /nodes/pvomxencnode/build/make /nodes/pvomxbasedecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxvideodecnode/build/make /nodes/pvaacffparsernode/build/make /nodes/pvamrffparsernode/build/make /nodes/pvmp3ffparsernode/build/make /nodes/pvmp4ffparsernode/build_opencore/make /nodes/common/build/make /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvmp4ffcomposernode/build_opencore/make /nodes/pvdownloadmanagernode/build/make /nodes/streaming/streamingmanager/plugins/rtspunicast/build/make /nodes/streaming/streamingmanager/plugins/rtsptunicast/build/make /nodes/streaming/streamingmanager/plugins/common/build/make /nodes/streaming/streamingmanager/build/make /modules/linux_rtsp/smplugins/unicast/core/build/make /modules/linux_rtsp/smplugins/unicast/registry/build/make /modules/linux_rtsp/smplugins/tunneling/core/build/make /modules/linux_rtsp/smplugins/tunneling/registry/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/common/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/rtp/build/make /nodes/streaming/jitterbuffernode/build/make /nodes/pvcommsionode/build/make /nodes/pvclientserversocketnode/build/make /nodes/pvloopbacknode/build/make /nodes/pvcommonparsernode/build/make /engines/player/build/make /engines/author/build/make /engines/2way/build/make /engines/2way/sample_app/pv2waysample/build/make /engines/common/build/make /engines/adapters/player/framemetadatautility/build/make /engines/pvme/build/make /modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make /modules/linux_rtsp/smplugins/unicast/core/build/make /modules/linux_rtsp/smplugins/unicast/registry/build/make /modules/linux_rtsp/smplugins/tunneling/core/build/make /modules/linux_rtsp/smplugins/tunneling/registry/build/make /modules/linux_download/core/build/make /modules/linux_download/node_registry/build/make /modules/linux_mp4/core/build/make /modules/linux_mp4/node_registry/build/make /modules/cpm_oma1_passthru/build/make " +omx_aac_component_imp_m_lib="" +omx_ra_component_imp_m_lib="" +divxrecognizer_utility_y_lib="" +protocolenginenode_ps_lib="-lprotocolenginenode_ps" +pvsmfspcommonimp_y_mk="" +pvmp3ffparsernode_y_lib="" +pvdivxinterface_m_mk="" +MODS_pvdivxparser_node="-lpvdivx_recognizer -lopencore_player -lopencore_common" +omx_wmadec_sharedlibrary_so_name="" +omx_ra_component_m_lib="" +omx_aac_component_m_lib="-lomx_aac_component_lib" +wmadecoderlibpath="/codecs_v2/audio/wma/dec/build/make" +pvmtpip_engine_y_lib="" +pvmp4decoder_m_lib="-lpvmp4decoder" +pvrmffparser_y_mk="" +opencore_player_aggregate_libtype="shared" +scsp_y_lib="" +pvrfileplaybackplugininterface_m_lib="" +omx_avcenc_component_y_mk="" +optimized_bcast_ps_mk="" +wmadecoder_y_lib="" +oscllib_lib="-loscllib" +pvclientserversocketnode_y_lib="" +pvrmff_m_lib="" +DYNAMIC_LOAD_OMX_AMR_COMPONENT=1 +pvavch264enc_imp_m_lib="" +pvasfff_m_lib="" +LIBS_omxdec_static=" " +DYNAMIC_LOAD_OMX_AVCENC_COMPONENT=1 +AVC_MP_DECODER_ENABLED=0 +REGISTER_OMX_WMA_COMPONENT=0 +pv_http_parcom_m_lib="-lpv_http_parcom" +pvrbroadcastpluginregpopulator_m_mk="" +pv_rtsp_parcom_m_mk="/protocols/rtsp_parcom/build/make" +pvoma1passthruplugin_m_mk="/pvmi/content_policy_manager/plugins/oma1/passthru/build/make" +omx_wma_component_y_lib="" +pvrmffrecognizer_utility_m_mk="" +csprng_m_lib="" +smrtsptplugininterface_m_mk="/modules/linux_rtsp/smplugins/tunneling/core/build/make" +LIBS_fileformats_shared="-lpvfileparserutils -lpvid3parcom -lpvpvxparser -lpvwav -lpvmp3ff -lpvaacparser -lpvgsmamrparser -lmp4recognizer_utility -lpvmp4ff -lpvmp4ffcomposer -lscsp -laudioparser -lamrparser -lwavparser" +pvwmdrmoemsettings_aggregate_libtype="static" +LIBS_engines_static=" " +pv_smooth_streaming_y_mk="" +pvmp3_m_lib="-lpvmp3" +opencore_download_aggregate_libtype="shared" +pvsdpparser_plugins=" sdp_opencore.mk" +pvmimeutils_m_mk="/baselibs/pv_mime_utils/build/make" +AGGREGATE_LIBDIRS_pvprotocolengine_asfstreamingreg="" +protocolenginenode_segments_mk="/nodes/pvprotocolenginenode/base/build/make /nodes/pvprotocolenginenode/protocol_common/build/make /nodes/pvprotocolenginenode/download_protocols/common/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make /nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make" +omx_mp3dec_sharedlibrary_link_type="loaded" +pvsqlite_so_name="" +asf_payload_parser_m_mk="" +pv_http_retriever_y_lib="" +pvamrwbdecoder_imp_m_lib="" +oscl_m_lib="-lpvlogger -losclregcli -losclregserv -losclutil -losclproc -losclio -losclmemory -losclerror -losclbase" +pvasfffrecognizer_y_lib="" +pvmediainputnode_y_mk="" +pvdivxreginterface_m_mk="" +omx_common_m_lib="-lomx_common_lib" +pvprotocolenginefasttrackdownloadinterface_m_mk="" +pvwav_m_mk="/fileformats/wav/parser/build/make" +omx_m4venc_sharedlibrary_link_type="loaded" +pvrmffinterface_m_mk="" +pvflvffrecognizer_m_mk="" +AGGREGATE_LIBDIRS_pvrtspunicastwithpvr_streamingreg="" +pvmp4ffcomposeropencore_y_lib="" +pvmp4ffparsernodeopencore_y_lib="" +LIBS_baselibs_shared=" -lpvgendatastruct -lpvmediadatastruct -lpvmimeutils -lthreadsafe_callback_ao -lpvthreadmessaging " +pvfileparserutils_m_lib="-lpvfileparserutils" +pvmshttp_streamingreg_so_name="" +pvlatmpayloadparser_m_mk="/protocols/rtp_payload_parser/util/build/latmparser/make" +pvid3parcom_m_lib="-lpvid3parcom" +pvdivxdrmplugininterface_m_lib="" +LIBDIR_fileformats_static=" /fileformats/avi/parser/build/make " +LIBS_cpm_shared="-lcpm -lpvoma1passthruplugin " +secure_data_format_y_lib="" +omx_m4venc_sharedlibrary_aggregate_libtype="shared" +LIBS_pvmi_static=" -lpvmioaviwavfileinput " +pv_amr_nb_common_lib_m_mk="/codecs_v2/audio/gsm_amr/amr_nb/common/build/make" +pvcrypto_y_lib="" +AGGREGATE_LIBDIRS_pvasfcommon=" " +LIBDIR_cpm_static=" " +opencore_pvme_so_name="opencore_pvme" +LIBDIR_omxjointimp_static="" +pvjitterbuffernode_y_lib="" +pvdownloadmanagernode_m_mk="/nodes/pvdownloadmanagernode/build/make" +pviptransport_m_mk="" +pvmediaoutputnode_y_mk="" +MODS_omx_aacdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common" +AGGREGATE_LIBDIRS_pvpvrcommonimpl_streaming="" +LIBS_packetsources_static="" +pvstreamingmanagernode_m_lib="-lpvstreamingmanagernode" +opencore_net_support_aggregate_libtype="shared" +pvfasttrack_downloadreg_aggregate_libtype="static" +pv_http_retriever_m_lib="" +opencore_mp4localreg_link_type="loaded" +AGGREGATE_LIBDIRS_pvmpeg2local=" " +LIBDIR_omxdecimp_shared="" +pvmio_comm_loopback_m_mk="/pvmi/media_io/pvmio_comm_loopback/build/make" +opencore_streamingreg_aggregate_libtype="shared" +pvlatmpayloadparser_m_lib="-lpvlatmpayloadparser" +pv2wayengine_m_lib="-lpv2wayengine" +pvamrffrecognizer_m_lib="-lpvamrffrecognizer" +omx_wmv_component_m_mk="" +pvflvffrecognizer_y_lib="" +smrtsptpluginregpopulator_m_mk="/modules/linux_rtsp/smplugins/tunneling/registry/build/make" +AGGREGATE_LIBDIRS_omx_aacenc_sharedlibrary=" " +LIBS_codecs_v2_shared="-lomx_avc_component_lib -lomx_m4v_component_lib -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib -lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib -lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3 -lpvencoder_gsmamr -lpv_avc_common_lib -lpvavcdecoder -lpvmp4decoder -lpvm4vencoder -lpvavch264enc -lm4v_config -lpv_config_parser -lcolorconvert" +opencore_pvme_aggregate_libtype="shared" +opencore_downloadreg_aggregate_libtype="shared" +pvdecoder_gsmamr_imp_m_lib="" +pvasflocalpbreg_aggregate_libtype="static" +pvdivxdrm_oem_settings_y_lib="" +omx_mastercore_m_mk="/codecs_v2/omx/omx_mastercore/build/make_multithreaded" +pvdivxparser_node_so_name="" +pvplayerservice_aggregate_libtype="static" +pvprotocolenginenode_ftdl_plugin_m_mk="" +omx_avc_component_m_mk="/codecs_v2/omx/omx_h264/build/make_multithreaded" +omx_aacenc_sharedlibrary_aggregate_libtype="static" +getactualaacconfig_imp_m_lib="-lgetactualaacconfig" +pvencoder_gsmamr_imp_m_mk="" +LIBDIR_recognizer_static=" " +MODS_pvmpeg2local="-lopencore_common -lopencore_player -lpvmpeg2localreg" +cpm_m_lib="-lcpm" +pvrmff_recognizer_aggregate_libtype="static" +MODS_opencore_author="-lopencore_common" +wmvdecoder_imp_m_mk="" +pvdivxdrm_aggregate_libtype="static" +pvamrffparsernode_y_lib="" +pvmioaviwavfileinput_m_lib="" +pv324m_plugins="default_support.mk" +MODS_omx_wmadec_sharedlibrary="-lomx_sharedlibrary -lopencore_common" +divxrecognizer_utility_m_lib="" +LIBDIR_recognizer_shared="/pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /pvmi/recognizer/plugins/pvplsffrecognizer/build/make " +REGISTER_OMX_WMV_COMPONENT=0 +omx_m4v_component_m_lib="-lomx_m4v_component_lib" +pvmpeg2ffparsernode_m_lib="" +pvomxbasedecnode_y_lib="" +MODS_pvrtsptunicast_streaming="-lopencore_net_support -lopencore_player -lopencore_common -lopencore_rtsp -lopencore_streaming" +pvsocketnode_m_mk="/nodes/pvsocketnode/build/make" +omx_avcdec_sharedlibrary_so_name="omx_avcdec_sharedlibrary" +pvdivx_recognizer_aggregate_libtype="static" +pvdownloadmanagernode_m_lib="-lpvdownloadmanagernode" +amrparser_y_lib="" +packetsources_default_m_mk="" +pvrtspbroadcastwithpvr_streamingreg_so_name="" +pvmp4ffrecognizer_m_lib="-lpvmp4ffrecognizer" +pvprotocolenginefasttrackdownloadpluginreginterface_m_mk="" +pv2waysample_y_lib="" +smrtsptrmplugininterface_m_lib="" +pvmp4ffcomposer_m_lib="" +pvflv_recognizer_aggregate_libtype="static" +pvrtspbroadcastwithpvr_streaming_so_name="" +rdt_parser_m_mk="" +WMA_BUILD_CFG_STDPROSTEREOLBRV1_ENABLED=0 +pvencoder_gsmamr_m_mk="/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make" +pv_rtsp_parcom_y_mk="" +opencore_streamingreg_link_type="loaded" +pvmio_comm_loopback_m_lib="-lpvmio_comm_loopback" +omx_wmv_component_y_lib="" +smrtspunicastpluginregpopulator_m_lib="-lpvrtspsmpluginreginterface" +pvcommonparsernode_y_lib="" +omx_m4vdec_sharedlibrary_so_name="omx_m4vdec_sharedlibrary" +LIBDIR_media_io_static=" /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make " +pvplayreadyutility_y_mk="" +pvrtspunicastwithpvr_streaming_so_name="" +AGGREGATE_LIBDIRS_omx_mp3dec_sharedlibrary="/codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/audio/mp3/dec/build/make" +AGGREGATE_LIBDIRS_pvrealsupportcommon="" +g726decnode_y_lib="" +pvasflocalpbinterface_m_mk="" +MODS_omx_rvdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common" +pvmp4decoder_m_mk="/codecs_v2/video/m4v_h263/dec/build/make" +pvmp4ffparsernode_y_mk="" +omx_aacenc_sharedlibrary_link_type="loaded" +pvdtcp_mbds_so_name="" +pvmpeg2localreg_so_name="" +BUILD_SMOOTHSTREAMING_PLUGIN=0 +omx_aacenc_component_m_mk="" +pv_http_retriever_m_mk="" +LIBDIR_protocols_static=" " +pvtinyxml_y_mk="" +LIBDIR_codecs_utilities_shared="/codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make" +AGGREGATE_LIBDIRS_pvprotocolengine_asfstreaming=" " +pvflvffparsernode_y_mk="" +pvdbconfigclass_link_type="loaded" +rtspbasedpluginselected_y_config=n +pv_avc_common_lib_m_lib="-lpv_avc_common_lib" +pvrmffreginterface_m_lib="" +AGGREGATE_LIBDIRS_pvflv_recognizer=" " +pvrmffparsernode_y_mk="" +LIBS_extern_libs_static=" " +pvmp3ff_m_lib="-lpvmp3ff" +AGGREGATE_LIBDIRS_pviptransport="" +pvdivxparser_node_aggregate_libtype="static" +LIBDIR_extern_libs_static=" " +pvmp3_y_lib="" +pvdivxdrmplugin_m_mk="" +protocolenginenode_base_lib="-lprotocolenginenode_base" +pvaacparser_y_lib="" +pvmpeg2ffparsernode_m_mk="" +omx_rv_component_imp_m_mk="" +MODS_opencore_rtsp="-lopencore_net_support -lopencore_player -lopencore_common" +pvdb_recovery_utility_aggregate_libtype="static" +REGISTER_OMX_AMR_COMPONENT=1 +pvmtp_aggregate_libtype="static" +BUILD_WMHTTPSTREAMING_PLUGIN=0 +MODS_pvrtspunicast_streamingreg="-lopencore_common -lopencore_streaming" +omx_aacdec_sharedlibrary_link_type="loaded" +omx_radec_sharedlibrary_link_type="loaded" +pv_avc_common_imp_lib_m_mk="" +engines_common_headers_m_mk="/engines/common/build/make" +pvoma1passthruplugin_y_mk="" +pvdivxdrm_so_name="" +pvdivxdrm_m_mk="" +pvflvff_y_lib="" +LIBDIR_omxencimp_static="" +pvrmffreginterface_m_mk="" +LIBDIR_packetsources_static="" +omx_amrenc_sharedlibrary_aggregate_libtype="shared" +MODS_omx_m4venc_sharedlibrary="-lomx_sharedlibrary -lopencore_common " +pvjitterbufferrtp_m_lib="-lpvjitterbufferrtp" +pvmp4ff_y_mk="" +pvmp4ffcomposernode_m_mk="" +LIBDIR_oscl_shared="/oscl " +realmedia_payload_parser_m_lib="" +AGGREGATE_LIBDIRS_pvfileplaybackwithpvr_streaming=" " +cpm_headers_y_mk="" +audioparser_m_lib="-laudioparser" +pv_aac_dec_imp_m_mk="" +omx_wmv_component_imp_m_lib="" +DYNAMIC_LOAD_OMX_H263ENC_COMPONENT=1 +omx_m4v_component_imp_m_mk="" +protocolenginenode_common_mk="/nodes/pvprotocolenginenode/protocol_common/build/make" +LIBDIR_media_io_shared="/pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmio_comm_loopback/build/make" +pvflvinterface_m_mk="" +pvamrffparsernode_m_mk="/nodes/pvamrffparsernode/build/make" +pvmpeg2localreg_link_type="loaded" +pvasfffparsernode_y_mk="" +pv_avc_common_lib_m_mk="/codecs_v2/video/avc_h264/common/build/make" +pv_aac_dec_plugins="aacdec_util.mk" +pv_srs_wowhd_m_lib="" +pvfileplaybackwithpvr_streaming_so_name="" +realmedia_payload_parser_y_mk="" +colorconvert_m_mk="/codecs_v2/utilities/colorconvert/build/make" +threadsafe_callback_ao_m_lib="-lthreadsafe_callback_ao" +omx_wmadec_sharedlibrary_link_type="loaded" +opencore_rtsp_so_name="opencore_rtsp" +mpeg2recognizer_utility_m_lib="" +pvmpeg2ffrecognizer_m_lib="" +LIBDIR_codecs_utilities_static=" " +pvpvrcommonimp_y_lib="" +pvmetadata_engine_m_mk="/engines/pvme/build/make" +pvauthorengine_m_mk="/engines/author/build/make" +getaacaudioinfo_m_mk="" +pvmshttpfsp_m_lib="" +pvomxvideodecnode_y_mk="" +opencore_streaming_link_type="loaded" +pvmediadatastruct_y_mk="" +pvasfffrecognizer_m_lib="" +pvplayreadyplugin_m_mk="" +protocolenginenode_download_common_mk="/nodes/pvprotocolenginenode/download_protocols/common/build/make" +pvrmffrecognizer_y_mk="" +pvavifileparser_m_lib="" +omx_avcenc_component_y_lib="" +rtprtcp_y_mk="" +pvmp4reginterface_m_mk="/modules/linux_mp4/node_registry/build/make" +omx_m4venc_component_y_mk="" +LIBDIR_module="/modules" +pvpvxparser_m_mk="/fileformats/pvx/parser/build/make" +protocolenginenode_common_lib="-lprotocolenginenode_common" +pv_omx_interface_m_lib="-lpv_omx_interface" +MODS_pvmshttp_streaming="-lopencore_net_support -lopencore_player -lopencore_common -lopencore_streaming -lpvasfcommon" +smmshttppluginregpopulator_m_mk="" +pvrmffrecognizer_m_lib="" +rtspbasedpluginselected_m_config=y +pvrtsp_cli_eng_playlist_node_m_lib="" +pv_avc_mp_decoder_y_lib="" +mp4recognizer_utility_m_mk="/fileformats/mp4/parser/utils/mp4recognizer/build/make" +pvamrffrecognizer_m_mk="/pvmi/recognizer/plugins/pvamrffrecognizer/build/make" +pvasflocalpbreginterface_m_lib="" +colorconvert_m_lib="-lcolorconvert" +pvprotocolengine_asfstreaming_so_name="" +omx_baseclass_y_lib="" +pvrmffinterface_m_lib="" +wmvdecoder_imp_m_lib="" +pvmtp_engine_y_mk="" +LIBDIR_video_shared="/codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make /codecs_v2/video/m4v_h263/dec/build/make /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make" +mtpconfiginterface_m_lib="" +pvasfff_m_mk="" +pvaudiotrackmio_m_lib="" +DYNAMIC_LOAD_OMX_AAC_COMPONENT=1 +rvdecoder_imp_m_mk="" +pvdivxdrmplugin_y_lib="" +pvflvffparsernode_y_lib="" +pvgendatastruct_y_mk="" +pvmiofileoutput_y_lib="" +AGGREGATE_LIBDIRS_pvrtspunicastwithpvr_streaming=" " +pvwmdrmmd_so_name="" +pvdownloadreginterface_m_lib="-lpvdownloadreginterface" +LIBS_static=" -lunit_test -lunit_test_utils -lpvavifileparser -lpvmioaviwavfileinput " +REGISTER_OMX_M4V_COMPONENT=1 +MODS_opencore_net_support="-lopencore_common" +pvcrypto_y_mk="" +AGGREGATE_LIBDIRS_pvrtsptunicast_streaming="/modules/linux_rtsp/smplugins/tunneling/core/build/make /nodes/streaming/streamingmanager/plugins/rtsptunicast/build/make" +omx_aacenc_component_imp_m_mk="" +asfrecognizer_utility_y_lib="" +pv_aac_enc_m_mk="" +pvmp3ff_m_mk="/fileformats/mp3/parser/build/make" +pvplsffrecognizer_m_mk="/pvmi/recognizer/plugins/pvplsffrecognizer/build/make" +pvomx_proxy_y_lib="" +pvmiofileinput_m_mk="/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor" +pvfasttrack_download_aggregate_libtype="static" +oscl_y_lib="" +mtpconfiginterface_m_mk="" +MODS_omx_radec_sharedlibrary="-lomx_sharedlibrary -lopencore_common -lopencore_player -lpvrealsupportcommon" +pvrmffrecognizer_utility_y_mk="" +omx_rv_component_y_mk="" +wavparser_m_mk="/fileformats/audioparser/wav/build/make" +LIBS_protocols_static=" " +MODS_pvmp4eu="-lopencore_common -lopencore_player -lopencore_author" +LIBDIR_audio_shared=" /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make " +pvmtpdrmmanagerplugin_so_name="" +pvdivxdrm_link_type="loaded" +pvsdpparser_opencore_m_lib="-lpvsdpparser" +protocolenginenode_m_lib="-lprotocolenginenode_base -lprotocolenginenode_common -lprotocolenginenode_download_common -lprotocolenginenode_pdl -lprotocolenginenode_ps -lprotocolenginenode_shoutcast" +pvrmffparser_node_aggregate_libtype="static" +BUILD_SHOUTCAST_PLUGIN=1 +pvdb_recovery_utility_m_mk="" +pvomxaudiodecnode_m_lib="-lpvomxaudiodecnode" +pv324m_y_lib="" +pvflv_recognizer_so_name="" +BUILD_WOW_HD_AUDIO=0 +pvsocketnode_y_lib="" +unit_test_y_mk="/oscl/unit_test/build/make" +AGGREGATE_LIBDIRS_pv="/oscl /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/mp3/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/video/avc_h264/dec/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/enc/build/make /codecs_v2/video/m4v_h263/dec/build/make /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make /codecs_v2/utilities/colorconvert/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/gen_data_structures/build/make /pvmi/pvmf/build/make /pvmi/content_policy_manager/build/make /pvmi/media_io/pvmiofileoutput/build/make /fileformats/common/parser/build/make /fileformats/id3parcom/build/make /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/mp4/composer/build_opencore/make /nodes/pvmp4ffcomposernode/build_opencore/make /fileformats/pvx/parser/build/make /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvmediaoutputnode/build/make /nodes/pvfileoutputnode/build/make /fileformats/rawgsmamr/parser/build/make /nodes/pvamrffparsernode/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /fileformats/rawaac/parser/build/make /nodes/pvaacffparsernode/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /fileformats/mp3/parser/build/make /nodes/pvmp3ffparsernode/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /nodes/pvcommonparsernode/build/make /fileformats/audioparser/common/build/make /fileformats/audioparser/amr/build/make /fileformats/audioparser/wav/build/make /nodes/pvomxvideodecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxbasedecnode/build/make /nodes/pvwavffparsernode/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make /pvmi/recognizer/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /engines/adapters/player/framemetadatautility/build/make /engines/player/build/make /engines/author/build/make /engines/2way/sample_app/pv2waysample/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /engines/2way/build/make /nodes/pvclientserversocketnode/build/make /baselibs/thread_messaging/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /fileformats/scsp/build/make" +PV_ONE_SEGMENT_BROADCAST=0 +getactualaacconfig_y_mk="" +AGGREGATE_LIBDIRS_pvmtp="" +protocolenginenode_base_mk="/nodes/pvprotocolenginenode/base/build/make" +pvmf_y_lib="" +pv_config_parser_y_lib="" +opencore_2way_aggregate_libtype="shared" +pvpvrcommonimp_m_lib="" +m4v_config_m_lib="-lm4v_config" +pvaacffrecognizer_m_lib="-lpvaacffrecognizer" +cpm_y_mk="" +MODS_pvrtsptunicast_streamingreg="-lopencore_common -lopencore_streaming" +pvrbroadcastplugininterface_m_lib="" +pvmtpdrmmanagerplugin_link_type="loaded" +wmvdecoder_y_mk="" +AGGREGATE_LIBDIRS_omx_aacdec_sharedlibrary="/codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/audio/aac/dec/build/make" +pvsmfspcommonimp_y_lib="" +opencore_mp4localreg_so_name="opencore_mp4localreg" +pvcommonparsernode_y_mk="" +pvmtpdrmmanagerplugin_m_lib="" +flvrecognizer_utility_y_mk="" +omx_radec_sharedlibrary_so_name="" +pv_avc_mp_decoder_m_lib="" +pvomxvideodecnode_m_mk="/nodes/pvomxvideodecnode/build/make" +pvmp4ffcomposernodeopencore_m_mk="/nodes/pvmp4ffcomposernode/build_opencore/make" +pvrtsp_cli_eng_playlist_node_m_mk="" +pvomxaudiodecnode_y_mk="" +pvra8decoder_y_mk="" +AGGREGATE_LIBDIRS_pvflvparser_node=" " +AGGREGATE_LIBDIRS_opencore_rtsp="/protocols/rtsp_parcom/build/make /protocols/rtsp_client_engine/build/make_segments /protocols/rtp_payload_parser/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/rtp/build/make" +pvflvff_m_mk="" +m4v_config_y_mk="" +pvthreadmessaging_y_lib="" +pvthreadmessaging_m_mk="/baselibs/thread_messaging/build/make" +pvjitterbuffercommon_m_lib="-lpvjitterbuffer" +LIBS_tools_v2_shared="-lpvsminterface -lpvsmreginterface -lpvrtspsmplugininterface -lpvrtspsmpluginreginterface -lpvrtsptsmplugininterface -lpvrtsptsmpluginreginterface -lpvdownloadinterface -lpvdownloadreginterface -lpvmp4interface -lpvmp4reginterface -lpvoma1passthruplugininterface " +LIBS_pvmi_shared="-lcpm -lpvoma1passthruplugin -lpvmiofileoutput -lpvmiofileinput -lpvmio_comm_loopback -lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer -lpvplsffrecognizer -lpvmf " +pvcommsionode_m_mk="/nodes/pvcommsionode/build/make" +pvm4vencoder_imp_m_mk="" +g726decnode_m_lib="" +omx_mp3_component_imp_m_lib="" +pvstreamingmanagernode_m_mk="/nodes/streaming/streamingmanager/build/make" +pvplayreadyplugininterface_m_mk="" +mpeg2recognizer_utility_m_mk="" +DYNAMIC_LOAD_OMX_H263_COMPONENT=1 +pvomxencnode_y_lib="" +smrtsptrmplugininterface_m_mk="" +pvmetadata_engine_y_mk="" +omx_wma_component_imp_m_lib="" +wavparser_y_lib="" +pvpvxparser_y_lib="" +pvra8decoder_y_lib="" +pvdbconfiginterface_m_lib="" +MODS_pvasflocalpbreg="-lopencore_common -lpvasfcommon" +pvrmffparsernode_m_lib="" +MODS_pvplayerservice="" +pv_divxfile_parser_m_mk="" +LIBS_media_io_static=" -lpvmioaviwavfileinput " +pv_amr_nb_common_imp_lib_m_mk="" +MODS_pvrmffparser_node="-lpvrmff_recognizer -lopencore_player -lopencore_common -lpvrealsupportcommon" +pvmp4eu_m_mk="" +pvrmff_y_lib="" +pvdtcp_mbds_y_lib="" +pvwmdrmoemsettings_link_type="loaded" +pvstillimagenode_y_lib="" +USE_OMX_ENC_NODE=1 +pvrtsptwithrealfsp_m_lib="" +mp4recognizer_utility_y_lib="" +asf_payload_parser_y_mk="" +pvm4vencoder_m_lib="-lpvm4vencoder" +LIBS_codecs_utilities_shared="-lm4v_config -lpv_config_parser -lcolorconvert" +opencore_2way_so_name="opencore_2way" +AGGREGATE_LIBDIRS_pvsqlite="" +pv2waysample_y_mk="" +omx_avcdec_sharedlibrary_aggregate_libtype="shared" +AGGREGATE_LIBDIRS_omx_wmadec_sharedlibrary=" " +omx_wmvdec_sharedlibrary_so_name="" +pvdtcpplugin_y_mk="" +pvmshttp_streaming_so_name="" +AGGREGATE_LIBDIRS_omx_amrdec_sharedlibrary="/codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make" +getactualaacconfig_m_lib="-lgetactualaacconfig" +MODS_pvprotocolengine_asfstreaming="-lopencore_net_support -lopencore_common -lpvasfcommon" +pvprotocolengine_asfstreaming_link_type="loaded" +omx_amrenc_component_y_lib="" +MODS_pvrealsupportcommon="-lopencore_common" +AGGREGATE_LIBDIRS_pvrtsptunicastforrm_streamingreg="" +pvaacffparsernode_m_mk="/nodes/pvaacffparsernode/build/make" +pvm4vencoder_imp_m_lib="" +rtppayloadparser_y_lib="" +pvrmffparser_y_lib="" +wmvdecoder_m_mk="" +packetsources_default_m_lib="" +omx_amrenc_component_imp_m_lib="" +pvaacffrecognizer_y_mk="" +DYNAMIC_LOAD_OMX_AVC_COMPONENT=1 +REGISTER_OMX_RA_COMPONENT=0 +LIBS_omxdecimp_static="" +pvmtpip_aggregate_libtype="static" +pv_smooth_streaming_m_lib="" +WMA_BUILD_CFG_LSL_ENABLED=0 +pv_aac_enc_imp_m_lib="" +LIBDIR_nodes_static=" " +smrtspunicastplugininterface_m_mk="/modules/linux_rtsp/smplugins/unicast/core/build/make" +pvmshttp_streaming_aggregate_libtype="static" +PV_MULTICHANNEL_FRIENDLY=0 +asfrecognizer_utility_m_mk="" +pvrmffparsernode_m_mk="" +realaudio_deinterleaver_m_mk="" +LIBDIR_baselibs_static=" " +pvwav_m_lib="-lpvwav" +pvmp4decoder_imp_m_lib="" +pv_rtsp_parcom_y_lib="" +LIBDIR_static=" /oscl/unit_test/build/make /oscl/unit_test_utils/build/make /fileformats/avi/parser/build/make /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make " +pvmp4decoder_y_mk="" +omx_mastercore_m_lib="-lomx_mastercore_lib" +omx_m4vdec_sharedlibrary_aggregate_libtype="shared" +pv_config_parser_y_mk="" +MODS_pvmtpconfigclass="-lopencore_common" +LIBS_oscl_static=" -lunit_test -lunit_test_utils" +pvfileoutputnode_m_mk="/nodes/pvfileoutputnode/build/make" +wmadecoder_imp_m_lib="" +g726decnode_y_mk="" +oscl_m_mk="/oscl" +pvpvxparser_m_lib="-lpvpvxparser" +rtspbasedpluginselected=y +pv_http_retriever_y_mk="" +MODS_pvrtsptunicastforrm_streaming="-lopencore_net_support -lopencore_player -lopencore_common -lpvrtsptunicast_streaming -lopencore_rtsp -lopencore_streaming -lpvwmdrmmd -lpvrealsupportcommon" +pvfileplaybackwithpvrfsp_m_lib="" +pvdivxdrm_y_lib="" +pvmtpconfigclass_link_type="loaded" +omx_m4venc_component_imp_m_lib="" +pvrmff_recognizer_so_name="" +pvdb_recovery_utility_y_lib="" +pvmetadata_engine_y_lib="" +pvamrffrecognizer_y_lib="" +LIBS_omxjointimp_shared="-lomx_mastercore_lib" +pvmediaoutputnode_m_mk="/nodes/pvmediaoutputnode/build/make" +pvm4vencoder_y_mk="" +pvbroadcastwithpvrfsp_m_mk="" +LIBDIR_omxjoint_shared="/codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make" +pvrmff_recognizer_link_type="loaded" +REGISTER_OMX_M4VENC_COMPONENT=1 +AGGREGATE_LIBDIRS_pvplayready=" " +pvpvrff_y_mk="" +pvpvrnode_y_mk="" +omx_baseclass_y_mk="" +AGGREGATE_LIBDIRS_pvfasttrack_downloadreg="" +pvrtspunicastwithpvrfsp_m_lib="" +pvamrwbdecoder_m_mk="/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make" +pvplayready_so_name="" +pvplayer_engine_y_mk="" +pvamrwbdecoder_y_lib="" +pvsqlite_m_lib="" +LIBDIR_tools_v2_shared="/modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make /modules/linux_rtsp/smplugins/unicast/core/build/make /modules/linux_rtsp/smplugins/unicast/registry/build/make /modules/linux_rtsp/smplugins/tunneling/core/build/make /modules/linux_rtsp/smplugins/tunneling/registry/build/make /modules/linux_download/core/build/make /modules/linux_download/node_registry/build/make /modules/linux_mp4/core/build/make /modules/linux_mp4/node_registry/build/make /modules/cpm_oma1_passthru/build/make " +wmadecoder_y_mk="" +WMA_AUDIO_SUPPORT_ENABLED=1 +pvmtpip_engine_m_lib="" +pvrtsptunicastfsp_y_lib="" +protocolenginenode_m_mk="/nodes/pvprotocolenginenode/base/build/make /nodes/pvprotocolenginenode/protocol_common/build/make /nodes/pvprotocolenginenode/download_protocols/common/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make /nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make" +pvmedialayernode_y_lib="" +pvg726decoder_m_mk="" +pvdivxffrecognizer_m_mk="" +pvflvffparsernode_m_lib="" +pvmp4ffcomposernodeopencore_y_lib="" +scsp_y_mk="" +pvjitterbufferrtp_m_mk="/nodes/streaming/jitterbuffernode/jitterbuffer/rtp/build/make" +pvplayreadyutility_m_mk="" +pventropysrc_y_lib="" +pvdecoder_gsmamr_y_mk="" +pvplayerservice_so_name="" +pvmp4ffcomposernode_m_lib="" +pvplayready_aggregate_libtype="static" +pvloopbacknode_y_mk="" +pvfileplaybackwithpvr_streamingreg_so_name="" +AGGREGATE_LIBDIRS_pvdivxparser_node=" " +pvdivxoemsettings_link_type="loaded" +pvrmffparser_node_link_type="loaded" +pvgsmamrparser_m_lib="-lpvgsmamrparser" +omx_mp3_component_m_mk="/codecs_v2/omx/omx_mp3/build/make_multithreaded" +MODS_pvflv_recognizer="-lopencore_common" +pv_divxfile_parser_m_lib="" +omx_mp3_component_m_lib="-lomx_mp3_component_lib" +pvaacparser_m_lib="-lpvaacparser" +pvwavffparsernode_m_mk="/nodes/pvwavffparsernode/build/make" +BUILD_STATIC_FILEPLAYBACK_PVR=0 +pvdivxoemsettings_m_lib="" +LIBS_omxencimp_static="" +MODS_opencore_2way="-lopencore_common" +pv_aggregate_libtype="static" +rvdecoder_m_lib="" +LIBDIR_fileformats_shared="/fileformats/common/parser/build/make /fileformats/id3parcom/build/make /fileformats/pvx/parser/build/make /fileformats/wav/parser/build/make /fileformats/mp3/parser/build/make /fileformats/rawaac/parser/build/make /fileformats/rawgsmamr/parser/build/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/composer/build_opencore/make /fileformats/scsp/build/make /fileformats/audioparser/common/build/make /fileformats/audioparser/amr/build/make /fileformats/audioparser/wav/build/make" +omx_queue_m_mk="/codecs_v2/omx/omx_queue/build/make" +omx_wmadec_sharedlibrary_aggregate_libtype="static" +protocolenginenode_ps_mk="/nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make" +pvplayreadyutility_m_lib="" +pv_http_parcom_m_mk="/protocols/http_parcom/build/make" +pvmshttp_streamingreg_link_type="loaded" +LIBDIR_packetsources_shared="" +pvrmffparser_node_so_name="" +LIBDIR_omxjoint_static=" " +pv_amr_nb_common_lib_m_lib="-lpv_amr_nb_common_lib" +pvmiofileoutput_y_mk="" +MODS_opencore_mp4local="-lopencore_common -lopencore_player" +AGGREGATE_LIBDIRS_pvmshttp_streamingreg="" +pvrtspunicast_streamingreg_link_type="loaded" +pvmp3ff_y_lib="" +pvrrtspunicastpluginregpopulator_m_lib="" +pvmiofileinput_y_lib="" +LIBS_fileformats_static=" -lpvavifileparser " +divxrecognizer_utility_y_mk="" +pvmp3ffparsernode_y_mk="" +pvavch264enc_y_mk="" +pvg726decoder_m_lib="" +AGGREGATE_LIBDIRS_pvrmffparser_node=" " +LIBS_recognizer_shared="-lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer -lpvplsffrecognizer " +pvstreamingmanagernode_y_lib="" +pvdivxdrm_oem_settings_y_mk="" +pvrtsptunicastforrm_streaming_so_name="" +unit_test_utils_y_lib="-lunit_test_utils" +pvsqlite_y_lib="" +AGGREGATE_LIBDIRS_pvdivxdrm=" " +pvmtpdrmmanagerplugin_m_mk="" +opencore_player_so_name="opencore_player" +omx_aacenc_sharedlibrary_so_name="" +rvdecoder_y_mk="" +colorconvert_y_mk="" +pvflvreginterface_m_lib="" +pv_m3u_parser_m_lib="" +pv_m3u_parser_m_mk="" +pvoma1ffrecognizer_m_mk="" +packetsources_default_y_lib="" +DYNAMIC_LOAD_OMX_AACENC_COMPONENT=0 +pvplayer_engine_m_lib="-lpvplayer_engine" +opencore_rtsp_aggregate_libtype="shared" +pvrmffrecognizer_utility_m_lib="" +pvdivxffparsernode_m_mk="" +pv_avc_mp_decoder_imp_m_lib="" +packetsources_default_y_mk="" +omx_amrenc_sharedlibrary_so_name="omx_amrenc_sharedlibrary" +pv2wayengine_y_mk="" +pvmpeg2ff_m_mk="" +pvrtspunicast_streaming_so_name="pvrtspunicast_streaming" +AGGREGATE_LIBDIRS_omx_avcdec_sharedlibrary="/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/video/avc_h264/dec/build/make " +pvmp4ffopencore_y_lib="" +omx_m4venc_component_y_lib="" +pvrtsptunicast_streaming_link_type="loaded" +pvpvrnode_m_lib="" +pvpvrff_m_lib="" +pvframemetadatautility_y_lib="" +omx_avcenc_component_imp_m_mk="" +omx_amr_component_y_mk="" +divxrecognizer_utility_m_mk="" +pvavch264enc_y_lib="" +pvclientserversocketnode_m_mk="/nodes/pvclientserversocketnode/build/make" +omx_rv_component_imp_m_lib="" +LIBDIR_nodes_shared="/nodes/pvfileoutputnode/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvsocketnode/build/make /nodes/pvprotocolenginenode/base/build/make /nodes/pvprotocolenginenode/protocol_common/build/make /nodes/pvprotocolenginenode/download_protocols/common/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_download/build/make /nodes/pvprotocolenginenode/download_protocols/progressive_streaming/build/make /nodes/pvprotocolenginenode/download_protocols/shoutcast/build/make /nodes/pvwavffparsernode/build/make /nodes/pvomxencnode/build/make /nodes/pvomxbasedecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxvideodecnode/build/make /nodes/pvaacffparsernode/build/make /nodes/pvamrffparsernode/build/make /nodes/pvmp3ffparsernode/build/make /nodes/pvmp4ffparsernode/build_opencore/make /nodes/common/build/make /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvmp4ffcomposernode/build_opencore/make /nodes/pvdownloadmanagernode/build/make /nodes/streaming/streamingmanager/plugins/rtspunicast/build/make /nodes/streaming/streamingmanager/plugins/rtsptunicast/build/make /nodes/streaming/streamingmanager/plugins/common/build/make /nodes/streaming/streamingmanager/build/make /modules/linux_rtsp/smplugins/unicast/core/build/make /modules/linux_rtsp/smplugins/unicast/registry/build/make /modules/linux_rtsp/smplugins/tunneling/core/build/make /modules/linux_rtsp/smplugins/tunneling/registry/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/common/build/make /nodes/streaming/jitterbuffernode/jitterbuffer/rtp/build/make /nodes/streaming/jitterbuffernode/build/make /nodes/pvcommsionode/build/make /nodes/pvclientserversocketnode/build/make /nodes/pvloopbacknode/build/make /nodes/pvcommonparsernode/build/make" +pvasfff_y_mk="" +getactualaacconfig_for_static_m_lib="" +pvmp3ffrecognizer_y_lib="" +AGGREGATE_LIBDIRS_pvfasttrack_download=" " +AGGREGATE_LIBDIRS_pvdivx_recognizer=" " +pvprotocolenginewmhttpstreamingpluginreginterface_m_mk="" +pvclientserversocketnode_m_lib="-lpvclientserversocketnode" +pvsqlite_m_mk="" +DYNAMIC_LOAD_OMX_MP3_COMPONENT=1 +pvavcdecoder_y_mk="" +pvrtsptunicastforrm_streamingreg_so_name="" +getactualaacconfig_y_lib="" +pvoma1passthruplugininterface_m_lib="-lpvoma1passthruplugininterface" +wma_common_hdrs_y_mk="" +omx_amrenc_component_y_mk="" +LIBS_omxjoint_static=" " +pvmtpconfigclass_so_name="" +pvmio_comm_loopback_y_mk="" +pvmediaoutputnode_m_lib="-lpvmediaoutputnode" +BUILD_STATIC_RTSPUNICAST=0 +LIBDIR_audio_static=" " +pvra8decoder_m_lib="" +pvdbconfigclass_so_name="" +omx_rv_component_y_lib="" +pvmtpip_engine_m_mk="" +pvlatmpayloadparser_y_mk="" +omx_m4v_component_m_mk="/codecs_v2/omx/omx_m4v/build/make_multithreaded" +packetsources_default_plugins=" " +omx_queue_y_lib="" +protocolenginenode_pdl_lib="-lprotocolenginenode_pdl" +pvrfileplaybackpluginregpopulator_m_lib="" +pvpvr_m_lib="" +AGGREGATE_LIBDIRS_pvmtpdrmmanagerplugin="" +pvmp4ffcomposernode_y_lib="" +pvasxparser_y_mk="" +MODS_pvdtcp_mbds="-lopencore_download -lopencore_common" +pvmp3ffparsernode_m_mk="/nodes/pvmp3ffparsernode/build/make" +pvdivxffrecognizer_y_lib="" +pvmp4eu_y_mk="" +pvdownloadmanagernode_y_mk="" +omx_wmvdec_sharedlibrary_aggregate_libtype="static" +omx_sharedlibrary_so_name="omx_sharedlibrary" +omx_avc_component_imp_m_mk="" +unit_test_m_lib="" +MODS_pvasfcommon="-lopencore_common" +pvid3parcom_y_mk="" +pventropysrc_y_mk="" +pvrtsptunicastforrm_streaming_aggregate_libtype="static" +opencore_streaming_aggregate_libtype="shared" +pvomx_proxy_y_mk="" +pvdivxparser_node_link_type="loaded" +pvsmreginterface_m_lib="-lpvsmreginterface" +DYNAMIC_LOAD_OMX_RA_COMPONENT=0 +pvmediainputnode_m_mk="/nodes/pvmediainputnode/build/make_pvauthor" +pvoma1lockstream_m_lib="" +pvcommsionode_y_lib="" +pv_avc_common_lib_y_lib="" +pvomxaudiodecnode_y_lib="" +pvflvffrecognizer_m_lib="" +omx_wma_component_y_mk="" +pv_srs_wowhd_y_mk="" +omx_baseclass_m_lib="-lomx_baseclass_lib" +ss_or_als=n +pvoma1ffrecognizer_y_mk="" +pvoma1passthruplugin_m_lib="-lpvoma1passthruplugin" +protocolenginenode_download_common_lib="-lprotocolenginenode_download_common" +pvwav_y_mk="" +pvwav_y_lib="" +pv_aac_enc_imp_m_mk="" +opencore_mp4localreg_aggregate_libtype="shared" +wmavoicedecoder_m_mk="" +pvmfrecognizer_y_mk="" +pvdbconfiginterface_m_mk="" +pvsdpparser_opencore_y_lib="" +protocolenginenode_y_lib="" +omx_m4venc_sharedlibrary_so_name="omx_m4venc_sharedlibrary" +pvmtp_usb_transport_m_mk="" +pvfileplaybackwithpvrfsp_y_mk="" +pv2waysample_m_lib="-lpv2waysample" +pvgeneraltools_m_mk="/protocols/systems/tools/general/build/make" +pv_aac_dec_m_mk="/codecs_v2/audio/aac/dec/build/make" +omx_aac_component_imp_m_mk="" +AGGREGATE_LIBDIRS_pvmshttp_streaming=" " +pvamrwbdecoder_m_lib="-lpvamrwbdecoder" +pv_http_parcom_y_lib="" +LIBS_engines_shared="-lpvplayer_engine -lpvauthorengine -lpv2wayengine -lpv2waysample -lpvframemetadatautility -lpvmetadata_engine " +omx_mp3dec_sharedlibrary_so_name="omx_mp3dec_sharedlibrary" +pvsmfspcommonimp_m_lib="-lpvsmfspcommon" +LIBDIR_video_static=" " +LIBDIR_omxenc_shared="/codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded " +opencore_net_support_so_name="opencore_net_support" +pvjitterbufferasf_m_mk="" +pvdivxdrmplugininterface_m_mk="" +LIBS_nodes_static=" " +pvfileoutputnode_m_lib="-lpvfileoutputnode" +MODS_pvfileplaybackwithpvr_streamingreg="-lopencore_common -lopencore_streaming" +pvomxvideodecnode_y_lib="" +AGGREGATE_LIBDIRS_pvdb_recovery_utility="" +AGGREGATE_LIBDIRS_opencore_author=" /fileformats/mp4/composer/build_opencore/make /nodes/pvmp4ffcomposernode/build_opencore/make /engines/author/build/make" +AGGREGATE_LIBDIRS_opencore_streamingreg="/modules/linux_rtsp/node_registry/build/make" +pvmtpip_engine_y_mk="" +MODS_omx_sharedlibrary="-lopencore_common" +pv_omx_interface_m_mk="/codecs_v2/omx/omx_sharedlibrary/interface/build/make" +pvavifileparser_y_lib="-lpvavifileparser" +pvrfileplaybackplugininterface_m_mk="" +pvoma1passthruplugininterface_m_mk="/modules/cpm_oma1_passthru/build/make" +audioparser_m_mk="/fileformats/audioparser/common/build/make" +protocolenginenode_ftdl_lib="" +LIBDIR_omxdec_shared="/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded " +omx_aacenc_component_y_lib="" +BUILD_PROGRESSIVE_STREAMING_PLUGIN=1 +pvfasttrack_download_so_name="" +MODS_pvpvrcommonimpl_streaming="-lopencore_net_support -lopencore_common -lopencore_rtsp -lopencore_streaming" +pvmp4decoder_imp_m_mk="" +omx_m4v_component_y_mk="" +rdt_parser_m_lib="" +pvprotocolenginewmhttpstreaminginterface_m_mk="" +pvprotocolengine_asfstreaming_aggregate_libtype="static" +pvdtcp_mbds_y_mk="" +pvloopbacknode_y_lib="" +realaudio_deinterleaver_m_lib="" +REGISTER_OMX_AMRENC_COMPONENT=1 +LIBS_cpm_static=" " +pvrtsptunicastforrm_streamingreg_link_type="loaded" +rtprtcp_m_lib="-lrtprtcp" +pvdbmanager_m_lib="" +WMA_VOICE_SUPPORT_ENABLED=1 +pvmpeg2ff_y_lib="" +pv_smooth_streaming_y_lib="" +omx_mastercore_y_mk="" +omx_mp3dec_sharedlibrary_aggregate_libtype="shared" +pvmp4ffcomposer_m_mk="" +pvasflocalpbreginterface_m_mk="" +pvasflocalpbinterface_m_lib="" +omx_avcenc_sharedlibrary_aggregate_libtype="shared" +pvdivx_recognizer_link_type="loaded" +AGGREGATE_LIBDIRS_pvrtspunicast_streamingreg="/modules/linux_rtsp/smplugins/unicast/registry/build/make" +pvasfffrecognizer_y_mk="" +opencore_mp4local_aggregate_libtype="shared" +pvplayer_engine_m_mk="/engines/player/build/make" +LIBDIR_engines_static=" " +LIBDIR_pvmi_static=" /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make " +pv324m_common_headers_y_mk="" +AGGREGATE_LIBDIRS_omx_sharedlibrary="/codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_sharedlibrary/interface/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make" +pvwmdrmmd_y_mk="" +omx_ra_component_y_lib="" +pvrmffrecognizer_utility_y_lib="" +AGGREGATE_LIBDIRS_pvmtpconfigclass="" +pvrtppacketsourcenode_m_lib="" +pvrtspunicastfsp_y_lib="" +pvprotocolengine_asfstreamingreg_so_name="" +oscllib_mk="/oscl/oscl/oscllib/build/make" +asfrecognizer_utility_m_lib="" +threadsafe_callback_ao_y_lib="" +MODS_pvrtspbroadcastwithpvr_streamingreg="-lopencore_common -lopencore_streaming" +protocolenginenode_y_mk="" +REGISTER_OMX_H263ENC_COMPONENT=1 +omx_baseclass_m_mk="/codecs_v2/omx/omx_baseclass/build/make" +pvdtcp_mbds_aggregate_libtype="static" +MODS_pviptransport="-lopencore_common" +AGGREGATE_LIBDIRS_omx_avcenc_sharedlibrary="/codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/video/avc_h264/enc/build/make" +pv_avc_mp_decoder_m_mk="" +pvrtsptunicastforrm_streaming_link_type="loaded" +LIBS_baselibs_static=" " +pvgendatastruct_y_lib="" +pv_config_parser_m_lib="-lpv_config_parser" +pvmpeg2local_so_name="" +pvmedialayernode_y_mk="" +pvdbmanager_y_mk="" +pvmtp_engine_y_lib="" +omx_avcenc_sharedlibrary_link_type="loaded" +opencore_common_so_name="opencore_common" +pv_divxfile_parser_y_mk="" +smmshttppluginregpopulator_m_lib="" +omx_mp3_component_y_mk="" +TARGET_aggregate=" opencore_common omx_sharedlibrary omx_avcdec_sharedlibrary omx_m4vdec_sharedlibrary omx_aacdec_sharedlibrary omx_amrdec_sharedlibrary omx_mp3dec_sharedlibrary omx_avcenc_sharedlibrary omx_m4venc_sharedlibrary omx_amrenc_sharedlibrary opencore_net_support opencore_player opencore_downloadreg opencore_download opencore_streamingreg opencore_streaming opencore_mp4localreg opencore_mp4local pvoma1passthru opencore_rtsp pvrtspunicast_streaming pvrtspunicast_streamingreg pvrtsptunicast_streaming pvrtsptunicast_streamingreg opencore_author opencore_2way opencore_pvme" +rdt_parser_y_mk="" +pvmpeg2localreg_aggregate_libtype="static" +REGISTER_OMX_AVCENC_COMPONENT=1 +pvamrwbdecoder_y_mk="" +pvrmffparsernode_y_lib="" +pvmp4ffparsernodeopencore_y_mk="" +pvmp4ffopencore_y_mk="" +realmedia_payload_parser_m_mk="" +colorconvert_y_lib="" +pvmp4ffopencore_m_mk="/fileformats/mp4/parser/build_opencore/make" +pvencoder_gsmamr_m_lib="-lpvencoder_gsmamr" +pvra8decoder_m_mk="" +rfc_2429_mk="rfc_2429.mk" +pvdbconfigclass_aggregate_libtype="static" +omx_sharedlibrary_link_type="loaded" +MODS_pvrtspunicastwithpvr_streaming="-lopencore_net_support -lopencore_player -lopencore_common -lpvpvrcommonimpl_streaming -lopencore_rtsp -lopencore_streaming" +omx_aacdec_sharedlibrary_so_name="omx_aacdec_sharedlibrary" +pv_so_name="" +pvrmffrecognizer_m_mk="" +pvavch264enc_imp_m_mk="" +pvgeneraltools_m_lib="-lpvgeneraltools" +LIBS_omxjoint_shared="-lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface" +pviptransport_so_name="" +pvdivxoemsettings_m_mk="" +cpm_y_lib="" +pvplsffrecognizer_y_lib="" +MODS_pvrtsptunicastforrm_streamingreg="-lopencore_common -lopencore_streaming" +pvdivxdrmplugin_m_lib="" +omx_rvdec_sharedlibrary_link_type="loaded" +wmadecoder_imp_m_mk="" +MODS_opencore_downloadreg="-lopencore_common" +pvmp3ffrecognizer_m_mk="/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make" +omx_sharedlibrary_aggregate_libtype="shared" +protocolenginenode_asfstreaming_lib="" +pvmtp_engine_m_lib="" +pvdivxinterface_m_lib="" +MODS_omx_aacenc_sharedlibrary="-lomx_sharedlibrary -lopencore_common " +LIBS_omxjointimp_static="" +amrparser_m_mk="/fileformats/audioparser/amr/build/make" +pvdivx_recognizer_so_name="" +omx_m4v_component_imp_m_lib="" +pvmp4ffcomposeropencore_y_mk="" +pvrtspbroadcastwithpvr_streamingreg_aggregate_libtype="static" +pvdivxffparsernode_m_lib="" +AGGREGATE_LIBDIRS_omx_wmvdec_sharedlibrary=" " +pv_srs_wowhd_y_lib="" +engines_common_headers_y_mk="" +pvmp4ffparsernode_y_lib="" +pvmioaviwavfileinput_m_mk="" +pvdb_so_name="" +pvmpeg2ffparsernode_y_mk="" +pvloopbacknode_m_lib="-lpvloopbacknode" +pvrbroadcastplugininterface_m_mk="" +pvmpeg2local_link_type="loaded" +protocolenginenode_segments_lib="-lprotocolenginenode_base -lprotocolenginenode_common -lprotocolenginenode_download_common -lprotocolenginenode_pdl -lprotocolenginenode_ps -lprotocolenginenode_shoutcast" +pvmf_m_lib="-lpvmf" +pvrealsupportcommon_aggregate_libtype="static" +pvdtcpplugin_m_lib="" +MODS_pvflvparser_node="-lpvflv_recognizer -lopencore_player -lopencore_common" +pvmp4eu_so_name="" +pvasfffparsernode_y_lib="" +LIBS_recognizer_static=" " +omx_rvdec_sharedlibrary_so_name="" +opencore_streaming_so_name="opencore_streaming" +pvmp4ffrecognizer_y_lib="" +flvrecognizer_utility_m_lib="" +LIBS_packetsources_shared="" +omx_rv_component_m_mk="" +pviptransport_y_mk="" +pvomxbasedecnode_m_mk="/nodes/pvomxbasedecnode/build/make" +pvmp3_m_mk="/codecs_v2/audio/mp3/dec/build/make" +LIBS_codecs_utilities_static=" " +LIBDIR_omxjointimp_shared="/codecs_v2/omx/omx_mastercore/build/make_multithreaded" +unit_test_y_lib="-lunit_test" +pvrbroadcastpluginregpopulator_m_lib="" +omx_ra_component_imp_m_mk="" +omx_m4venc_component_m_mk="/codecs_v2/omx/omx_m4venc/build/make_multithreaded" +MODS_opencore_streamingreg="-lopencore_common" +unit_test_m_mk="" +pvomxaudiodecnode_m_mk="/nodes/pvomxaudiodecnode/build/make" +pvprotocolenginefasttrackdownloadinterface_m_lib="" +MODS_pvrtspunicastwithpvr_streamingreg="-lopencore_common -lopencore_streaming" +omx_common_m_mk="/codecs_v2/omx/omx_common/build/make_multithreaded" +pvrtsptunicast_streamingreg_aggregate_libtype="shared" +REGISTER_OMX_AACENC_COMPONENT=0 +pvdivxffparsernode_y_mk="" +pvmediadatastruct_m_mk="/baselibs/media_data_structures/build/make" +pvsminterface_m_lib="-lpvsminterface" +MODS_omx_amrenc_sharedlibrary="-lomx_sharedlibrary -lopencore_common " +pvmp4ffparsernode_m_lib="" +pvfileparserutils_y_lib="" +MODS_pvmtpip="-lopencore_common -lpvdb" +omx_avcdec_sharedlibrary_link_type="loaded" +MODS_opencore_common="" +pvflvff_m_lib="" +pvcrypto_m_lib="" +pvplayready_link_type="loaded" +pvdivxoemsettings_aggregate_libtype="static" +pvmpeg2local_aggregate_libtype="static" +pvmpeg2ffrecognizer_y_mk="" +pvrmff_m_mk="" +# +# That's all, folks! diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pv_config_selected.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pv_config_selected.mk new file mode 100644 index 0000000..734e383 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pv_config_selected.mk @@ -0,0 +1,477 @@ +# +# Automatically generated, don't edit +# + +# +# PV Code Base Configuration System +# + +# +# Menu for selecting supported features +# +module_support=y +PV_HAS_SHOUTCAST_SUPPORT_ENABLED=y + + +# +# Menu for configuring modules +# +pv_so=n +pvplayerservice_so=n +pvsplit_so=y +dynamic_loading_support=y +download_support=y +fasttrack_download_support=n +mp4local_support=y +mpeg2local_support=n +divxlocal_support=n +rmff_support=n +flvlocal_support=n +asflocal_support=n +playready_support=n +oma1_passthru_support=y +wmdrmoemsettings_support=n +pvdivxoemsettings_support=n +divxdrm_support=n +mtp_db_support=n +pvdb_config_support=n +mtp_config_support=n +mtp_drmmanagerplugin_support=n +usb_transport_support=n +dtcp_support=n + + +# +# Menu for configuring Baselibs +# +csprng_lib=n +pvcrypto_lib=n +pventropysrc_lib=n +pvgendatastruct_lib=m +pvmediadatastruct_lib=m +pvmimeutils_lib=m +threadsafe_callback_ao_lib=m +pvthreadmessaging_lib=m +secure_data_format_lib=n + + +# +# Menu for configuring File Formats +# +pvasfff_lib=n +pvmp3ff_lib=m +pvmp4ffcomposer_lib=n +pvmp4ffcomposeropencore_lib=m +pvmp4ff_lib=n +pvmp4ffopencore_lib=m +mp4recognizer_utility_lib=m +pvaacparser_lib=m +pvgsmamrparser_lib=m +pvrmff_lib=n +pvrmffparser_lib=n +pvfileparserutils_lib=m +pvid3parcom_lib=m +pvpvxparser_lib=m +pvwav_lib=m +pvasxparser_lib=n +pvavifileparser_lib=y +pvpvrff_lib=n +asfrecognizer_utility_lib=n +pv_divxfile_parser_lib=n +scsp_lib=m +divxrecognizer_utility_lib=n +pvflvff_lib=n +pvrmffrecognizer_utility_lib=n +flvrecognizer_utility_lib=n +pvmpeg2ff_lib=n +mpeg2recognizer_utility_lib=n +audioparser_lib=m +amrparser_lib=m +wavparser_lib=m + + +# +# Menu for configuring Codecs +# + +# +# Menu for configuring OMX Support +# +omx_mastercore_lib=m +MAX_NUMBER_OF_OMX_CORES=10 +MAX_NUMBER_OF_OMX_COMPONENTS=50 +USE_DYNAMIC_LOAD_OMX_COMPONENTS=y +pv_omx=y +omx_avc_component_lib=m +omx_common_lib=m +omx_m4v_component_lib=m +omx_queue_lib=m +omx_wmv_component_lib=n +omx_rv_component_lib=n +pvomx_proxy_lib=m +omx_aac_component_lib=m +omx_amr_component_lib=m +omx_mp3_component_lib=m +omx_wma_component_lib=n +omx_ra_component_lib=n +omx_amrenc_component_lib=m +omx_m4venc_component_lib=m +omx_avcenc_component_lib=m +omx_aacenc_component_lib=n +omx_baseclass_lib=m + + +# +# Menu for configuring audio codecs +# +pv_aac_dec_lib=m +pv_aac_enc_lib=n +getactualaacconfig_lib=m +getaacaudioinfo_lib=n +pv_amr_nb_common_lib=m +pvdecoder_gsmamr_lib=m +pvencoder_gsmamr_lib=m +pvamrwbdecoder_lib=m +gsm_amr_headers_lib=m +pvmp3_lib=m +pvra8decoder_lib=n +pv_srs_wowhd_lib=n +wmadecoder_lib=n +useoldwmadecoder=n +usepv_one_segment_broadcast=n +usemultichannlefriendly=n +wma_audio_support=m + +# +# WMA Audio library build configurations (see build_configuration.doc) +# +wma_build_cfg_std=n +wma_build_cfg_stdprostereolbrv1=n +wma_build_cfg_stdprostereolbr=n +wma_build_cfg_stdprolbr=n +wma_build_cfg_lsl=n +wma_build_cfg_all=y + +wmavoicedecoder_lib=n +wma_voice_support=m +wma_common_hdrs_lib=n +pvg726decoder_lib=n + + +# +# Menu for configuring video codecs +# +pv_avc_common_lib=m +pvavcdecoder_lib=m +pv_avc_mp_decoder_lib=n +wmvdecoder_lib=n +pvmp4decoder_lib=m +M4VDEC_FLV_SUPPORT=n +rvdecoder_lib=n +pvm4vencoder_lib=m +pvavch264enc_lib=m + + +# +# Menu for configuring codecs utilities +# +m4v_config_lib=m +pv_config_parser_lib=m +colorconvert_lib=m + +# +# Choose the YUYV format +# +UY0VY1=y +Y1VY0U=n +Y0VY1U=n + + +# +# choose the RGB format +# +CC_RGB=y +CC_BGR=n + + +ENABLE_UNALIGNED_MEM_ACCESS_FLAG=n + + +# +# Menu for configuring Nodes +# + +# +# Menu for configuring Streaming Plugins +# +mshttp_support=n +rtspunicast_support=m +rtsptunicast_support=m +rtsptunicastwithreal_support=n +broadcastpvr_support=n +rtspunicastpvr_support=n +fileplaybackpvr_support=n + + +# +# Menu for configuring Download +# +pvdownloadmanagernode_lib=m +pvdtcp_mbds_lib=n + +# +# Menu for configuring downloadmanager features +# +PVMF_DOWNLOADMANAGER_SUPPORT_PPB=y +PVMF_MEMORYBUFFERDATASTREAM_DTCP_PPB=n +PVMF_DOWNLOADMANAGER_MIN_TCP_BUFFERS_FOR_PPB=39 +PVMF_DOWNLOADMANAGER_CACHE_SIZE_FOR_SC_IN_SECONDS=6 +PVMF_DOWNLOADMANAGER_MAX_BITRATE_FOR_SC=128 + + + +# +# Menu for configuring ProtocolEngine +# +penode_enabled=m +penode_pdl_support=y +penode_ps_support=y +penode_ftdl_support=n +penode_wmhttpstreaming_support=n +penode_shoutcast_support=y +penode_rtmp_support=n +penode_smooth_streaming_support=n +penode_apple_http_streaming_support=n + +pvfileoutputnode_lib=m +pvmediaoutputnode_lib=m +pvsocketnode_lib=m +pvwavffparsernode_lib=m +pvomxencnode_lib=m +pvomxaudiodecnode_lib=m +pvomxbasedecnode_lib=m +pvomxvideodecnode_lib=m +pvaacffparsernode_lib=m +pvamrffparsernode_lib=m +pvasfffparsernode_lib=n +pvmp3ffparsernode_lib=m +pvmp4ffparsernode_lib=n +pvmp4ffparsernodeopencore_lib=m +pvrmffparsernode_lib=n +pvrtppacketsourcenode_lib=n +nodes_common_headers_lib=m +pvmediainputnode_lib=m +pvmp4ffcomposernode_lib=n +pvmp4ffcomposernodeopencore_lib=m +pvpvr_lib=n +pvpvrnode_lib=n +pvcommsionode_lib=m +pvclientserversocketnode_lib=m +pvloopbacknode_lib=m +pvdivxffparsernode_lib=n +pvstillimagenode_lib=n +g726decnode_lib=n +pvflvffparsernode_lib=n +pvmpeg2ffparsernode_lib=n +pvcommonparsernode_lib=m + + +# +# Menu for configuring Oscl +# +build_oscl=m +unit_test_lib=y +unit_test_utils_lib=y + + +# +# Menu for configuring Protocols +# + +# +# Menu for configuring Value Adds for 2way +# +twoway_value_add_config=y +PV_2WAY_VALUE_ADD_NONE=y + +pv_http_parcom_lib=m +pv_http_retriever_lib=n +pvlatmpayloadparser_lib=m +rdt_parser_lib=n +pv_rtsp_parcom_lib=m +rtppayloadparser_lib=m + +# +# Menu for rtppayload parser plugins +# +rfc_2429=y +rfc_3016=y +rfc_3267=y +rfc_3640=y +rfc_3984=y + +asf_payload_lib=n +realmedia_payload_lib=n +rtprtcp_lib=m +pv324m_lib=m +pv_rtmp_parcom_lib=n +pv_smooth_streaming_lib=n +pv324m_common_headers_lib=m +pvgeneraltools_lib=m +pv_m3u_parser_lib=n + + +# +# Menu for configuring Pvmi +# + +# +# Menu for configuring Recognizers +# +pvmfrecognizer_lib=m +pvaacffrecognizer_lib=m +pvamrffrecognizer_lib=m +pvoma1ffrecognizer_lib=n +pvasfffrecognizer_lib=n +pvmp3ffrecognizer_lib=m +pvmp4ffrecognizer_lib=m +pvmpeg2ffrecognizer_lib=n +pvwavffrecognizer_lib=m +pvrmffrecognizer_lib=n +pvdivxffrecognizer_lib=n +pvplsffrecognizer_lib=m +pvflvffrecognizer_lib=n + + +# +# Menu for configuring Content Policy Manager +# +cpm_lib=m +oma1_passthru_plugin_lib=m +cpm_headers_lib=m +pvoma1lockstream_lib=n +pvplayreadyplugin_lib=n +pvdivxdrmplugin_lib=n +pvdtcpplugin_lib=n + + +# +# Menu for configuring Media IO +# +pvmiofileinput_lib=m +pvmiofileoutput_lib=m +pvmioaviwavfileinput_lib=y +pvmio_comm_loopback_lib=m +pvaudiotrackmio_lib=n + + +# +# Menu for configuring PacketSources +# +packetsources_default_lib=n + +# +# Menu for configuring PacketSource Plugins +# +optimized_bcast_ps_support=n +standard_bcast_ps_support=n + + +pvmf_lib=m +realaudio_deinterleaver_lib=n +pvdbmanager_lib=n +pvdb_recovery_utility_lib=n + + +# +# Menu for configuring Engines +# + +# +# Menu for configuring Player +# +pvplayer_engine_lib=m + +# +# Menu for player engine tunables +# +PVPLAYERENGINE_CONFIG_SYNCMARGIN_EARLY_DEF=-10 +PVPLAYERENGINE_CONFIG_SYNCMARGIN_LATE_DEF=50 +VIDEO_DEC_NODE_LOW_PRIORITY=y +PVPLAYERENGINE_SUPPORT_DTCP=y + + +# +# Menu for configuring player registry +# +BUILD_OMX_VIDEO_DEC_NODE=y +BUILD_OMX_AUDIO_DEC_NODE=y +BUILD_G726_DEC_NODE=n +BUILD_MP4_FF_PARSER_NODE=n +BUILD_MPEG2_FF_PARSER_NODE=n +BUILD_AMR_FF_PARSER_NODE=n +BUILD_AAC_FF_PARSER_NODE=y +BUILD_MP3_FF_PARSER_NODE=y +BUILD_WAV_FF_PARSER_NODE=n +BUILD_ASF_FF_PARSER_NODE=n +BUILD_RM_FF_PARSER_NODE=n +BUILD_STREAMING_MANAGER_NODE=n +BUILD_DOWNLOAD_MANAGER_NODE=n +BUILD_STILL_IMAGE_NODE=n +BUILD_MP4_FF_REC=n +BUILD_MPEG2_FF_REC=n +BUILD_ASF_FF_REC=n +BUILD_OMA1_FF_REC=n +BUILD_AAC_FF_REC=y +BUILD_RM_FF_REC=n +BUILD_MP3_FF_REC=y +BUILD_WAV_FF_REC=y +BUILD_AMR_FF_REC=y +BUILD_DIVX_FF_PARSER_NODE=n +BUILD_DIVX_FF_REC=n +BUILD_PLS_FF_REC=y +BUILD_FLV_FF_PARSER_NODE=n +BUILD_FLV_FF_REC=n +BUILD_COMMON_PARSER_NODE=y + + + +# +# Menu for configuring Author +# +pvauthorengine_lib=m + + +# +# Menu for configuring pv2way +# +pv2wayengine_lib=m +pv2waysample_lib=m + +engines_common_headers_lib=m +pvframemetadatautility_lib=m +pvmetadata_engine_lib=m +pvplayreadyutility_lib=n +pvmp4eu_lib=n + + +# +# Menu for configuring Extern_libs +# +pvmtp_engine_lib=n +pvmtpip_engine_lib=n +pviptransport_lib=n +pvsqlite_lib=n + +# +# Menu for configuring PlayReady wmdrm +# +pvwmdrmmd_lib=n + +pvtinyxml_lib=n +pvdivxdrm_lib=n +pvdivxdrm_oem_settings_lib=n + + +# +# That's all, folks! diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pvplayer.cfg b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pvplayer.cfg new file mode 100644 index 0000000..dedf822 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/pvplayer.cfg @@ -0,0 +1,7 @@ +(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_streamingreg" +(0x47652190,0x4874,0x4057,0x94,0x68,0x3f,0x08,0x29,0xef,0x06,0xb1),"libpvrtspunicast_streamingreg" +(0x47652190,0x4874,0x4057,0x94,0x68,0x3f,0x08,0x29,0xef,0x06,0xb1),"libpvrtsptunicast_streamingreg" +(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_downloadreg" +(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_mp4localreg" +(0x6d3413a0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_mp4localreg" +(0xa054369c,0x22c5,0x412e,0x19,0x17,0x87,0x4c,0x1a,0x19,0xd4,0x5f),"libomx_sharedlibrary" diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/setup.bat b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/setup.bat new file mode 100644 index 0000000..ebe4d5c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/setup.bat @@ -0,0 +1,23 @@ +@echo off +IF (%1)==() echo.Usage !!!ERROR!!! %0 {Base Directory} Use capital letter for drive letter. + +echo Setting up build environment with default configuration ... + +rem *** PROJECT_DIR is used as the project top-level directory. *** +rem *** The path to specify the location of project.mk *** + +set PROJECT_DIR=%cd% +echo Set PROJECT_DIR to %PROJECT_DIR% + +rem *** Set CFG_DIR *** + +set CFG_DIR=%cd% +echo Set CFG_DIR to %CFG_DIR% + +rem *** Setup the default environment *** + +if not exist ($?DEFAULT_SETUP_PATH) set DEFAULT_SETUP_PATH=../default +call %DEFAULT_SETUP_PATH%/setup.bat %1 + +rem *** Append output path of DLLs in PATH *** +set PATH=%BUILD_ROOT%\installed_lib\win32;%PATH% diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/setup.sh b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/setup.sh new file mode 100644 index 0000000..45539a8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/build_config/opencore_dynamic/setup.sh @@ -0,0 +1,11 @@ +## setup the default environment +. ../default/setup.sh + +## include the android definitions for export to android makefiles. +export PLATFORM_EXTRAS=$MK/android_make_extras.mk + +## for make completion targets +mkcmdcmpl + +## END FILE + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/Android.mk new file mode 100644 index 0000000..3588d7b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/Android.mk @@ -0,0 +1,173 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/analysis_sub_band.cpp \ + src/apply_ms_synt.cpp \ + src/apply_tns.cpp \ + src/buf_getbits.cpp \ + src/byte_align.cpp \ + src/calc_auto_corr.cpp \ + src/calc_gsfb_table.cpp \ + src/calc_sbr_anafilterbank.cpp \ + src/calc_sbr_envelope.cpp \ + src/calc_sbr_synfilterbank.cpp \ + src/check_crc.cpp \ + src/dct16.cpp \ + src/dct64.cpp \ + src/decode_huff_cw_binary.cpp \ + src/decode_noise_floorlevels.cpp \ + src/decoder_aac.cpp \ + src/deinterleave.cpp \ + src/digit_reversal_tables.cpp \ + src/dst16.cpp \ + src/dst32.cpp \ + src/dst8.cpp \ + src/esc_iquant_scaling.cpp \ + src/extractframeinfo.cpp \ + src/fft_rx4_long.cpp \ + src/fft_rx4_short.cpp \ + src/fft_rx4_tables_fxp.cpp \ + src/find_adts_syncword.cpp \ + src/fwd_long_complex_rot.cpp \ + src/fwd_short_complex_rot.cpp \ + src/gen_rand_vector.cpp \ + src/get_adif_header.cpp \ + src/get_adts_header.cpp \ + src/get_audio_specific_config.cpp \ + src/get_cce.cpp \ + src/get_dse.cpp \ + src/get_ele_list.cpp \ + src/get_ga_specific_config.cpp \ + src/get_ics_info.cpp \ + src/get_prog_config.cpp \ + src/get_pulse_data.cpp \ + src/get_sbr_bitstream.cpp \ + src/get_sbr_startfreq.cpp \ + src/get_sbr_stopfreq.cpp \ + src/get_tns.cpp \ + src/getfill.cpp \ + src/getgroup.cpp \ + src/getics.cpp \ + src/getmask.cpp \ + src/hcbtables_binary.cpp \ + src/huffcb.cpp \ + src/huffdecode.cpp \ + src/hufffac.cpp \ + src/huffspec_fxp.cpp \ + src/idct16.cpp \ + src/idct32.cpp \ + src/idct8.cpp \ + src/imdct_fxp.cpp \ + src/infoinit.cpp \ + src/init_sbr_dec.cpp \ + src/intensity_right.cpp \ + src/inv_long_complex_rot.cpp \ + src/inv_short_complex_rot.cpp \ + src/iquant_table.cpp \ + src/long_term_prediction.cpp \ + src/long_term_synthesis.cpp \ + src/lt_decode.cpp \ + src/mdct_fxp.cpp \ + src/mdct_tables_fxp.cpp \ + src/mdst.cpp \ + src/mix_radix_fft.cpp \ + src/ms_synt.cpp \ + src/pns_corr.cpp \ + src/pns_intensity_right.cpp \ + src/pns_left.cpp \ + src/ps_all_pass_filter_coeff.cpp \ + src/ps_all_pass_fract_delay_filter.cpp \ + src/ps_allocate_decoder.cpp \ + src/ps_applied.cpp \ + src/ps_bstr_decoding.cpp \ + src/ps_channel_filtering.cpp \ + src/ps_decode_bs_utils.cpp \ + src/ps_decorrelate.cpp \ + src/ps_fft_rx8.cpp \ + src/ps_hybrid_analysis.cpp \ + src/ps_hybrid_filter_bank_allocation.cpp \ + src/ps_hybrid_synthesis.cpp \ + src/ps_init_stereo_mixing.cpp \ + src/ps_pwr_transient_detection.cpp \ + src/ps_read_data.cpp \ + src/ps_stereo_processing.cpp \ + src/pulse_nc.cpp \ + src/pv_div.cpp \ + src/pv_log2.cpp \ + src/pv_normalize.cpp \ + src/pv_pow2.cpp \ + src/pv_sine.cpp \ + src/pv_sqrt.cpp \ + src/pvmp4audiodecoderconfig.cpp \ + src/pvmp4audiodecoderframe.cpp \ + src/pvmp4audiodecodergetmemrequirements.cpp \ + src/pvmp4audiodecoderinitlibrary.cpp \ + src/pvmp4audiodecoderresetbuffer.cpp \ + src/q_normalize.cpp \ + src/qmf_filterbank_coeff.cpp \ + src/sbr_aliasing_reduction.cpp \ + src/sbr_applied.cpp \ + src/sbr_code_book_envlevel.cpp \ + src/sbr_crc_check.cpp \ + src/sbr_create_limiter_bands.cpp \ + src/sbr_dec.cpp \ + src/sbr_decode_envelope.cpp \ + src/sbr_decode_huff_cw.cpp \ + src/sbr_downsample_lo_res.cpp \ + src/sbr_envelope_calc_tbl.cpp \ + src/sbr_envelope_unmapping.cpp \ + src/sbr_extract_extended_data.cpp \ + src/sbr_find_start_andstop_band.cpp \ + src/sbr_generate_high_freq.cpp \ + src/sbr_get_additional_data.cpp \ + src/sbr_get_cpe.cpp \ + src/sbr_get_dir_control_data.cpp \ + src/sbr_get_envelope.cpp \ + src/sbr_get_header_data.cpp \ + src/sbr_get_noise_floor_data.cpp \ + src/sbr_get_sce.cpp \ + src/sbr_inv_filt_levelemphasis.cpp \ + src/sbr_open.cpp \ + src/sbr_read_data.cpp \ + src/sbr_requantize_envelope_data.cpp \ + src/sbr_reset_dec.cpp \ + src/sbr_update_freq_scale.cpp \ + src/set_mc_info.cpp \ + src/sfb.cpp \ + src/shellsort.cpp \ + src/synthesis_sub_band.cpp \ + src/tns_ar_filter.cpp \ + src/tns_decode_coef.cpp \ + src/tns_inv_filter.cpp \ + src/trans4m_freq_2_time_fxp.cpp \ + src/trans4m_time_2_freq_fxp.cpp \ + src/unpack_idx.cpp \ + src/window_tables_fxp.cpp \ + src/pvmp4setaudioconfig.cpp \ + src/../util/getactualaacconfig/src/getactualaacconfig.cpp + + +LOCAL_MODULE := libpv_aac_dec + +LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO $(PV_CFLAGS) +LOCAL_ARM_MODE := arm + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/codecs_v2/audio/aac/dec/src \ + $(PV_TOP)/codecs_v2/audio/aac/dec/include \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + include/decoder_aac.h \ + include/e_tmp4audioobjecttype.h \ + include/pv_audio_type_defs.h \ + include/pvmp4audiodecoder_api.h + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/build/make/aacdec_util.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/build/make/aacdec_util.mk new file mode 100644 index 0000000..0a20342 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/build/make/aacdec_util.mk @@ -0,0 +1,7 @@ +# Makefile segment for aac utility when required along with the decoder + +SRCS += ../util/getactualaacconfig/src/getactualaacconfig.cpp + +# Currently, we don't have a dynamic build that will build only the AAC +# decoder and not the utility. +#HDRS += ../util/getactualaacconfig/include/getactualaacconfig.h diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/build/make/local.mk new file mode 100644 index 0000000..b20488f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/build/make/local.mk @@ -0,0 +1,167 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + +TARGET := pv_aac_dec + + +OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true + +XCPPFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO + +SRCDIR := ../../src +INCSRCDIR := ../../include + +SRCS := analysis_sub_band.cpp \ + apply_ms_synt.cpp \ + apply_tns.cpp \ + buf_getbits.cpp \ + byte_align.cpp \ + calc_auto_corr.cpp \ + calc_gsfb_table.cpp \ + calc_sbr_anafilterbank.cpp \ + calc_sbr_envelope.cpp \ + calc_sbr_synfilterbank.cpp \ + check_crc.cpp \ + dct16.cpp \ + dct64.cpp \ + decode_huff_cw_binary.cpp \ + decode_noise_floorlevels.cpp \ + decoder_aac.cpp \ + deinterleave.cpp \ + digit_reversal_tables.cpp \ + dst16.cpp \ + dst32.cpp \ + dst8.cpp \ + esc_iquant_scaling.cpp \ + extractframeinfo.cpp \ + fft_rx4_long.cpp \ + fft_rx4_short.cpp \ + fft_rx4_tables_fxp.cpp \ + find_adts_syncword.cpp \ + fwd_long_complex_rot.cpp \ + fwd_short_complex_rot.cpp \ + gen_rand_vector.cpp \ + get_adif_header.cpp \ + get_adts_header.cpp \ + get_audio_specific_config.cpp \ + get_cce.cpp \ + get_dse.cpp \ + get_ele_list.cpp \ + get_ga_specific_config.cpp \ + get_ics_info.cpp \ + get_prog_config.cpp \ + get_pulse_data.cpp \ + get_sbr_bitstream.cpp \ + get_sbr_startfreq.cpp \ + get_sbr_stopfreq.cpp \ + get_tns.cpp \ + getfill.cpp \ + getgroup.cpp \ + getics.cpp \ + getmask.cpp \ + hcbtables_binary.cpp \ + huffcb.cpp \ + huffdecode.cpp \ + hufffac.cpp \ + huffspec_fxp.cpp \ + idct16.cpp \ + idct32.cpp \ + idct8.cpp \ + imdct_fxp.cpp \ + infoinit.cpp \ + init_sbr_dec.cpp \ + intensity_right.cpp \ + inv_long_complex_rot.cpp \ + inv_short_complex_rot.cpp \ + iquant_table.cpp \ + long_term_prediction.cpp \ + long_term_synthesis.cpp \ + lt_decode.cpp \ + mdct_fxp.cpp \ + mdct_tables_fxp.cpp \ + mdst.cpp \ + mix_radix_fft.cpp \ + ms_synt.cpp \ + pns_corr.cpp \ + pns_intensity_right.cpp \ + pns_left.cpp \ + ps_all_pass_filter_coeff.cpp \ + ps_all_pass_fract_delay_filter.cpp \ + ps_allocate_decoder.cpp \ + ps_applied.cpp \ + ps_bstr_decoding.cpp \ + ps_channel_filtering.cpp \ + ps_decode_bs_utils.cpp \ + ps_decorrelate.cpp \ + ps_fft_rx8.cpp \ + ps_hybrid_analysis.cpp \ + ps_hybrid_filter_bank_allocation.cpp \ + ps_hybrid_synthesis.cpp \ + ps_init_stereo_mixing.cpp \ + ps_pwr_transient_detection.cpp \ + ps_read_data.cpp \ + ps_stereo_processing.cpp \ + pulse_nc.cpp \ + pv_div.cpp \ + pv_log2.cpp \ + pv_normalize.cpp \ + pv_pow2.cpp \ + pv_sine.cpp \ + pv_sqrt.cpp \ + pvmp4audiodecoderconfig.cpp \ + pvmp4audiodecoderframe.cpp \ + pvmp4audiodecodergetmemrequirements.cpp \ + pvmp4audiodecoderinitlibrary.cpp \ + pvmp4audiodecoderresetbuffer.cpp \ + q_normalize.cpp \ + qmf_filterbank_coeff.cpp \ + sbr_aliasing_reduction.cpp \ + sbr_applied.cpp \ + sbr_code_book_envlevel.cpp \ + sbr_crc_check.cpp \ + sbr_create_limiter_bands.cpp \ + sbr_dec.cpp \ + sbr_decode_envelope.cpp \ + sbr_decode_huff_cw.cpp \ + sbr_downsample_lo_res.cpp \ + sbr_envelope_calc_tbl.cpp \ + sbr_envelope_unmapping.cpp \ + sbr_extract_extended_data.cpp \ + sbr_find_start_andstop_band.cpp \ + sbr_generate_high_freq.cpp \ + sbr_get_additional_data.cpp \ + sbr_get_cpe.cpp \ + sbr_get_dir_control_data.cpp \ + sbr_get_envelope.cpp \ + sbr_get_header_data.cpp \ + sbr_get_noise_floor_data.cpp \ + sbr_get_sce.cpp \ + sbr_inv_filt_levelemphasis.cpp \ + sbr_open.cpp \ + sbr_read_data.cpp \ + sbr_requantize_envelope_data.cpp \ + sbr_reset_dec.cpp \ + sbr_update_freq_scale.cpp \ + set_mc_info.cpp \ + sfb.cpp \ + shellsort.cpp \ + synthesis_sub_band.cpp \ + tns_ar_filter.cpp \ + tns_decode_coef.cpp \ + tns_inv_filter.cpp \ + trans4m_freq_2_time_fxp.cpp \ + trans4m_time_2_freq_fxp.cpp \ + unpack_idx.cpp \ + window_tables_fxp.cpp \ + pvmp4setaudioconfig.cpp + + +HDRS := decoder_aac.h e_tmp4audioobjecttype.h pv_audio_type_defs.h pvmp4audiodecoder_api.h + +# include $(call process_include_list,$(LOCAL_PATH),$(pv_aac_dec_plugins)) + +include $(MK)/library.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/decoder_aac.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/decoder_aac.h new file mode 100644 index 0000000..68271f6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/decoder_aac.h @@ -0,0 +1,101 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \file decoder_aac.h + * \brief Header file for the AAC MDF wrapper + * + */ + +#ifndef __DECODER_AAC_H +#define __DECODER_AAC_H + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#include "oscl_base.h" +#include "pvmp4audiodecoder_api.h" + +#include "e_tmp4audioobjecttype.h" +extern Int PVMP4SetAudioConfig(tPVMP4AudioDecoderExternal *pExt, void *pMem, Int upsamplingFactor, Int samp_rate, Int num_ch, tMP4AudioObjectType audioObjectType); + +/*! + * \brief number of samples per frame (decoded frames) + */ + +#define KAAC_NUM_SAMPLES_PER_FRAME 1024 +#define KAAC_MAX_STREAMING_BUFFER_SIZE (PVMP4AUDIODECODER_INBUFSIZE * 1) + +#define KCAI_CODEC_NO_MEMORY -1 +#define KCAI_CODEC_INIT_FAILURE -2 + + + +/*! + * \class CDecoder_AAC "include/decoder_aac.h" + * \brief AAC Decoder class + */ + + +// CDecoder_AAC +class CDecoder_AAC +{ + public: + OSCL_IMPORT_REF void ConstructL(); + OSCL_IMPORT_REF static CDecoder_AAC *NewL(); + OSCL_IMPORT_REF ~CDecoder_AAC(); + + OSCL_IMPORT_REF int32 StartL(tPVMP4AudioDecoderExternal * pExt, + uint8 num_channels, + bool aAllocateInputBuffer = false, + bool aAllocateOutputBuffer = false, + Int upsamplingFactor = 1, + Int samp_rate = 44100, + tMP4AudioObjectType audioObjectType = MP4AUDIO_AAC_LC + ); + + OSCL_IMPORT_REF int32 StartL(tPVMP4AudioDecoderExternal * pExt, + uint8 num_channels, + bool aAllocateInputBuffer = false, + bool aAllocateOutputBuffer = false, + bool aAacplusEnabler = true + ); + OSCL_IMPORT_REF int32 ExecuteL(tPVMP4AudioDecoderExternal * pExt); + OSCL_IMPORT_REF void ResetDecoderL(void); + OSCL_IMPORT_REF void StopL(void); + + OSCL_IMPORT_REF void TerminateDecoderL(); + OSCL_IMPORT_REF int32 RetrieveDecodedStreamTypeL(tPVMP4AudioDecoderExternal * pExt); + + OSCL_IMPORT_REF void DisableSbrDecodingL(tPVMP4AudioDecoderExternal * pExt); + + private: + // number of samples per frame per channel (decoded) + uint32 iNumSamplesPerFrame; + bool iFirstFrame; + uint8 *pMem; + + bool iAllocateInputBuffer; + bool iAllocateOutputBuffer; + + uint8* iInputBuf; + int16* iOutputBuf; +}; + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/e_tmp4audioobjecttype.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/e_tmp4audioobjecttype.h new file mode 100644 index 0000000..30b8d19 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/e_tmp4audioobjecttype.h @@ -0,0 +1,118 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_tmp4audioobjecttype.h + + This file contains enumerated types for MP4 Audio Object Types, as defined + in ISO/IEC 14496-3, AMMENDMENT 1 Dated 2000-09-15 + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_TMP4AUDIOOBJECTTYPE_H +#define E_TMP4AUDIOOBJECTTYPE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + typedef enum eMP4AudioObjectType + { + MP4AUDIO_NULL = 0, /* */ + MP4AUDIO_AAC_MAIN = 1, /* */ + MP4AUDIO_AAC_LC = 2, /* LC = Low Complexity */ + MP4AUDIO_AAC_SSR = 3, /* SSR = Scalable Sampling Rate */ + MP4AUDIO_LTP = 4, /* LTP = Long Term Prediction */ + MP4AUDIO_SBR = 5, /* SBR = Spectral Band Replication */ + MP4AUDIO_AAC_SCALABLE = 6, /* scales both bitrate and sampling rate */ + MP4AUDIO_TWINVQ = 7, /* low bit rate */ + MP4AUDIO_CELP = 8, + MP4AUDIO_HVXC = 9, + /* 10 is reserved */ + /* 11 is reserved */ + MP4AUDIO_TTSI = 12, + /* 13-16 are synthesis and MIDI types */ + MP4AUDIO_ER_AAC_LC = 17, /* */ + /* 18 is reserved */ + MP4AUDIO_ER_AAC_LTP = 19, /* */ + MP4AUDIO_ER_AAC_SCALABLE = 20, /* */ + MP4AUDIO_ER_TWINVQ = 21, /* */ + MP4AUDIO_ER_BSAC = 22, /* */ + MP4AUDIO_ER_AAC_LD = 23, /* */ + MP4AUDIO_ER_CELP = 24, /* */ + MP4AUDIO_ER_HVXC = 25, /* */ + MP4AUDIO_ER_HILN = 26, /* */ + MP4AUDIO_PARAMETRIC = 27, /* */ + MP4AUDIO_PS = 29 /* Explicit Parametric Stereo */ + + } tMP4AudioObjectType; + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + /* Should not be any function declarations in this file */ + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* E_TMP4AUDIOOBJECTTYPE_H */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/pv_audio_type_defs.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/pv_audio_type_defs.h new file mode 100644 index 0000000..e9b40d8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/pv_audio_type_defs.h @@ -0,0 +1,185 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + Filename: pv_audio_type_defs.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file was derived from a number of standards bodies. The type + definitions below were created from some of the best practices observed + in the standards bodies. + + This file is dependent on limits.h for defining the bit widths. In an + ANSI C environment limits.h is expected to always be present and contain + the following definitions: + + SCHAR_MIN + SCHAR_MAX + UCHAR_MAX + + INT_MAX + INT_MIN + UINT_MAX + + SHRT_MIN + SHRT_MAX + USHRT_MAX + + LONG_MIN + LONG_MAX + ULONG_MAX + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_AUDIO_TYPE_DEFS_H +#define PV_AUDIO_TYPE_DEFS_H + +#include "oscl_base.h" + + +#ifndef Char +typedef int8 Char; +#endif + +#ifndef UChar +typedef uint8 UChar; +#endif + + + +/*---------------------------------------------------------------------------- +; Define generic signed and unsigned int +----------------------------------------------------------------------------*/ +#ifndef Int +typedef signed int Int; +#endif + +#ifndef UInt +typedef unsigned int UInt; +#endif + + +/*---------------------------------------------------------------------------- +; Define 16 bit signed and unsigned words +----------------------------------------------------------------------------*/ + + +#ifndef Int16 +typedef int16 Int16; +#endif + +#ifndef INT16_MIN +#define INT16_MIN (-32768) +#endif + +#ifndef INT16_MAX +#define INT16_MAX 32767 +#endif + +#ifndef UInt16 +typedef uint16 UInt16; + +#endif + + +/*---------------------------------------------------------------------------- +; Define 32 bit signed and unsigned words +----------------------------------------------------------------------------*/ + + +#ifndef Int32 +typedef int32 Int32; +#endif + +#ifndef INT32_MIN +#define INT32_MIN (-2147483647 - 1) +#endif +#ifndef INT32_MAX +#define INT32_MAX 2147483647 +#endif + +#ifndef UInt32 +typedef uint32 UInt32; +#endif + +#ifndef UINT32_MIN +#define UINT32_MIN 0 +#endif +#ifndef UINT32_MAX +#define UINT32_MAX 0xffffffff +#endif + + +#ifndef INT_MAX +#define INT_MAX INT32_MAX /* for 32 bit */ +#endif + +/*---------------------------------------------------------------------------- +; Define 64 bit signed and unsigned words +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; Define boolean type +----------------------------------------------------------------------------*/ +#ifndef Bool +typedef Int Bool; +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef OFF +#define OFF 0 +#endif +#ifndef ON +#define ON 1 +#endif + +#ifndef NO +#define NO 0 +#endif +#ifndef YES +#define YES 1 +#endif + +#ifndef SUCCESS +#define SUCCESS 0 +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef LEFT +#define LEFT 0 +#endif + +#ifndef RIGHT +#define RIGHT 1 +#endif + + +#endif /* PV_AUDIO_TYPE_DEFS_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/pvmp4audiodecoder_api.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/pvmp4audiodecoder_api.h new file mode 100644 index 0000000..20b0e46 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/include/pvmp4audiodecoder_api.h @@ -0,0 +1,377 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Name: PVMP4AudioDecoder_API.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Main header file for the Packet Video MP4/AAC audio decoder library. The + constants, structures, and functions defined within this file, along with + a basic data types header file, is all that is needed to use and communicate + with the library. The internal data structures within the library are + purposely hidden. + + ---* Need description of the input buffering. *------- + + ---* Need an example of calling the library here *---- + +------------------------------------------------------------------------------ + REFERENCES + + (Normally header files do not have a reference section) + + ISO/EIC 14496-3:(1999) Document titled +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP4AUDIODECODER_API_H +#define PVMP4AUDIODECODER_API_H + +#include "pv_audio_type_defs.h" /* Basic data types used within the lib */ + +#include "e_tmp4audioobjecttype.h" + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /* + * This constant is the guaranteed-to-work buffer size, specified in bytes, + * for the input buffer for 2 audio channels to decode one frame of data, + * as specified by the MPEG-2 or MPEG-4 standard. + * The standard, and this constant, do not take into account that lower + * bitrates will use less data per frame. Note that the number of bits + * used per frame is variable, and only that the average value will be the + * bit rate specified during encoding. The standard does not specify + * over how many frames the average must be maintained. + * + * The constant value is 6144 * 2 channels / 8 bits per byte + */ + +#define PV_MAX_AAC_FRAME_SIZE_2_CH 1536 + + +#define PVMP4AUDIODECODER_INBUFSIZE PV_MAX_AAC_FRAME_SIZE_2_CH + + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + /* + * This enumeration is used for the structure element outputFormat. It + * specifies how the output data is to be formatted. Presently only 16-bit + * PCM data is supported, and this enum informs how the single output + * buffer should be for two-channel stereo data. + * Grouped format stores all the left channel values, then right: + * "LLLL...LLRRRR...RR" + * Interleave format store left, then right audio samples: + * "LRLRLRLR...." + */ + typedef enum ePVMP4AudioDecoderOutputFormat + { + OUTPUTFORMAT_16PCM_GROUPED = 0, + OUTPUTFORMAT_16PCM_INTERLEAVED = 1 + + } tPVMP4AudioDecoderOutputFormat; + + /* + * This enumeration holds the possible return values for the main decoder + * function, PVMP4AudioDecodeFrame. The plan was to easily distinguish + * whether an error was recoverable (streaming mode) or not. Presently no + * errors are recoverable, which is a result of not supporting ADTS in + * this release. + */ + typedef enum ePVMP4AudioDecoderErrorCode + { + MP4AUDEC_SUCCESS = 0, + MP4AUDEC_INVALID_FRAME = 10, + MP4AUDEC_INCOMPLETE_FRAME = 20, + MP4AUDEC_LOST_FRAME_SYNC = 30, /* Cannot happen since no ADTS */ + MP4AUDEC_PCE_CHANGE_REQUEST = 40 /* PCE change signal a change on + * parameters that require + * decoder reconfiguration + */ + } tPVMP4AudioDecoderErrorCode; + + + /* + * This enumeration holds the possible return values for stream type + * being decoded + */ + typedef enum + { + AAC = 0, + AACPLUS, + ENH_AACPLUS + } STREAMTYPE; + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + /* + * This structure is used to communicate information in to and out of the + * AAC decoder. + */ + + typedef struct +#ifdef __cplusplus + tPVMP4AudioDecoderExternal // To allow forward declaration of this struct in C++ +#endif + { + /* + * INPUT: + * Pointer to the input buffer that contains the encoded bistream data. + * The data is filled in such that the first bit transmitted is + * the most-significant bit (MSB) of the first array element. + * The buffer is accessed in a linear fashion for speed, and the number of + * bytes consumed varies frame to frame. + * The calling environment can change what is pointed to between calls to + * the decode function, library, as long as the inputBufferCurrentLength, + * and inputBufferUsedLength are updated too. Also, any remaining bits in + * the old buffer must be put at the beginning of the new buffer. + */ + UChar *pInputBuffer; + + /* + * INPUT: + * Number of valid bytes in the input buffer, set by the calling + * function. After decoding the bitstream the library checks to + * see if it when past this value; it would be to prohibitive to + * check after every read operation. This value is not modified by + * the AAC library. + */ + Int inputBufferCurrentLength; + + /* + * INPUT: + * The actual size of the buffer. + * This variable is not used by the library, but is used by the + * console test application. This parameter could be deleted + * if this value was passed into these function. The helper functions are + * not part of the library and are not used by the Common Audio Decoder + * Interface. + */ + Int inputBufferMaxLength; + + /* + * INPUT: + * Enumerated value the output is to be interleaved left-right-left-right. + * For further information look at the comments for the enumeration. + */ + tPVMP4AudioDecoderOutputFormat outputFormat; + + /* + * INPUT: (but what is pointed to is an output) + * Pointer to the output buffer to hold the 16-bit PCM audio samples. + * If the output is stereo, both left and right channels will be stored + * in this one buffer. Presently it must be of length of 2048 points. + * The format of the buffer is set by the parameter outputFormat. + */ + Int16 *pOutputBuffer; + + /* + * INPUT: (but what is pointed to is an output) + * Pointer to the output buffer to hold the 16-bit PCM AAC-plus audio samples. + * If the output is stereo, both left and right channels will be stored + * in this one buffer. Presently it must be of length of 2048 points. + * The format of the buffer is set by the parameter outputFormat. + */ + Int16 *pOutputBuffer_plus; /* Used in AAC+ and enhanced AAC+ */ + + /* + * INPUT: + * AAC Plus Upsampling Factor. Normally set to 2 when Spectrum Band + * Replication (SBR) is used + */ + Int32 aacPlusUpsamplingFactor; /* Used in AAC+ and enhanced AAC+ */ + + /* + * INPUT: + * AAC Plus enabler. Deafaults to be ON, unless run time conditions + * require the SBR and PS tools disabled + */ + bool aacPlusEnabled; + /* + * INPUT: + * (Currently not being used inside the AAC library.) + * This flag is set to TRUE when the playback position has been changed, + * for example, rewind or fast forward. This informs the AAC library to + * take an appropriate action, which has yet to be determined. + */ + Bool repositionFlag; + + /* + * INPUT: + * Number of requested output audio channels. This relieves the calling + * environment from having to perform stereo-to-mono or mono-to-stereo + * conversions. + */ + Int desiredChannels; + + /* + * INPUT/OUTPUT: + * Number of elements used by the library, initially set to zero by + * the function PVMP4AudioDecoderInitLibrary, and modified by each + * call to PVMP4AudioDecodeFrame. + */ + Int inputBufferUsedLength; + + /* + * INPUT/OUTPUT: + * Number of bits left over in the next buffer element, + * This value will always be zero, unless support for ADTS is added. + */ + Int32 remainderBits; + + /* + * OUTPUT: + * The sampling rate decoded from the bitstream, in units of + * samples/second. For this release of the library this value does + * not change from frame to frame, but future versions will. + */ + Int32 samplingRate; + + /* + * OUTPUT: + * This value is the bitrate in units of bits/second. IT + * is calculated using the number of bits consumed for the current frame, + * and then multiplying by the sampling_rate, divided by points in a frame. + * This value can changes frame to frame. + */ + Int32 bitRate; + + /* + * OUTPUT: + * The number of channels decoded from the bitstream. The output data + * will have be the amount specified in the variable desiredChannels, + * this output is informative only, and can be ignored. + */ + Int encodedChannels; + + /* + * OUTPUT: + * This value is the number of output PCM samples per channel. + * It is presently hard-coded to 1024, but may change in the future. + * It will not change frame to frame, and would take on + * one of these four values: 1024, 960, 512, or 480. If an error occurs + * do not rely on this value. + */ + Int frameLength; + + /* + * This value is audio object type as defined in struct tMP4AudioObjectType + * in file e_tMP4AudioObjectType.h + */ + Int audioObjectType; + + /* + * This value is extended audio object type as defined in struct tMP4AudioObjectType + * in file e_tMP4AudioObjectType.h. It carries the output Audio Object Type + */ + Int extendedAudioObjectType; + + /* + * This value indicates if the clip is multichannel, if true, it will only decode the + * front channel stereo or mono(if stereo not available) + */ + bool multichannel_detected; + + /* + * This value indicates the total number of channels detected in a multichannel clip + * format (number of channel)<<1 + lfe + * i.e. 5.1 === 11 <> (5 channels)<<1 + 1 lfe + */ + Int multichannel_numChannels; + + + } tPVMP4AudioDecoderExternal; + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + OSCL_IMPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void); + + OSCL_IMPORT_REF Int PVMP4AudioDecoderInitLibrary( + tPVMP4AudioDecoderExternal *pExt, + void *pMem); + + OSCL_IMPORT_REF Int PVMP4AudioDecodeFrame( + tPVMP4AudioDecoderExternal *pExt, + void *pMem); + + OSCL_IMPORT_REF Int PVMP4AudioDecoderConfig( + tPVMP4AudioDecoderExternal *pExt, + void *pMem); + + OSCL_IMPORT_REF void PVMP4AudioDecoderResetBuffer( + void *pMem); + + OSCL_IMPORT_REF void PVMP4AudioDecoderDisableAacPlus( + tPVMP4AudioDecoderExternal *pExt, + void *pMem); + + Int PVMP4SetAudioConfig( + tPVMP4AudioDecoderExternal *pExt, + void *pMem, + Int upsamplingFactor, + Int samp_rate, + int num_ch, + tMP4AudioObjectType audioObjectType); + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif /* PVMP4AUDIODECODER_API_H */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/aac_mem_funcs.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/aac_mem_funcs.h new file mode 100644 index 0000000..cdd1e44 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/aac_mem_funcs.h @@ -0,0 +1,48 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: aac_mem_funcs.h + Funtions: + + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ + +#ifndef AAC_MEM_FUNCS_H +#define AAC_MEM_FUNCS_H + + +#include "pv_audio_type_defs.h" +#include "oscl_mem.h" + + + +#define pv_memset(to, c, n) oscl_memset(to, c, n) + + +#define pv_memcpy(to, from, n) oscl_memcpy(to, from, n) +#define pv_memmove(to, from, n) oscl_memmove(to, from, n) +#define pv_memcmp(p, q, n) oscl_memcmp(p, q, n) + + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/analysis_sub_band.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/analysis_sub_band.cpp new file mode 100644 index 0000000..87d6252 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/analysis_sub_band.cpp @@ -0,0 +1,282 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: analysis_sub_band.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 vec[], Input vector, 32-bit + const Int32 *cosTerms, Cosine Terms + Int maxbands number of bands used + Int32 *scratch_mem Scratch memory + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement root squared of a number + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "analysis_sub_band.h" +#include "dst32.h" +#include "idct32.h" +#include "mdst.h" + +#include "aac_mem_funcs.h" +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +#ifdef HQ_SBR + + +const Int32 exp_1_5_phi[32] = +{ + + 0x7FEA04B6, 0x7F380E1C, 0x7DD6176E, 0x7BC6209F, + 0x790A29A4, 0x75A6326E, 0x719E3AF3, 0x6CF94326, + 0x67BD4AFB, 0x61F15269, 0x5B9D5964, 0x54CA5FE4, + 0x4D8165DE, 0x45CD6B4B, 0x3DB87023, 0x354E7460, + 0x2C9977FB, 0x23A77AEF, 0x1A837D3A, 0x113A7ED6, + 0x07D97FC2, 0xFE6E7FFE, 0xF5057F87, 0xEBAB7E60, + 0xE26D7C89, 0xD9587A06, 0xD07976D9, 0xC7DB7308, + 0xBF8C6E97, 0xB796698C, 0xB00563EF, 0xA8E25DC8, + +}; + +#endif + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void analysis_sub_band_LC(Int32 vec[64], + Int32 cosine_total[], + Int32 maxBand, + Int32 scratch_mem[][64]) +{ + Int32 i; + Int32 *cosine_term = &scratch_mem[0][0]; + Int32 *sine_term = &scratch_mem[0][32]; + + Int32 *pt_cos_t; + + + Int32 *pt_vec = &vec[0]; + Int32 *pt_vec_32 = &vec[32]; + + Int32 *pt_cos = cosine_term; + Int32 *pt_sin = sine_term; + + for (i = 8; i != 0; i--) + { + Int32 tmp1 = *(pt_vec_32++); + Int32 tmp3 = *(pt_vec_32++); + Int32 tmp2 = *(pt_vec++); + Int32 tmp4 = *(pt_vec++); + *(pt_cos++) = (tmp1 - tmp2) >> 1; + *(pt_cos++) = (tmp3 - tmp4) >> 1; + *(pt_sin++) = (tmp1 + tmp2); + *(pt_sin++) = (tmp3 + tmp4); + tmp1 = *(pt_vec_32++); + tmp3 = *(pt_vec_32++); + tmp2 = *(pt_vec++); + tmp4 = *(pt_vec++); + *(pt_cos++) = (tmp1 - tmp2) >> 1; + *(pt_cos++) = (tmp3 - tmp4) >> 1; + *(pt_sin++) = (tmp1 + tmp2); + *(pt_sin++) = (tmp3 + tmp4); + } + + + idct_32(cosine_term, scratch_mem[1]); + + dst_32(sine_term, scratch_mem[1]); + + pt_cos = cosine_term; + pt_sin = sine_term; + + pt_cos_t = cosine_total; + + for (i = 0; i < maxBand; i += 4) + { + *(pt_cos_t++) = (*(pt_cos++) + *(pt_sin++)); + *(pt_cos_t++) = (-*(pt_cos++) + *(pt_sin++)); + *(pt_cos_t++) = (-*(pt_cos++) - *(pt_sin++)); + *(pt_cos_t++) = (*(pt_cos++) - *(pt_sin++)); + } + + pt_cos_t = &cosine_total[maxBand]; + + for (i = (32 - maxBand); i != 0; i--) + { + *(pt_cos_t++) = 0; + } +} + + +#ifdef HQ_SBR + + +void analysis_sub_band(Int32 vec[64], + Int32 cosine_total[], + Int32 sine_total[], + Int32 maxBand, + Int32 scratch_mem[][64]) +{ + Int32 i; + Int32 *sine_term1 = &scratch_mem[0][0]; + Int32 *sine_term2 = &scratch_mem[0][32]; + + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + + const Int32 *pt_exp; + Int32 exp_1_5; + + Int32 *pt_vec = &vec[0]; + Int32 *pt_vec_32 = &vec[32]; + + Int32 *pt_cos1 = pt_vec; + Int32 *pt_sin1 = sine_term1; + Int32 *pt_cos2 = pt_vec_32; + Int32 *pt_sin2 = sine_term2; + + + pv_memcpy(sine_term1, vec, 64*sizeof(*vec)); + + mdst_32(sine_term1, scratch_mem[1]); + mdst_32(sine_term2, scratch_mem[1]); + + mdct_32(&vec[ 0]); + mdct_32(&vec[32]); + + pt_cos1 = &vec[ 0]; + pt_cos2 = &vec[32]; + + + pt_sin1 = sine_term1; + pt_sin2 = sine_term2; + + pt_vec = cosine_total; + pt_vec_32 = sine_total; + pt_exp = exp_1_5_phi; + + temp3 = (*(pt_cos1++) - *(pt_sin2++)); + temp4 = (*(pt_sin1++) + *(pt_cos2++)); + + for (i = 0; i < maxBand; i += 2) + { + + exp_1_5 = *(pt_exp++); + temp1 = cmplx_mul32_by_16(temp3, temp4, exp_1_5); + temp2 = cmplx_mul32_by_16(temp4, -temp3, exp_1_5); + + *(pt_vec++) = shft_lft_1(temp1); + *(pt_vec_32++) = shft_lft_1(temp2); + + temp3 = (*(pt_cos1++) + *(pt_sin2++)); + temp4 = (*(pt_sin1++) - *(pt_cos2++)); + + exp_1_5 = *(pt_exp++); + temp1 = cmplx_mul32_by_16(temp3, temp4, exp_1_5); + temp2 = cmplx_mul32_by_16(temp4, -temp3, exp_1_5); + + *(pt_vec++) = shft_lft_1(temp1); + *(pt_vec_32++) = shft_lft_1(temp2); + + temp3 = (*(pt_cos1++) - *(pt_sin2++)); + temp4 = (*(pt_sin1++) + *(pt_cos2++)); + } + + + pt_cos1 = &cosine_total[maxBand]; /* in the chance that maxband is not even */ + pt_sin1 = &sine_total[maxBand]; + + for (i = (32 - maxBand); i != 0; i--) + { + *(pt_cos1++) = 0; + *(pt_sin1++) = 0; + } + +} + + +#endif + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/analysis_sub_band.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/analysis_sub_band.h new file mode 100644 index 0000000..3c3c1fb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/analysis_sub_band.h @@ -0,0 +1,77 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: analysis_sub_band.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef ANALYSIS_SUB_BAND_H +#define ANALYSIS_SUB_BAND_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + void analysis_sub_band_LC(Int32 vec[64], + Int32 cosine_total[], + Int32 maxBand, + Int32 scratch_mem[][64]); + +#ifdef HQ_SBR + + + void analysis_sub_band(Int32 vec[64], + Int32 cosine_total[], + Int32 sine_total[], + Int32 maxBand, + Int32 scratch_mem[][64]); + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* ANALYSIS_SUB_BAND_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_ms_synt.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_ms_synt.cpp new file mode 100644 index 0000000..b1a1164 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_ms_synt.cpp @@ -0,0 +1,427 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: apply_ms_synt.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + pFrameInfo = Pointer to structure that holds information about each group. + (long block flag, number of windows, scalefactor bands + per group, etc.) + [const pFrameInfo * const] + + group = Array that contains indexes of the + first window in the next group. + [const Int *, length 8] + + mask_map = Array that denotes whether M/S stereo is turned on for + each grouped scalefactor band. + [const Int *, length MAX_SFB] + + codebook_map = Array that denotes which Huffman codebook was used for + the encoding of each grouped scalefactor band. + [const Int *, length MAX_SFB] + + coefLeft = Array containing the fixed-point spectral coefficients + for the left channel. + [Int32 *, length 1024] + + coefRight = Array containing the fixed-point spectral coefficients + for the right channel. + [Int32 *, length 1024] + + q_formatLeft = The Q-format for the left channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAX_SFB] + + q_formatRight = The Q-format for the right channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAX_SFB] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coefLeft = Contains the new spectral information. + + coefRight = Contains the new spectral information. + + q_formatLeft = Q-format may be updated with changed to fixed-point + data in coefLeft. + + q_formatRight = Q-format may be updated with changed to fixed-point + data in coefRight. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function steps through all of the tools that are applied on a + scalefactor band basis. + + The use of M/S stereo is checked for. For M/S decoding to take + place, ms_mask_map must be TRUE for that particular SFB, AND the Huffman + codebook used must be < NOISE_HCB. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.7.1 M/S stereo + Subpart 4.6.2 ScaleFactors + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pCoefRight = coefRight; + pCoefLeft = coefLeft; + + window_start = 0; + tot_sfb = 0; + + coef_per_win = pFrameInfo->coef_per_win[0]; + + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + DO + + pBand = pFrameInfo->win_sfb_top[window_start]; + + partition = *(pGroup); + + pGroup = pGroup + 1; + + band_start = 0; + + wins_in_group = (partition - window_start); + + FOR (sfb = sfb_per_win; sfb > 0; sfb--) + + band_stop = *(pBand); + + pBand = pBand + 1; + + codebook = *(pCodebookMap); + + pCodebookMap = pCodebookMap + 1; + + mask_enabled = *(pMaskMap); + + pMaskMap = pMaskMap + 1; + + IF (codebook < NOISE_HCB) + THEN + IF (mask_enabled != FALSE) + THEN + band_length = band_stop - band_start; + + CALL + ms_synt( + wins_in_group, + coef_per_win, + sfb_per_win, + band_length, + &(pCoefLeft[band_start]), + &(pCoefRight[band_start]), + &(q_formatLeft[tot_sfb]), + &(q_formatRight[tot_sfb]) ); + + MODIFYING + &(pCoefLeft[band_start]), + &(pCoefRight[band_start]), + &(q_formatLeft[tot_sfb]), + &(q_formatRight[tot_sfb]) + + RETURNING + None + ENDIF + ENDIF + band_start = band_stop; + + tot_sfb = tot_sfb + 1; + + ENDFOR + + pCoefRight = pCoefRight + coef_per_win * wins_in_group; + pCoefLeft = pCoefLeft + coef_per_win * wins_in_group; + + wins_in_group = wins_in_group - 1; + + tot_sfb = tot_sfb + sfb_per_win * wins_in_group; + + window_start = partition; + + WHILE (partition < pFrameInfo->num_win); + + return; +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "apply_ms_synt.h" +#include "e_huffmanconst.h" +#include "ms_synt.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void apply_ms_synt( + const FrameInfo * const pFrameInfo, + const Int group[], + const Bool mask_map[], + const Int codebook_map[], + Int32 coefLeft[], + Int32 coefRight[], + Int q_formatLeft[MAXBANDS], + Int q_formatRight[MAXBANDS]) + +{ + + Int32 *pCoefRight; + + Int32 *pCoefLeft; + + Int tot_sfb; + Int sfb; + + Int band_length; + Int band_start; + Int band_stop; + Int coef_per_win; + + Int codebook; + Int partition; + Int window_start; + + Int sfb_per_win; + Int wins_in_group; + + const Int16 *pBand; + const Int *pCodebookMap = codebook_map; + const Int *pGroup = group; + const Bool *pMaskMap = mask_map; + + Bool mask_enabled; + + pCoefRight = coefRight; + pCoefLeft = coefLeft; + + window_start = 0; + tot_sfb = 0; + + /* + * Each window in the frame should have the same number of coef's, + * so coef_per_win is constant in all the loops + */ + coef_per_win = pFrameInfo->coef_per_win[0]; + + /* + * Because the number of scalefactor bands per window should be + * constant for each frame, sfb_per_win can be determined outside + * of the loop. + * + * For 44.1 kHz sampling rate sfb_per_win = 14 for short windows + * sfb_per_win = 49 for long windows + */ + + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + do + { + pBand = pFrameInfo->win_sfb_top[window_start]; + + /* + * Partition is equal to the first window in the next group + * + * { Group 0 }{ Group 1 }{ Group 2 }{Group 3} + * [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7] + * + * pGroup[0] = 2 + * pGroup[1] = 5 + * pGroup[2] = 7 + * pGroup[3] = 8 + */ + + partition = *(pGroup++); + + if (partition == 0) + { + break; /* error condition */ + } + + band_start = 0; + + wins_in_group = (partition - window_start); + + for (sfb = sfb_per_win; sfb > 0; sfb--) + { + /* band is offset table, band_stop is last coef in band */ + band_stop = *(pBand++); + + codebook = *(pCodebookMap++); + + mask_enabled = *(pMaskMap++); + + /* + * When a codebook < NOISE_HCB is found, apply M/S to that + * scalefactorband. + * + * Example... sfb[3] == NOISE_HCB + * + * [ Group 1 ] + * [win 0 ][win 1 ] + * [0][1][2][X][4][5][6][7][0][1][2][X][4][5][6][7] + * + * The for(sfb) steps through the sfb's 0-7 in win 0. + * + * Finding sfb[3]'s codebook == NOISE_HCB, the code + * steps through all the windows in the group (they share + * the same scalefactors) and replaces that sfb with noise. + */ + + if (codebook < NOISE_HCB) + { + if (mask_enabled != FALSE) + { + band_length = band_stop - band_start; + + ms_synt( + wins_in_group, + coef_per_win, + sfb_per_win, + band_length, + &(pCoefLeft[band_start]), + &(pCoefRight[band_start]), + &(q_formatLeft[tot_sfb]), + &(q_formatRight[tot_sfb])); + } + } + band_start = band_stop; + + tot_sfb++; + + } /* for (sfb) */ + + /* + * Increment pCoefRight and pCoefLeft by + * coef_per_win * the number of windows + */ + + pCoefRight += coef_per_win * wins_in_group; + pCoefLeft += coef_per_win * wins_in_group--; + + /* + * Increase tot_sfb by sfb_per_win times the number of windows minus 1. + * The minus 1 comes from the fact that tot_sfb is already pointing + * to the first sfb in the 2nd window of the group. + */ + tot_sfb += sfb_per_win * wins_in_group; + + window_start = partition; + + } + while (partition < pFrameInfo->num_win); + + /* pFrameInfo->num_win = 1 for long windows, 8 for short_windows */ + + return; + +} /* apply_ms_synt() */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_ms_synt.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_ms_synt.h new file mode 100644 index 0000000..88b7874 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_ms_synt.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: apply_ms_synt.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes the function declaration for apply_ms_synt(). + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef APPLY_MS_SYNT_H +#define APPLY_MS_SYNT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void apply_ms_synt( + const FrameInfo * const pFrameInfo, + const Int group[], + const Bool mask_map[], + const Int codebook_map[], + Int32 coefLeft[], + Int32 coefRight[], + Int q_formatLeft[MAXBANDS], + Int q_formatRight[MAXBANDS]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_tns.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_tns.cpp new file mode 100644 index 0000000..8edbfae --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_tns.cpp @@ -0,0 +1,402 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: apply_tns.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + coef = Array of input coefficients. + [Int32 *, length 1024] + + q_format = Array of q-formats, one per scalefactor band, for the + entire frame. In the case of tns_inv_filter, only the + first element is used, since the input to tns_inv_filter + is all of the same q-format. + [Int * const, length MAX_SFB] + + pFrameInfo = Pointer to structure that holds information about each group. + (long block flag, number of windows, scalefactor bands + per group, etc.) + [const FrameInfo * const] + + pTNS_frame_info = pointer to structure containing the details on each + TNS filter (order, filter coefficients, + coefficient res., etc.) + [TNS_frame_info * const] + + inverse_flag = TRUE if inverse filter is to be applied. + FALSE if forward filter is to be applied. + [Bool] + + scratch_Int_buffer = Pointer to scratch memory to store the + filter's state memory. Used by both + tns_inv_filter. + [Int *, length TNS_MAX_ORDER] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coef[] = TNS altered data. + q_format = q-formats in TNS scalefactor bands may be modified. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function applies either the TNS forward or TNS inverse filter, based + on inverse_flag being FALSE or TRUE, respectively. + + For the TNS forward filter, the data fed into tns_ar_filter is normalized + all to the same q-format. + +------------------------------------------------------------------------------ + REQUIREMENTS + + The input, coef, should use all 32-bits, else the scaling by tns_ar_filter + may eliminate the data. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.8 (Temporal Noise Shaping) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + NO PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tns_frame_info.h" +#include "s_tnsfilt.h" +#include "s_frameinfo.h" +#include "tns_inv_filter.h" +#include "tns_ar_filter.h" +#include "apply_tns.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void apply_tns( + Int32 coef[], + Int q_format[], + const FrameInfo * const pFrameInfo, + TNS_frame_info * const pTNS_frame_info, + const Bool inverse_flag, + Int32 scratch_Int_buffer[]) +{ + Int num_tns_bands; + Int num_TNS_coef; + + Int f; + + Int tempInt; + Int tempInt2; + + Int sfb_per_win; + Int sfbWidth; + + Int coef_per_win; + Int min_q; + Int win; + + Int32 *pCoef = coef; + Int32 *pTempCoef; + + Int *pStartQformat = q_format; + + Int *pQformat; + Int32 *pLpcCoef; + + Int sfb_offset; + + const Int16 *pWinSfbTop; + + TNSfilt *pFilt; + + coef_per_win = pFrameInfo->coef_per_win[0]; + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + win = 0; + + pLpcCoef = pTNS_frame_info->lpc_coef; + + pFilt = pTNS_frame_info->filt; + + do + { + for (f = pTNS_frame_info->n_filt[win]; f > 0; f--) + { + /* Skip to the next filter if the order is 0 */ + tempInt = pFilt->order; + + if (tempInt > 0) + { + /* + * Do not call tns_ar_filter or tns_inv_filter + * if the difference + * between start_coef and stop_stop is <= 0. + * + */ + num_TNS_coef = (pFilt->stop_coef - pFilt->start_coef); + + if (num_TNS_coef > 0) + { + if (inverse_flag != FALSE) + { + tns_inv_filter( + &(pCoef[pFilt->start_coef]), + num_TNS_coef, + pFilt->direction, + pLpcCoef, + pFilt->q_lpc, + pFilt->order, + scratch_Int_buffer); + } + else + { + num_tns_bands = (pFilt->stop_band - pFilt->start_band); + + /* + * pQformat is initialized only once. + * + * Here is how TNS is applied on scalefactor bands + * + * [0][1][2][3][4][5][6][7][8] + * | \ + * start_band stop_band + * + * In this example, TNS would be applied to 8 + * scalefactor bands, 0-7. + * + * pQformat is initially set to &(pStartQformat[8]) + * + * 1st LOOP + * Entry: pQformat = &(pStartQformat[8]) + * + * pQformat is pre-decremented 8 times in the + * search for min_q + * + * Exit: pQformat = &(pStartQformat[0]) + * + * 2nd LOOP + * Entry: pQformat = &(pStartQformat[0]) + * + * pQformat is post-incremented 8 times in the + * normalization of the data loop. + * + * Exit: pQformat = &(pStartQformat[8] + * + * + * shift_amt = tns_ar_filter(...) + * + * 3rd LOOP + * Entry: pQformat = &(pStartQformat[8]) + * + * pQformat is pre-decremented 8 times in the + * adjustment of the q-format to min_q - shift_amt + * + * Exit: pQformat = &(pStartQformat[0]) + * + */ + + pQformat = + &(pStartQformat[pFilt->stop_band]); + + /* + * Scan the array of q-formats and find the minimum over + * the range where the filter is to be applied. + * + * At the end of this scan, + * pQformat = &(q-format[pFilt->start_band]); + * + */ + + min_q = INT16_MAX; + + for (tempInt = num_tns_bands; tempInt > 0; tempInt--) + { + tempInt2 = *(--pQformat); + + if (tempInt2 < min_q) + { + min_q = tempInt2; + } + } /* for(tempInt = num_bands; tempInt > 0; tempInt--)*/ + + /* + * Set up the pointers so we can index into coef[] + * on a scalefactor band basis. + */ + tempInt = pFilt->start_band; + + tempInt--; + + /* Initialize sfb_offset and pWinSfbTop */ + if (tempInt >= 0) + { + pWinSfbTop = + &(pFrameInfo->win_sfb_top[win][tempInt]); + + sfb_offset = *(pWinSfbTop++); + } + else + { + pWinSfbTop = pFrameInfo->win_sfb_top[win]; + sfb_offset = 0; + } + + pTempCoef = pCoef + pFilt->start_coef; + + /* Scale the data in the TNS bands to min_q q-format */ + for (tempInt = num_tns_bands; tempInt > 0; tempInt--) + { + sfbWidth = *(pWinSfbTop++) - sfb_offset; + + sfb_offset += sfbWidth; + + tempInt2 = *(pQformat++) - min_q; + + /* + * This should zero out the data in one scalefactor + * band if it is so much less than the neighboring + * scalefactor bands. + * + * The only way this "should" happen is if one + * scalefactor band contains zero data. + * + * Zero data can be of any q-format, but we always + * set it very high to avoid the zero-data band being + * picked as the one to normalize to in the scan for + * min_q. + * + */ + if (tempInt2 > 31) + { + tempInt2 = 31; + } + + for (sfbWidth >>= 2; sfbWidth > 0; sfbWidth--) + { + *(pTempCoef++) >>= tempInt2; + *(pTempCoef++) >>= tempInt2; + *(pTempCoef++) >>= tempInt2; + *(pTempCoef++) >>= tempInt2; + } + + } /* for(tempInt = num_bands; tempInt > 0; tempInt--)*/ + + tempInt2 = + tns_ar_filter( + &(pCoef[pFilt->start_coef]), + num_TNS_coef, + pFilt->direction, + pLpcCoef, + pFilt->q_lpc, + pFilt->order); + + /* + * Update the q-format for all the scalefactor bands + * taking into account the adjustment caused by + * tns_ar_filter + */ + + min_q -= tempInt2; + + for (tempInt = num_tns_bands; tempInt > 0; tempInt--) + { + *(--pQformat) = min_q; + } + + } /* if (inverse_flag != FALSE) */ + + } /* if (num_TNS_coef > 0) */ + + pLpcCoef += pFilt->order; + + } /* if (tempInt > 0) */ + + pFilt++; + + } /* for (f = pTNSinfo->n_filt; f > 0; f--) */ + + pCoef += coef_per_win; + pStartQformat += sfb_per_win; + + win++; + + } + while (win < pFrameInfo->num_win); + + return; + +} /* apply_tns() */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_tns.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_tns.h new file mode 100644 index 0000000..6c2d82b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/apply_tns.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: apply_tns.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the function declaration for + apply_tns.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef APPLY_TNS_H +#define APPLY_TNS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tns_frame_info.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void apply_tns( + Int32 coef[], + Int q_format[], + const FrameInfo * const pFrameInfo, + TNS_frame_info * const pTNS_frame_info, + const Bool inverse_flag, + Int32 scratch_Int_buffer[]); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/bit_reversal_swap.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/bit_reversal_swap.h new file mode 100644 index 0000000..e72ad1c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/bit_reversal_swap.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: bit_reversal_swap.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function bit_reversal_swap() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef BIT_REVERSAL_SWAP_H +#define BIT_REVERSAL_SWAP_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const Int Index_64_a[]; +extern const Int Index_64_b[]; + +extern const Int Index_512_a[]; +extern const Int Index_512_b[]; + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void bit_reversal_swap( + Int32 Data[], + const Int *pIndex_a, + const Int *pIndex_b); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* BIT_REVERSAL_SWAP_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/buf_getbits.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/buf_getbits.cpp new file mode 100644 index 0000000..3d08e31 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/buf_getbits.cpp @@ -0,0 +1,160 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: buf_getbits.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: hBitBuf Handle to Bitbuffer + n Number of bits to read + + Return: bits + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads n bits from Bitbuffer + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#include "buf_getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +UInt32 buf_getbits(BIT_BUFFER * hBitBuf, Int32 n) +{ + + /* read bits from MSB side */ + if (hBitBuf->buffered_bits <= 16) + { + hBitBuf->buffer_word = (hBitBuf->buffer_word << 16) | (*(hBitBuf->char_ptr++) << 8); + hBitBuf->buffer_word |= *(hBitBuf->char_ptr++); + hBitBuf->buffered_bits += 16; + } + + hBitBuf->buffered_bits -= n; + hBitBuf->nrBitsRead += n; + + return ((hBitBuf->buffer_word >> hBitBuf->buffered_bits) & ((1 << n) - 1)); + +} + + +UInt32 buf_get_1bit(BIT_BUFFER * hBitBuf) +{ + + /* read bits from MSB side */ + if (hBitBuf->buffered_bits <= 16) + { + hBitBuf->buffer_word = (hBitBuf->buffer_word << 16) | (*(hBitBuf->char_ptr++) << 8); + hBitBuf->buffer_word |= *(hBitBuf->char_ptr++); + hBitBuf->buffered_bits += 16; + } + + hBitBuf->buffered_bits--; + hBitBuf->nrBitsRead++; + + return ((hBitBuf->buffer_word >> hBitBuf->buffered_bits) & 1); + +} + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/buf_getbits.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/buf_getbits.h new file mode 100644 index 0000000..4248986 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/buf_getbits.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: buf_getbits.h + + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef BUF_GETBITS_H +#define BUF_GETBITS_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + UInt32 buf_getbits(BIT_BUFFER * hBitBuf, Int32 n); + + UInt32 buf_get_1bit(BIT_BUFFER * hBitBuf); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/byte_align.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/byte_align.cpp new file mode 100644 index 0000000..76db1bc --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/byte_align.cpp @@ -0,0 +1,166 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to a BITS structure that holds information + regarding the input stream. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pInputStream->usedBits is rounded up to a number that represents the next + byte boundary. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Makes the input stream structure pointed to align to the next byte boundary. + If it is already at a byte boundary it is left alone. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global or static variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +void byte_align( + BITS *pInputStream) + + MODIFYING(pInputStream->usedBits = pInputStream->usedBits + + (pInputStream->usedBits + 7) % 8) + + RETURN(nothing) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + + + +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/* + * A negative number was used for this mask so that it works on both + * 16-bit or 32-bit machines. The mask must be cast to unsigned int to + * work with TI compiler, ver 1.80. + */ +#define BYTE_ALIGN_MASK ((UInt)(-8)) + +#define BYTE_ALIGN_ROUNDUP 7 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void byte_align( + BITS *pInputStream) +{ + /* + * Round up to the next byte by adding 7 and masking off with + * FFF8 or FFFFFFF8. The masking operation is a faster way to + * perform modulo arithmetic if the number is a power of 2. + * + * This code is the same as + * pInputStream->usedBits += (pInputStream->usedBits + 7) % 8 + */ + pInputStream->usedBits += BYTE_ALIGN_ROUNDUP; + pInputStream->usedBits &= BYTE_ALIGN_MASK; + + return; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_auto_corr.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_auto_corr.cpp new file mode 100644 index 0000000..934847b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_auto_corr.cpp @@ -0,0 +1,404 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_auto_corr.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#ifdef AAC_PLUS + + +#include "calc_auto_corr.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#include "fxp_mul32.h" +#include "pv_normalize.h" + +#define N 2 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void calc_auto_corr_LC(struct ACORR_COEFS *ac, + Int32 realBuf[][32], + Int32 bd, + Int32 len) +{ + Int32 j; + Int32 temp1; + Int32 temp3; + Int32 temp5; + + int64 temp_r01r; + int64 temp_r02r; + int64 temp_r11r; + int64 temp_r12r; + int64 temp_r22r; + int64 max = 0; + + + temp1 = (realBuf[ 0][bd]) >> N; + temp3 = (realBuf[-1][bd]) >> N; + temp5 = (realBuf[-2][bd]) >> N; + + + temp_r11r = fxp_mac64_Q31(0, temp3, temp3); /* [j-1]*[j-1] */ + temp_r12r = fxp_mac64_Q31(0, temp3, temp5); /* [j-1]*[j-2] */ + temp_r22r = fxp_mac64_Q31(0, temp5, temp5); /* [j-2]*[j-2] */ + + temp_r01r = 0; + temp_r02r = 0; + + for (j = 1; j < len; j++) + { + temp_r01r = fxp_mac64_Q31(temp_r01r, temp1, temp3); /* [j ]*[j-1] */ + temp_r02r = fxp_mac64_Q31(temp_r02r, temp1, temp5); /* [j ]*[j-2] */ + temp_r11r = fxp_mac64_Q31(temp_r11r, temp1, temp1); /* [j-1]*[j-1] */ + + temp5 = temp3; + temp3 = temp1; + temp1 = (realBuf[j][bd]) >> N; + } + + + temp_r22r += temp_r11r; + temp_r12r += temp_r01r; /* [j-1]*[j-2] */ + + temp_r22r = fxp_mac64_Q31(temp_r22r, -temp3, temp3); + + temp_r01r = fxp_mac64_Q31(temp_r01r, temp1, temp3); + temp_r02r = fxp_mac64_Q31(temp_r02r, temp1, temp5); + + max |= temp_r01r ^(temp_r01r >> 63); + max |= temp_r02r ^(temp_r02r >> 63); + max |= temp_r11r; + max |= temp_r12r ^(temp_r12r >> 63); + max |= temp_r22r; + + if (max) + { + temp1 = (UInt32)(max >> 32); + if (temp1) + { + temp3 = 33 - pv_normalize(temp1); + ac->r01r = (Int32)(temp_r01r >> temp3); + ac->r02r = (Int32)(temp_r02r >> temp3); + ac->r11r = (Int32)(temp_r11r >> temp3); + ac->r12r = (Int32)(temp_r12r >> temp3); + ac->r22r = (Int32)(temp_r22r >> temp3); + + } + else + { + temp3 = pv_normalize(((UInt32)max) >> 1) - 2; + + if (temp3 > 0) + { + ac->r01r = (Int32)(temp_r01r << temp3); + ac->r02r = (Int32)(temp_r02r << temp3); + ac->r11r = (Int32)(temp_r11r << temp3); + ac->r12r = (Int32)(temp_r12r << temp3); + ac->r22r = (Int32)(temp_r22r << temp3); + } + else + { + temp3 = -temp3; + ac->r01r = (Int32)(temp_r01r >> temp3); + ac->r02r = (Int32)(temp_r02r >> temp3); + ac->r11r = (Int32)(temp_r11r >> temp3); + ac->r12r = (Int32)(temp_r12r >> temp3); + ac->r22r = (Int32)(temp_r22r >> temp3); + } + + } + + /* + * ac->det = ac->r11r*ac->r22r - rel*(ac->r12r*ac->r12r); + */ + /* 1/(1 + 1e-6) == 1 - 1e-6 */ + /* 2^-20 == 1e-6 */ + ac->det = fxp_mul32_Q30(ac->r12r, ac->r12r); + + ac->det -= ac->det >> 20; + + ac->det = fxp_mul32_Q30(ac->r11r, ac->r22r) - ac->det; + } + else + { + pv_memset((void *)ac, 0, sizeof(struct ACORR_COEFS)); + } + + +} + + +#ifdef HQ_SBR + + +void calc_auto_corr(struct ACORR_COEFS *ac, + Int32 realBuf[][32], + Int32 imagBuf[][32], + Int32 bd, + Int32 len) +{ + + + Int32 j; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 temp5; + Int32 temp6; + + int64 accu1 = 0; + int64 accu2 = 0; + int64 accu3 = 0; + int64 accu4 = 0; + int64 accu5 = 0; + + + int64 temp_r12r; + int64 temp_r12i; + int64 temp_r22r; + int64 max = 0; + + + temp1 = realBuf[0 ][bd] >> N; + temp2 = imagBuf[0 ][bd] >> N; + temp3 = realBuf[0-1][bd] >> N; + temp4 = imagBuf[0-1][bd] >> N; + temp5 = realBuf[0-2][bd] >> N; + temp6 = imagBuf[0-2][bd] >> N; + + temp_r22r = fxp_mac64_Q31(0, temp5, temp5); + temp_r22r = fxp_mac64_Q31(temp_r22r, temp6, temp6); + temp_r12r = fxp_mac64_Q31(0, temp3, temp5); + temp_r12r = fxp_mac64_Q31(temp_r12r, temp4, temp6); + temp_r12i = -fxp_mac64_Q31(0, temp3, temp6); + temp_r12i = fxp_mac64_Q31(temp_r12i, temp4, temp5); + + for (j = 1; j < len; j++) + { + accu1 = fxp_mac64_Q31(accu1, temp3, temp3); + accu1 = fxp_mac64_Q31(accu1, temp4, temp4); + accu2 = fxp_mac64_Q31(accu2, temp1, temp3); + accu2 = fxp_mac64_Q31(accu2, temp2, temp4); + accu3 = fxp_mac64_Q31(accu3, temp2, temp3); + accu3 = fxp_mac64_Q31(accu3, -temp1, temp4); + accu4 = fxp_mac64_Q31(accu4, temp1, temp5); + accu4 = fxp_mac64_Q31(accu4, temp2, temp6); + accu5 = fxp_mac64_Q31(accu5, temp2, temp5); + accu5 = fxp_mac64_Q31(accu5, -temp1, temp6); + + temp5 = temp3; + temp6 = temp4; + temp3 = temp1; + temp4 = temp2; + temp1 = realBuf[j][bd] >> N; + temp2 = imagBuf[j][bd] >> N; + } + + + temp_r22r += accu1; + temp_r12r += accu2; + temp_r12i += accu3; + + + accu1 = fxp_mac64_Q31(accu1, temp3, temp3); + accu1 = fxp_mac64_Q31(accu1, temp4, temp4); + accu2 = fxp_mac64_Q31(accu2, temp1, temp3); + accu2 = fxp_mac64_Q31(accu2, temp2, temp4); + accu3 = fxp_mac64_Q31(accu3, temp2, temp3); + accu3 = fxp_mac64_Q31(accu3, -temp1, temp4); + accu4 = fxp_mac64_Q31(accu4, temp1, temp5); + accu4 = fxp_mac64_Q31(accu4, temp2, temp6); + accu5 = fxp_mac64_Q31(accu5, temp2, temp5); + accu5 = fxp_mac64_Q31(accu5, -temp1, temp6); + + + max |= accu5 ^(accu5 >> 63); + max |= accu4 ^(accu4 >> 63); + max |= accu3 ^(accu3 >> 63); + max |= accu2 ^(accu2 >> 63); + max |= accu1; + max |= temp_r12r ^(temp_r12r >> 63); + max |= temp_r12i ^(temp_r12i >> 63); + max |= temp_r22r; + + if (max) + { + + temp1 = (UInt32)(max >> 32); + if (temp1) + { + temp1 = 34 - pv_normalize(temp1); + ac->r11r = (Int32)(accu1 >> temp1); + ac->r01r = (Int32)(accu2 >> temp1); + ac->r01i = (Int32)(accu3 >> temp1); + ac->r02r = (Int32)(accu4 >> temp1); + ac->r02i = (Int32)(accu5 >> temp1); + ac->r12r = (Int32)(temp_r12r >> temp1); + ac->r12i = (Int32)(temp_r12i >> temp1); + ac->r22r = (Int32)(temp_r22r >> temp1); + } + else + { + temp1 = pv_normalize(((UInt32)max) >> 1) - 3; + + if (temp1 > 0) + { + ac->r11r = (Int32)(accu1 << temp1); + ac->r01r = (Int32)(accu2 << temp1); + ac->r01i = (Int32)(accu3 << temp1); + ac->r02r = (Int32)(accu4 << temp1); + ac->r02i = (Int32)(accu5 << temp1); + ac->r12r = (Int32)(temp_r12r << temp1); + ac->r12i = (Int32)(temp_r12i << temp1); + ac->r22r = (Int32)(temp_r22r << temp1); + } + else + { + temp1 = -temp1; + ac->r11r = (Int32)(accu1 >> temp1); + ac->r01r = (Int32)(accu2 >> temp1); + ac->r01i = (Int32)(accu3 >> temp1); + ac->r02r = (Int32)(accu4 >> temp1); + ac->r02i = (Int32)(accu5 >> temp1); + ac->r12r = (Int32)(temp_r12r >> temp1); + ac->r12i = (Int32)(temp_r12i >> temp1); + ac->r22r = (Int32)(temp_r22r >> temp1); + } + + } + + /* + * ac->det = ac->r11r*ac->r22r - rel*(ac->r12r*ac->r12r); + */ + /* 1/(1 + 1e-6) == 1 - 1e-6 */ + /* 2^-20 == 1e-6 */ + + ac->det = fxp_mul32_Q29(ac->r12i, ac->r12i); + ac->det = fxp_mac32_Q29(ac->r12r, ac->r12r, ac->det); + + ac->det -= ac->det >> 20; + + ac->det = -fxp_msu32_Q29(ac->r11r, ac->r22r, ac->det); + + } + else + { + pv_memset((void *)ac, 0, sizeof(struct ACORR_COEFS)); + } + +} + +#endif + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_auto_corr.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_auto_corr.h new file mode 100644 index 0000000..94c9a96 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_auto_corr.h @@ -0,0 +1,116 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_auto_corr.h + Funtions: + +------------------------------------------------------------------------------ + + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CALC_AUTO_CORR_H +#define CALC_AUTO_CORR_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +struct ACORR_COEFS +{ + Int32 r11r; + Int32 r01r; + Int32 r02r; + Int32 r12r; + Int32 r22r; +#ifdef HQ_SBR + Int32 r01i; + Int32 r02i; + Int32 r12i; +#endif + Int32 det; +}; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void calc_auto_corr_LC(struct ACORR_COEFS *ac, + Int32 realBuf[][32], + Int32 bd, + Int32 len); + + +#ifdef HQ_SBR + + void calc_auto_corr(struct ACORR_COEFS *ac, + Int32 realBuf[][32], + Int32 imagBuf[][32], + Int32 bd, + Int32 len); + +#endif + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_gsfb_table.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_gsfb_table.cpp new file mode 100644 index 0000000..b86f619 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_gsfb_table.cpp @@ -0,0 +1,231 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_gsfb_table.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pFrameInfo = pointer to structure that holds information for current + frame. Data type FrameInfo + + group[] = array that contains the grouping information of short + windows (stop index of windows in each group). + Data type Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pFrameInfo -> frame_sfb_top contains the cumulative bandwidth of + scalefactor bands in each group + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function is only invoked when short windows are present. It calculates + the number of groups in one frame, and the scalefactor bandwidth of each + scalefactor band in each group. + All windows within one group share the same scalefactors and are interleaved + on a scalefactor band basis. Within each group, the actual length of one + scalefactor band equals to the number of windows times the number of + coefficients in a regular scalefactor band. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall replace the contents of pFrameInfo->frame_sfb_top + with the cumulative bandwidth of each scalefactor band in each group + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p54. 4.5.2.3.2 decoding process + +------------------------------------------------------------------------------ + PSEUDO-CODE + + offset = 0; + group_idx = 0; + + DO + pFrameInfo->group_len[group_idx] = group[group_idx] - offset; + offset = group[group_idx]; + group_idx++; + + WHILE (offset < NUM_SHORT_WINDOWS); + + + pFrameInfo->num_groups = group_idx; + + pFrameSfbTop = pFrameInfo->frame_sfb_top; + offset = 0; + + FOR (group_idx = 0; group_idx < pFrameInfo->num_groups; group_idx++) + + len = pFrameInfo->group_len[group_idx]; + + FOR (sfb = 0; sfb < pFrameInfo->sfb_per_win[group_idx]; sfb++) + + offset += pFrameInfo->sfb_width_128[sfb] * len; + *pFrameSfbTop++ = offset; + + ENDFOR + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void calc_gsfb_table( + FrameInfo *pFrameInfo, + Int group[]) +{ + + Int group_idx; + Int offset; + Int *pFrameSfbTop; + Int *pSfbWidth128; + Int sfb; + Int nsfb; + Int len; + Int ngroups; + + /* clear out the default values set by infoinit */ + /* */ + pv_memset(pFrameInfo->frame_sfb_top, + 0, + MAXBANDS*sizeof(pFrameInfo->frame_sfb_top[0])); + /* */ + /* first calculate the group length*/ + offset = 0; + ngroups = 0; + do + { + pFrameInfo->group_len[ngroups] = group[ngroups] - offset; + offset = group[ngroups]; + ngroups++; + + } + while (offset < NUM_SHORT_WINDOWS); + + + /* calculate the cumulative scalefactor bandwidth for one frame */ + pFrameInfo->num_groups = ngroups; + + pFrameSfbTop = pFrameInfo->frame_sfb_top; + offset = 0; + + + for (group_idx = 0; group_idx < ngroups; group_idx++) + { + len = pFrameInfo->group_len[ group_idx]; + nsfb = pFrameInfo->sfb_per_win[group_idx]; + + pSfbWidth128 = pFrameInfo->sfb_width_128; + + for (sfb = nsfb; sfb > 0; sfb--) + { + offset += *pSfbWidth128++ * len; + *pFrameSfbTop++ = offset; + } + } + + +} /* calc_gsfb_table */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.cpp new file mode 100644 index 0000000..2bc8853 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.cpp @@ -0,0 +1,347 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_sbr_anafilterbank.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "calc_sbr_anafilterbank.h" +#include "qmf_filterbank_coeff.h" +#include "analysis_sub_band.h" + +#include "aac_mem_funcs.h" +#include "fxp_mul32.h" + + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void calc_sbr_anafilterbank_LC(Int32 * Sr, + Int16 * X, + Int32 scratch_mem[][64], + Int32 maxBand) +{ + + Int i; + Int32 *p_Y_1; + Int32 *p_Y_2; + + Int16 * pt_X_1; + Int16 * pt_X_2; + Int32 realAccu1; + Int32 realAccu2; + + Int32 tmp1; + Int32 tmp2; + + + const Int32 * pt_C; + + p_Y_1 = scratch_mem[0]; + + + p_Y_2 = p_Y_1 + 63; + pt_C = &sbrDecoderFilterbankCoefficients_an_filt_LC[0]; + + pt_X_1 = X; + + + realAccu1 = fxp_mul32_by_16(Qfmt27(-0.51075594183097F), pt_X_1[-192]); + realAccu1 = fxp_mac32_by_16(Qfmt27(0.51075594183097F), pt_X_1[-128], realAccu1); + realAccu1 = fxp_mac32_by_16(Qfmt27(-0.01876919066980F), pt_X_1[-256], realAccu1); + *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(0.01876919066980F), pt_X_1[ -64], realAccu1); + + + /* create array Y */ + + pt_X_1 = &X[-1]; + pt_X_2 = &X[-319]; + + + for (i = 15; i != 0; i--) + { + tmp1 = *(pt_X_1--); + tmp2 = *(pt_X_2++); + + realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); + realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); + tmp1 = pt_X_1[ -63]; + tmp2 = pt_X_2[ +63]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -127]; + tmp2 = pt_X_2[ +127]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -191]; + tmp2 = pt_X_2[ +191]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -255]; + tmp2 = pt_X_2[ +255]; + *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + + tmp1 = *(pt_X_1--); + tmp2 = *(pt_X_2++); + realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); + realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); + + tmp1 = pt_X_1[ -63]; + tmp2 = pt_X_2[ +63]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -127]; + tmp2 = pt_X_2[ +127]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -191]; + tmp2 = pt_X_2[ +191]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -255]; + tmp2 = pt_X_2[ +255]; + *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + + } + + + tmp1 = *(pt_X_1--); + tmp2 = *(pt_X_2++); + realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); + realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); + + tmp1 = pt_X_1[ -63]; + tmp2 = pt_X_2[ +63]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -127]; + tmp2 = pt_X_2[ +127]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -191]; + tmp2 = pt_X_2[ +191]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -255]; + tmp2 = pt_X_2[ +255]; + *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + *(p_Y_2) = fxp_mac32_by_16(*(pt_C), tmp2, realAccu2); + + + realAccu2 = fxp_mul32_by_16(Qfmt27(0.00370548843500F), X[ -32]); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.00370548843500F), X[-288], realAccu2); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.09949460091720F), X[ -96], realAccu2); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.09949460091720F), X[-224], realAccu2); + *(p_Y_1) = fxp_mac32_by_16(Qfmt27(1.20736865027288F), X[-160], realAccu2); + + + analysis_sub_band_LC(scratch_mem[0], + Sr, + maxBand, + (Int32(*)[64])scratch_mem[1]); + +} + + + +#ifdef HQ_SBR + +void calc_sbr_anafilterbank(Int32 * Sr, + Int32 * Si, + Int16 * X, + Int32 scratch_mem[][64], + Int32 maxBand) +{ + Int i; + Int32 *p_Y_1; + Int32 *p_Y_2; + + + + + const Int32 * pt_C; + Int16 * pt_X_1; + Int16 * pt_X_2; + Int32 realAccu1; + Int32 realAccu2; + + Int32 tmp1; + Int32 tmp2; + + + p_Y_1 = scratch_mem[0]; + + + p_Y_2 = p_Y_1 + 63; + pt_C = &sbrDecoderFilterbankCoefficients_an_filt[0]; + + realAccu1 = fxp_mul32_by_16(Qfmt27(-0.36115899F), X[-192]); + realAccu1 = fxp_mac32_by_16(Qfmt27(0.36115899F), X[-128], realAccu1); + realAccu1 = fxp_mac32_by_16(Qfmt27(-0.013271822F), X[-256], realAccu1); + *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(0.013271822F), X[ -64], realAccu1); + + /* create array Y */ + + pt_X_1 = &X[-1]; + pt_X_2 = &X[-319]; + + + for (i = 31; i != 0; i--) + { + tmp1 = *(pt_X_1--); + tmp2 = *(pt_X_2++); + realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); + realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); + tmp1 = pt_X_1[ -63]; + tmp2 = pt_X_2[ 63]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -127]; + tmp2 = pt_X_2[ 127]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -191]; + tmp2 = pt_X_2[ 191]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -255]; + tmp2 = pt_X_2[ 255]; + *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + } + + + realAccu2 = fxp_mul32_by_16(Qfmt27(0.002620176F), X[ -32]); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.002620176F), X[-288], realAccu2); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.070353307F), X[ -96], realAccu2); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.070353307F), X[-224], realAccu2); + + + *p_Y_2 = fxp_mac32_by_16(Qfmt27(0.85373856F), (X[-160]), realAccu2); + + + analysis_sub_band(scratch_mem[0], + Sr, + Si, + maxBand, + (Int32(*)[64])scratch_mem[1]); + +} + + +#endif + + + +#endif /* AAC_PLUS */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.h new file mode 100644 index 0000000..fbfec52 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.h @@ -0,0 +1,107 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_sbr_anafilterbank.h + Funtions: + get_dse + +------------------------------------------------------------------------------ + +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CALC_SBR_ANAFILTERBANK_H +#define CALC_SBR_ANAFILTERBANK_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + +#define ROUND_ANAFIL 0 +//#define ROUND_ANAFIL 0 +#define ROUND_ANAFIL_LC (0) + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + + void calc_sbr_anafilterbank_LC(Int32 * Sr, + Int16 * X, + Int32 scratch_mem[][64], + Int32 maxBand); + + +#ifdef HQ_SBR + + void calc_sbr_anafilterbank(Int32 * Sr, + Int32 * Si, + Int16 * X, + Int32 scratch_mem[][64], + Int32 maxBand); + +#endif + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* CALC_SBR_ANAFILTERBANK_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.cpp new file mode 100644 index 0000000..c9cd4ac --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.cpp @@ -0,0 +1,2194 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: calc_sbr_envelope.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "calc_sbr_envelope.h" +#include "sbr_envelope_calc_tbl.h" +#include "sbr_create_limiter_bands.h" +#include "aac_mem_funcs.h" + +#include "fxp_mul32.h" +#include "pv_normalize.h" + +#include "sbr_aliasing_reduction.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#include "pv_sqrt.h" + +#include "pv_div.h" +#include "fxp_mul32.h" +#include "pv_normalize.h" + +#define Q30fmt(x) (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F)) +#define Q28fmt(x) (Int32)(x*((Int32)1<<28) + (x>=0?0.5F:-0.5F)) +#define Q15fmt(x) (Int32)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void envelope_application_LC(Int32 *aBufR, + Int32 *nrg_gain_man, + Int32 *nrg_gain_exp, + Int32 *noise_level_man, + Int32 *noise_level_exp, + Int32 *nrg_tone_man, + Int32 *nrg_tone_exp, + Int32 band_nrg_tone_detector, + const Int32 *frame_info, + Int32 *harm_index, + Int32 *phase_index, + Int32 i, + Int32 lowSubband, + Int32 noSubbands, + Int32 noNoiseFlag); + + + void energy_estimation_LC(Int32 *aBufR, + Int32 *nrg_est_man, + Int32 *nrg_est_exp, + const Int32 *frame_info, + Int32 i, + Int32 k, + Int32 c, + Int32 ui2); + +#ifdef HQ_SBR + + + void envelope_application(Int32 *aBufR, + Int32 *aBufI, + Int32 *nrg_gain_man, + Int32 *nrg_gain_exp, + Int32 *noise_level_man, + Int32 *noise_level_exp, + Int32 *nrg_tone_man, + Int32 *nrg_tone_exp, + Int32 *fBuf_man[64], + Int32 *fBuf_exp[64], + Int32 *fBufN_man[64], + Int32 *fBufN_exp[64], + const Int32 *frame_info, + Int32 *harm_index, + Int32 *phase_index, + Int32 i, + Int32 lowSubband, + Int32 noSubbands, + Int32 noNoiseFlag, + Int32 band_nrg_tone_detector, + Int32 maxSmoothLength, + Int32 smooth_length); + + + void energy_estimation(Int32 *aBufR, + Int32 *aBufI, + Int32 *nrg_est_man, + Int32 *nrg_est_exp, + const Int32 *frame_info, + Int32 i, + Int32 k, + Int32 c, + Int32 ui2); + +#endif + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void calc_sbr_envelope(SBR_FRAME_DATA *frameData, + Int32 *aBufR, + Int32 *aBufI, + Int freqBandTable1[2][MAX_FREQ_COEFFS + 1], + const Int32 *nSfb, + Int32 freqBandTable2[MAX_NOISE_COEFFS + 1], + Int32 nNBands, + Int32 reset, + Int32 *degreeAlias, + Int32 *harm_index, + Int32 *phase_index, + Int32 hFp[64], + Int32 *sUp, + Int32 limSbc[][13], + Int32 *gateMode, +#ifdef HQ_SBR + Int32 *fBuf_man[64], + Int32 *fBuf_exp[64], + Int32 *fBufN_man[64], + Int32 *fBufN_exp[64], +#endif + Int32 scratch_mem[][64], + struct PATCH Patch, + Int32 sqrt_cache[][4], + Int32 LC_flag) +{ + + Int32 c; + Int32 li; + Int32 ui; + Int32 i; + Int32 j; + Int32 k = 0; + Int32 l; + Int m = 0; + Int kk = 0; + Int o; + Int next = -1; + Int32 ui2; + Int flag; + Int noNoiseFlag; + Int *ptr; + + + UInt32 nrg = 0; + Int32 nrg_exp = 0; + struct intg_div quotient; + struct intg_sqrt root_sq; + + Int32 aux1; + + Int32 *nL_man = frameData->sbrNoiseFloorLevel_man; + Int32 *nL_exp = frameData->sbrNoiseFloorLevel_exp; + + Int32 *sfb_nrg_man = frameData->iEnvelope_man; + Int32 *sfb_nrg_exp = frameData->iEnvelope_exp; + + Int32 tmp_q1; + Int32 tmp_q2; + + Int32 g_max_man; + Int32 g_max_exp; + + Int32 p_ref_man; + Int32 p_ref_exp; + + Int32 p_est_man; + Int32 p_est_exp; + + Int32 p_adj_man; + Int32 p_adj_exp; + Int32 avg_gain; + + Int32 boost_gain_q; + + Int32 band_nrg_tone_detector; + + Int32 *nrg_est_man = scratch_mem[0]; + Int32 *nrg_est_exp = scratch_mem[1]; + Int32 *nrg_ref_man = scratch_mem[2]; + Int32 *nrg_ref_exp = scratch_mem[3]; + Int32 *nrg_gain_man = scratch_mem[4]; + Int32 *nrg_gain_exp = scratch_mem[5]; + Int32 *noise_level_man = scratch_mem[6]; + Int32 *noise_level_exp = scratch_mem[7]; + Int32 *nrg_tone_man = scratch_mem[8]; + Int32 *nrg_tone_exp = scratch_mem[9]; + Int32 *hF = scratch_mem[10]; + + + + const Int32 *frame_info = frameData->frameInfo; + Int32 int_mode = frameData->sbr_header.interpolFreq; + + + + + + Int32 dontUseTheseGainValues[64]; + +#ifdef HQ_SBR + + Int32 n; + Int32 smooth_length; + Int32 smoothingLength = frameData->sbr_header.smoothingLength; + Int32 maxSmoothLength = smoothLengths[0]; + +#endif + + Int32 limiterBand = frameData->sbr_header.limiterBands; + Int32 limiterGains = frameData->sbr_header.limiterGains; + Int32 *addHarmonics = frameData->addHarmonics; + + Int32 lowSubband = freqBandTable1[LOW_RES][0]; + Int32 noSubbands = freqBandTable1[LOW_RES][nSfb[LOW_RES]] - lowSubband; + Int32 nEnv = frame_info[0]; + Int32 sEnv = frame_info[(nEnv + 1)<<1]; + + /* ensure that noSubbands in the range [0,64] */ + noSubbands = (noSubbands >> 31) ^ noSubbands; + if (noSubbands > 64) + { + noSubbands = 64; + } + + if (reset) + { + *sUp = 1; + *phase_index = 0; + sbr_create_limiter_bands(limSbc, + gateMode, + freqBandTable1[LOW_RES], + Patch, + nSfb[LOW_RES]); + } + + /* Mapping. */ + pv_memset((void*)hF, 0, (sizeof(*hF) << 6)); + + ptr = freqBandTable1[HI]; + l = *(ptr++); + + for (i = nSfb[HI]; i != 0; i--) + { + k = *(ptr++); + j = ((k + l) >> 1) - lowSubband; + l = k; + hF[j] = *(addHarmonics++); + } + + + /* Envelope adjustment. */ + + for (i = 0; i < nEnv; i++) + { + + if (frame_info[1+i] == frame_info[(nEnv<<1)+4+kk]) + { + kk++, next++; + } + + noNoiseFlag = (i == sEnv || i == frameData->prevEnvIsShort) ? 1 : 0; + +#ifdef HQ_SBR + smooth_length = (noNoiseFlag ? 0 : smoothLengths[smoothingLength]); +#endif + + + /* Estimate levels. */ + c = 0; + o = 0; + + band_nrg_tone_detector = 0; + + Int kkkk = freqBandTable1[ frame_info[nEnv+2+i] ][0]; + + for (j = 0; j < nSfb[frame_info[nEnv+2+i]]; j++) + { + li = freqBandTable1[ frame_info[nEnv+2+i] ][j ]; + ui = freqBandTable1[ frame_info[nEnv+2+i] ][j + 1]; + flag = 0; + + for (k = li; k < ui; k++) + { /* Calculate the average energy over the current envelope, */ + ui2 = (frame_info[1+i] << 1); + + if (LC_flag == ON) + { + energy_estimation_LC((Int32 *)aBufR, + nrg_est_man, + nrg_est_exp, + frame_info, + i, + k - kkkk, + c, + ui2); + } +#ifdef HQ_SBR + else + { + + energy_estimation((Int32 *)aBufR, + (Int32 *)aBufI, + nrg_est_man, + nrg_est_exp, + frame_info, + i, + k - kkkk, + c, + ui2); + } +#endif + + flag = (hF[c] && (i >= sEnv || hFp[c+lowSubband])) ? 1 : flag; + c++; + } + + + ui2 = freqBandTable2[o+1]; + + if (!int_mode) + { /* If no interpolation is used, */ + + tmp_q1 = -100; + + for (k = c - (ui - li); k < c; k++) + { + if (tmp_q1 < nrg_est_exp[k]) + { + tmp_q1 = nrg_est_exp[k]; + } + } + + nrg = 0; + for (k = c - (ui - li); k < c; k++) + { /* average the energy in all the QMF bands, */ + nrg += nrg_est_man[k] >> (tmp_q1 - nrg_est_exp[k]); /* for the whole scalefactor band. */ + } + nrg /= (ui - li); + nrg_exp = tmp_q1; + + } + + c -= (ui - li); + + for (k = 0; k < ui - li; k++) + { + o = (k + li >= ui2) ? o + 1 : o; + ui2 = freqBandTable2[o+1]; + /* + * If no interpolation is used, use the averaged energy from above, + * otherwise do nothing. + */ + + + if (!int_mode) + { + nrg_est_man[c] = nrg; + nrg_est_exp[c] = nrg_exp; + } + + if (LC_flag == ON) + { + nrg_est_exp[c] += 1; + + if (flag) + { + dontUseTheseGainValues[k + li - lowSubband] = 1; + } + else + { + dontUseTheseGainValues[k + li - lowSubband] = 0; + } + } + + nrg_ref_man[c] = sfb_nrg_man[m]; + nrg_ref_exp[c] = sfb_nrg_exp[m]; + + /* + * compute nL/(1 + nL); where nL = nL_man*2^nL_exp + */ + aux1 = next * nNBands + o; + + tmp_q1 = nL_exp[aux1]; + + if (tmp_q1 >= 0) + { + pv_div(nL_man[aux1], nL_man[aux1] + (0x3FFFFFFF >> tmp_q1), "ient); + } + else + { + tmp_q1 = nL_man[aux1] >> (-tmp_q1); + pv_div(tmp_q1, tmp_q1 + 0x3FFFFFFF, "ient); + } + + /* + * tmp_q1 = nL/(1 + nL)*nrg_ref[c]; + */ + + tmp_q1 = fxp_mul32_Q30(quotient.quotient >> quotient.shift_factor, nrg_ref_man[c]); + + if (flag) + { + /* + * Calculate levels and gain, dependent on whether a synthetic, a sine is present or not. + * + * nrg_gain[c]=(float)pv_sqrt( tmp/(nrg_est[c] + 1), sqrt_cache[1] ); + */ + + + pv_div(tmp_q1, nrg_est_man[c] + 1, "ient); + /* + * nrg_est_man[c] is an integer number, while tmp_q1 and quotient.quotient + * are fractions in Q30 + */ + + tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30; + + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[1]); + nrg_gain_man[c] = root_sq.root; /* in Q28 format */ + nrg_gain_exp[c] = root_sq.shift_factor; + + + /* + * nrg_tone[c]=(float)( (hF[c] && (i >= sEnv || hFp[c+lowSubband])) ? + * pv_sqrt(nrg_ref[c]/(1+tmp_nL), sqrt_cache[2]) : 0); + */ + if (hF[c] && (i >= sEnv || hFp[c+lowSubband])) + { + /* + * nrg_ref[c] and nL, as well as quotient.quotient + * are fractions in Q30 + */ + + /* aux1 == next*nNBands + o */ + + tmp_q2 = nL_exp[aux1]; + /* + * nrg_ref[c]/(1+tmp_nL) + */ + + if (tmp_q2 >= 0) + { + pv_div(nrg_ref_man[c], nL_man[aux1] + (0x3FFFFFFF >> tmp_q2), "ient); + } + else + { + tmp_q2 = nL_man[aux1] >> (-tmp_q2); + pv_div(nrg_ref_man[c], tmp_q2 + 0x3FFFFFFF, "ient); + tmp_q2 = 0; /* exponent has been applied to the sum ((man>>exp) + 1) */ + } + + tmp_q2 = nrg_ref_exp[c] - tmp_q2 - quotient.shift_factor; + + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[2]); + nrg_tone_man[c] = root_sq.root; + nrg_tone_exp[c] = root_sq.shift_factor; + + } + else + { + nrg_tone_man[c] = 0; + nrg_tone_exp[c] = 0; + } + + } + else + { + if (noNoiseFlag) + { + /* + * nrg_gain[c] = (float) pv_sqrt(nrg_ref[c] /(nrg_est[c] + 1), sqrt_cache[3]); + */ + + pv_div(nrg_ref_man[c], nrg_est_man[c] + 1, "ient); + + /* + * nrg_est_man[c] is an integer number, while nrg_ref_man[c] and + * quotient.quotient are fractions in Q30 + */ + + tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30; + + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[3]); + nrg_gain_man[c] = root_sq.root; + nrg_gain_exp[c] = root_sq.shift_factor; + + } + else + { + /* + * nrg_gain[c] = (float) pv_sqrt(nrg_ref[c]/((nrg_est[c] + 1)*(1+tmp_nL)), sqrt_cache[4]); + */ + /* aux1 == next*nNBands + o */ + + tmp_q2 = nL_exp[aux1]; + /* + * nrg_ref[c]/((nrg_est[c] + 1)*(1+tmp_nL)) + */ + + if (nrg_est_man[c] == 0) + { + tmp_q2 = 0; /* avoid division by 0 in next if-else, this could be due to + rounding noise */ + } + + + if (tmp_q2 >= 0) + { + + tmp_q2 = fxp_mul32_Q30(nrg_est_man[c] + 1, nL_man[aux1] + (0x3FFFFFFF >> tmp_q2)); + pv_div(nrg_ref_man[c], tmp_q2, "ient); + /* + * nrg_est_man[c] is an integer number, while nrg_ref_man[c] and + * quotient.quotient are fractions in Q30 + */ + tmp_q2 = nrg_ref_exp[c] - quotient.shift_factor - 30 - nL_exp[aux1]; + if (nrg_est_man[c]) + { + tmp_q2 -= nrg_est_exp[c]; + } + + tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30 - nL_exp[aux1]; + } + else + { + if (tmp_q2 > - 10) + { + tmp_q2 = nL_man[aux1] >> (-tmp_q2); + + tmp_q2 = fxp_mul32_Q30(nrg_est_man[c] + 1, tmp_q2 + 0x3FFFFFFF); + } + else + { + tmp_q2 = nrg_est_man[c] + 1; + } + + + pv_div(nrg_ref_man[c], tmp_q2, "ient); + /* + * nrg_est_man[c] is an integer number, while nrg_ref_man[c] and + * quotient.quotient are fractions in Q30 + */ + + tmp_q2 = nrg_ref_exp[c] - quotient.shift_factor - 30; + if (nrg_est_man[c]) + { + tmp_q2 -= nrg_est_exp[c]; + } + + } + + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[4]); + nrg_gain_man[c] = root_sq.root; + nrg_gain_exp[c] = root_sq.shift_factor; + + } + + nrg_tone_man[c] = 0; + nrg_tone_exp[c] = -100; + + } + + band_nrg_tone_detector |= nrg_tone_man[c]; /* detect any tone activity */ + + pv_sqrt(tmp_q1, nrg_ref_exp[c], &root_sq, sqrt_cache[5]); + noise_level_man[c] = root_sq.root; + noise_level_exp[c] = root_sq.shift_factor; + + c++; + + } /* ---- end-for-loop (k) ------ */ + m++; + + } /* -------- Estimate levels end-for-loop (j) ----- */ + + + + /* + * Limiter + */ + + + for (c = 0; c < gateMode[limiterBand]; c++) + { + + p_ref_man = 0; + p_est_man = 0; + + /* + * get max exponent for the reference and estimated energy + */ + p_ref_exp = -100; + p_est_exp = -100; + + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + if (p_ref_exp < nrg_ref_exp[k]) + { + p_ref_exp = nrg_ref_exp[k]; /* max */ + } + if (p_est_exp < nrg_est_exp[k]) + { + p_est_exp = nrg_est_exp[k]; /* max */ + } + } + + k -= limSbc[limiterBand][c]; /* number of element used in the addition */ + + while (k != 0) /* bit guard protection depends on log2(k) */ + { + k >>= 1; + p_ref_exp++; /* add extra bit-overflow-guard, nrg_ref_exp is in Q30 format */ + } + + + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { /*Calculate the average gain for the current limiter band.*/ + p_ref_man += (nrg_ref_man[k] >> (p_ref_exp - nrg_ref_exp[k])); + p_est_man += (nrg_est_man[k] >> (p_est_exp - nrg_est_exp[k])); + + } + + if (p_est_man) + { + /* + * "average gain" (not equal to average of nrg_gain) + */ + pv_div(p_ref_man, p_est_man, "ient); + + tmp_q2 = p_ref_exp - 30 - p_est_exp - quotient.shift_factor; + + /* + * avg_gain = sqrt(p_ref/p_est) + */ + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[6]); + avg_gain = root_sq.root; + g_max_exp = root_sq.shift_factor; + + /* + * maximum gain allowed is calculated from table. + */ + + /* + * g_max = avg_gain * limGains[limiterGains]; + */ + + g_max_man = fxp_mul32_Q30(avg_gain, limGains[limiterGains]); /* table is in Q30 */ + + if (limiterGains == 3) + { + g_max_exp = limGains[4]; + } + + tmp_q1 = g_max_exp >= 16 ? g_max_exp : 16; + + tmp_q2 = g_max_man >> (tmp_q1 - g_max_exp); + tmp_q1 = Q28fmt(1.52587890625F) >> (tmp_q1 - 16); + + if (tmp_q2 > tmp_q1) + { + /* upper limit, +100 dB */ + g_max_man = Q28fmt(1.52587890625F); + g_max_exp = 16; + } + } + else + { + /* Qfmt(1.52587890625F) exp = 16 */ + g_max_man = Q28fmt(1.52587890625F); + g_max_exp = 16; + } + + /* + * Compute Adjusted power p_adj + */ + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + + tmp_q1 = g_max_exp >= nrg_gain_exp[k] ? g_max_exp : nrg_gain_exp[k]; + + tmp_q2 = g_max_man >> (tmp_q1 - g_max_exp); + tmp_q1 = nrg_gain_man[k] >> (tmp_q1 - nrg_gain_exp[k]); + /* + * if(g_max <= nrg_gain[k]) + */ + if (tmp_q2 <= tmp_q1) + { + tmp_q1 = fxp_mul32_Q28(noise_level_man[k], g_max_man); + pv_div(tmp_q1, nrg_gain_man[k], "ient); + noise_level_man[k] = quotient.quotient >> 2; /* in Q28 */ + noise_level_exp[k] = noise_level_exp[k] + g_max_exp - quotient.shift_factor - nrg_gain_exp[k]; + + nrg_gain_man[k] = g_max_man; /* gains with noise supression */ + nrg_gain_exp[k] = g_max_exp; + } + } + + p_adj_exp = -100; + + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + tmp_q1 = nrg_est_exp[k] + (nrg_gain_exp[k] << 1) + 28; /* 28 to match shift down by mult32_Q28 */ + + if (p_adj_exp < tmp_q1) + { + p_adj_exp = tmp_q1; + } + if (nrg_tone_man[k]) + { + tmp_q1 = (nrg_tone_exp[k] << 1); + if (p_adj_exp < tmp_q1) + { + p_adj_exp = tmp_q1; + } + } + else if (!noNoiseFlag) + { + tmp_q1 = (noise_level_exp[k] << 1); + + if (p_adj_exp < tmp_q1) + { + p_adj_exp = tmp_q1; + } + } + } + + p_adj_exp += 1; /* overflow bit-guard*/ + + p_adj_man = 0; + + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + /* + * p_adj += nrg_gain[k]*nrg_gain[k]*nrg_est[k]; + */ + + if (p_adj_exp - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)) < 59) + { + tmp_q1 = fxp_mul32_Q28(nrg_gain_man[k], nrg_gain_man[k]); + tmp_q1 = fxp_mul32_Q28(tmp_q1, nrg_est_man[k]); + p_adj_man += (tmp_q1 >> (p_adj_exp - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1) + 28))); + } + + if (nrg_tone_man[k]) + { + /* + * p_adj += nrg_tone[k]*nrg_tone[k]; + */ + if (p_adj_exp - (nrg_tone_exp[k] << 1) < 31) + { + tmp_q1 = fxp_mul32_Q28(nrg_tone_man[k], nrg_tone_man[k]); + p_adj_man += (tmp_q1 >> (p_adj_exp - (nrg_tone_exp[k] << 1))); + } + } + else if (!noNoiseFlag) + { + /* + * p_adj += noise_level[k]*noise_level[k]; + */ + + if (p_adj_exp - (noise_level_exp[k] << 1) < 31) + { + tmp_q1 = fxp_mul32_Q28(noise_level_man[k], noise_level_man[k]); + p_adj_man += (tmp_q1 >> (p_adj_exp - (noise_level_exp[k] << 1))); + } + + } + } + + + if (p_adj_man) + { + pv_div(p_ref_man, p_adj_man, "ient); + tmp_q2 = p_ref_exp - p_adj_exp - 58 - quotient.shift_factor; /* 58 <> Q30 + Q28 */ + + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[7]); + + if (root_sq.shift_factor > -28) + { + boost_gain_q = root_sq.root << (root_sq.shift_factor + 28); + } + else + { + boost_gain_q = root_sq.root >> (-28 - root_sq.shift_factor); + } + + tmp_q1 = root_sq.shift_factor >= -28 ? root_sq.shift_factor : -28; + + tmp_q2 = root_sq.root >> (tmp_q1 - root_sq.shift_factor); + tmp_q1 = Q28fmt(1.584893192f) >> (tmp_q1 + 28); + + + if (tmp_q2 > tmp_q1) + { + boost_gain_q = Q28fmt(1.584893192f); + } + } + else + { + boost_gain_q = Q28fmt(1.584893192f); + } + + if (band_nrg_tone_detector) + { + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + nrg_gain_man[k] = fxp_mul32_Q28(nrg_gain_man[k], boost_gain_q); + noise_level_man[k] = fxp_mul32_Q28(noise_level_man[k], boost_gain_q); + nrg_tone_man[k] = fxp_mul32_Q28(nrg_tone_man[k], boost_gain_q); + } + } + else + { + + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + nrg_gain_man[k] = fxp_mul32_Q28(nrg_gain_man[k], boost_gain_q); + noise_level_man[k] = fxp_mul32_Q28(noise_level_man[k], boost_gain_q); + } + + + } + + } /* Limiter End for loop (c) */ + + + if (LC_flag == ON) + { + + /* + * Aliasing correction + */ + + sbr_aliasing_reduction(degreeAlias, + nrg_gain_man, + nrg_gain_exp, + nrg_est_man, + nrg_est_exp, + dontUseTheseGainValues, + noSubbands, + lowSubband, + sqrt_cache, + scratch_mem[3]); + + if (*sUp) /* Init only done once upon reset */ + { + *sUp = 0; + } + + envelope_application_LC((Int32 *)aBufR, + nrg_gain_man, + nrg_gain_exp, + noise_level_man, + noise_level_exp, + nrg_tone_man, + nrg_tone_exp, + band_nrg_tone_detector, + frame_info, + harm_index, + phase_index, + i, + lowSubband, + noSubbands, + noNoiseFlag); + } +#ifdef HQ_SBR + else + { + + if (*sUp) /* Init only done once upon reset */ + { + for (n = 0; n < maxSmoothLength; n++) + { + pv_memcpy(fBuf_man[n], nrg_gain_man, noSubbands*sizeof(*fBuf_man[n])); + pv_memcpy(fBufN_man[n], noise_level_man, noSubbands*sizeof(*fBufN_man[n])); + pv_memcpy(fBuf_exp[n], nrg_gain_exp, noSubbands*sizeof(*fBuf_exp[n])); + pv_memcpy(fBufN_exp[n], noise_level_exp, noSubbands*sizeof(*fBufN_exp[n])); + } + *sUp = 0; + } + + + envelope_application((Int32 *)aBufR, + (Int32 *)aBufI, + nrg_gain_man, + nrg_gain_exp, + noise_level_man, + noise_level_exp, + nrg_tone_man, + nrg_tone_exp, + fBuf_man, + fBuf_exp, + fBufN_man, + fBufN_exp, + frame_info, + harm_index, + phase_index, + i, + lowSubband, + noSubbands, + noNoiseFlag, + band_nrg_tone_detector, + maxSmoothLength, + smooth_length); + + } +#endif + + } /* ----- Envelope adjustment end for-loop (i) ---- */ + + + pv_memcpy(&hFp[0] + lowSubband, + hF, + (64 - lowSubband)*sizeof(*hF)); + + if (sEnv == nEnv) + { + frameData->prevEnvIsShort = 0; + } + else + { + frameData->prevEnvIsShort = -1; + } + + +} + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void envelope_application_LC(Int32 *aBufR, + Int32 *nrg_gain_man, + Int32 *nrg_gain_exp, + Int32 *noise_level_man, + Int32 *noise_level_exp, + Int32 *nrg_tone_man, + Int32 *nrg_tone_exp, + Int32 band_nrg_tone_detector, + const Int32 *frame_info, + Int32 *harm_index, + Int32 *phase_index, + Int32 i, + Int32 lowSubband, + Int32 noSubbands, + Int32 noNoiseFlag) +{ + + Int32 *ptrReal; + Int32 sb_gain_man; + Int32 sb_noise_man; + Int32 sb_noise_exp; + Int32 l; + Int32 k; + Int32 tmp_q1; + Int32 tmp_q2; + Int32 tone_count; + Int16 tmp_16; + Int32 indexMinus1; + Int32 indexPlus1; + + + /* + * Application + */ + + if (band_nrg_tone_detector) /* Add tone energy only if energy is detected */ + { + + /* + * pre-calculate tone application + */ + for (k = 0; k < noSubbands; k++) + { + tmp_q2 = (-nrg_tone_exp[k]); + tmp_q1 = nrg_tone_man[k]; + tmp_q2 = tmp_q1 >> tmp_q2; + tmp_q1 = fxp_mul32_by_16(tmp_q2, Q15fmt(0.0163f)); + nrg_tone_man[k] = tmp_q2; + nrg_tone_exp[k] = tmp_q1; + noise_level_exp[k] += 1; + nrg_gain_exp[k] += 28; + } + + for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++) + { + ptrReal = (aBufR + l * SBR_NUM_BANDS); + + tone_count = 0; + + indexPlus1 = (*harm_index + 1) & 3; + + if (indexPlus1 & 1) /* if indexPlus1 is odd */ + { + for (k = 0; k < noSubbands; k++) + { + + sb_gain_man = nrg_gain_man[k]; + tmp_q1 = *ptrReal; + tmp_q2 = nrg_gain_exp[k]; + tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man); + + if (tmp_q2 < 0) + { + if (tmp_q2 > -32) + { + *ptrReal = tmp_q1 >> (-tmp_q2); + } + } + else + { + *ptrReal = tmp_q1 << tmp_q2; + } + + *phase_index = (*phase_index + 1) & 511; + + if (!nrg_tone_man[k] && !noNoiseFlag) + + { + tmp_16 = rP_LCx[*phase_index]; + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -32) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + } + } + + tmp_q1 = nrg_tone_man[k]; + + if (*harm_index) + { + *ptrReal -= tmp_q1; + } + else + { + *ptrReal += tmp_q1; + } + + if (tmp_q1) + { + tone_count++; + } + + ptrReal++; + + } /* for-loop (k) */ + + } + else /* if indexPlus1 is even */ + { + indexMinus1 = (*harm_index - 1) & 3; + + /* --- k = 0 ----- */ + + sb_gain_man = nrg_gain_man[0]; + tmp_q1 = *ptrReal; + tmp_q2 = nrg_gain_exp[0]; + tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man); + + if (tmp_q2 < 0) + { + if (tmp_q2 > -32) + { + *ptrReal = tmp_q1 >> (-tmp_q2); + } + } + else + { + *ptrReal = tmp_q1 << tmp_q2; + } + + *phase_index = (*phase_index + 1) & 511; + + tmp_q1 = nrg_tone_exp[0]; + tmp_q2 = nrg_tone_exp[1]; + + if ((indexPlus1 != 0) ^((lowSubband & 1) != 0)) + { + *(ptrReal - 1) -= tmp_q1; + *(ptrReal) += tmp_q2; + } + else + { + *(ptrReal - 1) += tmp_q1; + *(ptrReal) -= tmp_q2; + } + + if (!nrg_tone_man[0] && !noNoiseFlag) + { + tmp_16 = rP_LCx[*phase_index]; + sb_noise_man = noise_level_man[0]; + sb_noise_exp = noise_level_exp[0]; + + tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -32) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + } + } + else + { + tone_count++; + } + + ptrReal++; + + /* ---- */ + + for (k = 1; k < noSubbands - 1; k++) + { + + sb_gain_man = nrg_gain_man[k]; + tmp_q1 = *ptrReal; + tmp_q2 = nrg_gain_exp[k]; + tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man); + + if (tmp_q2 < 0) + { + if (tmp_q2 > -32) + { + *ptrReal = tmp_q1 >> (-tmp_q2); + } + } + else + { + *ptrReal = tmp_q1 << tmp_q2; + } + + *phase_index = (*phase_index + 1) & 511; + + + if (tone_count < 16) + { + tmp_q1 = nrg_tone_exp[k - 1]; + tmp_q2 = nrg_tone_exp[k + 1]; + + tmp_q1 -= tmp_q2; + + + if ((indexPlus1 != 0) ^(((k + lowSubband) & 1) != 0)) + { + *(ptrReal) -= tmp_q1; + } + else + { + *(ptrReal) += tmp_q1; + } + } /* if (tone_count < 16) */ + + + if (!nrg_tone_man[k] && !noNoiseFlag) + { + tmp_16 = rP_LCx[*phase_index]; + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -32) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + } + } + else + { + tone_count++; + } + + ptrReal++; + + } /* for-loop (k) */ + + sb_gain_man = nrg_gain_man[k]; + tmp_q1 = *ptrReal; + tmp_q2 = nrg_gain_exp[k]; + tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man); + + if (tmp_q2 < 0) + { + if (tmp_q2 > -31) + { + *ptrReal = tmp_q1 >> (-tmp_q2); + } + } + else + { + *ptrReal = tmp_q1 << tmp_q2; + } + + *phase_index = (*phase_index + 1) & 511; + + + if ((tone_count < 16) && !(indexMinus1 &1)) + { + tmp_q1 = nrg_tone_exp[k - 1]; + tmp_q2 = nrg_tone_exp[k ]; + + if ((indexMinus1 != 0) ^(((k + lowSubband) & 1) != 0)) + { + *(ptrReal) += tmp_q1; + + if (k + lowSubband < 62) + { + *(ptrReal + 1) -= tmp_q2; + } + } + else + { + *(ptrReal) -= tmp_q1; + + if (k + lowSubband < 62) + { + *(ptrReal + 1) += tmp_q2; + } + } + } /* if (tone_count < 16) */ + + + if (!nrg_tone_man[k] && !noNoiseFlag) + { + tmp_16 = rP_LCx[*phase_index]; + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -31) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + } + } + + } /* if indexPlus1 is odd */ + + *harm_index = indexPlus1; + + + } /* for-loop (l) */ + + } + else /* if ( band_nrg_tone_detector) */ + { + + for (k = 0; k < noSubbands; k++) + { + tmp_q1 = noise_level_exp[k]; + tmp_q2 = nrg_gain_exp[k]; + noise_level_exp[k] = tmp_q1 + 1; + nrg_gain_exp[k] = tmp_q2 + 28; + } + + for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++) + { + ptrReal = (aBufR + l * SBR_NUM_BANDS); + + for (k = 0; k < noSubbands; k++) + { + + tmp_q1 = *ptrReal; + sb_gain_man = nrg_gain_man[k]; + + tmp_q2 = nrg_gain_exp[k]; + + tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man); + + if (tmp_q2 < 0) + { + if (tmp_q2 > -31) + { + *ptrReal = tmp_q1 >> (-tmp_q2); + } + } + else + { + *ptrReal = tmp_q1 << tmp_q2; + } + + *phase_index = (*phase_index + 1) & 511; + + if (! noNoiseFlag) + { + tmp_16 = rP_LCx[*phase_index]; + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -31) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + } + } + + ptrReal++; + + } /* for-loop (k) */ + + *harm_index = (*harm_index + 1) & 3; + + + } /* for-loop (l) */ + + } + +} + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +#define Qfmt15(a) (Int32)(a*((Int32)1<<15) + (a>=0?0.5F:-0.5F)) + + +const Int16 pow2[39] = { 0, 0, 1, 0, 2, + 0, Qfmt15(2 / 6.0f), 0, 3, 0, Qfmt15(2 / 10.0f), 0, Qfmt15(2 / 12.0f), 0, Qfmt15(2 / 14.0f), 0, 4, + 0, Qfmt15(2 / 18.0f), 0, Qfmt15(2 / 20.0f), 0, Qfmt15(2 / 22.0f), 0, Qfmt15(2 / 24.0f), + 0, Qfmt15(2 / 26.0f), 0, Qfmt15(2 / 28.0f), 0, Qfmt15(2 / 30.0f), 0, 5, 0, Qfmt15(2 / 34.0f), + 0, Qfmt15(2 / 36.0f), 0, Qfmt15(2 / 38.0f) + }; + +void energy_estimation_LC(Int32 *aBufR, + Int32 *nrg_est_man, + Int32 *nrg_est_exp, + const Int32 *frame_info, + Int32 i, + Int32 k, + Int32 c, + Int32 ui2) +{ + Int32 aux1; + Int32 aux2; + Int32 l; + + + int64 nrg_h = 0; + Int32 tmp1; + UInt32 tmp2; + + for (l = ui2; l < (frame_info[2+i] << 1); l++) + { + + aux1 = aBufR[l++*SBR_NUM_BANDS + k ]; + aux2 = aBufR[l *SBR_NUM_BANDS + k ]; + + nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1); + nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2); + } + + /* + * Check for overflow and saturate if needed + */ + if (nrg_h < 0) + { + nrg_h = 0x7fffffff; + nrg_h <<= 32; + nrg_h |= 0xffffffff; + } + + + if (nrg_h) + { + tmp2 = (UInt32)(nrg_h >> 32); + if (tmp2) + { + aux2 = pv_normalize(tmp2); + if (aux2) + { + aux2 -= 1; /* ensure Q30 */ + } + nrg_h = (nrg_h << aux2) >> 33; + tmp2 = (UInt32)(nrg_h); + nrg_est_exp[c] = 33 - aux2; + } + else + { + tmp2 = (UInt32)(nrg_h >> 2); + aux2 = pv_normalize(tmp2); + if (aux2) + { + aux2 -= 1; /* ensure Q30 */ + } + + tmp2 = (tmp2 << aux2); + nrg_est_exp[c] = -aux2 + 2; + } + + tmp1 = (l - ui2); + + aux2 = pow2[tmp1]; + if (tmp1 == (tmp1 & (-tmp1))) + { + nrg_est_man[c] = tmp2 >> aux2; + } + else + { + nrg_est_man[c] = fxp_mul32_by_16(tmp2, aux2); + } + + } + else + { + nrg_est_man[c] = 0; + nrg_est_exp[c] = -100; + } + +} + + + + + + +#if HQ_SBR + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void envelope_application(Int32 *aBufR, + Int32 *aBufI, + Int32 *nrg_gain_man, + Int32 *nrg_gain_exp, + Int32 *noise_level_man, + Int32 *noise_level_exp, + Int32 *nrg_tone_man, + Int32 *nrg_tone_exp, + Int32 *fBuf_man[64], + Int32 *fBuf_exp[64], + Int32 *fBufN_man[64], + Int32 *fBufN_exp[64], + const Int32 *frame_info, + Int32 *harm_index, + Int32 *phase_index, + Int32 i, + Int32 lowSubband, + Int32 noSubbands, + Int32 noNoiseFlag, + Int32 band_nrg_tone_detector, + Int32 maxSmoothLength, + Int32 smooth_length) +{ + + Int32 *ptrReal; + Int32 *ptrImag; + Int32 sb_gain_man; + Int32 sb_gain_exp; + Int32 sb_noise_man; + Int32 sb_noise_exp; + Int32 l; + Int32 k; + Int32 n; + Int32 tmp_q1; + Int32 tmp_q2; + Int32 aux1; + Int32 aux2; + Int32 filter_history = 0; + + + if (band_nrg_tone_detector) /* Add tone energy only if energy is detected */ + { + + /* + * pre-calculate tone application + */ + + ptrReal = nrg_tone_exp; + ptrImag = nrg_tone_man; + tmp_q1 = - *(ptrReal++); + aux1 = *(ptrImag); + for (k = 0; k < noSubbands; k++) + { + *(ptrImag++) = aux1 >> tmp_q1; + tmp_q1 = - *(ptrReal++); + aux1 = *(ptrImag); + } + + /* + * Application + */ + + for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++) + { + ptrReal = (aBufR + l * SBR_NUM_BANDS); + ptrImag = (aBufI + l * SBR_NUM_BANDS); + + if (filter_history <= maxSmoothLength) /* no more update is needed as buffer will have same info */ + { + pv_memmove(fBuf_man[maxSmoothLength], nrg_gain_man, noSubbands*sizeof(*nrg_gain_man)); + pv_memmove(fBuf_exp[maxSmoothLength], nrg_gain_exp, noSubbands*sizeof(*nrg_gain_exp)); + pv_memmove(fBufN_man[maxSmoothLength], noise_level_man, noSubbands*sizeof(*noise_level_man)); + pv_memmove(fBufN_exp[maxSmoothLength], noise_level_exp, noSubbands*sizeof(*noise_level_exp)); + } + + /* + * nrg_gain_max bounded to 1.584893192*1e5, which requires (32-bit) Q14 notation + */ + for (k = 0; k < noSubbands; k++) + { + if (smooth_length == 0) /* no filter-smooth needed */ + { + sb_gain_man = nrg_gain_man[k]; + sb_gain_exp = nrg_gain_exp[k]; + + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + } + else + { /* else smooth_length == 4 and fir_4 filter is being used */ + + sb_gain_exp = fBuf_exp[maxSmoothLength][k]; + + sb_noise_exp = fBufN_exp[maxSmoothLength][k]; + + for (n = maxSmoothLength - smooth_length; n < maxSmoothLength; n++) + { + if (sb_gain_exp < fBuf_exp[n][k]) + { + sb_gain_exp = fBuf_exp[n][k]; + } + + if (sb_noise_exp < fBufN_exp[n][k]) + { + sb_noise_exp = fBufN_exp[n][k]; + } + } + + sb_gain_man = fxp_mul32_Q30(fBuf_man[maxSmoothLength][k], Q30fmt(0.33333333333333f)); + sb_gain_man = sb_gain_man >> (sb_gain_exp - fBuf_exp[maxSmoothLength][k]); + + sb_noise_man = fxp_mul32_Q30(fBufN_man[maxSmoothLength][k], Q30fmt(0.33333333333333f)); + sb_noise_man = sb_noise_man >> (sb_noise_exp - fBufN_exp[maxSmoothLength][k]); + + n = maxSmoothLength - smooth_length; + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.03183050093751f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.03183050093751f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.11516383427084f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.11516383427084f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.21816949906249f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.21816949906249f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.30150283239582f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.30150283239582f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n][k]); + + } + + + + /* + * *ptrReal = *ptrReal * sb_gain ; + * *ptrImag = *ptrImag * sb_gain; + */ + aux1 = *ptrReal; + aux2 = *ptrImag; + sb_gain_exp += 32; + aux1 = fxp_mul32_Q31(aux1, sb_gain_man); + aux2 = fxp_mul32_Q31(aux2, sb_gain_man); + + + if (sb_gain_exp < 0) + { + sb_gain_exp = -sb_gain_exp; + if (sb_gain_exp < 32) + { + *ptrReal = (aux1 >> sb_gain_exp); + *ptrImag = (aux2 >> sb_gain_exp); + } + } + else + { + *ptrReal = (aux1 << sb_gain_exp); + *ptrImag = (aux2 << sb_gain_exp); + } + + + + /* + * if ( sb_noise != 0) + * { + * *ptrReal += sb_noise * rP[*phase_index][0]; + * *ptrImag += sb_noise * rP[*phase_index][1]; + * } + */ + *phase_index = (*phase_index + 1) & 511; + + if (nrg_tone_man[k] || noNoiseFlag) + { + sb_noise_man = 0; + sb_noise_exp = 0; + } + else + { + + Int32 tmp = rPxx[*phase_index]; + sb_noise_exp += 1; + tmp_q1 = fxp_mul32_by_16t(sb_noise_man, tmp); + tmp_q2 = fxp_mul32_by_16b(sb_noise_man, tmp); + + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -32) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + *ptrImag += tmp_q2 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + *ptrImag += tmp_q2 << sb_noise_exp; + } + } + + /* + * tmp_q1 = nrg_tone[k] + */ + + tmp_q1 = nrg_tone_man[k]; + + if (*harm_index & 1) + { + if ((((k + lowSubband) & 1) != 0) ^(*harm_index != 1)) + { + *ptrImag -= tmp_q1; + } + else + { + *ptrImag += tmp_q1; + } + } + else + { + *ptrReal += (*harm_index) ? -tmp_q1 : tmp_q1; + } + + *ptrReal++ <<= 10; + *ptrImag++ <<= 10; + + + } /* for-loop (k) */ + + + *harm_index = (*harm_index + 1) & 3; + + /* + * Update smoothing filter history + */ + + if (filter_history++ < maxSmoothLength) /* no more update is needed as buffer will have same info */ + { + /* + * mantissas + */ + + ptrReal = (Int32 *)fBuf_man[0]; + ptrImag = (Int32 *)fBufN_man[0]; + + for (n = 0; n < maxSmoothLength; n++) + { + fBuf_man[n] = fBuf_man[n+1]; + fBufN_man[n] = fBufN_man[n+1]; + } + + fBuf_man[maxSmoothLength] = ptrReal; + fBufN_man[maxSmoothLength] = ptrImag; + + /* + * exponents + */ + ptrReal = (Int32 *)fBuf_exp[0]; + ptrImag = (Int32 *)fBufN_exp[0]; + + for (n = 0; n < maxSmoothLength; n++) + { + fBuf_exp[n] = fBuf_exp[n+1]; + fBufN_exp[n] = fBufN_exp[n+1]; + } + + fBuf_exp[maxSmoothLength] = ptrReal; + fBufN_exp[maxSmoothLength] = ptrImag; + } + + } /* for-loop (l) */ + + + } + else /* ---- if ( band_nrg_tone_detector) ---- */ + { + + /* + * Application + */ + + for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++) + { + ptrReal = (aBufR + l * SBR_NUM_BANDS); + ptrImag = (aBufI + l * SBR_NUM_BANDS); + + if (filter_history <= maxSmoothLength) /* no more update is needed as buffer will have same info */ + { + pv_memmove(fBuf_man[maxSmoothLength], nrg_gain_man, noSubbands*sizeof(*nrg_gain_man)); + pv_memmove(fBuf_exp[maxSmoothLength], nrg_gain_exp, noSubbands*sizeof(*nrg_gain_exp)); + pv_memmove(fBufN_man[maxSmoothLength], noise_level_man, noSubbands*sizeof(*noise_level_man)); + pv_memmove(fBufN_exp[maxSmoothLength], noise_level_exp, noSubbands*sizeof(*noise_level_exp)); + } + + /* + * nrg_gain_max bounded to 1.584893192*1e5, which requires (32-bit) Q14 notation + */ + for (k = 0; k < noSubbands; k++) + { + if (smooth_length == 0) /* no filter-smooth needed */ + { + sb_gain_man = nrg_gain_man[k]; + sb_gain_exp = nrg_gain_exp[k]; + + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + } + else + { /* else smooth_length == 4 and fir_4 filter is being used */ + + sb_gain_exp = fBuf_exp[maxSmoothLength][k]; + + sb_noise_exp = fBufN_exp[maxSmoothLength][k]; + + for (n = maxSmoothLength - smooth_length; n < maxSmoothLength; n++) + { + if (sb_gain_exp < fBuf_exp[n][k]) + { + sb_gain_exp = fBuf_exp[n][k]; + } + + if (sb_noise_exp < fBufN_exp[n][k]) + { + sb_noise_exp = fBufN_exp[n][k]; + } + } + + sb_gain_man = fxp_mul32_Q30(fBuf_man[maxSmoothLength][k], Q30fmt(0.33333333333333f)); + sb_gain_man = sb_gain_man >> (sb_gain_exp - fBuf_exp[maxSmoothLength][k]); + + sb_noise_man = fxp_mul32_Q30(fBufN_man[maxSmoothLength][k], Q30fmt(0.33333333333333f)); + sb_noise_man = sb_noise_man >> (sb_noise_exp - fBufN_exp[maxSmoothLength][k]); + + n = maxSmoothLength - smooth_length; + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.03183050093751f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.03183050093751f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.11516383427084f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.11516383427084f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.21816949906249f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.21816949906249f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.30150283239582f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.30150283239582f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n][k]); + + } + + + + /* + * *ptrReal = *ptrReal * sb_gain ; + * *ptrImag = *ptrImag * sb_gain; + */ + aux1 = *ptrReal; + aux2 = *ptrImag; + sb_gain_exp += 32; + aux1 = fxp_mul32_Q31(aux1, sb_gain_man); + aux2 = fxp_mul32_Q31(aux2, sb_gain_man); + + + + /* + * if ( sb_noise != 0) + * { + * *ptrReal += sb_noise * rP[*phase_index][0]; + * *ptrImag += sb_noise * rP[*phase_index][1]; + * } + */ + + + if (sb_gain_exp < 0) + { + if (sb_gain_exp > -32) + { + if (sb_gain_exp > -10) + { + *ptrReal = aux1 << (10 + sb_gain_exp); + *ptrImag = aux2 << (10 + sb_gain_exp); + } + else + { + *ptrReal = aux1 >> (-sb_gain_exp - 10); + *ptrImag = aux2 >> (-sb_gain_exp - 10); + } + } + } + else + { + *ptrReal = aux1 << (sb_gain_exp + 10); + *ptrImag = aux2 << (sb_gain_exp + 10); + } + + + + + /* + * if ( sb_noise != 0) + * { + * *ptrReal += sb_noise * rP[*phase_index][0]; + * *ptrImag += sb_noise * rP[*phase_index][1]; + * } + */ + *phase_index = (*phase_index + 1) & 511; + + if (!noNoiseFlag) + { + + Int32 tmp = rPxx[*phase_index]; + sb_noise_exp += 1; + tmp_q1 = fxp_mul32_by_16t(sb_noise_man, tmp); + tmp_q2 = fxp_mul32_by_16b(sb_noise_man, tmp); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -32) + { + if (sb_noise_exp > -10) + { + *ptrReal += tmp_q1 << (10 + sb_noise_exp); + *ptrImag += tmp_q2 << (10 + sb_noise_exp); + } + else + { + *ptrReal += tmp_q1 >> (-sb_noise_exp - 10); + *ptrImag += tmp_q2 >> (-sb_noise_exp - 10); + } + } + } + else + { + *ptrReal += tmp_q1 << (sb_noise_exp + 10); + *ptrImag += tmp_q2 << (sb_noise_exp + 10); + } + } + + ptrReal++; + ptrImag++; + + + } /* for-loop (k) */ + + + *harm_index = (*harm_index + 1) & 3; + + /* + * Update smoothing filter history + */ + + if (filter_history++ < maxSmoothLength) /* no more update is needed as buffer will have same info */ + { + /* + * mantissas + */ + + ptrReal = (Int32 *)fBuf_man[0]; + ptrImag = (Int32 *)fBufN_man[0]; + + for (n = 0; n < maxSmoothLength; n++) + { + fBuf_man[n] = fBuf_man[n+1]; + fBufN_man[n] = fBufN_man[n+1]; + } + + fBuf_man[maxSmoothLength] = ptrReal; + fBufN_man[maxSmoothLength] = ptrImag; + + /* + * exponents + */ + ptrReal = (Int32 *)fBuf_exp[0]; + ptrImag = (Int32 *)fBufN_exp[0]; + + for (n = 0; n < maxSmoothLength; n++) + { + fBuf_exp[n] = fBuf_exp[n+1]; + fBufN_exp[n] = fBufN_exp[n+1]; + } + + fBuf_exp[maxSmoothLength] = ptrReal; + fBufN_exp[maxSmoothLength] = ptrImag; + } + + } /* for-loop (l) */ + + } /* if ( band_nrg_tone_detector) */ + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void energy_estimation(Int32 *aBufR, + Int32 *aBufI, + Int32 *nrg_est_man, + Int32 *nrg_est_exp, + const Int32 *frame_info, + Int32 i, + Int32 k, + Int32 c, + Int32 ui2) +{ + + Int32 aux1; + Int32 aux2; + Int32 l; + + int64 nrg_h = 0; + Int32 tmp1; + Int32 tmp2; + + aux1 = aBufR[ui2*SBR_NUM_BANDS + k]; + aux2 = aBufI[ui2*SBR_NUM_BANDS + k]; + for (l = ui2 + 1; l < (frame_info[2+i] << 1); l++) + { + nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1); + nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2); + aux1 = aBufR[l*SBR_NUM_BANDS + k]; + aux2 = aBufI[l*SBR_NUM_BANDS + k]; + } + nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1); + nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2); + + + /* + * Check for overflow and saturate if needed + */ + if (nrg_h < 0) + { + nrg_h = 0x7fffffff; + nrg_h <<= 32; + nrg_h |= 0xffffffff; + } + + if (nrg_h) + { + + aux1 = (UInt32)(nrg_h >> 32); + if (aux1) + { + aux2 = pv_normalize(aux1); + if (aux2) + { + aux2 -= 1; /* ensure Q30 */ + nrg_h = (nrg_h << aux2) >> 33; + tmp2 = (UInt32)(nrg_h); + nrg_est_exp[c] = 33 - aux2; + } + else + { + tmp2 = (UInt32)(aux1 >> 1); + nrg_est_exp[c] = 33 ; + + + } + } + else + { + aux1 = (UInt32)(nrg_h >> 1); + aux2 = pv_normalize(aux1); + + tmp2 = (aux1 << aux2); + nrg_est_exp[c] = -aux2 + 1; + + + } + + + + tmp1 = (l - ui2); + aux2 = pow2[tmp1]; + if (tmp1 == (tmp1 & (-tmp1))) + { + nrg_est_man[c] = tmp2 >> aux2; + } + else + { + nrg_est_man[c] = fxp_mul32_by_16(tmp2, aux2); + } + } + else + { + nrg_est_man[c] = 0; + nrg_est_exp[c] = -100; + } + + +} + +#endif + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.h new file mode 100644 index 0000000..d56f786 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.h @@ -0,0 +1,138 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_sbr_envelope.h + Funtions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CALCULATE_SBR_ENVELOPE_H +#define CALCULATE_SBR_ENVELOPE_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_sbr_frame_data.h" +#include "sbr_generate_high_freq.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + void calc_sbr_envelope(SBR_FRAME_DATA *frameData, + Int32 *aBufR, + Int32 *aBufI, + Int freqBandTable1[2][MAX_FREQ_COEFFS + 1], + const Int32 *nSfb, + Int32 freqBandTable2[MAX_NOISE_COEFFS + 1], + Int32 nNBands, + Int32 reset, + Int32 *degreeAlias, + Int32 *harm_index, + Int32 *phase_index, + Int32 hFp[64], + Int32 *sUp, + Int32 limSbc[][13], + Int32 *gateMode, +#ifdef HQ_SBR + Int32 *fBuf_man[64], + Int32 *fBuf_exp[64], + Int32 *fBufN_man[64], + Int32 *fBufN_exp[64], +#endif + Int32 scratch_mem[][64], + struct PATCH Patch, + Int32 sqrt_cache[][4], + Int32 LC_flag); +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* CALCULATE_SBR_ENVELOPE_H */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.cpp new file mode 100644 index 0000000..cfe3fa8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.cpp @@ -0,0 +1,575 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_sbr_synfilterbank.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +#ifdef AAC_PLUS + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "calc_sbr_synfilterbank.h" +#include "qmf_filterbank_coeff.h" +#include "synthesis_sub_band.h" +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#if ((PV_CPU_ARCH_VERSION >=5) && (PV_COMPILER == EPV_ARM_GNUC)) + +__inline Int16 sat(Int32 y) +{ + register Int32 x; + register Int32 ra = y; + + + asm volatile( + "qdadd %0, %1, %1\n\t" + "mov %0, %0, asr #16" + : "=&r*i"(x) + : "r"(ra)); + + return ((Int16)x); +} + + +#define saturate2( a, b, c, d) *c = sat( a); \ + *d = sat( b); \ + c += 2; \ + d -= 2; + + +#else + + +#define saturate2( a, b, c, d) a -= (a>>2); \ + a = (a>>N); \ + if((a>>15) != (a>>31)) \ + { \ + a = ((a >> 31) ^ INT16_MAX); \ + } \ + *c = (Int16)a; \ + c += 2; \ + b -= (b>>2); \ + b = (b>>N); \ + if((b>>15) != (b>>31)) \ + { \ + b = ((b >> 31) ^ INT16_MAX); \ + } \ + *d = (Int16)b; \ + d -= 2; +#endif + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void calc_sbr_synfilterbank_LC(Int32 * Sr, + Int16 * timeSig, + Int16 V[1280], + bool bDownSampleSBR) +{ + Int32 i; + + Int32 realAccu1; + Int32 realAccu2; + const Int32 *pt_C2; + + Int16 *pt_V1; + Int16 *pt_V2; + + + Int16 *pt_timeSig; + + Int16 *pt_timeSig_2; + Int32 test1; + Int16 tmp1; + Int16 tmp2; + + /* shift filterstates */ + + Int32 * pt_Sr = Sr; + + + if (bDownSampleSBR == false) + { + + synthesis_sub_band_LC(pt_Sr, V); + + /* content of V[] is at most 16 bits */ + + pt_timeSig = &timeSig[0]; + pt_timeSig_2 = &timeSig[64]; + + + tmp1 = V[ 704]; + tmp2 = V[ 768]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.853738560F), ROUND_SYNFIL1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.361158990F), realAccu1); + tmp1 = -V[ 512]; + tmp2 = V[ 960]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.361158990F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.070353307F), realAccu1); + tmp1 = V[ 448]; + tmp2 = V[1024]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.070353307F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.013271822F), realAccu1); + tmp1 = -V[ 256]; + tmp2 = V[ 192]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.013271822F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.002620176F), realAccu1); + realAccu1 = fxp_mac_16_by_16(V[1216], Qfmt(0.002620176F), realAccu1); + + tmp1 = V[ 32]; + tmp2 = V[1248]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.000665042F), ROUND_SYNFIL2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.000665042F), realAccu2); + tmp1 = V[ 224]; + tmp2 = V[1056]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.005271576F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.005271576F), realAccu2); + tmp1 = V[ 992]; + tmp2 = V[ 288]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.058591568F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.058591568F), realAccu2); + tmp1 = V[ 480]; + tmp2 = V[ 800]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.058370533F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.058370533F), realAccu2); + tmp1 = V[ 736]; + tmp2 = V[ 544]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.702238872F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.702238872F), realAccu2); + + + + saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2); + + pt_timeSig_2 = &timeSig[126]; + + pt_V1 = &V[1]; + pt_V2 = &V[1279]; + + pt_C2 = &sbrDecoderFilterbankCoefficients[0]; + + for (i = 31; i != 0; i--) + { + test1 = *(pt_C2++); + tmp1 = *(pt_V1++); + tmp2 = *(pt_V2--); + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, ROUND_SYNFIL); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, ROUND_SYNFIL); + tmp1 = pt_V1[ 191]; + tmp2 = pt_V2[ -191]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 255]; + tmp2 = pt_V2[ -255]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 447]; + tmp2 = pt_V2[ -447]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 511]; + tmp2 = pt_V2[ -511]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 703]; + tmp2 = pt_V2[ -703]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 767]; + tmp2 = pt_V2[ -767]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 959]; + tmp2 = pt_V2[ -959]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 1023]; + tmp2 = pt_V2[ -1023]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 1215]; + tmp2 = pt_V2[ -1215]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2); + + } + } + else + { + + synthesis_sub_band_LC_down_sampled(Sr, V); + + /* + * window signal + * calculate output samples + */ + + + pt_V1 = &V[0]; + pt_V2 = &V[96]; + + + Int32 * pt_out = Sr; + + for (i = 0; i < 8; i++) + { + *(pt_out++) = 0; + *(pt_out++) = 0; + *(pt_out++) = 0; + *(pt_out++) = 0; + } + + const Int32* pt_C1 = &sbrDecoderFilterbankCoefficients_down_smpl[0]; + pt_C2 = &sbrDecoderFilterbankCoefficients_down_smpl[16]; + + for (int k = 0; k < 5; k++) + { + pt_out -= 32; + for (i = 0; i < 16; i++) + { + realAccu1 = fxp_mul_16_by_16bt(*(pt_V1++), *(pt_C1)); + realAccu2 = fxp_mul_16_by_16bb(*(pt_V1++), *(pt_C1++)); + realAccu1 = fxp_mac_16_by_16_bt(*(pt_V2++), *(pt_C2), realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(*(pt_V2++), *(pt_C2++), realAccu2); + *(pt_out++) += realAccu1 >> 5; + *(pt_out++) += realAccu2 >> 5; + + } + pt_V1 += 96; + pt_V2 += 96; + pt_C1 += 16; + pt_C2 += 16; + } + pt_out -= 32; + + for (i = 0; i < 32; i++) + { + timeSig[2*i] = (Int16)((*(pt_out++) + 512) >> 10); + } + + } + +} + + + +#ifdef HQ_SBR + +void calc_sbr_synfilterbank(Int32 * Sr, + Int32 * Si, + Int16 * timeSig, + Int16 V[1280], + bool bDownSampleSBR) +{ + Int32 i; + + const Int32 *pt_C2; + + Int32 realAccu1; + Int32 realAccu2; + + Int16 *pt_V1; + Int16 *pt_V2; + + Int16 *pt_timeSig; + + Int16 *pt_timeSig_2; + Int32 test1; + Int16 tmp1; + Int16 tmp2; + + + if (bDownSampleSBR == false) + { + synthesis_sub_band(Sr, Si, V); + + /* content of V[] is at most 16 bits */ + pt_timeSig = &timeSig[0]; + pt_timeSig_2 = &timeSig[64]; + + tmp1 = V[ 704]; + tmp2 = V[ 768]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.853738560F), ROUND_SYNFIL); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.361158990F), realAccu1); + tmp1 = -V[ 512]; + tmp2 = V[ 960]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.361158990F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.070353307F), realAccu1); + tmp1 = V[ 448]; + tmp2 = V[1024]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.070353307F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.013271822F), realAccu1); + tmp1 = -V[ 256]; + tmp2 = V[ 192]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.013271822F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.002620176F), realAccu1); + realAccu1 = fxp_mac_16_by_16(V[1216], Qfmt(0.002620176F), realAccu1); + + tmp1 = V[ 32]; + tmp2 = V[1248]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.000665042F), ROUND_SYNFIL); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.000665042F), realAccu2); + tmp1 = V[ 224]; + tmp2 = V[1056]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.005271576F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.005271576F), realAccu2); + tmp1 = V[ 992]; + tmp2 = V[ 288]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.058591568F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.058591568F), realAccu2); + tmp1 = V[ 480]; + tmp2 = V[ 800]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.058370533F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.058370533F), realAccu2); + tmp1 = V[ 736]; + tmp2 = V[ 544]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.702238872F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.702238872F), realAccu2); + + + saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2); + + pt_timeSig_2 = &timeSig[126]; + + pt_V1 = &V[1]; + pt_V2 = &V[1279]; + + pt_C2 = &sbrDecoderFilterbankCoefficients[0]; + + for (i = 31; i != 0; i--) + { + test1 = *(pt_C2++); + tmp1 = *(pt_V1++); + tmp2 = *(pt_V2--); + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, ROUND_SYNFIL); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, ROUND_SYNFIL); + tmp1 = pt_V1[ 191]; + tmp2 = pt_V2[ -191]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 255]; + tmp2 = pt_V2[ -255]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 447]; + tmp2 = pt_V2[ -447]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 511]; + tmp2 = pt_V2[ -511]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 703]; + tmp2 = pt_V2[ -703]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 767]; + tmp2 = pt_V2[ -767]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 959]; + tmp2 = pt_V2[ -959]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 1023]; + tmp2 = pt_V2[ -1023]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 1215]; + tmp2 = pt_V2[ -1215]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2); + } + + } + else + { + + synthesis_sub_band_down_sampled(Sr, Si, V); + + + Int32 * pt_out = Sr; + + for (i = 0; i < 8; i++) + { + *(pt_out++) = 0; + *(pt_out++) = 0; + *(pt_out++) = 0; + *(pt_out++) = 0; + } + + + /* + * window signal + * calculate output samples + */ + + pt_V1 = &V[0]; + pt_V2 = &V[96]; + + + const Int32* pt_C1 = &sbrDecoderFilterbankCoefficients_down_smpl[0]; + pt_C2 = &sbrDecoderFilterbankCoefficients_down_smpl[16]; + + for (Int k = 0; k < 5; k++) + { + pt_out -= 32; + for (i = 0; i < 16; i++) + { + realAccu1 = fxp_mul_16_by_16bt(*(pt_V1++), *(pt_C1)); + realAccu2 = fxp_mul_16_by_16bb(*(pt_V1++), *(pt_C1++)); + realAccu1 = fxp_mac_16_by_16_bt(*(pt_V2++), *(pt_C2), realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(*(pt_V2++), *(pt_C2++), realAccu2); + *(pt_out++) += realAccu1 >> 5; + *(pt_out++) += realAccu2 >> 5; + } + pt_V1 += 96; + pt_V2 += 96; + pt_C1 += 16; + pt_C2 += 16; + } + pt_out -= 32; + + for (i = 0; i < 32; i++) + { + timeSig[2*i] = (Int16)((*(pt_out++) + 512) >> 10); + } + + } +} + + +#endif /* --- HQ_SBR --- */ + + +#endif /* --- AAC_PLUS --- */ + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.h new file mode 100644 index 0000000..e39ccbe --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.h @@ -0,0 +1,96 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CALC_SBR_SYNFILTERBANK_H +#define CALC_SBR_SYNFILTERBANK_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ +#define N 14 + +#define ROUND_SYNFIL (32768 + 4096) +#define ROUND_SYNFIL1 (32768 + 4096) +#define ROUND_SYNFIL2 (32768 - 4096) + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + + void calc_sbr_synfilterbank_LC(Int32 * Sr, + Int16 * timeSig, + Int16 V[1280], + bool bDownSampleSBR); + +#ifdef HQ_SBR + + + void calc_sbr_synfilterbank(Int32 * Sr, + Int32 * Si, + Int16 * timeSig, + Int16 V[1280], + bool bDownSampleSBR); + +#endif + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/chans.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/chans.h new file mode 100644 index 0000000..869be3c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/chans.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: chans.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CHANS_H +#define CHANS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + /* #define is required in order to use these args in #if () directive */ +#define ICChans 0 +#define DCChans 0 +#define XCChans 0 +#define CChans 0 + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + enum + { + /* + * channels for 5.1 main profile configuration + * (modify for any desired decoder configuration) + */ + FChans = 2, /* front channels: left, center, right */ + FCenter = 0, /* 1 if decoder has front center channel */ + SChans = 0, /* side channels: */ + BChans = 0, /* back channels: left surround, right surround */ + BCenter = 0, /* 1 if decoder has back center channel */ + LChans = 0, /* LFE channels */ + XChans = 0, /* scratch space for parsing unused channels */ + + Chans = FChans + SChans + BChans + LChans + XChans + }; + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* CHANS_H */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/check_crc.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/check_crc.cpp new file mode 100644 index 0000000..9c5d5e4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/check_crc.cpp @@ -0,0 +1,137 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: check_crc.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + INPUT + + + OUTPUT + + errorCode, noError if successful + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "check_crc.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void check_crc(HANDLE_CRC hCrcBuf, UInt32 bValue, Int32 nBits) +{ + Int32 i; + UInt32 bMask = (1UL << (nBits - 1)); + + for (i = 0; i < nBits; i++, bMask >>= 1) + { + UInt16 flag = (UInt16)((hCrcBuf->crcState & hCrcBuf->crcMask) ? 1 : 0); + UInt16 flag1 = (UInt16)((bMask & bValue) ? 1 : 0); + + flag ^= flag1; + hCrcBuf->crcState <<= 1; + if (flag) + hCrcBuf->crcState ^= hCrcBuf->crcPoly; + } + +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/check_crc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/check_crc.h new file mode 100644 index 0000000..d4f3df4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/check_crc.h @@ -0,0 +1,118 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: check_crc.h + Funtions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CHECK_CRC_H +#define CHECK_CRC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_crc_buffer.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + void check_crc(HANDLE_CRC hCrcBuf, + UInt32 bValue, + Int32 nBits); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct16.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct16.cpp new file mode 100644 index 0000000..4a1c0ce --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct16.cpp @@ -0,0 +1,260 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: dct16.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 16 + + Int32 flag 1 forward dct16, 0 modified dct-16 + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement dct of lenght 16 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#include "dct16.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define Qfmt_31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) + +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void dct_16(Int32 vec[], Int flag) +{ + Int32 tmp0; + Int32 tmp1; + Int32 tmp2; + Int32 tmp3; + Int32 tmp4; + Int32 tmp5; + Int32 tmp6; + Int32 tmp7; + Int32 tmp_o0; + Int32 tmp_o1; + Int32 tmp_o2; + Int32 tmp_o3; + Int32 tmp_o4; + Int32 tmp_o5; + Int32 tmp_o6; + Int32 tmp_o7; + Int32 itmp_e0; + Int32 itmp_e1; + Int32 itmp_e2; + + /* split input vector */ + + + tmp_o0 = fxp_mul32_by_16((vec[ 0] - vec[15]), Qfmt15(0.50241928618816F)); + tmp0 = vec[ 0] + vec[15]; + + tmp_o7 = fxp_mul32_Q31((vec[ 7] - vec[ 8]) << 3, Qfmt_31(0.63764357733614F)); + tmp7 = vec[ 7] + vec[ 8]; + + itmp_e0 = (tmp0 + tmp7); + tmp7 = fxp_mul32_by_16((tmp0 - tmp7), Qfmt15(0.50979557910416F)); + + tmp_o1 = fxp_mul32_by_16((vec[ 1] - vec[14]), Qfmt15(0.52249861493969F)); + tmp1 = vec[ 1] + vec[14]; + tmp_o6 = fxp_mul32_by_16((vec[ 6] - vec[ 9]) << 1, Qfmt15(0.86122354911916F)); + tmp6 = vec[ 6] + vec[ 9]; + + itmp_e1 = (tmp1 + tmp6); + tmp6 = fxp_mul32_by_16((tmp1 - tmp6), Qfmt15(0.60134488693505F)); + + tmp_o2 = fxp_mul32_by_16((vec[ 2] - vec[13]), Qfmt15(0.56694403481636F)); + tmp2 = vec[ 2] + vec[13]; + tmp_o5 = fxp_mul32_by_16((vec[ 5] - vec[10]) << 1, Qfmt15(0.53033884299517F)); + tmp5 = vec[ 5] + vec[10]; + + itmp_e2 = (tmp2 + tmp5); + tmp5 = fxp_mul32_by_16((tmp2 - tmp5), Qfmt15(0.89997622313642F)); + + tmp_o3 = fxp_mul32_by_16((vec[ 3] - vec[12]), Qfmt15(0.64682178335999F)); + tmp3 = vec[ 3] + vec[12]; + tmp_o4 = fxp_mul32_by_16((vec[ 4] - vec[11]), Qfmt15(0.78815462345125F)); + tmp4 = vec[ 4] + vec[11]; + + tmp1 = (tmp3 + tmp4); + tmp4 = fxp_mul32_Q31((tmp3 - tmp4) << 2, Qfmt_31(0.64072886193538F)); + + /* split even part of tmp_e */ + + tmp0 = (itmp_e0 + tmp1); + tmp1 = fxp_mul32_by_16((itmp_e0 - tmp1), Qfmt15(0.54119610014620F)); + + + tmp3 = fxp_mul32_by_16((itmp_e1 - itmp_e2) << 1, Qfmt15(0.65328148243819F)); + tmp2 = (itmp_e1 + itmp_e2); + + vec[ 0] = tmp0 >> 1; + vec[ 0] += tmp2 >> 1; + vec[ 8] = fxp_mul32_by_16((tmp0 - tmp2), Qfmt15(0.70710678118655F)); + vec[12] = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F)); + vec[ 4] = tmp1 + tmp3; + vec[ 4] += vec[12]; + + /* split odd part of tmp_e */ + + tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F)); + tmp7 += tmp4; + tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F)); + + tmp6 += tmp5; + + vec[10] = fxp_mul32_by_16((tmp7 - tmp6) << 1, Qfmt15(0.70710678118655F)); + vec[ 2] = tmp7 + tmp6; + vec[14] = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F)); + + tmp1 += tmp3 + vec[14]; + vec[ 2] += tmp1; + vec[ 6] = tmp1 + vec[10]; + + vec[10] += vec[14]; + + + // dct8; + + tmp7 = tmp_o0 + tmp_o7; + tmp_o7 = fxp_mul32_by_16((tmp_o0 - tmp_o7) << 1, Qfmt15(0.50979557910416F)); + + tmp6 = tmp_o1 + tmp_o6; + tmp_o1 = fxp_mul32_by_16((tmp_o1 - tmp_o6) << 1, Qfmt15(0.60134488693505F)); + + tmp5 = tmp_o2 + tmp_o5; + tmp_o5 = fxp_mul32_by_16((tmp_o2 - tmp_o5) << 1, Qfmt15(0.89997622313642F)); + + tmp4 = tmp_o3 + tmp_o4; + + tmp_o3 = fxp_mul32_Q31((tmp_o3 - tmp_o4) << 3, Qfmt_31(0.6407288619354F)); + + if (!flag) + { + tmp7 = -tmp7; + tmp_o7 = -tmp_o7; + tmp6 = -tmp6; + tmp_o1 = -tmp_o1; + tmp5 = -tmp5; + tmp_o5 = -tmp_o5; + tmp4 = -tmp4; + tmp_o3 = -tmp_o3; + } + + // even part + + tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F)); + tmp0 = tmp7 + tmp4; + tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F)); + tmp2 = tmp6 + tmp5; + + vec[ 9] = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F)); + vec[ 1] = tmp0 + tmp2; + vec[13] = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F)); + + vec[ 5] = tmp1 + tmp3 + vec[13]; + + // odd part + + tmp0 = tmp_o7 + tmp_o3; + tmp1 = fxp_mul32_by_16((tmp_o7 - tmp_o3) << 1, Qfmt15(0.54119610014620F)); + tmp2 = tmp_o1 + tmp_o5; + tmp3 = fxp_mul32_Q31((tmp_o1 - tmp_o5) << 2, Qfmt_31(0.65328148243819F)); + + vec[11] = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F)); + vec[ 3] = tmp0 + tmp2; + vec[15] = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F)); + vec[ 7] = tmp1 + tmp3 + vec[15]; + + + vec[ 3] += vec[ 7]; + vec[ 7] += vec[11]; + vec[11] += vec[15]; + + vec[ 1] += vec[ 3]; + vec[ 3] += vec[ 5]; + vec[ 5] += vec[ 7]; + vec[ 7] += vec[ 9]; + vec[ 9] += vec[11]; + vec[11] += vec[13]; + vec[13] += vec[15]; + + +} + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct16.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct16.h new file mode 100644 index 0000000..1442c71 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct16.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dct16.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef DCT16_H +#define DCT16_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void dct_16(Int32 vec[], Int flag); + + +#ifdef __cplusplus +} +#endif + +#endif /* DCT16_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct64.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct64.cpp new file mode 100644 index 0000000..a08519b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct64.cpp @@ -0,0 +1,562 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dct64.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 64 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement dct of lenght 64 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "dct16.h" +#include "dct64.h" + +#include "pv_audio_type_defs.h" +#include "synthesis_sub_band.h" + +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define Qfmt(a) (Int32)(a*((Int32)1<<26) + (a>=0?0.5F:-0.5F)) +#define Qfmt31(a) (Int32)(a*0x7FFFFFFF) + +const Int32 CosTable_48[48] = +{ + Qfmt31(0.50015063602065F) , Qfmt31(0.50135845244641F) , + Qfmt31(0.50378872568104F) , Qfmt31(0.50747117207256F) , + Qfmt31(0.51245147940822F) , Qfmt31(0.51879271310533F) , + Qfmt31(0.52657731515427F) , Qfmt31(0.53590981690799F) , + Qfmt31(0.54692043798551F) , Qfmt31(0.55976981294708F) , + Qfmt31(0.57465518403266F) , Qfmt31(0.59181853585742F) , + Qfmt31(0.61155734788251F) , Qfmt31(0.63423893668840F) , + Qfmt31(0.66031980781371F) , Qfmt31(0.69037212820021F) , + Qfmt31(0.72512052237720F) , Qfmt31(0.76549416497309F) , + Qfmt31(0.81270209081449F) , Qfmt31(0.86834471522335F) , + Qfmt(0.93458359703641F) , Qfmt(1.01440826499705F) , + Qfmt(1.11207162057972F) , Qfmt(1.23383273797657F) , + Qfmt(1.38929395863283F) , Qfmt(1.59397228338563F) , + Qfmt(1.87467598000841F) , Qfmt(2.28205006800516F) , + Qfmt(2.92462842815822F) , Qfmt(4.08461107812925F) , + Qfmt(6.79675071167363F) , Qfmt(20.37387816723145F) , /* 32 */ + Qfmt(0.50060299823520F) , Qfmt(0.50547095989754F) , + Qfmt(0.51544730992262F) , Qfmt(0.53104259108978F) , + Qfmt(0.55310389603444F) , Qfmt(0.58293496820613F) , + Qfmt(0.62250412303566F) , Qfmt(0.67480834145501F) , + Qfmt(0.74453627100230F) , Qfmt(0.83934964541553F) , + Qfmt(0.97256823786196F) , Qfmt(1.16943993343288F) , + Qfmt(1.48416461631417F) , Qfmt(2.05778100995341F) , + Qfmt(3.40760841846872F) , Qfmt(10.19000812354803F) +}; + + + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; dct_64 +----------------------------------------------------------------------------*/ + +void pv_split_LC(Int32 *vector, + Int32 *temp_o) +{ + + Int32 i; + Int32 *pt_vector = &vector[0]; + Int32 *pt_vector_N_1 = &vector[31]; + const Int32 *pt_cosTerms = &CosTable_48[32]; + Int32 *pt_temp_o = temp_o; + Int32 tmp1; + Int32 tmp2; + Int32 tmp3; + + + tmp1 = *(pt_vector); + tmp2 = *(pt_vector_N_1--); + for (i = 16; i != 0; i--) + { + tmp3 = *(pt_cosTerms++); + *(pt_vector++) = tmp1 + tmp2; + *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), tmp3); + tmp1 = *(pt_vector); + tmp2 = *(pt_vector_N_1--); + } + +} + + +#ifdef HQ_SBR + + +void dct_64(Int32 vec[], Int32 *scratch_mem) +{ + Int32 *temp_e1; + Int32 *temp_o1; + + Int32 *pt_vec; + + Int i; + + Int32 aux1; + Int32 aux2; + Int32 aux3; + Int32 aux4; + + const Int32 *cosTerms = &CosTable_48[31]; + + temp_o1 = &vec[32]; + temp_e1 = temp_o1 - 1; + + + for (i = 6; i != 0; i--) + { + aux1 = *(temp_e1); + aux2 = *(temp_o1); + aux3 = *(cosTerms--); + *(temp_e1--) = aux1 + aux2; + *(temp_o1++) = fxp_mul32_Q26((aux1 - aux2), aux3); + aux1 = *(temp_e1); + aux2 = *(temp_o1); + aux3 = *(cosTerms--); + *(temp_e1--) = aux1 + aux2; + *(temp_o1++) = fxp_mul32_Q26((aux1 - aux2), aux3); + } + + + for (i = 10; i != 0; i--) + { + aux1 = *(temp_e1); + aux2 = *(temp_o1); + aux3 = *(cosTerms--); + *(temp_e1--) = aux1 + aux2; + *(temp_o1++) = fxp_mul32_Q31((aux1 - aux2), aux3) << 1; + aux1 = *(temp_e1); + aux2 = *(temp_o1); + aux3 = *(cosTerms--); + *(temp_e1--) = aux1 + aux2; + *(temp_o1++) = fxp_mul32_Q31((aux1 - aux2), aux3) << 1; + } + + + pv_split(&vec[16]); + + dct_16(&vec[16], 0); + dct_16(vec, 1); // Even terms + + pv_merge_in_place_N32(vec); + + pv_split_z(&vec[32]); + + dct_16(&vec[32], 1); // Even terms + dct_16(&vec[48], 0); + + pv_merge_in_place_N32(&vec[32]); + + + + aux1 = vec[32]; + aux3 = vec[33]; + aux4 = vec[ 1]; /* vec[ 1] */ + + /* -----------------------------------*/ + aux1 = vec[32] + vec[33]; + vec[ 0] += aux1; + vec[ 1] += aux1; + + aux1 = vec[34]; + aux2 = vec[ 2]; /* vec[ 2] */ + aux3 += aux1; + vec[ 2] = aux4 + aux3; + aux4 = vec[ 3]; /* vec[ 3] */ + vec[ 3] = aux2 + aux3; + + aux3 = vec[35]; + + /* -----------------------------------*/ + aux1 += aux3; + vec[32] = vec[ 4]; + vec[33] = vec[ 5]; + vec[ 4] = aux2 + aux1; + vec[ 5] = aux4 + aux1; + + aux1 = vec[36]; + aux2 = vec[32]; /* vec[ 4] */ + aux3 += aux1; + vec[34] = vec[ 6]; + vec[35] = vec[ 7]; + vec[ 6] = aux4 + aux3; + vec[ 7] = aux2 + aux3; + + aux3 = vec[37]; + aux4 = vec[33]; /* vec[ 5] */ + + /* -----------------------------------*/ + aux1 += aux3; + vec[32] = vec[ 8]; + vec[33] = vec[ 9]; + vec[ 8] = aux2 + aux1; + vec[ 9] = aux4 + aux1; + + aux1 = vec[38]; + aux2 = vec[34]; /* vec[ 6] */ + aux3 += aux1; + vec[34] = vec[10]; + vec[10] = aux4 + aux3; + aux4 = vec[35]; /* vec[ 7] */ + vec[35] = vec[11]; + vec[11] = aux2 + aux3; + + aux3 = vec[39]; + + /* -----------------------------------*/ + aux1 += aux3; + vec[36] = vec[12]; + vec[37] = vec[13]; + vec[12] = aux2 + aux1; + vec[13] = aux4 + aux1; + + aux1 = vec[40]; + aux2 = vec[32]; /* vec[ 8] */ + aux3 += aux1; + vec[32] = vec[14]; + vec[14] = aux4 + aux3; + aux4 = vec[33]; /* vec[ 9] */ + vec[33] = vec[15]; + vec[15] = aux2 + aux3; + + aux3 = vec[41]; + + /* -----------------------------------*/ + aux1 += aux3; + vec[38] = vec[16]; + vec[39] = vec[17]; + vec[16] = aux2 + aux1; + vec[17] = aux4 + aux1; + + aux1 = vec[42]; + aux2 = vec[34]; /* vec[10] */ + aux3 += aux1; + vec[34] = vec[18]; + vec[18] = aux4 + aux3; + aux4 = vec[35]; /* vec[11] */ + vec[35] = vec[19]; + vec[19] = aux2 + aux3; + + aux3 = vec[43]; + + /* -----------------------------------*/ + aux1 += aux3; + vec[40] = vec[20]; + vec[41] = vec[21]; + vec[20] = aux2 + aux1; + vec[21] = aux4 + aux1; + + aux1 = vec[44]; + aux2 = vec[36]; /* vec[12] */ + aux3 += aux1; + vec[42] = vec[22]; + vec[43] = vec[23]; + vec[22] = aux4 + aux3; + vec[23] = aux2 + aux3; + + aux3 = vec[45]; + aux4 = vec[37]; /* vec[13] */ + + /* -----------------------------------*/ + + + scratch_mem[0] = vec[24]; + scratch_mem[1] = vec[25]; + aux1 += aux3; + vec[24] = aux2 + aux1; + vec[25] = aux4 + aux1; + + aux1 = vec[46]; + aux2 = vec[32]; /* vec[14] */ + scratch_mem[2] = vec[26]; + scratch_mem[3] = vec[27]; + aux3 += aux1; + vec[26] = aux4 + aux3; + vec[27] = aux2 + aux3; + + aux3 = vec[47]; + aux4 = vec[33]; /* vec[15] */ + + /* -----------------------------------*/ + scratch_mem[4] = vec[28]; + scratch_mem[5] = vec[29]; + aux1 += aux3; + vec[28] = aux2 + aux1; + vec[29] = aux4 + aux1; + + aux1 = vec[48]; + aux2 = vec[38]; /* vec[16] */ + scratch_mem[6] = vec[30]; + scratch_mem[7] = vec[31]; + aux3 += aux1; + vec[30] = aux4 + aux3; + vec[31] = aux2 + aux3; + + aux3 = vec[49]; + aux4 = vec[39]; /* vec[17] */ + + /* -----------------------------------*/ + aux1 += aux3; + vec[32] = aux2 + aux1; + vec[33] = aux4 + aux1; + + aux1 = vec[50]; + aux2 = vec[34]; /* vec[18] */ + aux3 += aux1; + vec[34] = aux4 + aux3; + aux4 = vec[35]; /* vec[19] */ + vec[35] = aux2 + aux3; + + aux3 = vec[51]; + + + /* -----------------------------------*/ + aux1 += aux3; + vec[36] = aux2 + aux1; + vec[37] = aux4 + aux1; + + aux1 = vec[52]; + aux2 = vec[40]; /* vec[20] */ + aux3 += aux1; + vec[38] = aux4 + aux3; + vec[39] = aux2 + aux3; + + aux3 = vec[53]; + aux4 = vec[41]; /* vec[21] */ + + /* -----------------------------------*/ + aux1 += aux3; + vec[40] = aux2 + aux1; + vec[41] = aux4 + aux1; + + aux1 = vec[54]; + aux2 = vec[42]; /* vec[22] */ + aux3 += aux1; + vec[42] = aux4 + aux3; + aux4 = vec[43]; /* vec[23] */ + vec[43] = aux2 + aux3; + + aux3 = vec[55]; + + /* -----------------------------------*/ + + pt_vec = &vec[44]; + temp_o1 = &vec[56]; + temp_e1 = &scratch_mem[0]; + + for (i = 4; i != 0; i--) + { + aux1 += aux3; + *(pt_vec++) = aux2 + aux1; + *(pt_vec++) = aux4 + aux1; + + aux1 = *(temp_o1++); + aux3 += aux1; + aux2 = *(temp_e1++); + *(pt_vec++) = aux4 + aux3; + *(pt_vec++) = aux2 + aux3; + + aux3 = *(temp_o1++); + aux4 = *(temp_e1++); + } + + aux1 += aux3; + vec[60] = aux2 + aux1; + vec[61] = aux4 + aux1; + vec[62] = aux4 + aux3; + +} + + +#endif + +/*---------------------------------------------------------------------------- +; pv_split +----------------------------------------------------------------------------*/ + + +void pv_split(Int32 *temp_o) +{ + + Int32 i; + const Int32 *pt_cosTerms = &CosTable_48[47]; + Int32 *pt_temp_o = temp_o; + Int32 *pt_temp_e = pt_temp_o - 1; + Int32 tmp1; + Int32 tmp2; + Int32 cosx; + + for (i = 8; i != 0; i--) + { + tmp2 = *(pt_temp_o); + tmp1 = *(pt_temp_e); + cosx = *(pt_cosTerms--); + *(pt_temp_e--) = tmp1 + tmp2; + *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), cosx); + tmp1 = *(pt_temp_e); + tmp2 = *(pt_temp_o); + cosx = *(pt_cosTerms--); + *(pt_temp_e--) = tmp1 + tmp2; + *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), cosx); + } +} + + + +void pv_split_z(Int32 *vector) +{ + Int32 i; + Int32 *pt_vector = &vector[31]; + const Int32 *pt_cosTerms = &CosTable_48[32]; + Int32 *pt_temp_e = vector; + Int32 tmp1; + Int32 tmp2; + Int32 cosx; + + for (i = 8; i != 0; i--) + { + tmp1 = *(pt_vector); + tmp2 = *(pt_temp_e); + cosx = *(pt_cosTerms++); + *(pt_temp_e++) = tmp1 + tmp2; + *(pt_vector--) = fxp_mul32_Q26((tmp1 - tmp2), cosx); + tmp2 = *(pt_temp_e); + tmp1 = *(pt_vector); + cosx = *(pt_cosTerms++); + *(pt_temp_e++) = tmp1 + tmp2; + *(pt_vector--) = fxp_mul32_Q26((tmp1 - tmp2), cosx); + } +} + + +void pv_merge_in_place_N32(Int32 vec[]) +{ + + Int32 temp[4]; + + temp[0] = vec[14]; + vec[14] = vec[ 7]; + temp[1] = vec[12]; + vec[12] = vec[ 6]; + temp[2] = vec[10]; + vec[10] = vec[ 5]; + temp[3] = vec[ 8]; + vec[ 8] = vec[ 4]; + vec[ 6] = vec[ 3]; + vec[ 4] = vec[ 2]; + vec[ 2] = vec[ 1]; + + vec[ 1] = vec[16] + vec[17]; + vec[16] = temp[3]; + vec[ 3] = vec[18] + vec[17]; + vec[ 5] = vec[19] + vec[18]; + vec[18] = vec[9]; + temp[3] = vec[11]; + + vec[ 7] = vec[20] + vec[19]; + vec[ 9] = vec[21] + vec[20]; + vec[20] = temp[2]; + temp[2] = vec[13]; + vec[11] = vec[22] + vec[21]; + vec[13] = vec[23] + vec[22]; + vec[22] = temp[3]; + temp[3] = vec[15]; + vec[15] = vec[24] + vec[23]; + vec[17] = vec[25] + vec[24]; + vec[19] = vec[26] + vec[25]; + vec[21] = vec[27] + vec[26]; + vec[23] = vec[28] + vec[27]; + vec[25] = vec[29] + vec[28]; + vec[27] = vec[30] + vec[29]; + vec[29] = vec[30] + vec[31]; + vec[24] = temp[1]; + vec[26] = temp[2]; + vec[28] = temp[0]; + vec[30] = temp[3]; +} + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct64.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct64.h new file mode 100644 index 0000000..73710fe --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dct64.h @@ -0,0 +1,76 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dct64.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef DCT64_H +#define DCT64_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + extern const Int32 CosTable_48[48]; + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void pv_split_LC(Int32 *vector, + Int32 *temp_o); + + +#ifdef HQ_SBR + + void dct_64(Int32 vec[], Int32 *scratch_mem); + +#endif + + void pv_split(Int32 *temp_o); + + void pv_split_z(Int32 *vector); + + void pv_merge_in_place_N32(Int32 vec[]); + +#ifdef __cplusplus +} +#endif + +#endif /* DCT64_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decode_huff_cw_binary.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decode_huff_cw_binary.cpp new file mode 100644 index 0000000..79859b0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decode_huff_cw_binary.cpp @@ -0,0 +1,673 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: decode_huff_cw_binary.cpp + Funtions: + decode_huff_cw_tab1 + decode_huff_cw_tab2 + decode_huff_cw_tab3 + decode_huff_cw_tab4 + decode_huff_cw_tab5 + decode_huff_cw_tab6 + decode_huff_cw_tab7 + decode_huff_cw_tab8 + decode_huff_cw_tab9 + decode_huff_cw_tab10 + decode_huff_cw_tab11 + decode_huff_cw_scl + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + BITS *pInputStream = pointer to input bit stream + + Local Stores/Buffers/Pointers Needed: + + + Global Stores/Buffers/Pointers Needed: + + + Outputs: + idx = bit field extracted from a leaf entry of packed Huffman Tables + + Pointers and Buffers Modified: + + Local Stores Modified: + + Global Stores Modified: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + These functions are used to decode huffman codewords from the input + bitstream using combined binary search and look-up table approach. + + First the codewords are grouped and the input symbol is determined + which group it belongs. Then within that group, a look-up table is + used to determine which codeword the symbol is. + The table is created by ordering the codeword in the table according to their + normalized shifted binary value, i.e., all the codewords are left + shifted to meet the maximum codelength. Example, max codelength is + 10, the codeword with lenth 3 will left shift by 7. + The binary values of after the shift are sorted. + Then the sorted table is divided into several partition. + At the VLC decoding period, input is read in at max codelenght. + The partition is decided using if-else logic. + Inside each partition, a look-up table is used to map the input value + to a correct symbol. Table entries can appear to be repeated according + to the humming distance between adjacent codewords. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) Introduction to Algorithms, + Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest. + The MIT press, 1990 + + (3) "Selecting an Optimal Huffman Decoder for AAC", + Vladimir Z. Mesarovic, et al. + AES 111th Convention, September 21-24, 2001, New York, USA + +------------------------------------------------------------------------------ + PSEUDO-CODE + + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define MAX_CW_LEN (19) +#define MASK_IDX (0x1FF) +#define MASK_RIGHT (0xFE00) + +#define UPPER16 (16) +#define MASK_LOW16 (0xFFFF) +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int decode_huff_cw_tab1( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 11, + pInputStream); + if ((cw >> 10) == 0) + { + pInputStream->usedBits -= (11 - 1); + return 40; /* idx is 40 */ + } + else if ((cw >> 6) <= 23) + { + tab = (cw >> 6) - 16; + } + else if ((cw >> 4) <= 119) + { + tab = (cw >> 4) - 96 + 8; + } + else if ((cw >> 2) <= 503) + { + tab = (cw >> 2) - 480 + 32; + } + else + { + tab = cw - 2016 + 56; + } + + tab = *(huff_tab1 + tab); + + pInputStream->usedBits -= (11 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab2( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get9_n_lessbits( + 9, + pInputStream); + if ((cw >> 6) == 0) + { + pInputStream->usedBits -= (9 - 3); /* used 3 bits */ + return 40; /* idx is 40 */ + } + else if ((cw >> 3) <= 49) + { + tab = (cw >> 3) - 8; + } + else if ((cw >> 2) <= 114) + { + tab = (cw >> 2) - 100 + 42; + } + else if ((cw >> 1) <= 248) + { + tab = (cw >> 1) - 230 + 57; + } + else + { + tab = cw - 498 + 76; + } + + tab = *(huff_tab2 + tab); + + pInputStream->usedBits -= (9 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab3( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 16, + pInputStream); + if ((cw >> 15) == 0) + { + pInputStream->usedBits -= (16 - 1); /* used 1 bits */ + return 0; /* idx is 0 */ + } + else if ((cw >> 10) <= 57) + { + tab = (cw >> 10) - 32; + } + else if ((cw >> 7) <= 500) + { + tab = (cw >> 7) - 464 + 26; + } + else if ((cw >> 6) <= 1016) + { + tab = (cw >> 6) - 1002 + 63; + } + else if ((cw >> 4) <= 4092) + { + tab = (cw >> 4) - 4068 + 78; + } + else + { + tab = cw - 65488 + 103; + } + + tab = *(huff_tab3 + tab); + + pInputStream->usedBits -= (16 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab4( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 12, + pInputStream); + + if ((cw >> 7) <= 25) + { + tab = (cw >> 7); + } + else if ((cw >> 4) <= 246) + { + tab = (cw >> 4) - 208 + 26; + } + else if ((cw >> 2) <= 1017) + { + tab = (cw >> 2) - 988 + 65; + } + else + { + tab = cw - 4072 + 95; + } + + tab = *(huff_tab4 + tab); + + pInputStream->usedBits -= (12 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + + +Int decode_huff_cw_tab5( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 13, + pInputStream); + + if ((cw >> 12) == 0) + { + pInputStream->usedBits -= (13 - 1); /* used 1 bits */ + return 40; /* idx is 40 */ + } + else if ((cw >> 8) <= 27) + { + tab = (cw >> 8) - 16; + } + else if ((cw >> 5) <= 243) + { + tab = (cw >> 5) - 224 + 12; + } + else if ((cw >> 3) <= 1011) + { + tab = (cw >> 3) - 976 + 32; + } + else if ((cw >> 2) <= 2041) + { + tab = (cw >> 2) - 2024 + 68; + } + else + { + tab = cw - 8168 + 86; + } + + tab = *(huff_tab5 + tab); + + pInputStream->usedBits -= (13 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + + +Int decode_huff_cw_tab6( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 11, + pInputStream); + + if ((cw >> 7) <= 8) + { + tab = (cw >> 7); + } + else if ((cw >> 4) <= 116) + { + tab = (cw >> 4) - 72 + 9; + } + else if ((cw >> 2) <= 506) + { + tab = (cw >> 2) - 468 + 54; + } + else + { + tab = cw - 2028 + 93; + } + + tab = *(huff_tab6 + tab); + + pInputStream->usedBits -= (11 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + + +Int decode_huff_cw_tab7( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 12, + pInputStream); + + if ((cw >> 11) == 0) + { + pInputStream->usedBits -= (12 - 1); /* used 1 bits */ + return 0; /* idx is 0 */ + } + else if ((cw >> 6) <= 55) + { + tab = (cw >> 6) - 32; + } + else if ((cw >> 4) <= 243) + { + tab = (cw >> 4) - 224 + 24; + } + else if ((cw >> 2) <= 1018) + { + tab = (cw >> 2) - 976 + 44; + } + else + { + tab = cw - 4076 + 87; + } + + tab = *(huff_tab7 + tab); + + pInputStream->usedBits -= (12 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + + +Int decode_huff_cw_tab8( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 10, + pInputStream); + + if ((cw >> 5) <= 20) + { + tab = (cw >> 5); + } + else if ((cw >> 3) <= 117) + { + tab = (cw >> 3) - 84 + 21; + } + else if ((cw >> 2) <= 250) + { + tab = (cw >> 2) - 236 + 55; + } + else + { + tab = cw - 1004 + 70; + } + + tab = *(huff_tab8 + tab); + + pInputStream->usedBits -= (10 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab9( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 15, + pInputStream); + + if ((cw >> 11) <= 12) + { + tab = (cw >> 11); + } + else if ((cw >> 8) <= 114) + { + tab = (cw >> 8) - 104 + 13; + } + else if ((cw >> 6) <= 486) + { + tab = (cw >> 6) - 460 + 24; + } + else if ((cw >> 5) <= 993) + { + tab = (cw >> 5) - 974 + 51; + } + else if ((cw >> 4) <= 2018) + { + tab = (cw >> 4) - 1988 + 71; + } + else if ((cw >> 3) <= 4075) + { + tab = (cw >> 3) - 4038 + 102; + } + else if ((cw >> 2) <= 8183) + { + tab = (cw >> 2) - 8152 + 140; + } + else + { + tab = cw - 32736 + 172; + } + + tab = *(huff_tab9 + tab); + + pInputStream->usedBits -= (15 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab10( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 12, + pInputStream); + + if ((cw >> 6) <= 41) + { + tab = (cw >> 6); + } + else if ((cw >> 5) <= 100) + { + tab = (cw >> 5) - 84 + 42; + } + else if ((cw >> 4) <= 226) + { + tab = (cw >> 4) - 202 + 59; + } + else if ((cw >> 3) <= 484) + { + tab = (cw >> 3) - 454 + 84; + } + else if ((cw >> 2) <= 1010) + { + tab = (cw >> 2) - 970 + 115; + } + else if ((cw >> 1) <= 2043) + { + tab = (cw >> 1) - 2022 + 156; + } + else + { + tab = cw - 4088 + 178; + } + + tab = *(huff_tab10 + tab); + + pInputStream->usedBits -= (12 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab11( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 12, + pInputStream); + + if ((cw >> 6) <= 26) + { + tab = (cw >> 6); + } + else if ((cw >> 5) <= 69) + { + tab = (cw >> 5) - 54 + 27; + } + else if ((cw >> 4) <= 198) + { + tab = (cw >> 4) - 140 + 43; + } + else if ((cw >> 3) <= 452) + { + tab = (cw >> 3) - 398 + 102; + } + else if ((cw >> 2) <= 1000) + { + tab = (cw >> 2) - 906 + 157; + } + else if ((cw >> 1) <= 2044) + { + tab = (cw >> 1) - 2002 + 252; + } + else + { + tab = cw - 4090 + 295; + } + + tab = *(huff_tab11 + tab); + + pInputStream->usedBits -= (12 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_scl( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = getbits( + 19, + pInputStream); + + if ((cw >> 18) == 0) + { + pInputStream->usedBits -= (19 - 1); /* used 1 bits */ + return 60; /* idx is 60 */ + } + else if ((cw >> 13) <= 59) + { + tab = (cw >> 13) - 32; + } + else if ((cw >> 10) <= 505) + { + tab = (cw >> 10) - 480 + 28; + } + else if ((cw >> 7) <= 4089) + { + tab = (cw >> 7) - 4048 + 54; + } + else if ((cw >> 5) <= 16377) + { + tab = (cw >> 5) - 16360 + 96; + } + else if ((cw >> 3) <= 65526) + { + tab = (cw >> 3) - 65512 + 114; + } + else if ((cw >> 1) <= 262120) + { + tab = (cw >> 1) - 262108 + 129; + } + else + { + tab = cw - 524242 + 142; + } + + tab = *(huff_tab_scl + tab); + + pInputStream->usedBits -= (19 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.cpp new file mode 100644 index 0000000..69898b1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.cpp @@ -0,0 +1,156 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: decode_noise_floorlevels.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +#ifdef AAC_PLUS + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "decode_noise_floorlevels.h" +#include "sbr_constants.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void decode_noise_floorlevels(SBR_FRAME_DATA * hFrameData) + +{ + Int32 env; + Int32 i; + + Int32 * frameInfo = hFrameData->frameInfo; + Int32 nNfb = hFrameData->nNfb; + Int32 * domain_vec = hFrameData->domain_vec2; + + Int32 * sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man; + Int32 * prevNoiseLevel_man = hFrameData->prevNoiseLevel_man; + + Int32 nEnv = frameInfo[(frameInfo[0] << 1) + 3]; + + for (env = 0; env < nEnv; env++) + { + if (domain_vec[env] == 0) + { + prevNoiseLevel_man[0] = *(sbrNoiseFloorLevel_man++); + + for (i = 1; i < nNfb; i++) + { + *sbrNoiseFloorLevel_man += *(sbrNoiseFloorLevel_man - 1); + prevNoiseLevel_man[i] = *(sbrNoiseFloorLevel_man++); + } + } + else + { + for (i = 0; i < nNfb; i++) + { + *sbrNoiseFloorLevel_man += prevNoiseLevel_man[i]; + prevNoiseLevel_man[i] = *(sbrNoiseFloorLevel_man++); + } + } + + } +} + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.h new file mode 100644 index 0000000..05a1c57 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: decode_noise_floorlevels.h + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef DECODENOISEFLOORLEVELS_H +#define DECODENOISEFLOORLEVELS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void decode_noise_floorlevels(SBR_FRAME_DATA * hFrameData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decoder_aac.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decoder_aac.cpp new file mode 100644 index 0000000..2663e98 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/decoder_aac.cpp @@ -0,0 +1,496 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +////////////////////////////////////////////////////////////////////////////////// +// // +// File: decoder_aac.cpp // +// // +////////////////////////////////////////////////////////////////////////////////// + + +#include "decoder_aac.h" +#include "oscl_error_codes.h" +#include "oscl_exception.h" + +#include "e_tmp4audioobjecttype.h" + +// Use default DLL entry point +#include "oscl_dll.h" +OSCL_DLL_ENTRY_POINT_DEFAULT() + + +OSCL_EXPORT_REF CDecoder_AAC *CDecoder_AAC::NewL() +{ + CDecoder_AAC *dec = new CDecoder_AAC; + + if (dec == NULL) + { + OSCL_LEAVE(OsclErrNoMemory); + } + else + { + dec->ConstructL(); + } + + return dec; +} + + +OSCL_EXPORT_REF void CDecoder_AAC::ConstructL() +{ + // Initialize member variables + iFirstFrame = true; + iNumSamplesPerFrame = KAAC_NUM_SAMPLES_PER_FRAME; + pMem = NULL; + iAllocateInputBuffer = true; + iAllocateOutputBuffer = true; + iInputBuf = NULL; + iOutputBuf = NULL; +} + + +/* +----------------------------------------------------------------------------- + + CDecoder_AAC + + ~CDecoder_AAC + + Empty decoder destructor. + + Parameters: none + + Return Values: none + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF CDecoder_AAC::~CDecoder_AAC() +{ + if (pMem != NULL) + { + OSCL_ARRAY_DELETE(pMem); + pMem = NULL; + } + + if (iAllocateInputBuffer && iInputBuf) + { + OSCL_ARRAY_DELETE(iInputBuf); + iInputBuf = NULL; + } + + if (iAllocateOutputBuffer && iOutputBuf) + { + OSCL_ARRAY_DELETE(iOutputBuf); + iOutputBuf = NULL; + } +} + + +/* +----------------------------------------------------------------------------- + + CDecoder_AAC + + StartL + + Start decoder object. Initialize codec status. + + Parameters: none + + Return Values: status + +----------------------------------------------------------------------------- +*/ + +OSCL_EXPORT_REF int32 CDecoder_AAC::StartL(tPVMP4AudioDecoderExternal * pExt, + uint8 num_channels, + bool aAllocateInputBuffer, + bool aAllocateOutputBuffer, + Int upsamplingFactor, + Int samp_rate, + tMP4AudioObjectType audioObjectType) +{ + iFirstFrame = true; + + iAllocateInputBuffer = aAllocateInputBuffer; + iAllocateOutputBuffer = aAllocateOutputBuffer; + + if (iAllocateInputBuffer) + { + iInputBuf = OSCL_ARRAY_NEW(uint8, KAAC_MAX_STREAMING_BUFFER_SIZE); + if (iInputBuf == NULL) + { + return KCAI_CODEC_INIT_FAILURE; + } + pExt->pInputBuffer = iInputBuf; + pExt->inputBufferMaxLength = KAAC_MAX_STREAMING_BUFFER_SIZE; + } + else + { + pExt->pInputBuffer = NULL; + pExt->inputBufferMaxLength = 0; + } + + if (iAllocateOutputBuffer) + { +#ifdef AAC_PLUS + iOutputBuf = OSCL_ARRAY_NEW(int16, 4096); +#else + iOutputBuf = OSCL_ARRAY_NEW(int16, 2048); +#endif + + if (iOutputBuf == NULL) + { + return KCAI_CODEC_INIT_FAILURE; + } + + pExt->pOutputBuffer = iOutputBuf; +#ifdef AAC_PLUS + pExt->pOutputBuffer_plus = &iOutputBuf[2048]; +#else + pExt->pOutputBuffer_plus = NULL; +#endif + } + else + { + pExt->pOutputBuffer = NULL; + pExt->pOutputBuffer_plus = NULL; + } + + pExt->desiredChannels = num_channels; + pExt->inputBufferCurrentLength = 0; + pExt->outputFormat = OUTPUTFORMAT_16PCM_INTERLEAVED; + pExt->repositionFlag = TRUE; + pExt->inputBufferUsedLength = 0; + pExt->remainderBits = 0; + + int32 memreq = PVMP4AudioDecoderGetMemRequirements(); + + pMem = OSCL_ARRAY_NEW(uint8 , memreq); + + if (pMem == 0) + { + return KCAI_CODEC_NO_MEMORY; + } + + if (PVMP4AudioDecoderInitLibrary(pExt, pMem) != 0) + { + return(KCAI_CODEC_INIT_FAILURE); + } + + + if (PVMP4SetAudioConfig(pExt, + pMem, + upsamplingFactor, + samp_rate, + num_channels, + audioObjectType) != SUCCESS) + { + return KCAI_CODEC_INIT_FAILURE; + } + + iNumSamplesPerFrame = KAAC_NUM_SAMPLES_PER_FRAME; + + pExt->desiredChannels = pExt->encodedChannels; + + iFirstFrame = false; + + return SUCCESS; +} + + +/* +----------------------------------------------------------------------------- + + CDecoder_AAC + + StartL + + Start decoder object. Initialize codec status. + + Parameters: none + + Return Values: status + +----------------------------------------------------------------------------- +*/ + + + + +OSCL_EXPORT_REF int32 CDecoder_AAC::StartL(tPVMP4AudioDecoderExternal * pExt, + uint8 num_channels, + bool aAllocateInputBuffer, + bool aAllocateOutputBuffer, + bool aAacplusEnabler) +{ + iFirstFrame = true; + + iAllocateInputBuffer = aAllocateInputBuffer; + iAllocateOutputBuffer = aAllocateOutputBuffer; + + if (iAllocateInputBuffer) + { + iInputBuf = OSCL_ARRAY_NEW(uint8, KAAC_MAX_STREAMING_BUFFER_SIZE); + if (iInputBuf == NULL) + { + return KCAI_CODEC_INIT_FAILURE; + } + pExt->pInputBuffer = iInputBuf; + pExt->inputBufferMaxLength = KAAC_MAX_STREAMING_BUFFER_SIZE; + } + else + { + pExt->pInputBuffer = NULL; + pExt->inputBufferMaxLength = 0; + } + + if (iAllocateOutputBuffer) + { +#ifdef AAC_PLUS + iOutputBuf = OSCL_ARRAY_NEW(int16, 4096); +#else + iOutputBuf = OSCL_ARRAY_NEW(int16, 2048); +#endif + + if (iOutputBuf == NULL) + { + return KCAI_CODEC_INIT_FAILURE; + } + + pExt->pOutputBuffer = iOutputBuf; +#ifdef AAC_PLUS + pExt->pOutputBuffer_plus = &iOutputBuf[2048]; +#else + pExt->pOutputBuffer_plus = NULL; +#endif + } + else + { + pExt->pOutputBuffer = NULL; + pExt->pOutputBuffer_plus = NULL; + } + + pExt->desiredChannels = num_channels; + pExt->inputBufferCurrentLength = 0; + pExt->outputFormat = OUTPUTFORMAT_16PCM_INTERLEAVED; + pExt->repositionFlag = TRUE; + pExt->aacPlusEnabled = aAacplusEnabler; /* Dynamically enable AAC+ decoding */ + pExt->inputBufferUsedLength = 0; + pExt->remainderBits = 0; + + int32 memreq = PVMP4AudioDecoderGetMemRequirements(); + + pMem = OSCL_ARRAY_NEW(uint8 , memreq); + + if (pMem == 0) + { + return KCAI_CODEC_NO_MEMORY; + } + + return SUCCESS; +} + + +/* +----------------------------------------------------------------------------- + + CDecoder_AAC + + ExecuteL + + Execute decoder object. Read one encoded aac frame from the input + stream, decode it and write the decoded frame to output stream. + + Parameters: + + Return Values: status + + +----------------------------------------------------------------------------- +*/ + +OSCL_EXPORT_REF int32 CDecoder_AAC::ExecuteL(tPVMP4AudioDecoderExternal * pExt) +{ + int32 nResult = FALSE; + + if (iFirstFrame == false) + { + nResult = PVMP4AudioDecodeFrame(pExt, pMem); + } + else + { + if (PVMP4AudioDecoderInitLibrary(pExt, pMem) != 0) + { + return(KCAI_CODEC_INIT_FAILURE); + } + // set samples/frame to default value (right now this is the only one supported) + + if (PVMP4AudioDecoderConfig(pExt, pMem) != SUCCESS) + { + nResult = PVMP4AudioDecodeFrame(pExt, pMem); /* could be ADIF type */ + } + + iNumSamplesPerFrame = KAAC_NUM_SAMPLES_PER_FRAME; + + pExt->desiredChannels = pExt->encodedChannels; + + iFirstFrame = false; + } + + return nResult; +} + +/* +----------------------------------------------------------------------------- + + CDecoder_AAC + + StopL + + Stop decoder object. Flush out last frame + + Parameters: none + + Return Values: none + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF void CDecoder_AAC::StopL() +{ + PVMP4AudioDecoderResetBuffer(pMem); +} + +/* +----------------------------------------------------------------------------- + + CDecoder_AAC + + ResetDecoderL + + Stop decoder object. Reset decoder. + + Parameters: none + + Return Values: status + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF void CDecoder_AAC::ResetDecoderL() +{ + PVMP4AudioDecoderResetBuffer(pMem); +} + + +/* +----------------------------------------------------------------------------- + + CDecoder_AAC + + TerminateDecoderL + + Stop decoder object. close decoder. + + Parameters: none + + Return Values: none + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF void CDecoder_AAC::TerminateDecoderL() +{ + if (pMem != NULL) + { + OSCL_ARRAY_DELETE(pMem); + pMem = NULL; + } + + if (iAllocateInputBuffer && iInputBuf) + { + OSCL_ARRAY_DELETE(iInputBuf); + iInputBuf = NULL; + } + + if (iAllocateOutputBuffer && iOutputBuf) + { + OSCL_ARRAY_DELETE(iOutputBuf); + iOutputBuf = NULL; + } +} + + + +/* +----------------------------------------------------------------------------- + + CDecoder_AAC + + RetrieveDecodedStreamTypeL + + Utility to extract the decoding aac stream type being decoded. + + Parameters: none + + Return Values: status + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF int32 CDecoder_AAC::RetrieveDecodedStreamTypeL(tPVMP4AudioDecoderExternal * pExt) +{ + + if ((pExt->extendedAudioObjectType == MP4AUDIO_AAC_LC) || + (pExt->extendedAudioObjectType == MP4AUDIO_LTP)) + { + return AAC; /* AAC */ + } + else if (pExt->extendedAudioObjectType == MP4AUDIO_SBR) + { + return AACPLUS; /* AAC+ */ + } + else if (pExt->extendedAudioObjectType == MP4AUDIO_PS) + { + return ENH_AACPLUS; /* AAC++ */ + } + + return -1; /* Error evaluating the stream type */ +} + + + +/* +----------------------------------------------------------------------------- + + CDecoder_AAC + + DisableSbrDecodingL + + Disable aac+/eaac+ decoding. + + Parameters: none + + Return Values: none + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF void CDecoder_AAC::DisableSbrDecodingL(tPVMP4AudioDecoderExternal * pExt) +{ + PVMP4AudioDecoderDisableAacPlus(pExt, pMem); +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/deinterleave.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/deinterleave.cpp new file mode 100644 index 0000000..7e7bcca --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/deinterleave.cpp @@ -0,0 +1,250 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: deinterleave.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + interleaved = input array that contains interleaved coefficients + Data Type Int + + deinterleaved = output array that will be updated with de-interleaved + coefficients of input array. Data Type Int + + pFrameInfo = pointer to structure that holds information of current + frame. Data Type FrameInfo + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + deinterleaved contents updated with de-interleaved coefficients from + the input array: interleaved + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function performs the deinterleaving across all short windows in + each group + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should replace the contents of pDeinterleaved with the + de-interleaved 1024 coefficients of one frame + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p78 quant_to_spec + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pInterleaved = interleaved; + pDeinterleaved = deinterleaved; + + pSfbPerWin = pFrameInfo->sfb_per_win; + ngroups = pFrameInfo->num_groups; + pGroupLen = pFrameInfo->group_len; + + pGroup = pDeinterleaved; + + FOR (group = ngroups; group > 0; group--) + + pSfbWidth = pFrameInfo->sfb_width_128; + sfb_inc = 0; + pStart = pInterleaved; + + FOR (sfb = pSfbPerWin[ngroups-group]; sfb > 0; sfb--) + + pWin = pGroup; + + FOR (win = pGroupLen[ngroups-group]; win > 0; win--) + + pDeinterleaved = pWin + sfb_inc; + + pv_memcpy( + pDeinterleaved, + pInterleaved, + *pSfbWidth*sizeof(*pInterleaved)); + + pInterleaved += *pSfbWidth; + + pWin += SN2; + + ENDFOR (win) + + sfb_inc += *pSfbWidth++; + + ENDFOR (sfb) + + pGroup += (pInterleaved - pStart); + + ENDFOR (group) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void deinterleave( + Int16 interleaved[], + Int16 deinterleaved[], + FrameInfo *pFrameInfo) +{ + + Int group; /* group index */ + Int sfb; /* scalefactor band index */ + Int win; /* window index */ + Int16 *pGroup; + Int16 *pWin; + Int16 *pStart; + Int16 *pInterleaved; + Int16 *pDeinterleaved; + Int sfb_inc; + + Int ngroups; + Int *pGroupLen; + Int *pSfbPerWin; + Int *pSfbWidth; + + pInterleaved = interleaved; + pDeinterleaved = deinterleaved; + + pSfbPerWin = pFrameInfo->sfb_per_win; + ngroups = pFrameInfo->num_groups; + pGroupLen = pFrameInfo->group_len; + + pGroup = pDeinterleaved; + + for (group = ngroups; group > 0; group--) + { + pSfbWidth = pFrameInfo->sfb_width_128; + sfb_inc = 0; + pStart = pInterleaved; + + /* Perform the deinterleaving across all windows in a group */ + + for (sfb = pSfbPerWin[ngroups-group]; sfb > 0; sfb--) + { + pWin = pGroup; + + for (win = pGroupLen[ngroups-group]; win > 0; win--) + { + pDeinterleaved = pWin + sfb_inc; + + pv_memcpy( + pDeinterleaved, + pInterleaved, + *pSfbWidth*sizeof(*pInterleaved)); + + pInterleaved += *pSfbWidth; + + pWin += SN2; + + } /* for (win) */ + + sfb_inc += *pSfbWidth++; + + } /* for (sfb) */ + + pGroup += (pInterleaved - pStart); + + } /* for (group) */ + +} /* deinterleave */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/digit_reversal_tables.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/digit_reversal_tables.cpp new file mode 100644 index 0000000..bd80d96 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/digit_reversal_tables.cpp @@ -0,0 +1,273 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: digit_reversal_tables.cpp + Funtions: + +------------------------------------------------------------------------------ + MODULE DESCRIPTION + + Tables for digit reverse operation + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "digit_reversal_tables.h" +#include "imdct_fxp.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/* +------------------------------------------------------------------------------ + Digit Reverse tables +------------------------------------------------------------------------------ +*/ + +const Int16 digit_reverse_64[ 64] = +{ + + 0, + 32, + 64, + 96, + + 8, + 40, + 72, + 104, + + 16, + 48, + 80, + 112, + + 24, + 56, + 88, + 120, + + 2, + 34, + 66, + 98, + + 10, + 42, + 74, + 106, + + 18, + 50, + 82, + 114, + + 26, + 58, + 90, + 122, + + 4, + 36, + 68, + 100, + + 12, + 44, + 76, + 108, + + 20, + 52, + 84, + 116, + + 28, + 60, + 92, + 124, + + 6, + 38, + 70, + 102, + + 14, + 46, + 78, + 110, + + 22, + 54, + 86, + 118, + + 30, + 62, + 94, + 126 +}; + + +const Int16 digit_reverse_256[ 256] = +{ + + 0, + 128, + 256, + 384, + + 32, + 160, + 288, + 416, + + 64, + 192, + 320, + 448, + + 96, + 224, + 352, + 480, + + 8, + 136, + 264, + 392, + + 40, + 168, + 296, + 424, + + 72, + 200, + 328, + 456, + + 104, + 232, + 360, + 488, + + 16, + 144, + 272, + 400, + + 48, + 176, + 304, + 432, + + 80, + 208, + 336, + 464, + + 112, + 240, + 368, + 496, + + 24, + 152, + 280, + 408, + + 56, + 184, + 312, + 440, + + 88, + 216, + 344, + 472, + + 120, + 248, + 376, + 504, + + 2, + 130, + 258, + 386, + + 34, + 162, + 290, + 418, + + 66, + 194, + 322, + 450, + + 98, + 226, + 354, + 482, + + 10, + 138, + 266, + 394, + + 42, + 170, + 298, + 426, + + 74, + 202, + 330, + 458, + + 106, + 234, + 362, + 490, + + 18, + 146, + 274, + 402, + + 50, + 178, + 306, + 434, + + 82, + 210, + 338, + 466, + + 114, + 242, + 370, + 498, + + 26, + 154, + 282, + 410, + + 58, + 186, + 314, + 442, + + 90, + 218, + 346, + 474, + + 122, + 250, + 378, + 506, + + 4, + 132, + 260, + 388, + + 36, + 164, + 292, + 420, + + 68, + 196, + 324, + 452, + + 100, + 228, + 356, + 484, + + 12, + 140, + 268, + 396, + + 44, + 172, + 300, + 428, + + 76, + 204, + 332, + 460, + + 108, + 236, + 364, + 492, + + 20, + 148, + 276, + 404, + + 52, + 180, + 308, + 436, + + 84, + 212, + 340, + 468, + + 116, + 244, + 372, + 500, + + 28, + 156, + 284, + 412, + + 60, + 188, + 316, + 444, + + 92, + 220, + 348, + 476, + + 124, + 252, + 380, + 508, + + 6, + 134, + 262, + 390, + + 38, + 166, + 294, + 422, + + 70, + 198, + 326, + 454, + + 102, + 230, + 358, + 486, + + 14, + 142, + 270, + 398, + + 46, + 174, + 302, + 430, + + 78, + 206, + 334, + 462, + + 110, + 238, + 366, + 494, + + 22, + 150, + 278, + 406, + + 54, + 182, + 310, + 438, + + 86, + 214, + 342, + 470, + + 118, + 246, + 374, + 502, + + 30, + 158, + 286, + 414, + + 62, + 190, + 318, + 446, + + 94, + 222, + 350, + 478, + + 126, + 254, + 382, + 510 +}; + + + + +const Int16 digit_reverse_swap_256[ 241] = +{ + + 2, + 128, + 4, + 256, + + 6, + 384, + 8, + 32, + + 10, + 160, + 12, + 288, + + 14, + 416, + 16, + 64, + + 18, + 192, + 20, + 320, + + 22, + 448, + 24, + 96, + + 26, + 224, + 28, + 352, + + 30, + 480, + 34, + 136, + + 36, + 264, + 38, + 392, + + 42, + 168, + 44, + 296, + + 46, + 424, + 48, + 72, + + 50, + 200, + 52, + 328, + + 54, + 456, + 56, + 104, + + 58, + 232, + 60, + 360, + + 62, + 488, + 66, + 144, + + 68, + 272, + 70, + 400, + + 74, + 176, + 76, + 304, + + 78, + 432, + 82, + 208, + + 84, + 336, + 86, + 464, + + 88, + 112, + 90, + 240, + + 92, + 368, + 94, + 496, + + 98, + 152, + 100, + 280, + + 102, + 408, + 106, + 184, + + 108, + 312, + 110, + 440, + + 114, + 216, + 116, + 344, + + 118, + 472, + 122, + 248, + + 124, + 376, + 126, + 504, + + 132, + 258, + 134, + 386, + + 138, + 162, + 140, + 290, + + 142, + 418, + 146, + 194, + + 148, + 322, + 150, + 450, + + 154, + 226, + 156, + 354, + + 158, + 482, + 164, + 266, + + 166, + 394, + 172, + 298, + + 174, + 426, + 178, + 202, + + 180, + 330, + 182, + 458, + + 186, + 234, + 188, + 362, + + 190, + 490, + 196, + 274, + + 198, + 402, + 204, + 306, + + 206, + 434, + 212, + 338, + + 214, + 466, + 218, + 242, + + 220, + 370, + 222, + 498, + + 228, + 282, + 230, + 410, + + 236, + 314, + 238, + 442, + + 244, + 346, + 246, + 474, + + 252, + 378, + 254, + 506, + + 262, + 388, + 268, + 292, + + 270, + 420, + 276, + 324, + + 278, + 452, + 284, + 356, + + 286, + 484, + 294, + 396, + + 302, + 428, + 308, + 332, + + 310, + 460, + 316, + 364, + + 318, + 492, + 326, + 404, + + 334, + 436, + 342, + 468, + + 348, + 372, + 350, + 500, + + 358, + 412, + 366, + 444, + + 374, + 476, + 382, + 508, + + 398, + 422, + 406, + 454, + + 414, + 486, + 438, + 462, + + 446, + 494, + 478, + 502 +}; + + +#ifdef __cplusplus +extern "C" +{ +#endif + + void digit_reversal_swapping(Int32 *y, Int32 *x); + +#ifdef __cplusplus +} +#endif + +void digit_reversal_swapping(Int32 *y, Int32 *x) +{ + Int16 i, j; + Int32 tmp[2]; + const Int16 *pTable; + + pTable = digit_reverse_swap_256; + + for (Int k = 120; k != 0; k--) + { + i = *pTable++; + j = *pTable++; + tmp[0] = y[i]; + tmp[1] = y[i+1]; + y[i] = y[j]; + y[i+1] = y[j+1]; + y[j] = tmp[0]; + y[j+1] = tmp[1]; + + tmp[0] = x[j]; + tmp[1] = x[j+1]; + x[j] = x[i]; + x[j+1] = x[i+1]; + x[i] = tmp[0]; + x[i+1] = tmp[1]; + + } + +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/digit_reversal_tables.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/digit_reversal_tables.h new file mode 100644 index 0000000..6526531 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/digit_reversal_tables.h @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: digit_reversal_tables.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions digit_reversal_tables + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef DIGIT_REVERSAL_TABLES_H +#define DIGIT_REVERSAL_TABLES_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const Int16 digit_reverse_64[]; +extern const Int16 digit_reverse_256[]; + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* DIGIT_REVERSAL_TABLES_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst16.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst16.cpp new file mode 100644 index 0000000..16e4fe1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst16.cpp @@ -0,0 +1,165 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst16.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 16 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement discrete sine transform of lenght 16 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#include "dst16.h" +#include "dst8.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +#define R_SHIFT 28 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +const Int32 CosTable_8[8] = +{ + Qfmt(0.50241928618816F), Qfmt(0.52249861493969F), + Qfmt(0.56694403481636F), Qfmt(0.64682178335999F), + Qfmt(0.78815462345125F), Qfmt(1.06067768599035F), + Qfmt(1.72244709823833F), Qfmt(5.10114861868916F) +}; + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void dst_16(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 8 */ +{ + Int32 *temp_even = scratch_mem; + + Int i; + const Int32 *pt_cos = &CosTable_8[7]; + Int32 tmp0 = vec[15] >> 1; + Int32 tmp1, tmp2; + Int32 *pt_even = temp_even; + Int32 *pt_odd = vec; + Int32 *pt_vec = vec; + Int32 *pt_vecN_1; + Int32 tmp3; + + + *(pt_even++) = *(pt_vec++); + tmp1 = *(pt_vec++); + *(pt_odd++) = tmp1; + + for (i = 3; i != 0; i--) + { + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + tmp3 = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + *(pt_odd++) = tmp3 + tmp2; + tmp1 = tmp3; + + } + + *(pt_even) = *(pt_vec++); + *(pt_odd++) = *(pt_vec) + tmp1; + + + dst_8(temp_even); + dst_8(vec); + + pt_vec = &vec[7]; + + pt_even = &temp_even[7]; + pt_vecN_1 = &vec[8]; + + tmp1 = *(pt_even--); + + for (i = 4; i != 0; i--) + { + tmp3 = fxp_mul32_Q28((*(pt_vec) - tmp0), *(pt_cos--)); + tmp2 = *(pt_even--); + *(pt_vec--) = tmp3 + tmp1; + *(pt_vecN_1++) = tmp3 - tmp1; + tmp3 = fxp_mul32_Q28((*(pt_vec) + tmp0), *(pt_cos--)); + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp3 - tmp2; + *(pt_vec--) = tmp3 + tmp2; + } + +} + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst16.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst16.h new file mode 100644 index 0000000..952908a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst16.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst16.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef DST16_H +#define DST16_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void dst_16(Int32 vec[], Int32 scratch_mem[]); + +#ifdef __cplusplus +} +#endif + +#endif /* DST16_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst32.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst32.cpp new file mode 100644 index 0000000..bec2ee0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst32.cpp @@ -0,0 +1,193 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst32.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 32 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement discrete sine transform of lenght 32 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "dst32.h" +#include "dst16.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +#define R_SHIFT1 29 +#define Qfmt29(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) +#define Qfmt31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) + +const Int32 CosTable_16[14] = +{ + Qfmt31(0.50060299823520F), Qfmt31(0.50547095989754F), + Qfmt31(0.51544730992262F), Qfmt31(0.53104259108978F), + Qfmt31(0.55310389603444F), Qfmt31(0.58293496820613F), + Qfmt31(0.62250412303566F), Qfmt31(0.67480834145501F), + Qfmt31(0.74453627100230F), Qfmt31(0.83934964541553F), + Qfmt29(0.97256823786196F), Qfmt29(1.16943993343288F), + Qfmt29(1.48416461631417F), Qfmt29(2.05778100995341F) +}; + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void dst_32(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 32 */ +{ + Int32 *temp_even = scratch_mem; + + Int32 i; + const Int32 *pt_cos = &CosTable_16[13]; + Int32 tmp0 = vec[31] >> 1; + Int32 tmp1, tmp2; + Int32 *pt_even = temp_even; + Int32 *pt_odd = vec; + Int32 *pt_vec = vec; + Int32 *pt_vecN_1 = vec; + Int32 tmp3; + + + tmp1 = 0; + + for (i = 5; i != 0; i--) + { + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + tmp3 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + tmp1 = *(pt_vec++); + *(pt_odd++) = tmp3 + tmp2; + *(pt_odd++) = tmp1 + tmp3; + } + + *(pt_even) = *(pt_vec++); + *(pt_odd) = *(pt_vec) + tmp1; + + + dst_16(temp_even, &scratch_mem[16]); + dst_16(vec, &scratch_mem[24]); + + + pt_vecN_1 = &vec[16]; + + tmp1 = temp_even[15]; + + tmp3 = fxp_mul32_Q31((vec[15] - tmp0) << 3, Qfmt31(0.63687550772175F)) << 2; + tmp2 = temp_even[14]; + *(pt_vecN_1++) = tmp3 - tmp1; + vec[15] = tmp3 + tmp1; + tmp1 = temp_even[13]; + tmp3 = fxp_mul32_Q31((vec[14] + tmp0) << 3, Qfmt31(0.85190210461718F)); + *(pt_vecN_1++) = tmp3 - tmp2; + vec[14] = tmp3 + tmp2; + + pt_even = &temp_even[12]; + pt_vec = &vec[13]; + + for (i = 2; i != 0; i--) + { + tmp3 = fxp_mul32_Q29((*(pt_vec) - tmp0), *(pt_cos--)); + tmp2 = *(pt_even--); + *(pt_vec--) = tmp3 + tmp1; + *(pt_vecN_1++) = tmp3 - tmp1; + tmp3 = fxp_mul32_Q29((*(pt_vec) + tmp0), *(pt_cos--)); + tmp1 = *(pt_even--); + *(pt_vec--) = tmp3 + tmp2; + *(pt_vecN_1++) = tmp3 - tmp2; + } + + for (i = 5; i != 0; i--) + { + tmp3 = fxp_mul32_Q31((*(pt_vec) - tmp0), *(pt_cos--)) << 1; + tmp2 = *(pt_even--); + *(pt_vec--) = tmp3 + tmp1; + *(pt_vecN_1++) = tmp3 - tmp1; + tmp3 = fxp_mul32_Q31((*(pt_vec) + tmp0), *(pt_cos--)) << 1; + tmp1 = *(pt_even--); + *(pt_vec--) = tmp3 + tmp2; + *(pt_vecN_1++) = tmp3 - tmp2; + } + + +} + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst32.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst32.h new file mode 100644 index 0000000..e395c79 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst32.h @@ -0,0 +1,64 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst32.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef DST32_H +#define DST32_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + extern const Int32 CosTable_16[]; + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void dst_32(Int32 vec[], Int32 scratch_mem[]); + + +#ifdef __cplusplus +} +#endif + +#endif /* DST32_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst8.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst8.cpp new file mode 100644 index 0000000..d118800 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst8.cpp @@ -0,0 +1,172 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst8.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 8 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement discrete sine transform of lenght 8 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "dst8.h" + +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +#define R_SHIFT 29 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt31(x) (Int32)(x*0x7FFFFFFF + (x>=0?0.5F:-0.5F)) + + +void dst_8(Int32 vec[]) +{ + + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 temp5; + Int32 temp6; + Int32 temp7; + Int32 tmp_a; + Int32 tmp_aa; + Int32 tmp_b; + Int32 tmp_bb; + Int32 tmp_c; + Int32 tmp_cc; + Int32 tmp_d; + Int32 tmp_dd; + + temp1 = fxp_mul32_by_16(vec[1], Qfmt15(0.50979557910416F)); /* (1/(2*cos( phi)));*/ + temp2 = fxp_mul32_by_16(vec[2], Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi)));*/ + temp3 = fxp_mul32_by_16(vec[3], Qfmt15(0.60134488693505F)); /* (1/(2*cos(3*phi)));*/ + temp5 = fxp_mul32_by_16(vec[5], Qfmt15(0.89997622313642F)); /* (1/(2*cos(5*phi)));*/ + temp6 = fxp_mul32_by_16(vec[6] << 1, Qfmt15(0.65328148243819F)); /* (1/(2*cos(6*phi)));*/ + temp7 = vec[7] + fxp_mul32_Q31(vec[7], Qfmt31(0.56291544774152F)); /* (1/(2*cos(7*phi)));*/ + + /* even */ + tmp_a = fxp_mul32_Q31((temp2 + temp6) << 1, Qfmt31(0.70710678118655F)); + tmp_b = (temp2 - temp6) + tmp_a; + + temp4 = fxp_mul32_by_16(vec[4], Qfmt15(0.70710678118655F)); + vec[0] = tmp_a + temp4; + vec[1] = tmp_b + temp4; + vec[2] = tmp_b - temp4; + vec[3] = tmp_a - temp4; + + + /* odd */ + + tmp_a = fxp_mul32_by_16((temp1 + temp7) << 1, Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi))); */ + tmp_aa = (temp1 - temp7); + tmp_bb = (temp5 - temp3); + temp5 = fxp_mul32_Q29((temp5 + temp3), Qfmt(1.30656296487638F)); /* (1/(2*cos(6*phi))); */ + + + tmp_c = fxp_mul32_by_16((tmp_a + temp5) << 1, Qfmt15(0.70710678118655F)); + tmp_cc = tmp_a - temp5; + + tmp_d = fxp_mac32_by_16((tmp_aa - tmp_bb) << 1, Qfmt15(0.70710678118655F), tmp_c); + tmp_dd = (tmp_aa + tmp_bb); + + tmp_dd += tmp_c; + tmp_a = tmp_d + tmp_cc; + vec[5] = tmp_a - vec[2]; + vec[2] += tmp_a; + + temp5 = tmp_dd + tmp_cc; + + vec[4] = temp5 - vec[3]; + vec[3] += temp5; + vec[7] = tmp_c - vec[0]; + vec[0] += tmp_c; + vec[6] = tmp_d - vec[1]; + vec[1] += tmp_d; + +} + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst8.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst8.h new file mode 100644 index 0000000..a25673c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/dst8.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst8.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef DST8_H +#define DST8_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void dst_8(Int32 vec[]); + + +#ifdef __cplusplus +} +#endif + +#endif /* DST8_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_adif_const.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_adif_const.h new file mode 100644 index 0000000..8ee5381 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_adif_const.h @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_adif_const.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for ADIF header related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_ADIF_CONST_H +#define E_ADIF_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* + * audio data interchange format header + */ + LEN_ADIF_ID = (32 / 8), + LEN_COPYRT_PRES = 1, + LEN_COPYRT_ID = (72 / 8), + LEN_ORIG = 1, + LEN_HOME = 1, + LEN_BS_TYPE = 1, + LEN_BIT_RATE = 23, + LEN_NUM_PCE = 4, + LEN_ADIF_BF = 20 + +} eADIF_Const; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_blockswitching.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_blockswitching.h new file mode 100644 index 0000000..2aae688 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_blockswitching.h @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_blockswitching.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for BlockSwitching related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_BLOCK_SWITCHING_H +#define E_BLOCK_SWITCHING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* + * block switching + */ + LN = 2048, + SN = 256, + LN2 = LN / 2, + SN2 = SN / 2, + LN4 = LN / 4, + SN4 = SN / 4, + NSHORT = LN / SN, + MAX_SBK = NSHORT, + MAX_WIN = MAX_SBK, + + ONLY_LONG_WINDOW = 0, + LONG_START_WINDOW, + EIGHT_SHORT_WINDOW, + LONG_STOP_WINDOW, + NUM_WIN_SEQ, + + WLONG = ONLY_LONG_WINDOW, + WSTART, + WSHORT, + WSTOP, + + MAXBANDS = 16 * NSHORT, /* max number of scale factor bands */ + MAXFAC = 121, /* maximum scale factor */ + MIDFAC = (MAXFAC - 1) / 2, + SF_OFFSET = 100 /* global gain must be positive */ +} eBlockSwitching; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_coupling_mode.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_coupling_mode.h new file mode 100644 index 0000000..c217d30 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_coupling_mode.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_coupling_mode.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_COUPLING_MODE_H +#define E_COUPLING_MODE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + COUPLING_OFF, + COUPLING_LEVEL, + COUPLING_BAL +} +COUPLING_MODE; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_elementid.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_elementid.h new file mode 100644 index 0000000..45a47d7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_elementid.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: e_elementid.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for BlockType related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_ELEMENTID_H +#define E_ELEMENTID_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* sfb 40, coef 672, pred bw of 15.75 kHz at 48 kHz + * this is also the highest number of bins used + * by predictor for any sampling rate + */ + MAX_PRED_SFB = 40, /* 48 kHz only, now obsolete */ + MAX_PRED_BINS = 672, + + ID_SCE = 0, + ID_CPE, + ID_CCE, + ID_LFE, + ID_DSE, + ID_PCE, + ID_FIL, + ID_END +} +ElementId; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_huffmanconst.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_huffmanconst.h new file mode 100644 index 0000000..5c6037e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_huffmanconst.h @@ -0,0 +1,113 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_huffmanconst.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for Huffman related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_HUFFMAN_CONST_H +#define E_HUFFMAN_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* + * specify huffman tables as signed (1) or unsigned (0) + */ + HUF1SGN = 1, + HUF2SGN = 1, + HUF3SGN = 0, + HUF4SGN = 0, + HUF5SGN = 1, + HUF6SGN = 1, + HUF7SGN = 0, + HUF8SGN = 0, + HUF9SGN = 0, + HUF10SGN = 0, + HUF11SGN = 0, + + ZERO_HCB = 0, + BY4BOOKS = 4, + ESCBOOK = 11, + NSPECBOOKS = ESCBOOK + 1, + BOOKSCL = NSPECBOOKS, + NBOOKS = NSPECBOOKS + 1, + INTENSITY_HCB2 = 14, + INTENSITY_HCB = 15, + NOISE_HCB = 13, + NOISE_HCB2 = 113, + + NOISE_PCM_BITS = 9, + NOISE_PCM_OFFSET = (1 << (NOISE_PCM_BITS - 1)), + + NOISE_OFFSET = 90, + + LONG_SECT_BITS = 5, + SHORT_SECT_BITS = 3 +} eHuffmanConst; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_infoinitconst.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_infoinitconst.h new file mode 100644 index 0000000..f3a520e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_infoinitconst.h @@ -0,0 +1,90 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_infoinitconst.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for Infoinit related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_INFOINIT_CONST_H +#define E_INFOINIT_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "chans.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* block switch windows for single channels or channel pairs */ + Winds = Chans, + + /* average channel block length, bytes */ + Avjframe = 341, + + TEXP = 128, /* size of exp cache table */ + MAX_IQ_TBL = 128, /* size of inv quant table */ + MAXFFT = LN4 + +} infoinitConst; + + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_invf_mode.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_invf_mode.h new file mode 100644 index 0000000..68f3614 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_invf_mode.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_invf_mode.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_INVF_MODE_H +#define E_INVF_MODE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + INVF_OFF, + INVF_LOW_LEVEL, + INVF_MID_LEVEL, + INVF_HIGH_LEVEL, + + INVF_NO_OVERRIDE +} +INVF_MODE; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_maskstatus.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_maskstatus.h new file mode 100644 index 0000000..fd3d2e5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_maskstatus.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_maskstatus.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file gives the enum of mask_present value used in getmask.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_MASKSTATUS_H +#define E_MASKSTATUS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +enum +{ + MASK_NOT_PRESENT, + MASK_FROM_BITSTREAM, + MASK_ALL_FRAME, + MASK_ERROR +}; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_mp4ff_const.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_mp4ff_const.h new file mode 100644 index 0000000..f037951 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_mp4ff_const.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_mp4ff_const.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file enums the constants used by MP4FF header + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_MP4FF_CONST_H +#define E_MP4FF_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + LEN_OBJ_TYPE = 5, + LEN_SAMP_RATE_IDX = 4, + LEN_SAMP_RATE = 24, + LEN_CHAN_CONFIG = 4, + LEN_SYNC_EXTENSION_TYPE = 11, + LEN_FRAME_LEN_FLAG = 1, + LEN_DEPEND_ON_CORE = 1, + LEN_CORE_DELAY = 14, + LEN_EXT_FLAG = 1, + LEN_EP_CONFIG = 2, + LEN_LAYER_NUM = 3, + LEN_SUB_FRAME = 5, + LEN_LAYER_LEN = 11, + LEN_SECT_RES_FLAG = 1, + LEN_SCF_RES_FLAG = 1, + LEN_SPEC_RES_FLAG = 1, + LEN_EXT_FLAG3 = 1 +} eMP4FF_const; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_progconfigconst.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_progconfigconst.h new file mode 100644 index 0000000..2a52b55 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_progconfigconst.h @@ -0,0 +1,103 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_progconfigconst.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for ProgConfig related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_PROG_CONFIG_CONST_H +#define E_PROG_CONFIG_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* + * Program Configuration + */ + Main_Profile = 0, + LC_Profile = 1, + + Fs_48 = 3, + Fs_44 = 4, + Fs_32 = 5, + + LEN_PROFILE = 2, + LEN_SAMP_IDX = 4, + LEN_NUM_ELE = 4, + LEN_NUM_LFE = 2, + LEN_NUM_DAT = 3, + LEN_NUM_CCE = 4, + LEN_MIX_PRES = 1, + LEN_MMIX_IDX = 2, + LEN_PSUR_ENAB = 1, + LEN_ELE_IS_CPE = 1, + LEN_COMMENT_BYTES = 8 + +} eProgConfigConst; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_rawbitstreamconst.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_rawbitstreamconst.h new file mode 100644 index 0000000..cd24d13 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_rawbitstreamconst.h @@ -0,0 +1,125 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_rawbitstreamconst.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for the Raw Bitstream related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_RAW_BITSTREAM_CONST_H +#define E_RAW_BITSTREAM_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + LEN_SE_ID = 3, + LEN_TAG = 4, + LEN_COM_WIN = 1, + LEN_ICS_RESERV = 1, + LEN_WIN_SEQ = 2, + LEN_WIN_SH = 1, + LEN_MAX_SFBL = 6, + LEN_MAX_SFBS = 4, + LEN_CB = 4, + LEN_SCL_PCM = 8, + LEN_PRED_PRES = 1, + LEN_PRED_RST = 1, + LEN_PRED_RSTGRP = 5, + LEN_PRED_ENAB = 1, + LEN_MASK_PRES = 2, + LEN_MASK = 1, + LEN_PULSE_PRES = 1, + LEN_TNS_PRES = 1, + LEN_GAIN_PRES = 1, + + LEN_PULSE_NPULSE = 2, + LEN_PULSE_ST_SFB = 6, + LEN_PULSE_POFF = 5, + LEN_PULSE_PAMP = 4, + NUM_PULSE_LINES = 4, + PULSE_OFFSET_AMP = 4, + + LEN_IND_CCE_FLG = 1, + LEN_NCC = 3, + LEN_IS_CPE = 1, + LEN_CC_LR = 1, + LEN_CC_DOM = 1, + LEN_CC_SGN = 1, + LEN_CCH_GES = 2, + LEN_CCH_CGP = 1, + LEN_IND_SW_CCE = 1, + + LEN_D_ALIGN = 1, + LEN_D_CNT = 8, + LEN_D_ESC = 8, + LEN_F_CNT = 4, + LEN_F_ESC = 8, + LEN_BYTE = 8, + LEN_PAD_DATA = 8, + + LEN_PC_COMM = 9 + +} eRawBitstreamConst; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_element_id.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_element_id.h new file mode 100644 index 0000000..d8a820d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_element_id.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sbr_element_id.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SBR_ELEMENT_ID_H +#define E_SBR_ELEMENT_ID_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + SBR_ID_SCE = 0, + SBR_ID_CPE +} +SBR_ELEMENT_ID; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_error.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_error.h new file mode 100644 index 0000000..ca836df --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_error.h @@ -0,0 +1,100 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sbr_error.h + Funtions: + + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SBR_ERROR_H +#define E_SBR_ERROR_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define HANDLE_ERROR_INFO Int32 +#define noError 0 + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +typedef enum +{ + SBRDEC_OK = 0, + SBRDEC_NOSYNCH, + SBRDEC_ILLEGAL_PROGRAM, + SBRDEC_ILLEGAL_TAG, + SBRDEC_ILLEGAL_CHN_CONFIG, + SBRDEC_ILLEGAL_SECTION, + SBRDEC_ILLEGAL_SCFACTORS, + SBRDEC_ILLEGAL_PULSE_DATA, + SBRDEC_MAIN_PROFILE_NOT_IMPLEMENTED, + SBRDEC_GC_NOT_IMPLEMENTED, + SBRDEC_ILLEGAL_PLUS_ELE_ID, + SBRDEC_CREATE_ERROR, + SBRDEC_NOT_INITIALIZED, + SBRDEC_TOO_MANY_SBR_ENVELOPES, + SBRDEC_INVALID_BITSTREAM +} +SBR_ERROR; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_header_status.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_header_status.h new file mode 100644 index 0000000..cd221a1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_header_status.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sbr_header_status.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SBR_HEADER_STATUS_H +#define E_SBR_HEADER_STATUS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + HEADER_OK, + HEADER_RESET, + HEADER_NOT_INITIALIZED +} +SBR_HEADER_STATUS; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_master_status.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_master_status.h new file mode 100644 index 0000000..4e30acf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_master_status.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sbr_master_status.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SBR_MASTER_STATUS_H +#define E_SBR_MASTER_STATUS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + MASTER_OK, + MASTER_RESET +} +SBR_MASTER_STATUS; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_sync_state.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_sync_state.h new file mode 100644 index 0000000..9cef63c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sbr_sync_state.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sbr_sync_state.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SBR_SYNC_STATE_H +#define E_SBR_SYNC_STATE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + SBR_NOT_INITIALIZED, + UPSAMPLING, + SBR_ACTIVE +} +SBR_SYNC_STATE; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sr_mode.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sr_mode.h new file mode 100644 index 0000000..bf24106 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_sr_mode.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sr_mode.h + Funtions: + + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SR_MODE_H +#define E_SR_MODE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + SINGLE_RATE = 1, + UP_BY_2 +} +SR_MODE; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_tns_const.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_tns_const.h new file mode 100644 index 0000000..6cda439 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_tns_const.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_tns_const.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for TNS related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_TNS_CONST_H +#define E_TNS_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + TNS_MAX_BANDS = 49, + TNS_MAX_ORDER = 20, + TNS_MAX_WIN = 8, + TNS_MAX_FILT = 3, + Q_SPEC = 11, + Q_LPC = 19 + +} eTNS_Const; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_window_sequence.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_window_sequence.h new file mode 100644 index 0000000..cb87a9d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_window_sequence.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_window_sequence.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for Window Sequence related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_WINDOW_SEQUENCE_H +#define E_WINDOW_SEQUENCE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + ONLY_LONG_SEQUENCE, + LONG_START_SEQUENCE, + EIGHT_SHORT_SEQUENCE, + LONG_STOP_SEQUENCE, + NUM_WINDOW_SEQUENCE, + ENSURE_WINDOW_SEQUENCE_INT_SIZE = 0x7FFFFF +} +WINDOW_SEQUENCE; +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_window_shape.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_window_shape.h new file mode 100644 index 0000000..85b4807 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/e_window_shape.h @@ -0,0 +1,83 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_window_shape.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for Window Sequence related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_WINDOW_SHAPE_H +#define E_WINDOW_SHAPE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + SINE_WINDOW = 0, + KAISER_BESSEL_WINDOW, + NUM_WINDOW_SHAPES, + ENSURE_WINDOW_SHAPE_INT_SIZE = 0x7FFFFF +} +WINDOW_SHAPE; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.cpp new file mode 100644 index 0000000..d418af8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.cpp @@ -0,0 +1,699 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: esc_iquant_scaling.cpp + Funtions: esc_iquant_scaling + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + quantSpec[] = array of quantized compressed spectral coefficients, of + data type Int and length sfbWidth. + + sfbWidth = number of array elements in quantSpec and the output array + coef, data type Int. + + coef[] = output array of uncompressed coefficients, stored in a + variable Q format, depending on the maximum value found + for the group, array of Int32, length sfbWdith to be + overwritten. + + QFormat = the output Q format for the array coef[]. + + + scale = scaling factor after separating power of 2 factor out from + 0.25*(sfb_scale - 100), i.e., 0.25*sfb_scale. + + maxInput = maximum absolute value of quantSpec. + + Local Stores/Buffers/Pointers Needed: None. + + Global Stores/Buffers/Pointers Needed: + inverseQuantTable = lookup table of const integer values to the one third + power stored in Q27 format, in file iquant_table.c, const + array of UInt32, of size 1025. + + Outputs: None + + Pointers and Buffers Modified: + coef[] contents are overwritten with the uncompressed values from + quantSpec[] + + + + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function performs the inverse quantization of the spectral coeficients + read from huffman decoding. It takes each input array value to the four + thirds power, then scales it according to the scaling factor input argument + ,and stores the result in the output array in a variable Q format + depending upon the maximum input value found. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not have static or global variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Section 10.3, "Decoding process", page 43. + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + maxInput = 0; + + FOR (i = sfbWidth - 1; i >= 0; i--) + x = quantSpec[i]; + + IF ( x >= 0) + absX = x; + ELSE + absX = -x; + ENDIF + + coef[i] = absX; + + IF (absX > maxInput) + maxInput = absX; + ENDIF + ENDFOR + + IF (maxInput == 0) + *pQFormat = QTABLE; + ELSE + temp = inverseQuantTable[(maxInput >> ORDER) + 1]; + + temp += ((1 << (QTABLE))-1); + + temp >>= (QTABLE-1); + + temp *= maxInput; + + binaryDigits = 0; + WHILE( temp != 0) + temp >>= 1; + binaryDigits++; + WEND + + IF (binaryDigits < (SIGNED32BITS - QTABLE)) + binaryDigits = SIGNED32BITS - QTABLE; + ENDIF + + *pQFormat = SIGNED32BITS - binaryDigits; + shift = QTABLE - *pQFormat; + + IF (maxInput < TABLESIZE) + FOR (i = sfbWidth - 1; i >= 0; i--) + x = quantSpec[i]; + + absX = coef[i]; + + tmp_coef = x * (inverseQuantTable[absX] >> shift); + + b_low = (tmp_coef & 0xFFFF); + b_high = (tmp_coef >> 16); + + mult_low = ( (UInt32) b_low * scale ); + mult_high = ( (Int32) b_high * scale ); + + mult_low >>= 16; + + coef[i] = (Int32) (mult_high + mult_low); + + ENDFOR + ELSE + FOR (i = sfbWidth; i >= 0 ; i--) + x = quantSpec[i]; + absX = coef[i]; + + IF (absX < TABLESIZE) + tmp_coef = x * (inverseQuantTable[absX] >> shift); + ELSE + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + + approxOneThird = (w1 * FACTOR) >> shift; + + + x1 = index * SPACING; + w2 = inverseQuantTable[index+1]; + + deltaOneThird = (w2 - w1) * (absX - x1); + + deltaOneThird >>= (shift + ORDER - 1); + + tmp_coef = x * (approxOneThird + deltaOneThird); + + ENDIF + + b_low = (mult_high & 0xFFFF); + b_high = (mult_high >> 16); + + mult_low = ( (UInt32) b_low * scale ); + mult_high = ( (Int32) b_high * scale ); + + mult_low >>= 16; + + coef[i] = (Int32) (mult_high + mult_low); + + ENDFOR + ENDIF + ENDIF + + RETURN + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "iquant_table.h" +#include "esc_iquant_scaling.h" +#include "aac_mem_funcs.h" /* For pv_memset */ + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +/* + * Read further on what order is. + * Note: If ORDER is not a multiple of 3, FACTOR is not an integer. + * Note: Portions of this function assume ORDER is 3, and so does the table + * in iquant_table.c + */ +#define ORDER (3) +/* + * For input values > TABLESIZE, multiply by FACTOR to get x ^ (1/3) + * FACTOR = 2 ^ (ORDER/3) + */ +#define FACTOR (2) + +/* + * This is one more than the range of expected inputs. + */ +#define INPUTRANGE (8192) + +/* + * SPACING is 2 ^ ORDER, and is the spacing between points when in the + * interpolation range. + */ +#define SPACING (1<=4) && (PV_COMPILER == EPV_ARM_GNUC)) +/* + * Absolute value for 16 bit-numbers + */ +__inline Int32 abs2(Int32 x) +{ + register Int32 z; + register Int32 y; + register Int32 ra = x; + asm volatile( + "sub %0, %2, %2, lsr #31\n\t" + "eor %1, %0, %0, asr #31" + : "=&r*i"(z), + "=&r*i"(y) + : "r"(ra)); + + return (y); +} + +#define pv_abs(x) abs2(x) + + +#else + +#define pv_abs(x) ((x) > 0)? (x) : (-x) + +#endif + + + + + +void esc_iquant_scaling( + const Int16 quantSpec[], + Int32 coef[], + const Int sfbWidth, + Int const QFormat, + UInt16 scale, + Int maxInput) +{ + Int i; + Int x; + Int y; + Int index; + Int shift; + UInt absX; + UInt32 w1, w2; + UInt32 deltaOneThird; + UInt32 x1; + UInt32 approxOneThird; + Int32 mult_high; + + + pv_memset(coef, 0, sizeof(Int32) * sfbWidth); + + if (maxInput > 0) + { + + shift = QTABLE - QFormat; + + if (scale != 0) + { + if (maxInput < TABLESIZE) + { + + for (i = sfbWidth - 1; i >= 0; i -= 4) + { + x = quantSpec[i]; + y = quantSpec[i-1]; + if (x) + { + absX = pv_abs(x); + mult_high = (x * (inverseQuantTable[absX] >> shift)); + coef[i] = fxp_mul32_by_16(mult_high, scale) << 1; + } + + if (y) + { + absX = pv_abs(y); + mult_high = y * (inverseQuantTable[absX] >> shift); + coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1; + } + + x = quantSpec[i-2]; + y = quantSpec[i-3]; + if (x) + { + absX = pv_abs(x); + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1; + } + + if (y) + { + absX = pv_abs(y); + mult_high = y * (inverseQuantTable[absX] >> shift); + coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1; + } + } /* end for (i = sfbWidth - 1; i >= 0; i--) */ + + } /* end if (maxInput < TABLESIZE)*/ + + else /* maxInput >= TABLESIZE) */ + { + for (i = sfbWidth - 1; i >= 0; i -= 4) + { + x = quantSpec[i]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i] = fxp_mul32_by_16(mult_high, scale) << 1; + + } + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i] = fxp_mul32_by_16(mult_high, scale) << 1; + + } + } /* if(x) */ + + + x = quantSpec[i-1]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = (x * (inverseQuantTable[absX] >> shift)); + coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1; + + } + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1; + } + } /* if(x) */ + + x = quantSpec[i-2]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1; + } + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1; + } + } /* if(x) */ + + x = quantSpec[i-3]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1; + + } + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1; + + } + } /* if(x) */ + + } /* end for (i = sfbWidth - 1; i >= 0; i--) */ + } /* end else for if (maxInput < TABLESIZE)*/ + } + else /* scale == 0 */ + { + if (maxInput < TABLESIZE) + { + for (i = sfbWidth - 1; i >= 0; i -= 4) + { + x = quantSpec[i]; + y = quantSpec[i-1]; + if (x) + { + absX = pv_abs(x); + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i] = mult_high >> 1; + } + + if (y) + { + absX = pv_abs(y); + mult_high = y * (inverseQuantTable[absX] >> shift); + coef[i-1] = mult_high >> 1; + } + + x = quantSpec[i-2]; + y = quantSpec[i-3]; + if (x) + { + absX = pv_abs(x); + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-2] = mult_high >> 1; + } + + if (y) + { + absX = pv_abs(y); + mult_high = y * (inverseQuantTable[absX] >> shift); + coef[i-3] = mult_high >> 1; + } + } + + } /* end if (maxInput < TABLESIZE)*/ + + else /* maxInput >= TABLESIZE) */ + { + for (i = sfbWidth - 1; i >= 0; i -= 4) + { + x = quantSpec[i]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i] = (mult_high >> 1); + } /* end if (absX < TABLESIZE) */ + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i] = (mult_high >> 1); + } + } /* if(x) */ + + x = quantSpec[i-1]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-1] = (mult_high >> 1); + } /* end if (absX < TABLESIZE) */ + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-1] = (mult_high >> 1); + } + } /* if(x) */ + + x = quantSpec[i-2]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-2] = (mult_high >> 1); + } /* end if (absX < TABLESIZE) */ + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-2] = (mult_high >> 1); + } + } /* if(x) */ + + x = quantSpec[i-3]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-3] = (mult_high >> 1); + } /* end if (absX < TABLESIZE) */ + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-3] = (mult_high >> 1); + } + + } /* if(x) */ + + } /* end for (i = sfbWidth - 1; i >= 0; i--) */ + + } /* end else for if (maxInput < TABLESIZE)*/ + + } /* end else for if(scale!=0) */ + + } /* end else for if(maxInput == 0) */ + +} /* end esc_iquant_fxp */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.h new file mode 100644 index 0000000..8adef3d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.h @@ -0,0 +1,96 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: esc_iquant_scaling.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for esc_iquant_scaling.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef ESC_IQUANT_SCALING_H +#define ESC_IQUANT_SCALING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + + void esc_iquant_scaling( + const Int16 quantSpec[], + Int32 coef[], + const Int sfbWidth, + Int const pQFormat, + UInt16 scale, + Int maxInput); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* ESC_IQUANT_SCALING_H */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/extractframeinfo.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/extractframeinfo.cpp new file mode 100644 index 0000000..c8fdf36 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/extractframeinfo.cpp @@ -0,0 +1,491 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: extractframeinfo.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: hBitBuf - bitbuffer handle + v_frame_info - pointer to memorylocation where the frame-info will + be stored. + + Return: none. + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + +Extracts a frame_info vector from control data read from the bitstream. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "extractframeinfo.h" +#include "buf_getbits.h" +#include "aac_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/* + * (int) ceil (log (bs_num_env + 1) / log (2)) + * ceil(log([0:5]+1)/log(2)) + */ + +const Int32 bs_pointer_bits_tbl[MAX_ENVELOPES + 1] = { 0, 1, 2, 2, 3, 3}; + +/* + * (int)((float)numTimeSlots/bs_num_env + 0.5f) + * floor(16./[0:5] + 0.5) + */ + +const Int32 T_16_ov_bs_num_env_tbl[MAX_ENVELOPES + 1] = { 2147483647, 16, 8, + 5, 4, 3 + }; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +SBR_ERROR extractFrameInfo(BIT_BUFFER * hBitBuf, + SBR_FRAME_DATA * h_frame_data) +{ + + Int32 absBordLead = 0; + Int32 nRelLead = 0; + Int32 nRelTrail = 0; + Int32 bs_num_env = 0; + Int32 bs_num_rel = 0; + Int32 bs_var_bord = 0; + Int32 bs_var_bord_0 = 0; + Int32 bs_var_bord_1 = 0; + Int32 bs_pointer = 0; + Int32 bs_pointer_bits; + Int32 frameClass; + Int32 temp; + Int32 env; + Int32 k; + Int32 bs_num_rel_0 = 0; + Int32 bs_num_rel_1 = 0; + Int32 absBordTrail = 0; + Int32 middleBorder = 0; + Int32 bs_num_noise; + Int32 lA = 0; + + Int32 tE[MAX_ENVELOPES + 1]; + Int32 tQ[2 + 1]; + Int32 f[MAX_ENVELOPES + 1]; + Int32 bs_rel_bord[4]; + Int32 bs_rel_bord_0[4]; + Int32 bs_rel_bord_1[4]; + Int32 relBordLead[4]; + Int32 relBordTrail[4]; + + + Int32 *v_frame_info = h_frame_data->frameInfo; + + SBR_ERROR err = SBRDEC_OK; + + + /* + * First read from the bitstream. + */ + + /* Read frame class */ + h_frame_data->frameClass = frameClass = buf_getbits(hBitBuf, SBR_CLA_BITS); + + + switch (frameClass) + { + + case FIXFIX: + temp = buf_getbits(hBitBuf, SBR_ENV_BITS); /* 2 bits */ + + bs_num_env = 1 << temp; + + if (bs_num_env >= MAX_ENVELOPES) + { + bs_num_env = MAX_ENVELOPES - 1; // For FIXFIX this is limited to 4 + } + + + f[0] = buf_getbits(hBitBuf, SBR_RES_BITS); /* 1 bit */ + + for (env = 1; env < bs_num_env; env++) + { + f[env] = f[0]; + } + + nRelLead = bs_num_env - 1; + absBordTrail = 16; + + + break; + + case FIXVAR: + bs_var_bord = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */ + bs_num_rel = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */ + bs_num_env = bs_num_rel + 1; + + for (k = 0; k < bs_num_env - 1; k++) + { + bs_rel_bord[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1; + } + + bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env]; + + bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits); + + for (env = 0; env < bs_num_env; env++) + { /* 1 bit */ + f[bs_num_env - 1 - env] = buf_getbits(hBitBuf, SBR_RES_BITS); + } + + absBordTrail = 16 + bs_var_bord; + nRelTrail = bs_num_rel; + + break; + + case VARFIX: + bs_var_bord = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */ + bs_num_rel = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */ + bs_num_env = bs_num_rel + 1; + + for (k = 0; k < bs_num_env - 1; k++) + { + bs_rel_bord[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1; + } + + bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env]; + + bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits); + + for (env = 0; env < bs_num_env; env++) + { /* 1 bit */ + f[env] = buf_getbits(hBitBuf, SBR_RES_BITS); + } + + absBordTrail = 16; + absBordLead = bs_var_bord; + nRelLead = bs_num_rel; + + break; + + case VARVAR: + bs_var_bord_0 = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */ + bs_var_bord_1 = buf_getbits(hBitBuf, SBR_ABS_BITS); + bs_num_rel_0 = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */ + bs_num_rel_1 = buf_getbits(hBitBuf, SBR_NUM_BITS); + + bs_num_env = bs_num_rel_0 + bs_num_rel_1 + 1; + + if (bs_num_env > MAX_ENVELOPES) + { + bs_num_env = MAX_ENVELOPES; // For VARVAR this is limited to 5 + } + + + for (k = 0; k < bs_num_rel_0; k++) + { /* 2 bits */ + bs_rel_bord_0[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1; + } + + for (k = 0; k < bs_num_rel_1; k++) + { /* 2 bits */ + bs_rel_bord_1[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1; + } + + + bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env]; + + bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits); + + for (env = 0; env < bs_num_env; env++) + { /* 1 bit */ + f[env] = buf_getbits(hBitBuf, SBR_RES_BITS); + } + + absBordLead = bs_var_bord_0; + absBordTrail = 16 + bs_var_bord_1; + nRelLead = bs_num_rel_0; + nRelTrail = bs_num_rel_1; + + break; + + }; + + + /* + * Calculate the framing. + */ + + + switch (frameClass) + { + case FIXFIX: + for (k = 0; k < nRelLead; k++) + { + relBordLead[k] = T_16_ov_bs_num_env_tbl[bs_num_env]; + } + break; + case VARFIX: + for (k = 0; k < nRelLead; k++) + { + relBordLead[k] = bs_rel_bord[k]; + } + break; + case VARVAR: + for (k = 0; k < nRelLead; k++) + { + relBordLead[k] = bs_rel_bord_0[k]; + } + for (k = 0; k < nRelTrail; k++) + { + relBordTrail[k] = bs_rel_bord_1[k]; + } + break; + case FIXVAR: + for (k = 0; k < nRelTrail; k++) + { + relBordTrail[k] = bs_rel_bord[k]; + } + break; + } + + + tE[0] = absBordLead; + tE[bs_num_env] = absBordTrail; + + for (env = 1; env <= nRelLead; env++) + { + tE[env] = absBordLead; + for (k = 0; k <= env - 1; k++) + { + tE[env] += relBordLead[k]; + } + } + + for (env = nRelLead + 1; env < bs_num_env; env++) + { + tE[env] = absBordTrail; + for (k = 0; k <= bs_num_env - env - 1; k++) + { + tE[env] -= relBordTrail[k]; + } + } + + + + switch (frameClass) + { + case FIXFIX: + middleBorder = bs_num_env >> 1; + break; + case VARFIX: + switch (bs_pointer) + { + case 0: + middleBorder = 1; + break; + case 1: + middleBorder = bs_num_env - 1; + break; + default: + middleBorder = bs_pointer - 1; + break; + }; + break; + case FIXVAR: + case VARVAR: + switch (bs_pointer) + { + case 0: + case 1: + middleBorder = bs_num_env - 1; + break; + default: + middleBorder = bs_num_env + 1 - bs_pointer; + break; + }; + break; + }; + + + tQ[0] = tE[0]; + if (bs_num_env > 1) + { + tQ[1] = tE[middleBorder]; + tQ[2] = tE[bs_num_env]; + bs_num_noise = 2; + } + else + { + tQ[1] = tE[bs_num_env]; + bs_num_noise = 1; + } + + /* + * Check consistency on freq bands + */ + + if ((tE[bs_num_env] < tE[0]) || (tE[0] < 0) || (bs_num_env > MAX_ENVELOPES)) + { + err = SBRDEC_INVALID_BITSTREAM; + } + + + switch (frameClass) + { + case FIXFIX: + lA = -1; + break; + case VARFIX: + switch (bs_pointer) + { + case 0: + case 1: + lA = -1; + break; + default: + lA = bs_pointer - 1; + break; + }; + break; + case FIXVAR: + case VARVAR: + switch (bs_pointer) + { + case 0: + lA = - 1; + break; + default: + lA = bs_num_env + 1 - bs_pointer; + break; + }; + break; + }; + + /* + * Build the frameInfo vector... + */ + + v_frame_info[0] = bs_num_env; /* Number of envelopes*/ + pv_memcpy(v_frame_info + 1, tE, (bs_num_env + 1)*sizeof(Int32)); /* time borders*/ + /* frequency resolution */ + pv_memcpy(v_frame_info + 1 + bs_num_env + 1, f, bs_num_env*sizeof(Int32)); + + temp = (1 + bs_num_env) << 1; + v_frame_info[temp] = lA; /* transient envelope*/ + v_frame_info[temp + 1] = bs_num_noise; /* Number of noise envelopes */ + /* noise borders */ + pv_memcpy(v_frame_info + temp + 2, tQ, (bs_num_noise + 1)*sizeof(Int32)); + + + return (err); + +} + + + + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/extractframeinfo.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/extractframeinfo.h new file mode 100644 index 0000000..e912f62 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/extractframeinfo.h @@ -0,0 +1,90 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: extractframeinfo.h + + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef EXTRACTFRAMEINFO_H +#define EXTRACTFRAMEINFO_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" +#include "e_sbr_error.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef Int32 FRAME_INFO[LENGTH_FRAME_INFO]; + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + SBR_ERROR extractFrameInfo(BIT_BUFFER * hBitBuf, + SBR_FRAME_DATA * h_frame_data); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4.h new file mode 100644 index 0000000..6aa5575 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fft_rx4.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions fft_rx4() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef FFT_RX4_H +#define FFT_RX4_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define FFT_RX4_LONG 256 +#define ONE_FOURTH_FFT_RX4_LONG ((FFT_RX4_LONG)>>2) +#define FFT_RX4_SHORT 64 +#define ONE_FOURTH_FFT_RX4_SHORT ((FFT_RX4_SHORT)>>2) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const Int16 w_64rx4[]; +extern const Int32 W_64rx4[]; +extern const Int32 W_256rx4[]; +extern const Int32 w_512rx2[]; + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void fft_rx4_long( + Int32 Data[], + Int32 *peak_value); + + Int fft_rx4_short( + Int32 Data[], + Int32 *peak_value); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* FFT_RX4_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4_long.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4_long.cpp new file mode 100644 index 0000000..2aac501 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4_long.cpp @@ -0,0 +1,381 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fft_rx4_long.cpp + Funtions: fft_rx4_long + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Data = Input complex vector, arranged in the following order: + real, imag, real, imag... + This is a complex vector whose elements (real and Imag) are + Int32. + type Int32 * + + peak_value = Input, peak value of the input vector + Output, peak value of the resulting vector + type Int32 * + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + calculation are done in-place and returned in Data + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Fast Fourier Transform, radix 4 with Decimation in Frequency and block + floating point arithmetic. + The radix-4 FFT simply divides the FFT into four smaller FFTs. Each of + the smaller FFTs is then further divided into smaller ones and so on. + It consists of log 4 N stages and each stage consists of N/4 dragonflies. + + An FFT is nothing but a bundle of multiplications and summations which + may overflow during calculations. + + + This routine uses a scheme to test and scale the result output from + each FFT stage in order to fix the accumulation overflow. + + The Input Data should be in Q13 format to get the highest precision. + At the end of each dragonfly calculation, a test for possible bit growth + is made, if bit growth is possible the Data is scale down back to Q13. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should provide a fixed point FFT for an input array + of size 256. + +------------------------------------------------------------------------------ + REFERENCES + + [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling, + C. Nikias, Macmillan Pub. Co. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + + MODIFY( x[] ) + RETURN( exponent ) + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "fft_rx4.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void fft_rx4_long( + Int32 Data[], + Int32 *peak_value) + +{ + Int n1; + Int n2; + Int j; + Int k; + Int i; + + Int32 t1; + Int32 t2; + Int32 r1; + Int32 r2; + Int32 r3; + Int32 r4; + Int32 s1; + Int32 s2; + Int32 s3; + Int32 *pData1; + Int32 *pData2; + Int32 *pData3; + Int32 *pData4; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 max; + + Int32 exp_jw1; + Int32 exp_jw2; + Int32 exp_jw3; + + + + const Int32 *pw = W_256rx4; + + n2 = FFT_RX4_LONG; + + for (k = FFT_RX4_LONG; k > 4; k >>= 2) + { + + n1 = n2; + n2 >>= 2; + + for (i = 0; i < FFT_RX4_LONG; i += n1) + { + pData1 = &Data[ i<<1]; + pData2 = pData1 + n1; + + temp1 = *pData1; + temp2 = *pData2; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + + pData3 = pData1 + (n1 >> 1); + pData4 = pData3 + n1; + temp3 = *pData3++; + temp4 = *pData4++; + + t1 = temp3 + temp4; + + *(pData1++) = (r1 + t1); + t2 = temp3 - temp4; + *(pData2++) = (r1 - t1); + + temp1 = *pData1; + temp2 = *pData2; + + s1 = temp1 + temp2; + temp3 = *pData3; + s2 = temp1 - temp2; + temp4 = *pData4; + *pData3-- = (s2 - t2); + *pData4-- = (s2 + t2); + + t1 = temp3 + temp4; + + *pData1 = (s1 + t1); + *pData2 = (s1 - t1); + + r1 = temp3 - temp4; + + *pData4 = (r2 - r1); + *pData3 = (r2 + r1); + + } /* i */ + + + + for (j = 1; j < n2; j++) + { + + exp_jw1 = (*pw++); + exp_jw2 = (*pw++); + exp_jw3 = (*pw++); + + + for (i = j; i < FFT_RX4_LONG; i += n1) + { + pData1 = &Data[ i<<1]; + pData2 = pData1 + n1; + + temp1 = *pData1; + temp2 = *pData2++; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + + pData3 = pData1 + (n1 >> 1); + pData4 = pData3 + n1; + temp3 = *pData3++; + temp4 = *pData4++; + + r3 = temp3 + temp4; + r4 = temp3 - temp4; + + *(pData1++) = (r1 + r3); + r1 = (r1 - r3) << 1; + + temp2 = *pData2; + temp1 = *pData1; + + s1 = temp1 + temp2; + s2 = temp1 - temp2; + s3 = (s2 + r4) << 1; + s2 = (s2 - r4) << 1; + + temp3 = *pData3; + temp4 = *pData4; + + t1 = temp3 + temp4; + t2 = temp3 - temp4; + + *pData1 = (s1 + t1); + s1 = (s1 - t1) << 1; + + *pData2-- = cmplx_mul32_by_16(s1, -r1, exp_jw2); + r3 = (r2 - t2) << 1; + *pData2 = cmplx_mul32_by_16(r1, s1, exp_jw2); + + r2 = (r2 + t2) << 1; + + *pData3-- = cmplx_mul32_by_16(s2, -r2, exp_jw1); + *pData3 = cmplx_mul32_by_16(r2, s2, exp_jw1); + + *pData4-- = cmplx_mul32_by_16(s3, -r3, exp_jw3); + *pData4 = cmplx_mul32_by_16(r3, s3, exp_jw3); + + } /* i */ + + } /* j */ + + } /* k */ + + + max = 0; + + pData1 = Data - 7; + + + for (i = ONE_FOURTH_FFT_RX4_LONG; i != 0 ; i--) + { + pData1 += 7; + pData2 = pData1 + 4; + + + temp1 = *pData1; + temp2 = *pData2++; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + + pData3 = pData1 + 2; + pData4 = pData1 + 6; + temp1 = *pData3++; + temp2 = *pData4++; + + t1 = temp1 + temp2; + t2 = temp1 - temp2; + + temp1 = (r1 + t1); + r1 = (r1 - t1); + *(pData1++) = temp1; + max |= (temp1 >> 31) ^ temp1; + + + + temp2 = *pData2; + temp1 = *pData1; + + s1 = temp1 + temp2; + s2 = temp1 - temp2; + + + temp1 = *pData3; + temp2 = *pData4; + + s3 = (s2 + t2); + s2 = (s2 - t2); + + t1 = temp1 + temp2; + t2 = temp1 - temp2; + + temp1 = (s1 + t1); + *pData1 = temp1; + temp2 = (s1 - t1); + + max |= (temp1 >> 31) ^ temp1; + *pData2-- = temp2; + max |= (temp2 >> 31) ^ temp2; + + *pData2 = r1; + max |= (r1 >> 31) ^ r1; + *pData3-- = s2; + max |= (s2 >> 31) ^ s2; + *pData4-- = s3; + max |= (s3 >> 31) ^ s3; + + temp1 = (r2 - t2); + *pData4 = temp1; + temp2 = (r2 + t2); + *pData3 = temp2; + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + } /* i */ + + *peak_value = max; + + return ; + +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4_short.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4_short.cpp new file mode 100644 index 0000000..0b66dde --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4_short.cpp @@ -0,0 +1,424 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fft_rx4_short.cpp + Funtions: fft_rx4_short + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Data = Input complex vector, arranged in the following order: + real, imag, real, imag... + This is a complex vector whose elements (real and Imag) are + Int32. + type Int32 * + + peak_value = Input, peak value of the input vector + Output, peak value of the resulting vector + type Int32 * + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exponent returns a shift to compensate the scaling introduced by + overflow protection + + Pointers and Buffers Modified: + calculation are done in-place and returned in Data + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Fast Fourier Transform, radix 4 with Decimation in Frequency and block + floating point arithmetic. + The radix-4 FFT simply divides the FFT into four smaller FFTs. Each of + the smaller FFTs is then further divided into smaller ones and so on. + It consists of log 4 N stages and each stage consists of N/4 dragonflies. + + An FFT is nothing but a bundle of multiplications and summations which + may overflow during calculations. + + + This routine uses a scheme to test and scale the result output from + each FFT stage in order to fix the accumulation overflow. + + The Input Data should be in Q13 format to get the highest precision. + At the end of each dragonfly calculation, a test for possible bit growth + is made, if bit growth is possible the Data is scale down back to Q13. + + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should provide a fixed point FFT for an input array + of size 64. + +------------------------------------------------------------------------------ + REFERENCES + + [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling, + C. Nikias, Macmillan Pub. Co. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + + MODIFY( x[] ) + RETURN( exponent ) + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "fft_rx4.h" +#include "pv_normalize.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int fft_rx4_short( + Int32 Data[], + Int32 *peak_value) + +{ + Int n1; + Int n2; + Int n3; + Int j; + Int k; + Int i; + Int32 exp_jw1; + Int32 exp_jw2; + Int32 exp_jw3; + + + Int32 t1; + Int32 t2; + Int32 r1; + Int32 r2; + Int32 r3; + Int32 s1; + Int32 s2; + Int32 s3; + + Int32 *pData1; + Int32 *pData2; + Int32 *pData3; + Int32 *pData4; + const Int32 *pw; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 max; + Int exp; + Int exponent = 0; + Int shift; + + + max = *peak_value; + exp = 0; + + if (max > 0x008000) + { + exp = 8 - pv_normalize(max); /* use 24 bits */ + + exponent = exp; /* keeps track of # of shifts */ + + } + + n2 = FFT_RX4_SHORT; + + pw = W_64rx4; + + + /* shift down to avoid possible overflow in first pass of the loop */ + shift = 2; + + for (k = FFT_RX4_SHORT; k > 4; k >>= 2) + { + + n1 = n2; + n2 >>= 2; + n3 = n1 >> 1; + + exp -= 2; + + for (i = 0; i < FFT_RX4_SHORT; i += n1) + { + pData1 = &Data[ i<<1]; + pData3 = pData1 + n3; + pData2 = pData1 + n1; + pData4 = pData3 + n1; + + temp1 = *(pData1); + temp2 = *(pData2); + temp1 >>= shift; + temp2 >>= shift; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + + temp3 = *(pData3++); + temp4 = *(pData4++); + temp3 >>= shift; + temp4 >>= shift; + + t1 = temp3 + temp4; + t2 = temp3 - temp4; + + *(pData1++) = (r1 + t1) >> exp; + *(pData2++) = (r1 - t1) >> exp; + + temp1 = *pData1; + temp2 = *pData2; + temp1 >>= shift; + temp2 >>= shift; + + s1 = temp1 + temp2; + s2 = temp1 - temp2; + + temp3 = *pData3; + temp4 = *pData4; + temp3 >>= shift; + temp4 >>= shift; + + t1 = temp3 + temp4; + r1 = temp3 - temp4; + + *pData1 = (s1 + t1) >> exp; + *pData2 = (s1 - t1) >> exp; + + *pData4-- = (s2 + t2) >> exp; + *pData4 = (r2 - r1) >> exp; + + *pData3-- = (s2 - t2) >> exp; + *pData3 = (r2 + r1) >> exp; + + + } /* i */ + + for (j = 1; j < n2; j++) + { + exp_jw1 = *pw++; + exp_jw2 = *pw++; + exp_jw3 = *pw++; + + + for (i = j; i < FFT_RX4_SHORT; i += n1) + { + pData1 = &Data[ i<<1]; + pData3 = pData1 + n3; + pData2 = pData1 + n1; + pData4 = pData3 + n1; + + temp1 = *(pData1); + temp2 = *(pData2++); + temp1 >>= shift; + temp2 >>= shift; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + temp3 = *(pData3++); + temp4 = *(pData4++); + temp3 >>= shift; + temp4 >>= shift; + + t1 = temp3 + temp4; + t2 = temp3 - temp4; + + *(pData1++) = (r1 + t1) >> exp; + r1 = (r1 - t1) >> exp; + + temp1 = *pData1; + temp2 = *pData2; + temp1 >>= shift; + temp2 >>= shift; + + s1 = temp1 + temp2; + s2 = temp1 - temp2; + + s3 = (s2 + t2) >> exp; + s2 = (s2 - t2) >> exp; + + temp3 = *pData3; + temp4 = *pData4 ; + temp3 >>= shift; + temp4 >>= shift; + + t1 = temp3 + temp4; + t2 = temp3 - temp4; + + *pData1 = (s1 + t1) >> exp; + s1 = (s1 - t1) >> exp; + + + *pData2-- = cmplx_mul32_by_16(s1, -r1, exp_jw2) << 1; + *pData2 = cmplx_mul32_by_16(r1, s1, exp_jw2) << 1; + + r3 = ((r2 - t2) >> exp); + r2 = ((r2 + t2) >> exp); + + *pData3-- = cmplx_mul32_by_16(s2, -r2, exp_jw1) << 1; + *pData3 = cmplx_mul32_by_16(r2, s2, exp_jw1) << 1; + + *pData4-- = cmplx_mul32_by_16(s3, -r3, exp_jw3) << 1; + *pData4 = cmplx_mul32_by_16(r3, s3, exp_jw3) << 1; + + } /* i */ + + } /* j */ + + /* + * this will reset exp and shift to zero for the second pass of the + * loop + */ + exp = 2; + shift = 0; + + } /* k */ + + + max = 0; + + pData1 = Data - 7; + + for (i = ONE_FOURTH_FFT_RX4_SHORT; i != 0 ; i--) + { + pData1 += 7; + + pData3 = pData1 + 2; + pData2 = pData1 + 4; + pData4 = pData1 + 6; + + temp1 = *pData1; + temp2 = *pData2++; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + + temp1 = *pData3++; + temp2 = *pData4++; + + t1 = temp1 + temp2; + t2 = temp1 - temp2; + + temp1 = (r1 + t1); + r1 = (r1 - t1); + *(pData1++) = temp1; + max |= (temp1 >> 31) ^ temp1; + + + + temp1 = *pData1; + temp2 = *pData2; + + s1 = temp1 + temp2; + s2 = temp1 - temp2; + + s3 = (s2 + t2); + s2 = (s2 - t2); + + temp1 = *pData3; + temp2 = *pData4; + + t1 = temp1 + temp2; + t2 = temp1 - temp2; + + temp1 = (s1 + t1); + temp2 = (s1 - t1); + *pData1 = temp1; + *pData2-- = temp2; + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + *pData2 = r1; + *pData3-- = s2; + *pData4-- = s3; + max |= (r1 >> 31) ^ r1; + max |= (s2 >> 31) ^ s2; + max |= (s3 >> 31) ^ s3; + + temp1 = (r2 - t2); + temp2 = (r2 + t2); + *pData4 = temp1; + *pData3 = temp2; + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + } /* i */ + + *peak_value = max; + + + return (exponent); + +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4_tables_fxp.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4_tables_fxp.cpp new file mode 100644 index 0000000..977a168 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fft_rx4_tables_fxp.cpp @@ -0,0 +1,249 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fft_rx4_tables_fxp.cpp + Funtions: + +------------------------------------------------------------------------------ + MODULE DESCRIPTION + + Table generation + + n = 256 or 64; + M = precision; 2^10, 2^12, 2^13 + + for j=1; jusedBits < + (pInputStream->availableBits + syncword_length) ) + + max_search_length = (pInputStream->availableBits - pInputStream->usedBits); + + max_search_length = max_search_length - syncword_length; + + search_length = 0; + + adts_header = + CALL getbits(syncword_length, pInputStream); + MODIFYING pInputStream->usedBits + RETURNING bits from bitstream of length (syncword_length) + + test_for_syncword = adts_header AND syncword_mask; + test_for_syncword = test_for_syncword XOR syncword; + + WHILE ( (test_for_syncword != 0) && (search_length > 0) ) + + search_length = search_length - 1; + + adts_header = adts_header << 1; + adts_header = adts_header OR ... + + CALL getbits(syncword_length, pInputStream); + MODIFYING pInputStream->usedBits + RETURNING 1 bit from the bitstream + + test_for_syncword = adts_header AND syncword_mask; + test_for_syncword = test_for_syncword XOR syncword; + + ENDWHILE + + IF (search_length == 0) + status = ERROR; + ENDIF + + *(pSyncword) = adts_header; + + pInputStream->byteAlignOffset = + (pInputStream->usedBits - syncwordlength) AND 0x7; + + ELSE + status = ERROR; + ENDIF + + return (status); + + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "ibstream.h" +#include "find_adts_syncword.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int find_adts_syncword( + UInt32 *pSyncword, + BITS *pInputStream, + Int syncword_length, + UInt32 syncword_mask) +{ + + Int status = SUCCESS; + Int search_length; + UInt32 adts_header = 0; + UInt32 test_for_syncword; + UInt32 syncword = *(pSyncword); + + + /* + * Determine the maximum number of bits available to this function for + * the syncword search. + */ + if ((Int)pInputStream->usedBits < + ((Int)pInputStream->availableBits - syncword_length)) + { + search_length = (pInputStream->availableBits - pInputStream->usedBits); + + search_length -= syncword_length; + + adts_header = getbits(syncword_length, pInputStream); + + /* + * Mask the result in adts_header with the syncword_mask, so only the + * bits relevant to syncword detection are compared to *(pSyncword). + */ + test_for_syncword = adts_header & syncword_mask; + test_for_syncword ^= syncword; + + /* + * Scan byte-by-byte through the bitstream, until the function either + * runs out of bytes, or finds the syncword. + */ + + while ((test_for_syncword != 0) && (search_length > 0)) + { + search_length -= 8; + + adts_header <<= 8; + adts_header |= get9_n_lessbits(8, pInputStream); + + test_for_syncword = adts_header & syncword_mask; + test_for_syncword ^= syncword; + } + + if (search_length <= 0) + { + status = MP4AUDEC_LOST_FRAME_SYNC; + } + + *(pSyncword) = adts_header; + + } /* END if (pInputStream->usedBits < ...) */ + else + { + status = MP4AUDEC_LOST_FRAME_SYNC; + } + + return (status); + +} /* find_adts_syncword() */ + + + +/*---------------------------------------------------------------------------- + FUNCTION DESCRIPTION + + This module get the distance in bytes between the current and next sync word + then compare the content of the fix header (28 bits). + + If no match is found, the function returns + status == MP4AUDEC_LOST_FRAME_SYNC, and reset the success counter *pInvoke + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + adts_var_header 28 bit content of the variable part of the adts header + [UInt32] + + pSyncword = Pointer to variable containing the syncword that the + function should be scanning for in the buffer. [ UInt32 * ] + + pInputStream = Pointer to a BITS structure, used by the function getbits + to retrieve data from the bitstream. [ BITS * ] + + pInvoke = Pointer holding the success adts counter. [ Int * ] + + +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +Int validate_adts_syncword( + UInt32 adts_var_header, + UInt32 *pSyncword, + BITS *pInputStream, + Int *pInvoke) +{ + + UInt32 frame_length; + UInt32 tmp; + Int status = SUCCESS; + + /* + * frame_length is a 13-bit field which indicates the length, + * in bytes, of the frame including error_check and headers. + * This information can theoretically be used to help verify syncwords. + * adts_var_header is 28 bits long, need to remove 13-bit conformed by + * buffer fullnes and headerless frame info , and mask the rest + */ + frame_length = ((UInt)(adts_var_header >> 13)) & 0x1FFF; + + /* push current location, to validate 2 consecutive sync words */ + tmp = pInputStream->usedBits; + + /* Jump to next sync word, based on info on the header */ + pInputStream->usedBits += (frame_length << 3) + - LENGTH_FIXED_HEADER - LENGTH_VARIABLE_HEADER; + + + if ((Int)pInputStream->usedBits < + ((Int)pInputStream->availableBits - LENGTH_FIXED_HEADER)) + { + uint32 temp = getbits(LENGTH_FIXED_HEADER, pInputStream); + /* + * Check if fixed header in the very next predicted frame matches + */ + if ((*(pSyncword) & MASK_28BITS) != temp) + { + *(pInvoke) = 0; /* reset valid adts frame counter */ + status = MP4AUDEC_LOST_FRAME_SYNC; /* no match means a false lock on sync word */ + } + } + else + { + status = MP4AUDEC_LOST_FRAME_SYNC; /* no match means a false lock on sync word */ + } + /* pop current location */ + pInputStream->usedBits = tmp; + + return (status); + +} /* validate_adts_syncword() */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/find_adts_syncword.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/find_adts_syncword.h new file mode 100644 index 0000000..c90b869 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/find_adts_syncword.h @@ -0,0 +1,109 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: find_adts_syncword.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This function includes the function declaration for find_adts_syncword() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef FIND_ADTS_SYNCWORD_H +#define FIND_ADTS_SYNCWORD_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_bits.h" +#include "pvmp4audiodecoder_api.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define LENGTH_VARIABLE_HEADER 28 +#define LENGTH_FIXED_HEADER 28 +#define LENGTH_CRC 16 + +#define LENGTH_SYNCWORD 16 +#define ID_BIT_FILTER 0xFFF0 +#define SYNCWORD_15BITS 0xFFF0 + +#define MASK_28BITS 0x0FFFFFFFL + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + + Int find_adts_syncword( + UInt32 *pSyncword, + BITS *pInputStream, + Int syncword_length, + UInt32 syncword_mask); + + Int validate_adts_syncword( + UInt32 adts_var_header, + UInt32 *pSyncword, + BITS *pInputStream, + Int *pInvoke); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.cpp new file mode 100644 index 0000000..149eff3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.cpp @@ -0,0 +1,244 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fwd_long_complex_rot.cpp + Funtions: fwd_long_complex_rot + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Data_in = Input vector (sized for long windows + TWICE_FWD_LONG_CX_ROT_LENGTH), with time domain samples + type Int32 * + + Data_out = Output vector with a post-rotation by exp(-j(2pi/N)(k+1/8)), + (sized for long windows TWICE_FWD_LONG_CX_ROT_LENGTH) + type Int32 * + + max = Input, carries the maximum value of the input vector + "Data_in" + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exp = shift factor to reflect signal scaling + + Pointers and Buffers Modified: + Results are return in "Data_out" + + Local Stores Modified: + None + + Global Stores Modified: + None +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + fwd_long_complex_rot() performs the pre complex rotation for the MDCT + for the case of long windows. It also performs digit reverse ordering of + the first and second halves of the input vector "Data_in", as well as + reordering of the two half vectors (following radix-2 decomposition) + Word normalization is also done to ensure 16 by 16 bit multiplications. + +------------------------------------------------------------------------------ + REQUIREMENTS + + fwd_long_complex_rot() should execute a pre-rotation by + exp(-j(2pi/N)(k+1/8)), digit reverse ordering and normalization +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "fwd_long_complex_rot.h" +#include "digit_reversal_tables.h" +#include "imdct_fxp.h" +#include "pv_normalize.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +Int fwd_long_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max) +{ + Int i; + const Int32 *p_rotate; + Int32 temp_re; + Int32 temp_im; + Int32 *pData_in_ref1; + Int32 *pData_in_ref2; + Int32 exp_jw; + Int32 temp_re_32; + Int32 temp_im_32; + + Int32 *pData_out_1; + Int32 *pData_out_2; + Int32 *pData_out_3; + Int32 *pData_out_4; + + Int32 *pData_in_1; + Int32 *pData_in_2; + + Int exp; + + p_rotate = exp_rotation_N_2048; + + pData_in_ref1 = Data_in; + pData_in_ref2 = &Data_in[TWICE_FWD_LONG_CX_ROT_LENGTH]; + + pData_out_1 = Data_out; + pData_out_2 = &Data_out[LONG_WINDOW_LENGTH_m_1]; + pData_out_3 = &Data_out[LONG_WINDOW_LENGTH]; + pData_out_4 = &Data_out[TWICE_LONG_WINDOW_LENGTH_m_1]; + + /* + * Data_out + * >>>> <<<< + * pData_out_3 pData_out_4 + * | | | | | + * pData_out_1 pData_out_2 + * >>>> <<<< + */ + + + exp = 16 - pv_normalize(max); + + if (exp < 0) + { + exp = 0; + } + + /* + * Apply A/2^(diff) + B + */ + + + pData_in_1 = pData_in_ref1; + pData_in_2 = pData_in_ref2; + + for (i = FWD_LONG_CX_ROT_LENGTH; i != 0; i--) + { + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + exp_jw = *p_rotate++; + + /* + * Use auxiliary variables to avoid double accesses to memory. + * Data in is scaled to use only lower 16 bits. + */ + + temp_re = *(pData_in_1++) >> exp; + temp_im = *(pData_in_1++) >> exp; + + /* + * Pre-rotation + */ + + temp_re_32 = (cmplx_mul32_by_16(temp_re, temp_im, exp_jw)); + temp_im_32 = (cmplx_mul32_by_16(temp_im, -temp_re, exp_jw)); + + *(pData_out_1++) = - temp_re_32; + *(pData_out_2--) = temp_im_32; + *(pData_out_3++) = - temp_im_32; + *(pData_out_4--) = temp_re_32; + + /* + * Pointer increment to jump over imag (1 & 4) or real parts + * (2 & 3) + */ + pData_out_1++; + pData_out_2--; + pData_out_3++; + pData_out_4--; + + /* + * Repeat procedure for odd index at the output + */ + + exp_jw = *p_rotate++; + + temp_re = *(pData_in_2++) >> exp; + temp_im = *(pData_in_2++) >> exp; + + temp_re_32 = (cmplx_mul32_by_16(temp_re, temp_im, exp_jw)); + temp_im_32 = (cmplx_mul32_by_16(temp_im, -temp_re, exp_jw)); + + *(pData_out_1++) = - temp_re_32; + *(pData_out_2--) = temp_im_32; + *(pData_out_3++) = - temp_im_32; + *(pData_out_4--) = temp_re_32; + + pData_out_1++; + pData_out_2--; + pData_out_3++; + pData_out_4--; + + } + + return (exp + 1); +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.h new file mode 100644 index 0000000..fb5060b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fwd_long_complex_rot.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions fwd_long_complex_rot + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef FWD_LONG_COMPLEX_ROT_H +#define FWD_LONG_COMPLEX_ROT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define FWD_LONG_CX_ROT_LENGTH 256 +#define TWICE_FWD_LONG_CX_ROT_LENGTH (FWD_LONG_CX_ROT_LENGTH<<1) +#define LONG_WINDOW_LENGTH 1024 +#define LONG_WINDOW_LENGTH_m_1 (LONG_WINDOW_LENGTH - 1) +#define TWICE_LONG_WINDOW_LENGTH_m_1 ((LONG_WINDOW_LENGTH<<1) - 1) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + + +Int fwd_long_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* FWD_LONG_COMPLEX_ROT_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.cpp new file mode 100644 index 0000000..002b377 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.cpp @@ -0,0 +1,222 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: fwd_short_complex_rot.cpp + Funtions: fwd_short_complex_rot + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Data_in = Input vector (sized for short windows + 2*FWD_SHORT_CX_ROT_LENGTH elements), with freq. domain samples + type Int32 * + + Data_out = Output vector with a post-rotation by exp(-j(2pi/N)(k+1/8)), + (sized for short windows 2*FWD_SHORT_CX_ROT_LENGTH) + type Int32 * + + max = Input, carries the maximum value of the input vector + "Data_in" + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exp = shift factor to reflect signal scaling + + Pointers and Buffers Modified: + Results are return in "Data_out" + + Local Stores Modified: + None + + Global Stores Modified: + None +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + fwd_short_complex_rot() performs the complex rotation for the MDCT + for the case of short windows. It performs digit reverse ordering as well + word normalization to ensure 16 by 16 bit multiplications. + +------------------------------------------------------------------------------ + REQUIREMENTS + + fwd_short_complex_rot() should execute a pre-rotation by + exp(-j(2pi/N)(k+1/8)), digit reverse ordering and word normalization +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "fwd_short_complex_rot.h" +#include "digit_reversal_tables.h" +#include "imdct_fxp.h" +#include "pv_normalize.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +Int fwd_short_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max) + +{ + Int i; + Int16 I; + const Int16 *pTable; + const Int32 *p_rotate; + + Int32 *pData_in_1; + Int exp; + Int32 temp_re; + Int32 temp_im; + + Int32 cos_n; + Int32 sin_n; + Int32 temp_re_32; + Int32 temp_im_32; + + Int32 *pData_in_ref; + + Int32 *pData_out_1; + Int32 *pData_out_2; + Int32 *pData_out_3; + Int32 *pData_out_4; + + pTable = digit_reverse_64; + p_rotate = exp_rotation_N_256; + + pData_in_ref = Data_in; + + exp = 16 - pv_normalize(max); + + if (exp < 0) + { + exp = 0; + } + + pData_out_1 = Data_out; + pData_out_2 = &Data_out[TWICE_FWD_SHORT_CX_ROT_LENGTH_m_1]; + pData_out_3 = &Data_out[TWICE_FWD_SHORT_CX_ROT_LENGTH]; + pData_out_4 = &Data_out[FOUR_FWD_SHORT_CX_ROT_LENGTH_m_1]; + + /* + * Data_out + * >>>> <<<< + * pData_out_3 pData_out_4 + * | | | | | + * pData_out_1 pData_out_2 + * >>>> <<<< + */ + + + for (i = FWD_SHORT_CX_ROT_LENGTH; i != 0; i--) + { + /* + * Perform digit reversal by accessing index I from table + */ + + I = *pTable++; + pData_in_1 = pData_in_ref + I; + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + sin_n = *p_rotate++; + cos_n = sin_n >> 16; + sin_n = sin_n & 0xFFFF; + + /* + * Use auxiliary variables to avoid double accesses to memory. + * Data in is scaled to use only lower 16 bits. + */ + + temp_re = *(pData_in_1++) >> exp; + temp_im = *(pData_in_1) >> exp; + + /* + * Pre-rotation + */ + + temp_re_32 = (temp_re * cos_n + temp_im * sin_n) >> 16; + temp_im_32 = (temp_im * cos_n - temp_re * sin_n) >> 16; + + *(pData_out_1++) = - temp_re_32; + *(pData_out_2--) = temp_im_32; + *(pData_out_3++) = - temp_im_32; + *(pData_out_4--) = temp_re_32; + + /* + * Pointer increment to jump over imag (1 & 4) or real parts + * (2 & 3) + */ + + pData_out_1++; + pData_out_2--; + pData_out_3++; + pData_out_4--; + + } /* for(i) */ + + return (exp); +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.h new file mode 100644 index 0000000..2d98daa --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fwd_short_complex_rot.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions fwd_short_complex_rot + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef FWD_SHORT_COMPLEX_ROT_H +#define FWD_SHORT_COMPLEX_ROT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define FWD_SHORT_CX_ROT_LENGTH 64 +#define TWICE_FWD_SHORT_CX_ROT_LENGTH (FWD_SHORT_CX_ROT_LENGTH<<1) +#define TWICE_FWD_SHORT_CX_ROT_LENGTH_m_1 ((FWD_SHORT_CX_ROT_LENGTH<<1) - 1) +#define FOUR_FWD_SHORT_CX_ROT_LENGTH_m_1 ((FWD_SHORT_CX_ROT_LENGTH<<2) - 1) +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int fwd_short_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* FWD_SHORT_COMPLEX_ROT_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32.h new file mode 100644 index 0000000..fc9b2d9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32.h @@ -0,0 +1,45 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ +#ifndef FXP_MUL32 +#define FXP_MUL32 + +#include "oscl_base_macros.h"// has integer values of PV_COMPILER + +#if ((PV_COMPILER == EPV_ARM_GNUC) && (PV_CPU_ARCH_VERSION >=5)) +#include "fxp_mul32_arm_gcc.h" + +#else/*#else for PV__PROCESSOR__PENTIUM*/ + +#ifndef C_EQUIVALENT +#define C_EQUIVALENT +#endif/*#endif for C_EQUIVALENT*/ + +#include "fxp_mul32_c_equivalent.h" + +#endif/*#endif for PV__PROCESSOR__PENTIUM*/ + +#endif /* FXP_MUL32 */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_gcc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_gcc.h new file mode 100644 index 0000000..cc63c33 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_gcc.h @@ -0,0 +1,536 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_arm_gcc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef FXP_MUL32_ARM_GCC +#define FXP_MUL32_ARM_GCC + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#include "pv_audio_type_defs.h" + + + +#define preload_cache( a) + + + static inline Int32 shft_lft_1(Int32 y) + { + register Int32 x; + register Int32 ra = y; + + + asm volatile( + "qadd %0, %1, %1\n\t" + : "=&r*i"(x) + : "r"(ra)); + + return (x); + } + + static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, const Int32 L_var2) + { + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smulbb %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + + +#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b) + + + static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, const Int32 L_var2) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smultb %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + + static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, const Int32 L_var2) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smulbt %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + + static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, const Int32 L_var2) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smultt %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + + static inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add) +{ + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "smlabb %0, %1, %2, %3" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp); + } + + + + static inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, const Int32 L_var2, Int32 L_add) +{ + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "smlabb %0, %1, %2, %3" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp); + } + + + static inline Int32 fxp_mac_16_by_16_bt(const Int32 L_var1, const Int32 L_var2, Int32 L_add) +{ + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "smlabt %0, %1, %2, %3" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp); + } + + + + static inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw) +{ + register Int32 cx_sum; + register Int32 rx = (Int32)x; + register Int32 ry = (Int32)y; + register Int32 rexp = (Int32)exp_jw; + asm volatile( + "smulwt %0, %1, %3\n\t" + "smlawb %0, %2, %3, %0" + : "=&r*i"(cx_sum) + : "r"(rx), + "r"(ry), + "r"(rexp)); + + return (cx_sum); + } + + + static inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smulwb %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + +#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b) + + + static inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smulwt %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + + + + static inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "smlawb %0, %1, %2, %3" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp); + } + + + __inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2) +{ + sum += (int64)L_var1 * L_var2; + return (sum); + } + + + + + static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) + { + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %4, %4, %0, asl #2\n\t" + "add %0, %4, %1, lsr #30" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b) +{ + + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %0, %0, %4" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + + static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_sub; + + asm volatile("smull %1, %0, %2, %3\n\t" + "sub %0, %4, %0" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile( + "smull %1, %0, %2, %3" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #2\n\t" + "orr %0, %0, %1, lsr #30" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + + + static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %4, %4, %0, lsl #3\n\t" + "add %0, %4, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_sub; + + asm volatile("smull %1, %0, %2, %3\n\t" + "sub %4, %4, %0, lsl #3\n\t" + "sub %0, %4, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #3\n\t" + "orr %0, %0, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + + + static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #4\n\t" + "orr %0, %0, %1, lsr #28" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #5\n\t" + "orr %0, %0, %1, lsr #27" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #6\n\t" + "orr %0, %0, %1, lsr #26" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #12\n\t" + "orr %0, %0, %1, lsr #20" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #17\n\t" + "orr %0, %0, %1, lsr #15" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + + static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #18\n\t" + "orr %0, %0, %1, lsr #14" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32 */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4_gcc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4_gcc.h new file mode 100644 index 0000000..ce748ff --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4_gcc.h @@ -0,0 +1,620 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_arm_v4_gcc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + + + +#ifndef FXP_MUL32_V4_ARM_GCC +#define FXP_MUL32_V4_ARM_GCC + + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#include "pv_audio_type_defs.h" + +#define preload_cache( a) + + + static inline Int32 shft_lft_1(Int32 L_var1) + { + Int32 x; + register Int32 ra = L_var1; + Int32 z = INT32_MAX; + + asm volatile( + "mov %0, %1, asl #1\n\t" + "teq %1, %0, asr #1\n\t" + "eorne %0, %2, %1, asr #31" + : "=&r*i"(x) + : "r"(ra), + "r"(z)); + + return(x); + } + + static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %3, asl #16\n\t" + "mov %0, %0, asr #16\n\t" + "mov %1, %2, asl #16\n\t" + "mov %1, %1, asr #16\n\t" + "mul %0, %1, %0" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb)); + + return (tmp1); + + } + +#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b) + + + static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %3, asl #16\n\t" + "mov %0, %0, asr #16\n\t" + "mov %1, %2, asr #16\n\t" + "mul %0, %1, %0" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb)); + + return (tmp1); + + } + + + static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %3, asr #16\n\t" + "mov %1, %2, asl #16\n\t" + "mov %1, %1, asr #16\n\t" + "mul %0, %1, %0" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb)); + + return (tmp1); + + } + + + static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %3, asr #16\n\t" + "mov %1, %2, asr #16\n\t" + "mul %0, %1, %0" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb)); + + return (tmp1); + + } + + + + static inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add) +{ + + Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "mla %0, %1, %2, %3" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp); + } + + + + static inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "mov %0, %3, asl #16\n\t" + "mov %0, %0, asr #16\n\t" + "mla %1, %0, %2, %4" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp2); + } + + + + static inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "mov %0, %3, asr #16\n\t" + "mla %1, %0, %2, %4" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp2); + + } + + + + static inline Int32 cmplx_mul32_by_16(Int32 x, Int32 y, Int32 exp_jw) +{ + + Int32 rTmp0; + Int32 iTmp0; + Int32 result64_hi; + register Int32 ra = (Int32)x; + register Int32 rb = (Int32)y; + register Int32 rc = (Int32)exp_jw; + + + + asm volatile( + "mov %0, %5, asr #16\n\t" + "mov %1, %5, asl #16\n\t" + "mov %0, %0, asl #16\n\t" + : "=&r*i"(rTmp0), + "=&r*i"(iTmp0), + "=&r*i"(result64_hi) + : "r"(ra), + "r"(rb), + "r"(rc)); + + + asm volatile( + "smull %0, %2, %3, %0\n\t" + "smlal %1, %2, %4, %1" + : "=&r*i"(rTmp0), + "=&r*i"(iTmp0), + "=&r*i"(result64_hi) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + + + } + + + static inline Int32 fxp_mul32_by_16(Int32 L_var1, Int32 L_var2) +{ + + Int32 rTmp0; + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %4, asl #16\n\t" + "smull %2, %1, %0, %3" + : "=&r*i"(rTmp0), + "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + +#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b) + + + + static inline Int32 fxp_mul32_by_16t(Int32 L_var1, Int32 L_var2) +{ + + Int32 rTmp0; + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %4, asr #16\n\t" + "mov %0, %0, asl #16\n\t" + "smull %2, %1, %0, %3" + : "=&r*i"(rTmp0), + "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + + static inline Int32 fxp_mac32_by_16(Int32 L_var1, Int32 L_var2, Int32 L_add) +{ + + Int32 rTmp0; + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "mov %0, %4, asl #16\n\t" + "mov %1, %5\n\t" + "smlal %2, %1, %0, %3" + : "=&r*i"(rTmp0), + "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + static inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2) +{ + sum += (int64)L_var1 * L_var2; + return (sum); + } + + + static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) + { + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %4, %4, %0, asl #2\n\t" + "add %0, %4, %1, lsr #30" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b) +{ + + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %0, %0, %4" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + + static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_sub; + + asm volatile("smull %1, %0, %2, %3\n\t" + "sub %0, %4, %0" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile( + "smull %1, %0, %2, %3" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #2\n\t" + "orr %0, %0, %1, lsr #30" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + + + static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %4, %4, %0, lsl #3\n\t" + "add %0, %4, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_sub; + + asm volatile("smull %1, %0, %2, %3\n\t" + "sub %4, %4, %0, lsl #3\n\t" + "sub %0, %4, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #3\n\t" + "orr %0, %0, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + + + static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #4\n\t" + "orr %0, %0, %1, lsr #28" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #5\n\t" + "orr %0, %0, %1, lsr #27" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #6\n\t" + "orr %0, %0, %1, lsr #26" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #12\n\t" + "orr %0, %0, %1, lsr #20" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #17\n\t" + "orr %0, %0, %1, lsr #15" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + + static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #18\n\t" + "orr %0, %0, %1, lsr #14" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32_V4_ARM_GCC */ + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32_c_equivalent.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32_c_equivalent.h new file mode 100644 index 0000000..faf6eec --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/fxp_mul32_c_equivalent.h @@ -0,0 +1,275 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_c_equivalent.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef FXP_MUL32_C_EQUIVALENT +#define FXP_MUL32_C_EQUIVALENT + + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#include "pv_audio_type_defs.h" + + +#if defined(C_EQUIVALENT) + +#define preload_cache( a) + + __inline Int32 shft_lft_1(Int32 L_var1) + { + if (((L_var1 << 1) >> 1) == L_var1) + L_var1 <<= 1; + else + L_var1 = ((L_var1 >> 31) ^ INT32_MAX); + + return (L_var1); + + } + + + __inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2) + { + L_var2 = (L_var2 << 16) >> 16; + L_var1 = (L_var1 << 16) >> 16; + + L_var1 *= L_var2; + + return L_var1; + + } + + +#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b) + + + __inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2) + { + L_var2 = (L_var2 << 16) >> 16; + L_var1 = L_var1 >> 16; + + L_var1 *= L_var2; + + return L_var1; + + } + + + __inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2) + { + L_var2 = L_var2 >> 16; + L_var1 = (L_var1 << 16) >> 16; + + L_var1 *= L_var2; + + return L_var1; + + } + + + __inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2) + { + L_var2 = L_var2 >> 16; + L_var1 = L_var1 >> 16; + + L_var1 *= L_var2; + + return L_var1; + + } + + __inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add) + { + + L_add += L_var1 * L_var2; + + return L_add; + + } + + + + + + __inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add) + { + L_var2 = (L_var2 << 16) >> 16; + + L_add += L_var1 * L_var2; + + return L_add; + + } + + + __inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add) + { + L_var2 = L_var2 >> 16; + + L_add += L_var1 * L_var2; + + return L_add; + + } + + + __inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw) + { + Int32 rTmp0 = (Int16)(exp_jw >> 16); + Int32 iTmp0 = exp_jw; + Int32 z; + + z = (Int32)(((int64)x * (rTmp0 << 16)) >> 32); + z += (Int32)(((int64)y * (iTmp0 << 16)) >> 32); + + return (z); + } + + + __inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2) + { + Int32 z; + + z = (Int32)(((int64) L_var1 * (L_var2 << 16)) >> 32); + return(z); + } + + +#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b) + + + __inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2) + { + Int32 rTmp0 = (Int16)(L_var2 >> 16); + Int32 z; + + z = (Int32)(((int64) L_var1 * (rTmp0 << 16)) >> 32); + + return(z); + } + + + __inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + Int32 rTmp0 = L_var2 << 16; + + L_add += (Int32)(((int64) L_var1 * rTmp0) >> 32); + + return(L_add); + } + + __inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2) + { + sum += (int64)L_var1 * L_var2; + return (sum); + } + + __inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 32); + } + + __inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b) + { + return (L_add + (Int32)(((int64)(a) * b) >> 32)); + } + + __inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b) + { + return (L_sub - (Int32)(((int64)(a) * b) >> 32)); + } + + + __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 30); + } + + __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) + { + return (L_add + (Int32)(((int64)(a) * b) >> 30)); + } + + + __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 29); + } + + __inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add) + { + return (L_add + (Int32)(((int64)(a) * b) >> 29)); + } + + __inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub) + { + return (L_sub - (Int32)(((int64)(a) * b) >> 29)); + } + + + __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 28); + } + + __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 27); + } + + __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 26); + } + + __inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 20); + } + + __inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 15); + } + + __inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 14); + } + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32 */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/gen_rand_vector.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/gen_rand_vector.cpp new file mode 100644 index 0000000..3c4217e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/gen_rand_vector.cpp @@ -0,0 +1,456 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Description: +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: random_array[] = Array for storage of the power-scaled + random values of length "band_length" + Int32 + + band_length = Length of random_array[] + const Int + + pSeed = seed for random number generator + Int32* + + power_scale = scale factor for this particular band + const Int + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: Function returns the q-format the random vector is stored in. + + Pointers and Buffers Modified: + random_array[] = filled with random numbers scaled + to the correct power as defined by the input value power_scale. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function generates a vector of uniformly distributed random numbers for + the PNS block. The random numbers are each scaled by a scale_factor, + defined in Ref(2) as + + 2^(scale_factor/4) + ------------------ + sqrt(N*MEAN_NRG) + + where N == band_length, and MEAN_NRG is defined as... + + N-1 + ___ + 1 \ + --- > x(i)^2 + N /__ + i=0 + + And x is the unscaled vector from the random number generator. + + This function takes advantage of the fact that the portion of the + scale_factor that is divisible by 4 can be simply accounted for by varying + the q-format. + + The scaling of the random numbers is thus broken into the + equivalent equation below. + + 2^(scale_factor%4) 2^(floor(scale_factor/4)) + ------------------ * + sqrt(N*MEAN_NRG) + + + 2^(scale_factor%4) is stored in a simple 4-element table. + 2^(floor(scale_factor/4) is accounted for by adjusting the q-format. + sqrt(N*MEAN_NRG) is calculated and implemented via a polynomial approximation. +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall produce uniformly distributed random 32-bit integers, + with signed random values of average energy equal to the results of the ISO + code's multiplying factor discussed in the FUNCTION DESCRIPTION section. + + Please see Ref (2) for a detailed description of the requirements. +------------------------------------------------------------------------------ + REFERENCES + + (1) Numerical Recipes in C Second Edition + William H. Press Saul A. Teukolsky + William T. Vetterling Brian P. Flannery + Page 284 + + (2) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.12 (Perceptual Noise Substitution) + + (3) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + power_adj = scale_mod_4[power_scale & 3]; + + power = 0; + + FOR (k=band_length; k > 0; k--) + + *(pSeed) = *(pSeed) * 1664525L; + *(pSeed) = *(pSeed) + 1013904223L; + + temp = (Int)(*(pSeed) >> 16); + + power = power + ((temp*temp) >> 6); + + *(pArray) = (Int32)temp; + + pArray = pArray + 1; + + ENDFOR + + k = 0; + q_adjust = 30; + + IF (power) + THEN + + WHILE ( power > 32767) + + power = power >> 1; + k = k + 1; + + ENDWHILE + + k = k - 13; + + IF (k < 0) + THEN + k = -k; + IF ( k & 1 ) + THEN + power_adj = (power_adj*SQRT_OF_2)>>14; + ENDIF + q_adjust = q_adjust - ( k >> 1); + + ELSE IF (k > 0) + THEN + IF ( k & 1 ) + THEN + power_adj = (power_adj*INV_SQRT_OF_2)>>14; + ENDIF + q_adjust = q_adjust + ( k >> 1); + ENDIF + + pInvSqrtCoeff = inv_sqrt_coeff; + + inv_sqrt_power = (*(pInvSqrtCoeff)* power) >>15; + + pInvSqrtCoeff = pInvSqrtCoeff + 1; + + inv_sqrt_power = inv_sqrt_power + *(pInvSqrtCoeff); + + pInvSqrtCoeff = pInvSqrtCoeff + 1; + + FOR ( k=INV_SQRT_POLY_ORDER - 1; k>0; k--) + + inv_sqrt_power = ( inv_sqrt_power * power)>>15; + + inv_sqrt_power = inv_sqrt_power + *(pInvSqrtCoeff); + + pInvSqrtCoeff = pInvSqrtCoeff + 1; + + ENDFOR + + inv_sqrt_power = (inv_sqrt_power*power_adj)>>13; + + FOR (k=band_length; k > 0; k--) + + pArray = pArray - 1; + + *(pArray) = *(pArray)*inv_sqrt_power; + + ENDFOR + + ENDIF + + q_adjust = q_adjust - (power_scale >> 2); + + return q_adjust; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "gen_rand_vector.h" +#include "window_block_fxp.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define SQRT_OF_2 23170 /* sqrt(2) in Q14 */ +#define INV_SQRT_OF_2 11585 /* 1/sqrt(2) in Q14 */ +#define INV_SQRT_POLY_ORDER 4 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + + +/* + * 2^([0:3]/4) = 1.0000 1.1892 1.4142 1.6818 + */ +const UInt scale_mod_4[4] = { 16384, 19484, 23170, 27554}; + +/* + * polynomial approx. in Q12 (type Int) + */ + +const Int inv_sqrt_coeff[INV_SQRT_POLY_ORDER+1] = + { 4680, -17935, 27697, -22326, 11980}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int gen_rand_vector( + Int32 random_array[], + const Int band_length, + Int32* pSeed, + const Int power_scale) +{ + + Int k; + UInt power_adj; + Int q_adjust = 30; + + Int32 temp; + Int32 seed; + Int32 power; + + Int32* pArray = &random_array[0]; + + Int32 inv_sqrt_power; + const Int *pInvSqrtCoeff; + + /* + * The out of the random number generator is scaled is such a way + * that is independent of the band length. + * The output is computed as: + * + * x(i) + * output = ------------------ * 2^(power_scale%4) 2^(floor(power_scale/4)) + * bl + * sqrt( SUM x(i)^2 ) + * 0 + * + * bl == band length + */ + + + /* + * get 2^(power_scale%4) + */ + + + power = 0; + + seed = *pSeed; + + /* + * band_length is always an even number (check tables in pg.66 IS0 14496-3) + */ + if (band_length < 0 || band_length > LONG_WINDOW) + { + return q_adjust; /* avoid any processing on error condition */ + } + + for (k = (band_length >> 1); k != 0; k--) + { + /*------------------------------------------------ + Numerical Recipes in C + Page 284 + ------------------------------------------------*/ + seed *= 1664525L; + seed += 1013904223L; + + temp = seed >> 16; + + seed *= 1664525L; + seed += 1013904223L; + + /* shift by 6 make room for band length accumulation */ + power += ((temp * temp) >> 6); + *pArray++ = temp; + + temp = seed >> 16; + power += ((temp * temp) >> 6); + *pArray++ = temp; + + } /* END for (k=half_band_length; k > 0; k--) */ + + + *pSeed = seed; + + /* + * If the distribution is uniform, the power is expected to use between + * 28 and 27 bits, by shifting down by 13 bits the power will be a + * Q15 number. + * For different band lengths, the power uses between 20 and 29 bits + */ + + + k = 0; + + if (power) + { + /* + * approximation requires power between 0.5 < power < 1 in Q15. + */ + + while (power > 32767) + { + power >>= 1; + k++; + } + + /* + * expected power bit usage == 27 bits + */ + + k -= 13; + + power_adj = scale_mod_4[power_scale & 3]; + + if (k < 0) + { + k = -k; + if (k & 1) + { /* multiply by sqrt(2) */ + power_adj = (UInt)(((UInt32) power_adj * SQRT_OF_2) >> 14); + } + q_adjust -= (k >> 1); /* adjust Q instead of shifting up */ + } + else if (k > 0) + { + if (k & 1) + { /* multiply by 1/sqrt(2) */ + power_adj = (UInt)(((UInt32) power_adj * INV_SQRT_OF_2) >> 14); + } + q_adjust += (k >> 1); /* adjust Q instead of shifting down */ + } + + /* + * Compute 1/sqrt(power), where 0.5 < power < 1.0 is approximated + * using a polynomial order INV_SQRT_POLY_ORDER + */ + + pInvSqrtCoeff = inv_sqrt_coeff; + + inv_sqrt_power = (*(pInvSqrtCoeff++) * power) >> 15; + inv_sqrt_power += *(pInvSqrtCoeff++); + inv_sqrt_power = (inv_sqrt_power * power) >> 15; + inv_sqrt_power += *(pInvSqrtCoeff++); + inv_sqrt_power = (inv_sqrt_power * power) >> 15; + inv_sqrt_power += *(pInvSqrtCoeff++); + inv_sqrt_power = (inv_sqrt_power * power) >> 15; + inv_sqrt_power += *(pInvSqrtCoeff); + + inv_sqrt_power = (inv_sqrt_power * power_adj) >> 13; + + pArray = &random_array[0]; + + for (k = (band_length >> 1); k != 0; k--) + { + temp = *(pArray) * inv_sqrt_power; + *(pArray++) = temp; + temp = *(pArray) * inv_sqrt_power; + *(pArray++) = temp; + } /* END for (k=half_band_length; k > 0; k--) */ + + } /* if(power) */ + + /* + * Adjust Q with the value corresponding to 2^(floor(power_scale/4)) + */ + + q_adjust -= (power_scale >> 2); + + return (q_adjust); + +} /* gen_rand_vector */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/gen_rand_vector.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/gen_rand_vector.h new file mode 100644 index 0000000..3ac5549 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/gen_rand_vector.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: gen_rand_vector.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the function declaration for gen_rand_vector. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef gen_rand_vector_H +#define gen_rand_vector_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int gen_rand_vector( + Int32 random_array[], + const Int band_length, + Int32 *pSeed, + const Int power_scale); +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adif_header.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adif_header.cpp new file mode 100644 index 0000000..1bca3b0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adif_header.cpp @@ -0,0 +1,395 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_adif_header.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that contains the current state + of this instance of the library, of data type pointer to + tDec_Int_File + + pScratchPCE = pointer to a ProgConfig structure used as scratch in the + the function get_prog_config. of data type pointer to + ProgConfig + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + The function returns 0 if no error occurred, non-zero otherwise. + + Pointers and Buffers Modified: + pVars->adif_header contents are updated with the some of the ADIF header + contents + pVars->tempProgConfig contents are overwritten with last PCE found, + which is most likely the first one found. + pVars->prog_config contents are updated with the first PCE found. + pVars->inputStream contents are modify in such a way that the + stream is moved further along in the buffer. + pVars->SFBWidth128 contents may be updated. + pVars->winSeqInfo contents may be updated. + pScratchPCE contents may be updated. + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads in the ADIF Header found at the front of ADIF streams. + If the header is not found an error is returned. An ADIF header can contain + from zero to sixteen program configuration elements (PCE). This function, and + the rest of the library, saves and uses the first PCE found. +------------------------------------------------------------------------------ + REQUIREMENTS + + Function shall not use static or global variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(), + page 16, and section 8.5 "Program Config Element (PCE)", page 30. + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + CALL getbits( + neededBits = 2 * LEN_BYTE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( theIDFromFile ) + + CALL getbits( + neededBits = 2 * LEN_BYTE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( temp ) + + theIDFromFile = (theIDFromFile << (2*LEN_BYTE)) | temp; + + IF (theIDFromFile != ADIF_ID) + THEN + + pInputStream->usedBits -= (4 * LEN_BYTE); + + status = -1; + ELSE + CALL getbits( + neededBits = LEN_COPYRT_PRES, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( temp ) + + IF (temp != FALSE) THEN + FOR (i = LEN_COPYRT_ID; i > 0; i--) + CALL getbits( + neededBits = LEN_BYTE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + + END FOR + END IF + + CALL getbits( + neededBits = LEN_ORIG + LEN_HOME, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + + CALL getbits( + neededBits = LEN_BS_TYPE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( bitStreamType ) + + CALL getbits( + neededBits = LEN_BIT_RATE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( pHeader->bitrate ) + + CALL getbits( + neededBits = LEN_NUM_PCE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( numConfigElementsMinus1 ) + + FOR ( i = numConfigElementsMinus1; + (i >= 0) && (status == SUCCESS); + i--) + + IF (bitStreamType == CONSTANT_RATE_BITSTREAM) THEN + CALL getbits( + neededBits = LEN_ADIF_BF, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + END IF + + CALL get_prog_config( + pVars = pVars) + MODIFYING( pVars->prog_config ) + RETURNING( status ) + + END FOR + END IF + + RETURN (status) + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_adif_const.h" + +#include "s_progconfig.h" +#include "s_adif_header.h" +#include "s_bits.h" +#include "s_mc_info.h" +#include "s_frameinfo.h" +#include "s_tdec_int_file.h" + +#include "get_prog_config.h" +#include "ibstream.h" + +#include "get_adif_header.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/* + * This constant is simply the characters 'A' 'D' 'I' 'F' compressed into + * a UInt32. Any possible endian problems that exist must be solved by + * the function that fills the buffer and getbits(), or this constant and + * the rest of the bit stream will not work. + */ +#define ADIF_ID (0x41444946) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +Int get_adif_header( + tDec_Int_File *pVars, + ProgConfig *pScratchPCE) +{ + Int i; + UInt32 temp; + Int numConfigElementsMinus1; + Int bitStreamType; + UInt32 theIDFromFile; + + BITS *pInputStream = &pVars->inputStream; + ADIF_Header *pHeader = &pVars->scratch.adif_header; + Int status = SUCCESS; + + /* + * The ADIF_ID field is 32 bits long, one more than what getbits() can + * do, so read the field in two parts. There is no point in saving the + * string - it either matches or it does not. If it matches, it must + * have been 'ADIF' + */ + + theIDFromFile = get17_n_lessbits((2 * LEN_BYTE), pInputStream); + + temp = get17_n_lessbits((2 * LEN_BYTE), pInputStream); + + theIDFromFile = (theIDFromFile << (2 * LEN_BYTE)) | temp; + + + if (theIDFromFile != ADIF_ID) + { + /* + * Rewind the bit stream pointer so a search for ADTS header + * can start at the beginning. + */ + + pInputStream->usedBits -= (4 * LEN_BYTE); + + /* + * The constant in the next line needs to be updated when + * error handling method is determined. + */ + status = -1; + } + else + { + /* + * To save space, the unused fields are read in, but not saved. + */ + + /* copyright string */ + temp = + get1bits(/* LEN_COPYRT_PRES,*/ + pInputStream); + + if (temp != FALSE) + { + /* + * Read in and ignore the copyright string. If restoring + * watch out for count down loop. + */ + + for (i = LEN_COPYRT_ID; i > 0; i--) + { + get9_n_lessbits(LEN_BYTE, + pInputStream); + } /* end for */ + + /* + * Make sure to terminate the string with '\0' if restoring + * the the copyright string. + */ + + } /* end if */ + + /* Combine the original/copy and fields into one call */ + get9_n_lessbits( + LEN_ORIG + LEN_HOME, + pInputStream); + + bitStreamType = + get1bits(/* LEN_BS_TYPE,*/ + pInputStream); + + pHeader->bitrate = + getbits( + LEN_BIT_RATE, + pInputStream); + + /* + * Read in all the Program Configuration Elements. + * For this library, only one of the up to 16 possible PCE's will be + * saved. Since each PCE must be read, a temporary PCE structure is + * used, and if that PCE is the one to use, it is copied into the + * single PCE. This is done inside of get_prog_config() + */ + + numConfigElementsMinus1 = get9_n_lessbits(LEN_NUM_PCE, + pInputStream); + + for (i = numConfigElementsMinus1; + (i >= 0) && (status == SUCCESS); + i--) + { + /* + * For ADIF contant bit rate streams, the _encoder_ buffer + * fullness is transmitted. This version of an AAC decoder has + * no use for this variable; yet it must be read in to move + * the bitstream pointers. + */ + + if (bitStreamType == CONSTANT_RATE_BITSTREAM) + { + getbits( + LEN_ADIF_BF, + pInputStream); + } /* end if */ + + pVars->adif_test = 1; + /* Get one program configuration element */ + status = + get_prog_config( + pVars, + pScratchPCE); + +#ifdef AAC_PLUS + + /* + * For implicit signalling, no hint that sbr or ps is used, so we need to + * check the sampling frequency of the aac content, if lesser or equal to + * 24 KHz, by defualt upsample, otherwise, do nothing + */ + if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == true) && + pVars->mc_info.audioObjectType == MP4AUDIO_AAC_LC) + { + pVars->mc_info.upsamplingFactor = 2; + pVars->prog_config.sampling_rate_idx -= 3; + pVars->mc_info.sbrPresentFlag = 1; + pVars->sbrDecoderData.SbrChannel[0].syncState = UPSAMPLING; + pVars->sbrDecoderData.SbrChannel[1].syncState = UPSAMPLING; + } +#endif + + + + } /* end for */ + + + } /* end 'else' of --> if (theIDFromFile != ADIF_ID) */ + + return status; + +} /* end get_adif_header */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adif_header.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adif_header.h new file mode 100644 index 0000000..0f8ecec --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adif_header.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_adif_header.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for get_adif_header.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_ADIF_HEADER_H +#define GET_ADIF_HEADER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define CONSTANT_RATE_BITSTREAM (0) +#define VARIABLE_RATE_BITSTREAM (1) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int get_adif_header( + tDec_Int_File *pVars, + ProgConfig *pScratchPCE); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adts_header.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adts_header.cpp new file mode 100644 index 0000000..ec80f2c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adts_header.cpp @@ -0,0 +1,662 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_adts_header.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = Pointer to structure that holds file-scope variables. + [ tDec_Int_File * ] + + pSyncword = Pointer to variable that holds the 28-bit fixed + header upon the exit of this function. [ UInt32 * ] + + pInvoke = Pointer to variable that keeps track of how many + "short" (14 bit) headers have been successfully + parsed from the bitstream. [ Int * ] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + Status = SUCCESS or ERROR CODE + + Pointers and Buffers Modified: + pVars->prog_config Updated with program information data as read from + the ADTS header. + + pSyncword Value pointed to is updated with the contents of + the 28-bit fixed header. + + pInvoke Value pointed to is updated to reflect the number + of successful "short" (14 bit) headers that have + been successfully parsed from the bitstream. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Acronym Definitions + ADTS Audio Data Transport Stream + CRC Cyclic Redundancy Code + + This function calls find_adts_syncword to find the next ADTS header. Until + three consistent headers have been read, the syncword used for detection + consists of the 12-bit syncword and the 2-bit Layer. After three consistent + headers are read, the entire fixed header is used for a robust 28-bit + syncword. + + Configuration information is then extracted from the bitstream. + + The bitstream information is packed as follows. + Comments about the correct interpretation of these bits are contained within + the code. + + CRC_absent sampling_rate_idx + \ / \ + \ / \ + \ Profile / \ UNUSED + \ / \ / \ / +|00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25| + \ _______________ / | \ / \ / + \-------|0xFFF syncword |-------/ | Layer == '00' for AAC \ / + \-------------/ | \ / + | \/ + ID == '1' for MPEG-2 AAC channel_config + copyright_id_bit == '0' for MPEG-4 AAC + / + home / + / / +|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42| + | \ \ _____________ / + | \ \--------|frame length |---------/ + orig_copy \ \-----------/ + \ ______________________________ + copyright_id_start | TOTAL HEADER LENGTH: 56 bits| + |-----------------------------| +|43|44|45|46|47|48|49|50|51|52|53|54|55| | FIXED HEADER BITS 00-27 | + \ _______________ / | | | VARIABLE HEADER BITS 28-55 | + \-----|buffer_fullness|----/ \ / |_____________________________| + \-------------/ | + headerless_frames + + In addition to the bits displayed above, if the value CRC_absent is '0' an + additional 16 bits corresponding to a CRC word are read from the bitstream, + following the header. +------------------------------------------------------------------------------ + REQUIREMENTS + + After the ADTS syncword is detected, this function shall parse the + information residing behind the syncword in the bitstream. +------------------------------------------------------------------------------ + REFERENCES + (1) ISO/IEC 13818-7:1997(E) + Part 7 + Subpart 6.2 (Audio_Data_Transport_Stream frame, ADTS) + + (2) ISO/IEC 11172-3:1993(E) + Part 3 + Subpart 2.4.3 The audio decoding process + + (3) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those UIntending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF (*(pInvoke) > 3) + + CALL find_adts_syncword( + pSyncword, + &(pVars->inputStream), + LENGTH_FIXED_HEADER, + MASK_28BITS); + RETURNING status + ELSE + + *(pSyncword) = SYNCWORD_15BITS; + + CALL find_adts_syncword( + pSyncword, + &(pVars->inputStream), + LENGTH_SYNCWORD, + ID_BIT_FILTER); + + MODIFYING *(pSyncword) = 28-bit fixed header (long syncword) + RETURNING status + + CALL getbits( + (LENGTH_FIXED_HEADER - LENGTH_SYNCWORD), + &(pVars->inputStream)); + + MODIFYING pVars->inputStream + RETURNING adts_header = remaining bits in the fixed header + + *(pSyncword) <<= 13; + *(pSyncword) = *(pSyncword) OR adts_header; + + pVars->prog_config.CRC_absent = ((UInt)(adts_header >> 12)) AND 0x0001; + + lower_16 = (UInt)adts_header; + + pVars->prog_config.profile = (lower_16 >> 10) AND 0x3; + + pVars->prog_config.sampling_rate_idx = (lower_16 >> 6) AND 0xF; + + channel_configuration = (lower_16 >> 2) AND 0x7; + + channel_configuration = channel_configuration - 1; + pVars->prog_config.front.ele_is_cpe[0] = channel_configuration; + + pVars->prog_config.front.num_ele = 1; + + pVars->prog_config.front.ele_tag[0] = 0; + + pVars->prog_config.mono_mix.present = 0; + pVars->prog_config.stereo_mix.present = 0; + pVars->prog_config.matrix_mix.present = 0; + + CALL set_mc_info( + &(pVars->mc_info), + &(pVars->savedMCInfo), + &(pVars->prog_config), + pVars->pWinSeqInfo, + pVars->SFBWidth128); + MODIFYING pVars->mc_info = multi-channel configuration information + RETURNING status = SUCCESS/FAILURE + + IF ( (*pInvoke) != 0) + CALL check_mc_info( + &(pVars->mc_info), + &(pVars->savedMCInfo), + FALSE); + RETURNING status = SUCCESS/FAILURE + ELSE + CALL check_mc_info( + &(pVars->mc_info), + &(pVars->savedMCInfo), + TRUE); + MODIFYING pVars->savedMCInfo = pVars->mc_info + RETURNING status = SUCCESS/FAILURE + ENDIF + + IF (status == SUCCESS) + (*pInvoke) = (*pInvoke) + 1; + ELSE + (*pInvoke) = 0; + ENDIF + + ENDIF + + CALL getbits( + LENGTH_VARIABLE_HEADER, + &(pVars->inputStream)); + RETURNING adts_header = 28-bits (the contents of the variable header.) + + pVars->prog_config.frame_length = ((UInt)(adts_header >> 13)) AND 0x1FFF; + + lower_16 = (UInt)adts_header; + + pVars->prog_config.buffer_fullness = (lower_16 >> 2) AND 0x7FF; + + pVars->prog_config.headerless_frames = (lower_16 AND 0x0003); + + IF (pVars->prog_config.CRC_absent == 0) + + CALL getbits( + LENGTH_CRC, + &(pVars->inputStream) ); + RETURNING pVars->prog_config.CRC_check = 16-bit CRC + + ENDIF + + pVars->default_config = 0; + + IF (byte_align_offset > 7) + status = 1; + ENDIF + + return (status); + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "s_tdec_int_file.h" +#include "ibstream.h" +#include "set_mc_info.h" +#include "find_adts_syncword.h" +#include "get_adts_header.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define NUM_OF_TRIES (5) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int get_adts_header( + tDec_Int_File *pVars, + UInt32 *pSyncword, + Int *pInvoke, + Int CorrectlyReadFramesCount) +{ + UInt32 adts_header; + UInt32 adts_var_header = 0; + UInt lower_16; + Int status = MP4AUDEC_LOST_FRAME_SYNC; + UInt channel_configuration; + + + /* + * Loop NUM_OF_TRIES times until succesfully locking into a sync word + * Success requires match and validation. + * Search is done over the available buffered data. + */ + for (int k = 0 ; ((k < NUM_OF_TRIES) && (status != SUCCESS)); k++) + { + status = SUCCESS; + + /* + * Sync words are always byte aligned + */ + byte_align(&(pVars->inputStream)); + + /* + * Search for the LONG ADTS syncword (comprised of the entire fixed header) + * if the number of CorrectlyReadFrames is > CorrectlyReadFramesCount + * + * Otherwise, search for just the short syncword. + */ + if (*(pInvoke) > CorrectlyReadFramesCount) + { + /* + * Find the long ADTS syncword + * (comprised of the entire ADTS fixed header) + */ + + status = find_adts_syncword(pSyncword, + &(pVars->inputStream), + LENGTH_FIXED_HEADER, + MASK_28BITS); + + if (status == MP4AUDEC_LOST_FRAME_SYNC) + { + break; /* No sync word found in the available data */ + } + + /* Grab the bits in the ADTS variable header */ + adts_var_header = getbits(LENGTH_VARIABLE_HEADER, &(pVars->inputStream)); + + /* + * Validate sync word by checking next header a the distance specified in + * the current header + */ + status = validate_adts_syncword(adts_var_header, + pSyncword, + &(pVars->inputStream), + pInvoke); + + if (status == MP4AUDEC_LOST_FRAME_SYNC) + { + pVars->inputStream.usedBits -= LENGTH_VARIABLE_HEADER; + + continue; /* No sync word could be validated, keep searching long sync word */ + } + } + else + { + + *(pSyncword) = SYNCWORD_15BITS; + + status = find_adts_syncword(pSyncword, + &(pVars->inputStream), + LENGTH_SYNCWORD, + ID_BIT_FILTER); + + if (status == MP4AUDEC_LOST_FRAME_SYNC) + { + break; /* No sync word found in the available data */ + } + + /* + * Extract the data from the header following the syncword + */ + adts_header = getbits((LENGTH_FIXED_HEADER - LENGTH_SYNCWORD), + &(pVars->inputStream)); + + /* Assembling possible long ADTS syncword */ + *(pSyncword) <<= (LENGTH_FIXED_HEADER - LENGTH_SYNCWORD); + *(pSyncword) |= adts_header; + + /* Grab the bits in the ADTS variable header */ + adts_var_header = getbits(LENGTH_VARIABLE_HEADER, &(pVars->inputStream)); + + /* + * Validate sync word by checking next header a the distance specified in + * the current header + */ + + status = validate_adts_syncword(adts_var_header, + pSyncword, + &(pVars->inputStream), + pInvoke); + + if (status == MP4AUDEC_LOST_FRAME_SYNC) + { + pVars->inputStream.usedBits -= (LENGTH_VARIABLE_HEADER + LENGTH_SYNCWORD); + + continue; /* No sync word could be validated, keep searching initial sync word */ + } + + /* + * All the unread bits in adts_header reside in the lower + * 16-bits at this point. Perform a typecast for faster + * execution on 16-bit processors. + */ + lower_16 = (UInt)adts_header; + + /* + * Profile consists of 2 bits, which indicate + * the profile used. + * + * '00' AAC_MAIN profile + * '01' AAC_LC (Low Complexity) profile + * '10' AAC_SSR (Scaleable Sampling Rate) profile + * '11' AAC_LTP (Long Term Prediction) profile + */ + pVars->prog_config.profile = (lower_16 >> 10) & 0x3; + + if ((pVars->prog_config.profile + 1) == MP4AUDIO_AAC_SSR || + (pVars->prog_config.profile + 1) == MP4AUDIO_AAC_MAIN) + { + status = 1; /* Not supported */ + } + + /* + * Sampling_rate_idx consists of 4 bits + * see Ref #1 for their interpretation. + */ + pVars->prog_config.sampling_rate_idx = (lower_16 >> 6) & 0xF; + + /* + * private_bit is a bit for private use. ISO/IEC will not make + * use of this bit in the future. + * + * We currently make no use of it, but parsing the information + * from the bitstream could be easily implemented with the + * following instruction... + * + * private_bit = (lower_16 & 0x0400) >> 10; + */ + + /* + * These 3 bits indicate the channel configuration used. + * + * If '0' then the channel configuration is unspecified here, + * and must be given by a program configuration element in + * the raw data block. + * + * If '1' then the channel configuration is MONO. + * If '2' then the channel configuration is STEREO + * + * 3-7 represent channel configurations which this library + * will not support in the forseeable future. + */ + channel_configuration = (lower_16 >> 2) & 0x7; + /* do not support more than 2 channels */ + if (channel_configuration > 2) + { + status = 1; + } + + /* + * The following 2 bits encode copyright information. + * original_copy is '0' if there is no copyright in the bitstream. + * '1' if the bitstream is copyright protected. + * + * home is '0' for a copy, '1' for an original. + * + * PacketVideo currently does nothing with this information, + * however, parsing the data from the bitstream could be easily + * implemented with the following instructions... + * + * original_copy = (lower_16 >> 1) & 0x1; + * + * home = (lower_16 & 0x1); + * + */ + + /* Set up based on information extracted from the ADTS FIXED header */ + + /* This equals 1 for STEREO, 0 for MONO */ + if (channel_configuration) + { + channel_configuration--; + } + pVars->prog_config.front.ele_is_cpe[0] = channel_configuration; + + /* This value is constant for both MONO and STEREO */ + pVars->prog_config.front.num_ele = 1; + + /* ADTS does not specify this tag value - do we even use it? */ + pVars->prog_config.front.ele_tag[0] = 0; + + /* Disable all mix related variables */ + pVars->prog_config.mono_mix.present = 0; + pVars->prog_config.stereo_mix.present = 0; + pVars->prog_config.matrix_mix.present = 0; + + /* enter configuration into MC_Info structure */ + if (status == SUCCESS) + { + /* profile + 1 == audioObjectType */ + status = set_mc_info( + &(pVars->mc_info), + (tMP4AudioObjectType)(pVars->prog_config.profile + 1), + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[0], + pVars->prog_config.front.ele_is_cpe[0], + pVars->winmap, /* changed from pVars->pWinSeqInfo, */ + pVars->SFBWidth128); + + } /* if (status == SUCCESS) */ + + +#ifdef AAC_PLUS + + /* default as adts has limited number of bits and can't carry this info */ + pVars->mc_info.ExtendedAudioObjectType = pVars->mc_info.audioObjectType; /* default */ + + /* + * For implicit signalling, no hint that sbr or ps is used, so we need to + * check the sampling frequency of the aac content, if lesser or equal to + * 24 KHz, by defualt upsample, otherwise, do nothing + */ + if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == TRUE)) + { + pVars->mc_info.upsamplingFactor = 2; + pVars->prog_config.sampling_rate_idx -= 3; + pVars->mc_info.sbrPresentFlag = 1; + pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_ACTIVE; + pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_ACTIVE; + } +#endif + + /* + * This keeps track of how many headers have been read in the file. + * After the three successful headers with the same configuration + * are read in, the entire ADTS fixed header is used as the syncword + * for a more robust 28-bit long syncword + */ + + if (status == SUCCESS) + { + (*pInvoke)++; + } + else + { + (*pInvoke) = 0; + } + + } /* END if (*(pInvoke) > 3) */ + } + + /* + * copyright_identification bit is a single bit of the 72-bit + * copyright_id field. This consists of a 8-bit copyright identifier + * and a 64-bit copyright_number. 72 headers must be decoded + * to reconstruct the entire copyright_id field. + * + * copyright_identification_start is a single bit flagging + * the beginning bit of the copyright_id field. '1' for start of + * copyright_id, '0' otherwise. + * + * + * PacketVideo currently does nothing with this information, + * however, parsing the data from the bitstream could be easily + * implemented with the following instructions... + * + * copyright_id_bit = ((UInt)(adts_header >> 27)) & 0x1; + * + * copyright_id_start = ((UInt)(adts_header >> 26)) & 0x1; + */ + + + /* + * All the unread bits in adts_header reside in the lower + * 16-bits at this point. Perform a typecast for faster + * execution on 16-bit processors. + */ + lower_16 = (UInt)adts_var_header; + + /* + * Indicates the number of 32-bit words remaining in the + * encoder buffer after the encoding of the first raw + * data block. This value is 0x7ff for variable bit + * rate encoders, since buffer fullness does not apply + * to Variable Bit Rate (VBR) encoders. + */ + pVars->prog_config.buffer_fullness = (lower_16 >> 2) & 0x7FF; + + + /* Denotes whether a CRC check should be performed 1 == NO, 0 == YES */ + pVars->prog_config.CRC_absent = + ((UInt)(*(pSyncword) >> (LENGTH_FIXED_HEADER - LENGTH_SYNCWORD))) & 1; + + /* + * headerless_frames indicates the number of + * frames with no headers to be processed before the reading + * in of the next header. + * + * In ADTS, up to 4 "no header frames" can exist between + * syncwords. + * + * EXAMPLES: + * + * Legend: (Sync words denoted by X, frames + * deonted by FRAME_#) + * + * Example(1): The ADTS sequence below packs 5 + * frames per header. + * Here, headerless_frames would always be read in as "4" + * + * |X||FRAME_0||FRAME_1||FRAME_2||FRAME_3||FRAME_4||X||FRAME_0| + * + * Example(2): The ADTS sequence below packs 1 frame per header. + * Here, headerless_frames would always be read in as "0" + * + * |X||FRAME_0||X||FRAME_1||X||FRAME_2| + * + */ + pVars->prog_config.headerless_frames = (lower_16 & 0x0003); + + if (pVars->prog_config.CRC_absent == 0) + { + pVars->prog_config.CRC_check = (UInt)getbits(LENGTH_CRC, + &(pVars->inputStream)); + } + + return (status); + +} /* END get_adts_header */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adts_header.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adts_header.h new file mode 100644 index 0000000..0bf711f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_adts_header.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_adts_header.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file has the function declaration for get_adts_header(). + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_ADTS_HEADER_H +#define GET_ADTS_HEADER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int get_adts_header( + tDec_Int_File *pVars, + UInt32 *pSyncword, + Int *pInvoke, + Int CorrectlyReadFramesCount); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_audio_specific_config.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_audio_specific_config.cpp new file mode 100644 index 0000000..369cffe --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_audio_specific_config.cpp @@ -0,0 +1,669 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_audio_specific_config.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that holds all information for + this instance of the library. pVars->prog_config is directly + used, and pVars->mc_info, pVars->prog_config, + pVars->pWinSeqInfo, pVars->SFBWidth128 are needed indirectly + for calling set_mc_info. Data type pointer to tDec_Int_File + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + status = 0 if successfully decoded AudioSpecificConfig + 1 if un-supported config is used for this release + + Pointers and Buffers Modified: + pVars->prog_config contents are updated with the information read in. + pVars->mc_info contents are updated with channel information. + pVars->pWinSeqInfo contents are updated with window information. + pVars->SFBWidth128 contents are updated with scale factor band width data. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads the bitstream for the structure "AudioSpecificConfig", + and sets the decoder configuration that is needed by the decoder to be able + to decode the media properly. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global variables + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + Part 3 + Subpart 1 p18 1.6 Interface to MPEG-4 Systems + Subpart 4 p13 4.4.1 GA Specific Configuration + Amendment p10 6.2.1 AudioSpecificInfo + Amendment p78 8.2 Decoder configuration (GASpecificConfig) + + (2) AAC DecoderSpecificInfo Information + PacketVideo descriptions - San Diego + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = SUCCESS; + + pInputStream = &(pVars->inputStream); + + temp = CALL getbits( + neededBits = LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX, + pInputStream = pInputStream) + MODIFYING (pInputStream) + RETURNING (temp) + + audioObjectType = (temp & 0x1f0) >> 4; + + pVars->prog_config.profile = audioObjectType; + + pVars->prog_config.sampling_rate_idx = temp & 0xf; + + IF (pVars->prog_config.sampling_rate_idx == 0xf) + THEN + sampling_rate = CALL getbits( + neededBits = LEN_SAMP_RATE, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (sampling_rate) + ENDIF + + channel_config = CALL getbits( + neededBits = LEN_CHAN_CONFIG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (channel_config) + + IF (channel_config > 2) + THEN + status = 1; + ENDIF + + IF (((audioObjectType == MP4AUDIO_AAC_MAIN) OR + (audioObjectType == MP4AUDIO_AAC_LC) OR + (audioObjectType == MP4AUDIO_AAC_SSR) OR + (audioObjectType == MP4AUDIO_LTP) OR + (audioObjectType == MP4AUDIO_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_TWINVQ)) AND (status == -1)) + THEN + status = CALL get_GA_specific_config( + pVars = pVars, + channel_config = channel_config, + audioObjectType = audioObjectType, + pInputStream = pInputStream); + MODIFYING (pVars->mc_info,channel_config,pInputStream) + RETURNING (status) + + ENDIF + + IF (audioObjectType == MP4AUDIO_CELP) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_HVXC) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_TTSI) + THEN + status = 1; + ENDIF + + IF ((audioObjectType == 13) OR (audioObjectType == 14) OR + (audioObjectType == 15) OR (audioObjectType == 16)) + THEN + status = 1; + ENDIF + + IF (((audioObjectType == MP4AUDIO_ER_AAC_LC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LTP) OR + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_ER_TWINVQ) OR + (audioObjectType == MP4AUDIO_ER_BSAC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LD)) AND (status == -1)) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_ER_CELP) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_ER_HVXC) + THEN + status = 1; + ENDIF + + IF ((audioObjectType == MP4AUDIO_ER_HILN) OR + (audioObjectType == MP4AUDIO_PARAMETRIC)) + THEN + status = 1; + ENDIF + + IF ((audioObjectType == MP4AUDIO_ER_AAC_LC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LTP) OR + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_ER_TWINVQ) OR + (audioObjectType == MP4AUDIO_ER_BSAC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LD) OR + (audioObjectType == MP4AUDIO_ER_CELP) OR + (audioObjectType == MP4AUDIO_ER_HVXC) OR + (audioObjectType == MP4AUDIO_ER_HILN) OR + (audioObjectType == MP4AUDIO_PARAMETRIC)) + THEN + epConfig = CALL getbits( + neededBits = LEN_EP_CONFIG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (epConfig) + + IF (epConfig == 2) + THEN + status = 1; + ENDIF + + ENDIF + + RETURN status; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_mp4ff_const.h" +#include "e_tmp4audioobjecttype.h" +#include "get_audio_specific_config.h" +#include "get_ga_specific_config.h" +#include "ibstream.h" +#include "sfb.h" /* Where samp_rate_info[] is declared */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int get_audio_specific_config(tDec_Int_File * const pVars) +{ + + UInt temp; + tMP4AudioObjectType audioObjectType; + //UInt32 sampling_rate; + UInt channel_config; + UInt syncExtensionType; + UInt extensionAudioObjectType = 0; + UInt extensionSamplingFrequencyIndex = 0; + BITS *pInputStream; + Int status; + + status = SUCCESS; + + pInputStream = &(pVars->inputStream); + + pVars->mc_info.upsamplingFactor = 1; /* default to regular AAC */ + + temp = get9_n_lessbits(LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX, + pInputStream); + + /* + * The following code can directly set the values of elements in + * MC_Info, rather than first setting the values in pVars->prog_config + * and then copy these values to MC_Info by calling set_mc_info. + * In order to keep consistent with get_prog_config (ADIF) and + * get_adts_header (ADTS), the code here is still copying + * the info, and set the pVars->current_program = 0 + */ + + /* AudioObjectType */ + audioObjectType = (tMP4AudioObjectType)((temp & 0x1f0) >> 4); + + pVars->mc_info.ExtendedAudioObjectType = audioObjectType; /* default */ + /* saving an audioObjectType into a profile field */ + /* pVars->prog_config.profile = audioObjectType; */ + + /* sampling rate index */ + pVars->prog_config.sampling_rate_idx = temp & 0xf; + + if (pVars->prog_config.sampling_rate_idx > 0xb) + { + /* + * Only support 12 sampling frequencies from array samp_rate_info ( see sfb.cpp) + * 7350 Hz (index 0xc) is not supported, the other indexes are reserved or escape + */ + if (pVars->prog_config.sampling_rate_idx == 0xf) /* escape sequence */ + { + /* + * sampling rate not listed in Table 1.6.2, + * this release does not support this + */ + /*sampling_rate = getbits( LEN_SAMP_RATE, + pInputStream);*/ + getbits(LEN_SAMP_RATE, pInputStream); /* future use */ + } + + status = 1; + } + + channel_config = get9_n_lessbits(LEN_CHAN_CONFIG, + pInputStream); + + if ((channel_config > 2) && (!pVars->aacConfigUtilityEnabled)) + { + /* + * AAC lib does not support more than two channels + * signal error when in decoder mode + * do not test when in utility mode + */ + status = 1; + + } + + if (audioObjectType == MP4AUDIO_SBR || audioObjectType == MP4AUDIO_PS) + { + /* to disable explicit backward compatiblity check */ + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + pVars->mc_info.sbrPresentFlag = 1; + + if (audioObjectType == MP4AUDIO_PS) + { + pVars->mc_info.psPresentFlag = 1; + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS; + } + + extensionSamplingFrequencyIndex = /* extensionSamplingFrequencyIndex */ + get9_n_lessbits(LEN_SAMP_RATE_IDX, + pInputStream); + if (extensionSamplingFrequencyIndex == 0x0f) + { + /* + * sampling rate not listed in Table 1.6.2, + * this release does not support this + */ + /*sampling_rate = getbits( LEN_SAMP_RATE, + pInputStream);*/ + getbits(LEN_SAMP_RATE, pInputStream); + } + + audioObjectType = (tMP4AudioObjectType) get9_n_lessbits(LEN_OBJ_TYPE , + pInputStream); + } + + + if ((/*(audioObjectType == MP4AUDIO_AAC_MAIN) ||*/ + (audioObjectType == MP4AUDIO_AAC_LC) || + /*(audioObjectType == MP4AUDIO_AAC_SSR) ||*/ + (audioObjectType == MP4AUDIO_LTP) /*||*/ + /*(audioObjectType == MP4AUDIO_AAC_SCALABLE) ||*/ + /*(audioObjectType == MP4AUDIO_TWINVQ)*/) && (status == SUCCESS)) + { + status = get_GA_specific_config(pVars, + pInputStream, + channel_config, + audioObjectType); + + /* + * verify that Program config returned a supported audio object type + */ + + if ((pVars->mc_info.audioObjectType != MP4AUDIO_AAC_LC) && + (pVars->mc_info.audioObjectType != MP4AUDIO_LTP)) + { + return 1; /* status != SUCCESS invalid aot */ + } + } + else + { + return 1; /* status != SUCCESS invalid aot or invalid parameter */ + } + + /* + * SBR tool explicit signaling ( backward compatible ) + */ + if (extensionAudioObjectType != MP4AUDIO_SBR) + { + syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE, + pInputStream); + + if (syncExtensionType == 0x2b7) + { + extensionAudioObjectType = get9_n_lessbits( /* extensionAudioObjectType */ + LEN_OBJ_TYPE, + pInputStream); + + if (extensionAudioObjectType == MP4AUDIO_SBR) + { + pVars->mc_info.sbrPresentFlag = get1bits(pInputStream); /* sbrPresentFlag */ + if (pVars->mc_info.sbrPresentFlag == 1) + { + extensionSamplingFrequencyIndex = + get9_n_lessbits( /* extensionSamplingFrequencyIndex */ + LEN_SAMP_RATE_IDX, + pInputStream); + if (pVars->aacPlusEnabled == true) + { +#ifdef AAC_PLUS + if (extensionSamplingFrequencyIndex < 3) + { + /* + * Disable SBR/PS for any sampling freq. > 48 KHz + * 3GPP request support up to Level 2, == max AAC/SBR present + * 24/48 KHz + */ + pVars->aacPlusEnabled = false; + } + else + { + pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) == + samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1; + + if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx) + { + /* + * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz + */ + if (pVars->prog_config.sampling_rate_idx < 6) + { + pVars->aacPlusEnabled = false; + } + + pVars->mc_info.bDownSampledSbr = true; + } + + pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex; + } + +#endif + } + + if (extensionSamplingFrequencyIndex == 0x0f) + { + /* + * sampling rate not listed in Table 1.6.2, + * this release does not support this + */ + /*sampling_rate = getbits( LEN_SAMP_RATE, + pInputStream);*/ + getbits(LEN_SAMP_RATE, pInputStream); + } + /* syncExtensionType */ + syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE, + pInputStream); + if (syncExtensionType == 0x548) + { + pVars->mc_info.psPresentFlag = get1bits(pInputStream); /* psPresentFlag */ + if (pVars->mc_info.psPresentFlag) + { + extensionAudioObjectType = MP4AUDIO_PS; + } + } + else + { + /* + * Rewind bitstream pointer so that the syncExtensionType reading has no + * effect when decoding raw bitstream + */ + pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE; + } + + pVars->mc_info.ExtendedAudioObjectType = (eMP4AudioObjectType)extensionAudioObjectType; + } + } + } + else if (!status) + { + /* + * Rewind bitstream pointer so that the syncExtensionType reading has no + * effect when decoding raw bitstream + */ + pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE; + +#ifdef AAC_PLUS + + /* + * For implicit signalling, no hint that sbr or ps is used, so we need to + * check the sampling frequency of the aac content, if lesser or equal to + * 24 KHz, by defualt upsample, otherwise, do nothing + */ + if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == true) && + audioObjectType == MP4AUDIO_AAC_LC) + { + pVars->mc_info.upsamplingFactor = 2; + pVars->prog_config.sampling_rate_idx -= 3; + pVars->mc_info.sbrPresentFlag = 1; + pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED; + pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED; + + } + else + { + /* + * Disable SBR decoding for any implicit-signalig clip whose SF is > 24 KHz + * sbr-downsampling has to be implicit + */ + pVars->aacPlusEnabled = false; + } +#endif + + } + } + else /* MP4AUDIO_SBR was detected */ + { + /* + * Set the real output frequency use by the SBR tool, define tentative upsample ratio + */ + if (pVars->aacPlusEnabled == true) + { +#ifdef AAC_PLUS + pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) == + samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1; + + if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx) + { + /* + * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz + */ + if (pVars->prog_config.sampling_rate_idx < 6) + { + pVars->aacPlusEnabled = false; + } + pVars->mc_info.bDownSampledSbr = true; + } + pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex; + + + +#endif + + } + + } /* if ( extensionAudioObjectType != MP4AUDIO_SBR ) */ + + + + if (channel_config > 2) + { + pVars->multichannel_numChannels = channel_config << 1; /* to go along with own multichannel format */ + pVars->multichannel_detected = true; + } + + /* + * The following object types are not supported in this release, + * however, keep these interfaces for future implementation + */ + + /* + *if (audioObjectType == MP4AUDIO_CELP) + *{ + * status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_HVXC) + *{ + * status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_TTSI) + *{ + * status = 1; + *} + */ + + /* + *if ((audioObjectType == 13) || (audioObjectType == 14) || + * (audioObjectType == 15) || (audioObjectType == 16)) + *{ + * status = 1; + *} + */ + + /* The following objects are Amendment 1 objects */ + /* + *if (((audioObjectType == MP4AUDIO_ER_AAC_LC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LTP) || + * (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) || + * (audioObjectType == MP4AUDIO_ER_TWINVQ) || + * (audioObjectType == MP4AUDIO_ER_BSAC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LD)) && (status == -1)) + *{ + */ + /* + * should call get_GA_specific_config + * for this release, do not support Error Resilience + * temporary solution is set status flag and exit decoding + */ + /* status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_ER_CELP) + * { + * status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_ER_HVXC) + *{ + * status = 1; + *} + */ + + /* + *if ((audioObjectType == MP4AUDIO_ER_HILN) || + * (audioObjectType == MP4AUDIO_PARAMETRIC)) + *{ + * status = 1; + *} + */ + + /* + *if ((audioObjectType == MP4AUDIO_ER_AAC_LC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LTP) || + * (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) || + * (audioObjectType == MP4AUDIO_ER_TWINVQ) || + * (audioObjectType == MP4AUDIO_ER_BSAC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LD) || + * (audioObjectType == MP4AUDIO_ER_CELP) || + * (audioObjectType == MP4AUDIO_ER_HVXC) || + * (audioObjectType == MP4AUDIO_ER_HILN) || + * (audioObjectType == MP4AUDIO_PARAMETRIC)) + *{ + */ + /* error protection config */ + /* + * epConfig = + * getbits( + * LEN_EP_CONFIG, + * pInputStream); + * + * if (epConfig == 2) + * { + */ + /* should call ErrorProtectionSpecificConfig() */ + /* + * status = 1; + * } + * + *} + */ + + return status; + +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_audio_specific_config.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_audio_specific_config.h new file mode 100644 index 0000000..a8980ea --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_audio_specific_config.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_audio_specific_config.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes function declaration for get_audio_specific_config + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_AUDIO_SPECIFIC_CONFIG_H +#define GET_AUDIO_SPECIFIC_CONFIG_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int get_audio_specific_config( + tDec_Int_File * const pVars +); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_cce.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_cce.cpp new file mode 100644 index 0000000..7ef09e6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_cce.cpp @@ -0,0 +1,160 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to a BITS structure that holds information + regarding the input stream. + + pVars = pointer to structure that holds information for decoding, + tDec_Int_File + + pChVars[] = pointer to structure that holds channel information, + tDec_Int_Chan + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pInputStream->usedBits is rounded up to a number that represents the next + byte boundary. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Adquire Coupling Channel Element (CCE) from raw bitstream + At this time this function just drops the information. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global or static variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + +------------------------------------------------------------------------------ + RESOURCES USED + + STACK USAGE: + + where: + + DATA MEMORY USED: x words + + PROGRAM MEMORY USED: x words + + CLOCK CYCLES: + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "get_cce.h" +#include "ibstream.h" +#include "getbits.h" +#include "s_bits.h" +#include "e_elementid.h" +#include "huffman.h" +#include "e_huffmanconst.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_cce.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_cce.h new file mode 100644 index 0000000..0fe23d6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_cce.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_cce.h + Funtions: + get_cce + + +------------------------------------------------------------------------------ + +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_CCE_H +#define GET_CCE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_tdec_int_file.h" +#include "s_tdec_int_chan.h" +#include "pv_audio_type_defs.h" +#include "s_elelist.h" +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int get_cce(BITS *pInputStream, + tDec_Int_File *pVars, + tDec_Int_Chan *pChVars[]); + + + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_dse.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_dse.cpp new file mode 100644 index 0000000..647e851 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_dse.cpp @@ -0,0 +1,202 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to a BITS structure that holds information + regarding the input stream. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pInputStream->usedBits is rounded up to a number that represents the next + byte boundary. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Adquire Data Stream element (DSE) from raw bitstream + At this time this function just drops the information. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global or static variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +void byte_align( + BITS *pInputStream) + + MODIFYING(pInputStream->usedBits = pInputStream->usedBits + + (pInputStream->usedBits + 7) % 8) + + RETURN(nothing) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "get_dse.h" +#include "ibstream.h" +#include "getbits.h" +#include "s_bits.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void get_dse( + Char *DataStreamBytes, + BITS *pInputStream) +{ + Int i; + Int data_byte_align_flag; + UInt count; + Int esc_count; + Char *pDataStreamBytes; + + pDataStreamBytes = DataStreamBytes; + + /* + * Get element instance tag ( 4 bits) + * ( max of 16 per raw data block) + */ + get9_n_lessbits(LEN_TAG, pInputStream); + + /* + * get data_byte_align_flag ( 1 bit0 to see if byte alignment is + * performed within the DSE + */ + data_byte_align_flag = get1bits(pInputStream); + + /* + * get count ( 8 bits) + */ + count = get9_n_lessbits(LEN_D_CNT, pInputStream); + + /* + * if count == 255, its value it is incremented by a + * second 8 bit value, esc_count. This final value represents + * the number of bytes in the DSE + */ + if (count == (1 << LEN_D_CNT) - 1) + { + esc_count = (Int)get9_n_lessbits(LEN_D_ESC, pInputStream); /* 8 bits */ + count += esc_count; + } + + /* + * Align if flag is set + */ + if (data_byte_align_flag) + { + byte_align(pInputStream); + } + + for (i = count; i != 0; i--) + { + *(pDataStreamBytes++) = (Char) get9_n_lessbits( + LEN_BYTE, + pInputStream); + } + + return; + +} /* end get_dse */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_dse.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_dse.h new file mode 100644 index 0000000..6bd16fc --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_dse.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_dse.h + Funtions: + get_dse + + +------------------------------------------------------------------------------ + +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_DSE_H +#define GET_DSE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_elelist.h" +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void get_dse( + Char *DataStreamBytes, + BITS *pInputStream); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ele_list.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ele_list.cpp new file mode 100644 index 0000000..20778bf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ele_list.cpp @@ -0,0 +1,194 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ele_list.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pElementList = pointer to an EleList structure - only the field num_ele + needs to be set. Data type pointer to EleList. + + pInputStream = pointer to a BITS structure, used by the function getbits + to provide data. Data type pointer to BITS + + enableCPE = boolean value indicating the area to be read contains + a channel pair element field. Data type Bool + + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: None + + Pointers and Buffers Modified: + pElementList contents are updated with information pertaining to channel + configuration. + + pInputBuffer contents are updated to the next location to be read from + the input stream. + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function is called several times by get_prog_config() to read in part of + the program configuration data related to channel setup. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not have static or global variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(), + page 16, and section 8.5 "Program Config Element (PCE)", page 30. + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + +------------------------------------------------------------------------------ + PSEUDO-CODE + + elementCount = pElementList->num_ele; + + FOR (index = 0; index < elementCount; index++) + IF (enableCPE != FALSE) THEN + pElementList->ele_is_cpe[index] = + getbits(LEN_ELE_IS_CPE, pInputStream); + ELSE + pElementList->ele_is_cpe[index] = 0; + END IF + + pElementList->ele_tag[index] = getbits(LEN_TAG, pInputStream); + + END FOR + + RETURNS nothing + +------------------------------------------------------------------------------ +*/ + + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_elelist.h" +#include "s_bits.h" +#include "e_progconfigconst.h" +#include "ibstream.h" +#include "get_ele_list.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void get_ele_list( + EleList *pElementList, + BITS *pInputStream, + const Bool enableCPE) +{ + Int index; + Int *pEleIsCPE; + Int *pEleTag; + + pEleIsCPE = &pElementList->ele_is_cpe[0]; + pEleTag = &pElementList->ele_tag[0]; + + for (index = pElementList->num_ele; index > 0; index--) + { + if (enableCPE != FALSE) + { + *pEleIsCPE++ = get1bits(/*LEN_ELE_IS_CPE, */pInputStream); + } + else + { + *pEleIsCPE++ = FALSE; + } + + *pEleTag++ = get9_n_lessbits(LEN_TAG, pInputStream); + + } /* end for (index) */ + + return; + +} /* end get_ele_list */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ele_list.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ele_list.h new file mode 100644 index 0000000..48f131e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ele_list.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ele_list.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for get_ele_list.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_ELE_LIST_H +#define GET_ELE_LIST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_elelist.h" +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void get_ele_list( + EleList *pElementList, + BITS *pInputStream, + const Bool enableCPE); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ga_specific_config.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ga_specific_config.cpp new file mode 100644 index 0000000..6e4d530 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ga_specific_config.cpp @@ -0,0 +1,441 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ga_specific_config.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that holds all information for + this instance of the library. pVars->prog_config + pVars->mc_info, pVars->pWinSeqInfo, pVars->SFBWidth128 + are needed for calling set_mc_info. + Data type pointer to tDec_Int_File + + channel_config = variable that indicates the channel configuration + information, in this decoder library, only values + 0, 1, and 2 are allowed. + Data type UInt + + audioObjectType = variable that indicates the Audio Object Type. + Data type UInt. + + pInputStream = pointer to a BITS structure that holds information + regarding the input stream. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + status = 0 if success + 1 otherwise + + Pointers and Buffers Modified: + pVars->mc_info contents are updated with channel information. + if infoinit is called within set_mc_info, then + pVars->pWinSeqInfo contents are updated with window information. + pVars->SFBWidth128 contents are updated with scale factor band width data. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function takes the sampling_rate_idx, channel_config, and + audioObjectType from AudioSpecificConfig() and set the decoder configuration + necessary for the decoder to decode properly. + It also reads the bitstream for frame length, scalable bitstream information + and extension information to General Audio defined in MPEG-4 phase 1 + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global variables + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + Part 3 + Subpart 1 p18 1.6 Interface to MPEG-4 Systems + Subpart 4 p13 4.4.1 GA Specific Configuration + Amendment p10 6.2.1 AudioSpecificInfo + Amendment p78 8.2 Decoder configuration (GASpecificConfig) + + (2) AAC DecoderSpecificInfo Information + PacketVideo descriptions - San Diego + +------------------------------------------------------------------------------ + PSEUDO-CODE + + frameLenFlag = CALL getbits( + neededBits = LEN_FRAME_LEN_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (frameLenFlag) + + dependsOnCoreCoder = CALL getbits( + neededBits = LEN_DEPEND_ON_CORE, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (dependsOnCoreCoder) + + IF (dependsOnCoreCoder != FALSE) + THEN + coreCoderDelay = CALL getbits( + neededBits = LEN_CORE_DELAY, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (coreCoderDelay) + ENDIF + + extFlag = CALL getbits( + neededBits = LEN_EXT_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (extFlag) + + IF (channel_config == 0) + THEN + status = CALL get_prog_config( + pVars = pVars, + pScratchPCE = &pVars->scratch_prog_config); + MODIFYING (pVars, pScratchPCE) + RETURNING (status) + + ELSE + channel_config--; + pVars->prog_config.front.ele_is_cpe[0] = channel_config; + pVars->prog_config.front.ele_tag[0] = 0; + + status = CALL set_mc_info( + pMC_Info = &(pVars->mc_info), + audioObjectType = audioObjectType, + sampling_rate_idx = pVars->prog_config.sampling_rate_idx, + tag = pVars->prog_config.front.ele_tag[0], + is_cpe = pVars->prog_config.front.ele_is_cpe[0], + pWinSeqInfo = pVars->pWinSeqInfo, + sfbwidth128 = pVars->SFBWidth128); + MODIFYING (pMC_Info, pWinSeqInfo, sfbwidth128) + RETURNING (SUCCESS) + ENDIF + + IF ((audioObjectType == MP4AUDIO_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE)) + THEN + layer_num = CALL getbits( + neededBits = LEN_LAYER_NUM, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (layer_num) + + status = 1; + ENDIF + + IF (extFlag != FALSE) + THEN + IF (audioObjectType == MP4AUDIO_ER_BSAC) + THEN + numOfSubFrame = CALL getbits( + neededBits = LEN_SUB_FRAME, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (numOfSubFrame) + + layer_len = CALL getbits( + neededBits = LEN_LAYER_LEN, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (layer_len) + + ENDIF + + IF (((audioObjectType > 16) AND (audioObjectType < 22)) OR + (audioObjectType == 23)) + THEN + aacSectionDataResilienceFlag = + CALL getbits( + neededBits = LEN_SECT_RES_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (aacSectionDataResilienceFlag) + + aacScalefactorDataResilienceFlag = + CALL getbits( + neededBits = LEN_SFB_RES_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (aacScalefactorDataResilienceFlag) + + aacSpectralDataResilienceFlag = + CALL getbits( + neededBits = LEN_SPEC_RES_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (aacSpectralDataResilienceFlag) + ENDIF + + status = 1; + + ENDIF + + RETURN status; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_mp4ff_const.h" +#include "e_tmp4audioobjecttype.h" +#include "s_tdec_int_file.h" +#include "get_ga_specific_config.h" +#include "set_mc_info.h" +#include "get_prog_config.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int get_GA_specific_config( + tDec_Int_File * const pVars, + BITS *pInputStream, + UInt channel_config, + const tMP4AudioObjectType audioObjectType +) +{ + + Int status = SUCCESS; + UInt dependsOnCoreCoder; + /* Int coreCoderDelay; */ + UInt extFlag; + + /* These variables are left for future implementation */ + /* UInt layer_num; */ + /* UInt numOfSubFrame; */ + /* UInt layer_len; */ + /* UInt aacSectionDataResilienceFlag; */ + /* UInt aacScalefactorDataResilienceFlag; */ + /* UInt aacSpectralDataResilienceFlag; */ + Int extFlag3; + + /* + * frame length flag == 0, 1024 samples/frame + * frame length flag == 1, 960 samples/frame + */ + get1bits(/* LEN_FRAME_LEN_FLAG,*/ + pInputStream); + + /* + * dependsOnCoreCoder == 1, core coder has different sampling rate + * in a scalable bitstream + */ + dependsOnCoreCoder = + get1bits(/* LEN_DEPEND_ON_CORE,*/ + pInputStream); + + if (dependsOnCoreCoder != FALSE) + { + /*coreCoderDelay = + * getbits( + * LEN_CORE_DELAY, + * pInputStream); + */ + + status = 1; /* do not support scalable coding in this release */ + } + + /* + * extension flag indicates if Amendment 1 objects are used or not + * extension flag == 0 objects = 1, 2, 3, 4, 6, 7 + * extension flag == 1 objects = 17, 19, 20, 21, 22, 23 + */ + extFlag = get1bits(pInputStream); /* LEN_EXT_FLAG,*/ + + + /* Force checks for implicit channel configuration */ + pVars->mc_info.implicit_channeling = 1; + + if (status == SUCCESS) + { + + if (channel_config == 0) + { + status = get_prog_config(pVars, + &pVars->scratch.scratch_prog_config); + + if (status != SUCCESS) + { + pVars->prog_config.front.ele_is_cpe[0] = 0; /* default to mono */ + pVars->mc_info.nch = 1; + pVars->prog_config.front.ele_tag[0] = 0; + pVars->mc_info.audioObjectType = audioObjectType; + + status = SUCCESS; + } + } + else + { + /* + * dummy tag = 0 and + * set up decoding configurations + */ + + if (pVars->multichannel_detected) /* more than 2 channels */ + { + pVars->prog_config.front.ele_is_cpe[0] = 1; /* In this case always default to play the stereo channel */ + pVars->prog_config.front.ele_tag[0] = 0; + } + else + { + channel_config--; + pVars->prog_config.front.ele_is_cpe[0] = channel_config; + pVars->prog_config.front.ele_tag[0] = 0; + } + + status = + set_mc_info( + &(pVars->mc_info), + audioObjectType, /* previously profile */ + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[0], + pVars->prog_config.front.ele_is_cpe[0], + pVars->winmap, /*pVars->pWinSeqInfo,*/ + pVars->SFBWidth128); + + } /* if (channel_config) */ + + } /* if(status) */ + + /* + * This layer_num is not found in ISO/IEC specs, + * but it is defined in San Diego spec for scalable bitstream + */ + if ((audioObjectType == MP4AUDIO_AAC_SCALABLE) || + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE)) + { + /*layer_num = + * getbits( + * LEN_LAYER_NUM, + * pInputStream); + */ + + status = 1; /* for this release only */ + } + + if (extFlag) + { + /* + * currently do not implement these functionalities + * defined in Amendment 1 + * keep it here for future release + */ + if (audioObjectType == MP4AUDIO_ER_BSAC) + { + status = 1; /* NOT SUPPORTED */ + /* + numOfSubFrame = getbits( LEN_SUB_FRAME, pInputStream); + + layer_len = getbits( LEN_LAYER_LEN, pInputStream); + */ + } + + /* + * The following code is equivalent to + * if ((audioObjectType == 17) || (audioObjectType == 18) || + * (audioObjectType == 19) || (audioObjectType == 20) || + * (audioObjectType == 21) || (audioObjectType == 23)) + */ + + if (((audioObjectType > 16) && (audioObjectType < 22)) || + (audioObjectType == 23)) + { + status = 1; /* NOT SUPPORTED */ + /* + aacSectionDataResilienceFlag = getbits( LEN_SECT_RES_FLAG, + pInputStream); + + aacScalefactorDataResilienceFlag = getbits( LEN_SCF_RES_FLAG, + pInputStream); + + aacSpectralDataResilienceFlag = getbits( LEN_SPEC_RES_FLAG, + pInputStream); + */ + } + /* + * this flag is tbd in version 3 of ISO/IEC spec + * if the encoder generates this bit, then it has to be read + * current adif2mp4ff does not write this bit. If this bit is to + * be read, it can be done by the following code: + */ + + extFlag3 = get1bits(pInputStream); /* LEN_EXT_FLAG3 */ + + if (extFlag3) + { + status = 1; /* NOT SUPPORTED */ + } + + } + + return status; +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ga_specific_config.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ga_specific_config.h new file mode 100644 index 0000000..bee73d1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ga_specific_config.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ga_specific_config.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes the function declaration for get_GA_specific_config.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_GA_SPECIFIC_CONFIG_H +#define GET_GA_SPECIFIC_CONFIG_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int get_GA_specific_config( + tDec_Int_File * const pVars, + BITS *pInputStream, + UInt channel_config, + const tMP4AudioObjectType audioObjectType +); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ics_info.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ics_info.cpp new file mode 100644 index 0000000..d2de5d4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ics_info.cpp @@ -0,0 +1,561 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ics_info.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + audioObjectType = MP4 Audio Object Type for the current song. Only if + this is set to LTP (MP4AUDIO_LTP) will long term + prediction bits be retrieved. Data type + tMP4AudioObjectType, which is an enumeration, which in + turn is an Int. + + pInputStream = pointer to a BITS structure, used by the function getbits + to provide data. This is the second parameter to this + function to match its position in getbits(). + Data type pointer to BITS structure + + common_window = field read in huffdecode, which tells whether information + is shared between the left and right channel. Long term + prediction (LTP) data is NOT shared even if its a common + window, so this flag is needed to see if another set of + LTP possibly needs to be read. If this flag is false, + pSecondLTPStatus is not touched, it could be NULL if + need be. Data type Bool, which is Int. + + pWindowSequence = pointer to where the the window type of the current + frame and channel should be placed, of data type + WINDOW_SEQUENCE, which is Int. It can take on one + of four values: ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE, + EIGHT_SHORT_SEQUENCE, LONG_STOP_SEQUENCE, + + pWindowShape = pointer to where the window shape for the current frame + and channel should be placed, of data type WINDOW_SHAPE, + which is Int. It can take on the one of these two values: + SINE_WINDOW, KAISER_BESSEL_WINDOW. It is used in the + "filterbank" section of decoding. + + group = array that holds the index of the first window in each + group. Data type array of Int, eight elements. + + p_max_sfb = pointer to where the maximum number of scale factor bands + for the current frame and channel will be placed. Data + type of pointer to Int. + + p_winmap = array of pointers to all of the possible four window + configurations. This parameter did not need to be pointers, + and could be changed in the future. Data type array of pointers + to FrameInfo structures, length 4. + + pFirstLTPStatus = pointer to a structure where the first LTP + information will be stored. It would be confusing and wrong + to call this left LTP status since if common_window = FALSE, + this function will be called twice - once for the left, once + for the right. It could be done, but extra conditional code + would need to be done. + Data type pointer to LT_PRED_STATUS structure. + + pSecondLTPStatus = pointer to where the right channel of LTP + information will be stored only if common_window is non-zero. + Data type pointer to LT_PRED_STATUS structure. + + Local Stores/Buffers/Pointers Needed: None. + + Global Stores/Buffers/Pointers Needed: None. + + Outputs: + status = 0 implies no error occurred, non-zero otherwise. + + Pointers and Buffers Modified: + pInputStream contents are modified in such a way that the number of bits + read increases. + pWindowSequence contents are updated with the current window for this + frame and channel + group[] contents will be modified to grouping information. See getgroup + source code for a better description of what this is. + p_max_sfb contents will be updated with the maximum scale factor bands + for this frame and channel. + pFirstLTPStatus contents may be updated if the stream has long term + prediction information. + pSecondLTPStatus contents may be updated if common_window != 0 and LTP data + is present. + + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function retrieves the individual channel stream (ICS) information + from the bitstream. The information read for the current + frame and channel is: + - window sequence + - window shape for use in the filter bank + - number of scale factor bands + - long term predication (LTP) information + - grouping information + + This function does NOT support MPEG2 style AAC Frequency Domain Predictor, + not to be confused with LTP (Long Term Prediction). If such data is found + to be on the file an error is generated. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function is not to use static or global data. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) Titled "Information technology - Coding + of audio-visual objects Part 3: Audio Subpart 4:" + Table 4.4.6 - Syntax of ics_info(), page 16. + + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = 0; + first_ltp_data_present = FALSE; + second_ltp_data_present = FALSE; + + + CALL getbits( + neededBits = LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + windowSequence = (temp >> LEN_WIN_SH) & ((0x1<> LEN_PREDICTOR_DATA_PRESENT); + + predictor_data_present = + (Bool) (temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT)-1)); + + IF (local_max_sfb > allowed_max_sfb) + THEN + status = 1 + ELSEIF (audioObjectType == MP4AUDIO_LTP) + THEN + IF (predictor_data_present != FALSE) + THEN + CALL getbits( + neededBits = LEN_LTP_DATA_PRESENT, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(first_ltp_data_present = returnValue) + + IF (ltp_data_present != FALSE) + THEN + + CALL lt_decode( + win_type = windowSequence, + pInputStream = pInputStream, + max_sfb = local_max_sfb, + pLt_pred = pFirstLTPStatus) + MODIFYING(pInputStream) + MODIFYING(pFirstLTPStatus) + RETURNING(nothing) + + ENDIF + + IF (common_window != FALSE) + THEN + CALL getbits( + neededBits = LEN_LTP_DATA_PRESENT, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(second_ltp_data_present = returnValue) + + IF (second_ltp_data_present != FALSE) + THEN + + CALL lt_decode( + win_type = windowSequence, + pInputStream = pInputStream, + max_sfb = local_max_sfb, + pLt_pred = pSecondLTPStatus) + MODIFYING(pInputStream) + MODIFYING(pSecondLTPStatus) + RETURNING(nothing) + ENDIF + ENDIF + ENDIF + ELSE + IF (predictor_data_present != FALSE) + THEN + status = 1 + ENDIF + END IF + ENDIF + + pFirstLTPStatus->ltp_data_present = first_ltp_data_present; + + IF (common_window != FALSE) + THEN + pSecondLTPStatus->ltp_data_present = second_ltp_data_present; + ENDIF + + pFrameInfo = p_winmap[*p_wnd]; + IF (local_max_sfb > pFrameInfo->sfb_per_frame) + THEN + status = 1; + ENDIF + + *(p_max_sfb) = local_max_sfb; + + MODIFY(*(pWindowSequence)) + MODIFY(*(pWinShape)) + MODIFY(*(p_max_sfb)) + MODIFY(group[]) + MODIFY(*pInputStream) + MODIFY(*pFirstLTPStatus) + MODIFY(*pSecondLTPStatus) + RETURN (status); + + + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +#include "e_rawbitstreamconst.h" +#include "e_tmp4audioobjecttype.h" + +#include "s_bits.h" +#include "s_frameinfo.h" +#include "s_lt_pred_status.h" + +#include "ibstream.h" +#include "lt_decode.h" +#include "ltp_common_internal.h" /* For LEN_LTP_DATA_PRESENT constant */ + +#include "get_ics_info.h" +#include "huffman.h" /* For the declaration of getgroup */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define LEN_PREDICTOR_DATA_PRESENT (1) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int get_ics_info( + const tMP4AudioObjectType audioObjectType, + BITS *pInputStream, + const Bool common_window, + WINDOW_SEQUENCE *pWindowSequence, + WINDOW_SHAPE *pWindowShape, + Int group[], + Int *p_max_sfb, + FrameInfo *p_winmap[], + LT_PRED_STATUS *pFirstLTPStatus, + LT_PRED_STATUS *pSecondLTPStatus) +{ + WINDOW_SEQUENCE windowSequence; + UInt temp; + Bool predictor_data_present; + UInt local_max_sfb; + UInt allowed_max_sfb; + Int status = SUCCESS; + Bool first_ltp_data_present = FALSE; + Bool second_ltp_data_present = FALSE; + + /* + * The following three calls to getbits have been replaced with one + * call for speed: + * + * getbits(LEN_ICS_RESERV, pInputStream); + * windowSequence = getbits(LEN_WIN_SEQ, pInputStream); + * *pWindowShape = getbits(LEN_WIN_SH, pInputStream); + * + */ + + temp = + get9_n_lessbits( + LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH, + pInputStream); + + + windowSequence = (WINDOW_SEQUENCE)((temp >> LEN_WIN_SH) & ((0x1 << LEN_WIN_SEQ) - 1)); + + *pWindowShape = (WINDOW_SHAPE)((temp) & ((0x1 << LEN_WIN_SH) - 1)); + + /* + * This pointer should not be NULL as long as the initialization code + * has been run, so the test for NULL has been removed. + */ + allowed_max_sfb = p_winmap[windowSequence]->sfb_per_win[0]; + + if (windowSequence == EIGHT_SHORT_SEQUENCE) + { + local_max_sfb = get9_n_lessbits(LEN_MAX_SFBS, + pInputStream); + + getgroup( + group, + pInputStream); + + if (local_max_sfb > allowed_max_sfb) + { + status = 1; /* ERROR CODE - needs to be updated */ + } + + } /* end of TRUE of if (windowSequence == EIGHT_SHORT_SEQUENCE) */ + else + { + /* There is only one group for long windows. */ + group[0] = 1; + + /* + * The window is long, get the maximum scale factor bands, + * and get long term prediction info. + * + * Reference [1] states that the audioObjectType is first tested, + * then the predictor_data_present is read on either branch of the + * if (audioObjectType == MP4AUDIO_LTP). Instead, this code combines + * the two calls on both branches into one before the + * if, and then in turn combines with another call to getbits, all + * in the name of speed. + * + * This would be the individual calls, without checking the number + * of scale factor bands: + * + * local_max_sfb = + * (Int) getbits( + * LEN_MAX_SFBL, + * pInputStream); + * + * if (audioObjectType == MP4AUDIO_LTP) + * { + * predictor_data_present = + * (Bool) getbits( + * LEN_PREDICTOR_DATA_PRESENT, + * pInputStream); + * + * ..... (read LTP data) + * + * } + * else + * { + * + * predictor_data_present = + * (Bool) getbits( + * LEN_PREDICTOR_DATA_PRESENT, + * pInputStream); + * + * ..... (its an error for this library) + * } + */ + temp = + get9_n_lessbits( + LEN_MAX_SFBL + LEN_PREDICTOR_DATA_PRESENT, + pInputStream); + + local_max_sfb = (Int)(temp >> LEN_PREDICTOR_DATA_PRESENT); + + predictor_data_present = + (Bool)(temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT) - 1)); + + if (local_max_sfb > allowed_max_sfb) + { + status = 1; /* ERROR CODE - needs to be updated */ + } + else if (audioObjectType == MP4AUDIO_LTP) + { + /* + * Note that the predictor data bit has already been + * read. + */ + + /* + * If the object type is LTP, the predictor data is + * LTP. If the object type is not LTP, the predictor data + * is so called "frequency predictor data", which is not + * supported by this implementation. Refer to (1) + */ + if (predictor_data_present != FALSE) + { + first_ltp_data_present = + (Bool) get1bits(/* LEN_LTP_DATA_PRESENT,*/ + pInputStream); + + if (first_ltp_data_present != FALSE) + { + lt_decode( + windowSequence, + pInputStream, + local_max_sfb, + pFirstLTPStatus); + } + if (common_window != FALSE) + { + second_ltp_data_present = + (Bool) get1bits(/* LEN_LTP_DATA_PRESENT,*/ + pInputStream); + + if (second_ltp_data_present != FALSE) + { + lt_decode( + windowSequence, + pInputStream, + local_max_sfb, + pSecondLTPStatus); + } + } /* if (common_window != FALSE) */ + + } /* if (predictor_data_present != FALSE) */ + + } /* else if (audioObjectType == MP4AUDIO_LTP) */ + else + { + /* + * Note that the predictor data bit has already been + * read. + */ + + /* + * The object type is not LTP. If there is data, its + * frequency predictor data, not supported by this + * implementation. + */ + if (predictor_data_present != FALSE) + { + status = 1; /* ERROR CODE UPDATE LATER */ + } /* if (predictor_data_present != FALSE) */ + + } /* end of "else" clause of if (audioObjectType == MP4AUDIO_LTP) */ + + } /* if (windowSequence == EIGHT_SHORT_SEQUENCE) [FALSE branch] */ + + + /* + * Save all local copies. + */ + pFirstLTPStatus->ltp_data_present = first_ltp_data_present; + if (common_window != FALSE) + { + pSecondLTPStatus->ltp_data_present = second_ltp_data_present; + } + + *p_max_sfb = local_max_sfb; + + *pWindowSequence = windowSequence; + + return (status); + +} /* get_ics_info */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ics_info.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ics_info.h new file mode 100644 index 0000000..dc5d4ad --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_ics_info.h @@ -0,0 +1,105 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ics_info.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Contains the declaration for the function get_ics_info() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_ICS_INFO_H +#define GET_ICS_INFO_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_tmp4audioobjecttype.h" +#include "s_bits.h" +#include "e_window_sequence.h" +#include "e_window_shape.h" +#include "s_frameinfo.h" +#include "s_lt_pred_status.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int get_ics_info( + const tMP4AudioObjectType audioObjectType, + BITS *pInputStream, + const Bool common_window, + WINDOW_SEQUENCE *p_wnd, + WINDOW_SHAPE *pWindowShape, + Int group[], + Int *p_max_sfb, + FrameInfo *p_winmap[], + LT_PRED_STATUS *pFirstLTPStatus, + LT_PRED_STATUS *pSecondLTPStatus); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* GET_ICS_INFO_H */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_prog_config.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_prog_config.cpp new file mode 100644 index 0000000..e0448b7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_prog_config.cpp @@ -0,0 +1,692 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_prog_config.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that holds all information for + this instance of the library. pVars->prog_config is directly + used, and pVars->mc_info, pVars->prog_config, pVars->winmap, + pVars->SFBWidth128 are needed indirectly for calling + set_mc_info. Data type pointer to tDec_Int_File structure. + + pScratchPCE = pointer to a temporary ProgConfig structure to be used + to read in the program configuration element. + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = zero if no error was found, non-zero otherwise. + + Pointers and Buffers Modified: + pVars->prog_config contents are updated with the PCE read in. + pVars->mc_info contents are updated with channel information. + pVars->winmap contents are updated with window information. + pVars->SFBWidth128 contents are updated with scale factor band width data. + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads from the input stream to memory for a temporary + program configuration element (PCE). If the PCE read is the first + encountered it is saved. Or, if the tag of the PCE read matches the tag of + the first PCE encounted, it is saved as well. This is a mechanism for + changing the sampling rate. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use static or global variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(), + page 16, and section 8.5 "Program Config Element (PCE)", page 30. + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = SUCCESS; + pInputStream = &(pVars->inputStream); + + + CALL getbits( + neededBits = LEN_TAG, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( tag = returnValue ) + + CALL getbits( + neededBits = LEN_PROFILE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( pScratchPCE->profile = returnValue ) + + CALL getbits( + neededBits = LEN_PROFILE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( pScratchPCE->sampling_rate_idx = returnValue ) + + CALL getbits( + neededBits = LEN_NUM_ELE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->front.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_ELE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->side.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_ELE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->back.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_LFE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->lfe.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_DAT, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->data.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_CCE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->coupling.num_ele = temp; + + CALL getbits( + neededBits = LEN_MIX_PRES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( flag = returnValue ) + + pScratchPCE->mono_mix.present = flag; + + IF (flag != FALSE) + THEN + CALL getbits( + neededBits = LEN_TAG, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->mono_mix.ele_tag = temp; + + ENDIF + + CALL getbits( + neededBits = LEN_MIX_PRES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( flag = returnValue ) + + pScratchPCE->stereo_mix.present = flag; + + IF (flag != FALSE) + THEN + + CALL getbits( + neededBits = LEN_TAG, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->stereo_mix.ele_tag = temp; + + ENDIF + + CALL getbits( + neededBits = LEN_MIX_PRES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( flag = returnValue ) + + flag = + getbits( + LEN_MIX_PRES, + pInputStream); + + pScratchPCE->matrix_mix.present = flag; + + IF (flag != FALSE) + THEN + CALL getbits( + neededBits = LEN_MMIX_IDX, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->matrix_mix.ele_tag = temp; + + CALL getbits( + neededBits = LEN_PSUR_ENAB, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->matrix_mix.pseudo_enab = temp; + + ENDIF + + + CALL get_ele_list( + pElementList = &pScratchPCE->front, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->front ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->side, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->side ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->back, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->back ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->lfe, + pInputStream = pInputStream, + enableCPE = FALSE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->lfe ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->data, + pInputStream = pInputStream, + enableCPE = FALSE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->data ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->coupling, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->coupling ) + RETURNING( nothing ) + + + CALL byte_align( + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( nothing ) + + CALL getbits( + neededBits = LEN_COMMENT_BYTES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( numChars = returnValue ) + + FOR (i = numChars; i > 0; i--) + + CALL getbits( + neededBits = LEN_COMMENT_BYTES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( nothing ) + + ENDFOR + + IF (pVars->current_program < 0) + THEN + pVars->current_program = tag; + ENDIF + + + IF (tag == pVars->current_program) + THEN + + CALL pv_memcpy( + to = &pVars->prog_config, + from = pScratchPCE, + n = sizeof(ProgConfig)) + MODIFYING( pVars->prog_config ) + RETURNING( nothing ) + + CALL set_mc_info( + pMC_Info = &pVars->mc_info, + objectType = pVars->prog_config.profile + 1, + samplin_rate_idx = pVars->prog_config.sampling_rate_idx, + tag = pVars->prog_config.front.ele_tag[0], + is_cpe = pVars->prog_config.front.ele_is_cpe[0], + pWinSeqInfo = pVars->winmap, + pSfbwidth128 = pVars->SFBWidth128) + MODIFYING( pVars->mc_info ) + MODIFYING( pVars->winmap ) + MODIFYING( pVars->SFBWidth128 ) + RETURN( status = return_value ) + + ENDIF + + MODIFY( pVars->mc_info ) + MODIFY( pVars->winmap ) + MODIFY( pVars->SFBWidth128 ) + RETURN (status) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "s_elelist.h" +#include "s_tdec_int_file.h" +#include "s_tdec_int_chan.h" +#include "e_progconfigconst.h" +#include "ibstream.h" +#include "get_ele_list.h" +#include "aac_mem_funcs.h" +#include "set_mc_info.h" +#include "get_prog_config.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +Int get_prog_config( + tDec_Int_File *pVars, + ProgConfig *pScratchPCE) +{ + Int i; + UInt tag; + Int numChars; + UInt temp; + Bool flag; + Int status = SUCCESS; + BITS *pInputStream = &(pVars->inputStream); + + + /* + * The tag is used at the very end to see if this PCE is + * the one to be used. Otherwise it does not need to be saved for the + * the simple configurations to be used in this version of an AAC + * decoder. + * + * All of the bits of this PCE must be read even if this PCE will not + * be used. They are read into a temporary PCE, then later it is decided + * whether to keep this PCE. + * + * To allow quick removal of the fields from the ProgConfig structure + * that will probably not be used at a later date, + * while still advancing the bitstream pointer,the return value of + * getbits is saved into a temporary variable, then transfered to + * the structure item. + */ + tag = get9_n_lessbits(LEN_TAG, pInputStream); + + pScratchPCE->profile = get9_n_lessbits(LEN_PROFILE, pInputStream); + + pScratchPCE->sampling_rate_idx = get9_n_lessbits(LEN_SAMP_IDX, pInputStream); + + if (!pVars->adif_test && (pScratchPCE->sampling_rate_idx != pVars->prog_config.sampling_rate_idx)) + { +#ifdef AAC_PLUS + /* + * PCE carries the baseline frequency, if SBR or PS are used, the frequencies will not match + * so check for this unique case, and let decoding continue if this is a redundant PCE + */ + if ((pScratchPCE->sampling_rate_idx != (pVars->prog_config.sampling_rate_idx + 3)) || + (pVars->mc_info.upsamplingFactor != 2)) +#endif + { + /* rewind the pointer as implicit channel configuration maybe the case */ + pInputStream->usedBits -= (LEN_TAG + LEN_PROFILE + LEN_SAMP_IDX); + + return (1); /* mismatch cannot happen */ + } + } + + + /* + * Retrieve the number of element lists for each of + * front, side, back, lfe, data, and coupling. + * + * For two-channel stereo or mono, only the data in the front needs + * to be saved. However, ALL fields need to be skipped over in some + * fashion. Also, the number of elements needs to be temporarily saved + * to call get_ele_list(). If that function was changed to pass in + * the number of points to be read, the memory set aside inside the + * ProgConfig structure could be removed. + */ + + /* + * The next six function calls could be combined into one, then use + * shifts and masks to retrieve the individual fields. + */ + temp = get9_n_lessbits(LEN_NUM_ELE, pInputStream); + + pScratchPCE->front.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = get9_n_lessbits(LEN_NUM_ELE, pInputStream); + + pScratchPCE->side.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = get9_n_lessbits(LEN_NUM_ELE, pInputStream); + + pScratchPCE->back.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = get9_n_lessbits(LEN_NUM_LFE, pInputStream); + + pScratchPCE->lfe.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = get9_n_lessbits(LEN_NUM_DAT, pInputStream); + pScratchPCE->data.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = get9_n_lessbits(LEN_NUM_CCE, pInputStream); + + pScratchPCE->coupling.num_ele = temp; + + /* + * Read in mix down data. + * + * Whether these fields can be removed and have proper operation + * will be determined at a later date. + */ + + /* Read presence of mono_mix */ + flag = get1bits(pInputStream);/* LEN_MIX_PRES,*/ + + pScratchPCE->mono_mix.present = flag; + + if (flag != FALSE) + { + temp = get9_n_lessbits(LEN_TAG, pInputStream); + + pScratchPCE->mono_mix.ele_tag = temp; + + } /* end if (flag != FALSE) */ + + /* Read presence of stereo mix */ + flag = get1bits(pInputStream); /* LEN_MIX_PRES,*/ + + pScratchPCE->stereo_mix.present = flag; + + if (flag != FALSE) + { + temp = get9_n_lessbits(LEN_TAG, pInputStream); + + pScratchPCE->stereo_mix.ele_tag = temp; + + } /* end if (flag != FALSE) */ + + /* Read presence of matrix mix */ + flag = get1bits(pInputStream); /* LEN_MIX_PRES,*/ + + pScratchPCE->matrix_mix.present = flag; + + if (flag != FALSE) + { + temp = get9_n_lessbits(LEN_MMIX_IDX, pInputStream); + + pScratchPCE->matrix_mix.ele_tag = temp; + + temp = get1bits(pInputStream); /* LEN_PSUR_ENAB,*/ + + pScratchPCE->matrix_mix.pseudo_enab = temp; + + } /* end if (flag != FALSE) */ + + /* + * Get each of the element lists. Only the front information will be + * used for the PV decoder, but the usedBits field of pInputStream must + * be advanced appropriately. + * + * This could be optimized by advancing the bit stream for the + * elements that do not need to be read. + */ + get_ele_list(&pScratchPCE->front, + pInputStream, + TRUE); + + get_ele_list(&pScratchPCE->side, + pInputStream, + TRUE); + + get_ele_list(&pScratchPCE->back, + pInputStream, + TRUE); + + get_ele_list(&pScratchPCE->lfe, + pInputStream, + FALSE); + + get_ele_list(&pScratchPCE->data, + pInputStream, + FALSE); + + get_ele_list(&pScratchPCE->coupling, + pInputStream, + TRUE); + + /* + * The standard requests a byte alignment before reading in the + * comment. This can be done because LEN_COMMENT_BYTES == 8. + */ + byte_align(pInputStream); + + numChars = get9_n_lessbits(LEN_COMMENT_BYTES, pInputStream); + + /* + * Ignore the comment - it requires 65 bytes to store (or worse on DSP). + * If this field is restored, make sure to append a trailing '\0' + */ + for (i = numChars; i > 0; i--) + { + pScratchPCE->comments[i] = (Char) get9_n_lessbits(LEN_BYTE, + pInputStream); + + } /* end for */ + + + if (pVars->current_program < 0) + { + /* + * If this is the first PCE, it becomes the current, regardless of + * its tag number. + */ + pVars->current_program = tag; + + pVars->mc_info.ch_info[0].tag = 0; + + } /* end if (pVars->current_program < 0) */ + + + if (tag == (UInt)pVars->current_program) + { + /* + * This branch is reached under two conditions: + * 1) This is the first PCE found, it was selected in the above if + * block. In all encoders found thus far, the tag value has been + * zero. + * 2) A PCE has been sent by the encoder with a tag that matches the + * the first one sent. It will then be re-read. No encoder found + * + * Regardless, the temporary PCE will now be copied into the + * the one official program configuration. + */ + + /* + * Keep adts setting in case of a redundant PCE (only applicable when + * using aac-lib own adts parser) + */ + pScratchPCE->file_is_adts = pVars->prog_config.file_is_adts; + pScratchPCE->headerless_frames = pVars->prog_config.headerless_frames; + + pv_memcpy(&pVars->prog_config, + pScratchPCE, + sizeof(ProgConfig)); + + + tag = 0; + + /* + * Check that dual-mono does not carry more than 2 tracks, otherwise flag an non-supported error + */ + if ((pVars->prog_config.front.num_ele > 2) && !(pVars->prog_config.front.ele_is_cpe[tag])) + { + status = 1; + } + + /* + * Check that stereo does not carry more than 1 track, otherwise flag an non-supported error + */ + if ((pVars->prog_config.front.num_ele > 1) && (pVars->prog_config.front.ele_is_cpe[tag])) + { + status = 1; + } + + + + if (!status) + { + + /* enter configuration into MC_Info structure */ + status = set_mc_info(&pVars->mc_info, + (tMP4AudioObjectType)(pVars->prog_config.profile + 1), + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[tag], + pVars->prog_config.front.ele_is_cpe[tag], + pVars->winmap, + pVars->SFBWidth128); + + if (pVars->mc_info.upsamplingFactor == 2) + { + /* + * prog_config.sampling_rate_idx corresponds to the aac base layer, + * if the upsampling factor is active, then the output frequency needs + * to be adjusted accordingly + */ + pVars->prog_config.sampling_rate_idx -= 3; + } + + } + + + } /* end if (tag == pVars->current_program) */ + + + + return (status); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_prog_config.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_prog_config.h new file mode 100644 index 0000000..6444df6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_prog_config.h @@ -0,0 +1,83 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_prog_config.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for get_prog_config.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_PROG_CONFIG_H +#define GET_PROG_CONFIG_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_progconfig.h" +#include "s_tdec_int_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int get_prog_config( + tDec_Int_File *pVars, + ProgConfig *pTempPCE); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_pulse_data.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_pulse_data.cpp new file mode 100644 index 0000000..7923075 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_pulse_data.cpp @@ -0,0 +1,239 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_pulse_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to a BITS structure, used by the function getbits + to provide data. Data type pointer to BITS structure + + pPulseInfo = pointer to pulse data structure to be filled with data + concerning pulses in the frequency domain. + Data type pointer to PulseInfo + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = return value, zero signifies success, non-zero otherwise. + Presently this function only returns a success, error + checking may be added later. + Data type Int. + + Pointers and Buffers Modified: + + pPulseInfo contents are updated with pulse information. Specifically, + pPulseInfo->number_pulse with the number of pulses found, and + pPulseInfo->pulse_start_sfb is set to the first scale factor band. + Then pPulseInfo->pulse_offset and pPulseInfo->pulse_amp are filled + with data. For these array, only the number of pulses defined will be + set, those values beyond the number of pulses will retain their previous + value and should not be read from. + Note: The value in pPulseInfo->number_pulse is different by a value of + one from the original ISO code. + + pInputBuffer contents are updated to the next location to be read from + the input stream. + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function fills in the pulse data structure with information to be used + later for restoring pulses in the spectrum. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global or static variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Table 6.17 - Syntax of pulse_data(), + page 15, and section 9.3 "Decoding process", starting on page 41. + + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = SUCCESS; + + CALL getbits(neededBits = LEN_PULSE_NPULSE + LEN_PULSE_ST_SFB, + pInputStream = pInputStream) + MODIFYING(*pInputStream) + RETURNING(temp) + + pPulseInfo->number_pulse = 1 + (temp >> LEN_PULSE_ST_SFB); + pPulseInfo->pulse_start_sfb = temp & ((1 << LEN_PULSE_ST_SFB) - 1); + + pPulseOffset = &pPulseInfo->pulse_offset[0]; + pPulseAmp = &pPulseInfo->pulse_amp[0]; + + FOR (i = PulseInfo->number_pulse; i > 0; i--) + CALL getbits(neededBits = LEN_PULSE_POFF + LEN_PULSE_PAMP, + pInputStream = pInputStream) + MODIFYING(*pInputStream) + RETURNING(temp) + + *pPulseOffset++ = temp >> LEN_PULSE_PAMP; + *pPulseAmp++ = temp & ((1 << LEN_PULSE_PAMP) - 1); + END FOR + + MODIFYING (*pInputStream) + MODIFYING (*pPulseInfo) + + RETURN status + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "ibstream.h" +#include "s_pulseinfo.h" +#include "s_bits.h" +#include "e_rawbitstreamconst.h" +#include "get_pulse_data.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int get_pulse_data( + PulseInfo *pPulseInfo, + BITS *pInputStream) +{ + Int i; + Int *pPulseOffset; + Int *pPulseAmp; + Int status = SUCCESS; + UInt temp; + + /* + * Read in both field fields at once to save cycles. These are the + * original lines of code: + * pPulseInfo->number_pulse = getbits(LEN_PULSE_NPULSE, pInputStream); + * pPulseInfo->pulse_start_sfb = getbits(LEN_PULSE_ST_SFB, pInputStream); + */ + + temp = + get9_n_lessbits( + LEN_PULSE_NPULSE + LEN_PULSE_ST_SFB, + pInputStream); + + pPulseInfo->number_pulse = (Int)(1 + (temp >> LEN_PULSE_ST_SFB)); + pPulseInfo->pulse_start_sfb = (Int)(temp & ((1 << LEN_PULSE_ST_SFB) - 1)); + + pPulseOffset = &pPulseInfo->pulse_offset[0]; + pPulseAmp = &pPulseInfo->pulse_amp[0]; + + /* + * This loop needs to count one more than the number read in from + * the bitstream - look at reference [1]. + */ + + for (i = pPulseInfo->number_pulse; i > 0; i--) + { + /* + * Read in both fields. Original lines: + * *pPulseOffset++ = getbits(LEN_PULSE_POFF, pInputStream); + * *pPulseAmp++ = getbits(LEN_PULSE_PAMP, pInputStream); + */ + + temp = + get9_n_lessbits( + LEN_PULSE_POFF + LEN_PULSE_PAMP, + pInputStream); + + *pPulseOffset++ = (Int)(temp >> LEN_PULSE_PAMP); + + *pPulseAmp++ = (Int)(temp & ((1 << LEN_PULSE_PAMP) - 1)); + } + + return (status); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_pulse_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_pulse_data.h new file mode 100644 index 0000000..e3d890b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_pulse_data.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_pulse_data.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for get_pulse_data.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_PULSE_DATA_H +#define GET_PULSE_DATA_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_pulseinfo.h" +#include "s_bits.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int get_pulse_data( + PulseInfo *pPulseInfo, + BITS *pInputStream); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* GET_PULSE_DATA_H */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.cpp new file mode 100644 index 0000000..49047b1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.cpp @@ -0,0 +1,176 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_bitstream.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + INPUT + + SBRDECODER self, + SBRBITSTREAM * stream, + float *timeData, + int numChannels + + OUTPUT + + errorCode, noError if successful + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + sbr decoder processing, set up SBR decoder phase 2 in case of + different cotrol data + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#ifdef AAC_PLUS + +#include "get_sbr_bitstream.h" +#include "pv_audio_type_defs.h" +#include "sbr_crc_check.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void get_sbr_bitstream(SBRBITSTREAM *sbrBitStream, BITS *pInputStream) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + + Int32 count; + Int32 esc_count; + Int32 Extention_Type; + Int32 i; + + count = get9_n_lessbits(LEN_F_CNT, pInputStream); + if (count == 15) + { + esc_count = get9_n_lessbits(LEN_F_ESC, pInputStream); + count = esc_count + 14; + } + + + + Extention_Type = get9_n_lessbits(LEN_F_CNT, pInputStream); + + + if (((Extention_Type == SBR_EXTENSION) || (Extention_Type == SBR_EXTENSION_CRC)) + && (count < MAXSBRBYTES) && (count) && (sbrBitStream->NrElements < MAXNRELEMENTS)) + { + + sbrBitStream->sbrElement[sbrBitStream->NrElements].ExtensionType = Extention_Type; + sbrBitStream->sbrElement[sbrBitStream->NrElements].Payload = count; + sbrBitStream->sbrElement[sbrBitStream->NrElements].Data[0] = (UChar) get9_n_lessbits(LEN_F_CNT, pInputStream); + for (i = 1 ; i < count ; i++) + { + sbrBitStream->sbrElement[sbrBitStream->NrElements].Data[i] = (UChar) get9_n_lessbits(8, pInputStream); + } + + sbrBitStream->NrElements += 1; + + } + else + { + pInputStream->usedBits += (count - 1) * LEN_BYTE; + pInputStream->usedBits += 4; /* compenste for LEN_F_CNT (=4) bits read for Extention_Type */ + + } +} + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.h new file mode 100644 index 0000000..43fc238 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.h @@ -0,0 +1,120 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_bitstream.h + Funtions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_SBR_BITSTREAM_H +#define GET_SBR_BITSTREAM_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_bits.h" +#include "ibstream.h" +#include "e_rawbitstreamconst.h" +#include "s_sbrbitstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void get_sbr_bitstream(SBRBITSTREAM *sbrBitStream, + BITS *pInputStream); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.cpp new file mode 100644 index 0000000..1c806e2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.cpp @@ -0,0 +1,176 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_startfreq.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "get_sbr_startfreq.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const Int v_offset[7][16] = +{ + { -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}, + { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13}, + { -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, + { -6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, + { -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20}, + { -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24}, + { 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24, 28, 33} +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int get_sbr_startfreq(const Int32 fs, + const Int32 start_freq) +{ + Int k0_min = 0; + Int32 index; + + + switch (fs) + { + case 16000: + index = 0; + k0_min = 24; + break; + case 22050: + index = 1; + k0_min = 17; + break; + case 24000: + index = 2; + k0_min = 16; + break; + case 32000: + index = 3; + k0_min = 16; + break; + case 44100: + index = 4; + k0_min = 12; + break; + case 48000: + index = 4; + k0_min = 11; + break; + case 64000: + index = 4; + k0_min = 10; + break; + case 88200: + case 96000: + index = 5; + k0_min = 7; + break; + + default: + index = 6; + } + return (k0_min + v_offset[index][start_freq]); + +} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.h new file mode 100644 index 0000000..044a97f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.h @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_startfreq.h + Funtions: + get_dse + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_SBR_STARTFREQ_H +#define GET_SBR_STARTFREQ_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int get_sbr_startfreq(const Int32 fs, + const Int32 start_freq); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.cpp new file mode 100644 index 0000000..0e5eeee --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.cpp @@ -0,0 +1,183 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_stopfreq.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + if(fs < 32000) + { + k1_min = (Int) ( ( (float) (6000 * 2 * 64) / fs ) + 0.5 ); + } + else + { + if (fs < 64000) + { + k1_min = (Int) ( ( (float) (8000 * 2 * 64) / fs ) + 0.5 ); + } + else + { + k1_min = (Int) ( ((float) (10000 * 2 * 64) / fs ) + 0.5); + } + } + + return((Int)( k1_min * pow( 64.0 / k1_min,(stop_freq)/13.0) + 0.5)); + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#include "get_sbr_stopfreq.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +const UChar sbr_stopfreq_tbl[6][13] = +{ + + { 21, 23, 25, 27, 29, 32, 35, 38, 41, 45, 49, 54, 59}, /* 48000 */ + { 23, 25, 27, 29, 31, 34, 37, 40, 43, 47, 51, 55, 59}, /* 44100 */ + { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61}, /* 32000 and 24000 */ + { 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 58, 61}, /* 22050 */ + { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62} /* 16000 */ + +}; + +Int get_sbr_stopfreq(const Int32 fs, + const Int32 stop_freq) +{ + + Int i; + + switch (fs) + { + case 48000: + i = 0; + break; + + case 32000: + case 24000: + i = 2; + break; + + case 22050: + i = 3; + break; + + case 16000: + i = 4; + break; + + case 44100: + default: + i = 1; + break; + } + + return((Int)sbr_stopfreq_tbl[i][stop_freq]); + +} + + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.h new file mode 100644 index 0000000..fceb534 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.h @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_stopfreq.h + Funtions: + get_dse + +------------------------------------------------------------------------------ + + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_SBR_STOPFREQ_H +#define GET_SBR_STOPFREQ_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int get_sbr_stopfreq(const Int32 fs, + const Int32 stop_freq); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sign_bits.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sign_bits.h new file mode 100644 index 0000000..0cbaad8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_sign_bits.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sign_bits.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for the function get_sign_bits() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_SIGN_BITS_H +#define GET_SIGN_BITS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void get_sign_bits( + Int q[], + BITS *pInputStream, + const Int q_len +); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* GET_SIGN_BITS_H */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_tns.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_tns.cpp new file mode 100644 index 0000000..437e0bf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_tns.cpp @@ -0,0 +1,514 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_tns.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + FrameInfo *pFrameInfo + Pointer to structure that holds information about each block. + (long block flag, + number of subblocks, + scalefactor bands per subblock, etc.) + + BITS *pInputStream + Pointer to a BITS structure that is + passed on to function getbits to pull information from the bitstream. + + TNS_Frame_info *pTnsFrameInfo + Pointer to filter data structure - to be populated by this function. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + TNS_frame_info *pTnsFrameInfo + + pTnsFrameInfo->n_filt = Number of tns filters to be applied to the data. + + pTnsFrameInfo->filt[]->order = The order of each individual TNS filter. + + pTnsFrameInfo->filt[]->coef_res = The resolution of the filter coefficients + + pTnsFrameInfo->filt[]->start_band = start of spectral band + + pTnsFrameInfo->filt[]->stop_band = end of spectral band + + pTnsFrameInfo->filt[]->coef[] = Each filter's coefficients are filled with + data read from the input bitstream. + + pTnsFrameInfo->filt[]->direction = A flag is set for each TNS filter. + + If the direction flag (on the bitstream) = 0, then the filter + is applied to the block of spectral data in normal (upward) fashion. + + If the direction flag (on the bitstream) = 1, then the filter + is applied in a reverse (downward) fashion. + (Starting with the last element in the block of data.) + + The value stored in filt[]->direction maps the values [0,1] to [1,-1] for + a more intuitive storage of this flag's meaning. + + Local Stores Modified: + + Global Stores Modified: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads the TNS filter information from the bitstream, and stores + the filter order, LPC coefficients, and the number of TNS filters to + be applied in the structure TNS_frame_info. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This code should match the ISO code in functionality, with the exception + that coef_res has range of [0,1] (PV code) instead of [3,4] (ISO code) + + coef_res is only used by tns_decode_coef. + +------------------------------------------------------------------------------ + REFERENCES + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.8 (Temporal Noise Shaping) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "get_tns.h" +#include "s_mc_info.h" +#include "s_frameinfo.h" +#include "s_tnsfilt.h" +#include "s_tns_frame_info.h" +#include "s_bits.h" +#include "ibstream.h" +#include "e_window_sequence.h" +#include "e_progconfigconst.h" + +#include "tns_decode_coef.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#define SCALE_FACTOR_BAND_OFFSET(x) ( ((x) > 0) ? pSFB_top[(x)-1] : 0 ) +#define MINIMUM(x,y) ( ((x) < (y)) ? (x) : (y) ) + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/* + * The entries in the ensuing tables provide the maximum permissable + * number of scalefactor bands for each TNS filter. This value is effected + * by the sampling rate, and window type. + */ + +const Int tns_max_bands_tbl_long_wndw[(1<win_sfb_top[0]; + + Int f; + Int t; + Int win; + UInt tempInt; + + Int num_filt_bits; + Int num_order_bits; + Int num_start_band_bits; + + Int top; + Int res; + Int res_index; + Int compress; + + Int sfb_per_win; + + Int32 *pLpcCoef; + Int32 *pStartLpcCoef; + Int s_mask; + Int n_mask; + + Int tns_bands; + UInt max_order; + Int coef_res; + + + TNSfilt *pFilt; + + if (wnd_seq != EIGHT_SHORT_SEQUENCE) + { + num_filt_bits = 2; + num_order_bits = 5; + num_start_band_bits = 6; + + tns_bands = tns_max_bands_tbl_long_wndw[pMC_Info->sampling_rate_idx]; + + /* + * Definition from 14496-3:1999 doc. Our first encoder follows this rule, + * later encoders don't + */ + + if (pMC_Info->sampling_rate_idx > 4) /* if (sampling_rate <= 32000 */ + { + max_order = 20; + } + else + { + max_order = 12; + } + } + else + { + num_filt_bits = 1; + num_order_bits = 3; + num_start_band_bits = 4; + + tns_bands = tns_max_bands_tbl_short_wndw[pMC_Info->sampling_rate_idx]; + + max_order = 7; + } + + /* + * After this branch, tns_bands will be equal to the minimum of + * the passed in variable, nbands, and the result from the + * tns_max_bands_tbl + */ + + if (max_bands < tns_bands) + { + tns_bands = max_bands; + } + + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + win = 0; + + pLpcCoef = pTnsFrameInfo->lpc_coef; + + pFilt = pTnsFrameInfo->filt; + + do + { + tempInt = get9_n_lessbits(num_filt_bits, + pInputStream); + + pTnsFrameInfo->n_filt[win] = tempInt; + + if (tempInt != 0) + { + /* + * coef_res = [0, 1] + * Switch between a resolution of 3 and 4 bits respectively + * + * if coef_res = 0, the coefficients have a range of + * + * -4 -3 -2 -1 0 1 2 3 + * + * if coef_res = 1, the coefficients have a range of + * + * -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 + * + * The arrays in ./src/tns_tab.c are completely based on + * the value of coef_res. + */ + res = get1bits( + pInputStream); + + /* res is post-incremented for correct calculation of res_index */ + coef_res = res++; + + top = sfb_per_win; + + for (f = pTnsFrameInfo->n_filt[win]; f > 0; f--) + { + tempInt = MINIMUM(top, tns_bands); + + pFilt->stop_coef = SCALE_FACTOR_BAND_OFFSET(tempInt); + + pFilt->stop_band = tempInt; + + top -= get9_n_lessbits(num_start_band_bits, + pInputStream); + + tempInt = MINIMUM(top, tns_bands); + + pFilt->start_coef = SCALE_FACTOR_BAND_OFFSET(tempInt); + + pFilt->start_band = tempInt; + + tempInt = get9_n_lessbits(num_order_bits, + pInputStream); + + pFilt->order = tempInt; + + if (tempInt != 0) + { + if (tempInt > max_order) + { + pFilt->order = max_order; + } + + /* + * This maps the bitstream's [0,1] to + * pFilt->direction = [1,-1] + */ + + tempInt = get1bits(pInputStream); + + pFilt->direction = (-(Int)tempInt) | 0x1; + + /* + * compress = [0,1] + * If compress is true, the MSB has + * been omitted from transmission (Ref. 1) + * + * For coef_res = 0, this limits the range of + * transmitted coefficients to... + * + * -2 -1 0 1 + * + * For coef_res = 1, the coefficients have + * a range of... + * + * -4 -3 -2 -1 0 1 2 3 + */ + compress = get1bits(pInputStream); + + /* + * res has a range of [1,2] + * compress has a range of [0,1] + * So (res - compress) has range [0,2]; + */ + res_index = res - compress; + + s_mask = 2 << res_index; + + /* + * If res_index = 0, grab 2 bits of data + * If res_index = 1, grab 3 bits of data + * If res_index = 2, grab 4 bits of data + */ + res_index += 2; + + pStartLpcCoef = pLpcCoef; + + for (t = pFilt->order; t > 0; t--) + { + /* + * These are the encoded coefficients, which will + * later be decoded into LPC coefficients by + * the function tns_decode_coef() + */ + tempInt = get9_n_lessbits(res_index, + pInputStream); + + n_mask = -((Int)tempInt & s_mask); + + /* + * n_mask is used to sign_extend the + * value, if it is negative. + * + */ + *(pLpcCoef++) = tempInt | n_mask; + } + + /* Decode the TNS coefficients */ + + tempInt = pFilt->stop_coef - pFilt->start_coef; + + if (tempInt > 0) + { + pFilt->q_lpc = + tns_decode_coef( + pFilt->order, + coef_res, + pStartLpcCoef, + scratchTnsDecCoefMem); + } + + } /* if (pTnsFilt->order != 0) */ + + pFilt++; + + } /* END for (f=pTnsInfo->n_filt; f>0; f--, pTnsFilt++) */ + + } /* if (pTnsInfo->n_filt != 0) */ + + win++; + + } + while (win < pFrameInfo->num_win); + + return; + +} /* get_tns */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_tns.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_tns.h new file mode 100644 index 0000000..8b5b16f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/get_tns.h @@ -0,0 +1,100 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_tns.h + + Author: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes the function definition for get_tns.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_TNS_H +#define GET_TNS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" +#include "s_mc_info.h" +#include "s_tns_frame_info.h" +#include "s_bits.h" +#include "e_window_sequence.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + void get_tns( + const Int max_bands, + BITS * const pInputStream, + const WINDOW_SEQUENCE wnd_seq, + const FrameInfo * const pFrameInfo, + const MC_Info * const pMC_Info, + TNS_frame_info * const pTnsFrameInfo, + Int32 scratchTnsDecCoefMem[]); + + +#ifdef __cplusplus +} +#endif + +#endif /* GET_TNS_H */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getbits.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getbits.h new file mode 100644 index 0000000..919686d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getbits.h @@ -0,0 +1,335 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getbits.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for the function getbits(). + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GETBITS_H +#define GETBITS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "ibstream.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + +#define INBUF_ARRAY_INDEX_SHIFT (3) +#define INBUF_BIT_WIDTH (1<<(INBUF_ARRAY_INDEX_SHIFT)) +#define INBUF_BIT_MODULO_MASK ((INBUF_BIT_WIDTH)-1) + +#define MAX_GETBITS (25) + +#define CHECK_INPUT_BUFFER_LIMITS 1 + + __inline UInt32 getbits( + const UInt neededBits, + BITS *pInputStream) + { + UInt32 returnValue = 0; + UInt offset; + UInt bitIndex; + UChar *pElem; /* Needs to be same type as pInput->pBuffer */ + + offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + pElem = pInputStream->pBuffer + offset; + +#if CHECK_INPUT_BUFFER_LIMITS + + offset = pInputStream->inputBufferCurrentLength - offset; + /* check if access to input buffer does not go beyond boundaries */ + if (offset > 3) + { + returnValue = (((UInt32) * (pElem)) << 24) | + (((UInt32) * (pElem + 1)) << 16) | + (((UInt32) * (pElem + 2)) << 8) | + ((UInt32) * (pElem + 3)); + } + else /* then access only available bytes */ + { + /* Access to the bitstream beyond frame boundaries are not allowed, + * Here, only what was available before the end of the frame will + * be processed. Non-accessible bytes will be filled in with zeros. + * Zero values guarantees that the data structures are filled in with values + * that eventually will signal an error (like invalid parameters) or that allow + * completion of the parsing routine. + * Overrun is detected on file pvmp4audiodecodeframe.cpp. + */ + switch (offset) + { + case 3: + returnValue = (((UInt32) * (pElem + 2)) << 8); + case 2: + returnValue |= (((UInt32) * (pElem + 1)) << 16); + case 1: + returnValue |= (((UInt32) * (pElem)) << 24); + default: + break; + } + } + + +#else + + returnValue = (((UInt32) * (pElem)) << 24) | + (((UInt32) * (pElem + 1)) << 16) | + (((UInt32) * (pElem + 2)) << 8) | + ((UInt32) * (pElem + 3)); +#endif + + /* Remove extra high bits by shifting up */ + bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK); + + /* This line is faster way to mask off the high bits. */ + returnValue = returnValue << (bitIndex); + + /* Move the field down. */ + returnValue = returnValue >> (32 - neededBits); + + pInputStream->usedBits += neededBits; + + return (returnValue); + + } + + + + __inline UInt get1bits( + BITS *pInputStream) + { + UInt returnValue; + UInt offset; + UInt bitIndex; + UChar *pElem; /* Needs to be same type as pInput->pBuffer */ + + offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + pElem = pInputStream->pBuffer + offset; + +#if CHECK_INPUT_BUFFER_LIMITS + returnValue = (offset < pInputStream->inputBufferCurrentLength) ? ((UInt) * (pElem)) : 0; +#else + returnValue = ((UInt32) * (pElem)); +#endif + + + /* Remove extra high bits by shifting up */ + bitIndex = (UInt)((pInputStream->usedBits++) & INBUF_BIT_MODULO_MASK); + + /* This line is faster way to mask off the high bits. */ + returnValue = 0xFF & (returnValue << (bitIndex)); + + /* Move the field down. */ + + return ((UInt)(returnValue >> 7)); + + } + + + + __inline UInt get9_n_lessbits( + const UInt neededBits, + BITS *pInputStream) + + { + UInt returnValue; + UInt offset; + UInt bitIndex; + UChar *pElem; /* Needs to be same type as pInput->pBuffer */ + + offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + pElem = pInputStream->pBuffer + offset; + +#if CHECK_INPUT_BUFFER_LIMITS + + + offset = pInputStream->inputBufferCurrentLength - offset; + /* check if access to input buffer does not go beyond boundaries */ + if (offset > 1) + { + returnValue = (((UInt32) * (pElem)) << 8) | + ((UInt32) * (pElem + 1)); + } + else /* then access only available bytes */ + { + /* Access to the bitstream beyond frame boundaries are not allowed, + * Here, only what was available before the end of the frame will + * be processed. Non-accessible bytes will be filled in with zeros. + * Zero values guarantees that the data structures are filled in with values + * that eventually will signal an error (like invalid parameters) or that allow + * completion of the parsing routine. + * Overrun is detected on file pvmp4audiodecodeframe.cpp + */ + switch (offset) + { + case 1: + returnValue = (((UInt32) * (pElem)) << 8); + break; + default: + returnValue = 0; + break; + } + } + + +#else + returnValue = (((UInt32) * (pElem)) << 8) | + ((UInt32) * (pElem + 1)) ; +#endif + + /* Remove extra high bits by shifting up */ + bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK); + + pInputStream->usedBits += neededBits; + + /* This line is faster way to mask off the high bits. */ + returnValue = 0xFFFF & (returnValue << (bitIndex)); + + /* Move the field down. */ + + return (UInt)(returnValue >> (16 - neededBits)); + + } + + __inline UInt32 get17_n_lessbits( + const UInt neededBits, + BITS *pInputStream) + { + UInt32 returnValue; + UInt offset; + UInt bitIndex; + UChar *pElem; /* Needs to be same type as pInput->pBuffer */ + + offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + pElem = pInputStream->pBuffer + offset; + +#if CHECK_INPUT_BUFFER_LIMITS + + offset = pInputStream->inputBufferCurrentLength - offset; + /* check if access to input buffer does not go beyond boundaries */ + + if (offset > 2) + { + returnValue = (((UInt32) * (pElem)) << 16) | + (((UInt32) * (pElem + 1)) << 8) | + ((UInt32) * (pElem + 2)); + } + else /* then access only available bytes */ + { + /* Access to the bitstream beyond frame boundaries are not allowed, + * Here, only what was available before the end of the frame will + * be processed. Non-accessible bytes will be filled in with zeros. + * Zero values guarantees that the data structures are filled in with values + * that eventually will signal an error (like invalid parameters) or that allow + * completion of the parsing routine. + * Overrun is detected on file pvmp4audiodecodeframe.cpp + */ + returnValue = 0; + switch (offset) + { + case 2: + returnValue = (((UInt32) * (pElem + 1)) << 8); + case 1: + returnValue |= (((UInt32) * (pElem)) << 16); + default: + break; + } + } + +#else + + returnValue = (((UInt32) * (pElem)) << 16) | + (((UInt32) * (pElem + 1)) << 8) | + ((UInt32) * (pElem + 2)); +#endif + + /* Remove extra high bits by shifting up */ + bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK); + + /* This line is faster way to mask off the high bits. */ + returnValue = 0xFFFFFF & (returnValue << (bitIndex)); + + /* Move the field down. */ + returnValue = returnValue >> (24 - neededBits); + + pInputStream->usedBits += neededBits; + + return (returnValue); + + } + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* GETBITS_H*/ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getfill.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getfill.cpp new file mode 100644 index 0000000..ddeb9ec --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getfill.cpp @@ -0,0 +1,200 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getfill.cpp + Funtions: getfill + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to structure BITS containing input stream + information. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pInputStream->usedBits is updated to the newly calculated value. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function passes over fill bits in the raw data block to adjust the + instantaneous bit rate when the bitstream is to be transmitted over a + constant rate channel. + +------------------------------------------------------------------------------ + REQUIREMENTS + + None + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p15 (Table 4.4.11) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + CALL getbits( + LEN_F_CNT, + pInputStream); + MODIFYING (pInputStream) + RETURNING (cnt) + + IF ( cnt == (1<usedBits += cnt * LEN_BYTE; + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "ibstream.h" +#include "e_rawbitstreamconst.h" +#include "getfill.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void getfill(BITS *pInputStream) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + Int cnt; + Int esc_cnt; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + cnt = get9_n_lessbits( + LEN_F_CNT, + pInputStream); + + if (cnt == (1 << LEN_F_CNT) - 1) /* if (cnt == 15) */ + { + esc_cnt = get9_n_lessbits( + LEN_F_ESC, + pInputStream); + + cnt += esc_cnt - 1; + } + + /* + * The following codes are replaced by directly updating usedBits + * in BITS structure. This will save one call for getbits(). + * + * for (i=0; iusedBits += cnt * LEN_BYTE; + + /*---------------------------------------------------------------------------- + ; Return nothing or data or data pointer + ----------------------------------------------------------------------------*/ + +} /* getfill */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getfill.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getfill.h new file mode 100644 index 0000000..1c887c7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getfill.h @@ -0,0 +1,90 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getfill.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file contains prototype declaration for getfill function. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GETFILL_H +#define GETFILL_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void getfill(BITS *pInputStream); + +#ifdef __cplusplus +} +#endif + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getgroup.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getgroup.cpp new file mode 100644 index 0000000..51fab4f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getgroup.cpp @@ -0,0 +1,214 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getgroup.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to structure that holds input bitstream + information. Type BITS + + group[] = array that holds the index of the first window in each + group. Type Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + group contains the index of first windows in each group + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads the window grouping information associated with an + Individual Channel Stream (ICS). If the window sequence is + EIGHT_SHORT_SEQUENCE, scalefactor grouping information is transmitted. If a + set of short windows form a group then they share scalefactors, intensity + positions and PNS information. The first short window is always a new group + so no grouping bit is transmitted. Subsequent short windows are in the same + group if the associated grouping bit is 1. A new group is started if the + associated grouping bit is 0. + The pointer pGroup points to an array that stores the first window index + of next group. For example, if the window grouping is: + + window index: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | + grouping : |<- 0 ->| 1 |<- 2 ->|<- 3 ->| + + Then: + + group[] : | 2 | 3 | 6 | 8 | + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should replace the contents of the array pointed to by pGroup + with the first window indexes of groups starting from the second group. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 + p16 (Table 4.4.6) + p55 (Recovering ics_info) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF (pFrameInfo->coef_per_win[0] > SN2) + + *pGroup++ = 1; + *pGroup = 1; + + ELSE + + FOR (win = 1; win < pFrameInfo->num_win; win++) + + IF (getbits(1,pInputStream) == 0) + + *pGroup++ = win; + + ENDIF + + ENDFOR (win) + + *pGroup = win; + + ENDIF(pFrameInfo) + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define SEVEN 7 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void getgroup( + Int group[], + BITS *pInputStream) +{ + Int win; + Int *pGroup; + UInt mask; + UInt groupBits; + + pGroup = group; + + mask = 0x40; + + /* only short-window sequences are grouped! + * first short window is always a new group, + * start reading bitstream from the second + * window, a new group is indicated by an + * "0" bit in the input stream + */ + groupBits = + get9_n_lessbits( + SEVEN, + pInputStream); + + for (win = 1; win < NUM_SHORT_WINDOWS; win++) + { + if ((groupBits & mask) == 0) + { + *pGroup++ = win; + + } /* if (groupBits) */ + + mask >>= 1; + + } /* for (win) */ + + *pGroup = win; + +} /* getgroup */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getics.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getics.cpp new file mode 100644 index 0000000..b7371e0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getics.cpp @@ -0,0 +1,619 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getics.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to structure that holds input stream, + Type BITS + + common_window = flag that indicates whether left and right channel + share the same window sequence & shape, Type Int + + pVars = pointer to structure that holds decoder information + Type tDec_Int_File + + pChVarsCh = pointer to structure that holds channel related + decoding information, Type tDec_Int_Chan + + group[] = pointer to array that contains window grouping + information of current frame, Type UChar + + pMax_sfb = pointer to variable that stores maximum active + scalefactor bands of current frame, Type UChar + + pCodebookMap = pointer to array that holds the indexes of all + Huffman codebooks used for current frame, ordered + from section 0 to last section. Type UChar + + pTnsFrameInfo = pointer to structure that holds TNS information. + Type TNS_frame_info + + pWinMap = array of pointers which points to structures that + hold information of long and short window sequences + Type FrameInfo + + pPulseInfo = pointer to structure that holds pulse data decoding + information, Type Nec_info + + sect[] = array of structures that hold section codebook and + section length in current frame, Type SectInfo + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + status = 0 if success + 1 otherwise + + Pointers and Buffers Modified: + pCodebookMap contents are replaced by the indexes of all the huffman + codebooks used for current frame + + pWinMap For short windows, the contents of frame_sfb_top are + modified by calc_gsfb_table, with the top coefficient + index of each scalefactor band. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function decodes individual channel stream by calling other Huffman + decoding functions. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function replaces the contents of pCodebookMap with the decoded + codebook indexes. By calling hufffac, it decodes scale factor data. Call + huffspec_fxp to decode spectral coefficients of current frame. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p24 (Table 4.4.24) + p54 (4.5.2.3.2) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pGroup = group; + + global_gain = CALL getbits( + neededBits = LEN_SCL_PCM, + pInputStream = pInputStream) + MODIFYING(pInputStream) + ReTURNING(global_gain) + + IF (common_window == FALSE) + THEN + status = CALL get_ics_info( + pVars->mc_info.audioObjectType, + pInputStream, + common_window, + &pChVars->wnd, + &pChVars->wnd_shape_this_bk, + group, + pMax_sfb, + pWinMap, + &pChVars->lt_status, + NULL) + MODIFYING(pInputStream,pChVars,group,max_sfb,lt_status) + RETURNING(status) + ENDIF + + memcpy(pFrameInfo, pWinMap[pChVars->wnd], sizeof(FrameInfo)) + + IF (*pMax_sfb > 0) + THEN + + i = 0; + totSfb = 0; + + DO + + totSfb++; + + WHILE( *pGroup++ < pFrameInfo->num_win); + + totSfb *= pFrameInfo->sfb_per_win[0]; + + nsect = CALL huffcb( + sect, + pInputStream, + pFrameInfo->sectbits, + totSfb, + pFrameInfo->sfb_per_win[0], + *pMax_sfb) + MODIFYING(sect,pInputStream,sectbits) + RETURNING(nsect) + + IF (nsect == 0) + THEN + status = 1 + + ENDIF + + sectStart = 0; + FOR (i = 0; i < nsect; i++) + + cb = sect[i].sect_cb; + sectWidth = sect[i].sect_end - sectStart; + sectStart += sectWidth; + + WHILE (sectWidth > 0) + + *pCodebookMap++ = cb + sectWidth-- + ENDWHILE + + ENDFOR (i) + + ELSE + + memset(pCodebookMap,ZERO_HCB,MAXBANDS*sizeof(*pCodebookMap)); + + ENDIF (*pMax_sfb) + + IF (pFrameInfo->islong == FALSE) + THEN + CALL calc_gsfb_table( + pFramInfo = pFrameInfo, + group[] = group) + MODIFYING(pFrameInfo->frame_sfb_top) + RETURNING(void) + ENDIF + + IF (status == SUCCESS) + THEN + status = CALL hufffac( + pFrameInfo, + pInputStream, + group, + nsect, + sect, + global_gain, + pChVars->factors, + pVars->huffBookUsed) + MODIFYING(pInputStream,factors) + RETURNING(status) + + ENDIF (status) + + IF (status == SUCCESS) + THEN + present = CALL getbits( + neededBits = LEN_PULSE_PRES, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(present) + + pPulseInfo->pulse_data_present = present; + + IF (present != FALSE) + THEN + IF (pFrameInfo->islong == 1) + THEN + CALL get_pulse_data( + pPulseInfo = pPulseInfo, + pInputStream = pInputStream) + MODIFYING(pInputStream,pPulseInfo) + RETURNING(void) + + ELSE + + status = 1; + + ENDIF (pFrameInfo) + ENDIF (present) + + ENDIF (status) + + IF (status == SUCCESS) + THEN + present = CALL getbits( + neededBits = LEN_TNS_PRES, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(present) + + pTnsFrameInfo->tns_data_present = present; + + IF (present != FALSE) + THEN + CALL get_tns( + pFrameInfo = pFrameInfo, + pTnsFrameInfo = pTnsFrameInfo, + pInputStream = pInputStream) + MODIFYING(pInputStream, pTnsFrameInfo) + RETURNING(void) + ELSE + + FOR (i = pTnsFrameInfo->n_subblocks - 1; i >= 0 ; i--) + + pTnsFrameInfo->info[i].n_filt = 0; + ENDFOR + + ENDIF(present) + + ENDIF (status) + + IF (status == SUCCESS) + THEN + present = CALL getbits( + neededBits = LEN_GAIN_PRES, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(present) + + IF (present != FALSE) + THEN + status = 1; + ENDIF + ENDIF (status) + + IF (status == SUCCESS) + THEN + status = CALL huffspec_fxp( + pFrameInfo, + pInputStream, + nsect, + sect, + pChVars->factors, + pChVars->fxpCoef, + pVars->quantSpec, + pVars->tmp_spec, + pWinMap[ONLY_LONG_WINDOW], + pPulseInfo, + pChVars->qFormat) + MODIFYING(pInputStream,fxpCoef,quantSpec,tmp_spec,qFormat) + RETURNING(status) + ENDIF + + RETURN status + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_huffmanconst.h" +#include "huffman.h" +#include "aac_mem_funcs.h" +#include "get_tns.h" +#include "e_elementid.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int getics( + Int id_syn_ele, + BITS *pInputStream, + Int common_window, + tDec_Int_File *pVars, + tDec_Int_Chan *pChVars, + Int group[], + Int *pMax_sfb, + Int *pCodebookMap, + TNS_frame_info *pTnsFrameInfo, + FrameInfo **pWinMap, + PulseInfo *pPulseInfo, + SectInfo sect[]) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + Int status = SUCCESS; + + Int nsect = 0; + Int i; + Int cb; + Int sectWidth; + Int sectStart; + Int totSfb; + Int *pGroup; + + FrameInfo *pFrameInfo; + + Int global_gain; /* originally passed in from huffdecode */ + Bool present; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + pGroup = group; + + /* read global gain from Input bitstream */ + global_gain = get9_n_lessbits(LEN_SCL_PCM, pInputStream); + + if (common_window == FALSE) + { + status = get_ics_info(pVars->mc_info.audioObjectType, + pInputStream, + common_window, + &pChVars->wnd, + &pChVars->wnd_shape_this_bk, + group, + pMax_sfb, + pWinMap, + &pChVars->pShareWfxpCoef->lt_status, + NULL); + } + + pFrameInfo = pWinMap[pChVars->wnd]; + + /* at least, number of window should be 1 or 8 */ + if ((pFrameInfo->num_win != 1) && (pFrameInfo->num_win != 8)) + { + status = 1; + } + + /* First, calculate total number of scalefactor bands + * for this grouping. Then, decode section data + */ + if (*pMax_sfb > 0) + { + + /* calculate total number of sfb */ + i = 0; + totSfb = 0; + + do + { + totSfb++; + + } + while (*pGroup++ < pFrameInfo->num_win); + + totSfb *= pFrameInfo->sfb_per_win[0]; + + /* decode section data */ + nsect = huffcb(sect, + pInputStream, + pFrameInfo->sectbits, + totSfb, + pFrameInfo->sfb_per_win[0], + *pMax_sfb); + + if (nsect == 0) + { + status = 1; /* decode section data error */ + + }/* if (nsect) */ + + /* generate "linear" description from section info + * stored as codebook for each scalefactor band and group + * when nsect == 0, for-loop does not execute + */ + sectStart = 0; + for (i = 0; i < nsect; i++) + { + cb = sect[i].sect_cb; + sectWidth = sect[i].sect_end - sectStart; + sectStart += sectWidth; + + while (sectWidth > 0) + { + *pCodebookMap++ = cb; /* cannot use memset for Int */ + sectWidth--; + } + + } /* for (i) */ + + } + else + { + /* set all sections with ZERO_HCB */ + pv_memset(pCodebookMap, + ZERO_HCB, + MAXBANDS*sizeof(*pCodebookMap)); + /* + for (i=MAXBANDS; i>0; i--) + { + *(pCodebookMap++) = ZERO_HCB; + } + */ + + } /* if (*pMax_sfb) */ + + /* calculate band offsets + * (because of grouping and interleaving this cannot be + * a constant: store it in pFrameInfo->frame_sfb_top) + */ + if (pFrameInfo->islong == FALSE) + { + calc_gsfb_table(pFrameInfo, group); + } + + /* decode scale factor data */ + if (status == SUCCESS) + { + status = hufffac(pFrameInfo, + pInputStream, + group, + nsect, + sect, + global_gain, + pChVars->pShareWfxpCoef->factors, + pVars->scratch.a.huffbook_used); + + } /* if (status) */ + + /* noiseless coding */ + if (status == SUCCESS) + { + present = get1bits(pInputStream); + + pPulseInfo->pulse_data_present = present; + + if (present != FALSE) + { + if (pFrameInfo->islong == 1) + { + status = get_pulse_data(pPulseInfo, + pInputStream); + } + else + { + /* CommonExit(1,"Pulse data not allowed for short blocks"); */ + status = 1; + + } /* if (pFrameInfo) */ + } /* if (present) */ + + } /* if (status) */ + + + /* decode tns data */ + if (status == SUCCESS) + { + present = get1bits(pInputStream); + + pTnsFrameInfo->tns_data_present = present; + + if (present != FALSE) + { + get_tns(pChVars->pShareWfxpCoef->max_sfb, + pInputStream, + pChVars->wnd, + pFrameInfo, + &pVars->mc_info, + pTnsFrameInfo, + pVars->scratch.a.tns_decode_coef); + } + else + { + for (i = pFrameInfo->num_win - 1; i >= 0 ; i--) + { + pTnsFrameInfo->n_filt[i] = 0; + } + + } /* if(present) */ + + } /* if (status) */ + + /* gain control */ + if (status == SUCCESS) + { + present = + get1bits(pInputStream); + + if (present != FALSE) + { + /* CommonExit(1, "Gain control not implemented"); */ + status = 1; + } + } /* if (status) */ + + if (status == SUCCESS) + { + /* Support Mono, Dual-Mono, or Stereo */ + if ((id_syn_ele == ID_SCE) || (id_syn_ele == ID_CPE)) + { + status = huffspec_fxp(pFrameInfo, + pInputStream, + nsect, + sect, + pChVars->pShareWfxpCoef->factors, + pChVars->fxpCoef, + pVars->share.a.quantSpec, + pVars->scratch.tmp_spec, + pWinMap[ONLY_LONG_WINDOW], + pPulseInfo, + pChVars->pShareWfxpCoef->qFormat); + } + } + + /*---------------------------------------------------------------------------- + ; Return status + ----------------------------------------------------------------------------*/ + + return status; + +} /* getics */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getmask.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getmask.cpp new file mode 100644 index 0000000..38b471c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/getmask.cpp @@ -0,0 +1,356 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getmask.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pFrameInfo = pointer to structure that holds information for current + frame, Type FrameInfo + + pInputStream= pointer to structure that holds input stream information + Type BITS + + pGroup = pointer to array that holds the stop window index for + each group in current frame, Type Int + + max_sfb = number of active sfbs for each window, Type Int + + mask[] = array that holds the MS_mask information + Type Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + mask_present = 0 (no Mid/Side mixed) + 2 (Mid/Side mixed present for entire frame) + 1 (Mid/Side mixed information read from bitstream) + -1 (invalid mask_present read from bitstream) + + Pointers and Buffers Modified: + pMask contents replaced by MS information of each scalefactor band + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads the Mid/Side(MS) mask information from the input + bitstream. If the mask_present field is equal to 2, the mask bits is set to + 1 for the entire frame. If mask_present has a value of 0, the function + returns 0, If mask_present is set to 1, the Mid/Side(MS) information is + read from the input stream. When mask_present is 3, an error code (-1) is + generated. + The Mid/Side(MS) information is later used for mixing the left and right + channel sounds. Each scalefactor band has its own MS information. + + (ISO comments: read a synthesis mask, read a synthesis mask uses + EXTENDED_MS_MASK and grouped mask ) + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall replace the contents of pMask with the MS information + of each scalefactor band + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 + p15 (Table 4.4.5 getmask) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + CALL getbits(LEN_MASK_PRES, pInputStream) + MODIFYING (pInputStream) + RETURNING (mask present information) + mask_present = mask present information + + SWITCH (mask_present) + + CASE (0): + BREAK; + + CASE (2): + nwin = pFrameInfo->num_win; + FOR(win = 0; win < nwin; win = *(pGroup++)) + + FOR(sfb = pFrameInfo->sfb_per_win[win]; sfb > 0; sfb--) + *(pMask++) = 1; + ENDFOR + + ENDFOR + + BREAK; + + CASE(1): + + nwin = pFrameInfo->num_win; + + nToDo = max_sfb; + + WHILE (nToDo > 0) + nCall = nToDo; + + IF (nCall > MAX_GETBITS) + THEN + nCall = MAX_GETBITS; + ENDIF + + tempMask = + getbits( + nCall, + pInputStream); + + bitmask = 1 << (nCall - 1); + FOR (sfb = nCall; sfb > 0; sfb--) + *(pMask++) = (tempMask & bitmask) >> (sfb - 1); + bitmask >>= 1; + ENDFOR + + nToDo -= nCall; + END WHILE + + pv_memset( + pMask, + 0, + (pFrameInfo->sfb_per_win[win]-max_sfb)*sizeof(*pMask)); + + ENDFOR (win) + + BREAK + + DEFAULT: + mask_present = -1 + + ENDSWITCH + + RETURN mask_present + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" +#include "aac_mem_funcs.h" +#include "e_maskstatus.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int getmask( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int group[], + Int max_sfb, + Int mask[]) +{ + + Int win; /* window index */ + Int sfb; + Int mask_present; + Int *pMask; + Int *pGroup; + Int nwin; + Int nCall; + Int nToDo; + UInt32 tempMask; + UInt32 bitmask; + + pMask = mask; + pGroup = group; + + mask_present = + get9_n_lessbits( + LEN_MASK_PRES, + pInputStream); + + switch (mask_present) + { + case(MASK_NOT_PRESENT): + /* special EXTENDED_MS_MASK cases */ + /* no ms at all */ + break; + + case(MASK_ALL_FRAME): + /* MS for whole spectrum on, mask bits set to 1 */ + nwin = pFrameInfo->num_win; + for (win = 0; win < nwin; win = *(pGroup++)) + { + for (sfb = pFrameInfo->sfb_per_win[win]; sfb > 0; sfb--) + { + *(pMask++) = 1; /* cannot use memset for Int type */ + } + + } + + break; + + case(MASK_FROM_BITSTREAM): + /* MS_mask_present==1, get mask information*/ + nwin = pFrameInfo->num_win; + for (win = 0; win < nwin; win = *(pGroup++)) + { + /* + * the following code is equivalent to + * + * for(sfb = max_sfb; sfb > 0; sfb--) + * { + * *(pMask++) = + * getbits( + * LEN_MASK, + * pInputStream); + * } + * + * in order to save the calls to getbits, the above + * for-loop is broken into two parts + */ + + nToDo = max_sfb; + + while (nToDo > 0) + { + nCall = nToDo; + + if (nCall > MAX_GETBITS) + { + nCall = MAX_GETBITS; + } + + tempMask = + getbits( + nCall, + pInputStream); + + bitmask = (UInt32) 1 << (nCall - 1); + for (sfb = nCall; sfb > 0; sfb--) + { + *(pMask++) = (Int)((tempMask & bitmask) >> (sfb - 1)); + bitmask >>= 1; + } + + nToDo -= nCall; + } + + /* + * set remaining sfbs to zero + * re-use nCall to save one variable on stack + */ + + nCall = pFrameInfo->sfb_per_win[win] - max_sfb; + + + if (nCall >= 0) + { + pv_memset(pMask, + 0, + nCall*sizeof(*pMask)); + + pMask += nCall; + } + else + { + mask_present = MASK_ERROR; + break; + } + + + } /* for (win) */ + + break; + + default: + /* error */ + break; + + } /* switch (mask_present) */ + + return mask_present; + +} /* getmask */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/hcbtables.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/hcbtables.h new file mode 100644 index 0000000..cea34cf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/hcbtables.h @@ -0,0 +1,103 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: hcbtables.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Declare the structure array for Huffman Codebooks information. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef _HCBTABLES_H +#define _HCBTABLES_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "s_hcb.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /* ISO: Hcb book[NSPECBOOKS + 2]; */ + + extern const Hcb hcbbook_binary[13]; + extern const Int32 huff_tab1[88]; + extern const Int32 huff_tab2[90]; + extern const Int32 huff_tab3[151]; + extern const Int32 huff_tab4[119]; + extern const Int32 huff_tab5[110]; + extern const Int32 huff_tab6[113]; + extern const Int32 huff_tab7[107]; + extern const Int32 huff_tab8[90]; + extern const Int32 huff_tab9[204]; + extern const Int32 huff_tab10[186]; + extern const Int32 huff_tab11[301]; + extern const UInt32 huff_tab_scl[188]; + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/hcbtables_binary.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/hcbtables_binary.cpp new file mode 100644 index 0000000..fc39be8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/hcbtables_binary.cpp @@ -0,0 +1,1896 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: hcbtables_binary.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: None + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: None + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This file defines the 12 packed Huffman Tables and a structure that reference + to these tables. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + ISO/IEC 14496-3: 1999(E) + Subpart 4 p78 (Table 4.6.1 and Table 4.6.2) + p77 (pseudo code) + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ +#include "s_hcb.h" +#include "hcbtables.h" + +/* This file store packed Huffman tables for binary tree search */ + +/* + * all tables are packed in the following way: + * right pointer (7 bits) idx (9 bits) + */ + + +const Hcb hcbbook_binary[13] = +{ + + { 0, -1, -1, -1, -1 }, /* ZERO_HCB */ + { 1, 4, 3, 1, 1 }, /* codebook 1 */ + { 2, 4, 3, 1, 1 }, /* codebook 2 */ + { 3, 4, 3, 0, 0 }, /* codebook 3 */ + { 4, 4, 3, 0, 0 }, /* codebook 4 */ + { 5, 2, 9, 4, 1 }, + { 6, 2, 9, 4, 1 }, + { 7, 2, 8, 0, 0 }, + { 8, 2, 8, 0, 0 }, + { 9, 2, 13, 0, 0 }, + {10, 2, 13, 0, 0 }, + {11, 2, 17, 0, 0 }, /* codebook 11 ESC book */ + {12, -1, -1, -1, -1 } /* scalefactor codebook */ + + +}; + + +/* New look-up table for huffman decoding + Created by ordering the codeword in the table according to their + normalized shifted binary value, i.e., all the codewords are left + shifted to meet the maximum codelength. Example, max codelength is + 10, the codeword with lenth 3 will left shift by 7. + The binary values of after the shift are sorted. + Then the sorted table is divided into several partition. + At the VLC decoding period, input is read in at max codelenght. + The partition is decided using if-else logic. + Inside each partition, a look-up table is used to map the input value + to a correct symbol. Table entries can appear to be repeated according + to the humming distance between adjacent codewords. +*/ + +const Int32 huff_tab1[88] = +{ + 0x430005, + 0xd0005, + 0x270005, + 0x310005, + 0x290005, + 0x250005, + 0x2b0005, + 0x1f0005, + 0x3a0007, + 0x160007, + 0x260007, + 0x2e0007, + 0x220007, + 0x2a0007, + 0x4c0007, + 0x240007, + 0x40007, + 0x1c0007, + 0x400007, + 0x300007, + 0x100007, + 0x2c0007, + 0x460007, + 0x200007, + 0x340007, + 0x320007, + 0xa0007, + 0x440007, + 0xc0007, + 0x420007, + 0xe0007, + 0x1e0007, + 0x490009, + 0x130009, + 0x3d0009, + 0x330009, + 0x2f0009, + 0x230009, + 0x210009, + 0x370009, + 0x410009, + 0x2d0009, + 0x190009, + 0xf0009, + 0x70009, + 0x1d0009, + 0x3b0009, + 0x390009, + 0x150009, + 0x10009, + 0x1b0009, + 0x350009, + 0x450009, + 0x4d0009, + 0x170009, + 0x4f0009, + 0x5000a, + 0x5000a, + 0x9000a, + 0x9000a, + 0x4b000a, + 0x4b000a, + 0x3f000a, + 0x3f000a, + 0xb000a, + 0xb000a, + 0x3000a, + 0x3000a, + 0x11000a, + 0x11000a, + 0x47000a, + 0x47000a, + 0x3c000b, + 0x14000b, + 0x18000b, + 0x38000b, + 0x50000b, + 0x8000b, + 0x48000b, + 0x6000b, + 0xb, + 0x4a000b, + 0x3e000b, + 0x1a000b, + 0x12000b, + 0x2000b, + 0x36000b, + 0x4e000b +}; + +const Int32 huff_tab2[90] = +{ + 0x430004, + 0x430004, + 0x430004, + 0x430004, + 0xd0005, + 0xd0005, + 0x290005, + 0x290005, + 0x250005, + 0x250005, + 0x270005, + 0x270005, + 0x1f0005, + 0x1f0005, + 0x2b0005, + 0x2b0005, + 0x310005, + 0x310005, + 0x220006, + 0x160006, + 0x2e0006, + 0x2a0006, + 0x300006, + 0x260006, + 0xc0006, + 0x3a0006, + 0x400006, + 0x40006, + 0x240006, + 0x460006, + 0x440006, + 0x200006, + 0x100006, + 0x320006, + 0x1c0006, + 0xe0006, + 0x1e0006, + 0xa0006, + 0x4c0006, + 0x340006, + 0x2c0006, + 0x420006, + 0x2f0007, + 0x410007, + 0x130007, + 0x210007, + 0x3d0007, + 0x4b0007, + 0x470007, + 0x190007, + 0x1d0007, + 0x4f0007, + 0xf0007, + 0x10007, + 0xb0007, + 0x370007, + 0x490007, + 0x3b0008, + 0x150008, + 0x70008, + 0x110008, + 0x50008, + 0x30008, + 0x1b0008, + 0x450008, + 0x3f0008, + 0x2d0008, + 0x350008, + 0x170008, + 0x90008, + 0x330008, + 0x390008, + 0x230008, + 0x4d0008, + 0x3c0008, + 0x140008, + 0x380009, + 0x9, + 0x180009, + 0x1a0009, + 0x500009, + 0x60009, + 0x3e0009, + 0x120009, + 0x80009, + 0x480009, + 0x360009, + 0x20009, + 0x4a0009, + 0x4e0009 +}; + +const Int32 huff_tab3[151] = +{ + 0x1b0004, + 0x1b0004, + 0x1b0004, + 0x1b0004, + 0x10004, + 0x10004, + 0x10004, + 0x10004, + 0x90004, + 0x90004, + 0x90004, + 0x90004, + 0x30004, + 0x30004, + 0x30004, + 0x30004, + 0x240005, + 0x240005, + 0x40005, + 0x40005, + 0xc0006, + 0xa0006, + 0x1e0006, + 0xd0006, + 0x1c0006, + 0x270006, + 0x280007, + 0x280007, + 0x280007, + 0x280007, + 0x1f0007, + 0x1f0007, + 0x1f0007, + 0x1f0007, + 0x250007, + 0x250007, + 0x250007, + 0x250007, + 0x360008, + 0x360008, + 0x20008, + 0x20008, + 0x50008, + 0x50008, + 0x3f0008, + 0x3f0008, + 0x300008, + 0x300008, + 0x70009, + 0x100009, + 0x2d0009, + 0xe0009, + 0x420009, + 0x60009, + 0x150009, + 0xf0009, + 0x120009, + 0xb0009, + 0x390009, + 0x310009, + 0x160009, + 0x2a0009, + 0x2b0009, + 0x2e000a, + 0x21000a, + 0x22000a, + 0x13000a, + 0x43000a, + 0x29000a, + 0x40000a, + 0x20000a, + 0x8000a, + 0x11000a, + 0x4b000a, + 0x33000a, + 0x1d000a, + 0x37000a, + 0x19000a, + 0x48000b, + 0x48000b, + 0x34000b, + 0x34000b, + 0x26000b, + 0x26000b, + 0x3a000b, + 0x3a000b, + 0x2c000b, + 0x2c000b, + 0x4c000b, + 0x4c000b, + 0x18000b, + 0x18000b, + 0x17000b, + 0x17000b, + 0x23000c, + 0x49000c, + 0x45000c, + 0x4e000c, + 0x1a000c, + 0x4f000c, + 0x46000c, + 0x32000c, + 0x35000c, + 0x14000d, + 0x14000d, + 0x14000d, + 0x14000d, + 0x14000d, + 0x14000d, + 0x14000d, + 0x14000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x3d000e, + 0x3d000e, + 0x3d000e, + 0x3d000e, + 0x44000e, + 0x44000e, + 0x44000e, + 0x44000e, + 0x41000e, + 0x41000e, + 0x41000e, + 0x41000e, + 0x50000f, + 0x50000f, + 0x4d000f, + 0x4d000f, + 0x47000f, + 0x47000f, + 0x3b000f, + 0x3b000f, + 0x38000f, + 0x38000f, + 0x4a0010, + 0x3e0010 +}; + +const Int32 huff_tab4[119] = +{ + 0x280004, + 0x280004, + 0xd0004, + 0xd0004, + 0x250004, + 0x250004, + 0x270004, + 0x270004, + 0x1f0004, + 0x1f0004, + 0x1b0004, + 0x1b0004, + 0x240004, + 0x240004, + 0x4, + 0x4, + 0x40004, + 0x40004, + 0x1e0004, + 0x1e0004, + 0x1c0005, + 0xc0005, + 0x10005, + 0xa0005, + 0x30005, + 0x90005, + 0x430007, + 0x430007, + 0x2b0007, + 0x2b0007, + 0x310007, + 0x310007, + 0x290007, + 0x290007, + 0x420007, + 0x420007, + 0x400007, + 0x400007, + 0x300007, + 0x300007, + 0x3a0007, + 0x3a0007, + 0x100007, + 0x100007, + 0xe0008, + 0x2a0008, + 0x160008, + 0x200008, + 0x2e0008, + 0x260008, + 0x220008, + 0x3f0008, + 0x390008, + 0x2d0008, + 0x370008, + 0xb0008, + 0x150008, + 0x50008, + 0xf0008, + 0x130008, + 0x1d0008, + 0x70008, + 0x210008, + 0x360008, + 0x20008, + 0x120009, + 0x120009, + 0x60009, + 0x60009, + 0x340009, + 0x340009, + 0x4c0009, + 0x4c0009, + 0x460009, + 0x460009, + 0x2c0009, + 0x2c0009, + 0x320009, + 0x320009, + 0x440009, + 0x440009, + 0x33000a, + 0x4b000a, + 0x45000a, + 0x19000a, + 0x11000a, + 0x49000a, + 0x17000a, + 0x3d000a, + 0x23000a, + 0x4f000a, + 0x2f000a, + 0x3b000a, + 0x41000a, + 0x35000a, + 0x47000b, + 0x47000b, + 0x4d000b, + 0x4d000b, + 0x18000b, + 0x18000b, + 0x48000b, + 0x48000b, + 0x8000b, + 0x8000b, + 0x3c000b, + 0x3c000b, + 0x14000b, + 0x14000b, + 0x38000b, + 0x38000b, + 0x50000b, + 0x50000b, + 0x1a000b, + 0x1a000b, + 0x4e000b, + 0x4e000b, + 0x4a000c, + 0x3e000c +}; + +const Int32 huff_tab5[110] = +{ + 0x1f0004, + 0x1f0004, + 0x310004, + 0x310004, + 0x290004, + 0x290004, + 0x270004, + 0x270004, + 0x300005, + 0x200005, + 0x1e0005, + 0x320005, + 0x160007, + 0x160007, + 0x2a0007, + 0x2a0007, + 0x3a0007, + 0x3a0007, + 0x260007, + 0x260007, + 0x150008, + 0x3b0008, + 0x1d0008, + 0x330008, + 0x170008, + 0x390008, + 0x210008, + 0x2f0008, + 0xd0008, + 0x430008, + 0x250008, + 0x2b0008, + 0xc0009, + 0xc0009, + 0x340009, + 0x340009, + 0x440009, + 0x440009, + 0x1c0009, + 0x1c0009, + 0xe0009, + 0xe0009, + 0x420009, + 0x420009, + 0x2e0009, + 0x2e0009, + 0x220009, + 0x220009, + 0x180009, + 0x180009, + 0x3c0009, + 0x3c0009, + 0x140009, + 0x140009, + 0x380009, + 0x380009, + 0xb000a, + 0x41000a, + 0x19000a, + 0x37000a, + 0x45000a, + 0x3d000a, + 0xf000a, + 0x13000a, + 0x24000a, + 0x4000a, + 0x4d000a, + 0x4c000a, + 0x3000b, + 0x2c000b, + 0x4b000b, + 0x1b000b, + 0x35000b, + 0x23000b, + 0x5000b, + 0x2d000b, + 0x40000b, + 0xa000b, + 0x10000b, + 0x1a000b, + 0x2000b, + 0x4e000b, + 0x36000b, + 0x3e000b, + 0x46000b, + 0x6000b, + 0x12000c, + 0x12000c, + 0x4a000c, + 0x4a000c, + 0x3f000c, + 0x3f000c, + 0x1000c, + 0x1000c, + 0x7000c, + 0x7000c, + 0x47000c, + 0x47000c, + 0x11000c, + 0x11000c, + 0x4f000c, + 0x4f000c, + 0x49000c, + 0x49000c, + 0x9000c, + 0x9000c, + 0x48000d, + 0x8000d, + 0x50000d, + 0xd +}; +const Int32 huff_tab6[113] = +{ + 0x280004, + 0x310004, + 0x270004, + 0x290004, + 0x1f0004, + 0x320004, + 0x200004, + 0x300004, + 0x1e0004, + 0x390006, + 0x390006, + 0x3b0006, + 0x3b0006, + 0x170006, + 0x170006, + 0x150006, + 0x150006, + 0x160006, + 0x160006, + 0x210006, + 0x210006, + 0x3a0006, + 0x3a0006, + 0x2f0006, + 0x2f0006, + 0x330006, + 0x330006, + 0x260006, + 0x260006, + 0x1d0006, + 0x1d0006, + 0x2a0006, + 0x2a0006, + 0x380006, + 0x380006, + 0x180006, + 0x180006, + 0x140006, + 0x140006, + 0x3c0006, + 0x3c0006, + 0xe0007, + 0x440007, + 0x420007, + 0x220007, + 0xc0007, + 0x340007, + 0x2e0007, + 0x1c0007, + 0x430007, + 0xd0007, + 0x250007, + 0x2b0007, + 0x450007, + 0xb0008, + 0xb0008, + 0x190008, + 0x190008, + 0x3d0008, + 0x3d0008, + 0x410008, + 0x410008, + 0x370008, + 0x370008, + 0x130008, + 0x130008, + 0xf0008, + 0xf0008, + 0x460008, + 0x460008, + 0x400009, + 0xa0009, + 0x100009, + 0x2d0009, + 0x1b0009, + 0x4d0009, + 0x50009, + 0x30009, + 0x350009, + 0x4b0009, + 0x230009, + 0x240009, + 0x60009, + 0x20009, + 0x3e0009, + 0x120009, + 0x40009, + 0x4e0009, + 0x4a0009, + 0x1a0009, + 0x4c0009, + 0x360009, + 0x2c0009, + 0x9000a, + 0x9000a, + 0x11000a, + 0x11000a, + 0x3f000a, + 0x3f000a, + 0x49000a, + 0x49000a, + 0x47000a, + 0x47000a, + 0x4f000a, + 0x4f000a, + 0x7000a, + 0x7000a, + 0x1000a, + 0x1000a, + 0x50000b, + 0x8000b, + 0xb, + 0x48000b +}; + +const Int32 huff_tab7[107] = +{ + 0x80003, + 0x80003, + 0x80003, + 0x80003, + 0x80003, + 0x80003, + 0x80003, + 0x80003, + 0x10003, + 0x10003, + 0x10003, + 0x10003, + 0x10003, + 0x10003, + 0x10003, + 0x10003, + 0x90004, + 0x90004, + 0x90004, + 0x90004, + 0x110006, + 0xa0006, + 0x100006, + 0x20006, + 0x190007, + 0x190007, + 0xb0007, + 0xb0007, + 0x120007, + 0x120007, + 0x180007, + 0x180007, + 0x30007, + 0x30007, + 0x130008, + 0x1a0008, + 0xc0008, + 0x210008, + 0xd0008, + 0x290008, + 0x1b0008, + 0x140008, + 0x40008, + 0x200008, + 0x220009, + 0x220009, + 0x150009, + 0x150009, + 0x2a0009, + 0x2a0009, + 0x50009, + 0x50009, + 0x310009, + 0x310009, + 0x280009, + 0x280009, + 0xe0009, + 0xe0009, + 0x230009, + 0x230009, + 0x1d0009, + 0x1d0009, + 0x1c0009, + 0x1c0009, + 0x2b0009, + 0x2b0009, + 0x160009, + 0x160009, + 0x320009, + 0x320009, + 0xf0009, + 0xf0009, + 0x1e000a, + 0x6000a, + 0x30000a, + 0x24000a, + 0x39000a, + 0x25000a, + 0x3a000a, + 0x2c000a, + 0x33000a, + 0x17000a, + 0x3b000a, + 0x34000a, + 0x2d000a, + 0x26000a, + 0x1f000a, + 0x38000b, + 0x38000b, + 0x7000b, + 0x7000b, + 0x35000b, + 0x35000b, + 0x2e000b, + 0x2e000b, + 0x3c000b, + 0x3c000b, + 0x27000b, + 0x27000b, + 0x2f000b, + 0x2f000b, + 0x3d000b, + 0x3d000b, + 0x3e000c, + 0x36000c, + 0x37000c, + 0x3f000c +}; +const Int32 huff_tab8[90] = +{ + 0x90003, + 0x90003, + 0x90003, + 0x90003, + 0x110004, + 0x110004, + 0x80004, + 0x80004, + 0xa0004, + 0xa0004, + 0x10004, + 0x10004, + 0x120004, + 0x120004, + 0x5, + 0x100005, + 0x20005, + 0x190005, + 0xb0005, + 0x1a0005, + 0x130005, + 0x1b0006, + 0x1b0006, + 0x210006, + 0x210006, + 0xc0006, + 0xc0006, + 0x220006, + 0x220006, + 0x140006, + 0x140006, + 0x180006, + 0x180006, + 0x30006, + 0x30006, + 0x230006, + 0x230006, + 0x1c0006, + 0x1c0006, + 0x2a0006, + 0x2a0006, + 0x290007, + 0x150007, + 0xd0007, + 0x2b0007, + 0x1d0007, + 0x240007, + 0x2c0007, + 0x40007, + 0x250007, + 0x200007, + 0x160007, + 0x320007, + 0x310007, + 0xe0007, + 0x1e0008, + 0x330008, + 0x2d0008, + 0x280008, + 0x340008, + 0x50008, + 0x260008, + 0x390008, + 0x3a0008, + 0x170008, + 0x350008, + 0x3b0008, + 0xf0008, + 0x2e0008, + 0x1f0008, + 0x360009, + 0x360009, + 0x3c0009, + 0x3c0009, + 0x300009, + 0x300009, + 0x270009, + 0x270009, + 0x60009, + 0x60009, + 0x3d0009, + 0x3d0009, + 0x3e0009, + 0x3e0009, + 0x370009, + 0x370009, + 0x2f000a, + 0x38000a, + 0x7000a, + 0x3f000a +}; +const Int32 huff_tab9[204] = +{ + 0x1, + 0x1, + 0x1, + 0x1, + 0x1, + 0x1, + 0x1, + 0x1, + 0xd0003, + 0xd0003, + 0x10003, + 0x10003, + 0xe0004, + 0x1b0006, + 0x1b0006, + 0xf0006, + 0xf0006, + 0x1a0006, + 0x1a0006, + 0x20006, + 0x20006, + 0x280007, + 0x1c0007, + 0x100007, + 0x270008, + 0x270008, + 0x30008, + 0x30008, + 0x1d0008, + 0x1d0008, + 0x290008, + 0x290008, + 0x110008, + 0x110008, + 0x350008, + 0x350008, + 0x1e0008, + 0x1e0008, + 0x120008, + 0x120008, + 0x360009, + 0x2a0009, + 0x40009, + 0x340009, + 0x420009, + 0x1f0009, + 0x130009, + 0x2b0009, + 0x430009, + 0x4f0009, + 0x370009, + 0x5000a, + 0x20000a, + 0x41000a, + 0x14000a, + 0x2c000a, + 0x15000a, + 0x69000a, + 0x38000a, + 0x44000a, + 0x50000a, + 0x5c000a, + 0x6000a, + 0x6a000a, + 0x22000a, + 0x2d000a, + 0x21000a, + 0x39000a, + 0x76000a, + 0x16000a, + 0x5d000a, + 0x4e000b, + 0x45000b, + 0x51000b, + 0x6b000b, + 0x7000b, + 0x77000b, + 0x2f000b, + 0x3a000b, + 0x2e000b, + 0x8000b, + 0x83000b, + 0x52000b, + 0x23000b, + 0x46000b, + 0x68000b, + 0x5b000b, + 0x5e000b, + 0x84000b, + 0x78000b, + 0x6c000b, + 0x17000b, + 0x5f000b, + 0x53000b, + 0x47000b, + 0x3c000b, + 0x3b000b, + 0x30000b, + 0x90000b, + 0x49000b, + 0x75000b, + 0x6d000b, + 0x85000c, + 0x24000c, + 0x9000c, + 0x91000c, + 0x79000c, + 0x54000c, + 0x9d000c, + 0x3d000c, + 0x6e000c, + 0x18000c, + 0x7a000c, + 0x86000c, + 0x48000c, + 0x60000c, + 0x25000c, + 0x19000c, + 0x9e000c, + 0x92000c, + 0x31000c, + 0x4a000c, + 0x55000c, + 0x6f000c, + 0x93000c, + 0xa000c, + 0x61000c, + 0x9f000c, + 0x82000c, + 0x87000c, + 0x3e000c, + 0x56000c, + 0x26000c, + 0x7b000c, + 0x7c000c, + 0x3f000c, + 0x8f000c, + 0x57000c, + 0x32000c, + 0x4b000c, + 0x70000d, + 0x63000d, + 0xa1000d, + 0x33000d, + 0x94000d, + 0x62000d, + 0xa0000d, + 0x95000d, + 0x88000d, + 0x40000d, + 0x64000d, + 0x4c000d, + 0xb000d, + 0xa2000d, + 0x58000d, + 0x9c000d, + 0x89000d, + 0x4d000d, + 0x65000d, + 0x7d000d, + 0xc000d, + 0x96000d, + 0x71000d, + 0x7e000d, + 0x8a000d, + 0x66000d, + 0xa3000d, + 0x59000d, + 0x73000d, + 0x97000d, + 0x67000d, + 0x5a000d, + 0x72000e, + 0x72000e, + 0x8b000e, + 0x8b000e, + 0x74000e, + 0x74000e, + 0x7f000e, + 0x7f000e, + 0x80000e, + 0x80000e, + 0x81000e, + 0x81000e, + 0x8d000e, + 0x8d000e, + 0xa5000e, + 0xa5000e, + 0x8c000e, + 0x8c000e, + 0x98000e, + 0x98000e, + 0xa4000e, + 0xa4000e, + 0x99000e, + 0x99000e, + 0xa6000e, + 0xa6000e, + 0xa7000e, + 0xa7000e, + 0x8e000f, + 0x9a000f, + 0x9b000f, + 0xa8000f +}; +const Int32 huff_tab10[186] = +{ + 0xe0004, + 0xe0004, + 0xe0004, + 0xe0004, + 0xf0004, + 0xf0004, + 0xf0004, + 0xf0004, + 0x1b0004, + 0x1b0004, + 0x1b0004, + 0x1b0004, + 0x1c0005, + 0x1c0005, + 0xd0005, + 0xd0005, + 0x10005, + 0x10005, + 0x100005, + 0x100005, + 0x290005, + 0x290005, + 0x280005, + 0x280005, + 0x1d0005, + 0x1d0005, + 0x2a0005, + 0x2a0005, + 0x1a0006, + 0x20006, + 0x1e0006, + 0x360006, + 0x110006, + 0x350006, + 0x6, + 0x370006, + 0x2b0006, + 0x270006, + 0x30006, + 0x380006, + 0x1f0006, + 0x430006, + 0x120007, + 0x420007, + 0x440007, + 0x2c0007, + 0x450007, + 0x390007, + 0x500007, + 0x200007, + 0x510007, + 0x340007, + 0x4f0007, + 0x40007, + 0x130007, + 0x2d0007, + 0x460007, + 0x520007, + 0x3a0007, + 0x530008, + 0x5d0008, + 0x2e0008, + 0x210008, + 0x470008, + 0x6a0008, + 0x5e0008, + 0x410008, + 0x5c0008, + 0x50008, + 0x690008, + 0x140008, + 0x6b0008, + 0x5f0008, + 0x3b0008, + 0x220008, + 0x540008, + 0x600008, + 0x150008, + 0x2f0008, + 0x6c0008, + 0x3c0008, + 0x480008, + 0x6d0008, + 0x490008, + 0x610009, + 0x550009, + 0x770009, + 0x4e0009, + 0x560009, + 0x780009, + 0x300009, + 0x760009, + 0x230009, + 0x60009, + 0x6e0009, + 0x790009, + 0x3d0009, + 0x840009, + 0x160009, + 0x620009, + 0x6f0009, + 0x7a0009, + 0x630009, + 0x850009, + 0x4a0009, + 0x860009, + 0x240009, + 0x830009, + 0x310009, + 0x7b0009, + 0x570009, + 0x680009, + 0x3e0009, + 0x5b0009, + 0x910009, + 0x64000a, + 0x92000a, + 0x88000a, + 0x17000a, + 0x90000a, + 0x7c000a, + 0x7000a, + 0x70000a, + 0x87000a, + 0x32000a, + 0x4b000a, + 0x71000a, + 0x94000a, + 0x8000a, + 0x93000a, + 0x25000a, + 0x65000a, + 0x58000a, + 0x89000a, + 0x3f000a, + 0x18000a, + 0x9e000a, + 0x7d000a, + 0x9f000a, + 0x95000a, + 0x4c000a, + 0xa0000a, + 0x96000a, + 0xa1000a, + 0x33000a, + 0x59000a, + 0x75000a, + 0x8a000a, + 0x82000a, + 0x9d000a, + 0x9000a, + 0x40000a, + 0x7e000a, + 0xa2000a, + 0x26000a, + 0x72000a, + 0x7f000b, + 0x19000b, + 0x97000b, + 0xa3000b, + 0x66000b, + 0x4d000b, + 0x5a000b, + 0x8b000b, + 0x73000b, + 0xa4000b, + 0xa000b, + 0x67000b, + 0x8f000b, + 0x8c000b, + 0x98000b, + 0x99000b, + 0xb000b, + 0x9a000b, + 0x80000b, + 0x8d000b, + 0x9c000b, + 0x74000b, + 0xa5000c, + 0x8e000c, + 0x81000c, + 0x9b000c, + 0xa7000c, + 0xc000c, + 0xa6000c, + 0xa8000c +}; +const Int32 huff_tab11[301] = +{ + 0x4, + 0x4, + 0x4, + 0x4, + 0x120004, + 0x120004, + 0x120004, + 0x120004, + 0x1200005, + 0x1200005, + 0x110005, + 0x110005, + 0x10005, + 0x10005, + 0x230005, + 0x230005, + 0x130005, + 0x130005, + 0x240005, + 0x240005, + 0x140006, + 0x340006, + 0x350006, + 0x220006, + 0x250006, + 0x20006, + 0x360006, + 0x450007, + 0x150007, + 0x460007, + 0x260007, + 0x470007, + 0x370007, + 0x330007, + 0x30007, + 0x560007, + 0x570007, + 0x270007, + 0x480007, + 0x160007, + 0x580007, + 0x380007, + 0x590007, + 0x490008, + 0x680008, + 0x280008, + 0x670008, + 0x690008, + 0x390008, + 0x170008, + 0x540008, + 0x430008, + 0x1150008, + 0x1130008, + 0x1140008, + 0x6a0008, + 0x1160008, + 0x440008, + 0x4a0008, + 0x40008, + 0x320008, + 0x5a0008, + 0x650008, + 0x1170008, + 0x1120008, + 0x1180008, + 0x290008, + 0x790008, + 0x3a0008, + 0x6b0008, + 0x5b0008, + 0x760008, + 0x11a0008, + 0x7a0008, + 0x780008, + 0x1190008, + 0x870008, + 0x210008, + 0x180008, + 0x4b0008, + 0x11b0008, + 0x7b0008, + 0x11c0008, + 0x980008, + 0x1110008, + 0x6c0008, + 0xa90008, + 0x2a0008, + 0x5c0008, + 0xba0008, + 0x11d0008, + 0x8b0008, + 0x8a0008, + 0x3b0008, + 0x550008, + 0x11e0008, + 0xcb0008, + 0x7c0008, + 0x4c0008, + 0x6d0008, + 0x7d0008, + 0x50008, + 0x8c0009, + 0x11f0009, + 0xdc0009, + 0x190009, + 0x890009, + 0xfe0009, + 0x5d0009, + 0xed0009, + 0x3c0009, + 0x8d0009, + 0x7e0009, + 0x2b0009, + 0x8e0009, + 0x9b0009, + 0x9c0009, + 0x10f0009, + 0x4d0009, + 0x6e0009, + 0x660009, + 0x9d0009, + 0x5e0009, + 0x8f0009, + 0x7f0009, + 0x1a0009, + 0xad0009, + 0x60009, + 0xac0009, + 0x9a0009, + 0x9e0009, + 0x4e0009, + 0x2c0009, + 0x9f0009, + 0x3d0009, + 0x6f0009, + 0xae0009, + 0x900009, + 0xaf0009, + 0xa00009, + 0xbe0009, + 0x1b0009, + 0x770009, + 0xb00009, + 0x800009, + 0x3e0009, + 0x5f0009, + 0xab0009, + 0x4f0009, + 0xbd0009, + 0xdf0009, + 0x700009, + 0xe00009, + 0x2d0009, + 0x1100009, + 0x600009, + 0xc00009, + 0xbf000a, + 0xa1000a, + 0x81000a, + 0x91000a, + 0x10000a, + 0x51000a, + 0x7000a, + 0x40000a, + 0xc1000a, + 0xde000a, + 0xe1000a, + 0xcf000a, + 0x2f000a, + 0xe2000a, + 0x92000a, + 0x71000a, + 0xb2000a, + 0xb1000a, + 0xf0000a, + 0xd0000a, + 0x1c000a, + 0x50000a, + 0xbc000a, + 0x3f000a, + 0x1e000a, + 0xce000a, + 0x82000a, + 0x41000a, + 0x61000a, + 0x62000a, + 0xf2000a, + 0x52000a, + 0xc2000a, + 0xf1000a, + 0xd1000a, + 0xe3000a, + 0xd2000a, + 0x88000a, + 0xc3000a, + 0x2e000a, + 0xa2000a, + 0xf3000a, + 0x73000a, + 0xb4000a, + 0x101000a, + 0x93000a, + 0xa3000a, + 0xf4000a, + 0xb3000a, + 0x63000a, + 0xc4000a, + 0xef000a, + 0x30000a, + 0x72000a, + 0x1d000a, + 0xe5000a, + 0x8000a, + 0xe4000a, + 0x83000a, + 0xd3000a, + 0x84000a, + 0x102000a, + 0xcd000a, + 0x74000a, + 0x31000a, + 0x104000a, + 0x103000a, + 0x1f000a, + 0xa4000a, + 0x53000a, + 0xf5000a, + 0x95000a, + 0xe6000a, + 0x94000a, + 0x64000a, + 0x42000a, + 0xb5000a, + 0xc5000a, + 0xd4000a, + 0x105000a, + 0x106000a, + 0x96000a, + 0x100000a, + 0x85000a, + 0x99000a, + 0x9000a, + 0xa6000a, + 0xa5000a, + 0xd5000a, + 0xf6000a, + 0xb7000a, + 0xf7000a, + 0xd6000a, + 0x75000a, + 0x86000a, + 0xa7000b, + 0x107000b, + 0xc6000b, + 0xc9000b, + 0x20000b, + 0xb6000b, + 0xb8000b, + 0xe8000b, + 0xe7000b, + 0xc8000b, + 0xc7000b, + 0x97000b, + 0xf9000b, + 0xe9000b, + 0xd9000b, + 0x108000b, + 0xf8000b, + 0xaa000b, + 0xd7000b, + 0xa8000b, + 0xa000b, + 0xd8000b, + 0xbb000b, + 0xda000b, + 0xb9000b, + 0xea000b, + 0xd000b, + 0xfa000b, + 0x109000b, + 0x10a000b, + 0xca000b, + 0xfb000b, + 0xdd000b, + 0xb000b, + 0xeb000b, + 0x10b000b, + 0x10c000b, + 0xdb000b, + 0xee000b, + 0xfc000b, + 0xec000b, + 0xcc000b, + 0xfd000b, + 0xe000c, + 0xc000c, + 0x10d000c, + 0xff000c, + 0xf000c, + 0x10e000c +}; + +const UInt32 huff_tab_scl[188] = +{ + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3d0004, + 0x3d0004, + 0x3d0004, + 0x3d0004, + 0x3a0004, + 0x3a0004, + 0x3a0004, + 0x3a0004, + 0x3e0004, + 0x3e0004, + 0x3e0004, + 0x3e0004, + 0x390005, + 0x390005, + 0x3f0005, + 0x3f0005, + 0x380006, + 0x400006, + 0x370006, + 0x410006, + 0x420007, + 0x420007, + 0x420007, + 0x420007, + 0x360007, + 0x360007, + 0x360007, + 0x360007, + 0x430007, + 0x430007, + 0x430007, + 0x430007, + 0x350008, + 0x350008, + 0x440008, + 0x440008, + 0x340008, + 0x340008, + 0x450008, + 0x450008, + 0x330008, + 0x330008, + 0x460009, + 0x320009, + 0x310009, + 0x470009, + 0x48000a, + 0x48000a, + 0x48000a, + 0x48000a, + 0x30000a, + 0x30000a, + 0x30000a, + 0x30000a, + 0x49000a, + 0x49000a, + 0x49000a, + 0x49000a, + 0x2f000a, + 0x2f000a, + 0x2f000a, + 0x2f000a, + 0x4a000a, + 0x4a000a, + 0x4a000a, + 0x4a000a, + 0x2e000a, + 0x2e000a, + 0x2e000a, + 0x2e000a, + 0x4c000b, + 0x4c000b, + 0x4b000b, + 0x4b000b, + 0x4d000b, + 0x4d000b, + 0x4e000b, + 0x4e000b, + 0x2d000b, + 0x2d000b, + 0x2b000b, + 0x2b000b, + 0x2c000c, + 0x4f000c, + 0x2a000c, + 0x29000c, + 0x50000c, + 0x28000c, + 0x51000d, + 0x51000d, + 0x27000d, + 0x27000d, + 0x52000d, + 0x52000d, + 0x26000d, + 0x26000d, + 0x53000d, + 0x53000d, + 0x25000e, + 0x23000e, + 0x55000e, + 0x21000e, + 0x24000e, + 0x22000e, + 0x54000e, + 0x20000e, + 0x57000f, + 0x57000f, + 0x59000f, + 0x59000f, + 0x1e000f, + 0x1e000f, + 0x1f000f, + 0x1f000f, + 0x560010, + 0x1d0010, + 0x1a0010, + 0x1b0010, + 0x1c0010, + 0x180010, + 0x580010, + 0x190011, + 0x190011, + 0x160011, + 0x160011, + 0x170011, + 0x170011, + 0x5a0012, + 0x150012, + 0x130012, + 0x30012, + 0x10012, + 0x20012, + 0x12, + 0x620013, + 0x630013, + 0x640013, + 0x650013, + 0x660013, + 0x750013, + 0x610013, + 0x5b0013, + 0x5c0013, + 0x5d0013, + 0x5e0013, + 0x5f0013, + 0x600013, + 0x680013, + 0x6f0013, + 0x700013, + 0x710013, + 0x720013, + 0x730013, + 0x740013, + 0x6e0013, + 0x690013, + 0x6a0013, + 0x6b0013, + 0x6c0013, + 0x6d0013, + 0x760013, + 0x60013, + 0x80013, + 0x90013, + 0xa0013, + 0x50013, + 0x670013, + 0x780013, + 0x770013, + 0x40013, + 0x70013, + 0xf0013, + 0x100013, + 0x120013, + 0x140013, + 0x110013, + 0xb0013, + 0xc0013, + 0xe0013, + 0xd0013 +}; diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffcb.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffcb.cpp new file mode 100644 index 0000000..0c04089 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffcb.cpp @@ -0,0 +1,324 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: huffcb.cpp + Funtions: + huffcb + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + UChar *pSect = pointer to array that contains the interleaved + information of huffman codebook index and section + length. Array contains: + [codebook index] + [section boundary] + [codebook index] + [section boundary] + ... + + Int sectbits = array that defines the number of bits + used for expressing the escape value of + section length + + Int tot_sfb = total number of sfb in one Frame + + Int sfb_per_win = number of sfb in each sub-block (window) + + UChar max_sfb = 1 + number of active sfbs - see reference (2) p56 + + BITS *pInputStream = pointer to input stream + + + Local Stores/Buffers/Pointers Needed: + + UChar base = number of sfb in already detected sections + + UChar sect_len_inc = section length increment in number of sfbs' + + UChar esc_val = escape value for section length + + Int bits = number of bits needed for expressing section length + + + Global Stores/Buffers/Pointers Needed: + + + Outputs: + + num_sect = total number of sections in one frame + + + Pointers and Buffers Modified: + + UChar *pSect = pointer to array where huffman codebook index and + section length are stored + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Background knowledge: 1024(960) coef's are separated into several sections, + each section is encoded with one single Huffman codebook, and each section + has a length of multiples of sfb. + + max_sfb <= sfb_per_win <= tot_sfb + tot_sfb = total number of scalefactor bands in one frame (1024 coefs) + + This function reads the codebook index and section boundaries (expressed + in number of sfb) from the input bitstream, store these information in + *pSect, and return the number of sections been detected. Returns 0 if there + is an error. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should fill the array *pSect with section Huffman codebook + indexes and section boundaries + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3 1999(E) + Subpart 4 p55 (Recovering section_data()) + p24-25 (Syntax of section_data()) + + (3) M. Bosi, K. Brandenburg, etc., "ISO/IEC MPEG-2 Advanced Audio Coding," + J. Audio Eng. Soc., Vol.45, No.10, 1997 October + +------------------------------------------------------------------------------ + PSEUDO-CODE + + bits_needed_for_ESC = sectbits[0]; + ESC_value = (1< max_sfb) + break; + ENDIF + + } + ENDFOR + + IF (base != total_sfb OR num_of_section>total_sfb) + return 0; + ENDIF + + return num_sect; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int huffcb( + SectInfo *pSect, + BITS *pInputStream, + Int sectbits[], + Int tot_sfb, + Int sfb_per_win, + Int max_sfb) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + + Int base; /* section boundary */ + Int sect_len_incr; + Int esc_val; /* ESC of section length = 31(long), =7 (short) */ + Int bits; /* # of bits used to express esc_val */ + Int num_sect; + Int active_sfb; + Int group_base; + + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + bits = sectbits[0]; /* 3 for SHORT_WIN, 5 for LONG_WIN */ + esc_val = (1 << bits) - 1; /* ESC_value for section length */ + num_sect = 0; + base = 0; + group_base = 0; + + /* read until the end of one frame */ + while ((base < tot_sfb) && (num_sect < tot_sfb)) + { + + pSect->sect_cb = get9_n_lessbits( + LEN_CB, + pInputStream); /* section codebook */ + + sect_len_incr = get9_n_lessbits( + bits, + pInputStream); /* length_incr */ + + + /* read until non-ESC value, see p55 reference 2 */ + while ((sect_len_incr == esc_val) && (base < tot_sfb)) + { + base += esc_val; + + sect_len_incr = get9_n_lessbits( + bits, + pInputStream); + } + + base += sect_len_incr; + pSect->sect_end = base; /* total # of sfb until current section */ + pSect++; + num_sect++; + + /* active_sfb = base % sfb_per_win; */ + active_sfb = base - group_base; + + /* + * insert a zero section for regions above max_sfb for each group + * Make sure that active_sfb is also lesser than tot_sfb + */ + + if ((active_sfb == max_sfb) && (active_sfb < tot_sfb)) + { + base += (sfb_per_win - max_sfb); + pSect->sect_cb = 0; /* huffman codebook 0 */ + pSect->sect_end = base; + num_sect++; + pSect++; + group_base = base; + } + else if (active_sfb > max_sfb) + { + /* within each group, the sections must delineate the sfb + * from zero to max_sfb so that the 1st section within each + * group starts at sfb0 and the last section ends at max_sfb + * see p55 reference 2 + */ + break; + } + + } /* while (base=0) */ + + + if (base != tot_sfb || num_sect > tot_sfb) + { + num_sect = 0; /* error */ + } + + return num_sect; + +} /* huffcb */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffdecode.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffdecode.cpp new file mode 100644 index 0000000..479e5d7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffdecode.cpp @@ -0,0 +1,501 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: huffdecode.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + id_syn_ele = identification flag for channel syntactic element, Int + + pInputStream= pointer to input bitstream, BITS. + + pVars = pointer to structure that holds information for decoding, + tDec_Int_File + + pChVars[] = pointer to structure that holds channel information, + tDec_Int_Chan + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + status = 0 if success + non-zero otherwise + + Pointers and Buffers Modified: + pChVars->sect contents updated by newly decoded section information + of current frame + + pChVars->factors contents updated by newly decoded scalefactors + + pChVars->ch_coef contents updated by newly decoded spectral coefficients + + PChVars->tns contents updated by newly decoded TNS information + + pVars->hasmask contents updated by newly decoded Mid/Side mask + information + + pVars->pulseInfo contents updated by newly decoded pulse data information + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function offers a framework for decoding the data of the next 1024 + samples. It maps the channel configuration according to the id_syn_ele flag, + configures the channel information, and calls getics to do huffman decoding + The function returns 1 if there was an error + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should set up the channel configuration for huffman decoding + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p15 (single_channel_element, channel_pair_element) + p15 (Table 4.4.5 getmask) + p16 (Table 4.4.6 get_ics_info) + p24 (Table 4.4.24 getics) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + tag = CALL getbits(LEN_TAG,pInputStream) + MODIFYING(pInputStream) + RETURNING(tag) + + common_window = 0; + + IF (id_syn_ele == ID_CPE) + THEN + common_window = CALL getbits(LEN_COM_WIN,pInputStream); + MODIFYING(pInputStream) + RETURNING(common_window) + ENDIF + + pMcInfo = &pVars->mc_info; + + IF ( (pMcInfo->ch_info[0].cpe != id_syn_ele) OR + (pMcInfo->ch_info[0].tag != tag) ) + THEN + status = 1; + ENDIF + + + IF (status == SUCCESS) + THEN + IF (id_syn_ele == ID_SCE) + THEN + + leftCh = 0; + RIGHT = 0; + pChVars[leftCh]->hasmask = 0; + ELSEIF (id_syn_ele == ID_CPE) + + leftCh = 0; + rightCh = 1; + + IF (common_window != FALSE) + THEN + + CALL get_ics_info( + audioObjectType = pVars->mc_info.audioObjectType, + pInputStream = pInputStream, + common_window = common_window, + pWindowSequence = &pChVars[leftCh]->wnd, + &pChVars[leftCh]->wnd_shape_this_bk, + pChVars[leftCh]->group, + &pChVars[leftCh]->max_sfb, + pVars->winmap, + &pChVars[leftCh]->lt_status, + &pChVars[rightCh]->lt_status); + MODIFYING(pInputStream, wnd, wnd_shape_this_bk,group, + max_sfb, lt_status) + RETURNING(status) + + IF (status == SUCCESS) + THEN + + pChVars[rightCh]->wnd = pChVars[leftCh]->wnd; + pChVars[rightCh]->wnd_shape_this_bk = + pChVars[leftCh]->wnd_shape_this_bk; + pChVars[rightCh]->max_sfb = pChVars[leftCh]->max_sfb; + pv_memcpy( + pChVars[rightCh]->group, + pChVars[leftCh]->group, + NSHORT*sizeof(pChVars[leftCh]->group[0])); + + hasmask = CALL getmask( + pVars->winmap[pChVars[leftCh]->wnd], + pInputStream, + pChVars[leftCh]->group, + pChVars[leftCh]->max_sfb, + pChVars[leftCh]->mask); + MODIFYING(pInputStream, mask) + RETURNING(hasmask) + + IF (hasmask == MASK_ERROR) + THEN + status = 1; + ENDIF + pChVars[leftCh]->hasmask = hasmask; + pChVars[rightCh]->hasmask = hasmask; + + ENDIF + + ELSE + + pChVars[leftCh]->hasmask = 0; + pChVars[rightCh]->hasmask = 0; + ENDIF(common_window) + + ENDIF(id_syn_ele) + + ENDIF (status) + + ch = leftCh; + + WHILE((ch <= rightCh) AND (status == SUCCESS)) + + status = CALL getics( + pInputStream, + common_window, + pVars, + pChVars[ch], + pChVars[ch]->group, + &pChVars[ch]->max_sfb, + pChVars[ch]->cb_map, + &pChVars[ch]->tns, + pVars->winmap, + &pVars->pulseInfo, + pChVars[ch]->sect); + MODIFYING(pInputStream,pVarsp,ChVars[ch],group, + max_sfb,tns,pulseInfo,sect) + RETURNING(status) + + ch++; + + ENDWHILE + + RETURN status; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "aac_mem_funcs.h" +#include "huffman.h" +#include "e_maskstatus.h" +#include "e_elementid.h" +#include "get_ics_info.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int huffdecode( + Int id_syn_ele, + BITS *pInputStream, + tDec_Int_File *pVars_0, + tDec_Int_Chan *pChVars_0[] +) + +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + Int ch = LEFT; + Int common_window = 0; + Int hasmask; + Int status = SUCCESS; + Int num_channels = 0; + Int tag = 0; + MC_Info *pMcInfo; + + tDec_Int_File *pVars = (tDec_Int_File *)pVars_0; + tDec_Int_Chan *pChVars[2]; + + pChVars[0] = pChVars_0[0]; + pChVars[1] = pChVars_0[1]; + per_chan_share_w_fxpCoef *pChLeftShare; /* Helper pointer */ + per_chan_share_w_fxpCoef *pChRightShare; /* Helper pointer */ + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + { + tag = get9_n_lessbits(LEN_TAG, pInputStream); + } + + + if (id_syn_ele == ID_CPE) + { + common_window = + get1bits(pInputStream); + } + + pMcInfo = &pVars->mc_info; + + + /* + * check if provided info (num of channels) on audio config, + * matches read bitstream data, if not, allow update only once. + * In almost all cases it should match. + */ + + + if ((pMcInfo->ch_info[0].cpe != id_syn_ele)) + { + if (pVars->mc_info.implicit_channeling) /* check done only once */ + { + pMcInfo->ch_info[0].cpe = id_syn_ele & 1; /* collect info from bitstream + * implicit_channeling flag is locked + * after 1st frame, to avoid toggling + * parameter in the middle of the clip + */ + pMcInfo->nch = (id_syn_ele & 1) + 1; /* update number of channels */ + } + else + { + status = 1; /* ERROR break if syntax error persist */ + } + } + + + + + if (status == SUCCESS) + { + if (id_syn_ele == ID_SCE) + { + if ((pVars->current_program < 0) && (pVars->bno <= 1)) /* No program config available */ + { + /* + * Acquire tags for single or dual mono channel only during first frame + * pMcInfo->ch_info[0].tag was init to 0 and used here as index for dual-mono channels + */ + if (pMcInfo->ch_info[0].tag >> 1) + { + status = 1; /* ERROR */ + } + + pVars->prog_config.front.ele_tag[ pMcInfo->ch_info[0].tag] = tag; + pMcInfo->ch_info[0].tag ^= 1; /* set index to next dual-mono, if exist */ + + ch = (tag == pVars->prog_config.front.ele_tag[0]) ? LEFT : RIGHT; /* Assign only L and R channel */ + num_channels = ch + 1; + pVars->hasmask = 0; + + /* Set number of channels 1 mono, 2 dual-mono */ + pMcInfo->nch = (pMcInfo->nch > num_channels) ? pMcInfo->nch : num_channels; + pVars->prog_config.front.num_ele = pMcInfo->nch; + + if (pMcInfo->ch_info[0].tag == 0) /* limit to only 2 channel, tag is set to zero on 2nd pass */ + { + pVars->current_program = 0; /* lock tag acquisition */ + } + } + else + { + if ((tag == pVars->prog_config.front.ele_tag[0]) || + (tag == pVars->prog_config.front.ele_tag[1])) + { + ch = (tag == pVars->prog_config.front.ele_tag[0]) ? LEFT : RIGHT; /* Assign only L and R channel */ + num_channels = ch + 1; + pVars->hasmask = 0; + } + else + { + + status = 1; /* ERROR == incorrect tag identifying dual-mono channel */ + + + } + + { + pMcInfo->nch = pVars->prog_config.front.num_ele; // dual mono + } + } + + if ((pMcInfo->nch > 1) && (pMcInfo->psPresentFlag)) + { + status = 1; /* ERROR == No eAAC+ for dual-mono */ + } + + } + else if (id_syn_ele == ID_CPE) + { + + pChLeftShare = pChVars[LEFT]->pShareWfxpCoef; + pChRightShare = pChVars[RIGHT]->pShareWfxpCoef; + num_channels = 2; + + if (common_window != FALSE) + { + + status = get_ics_info( + (tMP4AudioObjectType) pVars->mc_info.audioObjectType, + pInputStream, + (Bool)common_window, + (WINDOW_SEQUENCE *) & pChVars[LEFT]->wnd, + (WINDOW_SHAPE *) & pChVars[LEFT]->wnd_shape_this_bk, + pChLeftShare->group, + (Int *) & pChLeftShare->max_sfb, + pVars->winmap, + (LT_PRED_STATUS *) & pChLeftShare->lt_status, + (LT_PRED_STATUS *) & pChRightShare->lt_status); + + if (status == SUCCESS) + { + /* copy left channel info to right channel */ + pChVars[RIGHT]->wnd = pChVars[LEFT]->wnd; + pChVars[RIGHT]->wnd_shape_this_bk = + pChVars[LEFT]->wnd_shape_this_bk; + pChRightShare->max_sfb = pChLeftShare->max_sfb; + + pv_memcpy(pChRightShare->group, + pChLeftShare->group, + NSHORT*sizeof(pChLeftShare->group[0])); + + hasmask = getmask(pVars->winmap[pChVars[LEFT]->wnd], + pInputStream, + pChLeftShare->group, + pChLeftShare->max_sfb, + pVars->mask); + + if (hasmask == MASK_ERROR) + { + status = 1; /* ERROR code */ + } + pVars->hasmask = hasmask; + + } /* if (status == 0) */ + } + else + { + pVars->hasmask = 0; + } /* if (common_window) */ + + } /* if (id_syn_ele) */ + + } /* if (status) */ + + + while ((ch < num_channels) && (status == SUCCESS)) + { + pChLeftShare = pChVars[ch]->pShareWfxpCoef; + + status = getics(id_syn_ele, + pInputStream, + common_window, + pVars, + pChVars[ch], + pChLeftShare->group, + &pChLeftShare->max_sfb, + pChLeftShare->cb_map, + &pChLeftShare->tns, + pVars->winmap, + &pVars->share.a.pulseInfo, + pVars->share.a.sect); + + ch++; + + } /* while (ch) */ + + /*---------------------------------------------------------------------------- + ; Return status + ----------------------------------------------------------------------------*/ + + return status; + +} /* huffdecode */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/hufffac.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/hufffac.cpp new file mode 100644 index 0000000..2230048 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/hufffac.cpp @@ -0,0 +1,505 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: hufffac.cpp + Funtions: + hufffac + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + *pFrameInfo = pointer to structure that holds information + of each Frame. type FrameInfo + + *pInputStream = pointer to input bitstream. type BITS + + *pGroup = pointer to array that contains the index of the first + window in each group, type UChar + + nsect = number of sections to be decoded. type Int + + *pSect = pointer to structure array that contains the huffman + codebook index and section boundary for each section, + type SectInfo + + global_gain = initial value for "DPCM encoded" scalefactors and noise + energy, type Int + + *pFactors = pointer to array that stores the decoded scalefactors, + intensity position or noise energy, type Int + + huffBookUsed = array that will hold the huffman codebook index for + each sfb, type Int + + *pBook = pointer to structure that contains the huffman codebook + information, such as dimension, Largest Absolute Value + (LAV) of each huffman codebook, etc. type Hcb + + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + 0 if success + 1 if error + + Pointers and Buffers Modified: + + Int *pFactors contains the newly decoded scalefactors and/or + intensity position and/or noise energy level + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function first reads the Huffman codebook index of all sections within + one Frame. Then, depending on the huffman codebook index of each section, + the function decodes the scalefactors, and/or intensity positions + (INTENSITY_HCB, INTENSITY_HCB2), and/or noise energy (NOISE_HCB) + for every scalefactor band in each section. + The function returns 0 upon successful decoding, returns 1 if error. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should replace the content of the array pFactors with the + decoded scalefactors and/or intensity positions and/or noise energy + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p72-73 (scalefactors) + p76 (decoding) + p78 (Table 4.6.1, Table 4.6.2) + p93-94 (INTENSITY_HCB) + p123 (NOISE_HCB) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = SUCCESS; + + CALL pv_memset(pHuffBookUsed, ZERO_HCB, MAXBANDS*sizeof(*pHuffBookUsed)); + + CALL pv_memset(pFactors, ZERO_HCB, MAXBANDS*sizeof(*pFactors)); + + sect_start = 0; + + FOR(sect_idx = nsect; sect_idx > 0; sect_idx--) + { + sect_cb = pSect->sect_cb; + sect_end = pSect->sect_end; + pSect++; + + CALL pv_memset( + &pHuffBookUsed[sect_start], + sect_cb, + (sect_end - sect_start)); + + } + ENDFOR + + fac = global_gain; + is_pos = 0; + noise_nrg = global_gain - NOISE_OFFSET; + + pTable = pBook[BOOKSCL].pTable; + group_win = 0; + group_end = 0; + + WHILE((group_end < pFrameInfo->num_win)&&(status == SUCCESS)) + { + nsfb_win = pFrameInfo->sfb_per_win[group_end]; + group_end = *pGroup++; + + FOR(sfb = 0; sfb < nsfb_win; sfb++) + { + IF ((pHuffBookUsed[sfb] > 0)&&(pHuffBookUsed[sfb] < BOOKSCL)) + { + cw_index = CALL decode_huff_cw_binary(pTable, pInputStream); + + fac += cw_index - MIDFAC; + + IF((fac >= 2*TEXP) || (fac < 0)) + { + status = 1; + } + ELSE + { + pFactors[sfb] = fac; + } + ENDIF (fac) + + } + ELSE IF (pHuffBookUsed[sfb] == ZERO_HCB) + { + do nothing; + } + + ELSE IF ((pHuffBookUsed[sfb] == INTENSITY_HCB)|| + (pHuffBookUsed[sfb] == INTENSITY_HCB2)) + { + cw_index = CALL decode_huff_cw_binary(pTable, pInputStream); + + is_pos += cw_index - MIDFAC; + pFactors[sfb] = is_pos; + } + + ELSE IF (pHuffBookUsed[sfb] == NOISE_HCB) + { + IF (noise_pcm_flag == TRUE) + { + noise_pcm_flag = FALSE; + dpcm_noise_nrg = CALL getbits( + NOISE_PCM_BITS, + pInputStream); + + dpcm_noise_nrg -= NOISE_PCM_OFFSET; + } + ELSE + { + dpcm_noise_nrg = CALL decode_huff_cw_binary( + pTable, + pInputStream); + + dpcm_noise_nrg -= MIDFAC; + } + ENDIF (noise_pcm_flag) + + noise_nrg += dpcm_noise_nrg; + pFactors[sfb] = noise_nrg; + } + + ELSE IF (pHuffBookUsed[sfb] == BOOKSCL) + { + status = 1; + } + ENDIF (pHuffBookUsed[sfb]) + + } + ENDFOR (sfb) + + IF (pFrameInfo->islong == FALSE) + { + + FOR(group_win++; group_win < group_end; group_win++) + { + FOR (sfb=0; sfb < nsfb_win; sfb++) + { + pFactors[sfb + nsfb_win] = pFactors[sfb]; + } + ENDFOR + + pFactors += nsfb_win; + } + ENDFOR + + } + ENDIF (pFrameInfo) + + pHuffBookUsed += nsfb_win; + pFactors += nsfb_win; + + } + ENDWHILE (group_end) + + return status; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "aac_mem_funcs.h" /* pv_memset */ +#include "s_frameinfo.h" +#include "s_bits.h" +#include "s_sectinfo.h" +#include "s_huffman.h" +#include "ibstream.h" + +#include "hcbtables.h" +#include "e_huffmanconst.h" +#include "e_infoinitconst.h" +#include "huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int hufffac( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int *pGroup, /* may be changed to Int */ + Int nsect, + SectInfo *pSect, /* may be changed to Int */ + Int global_gain, + Int *pFactors, + Int huffBookUsed[]) +{ + Int sect_idx; + Int group_end; /* index of 1st window in next group */ + Int group_win; /* window index within group */ + Int cw_index; /* huff codeword index */ + Int nsfb_win; /* # of scfbands per window */ + Int sfb; /* scalefactor band index */ + Int sect_cb; /* huff codebook # for each section */ + Int fac; /* decoded scf */ + Int is_pos; /* intensity stereo position */ + Int noise_pcm_flag = TRUE; /* first PNS sfb */ + Int dpcm_noise_nrg; /* dpcm noise energy */ + Int noise_nrg; /* noise energy */ + Int status = SUCCESS; /* status of decoding */ + Int *pHuffBookUsed = &huffBookUsed[0]; + + + pv_memset(pFactors, + ZERO_HCB, + MAXBANDS*sizeof(*pFactors)); + + + if (nsect) + { + /* read section length and codebook */ + + if (nsect == 1) /* long window */ + { + sect_cb = pSect->sect_cb; /* codebook for this section */ + + /* all sfbs in one section share the same codebook */ + + for (sfb = pSect->sect_end >> 2; sfb != 0; sfb--) + { + *(pHuffBookUsed++) = sect_cb; + *(pHuffBookUsed++) = sect_cb; + *(pHuffBookUsed++) = sect_cb; + *(pHuffBookUsed++) = sect_cb; + } + for (sfb = pSect->sect_end & 3; sfb != 0; sfb--) + { + *(pHuffBookUsed++) = sect_cb; + } + + } + else /* short */ + { + Int sect_start = 0; /* start index of sfb for each section */ + for (sect_idx = nsect; sect_idx > 0; sect_idx--) + { + sect_cb = pSect->sect_cb; /* codebook for this section */ + + /* all sfbs in one section share the same codebook */ + for (sfb = sect_start; sfb < pSect->sect_end; sfb++) + { + pHuffBookUsed[sfb] = sect_cb; + } + + pSect++; + sect_start = sfb; + + } /* for (sect_idx) */ + } + } + else + { + /* clear array for the case of max_sfb == 0 */ + pv_memset(pHuffBookUsed, + ZERO_HCB, + MAXBANDS*sizeof(*pHuffBookUsed)); + } + + pHuffBookUsed = &huffBookUsed[0]; + + /* scale factors and noise energy are dpcm relative to global gain + * intensity positions are dpcm relative to zero + */ + fac = global_gain; + is_pos = 0; + noise_nrg = global_gain - NOISE_OFFSET; + + /* get scale factors, + * use reserved Table entry = 12, see reference (2) p78 Table 4.6.2 + */ + group_win = 0; + group_end = 0; + + + /* group by group decoding scalefactors and/or noise energy + * and/or intensity position + */ + while ((group_end < pFrameInfo->num_win) && (status == SUCCESS)) + { + nsfb_win = pFrameInfo->sfb_per_win[group_end]; + group_end = *pGroup++; /* index of 1st window in next group */ + + if (group_end == 0) + { + break; /* error condition */ + } + + + /* decode scf in first window of each group */ + + for (sfb = 0; sfb < nsfb_win; sfb++) + { + + switch (pHuffBookUsed[sfb]) + { + case ZERO_HCB: + break; + case INTENSITY_HCB: + case INTENSITY_HCB2: + /* intensity books */ + /* decode intensity position */ + cw_index = decode_huff_scl(pInputStream); + + is_pos += cw_index - MIDFAC; + pFactors[sfb] = is_pos; + break; + case NOISE_HCB: + /* noise books */ + /* decode noise energy */ + if (noise_pcm_flag == TRUE) + { + noise_pcm_flag = FALSE; + dpcm_noise_nrg = get9_n_lessbits(NOISE_PCM_BITS, + pInputStream); + + dpcm_noise_nrg -= NOISE_PCM_OFFSET; + } + else + { + dpcm_noise_nrg = decode_huff_scl(pInputStream); + + dpcm_noise_nrg -= MIDFAC; + } /* if (noise_pcm_flag) */ + + noise_nrg += dpcm_noise_nrg; + pFactors[sfb] = noise_nrg; + break; + case BOOKSCL: + status = 1; /* invalid books */ + sfb = nsfb_win; /* force out */ + break; + default: + /* spectral books */ + /* decode scale factors */ + cw_index = decode_huff_scl(pInputStream); + + fac += cw_index - MIDFAC; /* 1.5 dB */ + if ((fac >= 2*TEXP) || (fac < 0)) + { + status = 1; /* error, MUST 0<=scf<256, Ref. p73 */ + } + else + { + pFactors[sfb] = fac; /* store scf */ + } /* if (fac) */ + } + + } /* for (sfb=0), first window decode ends */ + + /* expand scf to other windows in the same group */ + if (pFrameInfo->islong == FALSE) + { + + for (group_win++; group_win < group_end; group_win++) + { + for (sfb = 0; sfb < nsfb_win; sfb++) + { + pFactors[sfb + nsfb_win] = pFactors[sfb]; + } + pFactors += nsfb_win; + } + + } /* if (pFrameInfo->islong), one group decode ends */ + + + /* points to next group */ + pHuffBookUsed += nsfb_win; + pFactors += nsfb_win; + + } /* while (group_end), all groups decode end */ + + return status; + +} /* hufffac */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffman.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffman.h new file mode 100644 index 0000000..1e27338 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffman.h @@ -0,0 +1,227 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: huffman.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + include function prototype definitions for Huffman decoding module + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef HUFFMAN_H +#define HUFFMAN_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" +#include "s_sectinfo.h" +#include "s_pulseinfo.h" +#include "s_tdec_int_file.h" +#include "s_tdec_int_chan.h" +#include "ibstream.h" + +#include "s_hcb.h" +#include "hcbtables.h" + +#include "get_pulse_data.h" +#include "get_ics_info.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ +#define DIMENSION_4 4 +#define DIMENSION_2 2 + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int decode_huff_cw_tab1( + BITS *pInputStream); + + Int decode_huff_cw_tab2( + BITS *pInputStream); + + Int decode_huff_cw_tab3( + BITS *pInputStream); + + Int decode_huff_cw_tab4( + BITS *pInputStream); + + Int decode_huff_cw_tab5( + BITS *pInputStream); + + Int decode_huff_cw_tab6( + BITS *pInputStream); + + Int decode_huff_cw_tab7( + BITS *pInputStream); + + Int decode_huff_cw_tab8( + BITS *pInputStream); + + Int decode_huff_cw_tab9( + BITS *pInputStream); + + Int decode_huff_cw_tab10( + BITS *pInputStream); + + Int decode_huff_cw_tab11( + BITS *pInputStream); + + Int decode_huff_scl( + BITS *pInputStream); + + Int infoinit( + const Int sampling_rate_idx, + FrameInfo **ppWin_seq_info, + Int *pSfbwidth128); + + void initScratchChannel( + tDec_Int_File *pt_Scratch, + tDec_Int_File *pVars, + tDec_Int_Chan *pt_ChScratch[]); + + + Int huffcb( + SectInfo *pSect, + BITS *pInputStream, + Int *pSectbits, + Int tot_sfb, + Int sfb_per_sbk, + Int max_sfb); + + Int hufffac( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int *pGroup, + Int nsect, + SectInfo *pSect, + Int global_gain, + Int *pFactors, + Int huffBookUsed[]); + + Int huffspec_fxp( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int nsect, + SectInfo *pSectInfo, + Int factors[], + Int32 coef[], + Int16 quantSpec[], + Int16 tmp_spec[], + const FrameInfo *pLongFrameInfo, + PulseInfo *pPulseInfo, + Int qFormat[]); + + + Int huffspec_fxp_parse_bits( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int nsect, + SectInfo *pSectInfo); + + Int huffdecode( + Int id_syn_ele, + BITS *pInputStream, + tDec_Int_File *pVars_0, + tDec_Int_Chan *pChVars_0[] + ); + + + void deinterleave( + Int16 interleaved[], + Int16 deinterleaved[], + FrameInfo *pFrameInfo); + + Int getics( + Int id_syn_ele, + BITS *pInputStream, + Int common_window, + tDec_Int_File *pVars, + tDec_Int_Chan *pChVars, + Int group[], + Int *pMax_sfb, + Int *pCodebookMap, + TNS_frame_info *pTnsInfo, + FrameInfo **pWinMap, + PulseInfo *pPulseInfo, + SectInfo sect[]); + + + void calc_gsfb_table( + FrameInfo *pFrameInfo, + Int group[]); + + Int getmask( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int *pGroup, + Int max_sfb, + Int *pMask); + + void getgroup( + Int group[], + BITS *pInputStream); + + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffspec_fxp.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffspec_fxp.cpp new file mode 100644 index 0000000..ae9ff5b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/huffspec_fxp.cpp @@ -0,0 +1,587 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: huffspec_fxp.cpp + Funtions: + huffspec_fxp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pFrameInfo = ptr to structure that holds Information of current Frame, + type FrameInfo + + pInputStream = ptr to structure of bitstream, type BITS + + nsect = number of sections in current Frame, at fs = 44.1 kHz, + range [0, 49] long block, [0,112] short blocks. type Int + + pSect = ptr to structure that holds section codebook and boundary + type SectInfo + + factors[] = array that contains scalefactors for each sfb, type Int16 + + coef[] = array that holds inverse quantized coefs, Int32 QFormat. + + quantSpec[] = array that holds quantized spectral coefs, type Int + + tmp_spec[] = temporary buffer to hold the de-interleaved coefs. + + pLongFrameInfo = ptr to structure that holds long frame info + + Local Stores/Buffers/Pointers Needed: + exptable = array contains the Q15 format data for 2^0, 2^0.25, 2^0.5, + and 2^0.75, type const Int. + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + + return 0 if decoding properly. + + Pointers and Buffers Modified: + + pInputStream read codeword index and/or sign bits and/or ESC value + + coef contains the newly inverse quantized 1024 spec coefs, + type Int32 Q-format from esc_iquant() + + quantSpec contains decoded quantized 1024 spec coefs, type Int + + tmp_spec contains the de-interleaved version of quantSpec + + qFormat contains Q-Format for each scalefactor band + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function first reads the section info (codebook and boundary), then + decode the spectral coefficients if a spectral codebook is used. + If necessary, get the sign bits, ESC value or the NEC_pulse data. In case of + short window sequences, the decoded data is de-interleaved before + multiplied by scalefactors. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should set the content of the array 'coef' with the inverse + quantized and rescaled value of spectral coefficients. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart (4) p56 (spectral_data() parsing and decoding) + p26 (Syntax of spectral_data()) + p74-78 (decoding: unpack_idx, get_sign_bits, + getescape, pulse_nc, deinterleave) + p72 (inverse quantization: esc_iquant) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "aac_mem_funcs.h" +#include "esc_iquant_scaling.h" +#include "huffman.h" +#include "unpack_idx.h" +#include "pulse_nc.h" +#include "iquant_table.h" +#include "e_huffmanconst.h" + + +#include "pv_normalize.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define ORDER (3) + +/* + * Format the table is stored in. + */ +#define QTABLE (27) + +/* + * Number of bits for data in a signed 32 bit integer. + */ +#define SIGNED32BITS (31) + +/* + * Round up value for intermediate values obtained from the table + */ +#define ROUND_UP (( ((UInt32) 1) << (QTABLE) )-1) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const UInt16 exptable[4] = +{ + 0, /* (2^0.00)<<15 (Q10), use zero to signal no scaling required! */ + 19485, /* (2^0.25)<<15 */ + 23171, /* (2^0.50)<<15 */ + 27555 /* (2^0.75)<<15 */ + +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int huffspec_fxp( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int nsect, + SectInfo *pSectInfo, + Int factors[], + Int32 coef[], + Int16 quantSpec[], + Int16 tmp_spec[], + const FrameInfo *pLongFrameInfo, + PulseInfo *pPulseInfo, + Int qFormat[]) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + const Hcb *pHcb; + Int i; + Int sfb; + Int idx_count; + Int sect_cb; /* section codebook */ + Int dim; + Int idx; + Int stop_idx; /* index of 1st coef in next sfb */ + Int sect_start; /* start index of sfb in one section*/ + Int sect_end; /* index of 1st sfb in next section */ + Int *pSfbStart; + Int *pSfb; + Int16 *pQuantSpec; /* probably could be short */ + Int max = 0; + /* rescaling parameters */ + Int nsfb; + Int tot_sfb; + Int fac; + + Int32 *pCoef; /* ptr to coef[], inverse quantized coefs */ + UInt16 scale; + + Int power_scale_div_4; + Int sfbWidth; + + void (*pUnpack_idx)( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max); + + Int(*pDec_huff_tab)(BITS *) = NULL; + + UInt32 temp; + Int binaryDigits, QFormat; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + sect_start = 0; + stop_idx = 0; + + /* pSfb: ptr to array that holds stop index of each sfb */ + pSfbStart = pFrameInfo->frame_sfb_top; + + if (pSfbStart == NULL) + { + return (-1); /* error condition */ + } + + pSfb = pSfbStart; + + /* decoding spectral values section by section */ + for (i = nsect; i > 0; i--) + { + /* read the codebook and section length */ + sect_cb = pSectInfo->sect_cb; /* codebook */ + if ((sect_cb > 15) || (sect_cb < 0)) + { + return (-1); /* error condition */ + } + sect_end = pSectInfo->sect_end; /* # of sfbs */ + + if (sect_end < 0) + { + return (-1); /* error condition */ + } + + pSectInfo++; + + /* sect_cb sect_cb - 1 + * ZERO_HCB 1111b + * 1 0000b + * 2 0001b + * 3 0010b + * 4 0011b + * 5 0100b + * 6 0101b + * 7 0110b + * 8 0111b + * 9 1000b + * 10 1001b + * 11 1010b + * 12 1011b + * NOISE_HCB 1100b + * INTENSITY_HCB2 1101b + * INTENSITY_HCB 1110b + * if ( ((sect_cb - 1) & 0xC) == 0xC ) is identical to + * if !((sect_cb == ZERO_HCB) || (sect_cb == NOISE_HCB) || + * (sec_cb == INTENSITY_HCB) || (sect_cb==INTENSITY_HCB2) ) + * use this compare scheme to speed up the execution + */ + + if (((sect_cb - 1) & 0xC) != 0xC) + { + /* decode spec in one section */ + if (sect_cb > BY4BOOKS) + { + dim = DIMENSION_2; /* set codebook dimension */ + } + else + { + dim = DIMENSION_4; + } + + pHcb = &hcbbook_binary[sect_cb]; + + if (sect_cb == ESCBOOK) + { + pUnpack_idx = &unpack_idx_esc; + } + else if (pHcb->signed_cb == FALSE) + { + pUnpack_idx = &unpack_idx_sgn; + } + else + { + pUnpack_idx = &unpack_idx; + } + + + switch (sect_cb) + { + case 1: + pDec_huff_tab = decode_huff_cw_tab1; + break; + case 2: + pDec_huff_tab = decode_huff_cw_tab2; + break; + case 3: + pDec_huff_tab = decode_huff_cw_tab3; + break; + case 4: + pDec_huff_tab = decode_huff_cw_tab4; + break; + case 5: + pDec_huff_tab = decode_huff_cw_tab5; + break; + case 6: + pDec_huff_tab = decode_huff_cw_tab6; + break; + case 7: + pDec_huff_tab = decode_huff_cw_tab7; + break; + case 8: + pDec_huff_tab = decode_huff_cw_tab8; + break; + case 9: + pDec_huff_tab = decode_huff_cw_tab9; + break; + case 10: + pDec_huff_tab = decode_huff_cw_tab10; + break; + case 11: + pDec_huff_tab = decode_huff_cw_tab11; + break; + default: + return (-1); /* error condition */ + } + + /* move ptr to first sfb of current section */ + pQuantSpec = quantSpec + stop_idx; + + /* step through all sfbs in current section */ + for (sfb = sect_start; sfb < sect_end; sfb++) + { + idx_count = *pSfb - stop_idx; + stop_idx = *pSfb++; + + /* decode all coefs for one sfb */ + while ((idx_count > 0) && (idx_count < 1024)) + { + + idx = (*pDec_huff_tab)(pInputStream); + + (*pUnpack_idx)(pQuantSpec, + idx, + pHcb, + pInputStream, + &max); /* unpack idx -> coefs */ + + pQuantSpec += dim; + idx_count -= dim; + + } /* while(idx_count) */ + + } /* for (sfb=sect_start) */ + } + else + { + + /* current section uses ZERO_HCB, NOISE_HCB, etc */ + + /* move sfb pointer to the start sfb of next section */ + pSfb = pSfbStart + sect_end; + /* number of coefs in current section */ + idx_count = *(pSfb - 1) - stop_idx; + + if ((idx_count > 1024) || (idx_count < 0)) + { + return (-1); /* error condition */ + } + + /* + * This memset is necessary in terms of (1) net savings in total + * MIPS and (2) accurate Q-Formats for fft_rx2 + * In case a scalefactor band uses ZERO_HCB, all coefficients of + * that sfb should be zeros. Without this call to memset, the + * coefficients for a ZERO_HCB sfb are the "leftovers" of the + * previous frame, which may not have all zero values. This leads + * to a drastical increase in the cycles consumed by esc_iquant_fxp + * and fft_rx2, which is the most "expensive" function of the + * library. + * This memset also guarantees the Q_Format for sfbs with all zero + * coefficients will be set properly. + * Profiling data on ARM and TMS320C55x proves that there is a net + * gain in total MIPS if a memset is called here. + */ + pv_memset(&quantSpec[stop_idx], + 0, + idx_count * sizeof(quantSpec[0])); + + /* + * This memset is called because pQuantSpec points to tmp_spec + * after deinterleaving + */ + + pv_memset(&tmp_spec[stop_idx], + 0, + idx_count * sizeof(tmp_spec[0])); + + + /* stop_idx is the index of the 1st coef of next section */ + stop_idx = *(pSfb - 1); + + }/* if (sect_cb) */ + + sect_start = sect_end; + + } /* for (i=nsect) */ + + /* noisless coding reconstruction */ + if (pFrameInfo->islong != FALSE) + { + if (pPulseInfo->pulse_data_present == 1) + { + pulse_nc(quantSpec, + pPulseInfo, + pLongFrameInfo, + &max); /* add pulse data */ + } + + pQuantSpec = quantSpec; + + } + else + { + deinterleave(quantSpec, + tmp_spec, + pFrameInfo); + + pQuantSpec = tmp_spec; + } + + + /* inverse quantization, Q_format: Int32 */ + /* rescaling */ + + /* what we can do here is assuming that we already know maxInput for each band, we have to go + though each one of them for re-quant and scaling, and pick the right qFormat to apply to + all spectral coeffs.*/ + + if ((max >= 0) && (max <= 8192)) /* (8192>>ORDER) == 1024 is the inverseQuantTable size */ + { + /* Get (max/SPACING) ^ (1/3), in Q Format */ + temp = inverseQuantTable[(max >> ORDER) + 1]; + } + else + { + return (-1); /* error condition */ + } + + + /* Round up before shifting down to Q0 */ + temp += ROUND_UP; + + /* shift down to Q0 and multiply by 2 (FACTOR) in one step */ + temp >>= (QTABLE - 1); + + /* Now get max ^ (4/3) in Q0 */ + temp *= max; + + + binaryDigits = 31 - pv_normalize(temp); + + + /* Prevent negative shifts caused by low maximums. */ + if (binaryDigits < (SIGNED32BITS - QTABLE)) + { + binaryDigits = SIGNED32BITS - QTABLE; + } + + QFormat = SIGNED32BITS - binaryDigits; + + /********************/ + tot_sfb = 0; + nsfb = pFrameInfo->sfb_per_win[0]; + pCoef = coef; + + for (i = pFrameInfo->num_win; i > 0; i--) + { + stop_idx = 0; + + for (sfb = 0; sfb < nsfb; sfb++) + { + sfbWidth = pFrameInfo->win_sfb_top[0][sfb] - stop_idx; + + /* sfbWidth must be possitive, lesser than 1024 and multiple of 4 */ + if ((sfbWidth < 0) || (sfbWidth > 1024) || (sfbWidth & 3)) + { + return (-1); /* error condition */ + } + + stop_idx += sfbWidth; + + fac = factors[tot_sfb] - SF_OFFSET; + scale = exptable[fac & 0x3]; + + power_scale_div_4 = fac >> 2; + + power_scale_div_4++; + + qFormat[tot_sfb] = QFormat; + + esc_iquant_scaling(pQuantSpec, + pCoef, + sfbWidth, + QFormat, + scale, + max); + + pQuantSpec += sfbWidth; + pCoef += sfbWidth; + + qFormat[tot_sfb++] -= power_scale_div_4; + + + } /* for (sfb) */ + } /* for (i) */ + + + /*---------------------------------------------------------------------------- + ; Return status + ----------------------------------------------------------------------------*/ + return SUCCESS; + +} /* huffspec_fxp */ + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ibstream.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ibstream.h new file mode 100644 index 0000000..3487796 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ibstream.h @@ -0,0 +1,100 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ibstream.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Contains defines, structures, and function definitions for the + input bit stream used in the AAC Decoder. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef IBSTREAM_H +#define IBSTREAM_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +#define INBUF_ARRAY_INDEX_SHIFT (3) +#define INBUF_BIT_WIDTH (1<<(INBUF_ARRAY_INDEX_SHIFT)) +#define INBUF_BIT_MODULO_MASK ((INBUF_BIT_WIDTH)-1) + +#define MAX_GETBITS (25) +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void byte_align( + BITS *pInputStream); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* IBSTREAM_H */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct16.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct16.cpp new file mode 100644 index 0000000..89b18b3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct16.cpp @@ -0,0 +1,197 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct16.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 16 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement inverse discrete cosine transform of lenght 16 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "idct16.h" +#include "idct8.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +#define R_SHIFT 28 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) +#define Qfmt31(x) (Int32)(x*(0x7FFFFFFF) + (x>=0?0.5F:-0.5F)) + +const Int32 CosTable_8i[8] = +{ + Qfmt31(0.50241928618816F), Qfmt31(0.52249861493969F), + Qfmt31(0.56694403481636F), Qfmt31(0.64682178335999F), + Qfmt(0.78815462345125F), Qfmt(1.06067768599035F), + Qfmt(1.72244709823833F), Qfmt(5.10114861868916F) +}; + + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void idct_16(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 8 */ +{ + Int32 *temp_even = scratch_mem; + + Int32 i; + const Int32 *pt_cos = CosTable_8i; + Int32 tmp1, tmp2; + Int32 *pt_even = temp_even; + Int32 *pt_odd = vec; + Int32 *pt_vec = vec; + + Int32 tmp3; + Int32 *pt_vecN_1; + + + *(pt_even++) = *(pt_vec++); + tmp1 = *(pt_vec++); + *(pt_odd++) = tmp1; + + for (i = 2; i != 0; i--) + { + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + tmp3 = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + *(pt_odd++) = tmp3 + tmp2; + tmp1 = tmp3; + } + + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + tmp3 = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + *(pt_odd++) = tmp3 + tmp2; + + + *(pt_even) = *(pt_vec++); + *(pt_odd++) = *(pt_vec) + tmp3; + + + idct_8(temp_even); + idct_8(vec); + + + pt_cos = &CosTable_8i[7]; + + pt_vec = &vec[7]; + + pt_even = &temp_even[7]; + pt_vecN_1 = &vec[8]; + + tmp1 = *(pt_even--); + + for (i = 2; i != 0; i--) + { + tmp3 = fxp_mul32_Q28(*(pt_vec), *(pt_cos--)); + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q28(*(pt_vec), *(pt_cos--)); + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp2 - tmp3; + *(pt_vec--) = tmp2 + tmp3; + } + + tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1; + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1; + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp2 - tmp3; + *(pt_vec--) = tmp2 + tmp3; + tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1; + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos)) << 1; + *(pt_vecN_1) = tmp2 - tmp3; + *(pt_vec) = tmp2 + tmp3; + +} + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct16.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct16.h new file mode 100644 index 0000000..b554376 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct16.h @@ -0,0 +1,64 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct16.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef IDCT16_H +#define IDCT16_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + void idct_16(Int32 vec[], Int32 scratch_mem[]); + + +#ifdef __cplusplus +} +#endif + +#endif /* IDCT16_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct32.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct32.cpp new file mode 100644 index 0000000..50283b4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct32.cpp @@ -0,0 +1,189 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct32.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 32 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement inverse discrete cosine transform of lenght 32 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#include "idct32.h" +#include "dst32.h" +#include "idct16.h" + +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + + +#define R_SHIFT1 29 +#define Qfmt1(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt3(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void idct_32(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 32 */ +{ + Int32 *temp_even = scratch_mem; + + Int32 i; + const Int32 *pt_cos = CosTable_16; + Int32 tmp1, tmp2; + Int32 *pt_even = temp_even; + Int32 *pt_odd = vec; + Int32 *pt_vec = vec; + Int32 *pt_vecN_1; + Int32 tmp3; + + + *(pt_even++) = *(pt_vec++); + tmp1 = *(pt_vec++); + tmp2 = 0; + + for (i = 7; i != 0; i--) + { + *(pt_odd++) = tmp2 + tmp1; + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + tmp1 = *(pt_vec++); + } + + *(pt_odd++) = tmp2 + tmp1; + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + + + idct_16(temp_even, &scratch_mem[16]); + idct_16(vec, &scratch_mem[24]); + + + pt_cos = &CosTable_16[13]; + + pt_vec = &vec[15]; + + pt_even = &temp_even[15]; + pt_vecN_1 = &vec[16]; + + tmp1 = *(pt_even--); + + + tmp3 = fxp_mul32_Q31(*(pt_vec) << 3, Qfmt3(0.63687550772175F)) << 2; + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q31(*(pt_vec) << 3, Qfmt3(0.85190210461718F)); + + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp2 - tmp3; + *(pt_vec--) = tmp2 + tmp3; + + for (i = 2; i != 0; i--) + { + tmp3 = fxp_mul32_Q29(*(pt_vec), *(pt_cos--)); + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q29(*(pt_vec), *(pt_cos--)); + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp2 - tmp3; + *(pt_vec--) = tmp2 + tmp3; + } + + for (i = 5; i != 0; i--) + { + tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1; + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1; + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp2 - tmp3; + *(pt_vec--) = tmp2 + tmp3; + } +} + + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct32.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct32.h new file mode 100644 index 0000000..53d7ef9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct32.h @@ -0,0 +1,64 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct32.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef IDCT32_H +#define IDCT32_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void idct_32(Int32 vec[], Int32 scratch_mem[]); + + + +#ifdef __cplusplus +} +#endif + +#endif /* IDCT32_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct8.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct8.cpp new file mode 100644 index 0000000..bc94627 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct8.cpp @@ -0,0 +1,161 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct8.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 8 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement inverse discrete cosine transform of lenght 8 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +#ifdef AAC_PLUS + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "idct8.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +#define R_SHIFT 29 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void idct_8(Int32 vec[]) +{ + + Int32 tmp0; + Int32 tmp1; + Int32 tmp2; + Int32 tmp3; + Int32 tmp4; + Int32 tmp5; + Int32 tmp6; + Int32 tmp7; + Int32 tmp8; + + + tmp5 = fxp_mul32_by_16(vec[4] << 1, Qfmt15(0.70710678118655F)); + + tmp1 = vec[0] + tmp5; + tmp5 = vec[0] - tmp5; + + tmp3 = fxp_mul32_by_16(vec[2] << 1, Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi)));*/ + tmp7 = fxp_mul32_Q29(vec[6], Qfmt(1.30656296487638F)); /* (1/(2*cos(6*phi)));*/ + + tmp0 = fxp_mul32_by_16((tmp3 - tmp7) << 1, Qfmt15(0.70710678118655F)); /* (1/(2*cos(2*phi))); */ + tmp7 = (tmp3 + tmp7) + tmp0; + + vec[0] = tmp1 + tmp7; + tmp2 = fxp_mul32_by_16(vec[1] << 1, Qfmt15(0.50979557910416F)); /* (1/(2*cos( phi)));*/ + vec[1] = tmp5 + tmp0; + vec[2] = tmp5 - tmp0; + tmp4 = fxp_mul32_by_16(vec[3] << 1, Qfmt15(0.60134488693505F)); /* (1/(2*cos(3*phi)));*/ + vec[3] = tmp1 - tmp7; + + tmp6 = fxp_mul32_by_16(vec[5] << 1, Qfmt15(0.89997622313642F)); /* (1/(2*cos(5*phi)));*/ + tmp8 = fxp_mul32_Q29(vec[7], Qfmt(2.56291544774151F)); /* (1/(2*cos(7*phi)));*/ + + tmp7 = tmp2 + tmp8; + tmp5 = fxp_mul32_by_16((tmp2 - tmp8) << 1, Qfmt15(0.54119610014620F)); + tmp8 = tmp4 + tmp6; + tmp6 = fxp_mul32_Q29((tmp4 - tmp6), Qfmt(1.30656296487638F)); + + tmp0 = tmp7 + tmp8; + tmp2 = fxp_mul32_by_16((tmp7 - tmp8) << 1, Qfmt15(0.70710678118655F)); + + tmp3 = fxp_mul32_by_16((tmp5 - tmp6) << 1, Qfmt15(0.70710678118655F)); + tmp1 = (tmp5 + tmp6) + tmp3; + + tmp5 = tmp0 + tmp1; + tmp6 = tmp1 + tmp2; + tmp7 = tmp2 + tmp3; + + vec[7] = vec[0] - tmp5; + vec[0] += tmp5; + vec[6] = vec[1] - tmp6; + vec[1] += tmp6; + vec[5] = vec[2] - tmp7; + vec[2] += tmp7; + vec[4] = vec[3] - tmp3; + vec[3] += tmp3; + +} + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct8.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct8.h new file mode 100644 index 0000000..4e37175 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/idct8.h @@ -0,0 +1,64 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct8.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef IDCT8_H +#define IDCT8_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void idct_8(Int32 vec[]); + + + +#ifdef __cplusplus +} +#endif + +#endif /* IDCT8_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/imdct_fxp.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/imdct_fxp.cpp new file mode 100644 index 0000000..626ae15 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/imdct_fxp.cpp @@ -0,0 +1,454 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: imdct_fxp.cpp + Funtions: imdct_fxp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + data_quant = Input vector, with quantized spectral lines: + type Int32 + + freq_2_time_buffer = Scratch memory used for in-place FFT calculation, + min size required 1024, + type Int32 + + n = Length of input vector "data_quant". Currently 256 or 2048 + type const Int + + Q_format = Q_format of the input vector "data_quant" + type Int + + max = Maximum value inside input vector "data_quant" + type Int32 + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + shift = shift factor to reflect scaling introduced by IFFT and imdct_fxp, + + Pointers and Buffers Modified: + Results are return in "Data_Int_precision" + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + The IMDCT is a linear orthogonal lapped transform, based on the idea of + time domain aliasing cancellation (TDAC). + IMDCT is critically sampled, which means that though it is 50% overlapped, + a sequence data after IMDCT has the same number of coefficients as samples + before the transform (after overlap-and-add). This means, that a single + block of IMDCT data does not correspond to the original block on which the + IMDCT was performed. When subsequent blocks of inverse transformed data + are added (still using 50% overlap), the errors introduced by the + transform cancels out.Thanks to the overlapping feature, the IMDCT is very + useful for quantization. It effectively removes the otherwise easily + detectable blocking artifact between transform blocks. + + N = twice the length of input vector X + y = vector of length N, will hold fixed point IDCT + p = 0:1:N-1 + + 2 N/2-1 + y(p) = --- SUM X(m)*cos(pi/(2*N)*(2*p+1+N/2)*(2*m+1)) + N m=0 + + The window that completes the TDAC is applied before calling this function. + The IMDCT can be calculated using an IFFT, for this, the IMDCT need be + rewritten as an odd-time odd-frequency discrete Fourier transform. Thus, + the IMDCT can be calculated using only one n/4 point FFT and some pre and + post-rotation of the sample points. + + + where X(k) is the input with N frequency lines + + X(k) ---------------------------- + | + | + Pre-rotation by exp(j(2pi/N)(k+1/8)) + | + | + N/4- point IFFT + | + | + Post-rotation by exp(j(2pi/N)(n+1/8)) + | + | + ------------- x(n) In the time domain + + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should provide a fixed point IMDCT with an average + quantization error less than 1 % (variance and mean). + +------------------------------------------------------------------------------ + REFERENCES + + [1] Analysis/Synthesis Filter Bank design based on time domain + aliasing cancellation + Jhon Princen, et. al. + IEEE Transactions on ASSP, vol ASSP-34, No. 5 October 1986 + Pg 1153 - 1161 + + [2] Regular FFT-related transform kernels for DCT/DST based + polyphase filterbanks + Rolf Gluth + Proc. ICASSP 1991, pg. 2205 - 2208 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + Cx, Cy are complex number + + + exp = log2(n)-1 + + FOR ( k=0; k< n/2; k +=2) + + Cx = - data_quant[k] + j data_quant[n/2-1 - k] + + freq_2_time_buffer = Cx * exp(j(2pi/n)(k+1/8)) + + ENDFOR + + CALL IFFT( freq_2_time_buffer, n/4) + + MODIFYING( freq_2_time_buffer ) + + RETURNING( shift ) + + FOR ( k=0; k< n/4; k +=2) + + Cx = freq_2_time_buffer[ k] + j freq_2_time_buffer[ k+1] + + Cy = Cx * exp(j(2pi/n)(k+1/8)) + + data_quant[3n/4-1 - k ] = Real(Cy) + data_quant[ n/4-1 - k ] = - Imag(Cy) + data_quant[3n/4 + k ] = Real(Cy) + data_quant[ n/4 + k ] = Imag(Cy) + + ENDFOR + + FOR ( k=n/4; k< n/2; k +=2) + + Cx = freq_2_time_buffer[ k] + j freq_2_time_buffer[ k+1] + + Cy = Cx * exp(j(2pi/n)(k+1/8)) + + data_quant[3n/4-1 - k ] = Real(Cy) + data_quant[ n/4 + k ] = - Real(Cy) + data_quant[5n/4 - k ] = Imag(Cy) + data_quant[ n/4 + k ] = Imag(Cy) + + ENDFOR + + MODIFIED data_quant[] + + RETURN (exp - shift) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "imdct_fxp.h" + + +#include "mix_radix_fft.h" +#include "digit_reversal_tables.h" +#include "fft_rx4.h" +#include "inv_short_complex_rot.h" +#include "inv_long_complex_rot.h" +#include "pv_normalize.h" +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" + +#include "window_block_fxp.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define ERROR_IN_FRAME_SIZE 10 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +Int imdct_fxp(Int32 data_quant[], + Int32 freq_2_time_buffer[], + const Int n, + Int Q_format, + Int32 max) +{ + + Int32 exp_jw; + Int shift = 0; + + const Int32 *p_rotate; + const Int32 *p_rotate_2; + + Int32 *p_data_1; + Int32 *p_data_2; + + Int32 temp_re32; + Int32 temp_im32; + + Int shift1 = 0; + Int32 temp1; + Int32 temp2; + + Int k; + Int n_2 = n >> 1; + Int n_4 = n >> 2; + + + + if (max != 0) + { + + switch (n) + { + case SHORT_WINDOW_TYPE: + p_rotate = exp_rotation_N_256; + shift = 21; /* log2(n)-1 + 14 acomodates 2/N factor */ + break; + + case LONG_WINDOW_TYPE: + p_rotate = exp_rotation_N_2048; + shift = 24; /* log2(n)-1 +14 acomodates 2/N factor */ + break; + + default: + /* + * There is no defined behavior for a non supported frame + * size. By returning a fixed scaling factor, the input will + * scaled down and the will be heard as a low level noise + */ + return(ERROR_IN_FRAME_SIZE); + + } + + /* + * p_data_1 p_data_2 + * | | + * RIRIRIRIRIRIRIRIRIRIRIRIRIRIRI....RIRIRIRIRIRI + * | | + * + */ + + p_data_1 = data_quant; /* uses first half of buffer */ + p_data_2 = &data_quant[n_2 - 1]; /* uses second half of buffer */ + + p_rotate_2 = &p_rotate[n_4-1]; + + shift1 = pv_normalize(max) - 1; /* -1 to leave room for addition */ + Q_format -= (16 - shift1); + max = 0; + + + if (shift1 >= 0) + { + temp_re32 = *(p_data_1++) << shift1; + temp_im32 = *(p_data_2--) << shift1; + + for (k = n_4 >> 1; k != 0; k--) + { + /* + * Real and Imag parts have been swaped to use FFT as IFFT + */ + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + exp_jw = *p_rotate++; + + temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw); + temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw); + + temp_im32 = *(p_data_1--) << shift1; + temp_re32 = *(p_data_2--) << shift1; + *(p_data_1++) = temp1; + *(p_data_1++) = temp2; + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + + /* + * Real and Imag parts have been swaped to use FFT as IFFT + */ + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + exp_jw = *p_rotate_2--; + + temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw); + temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw); + + + temp_re32 = *(p_data_1++) << shift1; + temp_im32 = *(p_data_2--) << shift1; + + *(p_data_2 + 2) = temp1; + *(p_data_2 + 3) = temp2; + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + } + } + else + { + temp_re32 = *(p_data_1++) >> 1; + temp_im32 = *(p_data_2--) >> 1; + + for (k = n_4 >> 1; k != 0; k--) + { + /* + * Real and Imag parts have been swaped to use FFT as IFFT + */ + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + exp_jw = *p_rotate++; + + temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw); + temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw); + + temp_im32 = *(p_data_1--) >> 1; + temp_re32 = *(p_data_2--) >> 1; + *(p_data_1++) = temp1; + *(p_data_1++) = temp2; + + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + + /* + * Real and Imag parts have been swaped to use FFT as IFFT + */ + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + exp_jw = *p_rotate_2--; + + temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw); + temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw); + + temp_re32 = *(p_data_1++) >> 1; + temp_im32 = *(p_data_2--) >> 1; + + *(p_data_2 + 3) = temp2; + *(p_data_2 + 2) = temp1; + + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + } + } + + + if (n != SHORT_WINDOW_TYPE) + { + + shift -= mix_radix_fft(data_quant, + &max); + + shift -= inv_long_complex_rot(data_quant, + max); + + } + else /* n_4 is 64 */ + { + + shift -= fft_rx4_short(data_quant, &max); + + + shift -= inv_short_complex_rot(data_quant, + freq_2_time_buffer, + max); + + pv_memcpy(data_quant, + freq_2_time_buffer, + SHORT_WINDOW*sizeof(*data_quant)); + } + + } + else + { + Q_format = ALL_ZEROS_BUFFER; + } + + return(shift + Q_format); + +} /* imdct_fxp */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/imdct_fxp.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/imdct_fxp.h new file mode 100644 index 0000000..4cf7cbe --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/imdct_fxp.h @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: imdct_fxp.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function imdct_fxp() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef IMDCT_FXP_H +#define IMDCT_FXP_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + +#define LONG_WINDOW_TYPE 2048 +#define SHORT_WINDOW_TYPE 256 + +#define ALL_ZEROS_BUFFER 31 + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + extern const Int32 exp_rotation_N_256[64]; + extern const Int32 exp_rotation_N_2048[512]; + /* + extern const Int exp_rotation_N_256[128]; + extern const Int exp_rotation_N_2048[1024]; + */ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int imdct_fxp( + Int32 data_quant[], + Int32 freq_2_time_buffer[], + const Int n, + Int Q_format, + Int32 max + ); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* IMDCT_FXP_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/infoinit.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/infoinit.cpp new file mode 100644 index 0000000..724c923 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/infoinit.cpp @@ -0,0 +1,312 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: infoinit.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pSi = pointer to sampling rate info + ppWin_seq_info = pointer array to window sequence Info struct + pSfbwidth128 = pointer to sfb bandwidth array of short window + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + + ppWin_seq_info[ONLY_LONG_WINDOW]{all structure members} = setup values + ppWin_seq_info[EIGHT_SHORT_WINDOW]{all structure members} = setup values + + Local Stores Modified: + + Global Stores Modified: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function sets the values of 'Info' structure for blocks containing long + and short window sequences, the following structures are being set: + + win_seq_info[ONLY_LONG_WINDOW], win_seq_info[EIGHT_SHORT_WINDOW], + only_long_info and eight_short_info + +------------------------------------------------------------------------------ + REQUIREMENTS + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p66 (sfb tables) + p111 (4.6.10) + p200 (Annex 4.B.5) +------------------------------------------------------------------------------ + PSEUDO-CODE + + pFrameInfo = pointer to only_long_info; + win_seq_info[ONLY_LONG_WINDOW] = pFrameInfo; + pFrameInfo{all structure members} = setup values; + + + pFrameInfo = pointer to eight_short_info; + win_seq_info[EIGHT_SHORT_WINDOW] = pFrameInfo; + pFrameInfo{all structure.members} = setup values; + + + FOR (window_seq = 0; window_seq < NUM_WIN_SEQ; win_seq++) + + win_seq_info[window_seq].members = setup values; + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sr_info.h" +#include "s_frameinfo.h" +#include "e_blockswitching.h" +#include "e_huffmanconst.h" +#include "sfb.h" +#include "huffman.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int infoinit( + const Int samp_rate_idx, + FrameInfo **ppWin_seq_info, + Int *pSfbwidth128) + +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + + Int i; + Int sfb_idx, sfb_sbk; + Int bins_sbk; + Int win_seq; + Int start_idx, end_idx; + Int nsfb_short; + Int16 *sfbands; + FrameInfo *pFrameInfo; + + const SR_Info *pSi = &(samp_rate_info[samp_rate_idx]); + + const Int16 * pt_SFbands1024 = NULL; + const Int16 * pt_SFbands128 = NULL; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + switch (pSi->samp_rate) + { + case 96000: + case 88200: + pt_SFbands1024 = sfb_96_1024; + pt_SFbands128 = sfb_64_128; /* equal to table sfb_96_128, (eliminated) */ + break; + case 64000: + pt_SFbands1024 = sfb_64_1024; + pt_SFbands128 = sfb_64_128; + break; + case 48000: + case 44100: + pt_SFbands1024 = sfb_48_1024; + pt_SFbands128 = sfb_48_128; + break; + case 32000: + pt_SFbands1024 = sfb_32_1024; + pt_SFbands128 = sfb_48_128; + break; + case 24000: + case 22050: + pt_SFbands1024 = sfb_24_1024; + pt_SFbands128 = sfb_24_128; + break; + case 16000: + case 12000: + case 11025: + pt_SFbands1024 = sfb_16_1024; + pt_SFbands128 = sfb_16_128; + break; + case 8000: + pt_SFbands1024 = sfb_8_1024; + pt_SFbands128 = sfb_8_128; + break; + default: + // sampling rate not supported + return -1; + } + + /* long block info */ + + pFrameInfo = ppWin_seq_info[ONLY_LONG_WINDOW]; + pFrameInfo->islong = 1; + pFrameInfo->num_win = 1; + pFrameInfo->coef_per_frame = LN2; /* = 1024 */ + + pFrameInfo->sfb_per_win[0] = pSi->nsfb1024; + pFrameInfo->sectbits[0] = LONG_SECT_BITS; + pFrameInfo->win_sfb_top[0] = (Int16 *)pt_SFbands1024; + + pFrameInfo->sfb_width_128 = NULL; /* no short block sfb */ + pFrameInfo->num_groups = 1; /* long block, one group */ + pFrameInfo->group_len[0] = 1; /* only one window */ + + /* short block info */ + pFrameInfo = ppWin_seq_info[EIGHT_SHORT_WINDOW]; + pFrameInfo->islong = 0; + pFrameInfo->num_win = NSHORT; + pFrameInfo->coef_per_frame = LN2; + + for (i = 0; i < pFrameInfo->num_win; i++) + { + pFrameInfo->sfb_per_win[i] = pSi->nsfb128; + pFrameInfo->sectbits[i] = SHORT_SECT_BITS; + pFrameInfo->win_sfb_top[i] = (Int16 *)pt_SFbands128; + } + + /* construct sfb width table */ + pFrameInfo->sfb_width_128 = pSfbwidth128; + for (i = 0, start_idx = 0, nsfb_short = pSi->nsfb128; i < nsfb_short; i++) + { + end_idx = pt_SFbands128[i]; + pSfbwidth128[i] = end_idx - start_idx; + start_idx = end_idx; + } + + + /* common to long and short */ + for (win_seq = 0; win_seq < NUM_WIN_SEQ; win_seq++) + { + + if (ppWin_seq_info[win_seq] != NULL) + { + pFrameInfo = ppWin_seq_info[win_seq]; + pFrameInfo->sfb_per_frame = 0; + sfb_sbk = 0; + bins_sbk = 0; + + for (i = 0; i < pFrameInfo->num_win; i++) + { + + /* compute coef_per_win */ + pFrameInfo->coef_per_win[i] = + pFrameInfo->coef_per_frame / pFrameInfo->num_win; + + /* compute sfb_per_frame */ + pFrameInfo->sfb_per_frame += pFrameInfo->sfb_per_win[i]; + + /* construct default (non-interleaved) bk_sfb_top[] */ + sfbands = pFrameInfo->win_sfb_top[i]; + for (sfb_idx = 0; sfb_idx < pFrameInfo->sfb_per_win[i]; + sfb_idx++) + { + pFrameInfo->frame_sfb_top[sfb_idx+sfb_sbk] = + sfbands[sfb_idx] + bins_sbk; + } + + bins_sbk += pFrameInfo->coef_per_win[i]; + sfb_sbk += pFrameInfo->sfb_per_win[i]; + } /* for i = sbk ends */ + } + + } /* for win_seq ends */ + + return SUCCESS; + +} /* infoinit */ + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/init_sbr_dec.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/init_sbr_dec.cpp new file mode 100644 index 0000000..2c378c9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/init_sbr_dec.cpp @@ -0,0 +1,185 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: init_sbr_dec.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + initializes sbr decoder structure +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "init_sbr_dec.h" +#include "aac_mem_funcs.h" +#include "extractframeinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 init_sbr_dec(Int32 codecSampleRate, + Int upsampleFac, + SBR_DEC *sbrDec, + SBR_FRAME_DATA *hFrameData) +{ + Int32 outFrameSize; + Int32 coreCodecFrameSize = 1024; +#ifdef HQ_SBR + Int32 i; +#endif + + + sbrDec->sbStopCodec = upsampleFac << 5; + sbrDec->prevLowSubband = upsampleFac << 5; + + + /* set sbr sampling frequency */ + sbrDec->outSampleRate = 2 * codecSampleRate; + outFrameSize = upsampleFac * coreCodecFrameSize; + + hFrameData->nSfb[LO] = 0; /* number of scale factor bands for high resp.low frequency resolution */ + hFrameData->nSfb[HI] = 0; + hFrameData->offset = 0; + + hFrameData->nNfb = hFrameData->sbr_header.noNoiseBands; + hFrameData->prevEnvIsShort = -1; + + /* Initializes pointers */ +#ifdef HQ_SBR + for (i = 0; i < 5; i++) + { + hFrameData->fBuf_man[i] = hFrameData->fBuffer_man[i]; + hFrameData->fBufN_man[i] = hFrameData->fBufferN_man[i]; + hFrameData->fBuf_exp[i] = hFrameData->fBuffer_exp[i]; + hFrameData->fBufN_exp[i] = hFrameData->fBufferN_exp[i]; + } +#endif + + + pv_memset((void *)hFrameData->sbr_invf_mode_prev, + 0, + MAX_NUM_NOISE_VALUES*sizeof(INVF_MODE)); + + /* Direct assignments */ + + sbrDec->noCols = 32; + + sbrDec->bufWriteOffs = 6 + 2; + sbrDec->bufReadOffs = 2; + sbrDec->qmfBufLen = sbrDec->noCols + sbrDec->bufWriteOffs; + + sbrDec->lowBandAddSamples = 288; + + sbrDec->startIndexCodecQmf = 0; + + sbrDec->lowSubband = 32; + + + return outFrameSize; +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/init_sbr_dec.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/init_sbr_dec.h new file mode 100644 index 0000000..304f6ea --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/init_sbr_dec.h @@ -0,0 +1,109 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: init_sbr_dec.h + Funtions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef INIT_SBR_DEC_H +#define INIT_SBR_DEC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "sbr_dec.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int32 init_sbr_dec(Int32 codecSampleRate, + Int upsampleFac, + SBR_DEC *sbrDec, + SBR_FRAME_DATA *hFrameData); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/intensity_right.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/intensity_right.cpp new file mode 100644 index 0000000..4e5ccee --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/intensity_right.cpp @@ -0,0 +1,416 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: intensity_right.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + scalefactor = Multiplier used to scale the data extracted from the left + channel for use on the right. + [const Int] + + coef_per_win = Number of coefficients per window. + (128 for short, 1024 for long) + [const Int] + + sfb_per_win = Number of scalefactor bands per window. This should be + a number divisible by four. + [const Int] + + wins_in_group = The number of windows in the group being decoded. + This number falls within the range 1-8. + [const Int] + + band_length = The length of the scalefactor band being decoded. + This value is divisible by 4. + [const Int] + + codebook = Value that denotes which Huffman codebook was used for + the encoding of this grouped scalefactor band. + [const Int] + + ms_used = Flag that denotes whether M/S is active for this band. + [const Bool] + + q_formatLeft = The Q-format for the left channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [const Int *, length MAXBANDS] + + q_formatRight = The Q-format for the right channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAXBANDS] + + coefLeft = Array containing the fixed-point spectral coefficients + for the left channel. + [const Int32 *, length 1024] + + coefRight = Array containing the fixed-point spectral coefficients + for the right channel. + [Int32 *, length 1024] + + Local Stores/Buffers/Pointers Needed: + intensity_factor = Table which stores the values of + 0.5^(0), 0.5^(1/4), 0.5^(2/4) and 0.5^(3/4) + [UInt, length 4] + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coefRight[] Contains the new spectral information + + q_formatRight[] Q-format may be updated with changed fixed-point + data in coefRight. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function applies Intensity Stereo, generating data on the right channel + that is derived from data on the Left. A scalefactor is applied using the + following formula... + + RightCh = LeftCh*0.5^(scalefactor/4) + + This function works for one scalefactor band, which may belong to a group. + (i.e. the same scalefactor band repeated across multiple windows belonging + to one group.) + +------------------------------------------------------------------------------ + REQUIREMENTS + + codebook must be either INTENSITY_HCB or INTENSITY_HCB2 when this function + is called. + + ms_used must be 1 when TRUE, 0 when FALSE. + + wins_in_group falls within the range [1-8] + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.7.2.3 Decoding Process (Intensity Stereo) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + multiplier = codebook AND 0x1; + + multiplier = multiplier XOR ms_used; + + multiplier = multiplier << 1; + + multiplier = multiplier - 1; + + multiplier = multiplier * intensity_factor[scalefactor & 0x3]; + + scf_div_4 = (scalefactor >> 2); + + nextWinPtrUpdate = (coef_per_win - band_length); + + FOR (win_indx = wins_in_group; win_indx > 0; win_indx--) + + *(pQformatRight) = scf_div_4 + *(pQformatLeft) - 1; + + FOR (tempInt = band_length; tempInt > 0; tempInt--) + tempInt2 = (Int)(*(pCoefLeft) >> 16); + + *(pCoefRight) = tempInt2 * multiplier; + + pCoefRight = pCoefRight + 1; + pCoefLeft = pCoefLeft + 1; + + ENDFOR + + pCoefRight = pCoefRight + nextWinPtrUpdate; + pCoefLeft = pCoefLeft + nextWinPtrUpdate; + + pQformatRight = pQformatRight + sfb_per_win; + pQformatLeft = pQformatLeft + sfb_per_win; + ENDFOR + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "intensity_right.h" +#include "e_huffmanconst.h" + +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const Int16 intensity_factor[4] = +{ + 32767, /* (0.5^0.00)*2^15 - 1 (minus 1 for storage as type Int) */ + 27554, /* (0.5^0.25)*2^15 */ + 23170, /* (0.5^0.50)*2^15 */ + 19484 +}; /* (0.5^0.75)*2^15 */ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void intensity_right( + const Int scalefactor, + const Int coef_per_win, + const Int sfb_per_win, + const Int wins_in_group, + const Int band_length, + const Int codebook, + const Bool ms_used, + const Int q_formatLeft[], + Int q_formatRight[], + const Int32 coefLeft[], + Int32 coefRight[]) + +{ + const Int32 *pCoefLeft = coefLeft; + Int32 *pCoefRight = coefRight; + + const Int *pQformatLeft = q_formatLeft; + Int *pQformatRight = q_formatRight; + + Int multiplier; + Int scf_div_4; + Int nextWinPtrUpdate; + + /* + * The sign of the intensity multiplier obeys the following table... + * + * codebook | ms_used | multiplier + * -------------------------------------- + * INTENSITY_HCB | TRUE | -1 + * INTENSITY_HCB | FALSE | +1 + * INTENSITY_HCB2 | TRUE | +1 + * INTENSITY_HCB2 | FALSE | -1 + * + * In binary, the above table is represented as... + * + * codebook | ms_used | multiplier + * -------------------------------------- + * 1111b | 1 | -1 + * 1111b | 0 | +1 + * 1110b | 1 | +1 + * 1110b | 0 | -1 + * + */ + + /* + * Deriving the correct value for "multiplier" is illustrated + * below for all 4 possible combinations of codebook and ms_used + */ + + /* + * 1111b AND 0x1 = 1b + * 1111b AND 0x1 = 1b + * 1110b AND 0x1 = 0b + * 1110b AND 0x1 = 0b + */ + multiplier = (codebook & 0x1); + + /* + * 1b XOR 1 = 0b + * 1b XOR 0 = 1b + * 0b XOR 1 = 1b + * 0b XOR 0 = 0b + */ + multiplier ^= ms_used; + + /* + * 0b << 1 = 0 + * 1b << 1 = 2 + * 1b << 1 = 2 + * 0b << 1 = 0 + */ + multiplier <<= 1; + + /* + * 0 - 1 = -1 + * 2 - 1 = +1 + * 2 - 1 = +1 + * 0 - 1 = -1 + */ + multiplier--; + + multiplier *= intensity_factor[scalefactor & 0x3]; + + scf_div_4 = (scalefactor >> 2); + + /* + * Step through all the windows in this group, replacing this + * band in each window's spectrum with + * left-channel correlated data + */ + + nextWinPtrUpdate = (coef_per_win - band_length); + + for (Int win_indx = wins_in_group; win_indx > 0; win_indx--) + { + + /* + * Calculate q_formatRight + * + * q_formatLeft must be included, since the values + * on the right-channel are derived from the values + * on the left-channel. + * + * scalefactor/4 is included, since the intensity + * formula is RightCh = LeftCh*0.5^(scalefactor/4) + * + * powers of 0.5 increase the q_format by 1. + * (Another way to multiply something by 0.5^(x) + * is to increase its q-format by x.) + * + * Finally the q-format must be decreased by 1. + * The reason for this is because the table is stored + * in q-15 format, but we are shifting by 16 to do + * a 16 x 16 multiply. + */ + + *(pQformatRight) = scf_div_4 + *(pQformatLeft); + + /* + * reconstruct right intensity values + * + * to make things faster, this for loop + * can be partially unrolled, since band_length is a multiple + * of four. + */ + + + if (multiplier == 32767) + { + Int32 tempInt2 = *(pCoefLeft++); + Int32 tempInt22 = *(pCoefLeft++); + + for (Int tempInt = band_length >> 1; tempInt > 0; tempInt--) + { + *(pCoefRight++) = tempInt2; + *(pCoefRight++) = tempInt22; + tempInt2 = *(pCoefLeft++); + tempInt22 = *(pCoefLeft++); + } + + } + else + { + + Int32 tempInt2 = *(pCoefLeft++); + Int32 tempInt22 = *(pCoefLeft++); + for (Int tempInt = band_length >> 1; tempInt > 0; tempInt--) + { + *(pCoefRight++) = fxp_mul32_by_16(tempInt2, multiplier) << 1; + *(pCoefRight++) = fxp_mul32_by_16(tempInt22, multiplier) << 1; + tempInt2 = *(pCoefLeft++); + tempInt22 = *(pCoefLeft++); + } + } + + /* + * Set pCoefRight and pCoefLeft to the beginning of + * this sfb in the next window in the group. + */ + + pCoefRight += nextWinPtrUpdate; + pCoefLeft += (nextWinPtrUpdate - 2); + + /* + * Update pQformatRight and pQformatLeft to this sfb in + * in the next window in the group. + */ + + pQformatRight += sfb_per_win; + pQformatLeft += sfb_per_win; + + } /* for (win_indx) */ + + +} /* void intensity_right */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/intensity_right.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/intensity_right.h new file mode 100644 index 0000000..0b34726 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/intensity_right.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: intensity_right.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Contains the function definitions for intensity_right +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef INTENSITY_RIGHT_H +#define INTENSITY_RIGHT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void intensity_right( + const Int scalefactor, + const Int coef_per_win, + const Int sfb_per_win, + const Int wins_in_group, + const Int band_length, + const Int codebook, + const Bool ms_used, + const Int q_formatLeft[], + Int q_formatRight[], + const Int32 coefLeft[], + Int32 coefRight[]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.cpp new file mode 100644 index 0000000..7446907 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.cpp @@ -0,0 +1,363 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: inv_long_complex_rot.cpp + Funtions: inv_long_complex_rot + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Data_in = Input vector (sized for long windows + TWICE_INV_LONG_CX_ROT_LENGTH), with time domain samples + type Int32 * + + Data_out = Output vector with a post-rotation by exp(j(2pi/N)(k+1/8)), + (sized for long windows TWICE_INV_LONG_CX_ROT_LENGTH) + type Int32 * + + max = Input, carries the maximum value of the input vector + "Data_in" + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exp = shift factor to reflect signal scaling + + Pointers and Buffers Modified: + Results are return in "Data_out" + + Local Stores Modified: + None + + Global Stores Modified: + None +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + inv_long_complex_rot() performs the complex rotation for the inverse MDCT + for the case of long windows. It also performs digit reverse ordering of + the first and second halves of the input vector "Data_in", as well as + reordering of the two half vectors (following radix-2 decomposition) + Word normalization is also done to ensure 16 by 16 bit multiplications. + +------------------------------------------------------------------------------ + REQUIREMENTS + + inv_long_complex_rot() should execute a post-rotation by + exp(-j(2pi/N)(k+1/8)), digit reverse ordering and word normalization + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "digit_reversal_tables.h" +#include "inv_long_complex_rot.h" +#include "imdct_fxp.h" +#include "inv_long_complex_rot.h" +#include "pv_normalize.h" + +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + + +Int inv_long_complex_rot( + Int32 *Data, + Int32 max) +{ + Int i; + Int16 I; + const Int32 *p_rotate; + Int32 temp_re; + Int32 temp_im; + + Int32 exp_jw; + Int32 *pData_in_1; + Int32 *pData_in_2; + Int exp; + Int32 *pData_in_ref1; + Int32 *pData_in_ref2; + + + Int16 temp_re_0; + Int16 temp_im_0; + Int16 temp_re_1; + Int16 temp_im_1; + Int16 *p_Data_Int_precision; + Int n = 2048; + Int n_2 = n >> 1; + Int n_4 = n >> 2; + Int n_3_4 = n_2 + n_4; + + Int16 *px_1; + Int16 *px_2; + Int16 *px_3; + Int16 *px_4; + + Int16 J; + const Int32 *p_rotate2; + + + + + p_rotate = &exp_rotation_N_2048[255]; + p_rotate2 = &exp_rotation_N_2048[256]; + + pData_in_ref1 = Data; + pData_in_ref2 = &Data[TWICE_INV_LONG_CX_ROT_LENGTH]; + + + /* + * Apply A/2^(diff) + B + */ + + p_Data_Int_precision = (Int16 *)Data; + + + + /* + * px2--> <--px1 px4--> <--px3 + * + * | | | + * |+++++++++++++|+++++++++++++|+++++++++++++|+++++++++++++| + * | | | | + * n/4 n/2 3n/4 + */ + + I = 255; + J = 256; + + pData_in_1 = pData_in_ref2 + I; + + px_1 = (Int16 *)pData_in_1; + px_1++; + + pData_in_2 = pData_in_ref2 + J; + + px_4 = (Int16 *)pData_in_2; + + exp = 16 - pv_normalize(max) - 1; + + for (i = INV_LONG_CX_ROT_LENGTH >> 1; i != 0; i--) + { + + pData_in_2 = pData_in_ref1 + J; + + temp_im = *(pData_in_2++); + temp_re = *(pData_in_2); + + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + exp_jw = *p_rotate2++; + + /* + * Post-rotation + */ + + + + temp_re_0 = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp); + temp_im_0 = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp); + + + pData_in_1 = pData_in_ref2 + I; + + /* + * Use auxiliary variables to avoid double accesses to memory. + * Data in is scaled to use only lower 16 bits. + */ + + temp_re = *(pData_in_1--); + temp_im = *(pData_in_1); + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + exp_jw = *p_rotate--; + + + /* + * Post-rotation + */ + + temp_re_1 = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp); + temp_im_1 = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp); + + + /* + * Repeat procedure for odd index at the output + */ + + pData_in_2 = pData_in_ref2 + J; + J += 2; + + temp_im = *(pData_in_2++); + temp_re = *(pData_in_2); + + + *(px_1--) = temp_re_0; + *(px_1--) = temp_im_1; + *(px_4++) = temp_im_0; + *(px_4++) = temp_re_1; + + + exp_jw = *p_rotate2++; + + + *(px_1--) = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp); + *(px_4++) = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp); + + + + /* + * Repeat procedure for odd index at the output + */ + + pData_in_1 = pData_in_ref1 + I; + I -= 2; + + temp_re = *(pData_in_1--); + temp_im = *(pData_in_1); + + + exp_jw = *p_rotate--; + + + *(px_4++) = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp); + *(px_1--) = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp); + + } + + /* + * <--px1 px4--> + * + * | | | + * |-------------|-------------|/////////////|\\\\\\\\\\\\\| + * | | | | + * n/4 n/2 3n/4 + */ + + + px_1 = p_Data_Int_precision + n_2 - 1; + px_2 = p_Data_Int_precision; + + px_4 = p_Data_Int_precision + n_3_4 - 1; + + for (i = 0; i> 1; i++) + { + + Int16 temp_re_0 = *(px_4--); + Int16 temp_im_1 = *(px_4--); + Int16 temp_re_2 = *(px_4--); + Int16 temp_im_3 = *(px_4--); + *(px_1--) = temp_re_0; + *(px_1--) = temp_im_1; + *(px_1--) = temp_re_2; + *(px_1--) = temp_im_3; + + *(px_2++) = (-temp_re_0); + *(px_2++) = (-temp_im_1); + *(px_2++) = (-temp_re_2); + *(px_2++) = (-temp_im_3); + + } + + + px_4 = p_Data_Int_precision + n_2; + + + pv_memcpy(px_4, pData_in_ref2 + 256, TWICE_INV_LONG_CX_ROT_LENGTH*sizeof(*px_4)); + + + + /* + * px2--> <--px1 px4--> <--px3 + * + * | | | + * |+++++++++++++|+++++++++++++|+++++++++++++|+++++++++++++| + * | | | | + * n/4 n/2 3n/4 + */ + px_3 = p_Data_Int_precision + n - 1; + + + for (i = 0; i> 1; i++) + { + + Int16 temp_im_0 = *(px_4++); + Int16 temp_re_1 = *(px_4++); + Int16 temp_im_2 = *(px_4++); + Int16 temp_re_3 = *(px_4++); + *(px_3--) = temp_im_0; + *(px_3--) = temp_re_1; + *(px_3--) = temp_im_2; + *(px_3--) = temp_re_3; + + } + + + return (exp + 1); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.h new file mode 100644 index 0000000..6981e10 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: inv_long_complex_rot.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function inv_long_complex_rot() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef INV_LONG_COMPLEX_ROT_H +#define INV_LONG_COMPLEX_ROT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define INV_LONG_CX_ROT_LENGTH 256 +#define TWICE_INV_LONG_CX_ROT_LENGTH (INV_LONG_CX_ROT_LENGTH<<1) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int inv_long_complex_rot( + Int32 *Data, + Int32 max); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* INV_LONG_COMPLEX_ROT_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.cpp new file mode 100644 index 0000000..302ef17 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.cpp @@ -0,0 +1,266 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: inv_short_complex_rot.cpp + Funtions: inv_short_complex_rot + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Data_in = Input vector (sized for short windows + 2*INV_SHORT_CX_ROT_LENGTH elements), with time domain samples + type Int32 * + + Data_out = Output vector with a post-rotation by exp(j(2pi/N)(k+1/8)), + (sized for short windows 2*INV_SHORT_CX_ROT_LENGTH) + type Int32 * + + max = Input, carries the maximum value of the input vector + "Data_in" + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exp = shift factor to reflect signal scaling + + Pointers and Buffers Modified: + Results are return in "Data_out" + + Local Stores Modified: + None + + Global Stores Modified: + None +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + inv_short_complex_rot() performs the complex rotation for the inverse MDCT + for the case of short windows. It performs digit reverse ordering as well + word normalization to ensure 16 by 16 bit multiplications. + +------------------------------------------------------------------------------ + REQUIREMENTS + + inv_short_complex_rot() should execute a post-rotation by + exp( j(2pi/N)(k+1/8)), digit reverse ordering and word normalization + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "digit_reversal_tables.h" +#include "imdct_fxp.h" +#include "inv_short_complex_rot.h" +#include "pv_normalize.h" +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +Int inv_short_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max) + +{ + Int i; + Int16 I; + const Int16 *pTable; + const Int32 *p_rotate; + + Int32 *pData_in_1; + Int exp; + Int32 temp_re; + Int32 temp_im; + + Int32 exp_jw; + Int16 *pData_re; + Int16 *pData_im; + Int32 *pData_in_ref; + + Int16 temp_re_0; + Int16 temp_im_0; + Int16 temp_re_1; + Int16 temp_im_1; + Int16 *p_data_1; + Int16 *p_data_2; + Int16 *p_Data_Int_precision; + Int16 *p_Data_Int_precision_1; + Int16 *p_Data_Int_precision_2; + + Int n = 256; + Int n_2 = n >> 1; + Int n_4 = n >> 2; + Int n_8 = n >> 3; + Int n_3_4 = n_2 + n_4; + + + p_data_1 = (Int16 *)Data_out; + p_data_1 += n; + pData_re = p_data_1; + pData_im = p_data_1 + n_4; + + + p_rotate = exp_rotation_N_256; + pTable = digit_reverse_64; + + pData_in_ref = Data_in; + + exp = 16 - pv_normalize(max); + + + if (exp < 0) + { + exp = 0; + } + + exp -= 1; + + for (i = INV_SHORT_CX_ROT_LENGTH; i != 0; i--) + { + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + /* + * Perform digit reversal by accessing index I from table + */ + + I = *pTable++; + pData_in_1 = pData_in_ref + I; + /* + * Use auxiliary variables to avoid double accesses to memory. + * Data in is scaled to use only lower 16 bits. + */ + + temp_im = *(pData_in_1++); + temp_re = *(pData_in_1); + + exp_jw = *p_rotate++; + + /* + * Post-rotation + */ + + *(pData_re++) = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp); + *(pData_im++) = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp); + } + + + p_data_2 = pData_im - 1; + + + p_Data_Int_precision = (Int16 *)Data_out; + p_Data_Int_precision_1 = p_Data_Int_precision + n_3_4 - 1; + p_Data_Int_precision_2 = p_Data_Int_precision + n_3_4; + + for (i = n_8 >> 1; i != 0; i--) + { + temp_re_0 = (*(p_data_1++)); + temp_re_1 = (*(p_data_1++)); + temp_im_0 = (*(p_data_2--)); + temp_im_1 = (*(p_data_2--)); + + *(p_Data_Int_precision_1--) = temp_re_0; + *(p_Data_Int_precision_1--) = temp_im_0; + *(p_Data_Int_precision_1--) = temp_re_1; + *(p_Data_Int_precision_1--) = temp_im_1; + + *(p_Data_Int_precision_2++) = temp_re_0; + *(p_Data_Int_precision_2++) = temp_im_0; + *(p_Data_Int_precision_2++) = temp_re_1; + *(p_Data_Int_precision_2++) = temp_im_1; + + } + + + /* + * loop is split to avoid conditional testing inside loop + */ + + p_Data_Int_precision_2 = p_Data_Int_precision; + + for (i = n_8 >> 1; i != 0; i--) + { + + temp_re_0 = (*(p_data_1++)); + temp_re_1 = (*(p_data_1++)); + temp_im_0 = (*(p_data_2--)); + temp_im_1 = (*(p_data_2--)); + + *(p_Data_Int_precision_1--) = temp_re_0; + *(p_Data_Int_precision_1--) = temp_im_0; + *(p_Data_Int_precision_1--) = temp_re_1; + *(p_Data_Int_precision_1--) = temp_im_1; + + *(p_Data_Int_precision_2++) = (Int16)(-temp_re_0); + *(p_Data_Int_precision_2++) = (Int16)(-temp_im_0); + *(p_Data_Int_precision_2++) = (Int16)(-temp_re_1); + *(p_Data_Int_precision_2++) = (Int16)(-temp_im_1); + + } + + return (exp + 1); +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.h new file mode 100644 index 0000000..46f7f64 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: inv_short_complex_rot.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions inv_short_complex_rot() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef INV_SHORT_COMPLEX_ROT_H +#define INV_SHORT_COMPLEX_ROT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define INV_SHORT_CX_ROT_LENGTH 64 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int inv_short_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* INV_SHORT_COMPLEX_ROT_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/iquant_table.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/iquant_table.cpp new file mode 100644 index 0000000..2751558 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/iquant_table.cpp @@ -0,0 +1,1122 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: iquant_table.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + None, just contains tables. +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Holds a table used for esc_iquant, containing the values of x^1/3 in + Q format. +------------------------------------------------------------------------------ + REQUIREMENTS + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Section 10.3, "Decoding process", page 43. + + +------------------------------------------------------------------------------ + PSEUDO-CODE + None. + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "iquant_table.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/* + This table contains the value of x ^ (1/3) where x is in the range of + [0..1024], in Q27 format. + Note that the length of the table is 1025, and not 1024 - this is because + the function esc_iquant may need to do an interpolation for numbers near + 8191, which in that case it needs to get 8192 ^(1/3). + */ +const UInt32 inverseQuantTable[] = +{ + 0x00000000, /* 0 */ + 0x08000000, /* 1 */ + 0x0a14517d, /* 2 */ + 0x0b89ba25, /* 3 */ + 0x0cb2ff53, /* 4 */ + 0x0dae07de, /* 5 */ + 0x0e897685, /* 6 */ + 0x0f4daedd, /* 7 */ + 0x10000000, /* 8 */ + 0x10a402fd, /* 9 */ + 0x113c4841, /* 10 */ + 0x11cab613, /* 11 */ + 0x1250bfe2, /* 12 */ + 0x12cf8890, /* 13 */ + 0x1347f8ab, /* 14 */ + 0x13bacd65, /* 15 */ + 0x1428a2fa, /* 16 */ + 0x1491fc15, /* 17 */ + 0x14f74744, /* 18 */ + 0x1558e2f7, /* 19 */ + 0x15b72095, /* 20 */ + 0x161246d7, /* 21 */ + 0x166a9399, /* 22 */ + 0x16c03d55, /* 23 */ + 0x17137449, /* 24 */ + 0x17646369, /* 25 */ + 0x17b33124, /* 26 */ + 0x18000000, /* 27 */ + 0x184aef29, /* 28 */ + 0x18941ad8, /* 29 */ + 0x18db9cb7, /* 30 */ + 0x19218c2e, /* 31 */ + 0x1965fea5, /* 32 */ + 0x19a907c2, /* 33 */ + 0x19eab998, /* 34 */ + 0x1a2b24d0, /* 35 */ + 0x1a6a58d5, /* 36 */ + 0x1aa863ee, /* 37 */ + 0x1ae5535d, /* 38 */ + 0x1b213377, /* 39 */ + 0x1b5c0fbd, /* 40 */ + 0x1b95f2ec, /* 41 */ + 0x1bcee70f, /* 42 */ + 0x1c06f590, /* 43 */ + 0x1c3e2745, /* 44 */ + 0x1c74847a, /* 45 */ + 0x1caa1501, /* 46 */ + 0x1cdee035, /* 47 */ + 0x1d12ed0b, /* 48 */ + 0x1d464212, /* 49 */ + 0x1d78e582, /* 50 */ + 0x1daadd3a, /* 51 */ + 0x1ddc2ecf, /* 52 */ + 0x1e0cdf8c, /* 53 */ + 0x1e3cf476, /* 54 */ + 0x1e6c7257, /* 55 */ + 0x1e9b5dba, /* 56 */ + 0x1ec9baf6, /* 57 */ + 0x1ef78e2c, /* 58 */ + 0x1f24db4e, /* 59 */ + 0x1f51a620, /* 60 */ + 0x1f7df23c, /* 61 */ + 0x1fa9c314, /* 62 */ + 0x1fd51bf2, /* 63 */ + 0x20000000, /* 64 */ + 0x202a7244, /* 65 */ + 0x205475a6, /* 66 */ + 0x207e0cee, /* 67 */ + 0x20a73aca, /* 68 */ + 0x20d001cc, /* 69 */ + 0x20f8646d, /* 70 */ + 0x2120650e, /* 71 */ + 0x214805fa, /* 72 */ + 0x216f4963, /* 73 */ + 0x2196316c, /* 74 */ + 0x21bcc020, /* 75 */ + 0x21e2f77a, /* 76 */ + 0x2208d961, /* 77 */ + 0x222e67ad, /* 78 */ + 0x2253a425, /* 79 */ + 0x22789082, /* 80 */ + 0x229d2e6e, /* 81 */ + 0x22c17f82, /* 82 */ + 0x22e5854f, /* 83 */ + 0x23094155, /* 84 */ + 0x232cb509, /* 85 */ + 0x234fe1d5, /* 86 */ + 0x2372c918, /* 87 */ + 0x23956c26, /* 88 */ + 0x23b7cc47, /* 89 */ + 0x23d9eabb, /* 90 */ + 0x23fbc8b9, /* 91 */ + 0x241d676e, /* 92 */ + 0x243ec7ff, /* 93 */ + 0x245feb86, /* 94 */ + 0x2480d319, /* 95 */ + 0x24a17fc3, /* 96 */ + 0x24c1f28b, /* 97 */ + 0x24e22c6c, /* 98 */ + 0x25022e5f, /* 99 */ + 0x2521f954, /* 100 */ + 0x25418e33, /* 101 */ + 0x2560ede2, /* 102 */ + 0x2580193e, /* 103 */ + 0x259f111f, /* 104 */ + 0x25bdd657, /* 105 */ + 0x25dc69b4, /* 106 */ + 0x25facbfe, /* 107 */ + 0x2618fdf8, /* 108 */ + 0x26370060, /* 109 */ + 0x2654d3ef, /* 110 */ + 0x2672795c, /* 111 */ + 0x268ff156, /* 112 */ + 0x26ad3c8a, /* 113 */ + 0x26ca5ba2, /* 114 */ + 0x26e74f41, /* 115 */ + 0x27041808, /* 116 */ + 0x2720b695, /* 117 */ + 0x273d2b81, /* 118 */ + 0x27597762, /* 119 */ + 0x27759acb, /* 120 */ + 0x2791964b, /* 121 */ + 0x27ad6a6f, /* 122 */ + 0x27c917c0, /* 123 */ + 0x27e49ec5, /* 124 */ + 0x28000000, /* 125 */ + 0x281b3bf3, /* 126 */ + 0x2836531b, /* 127 */ + 0x285145f3, /* 128 */ + 0x286c14f5, /* 129 */ + 0x2886c096, /* 130 */ + 0x28a1494b, /* 131 */ + 0x28bbaf85, /* 132 */ + 0x28d5f3b3, /* 133 */ + 0x28f01641, /* 134 */ + 0x290a179b, /* 135 */ + 0x2923f82a, /* 136 */ + 0x293db854, /* 137 */ + 0x2957587e, /* 138 */ + 0x2970d90a, /* 139 */ + 0x298a3a59, /* 140 */ + 0x29a37cca, /* 141 */ + 0x29bca0bb, /* 142 */ + 0x29d5a687, /* 143 */ + 0x29ee8e87, /* 144 */ + 0x2a075914, /* 145 */ + 0x2a200684, /* 146 */ + 0x2a38972c, /* 147 */ + 0x2a510b5f, /* 148 */ + 0x2a696370, /* 149 */ + 0x2a819fae, /* 150 */ + 0x2a99c069, /* 151 */ + 0x2ab1c5ed, /* 152 */ + 0x2ac9b088, /* 153 */ + 0x2ae18085, /* 154 */ + 0x2af9362c, /* 155 */ + 0x2b10d1c6, /* 156 */ + 0x2b28539b, /* 157 */ + 0x2b3fbbef, /* 158 */ + 0x2b570b09, /* 159 */ + 0x2b6e412b, /* 160 */ + 0x2b855e97, /* 161 */ + 0x2b9c6390, /* 162 */ + 0x2bb35056, /* 163 */ + 0x2bca2527, /* 164 */ + 0x2be0e242, /* 165 */ + 0x2bf787e4, /* 166 */ + 0x2c0e1649, /* 167 */ + 0x2c248dad, /* 168 */ + 0x2c3aee4a, /* 169 */ + 0x2c513859, /* 170 */ + 0x2c676c13, /* 171 */ + 0x2c7d89af, /* 172 */ + 0x2c939164, /* 173 */ + 0x2ca98368, /* 174 */ + 0x2cbf5ff1, /* 175 */ + 0x2cd52731, /* 176 */ + 0x2cead95e, /* 177 */ + 0x2d0076a9, /* 178 */ + 0x2d15ff45, /* 179 */ + 0x2d2b7363, /* 180 */ + 0x2d40d332, /* 181 */ + 0x2d561ee4, /* 182 */ + 0x2d6b56a7, /* 183 */ + 0x2d807aaa, /* 184 */ + 0x2d958b19, /* 185 */ + 0x2daa8823, /* 186 */ + 0x2dbf71f4, /* 187 */ + 0x2dd448b7, /* 188 */ + 0x2de90c98, /* 189 */ + 0x2dfdbdc0, /* 190 */ + 0x2e125c5c, /* 191 */ + 0x2e26e892, /* 192 */ + 0x2e3b628d, /* 193 */ + 0x2e4fca75, /* 194 */ + 0x2e642070, /* 195 */ + 0x2e7864a8, /* 196 */ + 0x2e8c9741, /* 197 */ + 0x2ea0b862, /* 198 */ + 0x2eb4c831, /* 199 */ + 0x2ec8c6d3, /* 200 */ + 0x2edcb46c, /* 201 */ + 0x2ef09121, /* 202 */ + 0x2f045d14, /* 203 */ + 0x2f18186a, /* 204 */ + 0x2f2bc345, /* 205 */ + 0x2f3f5dc7, /* 206 */ + 0x2f52e812, /* 207 */ + 0x2f666247, /* 208 */ + 0x2f79cc88, /* 209 */ + 0x2f8d26f4, /* 210 */ + 0x2fa071ac, /* 211 */ + 0x2fb3acd0, /* 212 */ + 0x2fc6d87f, /* 213 */ + 0x2fd9f4d7, /* 214 */ + 0x2fed01f8, /* 215 */ + 0x30000000, /* 216 */ + 0x3012ef0c, /* 217 */ + 0x3025cf39, /* 218 */ + 0x3038a0a6, /* 219 */ + 0x304b636d, /* 220 */ + 0x305e17ad, /* 221 */ + 0x3070bd81, /* 222 */ + 0x30835504, /* 223 */ + 0x3095de51, /* 224 */ + 0x30a85985, /* 225 */ + 0x30bac6b9, /* 226 */ + 0x30cd2609, /* 227 */ + 0x30df778d, /* 228 */ + 0x30f1bb60, /* 229 */ + 0x3103f19c, /* 230 */ + 0x31161a59, /* 231 */ + 0x312835b0, /* 232 */ + 0x313a43ba, /* 233 */ + 0x314c4490, /* 234 */ + 0x315e3849, /* 235 */ + 0x31701efd, /* 236 */ + 0x3181f8c4, /* 237 */ + 0x3193c5b4, /* 238 */ + 0x31a585e6, /* 239 */ + 0x31b7396f, /* 240 */ + 0x31c8e066, /* 241 */ + 0x31da7ae1, /* 242 */ + 0x31ec08f6, /* 243 */ + 0x31fd8abc, /* 244 */ + 0x320f0047, /* 245 */ + 0x322069ac, /* 246 */ + 0x3231c702, /* 247 */ + 0x3243185c, /* 248 */ + 0x32545dcf, /* 249 */ + 0x32659770, /* 250 */ + 0x3276c552, /* 251 */ + 0x3287e78a, /* 252 */ + 0x3298fe2c, /* 253 */ + 0x32aa094a, /* 254 */ + 0x32bb08f9, /* 255 */ + 0x32cbfd4a, /* 256 */ + 0x32dce652, /* 257 */ + 0x32edc423, /* 258 */ + 0x32fe96d0, /* 259 */ + 0x330f5e6a, /* 260 */ + 0x33201b04, /* 261 */ + 0x3330ccb0, /* 262 */ + 0x33417380, /* 263 */ + 0x33520f85, /* 264 */ + 0x3362a0d0, /* 265 */ + 0x33732774, /* 266 */ + 0x3383a380, /* 267 */ + 0x33941506, /* 268 */ + 0x33a47c17, /* 269 */ + 0x33b4d8c4, /* 270 */ + 0x33c52b1b, /* 271 */ + 0x33d5732f, /* 272 */ + 0x33e5b10f, /* 273 */ + 0x33f5e4ca, /* 274 */ + 0x34060e71, /* 275 */ + 0x34162e14, /* 276 */ + 0x342643c1, /* 277 */ + 0x34364f88, /* 278 */ + 0x34465178, /* 279 */ + 0x345649a1, /* 280 */ + 0x34663810, /* 281 */ + 0x34761cd6, /* 282 */ + 0x3485f800, /* 283 */ + 0x3495c99d, /* 284 */ + 0x34a591bb, /* 285 */ + 0x34b55069, /* 286 */ + 0x34c505b4, /* 287 */ + 0x34d4b1ab, /* 288 */ + 0x34e4545b, /* 289 */ + 0x34f3edd2, /* 290 */ + 0x35037e1d, /* 291 */ + 0x3513054b, /* 292 */ + 0x35228367, /* 293 */ + 0x3531f881, /* 294 */ + 0x354164a3, /* 295 */ + 0x3550c7dc, /* 296 */ + 0x35602239, /* 297 */ + 0x356f73c5, /* 298 */ + 0x357ebc8e, /* 299 */ + 0x358dfca0, /* 300 */ + 0x359d3408, /* 301 */ + 0x35ac62d1, /* 302 */ + 0x35bb8908, /* 303 */ + 0x35caa6b9, /* 304 */ + 0x35d9bbf0, /* 305 */ + 0x35e8c8b9, /* 306 */ + 0x35f7cd20, /* 307 */ + 0x3606c92f, /* 308 */ + 0x3615bcf3, /* 309 */ + 0x3624a878, /* 310 */ + 0x36338bc8, /* 311 */ + 0x364266ee, /* 312 */ + 0x365139f6, /* 313 */ + 0x366004ec, /* 314 */ + 0x366ec7d9, /* 315 */ + 0x367d82c9, /* 316 */ + 0x368c35c6, /* 317 */ + 0x369ae0dc, /* 318 */ + 0x36a98414, /* 319 */ + 0x36b81f7a, /* 320 */ + 0x36c6b317, /* 321 */ + 0x36d53ef7, /* 322 */ + 0x36e3c323, /* 323 */ + 0x36f23fa5, /* 324 */ + 0x3700b488, /* 325 */ + 0x370f21d5, /* 326 */ + 0x371d8797, /* 327 */ + 0x372be5d7, /* 328 */ + 0x373a3ca0, /* 329 */ + 0x37488bf9, /* 330 */ + 0x3756d3ef, /* 331 */ + 0x37651489, /* 332 */ + 0x37734dd1, /* 333 */ + 0x37817fd1, /* 334 */ + 0x378faa92, /* 335 */ + 0x379dce1d, /* 336 */ + 0x37abea7c, /* 337 */ + 0x37b9ffb7, /* 338 */ + 0x37c80dd7, /* 339 */ + 0x37d614e6, /* 340 */ + 0x37e414ec, /* 341 */ + 0x37f20df1, /* 342 */ + 0x38000000, /* 343 */ + 0x380deb20, /* 344 */ + 0x381bcf5a, /* 345 */ + 0x3829acb6, /* 346 */ + 0x3837833d, /* 347 */ + 0x384552f8, /* 348 */ + 0x38531bee, /* 349 */ + 0x3860de28, /* 350 */ + 0x386e99af, /* 351 */ + 0x387c4e89, /* 352 */ + 0x3889fcc0, /* 353 */ + 0x3897a45b, /* 354 */ + 0x38a54563, /* 355 */ + 0x38b2dfdf, /* 356 */ + 0x38c073d7, /* 357 */ + 0x38ce0152, /* 358 */ + 0x38db885a, /* 359 */ + 0x38e908f4, /* 360 */ + 0x38f68329, /* 361 */ + 0x3903f701, /* 362 */ + 0x39116483, /* 363 */ + 0x391ecbb6, /* 364 */ + 0x392c2ca1, /* 365 */ + 0x3939874d, /* 366 */ + 0x3946dbc0, /* 367 */ + 0x39542a01, /* 368 */ + 0x39617218, /* 369 */ + 0x396eb40c, /* 370 */ + 0x397befe4, /* 371 */ + 0x398925a7, /* 372 */ + 0x3996555c, /* 373 */ + 0x39a37f09, /* 374 */ + 0x39b0a2b7, /* 375 */ + 0x39bdc06a, /* 376 */ + 0x39cad82b, /* 377 */ + 0x39d7ea01, /* 378 */ + 0x39e4f5f0, /* 379 */ + 0x39f1fc01, /* 380 */ + 0x39fefc3a, /* 381 */ + 0x3a0bf6a2, /* 382 */ + 0x3a18eb3e, /* 383 */ + 0x3a25da16, /* 384 */ + 0x3a32c32f, /* 385 */ + 0x3a3fa691, /* 386 */ + 0x3a4c8441, /* 387 */ + 0x3a595c46, /* 388 */ + 0x3a662ea6, /* 389 */ + 0x3a72fb67, /* 390 */ + 0x3a7fc28f, /* 391 */ + 0x3a8c8425, /* 392 */ + 0x3a99402e, /* 393 */ + 0x3aa5f6b1, /* 394 */ + 0x3ab2a7b3, /* 395 */ + 0x3abf533a, /* 396 */ + 0x3acbf94d, /* 397 */ + 0x3ad899f1, /* 398 */ + 0x3ae5352c, /* 399 */ + 0x3af1cb03, /* 400 */ + 0x3afe5b7d, /* 401 */ + 0x3b0ae6a0, /* 402 */ + 0x3b176c70, /* 403 */ + 0x3b23ecf3, /* 404 */ + 0x3b306830, /* 405 */ + 0x3b3cde2c, /* 406 */ + 0x3b494eeb, /* 407 */ + 0x3b55ba74, /* 408 */ + 0x3b6220cc, /* 409 */ + 0x3b6e81f9, /* 410 */ + 0x3b7ade00, /* 411 */ + 0x3b8734e5, /* 412 */ + 0x3b9386b0, /* 413 */ + 0x3b9fd364, /* 414 */ + 0x3bac1b07, /* 415 */ + 0x3bb85d9e, /* 416 */ + 0x3bc49b2f, /* 417 */ + 0x3bd0d3be, /* 418 */ + 0x3bdd0751, /* 419 */ + 0x3be935ed, /* 420 */ + 0x3bf55f97, /* 421 */ + 0x3c018453, /* 422 */ + 0x3c0da427, /* 423 */ + 0x3c19bf17, /* 424 */ + 0x3c25d52a, /* 425 */ + 0x3c31e662, /* 426 */ + 0x3c3df2c6, /* 427 */ + 0x3c49fa5b, /* 428 */ + 0x3c55fd24, /* 429 */ + 0x3c61fb27, /* 430 */ + 0x3c6df468, /* 431 */ + 0x3c79e8ed, /* 432 */ + 0x3c85d8b9, /* 433 */ + 0x3c91c3d2, /* 434 */ + 0x3c9daa3c, /* 435 */ + 0x3ca98bfc, /* 436 */ + 0x3cb56915, /* 437 */ + 0x3cc1418e, /* 438 */ + 0x3ccd156a, /* 439 */ + 0x3cd8e4ae, /* 440 */ + 0x3ce4af5e, /* 441 */ + 0x3cf0757f, /* 442 */ + 0x3cfc3714, /* 443 */ + 0x3d07f423, /* 444 */ + 0x3d13acb0, /* 445 */ + 0x3d1f60bf, /* 446 */ + 0x3d2b1055, /* 447 */ + 0x3d36bb75, /* 448 */ + 0x3d426224, /* 449 */ + 0x3d4e0466, /* 450 */ + 0x3d59a23f, /* 451 */ + 0x3d653bb4, /* 452 */ + 0x3d70d0c8, /* 453 */ + 0x3d7c6180, /* 454 */ + 0x3d87ede0, /* 455 */ + 0x3d9375ec, /* 456 */ + 0x3d9ef9a8, /* 457 */ + 0x3daa7918, /* 458 */ + 0x3db5f43f, /* 459 */ + 0x3dc16b23, /* 460 */ + 0x3dccddc7, /* 461 */ + 0x3dd84c2e, /* 462 */ + 0x3de3b65d, /* 463 */ + 0x3def1c58, /* 464 */ + 0x3dfa7e22, /* 465 */ + 0x3e05dbc0, /* 466 */ + 0x3e113535, /* 467 */ + 0x3e1c8a85, /* 468 */ + 0x3e27dbb3, /* 469 */ + 0x3e3328c4, /* 470 */ + 0x3e3e71bb, /* 471 */ + 0x3e49b69c, /* 472 */ + 0x3e54f76b, /* 473 */ + 0x3e60342b, /* 474 */ + 0x3e6b6ce0, /* 475 */ + 0x3e76a18d, /* 476 */ + 0x3e81d237, /* 477 */ + 0x3e8cfee0, /* 478 */ + 0x3e98278d, /* 479 */ + 0x3ea34c40, /* 480 */ + 0x3eae6cfe, /* 481 */ + 0x3eb989ca, /* 482 */ + 0x3ec4a2a8, /* 483 */ + 0x3ecfb79a, /* 484 */ + 0x3edac8a5, /* 485 */ + 0x3ee5d5cb, /* 486 */ + 0x3ef0df10, /* 487 */ + 0x3efbe478, /* 488 */ + 0x3f06e606, /* 489 */ + 0x3f11e3be, /* 490 */ + 0x3f1cdda2, /* 491 */ + 0x3f27d3b6, /* 492 */ + 0x3f32c5fd, /* 493 */ + 0x3f3db47b, /* 494 */ + 0x3f489f32, /* 495 */ + 0x3f538627, /* 496 */ + 0x3f5e695c, /* 497 */ + 0x3f6948d5, /* 498 */ + 0x3f742494, /* 499 */ + 0x3f7efc9d, /* 500 */ + 0x3f89d0f3, /* 501 */ + 0x3f94a19a, /* 502 */ + 0x3f9f6e94, /* 503 */ + 0x3faa37e4, /* 504 */ + 0x3fb4fd8e, /* 505 */ + 0x3fbfbf94, /* 506 */ + 0x3fca7dfb, /* 507 */ + 0x3fd538c4, /* 508 */ + 0x3fdfeff3, /* 509 */ + 0x3feaa38a, /* 510 */ + 0x3ff5538e, /* 511 */ + 0x40000000, /* 512 */ + 0x400aa8e4, /* 513 */ + 0x40154e3d, /* 514 */ + 0x401ff00d, /* 515 */ + 0x402a8e58, /* 516 */ + 0x40352921, /* 517 */ + 0x403fc06a, /* 518 */ + 0x404a5436, /* 519 */ + 0x4054e488, /* 520 */ + 0x405f7164, /* 521 */ + 0x4069facb, /* 522 */ + 0x407480c1, /* 523 */ + 0x407f0348, /* 524 */ + 0x40898264, /* 525 */ + 0x4093fe16, /* 526 */ + 0x409e7663, /* 527 */ + 0x40a8eb4c, /* 528 */ + 0x40b35cd4, /* 529 */ + 0x40bdcafe, /* 530 */ + 0x40c835cd, /* 531 */ + 0x40d29d43, /* 532 */ + 0x40dd0164, /* 533 */ + 0x40e76231, /* 534 */ + 0x40f1bfae, /* 535 */ + 0x40fc19dc, /* 536 */ + 0x410670c0, /* 537 */ + 0x4110c45a, /* 538 */ + 0x411b14af, /* 539 */ + 0x412561c0, /* 540 */ + 0x412fab90, /* 541 */ + 0x4139f222, /* 542 */ + 0x41443578, /* 543 */ + 0x414e7595, /* 544 */ + 0x4158b27a, /* 545 */ + 0x4162ec2c, /* 546 */ + 0x416d22ac, /* 547 */ + 0x417755fd, /* 548 */ + 0x41818621, /* 549 */ + 0x418bb31a, /* 550 */ + 0x4195dcec, /* 551 */ + 0x41a00399, /* 552 */ + 0x41aa2722, /* 553 */ + 0x41b4478b, /* 554 */ + 0x41be64d6, /* 555 */ + 0x41c87f05, /* 556 */ + 0x41d2961a, /* 557 */ + 0x41dcaa19, /* 558 */ + 0x41e6bb03, /* 559 */ + 0x41f0c8db, /* 560 */ + 0x41fad3a3, /* 561 */ + 0x4204db5d, /* 562 */ + 0x420ee00c, /* 563 */ + 0x4218e1b1, /* 564 */ + 0x4222e051, /* 565 */ + 0x422cdbeb, /* 566 */ + 0x4236d484, /* 567 */ + 0x4240ca1d, /* 568 */ + 0x424abcb8, /* 569 */ + 0x4254ac58, /* 570 */ + 0x425e98fe, /* 571 */ + 0x426882ae, /* 572 */ + 0x42726969, /* 573 */ + 0x427c4d31, /* 574 */ + 0x42862e09, /* 575 */ + 0x42900bf3, /* 576 */ + 0x4299e6f1, /* 577 */ + 0x42a3bf05, /* 578 */ + 0x42ad9432, /* 579 */ + 0x42b76678, /* 580 */ + 0x42c135dc, /* 581 */ + 0x42cb025e, /* 582 */ + 0x42d4cc01, /* 583 */ + 0x42de92c7, /* 584 */ + 0x42e856b2, /* 585 */ + 0x42f217c4, /* 586 */ + 0x42fbd5ff, /* 587 */ + 0x43059166, /* 588 */ + 0x430f49f9, /* 589 */ + 0x4318ffbc, /* 590 */ + 0x4322b2b1, /* 591 */ + 0x432c62d8, /* 592 */ + 0x43361036, /* 593 */ + 0x433fbaca, /* 594 */ + 0x43496298, /* 595 */ + 0x435307a2, /* 596 */ + 0x435ca9e8, /* 597 */ + 0x4366496e, /* 598 */ + 0x436fe636, /* 599 */ + 0x43798041, /* 600 */ + 0x43831790, /* 601 */ + 0x438cac28, /* 602 */ + 0x43963e08, /* 603 */ + 0x439fcd33, /* 604 */ + 0x43a959ab, /* 605 */ + 0x43b2e372, /* 606 */ + 0x43bc6a89, /* 607 */ + 0x43c5eef3, /* 608 */ + 0x43cf70b2, /* 609 */ + 0x43d8efc7, /* 610 */ + 0x43e26c34, /* 611 */ + 0x43ebe5fb, /* 612 */ + 0x43f55d1e, /* 613 */ + 0x43fed19f, /* 614 */ + 0x44084380, /* 615 */ + 0x4411b2c1, /* 616 */ + 0x441b1f66, /* 617 */ + 0x44248970, /* 618 */ + 0x442df0e1, /* 619 */ + 0x443755bb, /* 620 */ + 0x4440b7fe, /* 621 */ + 0x444a17ae, /* 622 */ + 0x445374cc, /* 623 */ + 0x445ccf5a, /* 624 */ + 0x44662758, /* 625 */ + 0x446f7ccb, /* 626 */ + 0x4478cfb2, /* 627 */ + 0x4482200f, /* 628 */ + 0x448b6de5, /* 629 */ + 0x4494b935, /* 630 */ + 0x449e0201, /* 631 */ + 0x44a7484b, /* 632 */ + 0x44b08c13, /* 633 */ + 0x44b9cd5d, /* 634 */ + 0x44c30c29, /* 635 */ + 0x44cc4879, /* 636 */ + 0x44d5824f, /* 637 */ + 0x44deb9ac, /* 638 */ + 0x44e7ee93, /* 639 */ + 0x44f12105, /* 640 */ + 0x44fa5103, /* 641 */ + 0x45037e8f, /* 642 */ + 0x450ca9ab, /* 643 */ + 0x4515d258, /* 644 */ + 0x451ef899, /* 645 */ + 0x45281c6e, /* 646 */ + 0x45313dd8, /* 647 */ + 0x453a5cdb, /* 648 */ + 0x45437977, /* 649 */ + 0x454c93ae, /* 650 */ + 0x4555ab82, /* 651 */ + 0x455ec0f3, /* 652 */ + 0x4567d404, /* 653 */ + 0x4570e4b7, /* 654 */ + 0x4579f30c, /* 655 */ + 0x4582ff05, /* 656 */ + 0x458c08a4, /* 657 */ + 0x45950fea, /* 658 */ + 0x459e14d9, /* 659 */ + 0x45a71773, /* 660 */ + 0x45b017b8, /* 661 */ + 0x45b915aa, /* 662 */ + 0x45c2114c, /* 663 */ + 0x45cb0a9e, /* 664 */ + 0x45d401a1, /* 665 */ + 0x45dcf658, /* 666 */ + 0x45e5e8c4, /* 667 */ + 0x45eed8e6, /* 668 */ + 0x45f7c6c0, /* 669 */ + 0x4600b253, /* 670 */ + 0x46099ba0, /* 671 */ + 0x461282a9, /* 672 */ + 0x461b6770, /* 673 */ + 0x462449f6, /* 674 */ + 0x462d2a3c, /* 675 */ + 0x46360844, /* 676 */ + 0x463ee40f, /* 677 */ + 0x4647bd9f, /* 678 */ + 0x465094f5, /* 679 */ + 0x46596a12, /* 680 */ + 0x46623cf8, /* 681 */ + 0x466b0da8, /* 682 */ + 0x4673dc24, /* 683 */ + 0x467ca86c, /* 684 */ + 0x46857283, /* 685 */ + 0x468e3a69, /* 686 */ + 0x46970021, /* 687 */ + 0x469fc3ab, /* 688 */ + 0x46a88509, /* 689 */ + 0x46b1443b, /* 690 */ + 0x46ba0144, /* 691 */ + 0x46c2bc25, /* 692 */ + 0x46cb74df, /* 693 */ + 0x46d42b74, /* 694 */ + 0x46dcdfe4, /* 695 */ + 0x46e59231, /* 696 */ + 0x46ee425c, /* 697 */ + 0x46f6f068, /* 698 */ + 0x46ff9c54, /* 699 */ + 0x47084622, /* 700 */ + 0x4710edd4, /* 701 */ + 0x4719936b, /* 702 */ + 0x472236e7, /* 703 */ + 0x472ad84b, /* 704 */ + 0x47337798, /* 705 */ + 0x473c14cf, /* 706 */ + 0x4744aff1, /* 707 */ + 0x474d48ff, /* 708 */ + 0x4755dffb, /* 709 */ + 0x475e74e6, /* 710 */ + 0x476707c1, /* 711 */ + 0x476f988e, /* 712 */ + 0x4778274d, /* 713 */ + 0x4780b400, /* 714 */ + 0x47893ea8, /* 715 */ + 0x4791c746, /* 716 */ + 0x479a4ddc, /* 717 */ + 0x47a2d26b, /* 718 */ + 0x47ab54f3, /* 719 */ + 0x47b3d577, /* 720 */ + 0x47bc53f7, /* 721 */ + 0x47c4d074, /* 722 */ + 0x47cd4af0, /* 723 */ + 0x47d5c36c, /* 724 */ + 0x47de39e9, /* 725 */ + 0x47e6ae69, /* 726 */ + 0x47ef20ec, /* 727 */ + 0x47f79173, /* 728 */ + 0x48000000, /* 729 */ + 0x48086c94, /* 730 */ + 0x4810d730, /* 731 */ + 0x48193fd5, /* 732 */ + 0x4821a685, /* 733 */ + 0x482a0b40, /* 734 */ + 0x48326e07, /* 735 */ + 0x483acedd, /* 736 */ + 0x48432dc1, /* 737 */ + 0x484b8ab5, /* 738 */ + 0x4853e5bb, /* 739 */ + 0x485c3ed2, /* 740 */ + 0x486495fd, /* 741 */ + 0x486ceb3c, /* 742 */ + 0x48753e91, /* 743 */ + 0x487d8ffd, /* 744 */ + 0x4885df80, /* 745 */ + 0x488e2d1d, /* 746 */ + 0x489678d3, /* 747 */ + 0x489ec2a4, /* 748 */ + 0x48a70a91, /* 749 */ + 0x48af509b, /* 750 */ + 0x48b794c4, /* 751 */ + 0x48bfd70c, /* 752 */ + 0x48c81774, /* 753 */ + 0x48d055fe, /* 754 */ + 0x48d892aa, /* 755 */ + 0x48e0cd7a, /* 756 */ + 0x48e9066e, /* 757 */ + 0x48f13d88, /* 758 */ + 0x48f972c9, /* 759 */ + 0x4901a632, /* 760 */ + 0x4909d7c3, /* 761 */ + 0x4912077e, /* 762 */ + 0x491a3564, /* 763 */ + 0x49226175, /* 764 */ + 0x492a8bb4, /* 765 */ + 0x4932b420, /* 766 */ + 0x493adabc, /* 767 */ + 0x4942ff87, /* 768 */ + 0x494b2283, /* 769 */ + 0x495343b1, /* 770 */ + 0x495b6312, /* 771 */ + 0x496380a7, /* 772 */ + 0x496b9c71, /* 773 */ + 0x4973b670, /* 774 */ + 0x497bcea7, /* 775 */ + 0x4983e515, /* 776 */ + 0x498bf9bc, /* 777 */ + 0x49940c9e, /* 778 */ + 0x499c1db9, /* 779 */ + 0x49a42d11, /* 780 */ + 0x49ac3aa5, /* 781 */ + 0x49b44677, /* 782 */ + 0x49bc5088, /* 783 */ + 0x49c458d8, /* 784 */ + 0x49cc5f69, /* 785 */ + 0x49d4643c, /* 786 */ + 0x49dc6750, /* 787 */ + 0x49e468a9, /* 788 */ + 0x49ec6845, /* 789 */ + 0x49f46627, /* 790 */ + 0x49fc624f, /* 791 */ + 0x4a045cbe, /* 792 */ + 0x4a0c5575, /* 793 */ + 0x4a144c76, /* 794 */ + 0x4a1c41c0, /* 795 */ + 0x4a243555, /* 796 */ + 0x4a2c2735, /* 797 */ + 0x4a341763, /* 798 */ + 0x4a3c05de, /* 799 */ + 0x4a43f2a7, /* 800 */ + 0x4a4bddc0, /* 801 */ + 0x4a53c729, /* 802 */ + 0x4a5baee3, /* 803 */ + 0x4a6394ef, /* 804 */ + 0x4a6b794f, /* 805 */ + 0x4a735c02, /* 806 */ + 0x4a7b3d09, /* 807 */ + 0x4a831c67, /* 808 */ + 0x4a8afa1b, /* 809 */ + 0x4a92d626, /* 810 */ + 0x4a9ab089, /* 811 */ + 0x4aa28946, /* 812 */ + 0x4aaa605d, /* 813 */ + 0x4ab235ce, /* 814 */ + 0x4aba099b, /* 815 */ + 0x4ac1dbc5, /* 816 */ + 0x4ac9ac4c, /* 817 */ + 0x4ad17b31, /* 818 */ + 0x4ad94876, /* 819 */ + 0x4ae1141a, /* 820 */ + 0x4ae8de1f, /* 821 */ + 0x4af0a686, /* 822 */ + 0x4af86d50, /* 823 */ + 0x4b00327d, /* 824 */ + 0x4b07f60d, /* 825 */ + 0x4b0fb803, /* 826 */ + 0x4b17785f, /* 827 */ + 0x4b1f3722, /* 828 */ + 0x4b26f44b, /* 829 */ + 0x4b2eafde, /* 830 */ + 0x4b3669d9, /* 831 */ + 0x4b3e223e, /* 832 */ + 0x4b45d90e, /* 833 */ + 0x4b4d8e4a, /* 834 */ + 0x4b5541f2, /* 835 */ + 0x4b5cf407, /* 836 */ + 0x4b64a48a, /* 837 */ + 0x4b6c537c, /* 838 */ + 0x4b7400dd, /* 839 */ + 0x4b7bacaf, /* 840 */ + 0x4b8356f2, /* 841 */ + 0x4b8affa7, /* 842 */ + 0x4b92a6ce, /* 843 */ + 0x4b9a4c69, /* 844 */ + 0x4ba1f079, /* 845 */ + 0x4ba992fd, /* 846 */ + 0x4bb133f8, /* 847 */ + 0x4bb8d369, /* 848 */ + 0x4bc07151, /* 849 */ + 0x4bc80db2, /* 850 */ + 0x4bcfa88c, /* 851 */ + 0x4bd741df, /* 852 */ + 0x4bded9ad, /* 853 */ + 0x4be66ff6, /* 854 */ + 0x4bee04bb, /* 855 */ + 0x4bf597fc, /* 856 */ + 0x4bfd29bc, /* 857 */ + 0x4c04b9f9, /* 858 */ + 0x4c0c48b6, /* 859 */ + 0x4c13d5f2, /* 860 */ + 0x4c1b61af, /* 861 */ + 0x4c22ebed, /* 862 */ + 0x4c2a74ad, /* 863 */ + 0x4c31fbf0, /* 864 */ + 0x4c3981b6, /* 865 */ + 0x4c410600, /* 866 */ + 0x4c4888d0, /* 867 */ + 0x4c500a25, /* 868 */ + 0x4c578a00, /* 869 */ + 0x4c5f0862, /* 870 */ + 0x4c66854c, /* 871 */ + 0x4c6e00bf, /* 872 */ + 0x4c757abb, /* 873 */ + 0x4c7cf341, /* 874 */ + 0x4c846a52, /* 875 */ + 0x4c8bdfee, /* 876 */ + 0x4c935416, /* 877 */ + 0x4c9ac6cb, /* 878 */ + 0x4ca2380e, /* 879 */ + 0x4ca9a7de, /* 880 */ + 0x4cb1163e, /* 881 */ + 0x4cb8832d, /* 882 */ + 0x4cbfeead, /* 883 */ + 0x4cc758bd, /* 884 */ + 0x4ccec15f, /* 885 */ + 0x4cd62894, /* 886 */ + 0x4cdd8e5c, /* 887 */ + 0x4ce4f2b7, /* 888 */ + 0x4cec55a7, /* 889 */ + 0x4cf3b72c, /* 890 */ + 0x4cfb1747, /* 891 */ + 0x4d0275f8, /* 892 */ + 0x4d09d340, /* 893 */ + 0x4d112f21, /* 894 */ + 0x4d188999, /* 895 */ + 0x4d1fe2ab, /* 896 */ + 0x4d273a57, /* 897 */ + 0x4d2e909d, /* 898 */ + 0x4d35e57f, /* 899 */ + 0x4d3d38fc, /* 900 */ + 0x4d448b16, /* 901 */ + 0x4d4bdbcd, /* 902 */ + 0x4d532b21, /* 903 */ + 0x4d5a7914, /* 904 */ + 0x4d61c5a7, /* 905 */ + 0x4d6910d9, /* 906 */ + 0x4d705aab, /* 907 */ + 0x4d77a31e, /* 908 */ + 0x4d7eea34, /* 909 */ + 0x4d862feb, /* 910 */ + 0x4d8d7445, /* 911 */ + 0x4d94b743, /* 912 */ + 0x4d9bf8e6, /* 913 */ + 0x4da3392d, /* 914 */ + 0x4daa7819, /* 915 */ + 0x4db1b5ac, /* 916 */ + 0x4db8f1e6, /* 917 */ + 0x4dc02cc7, /* 918 */ + 0x4dc76650, /* 919 */ + 0x4dce9e81, /* 920 */ + 0x4dd5d55c, /* 921 */ + 0x4ddd0ae1, /* 922 */ + 0x4de43f10, /* 923 */ + 0x4deb71eb, /* 924 */ + 0x4df2a371, /* 925 */ + 0x4df9d3a3, /* 926 */ + 0x4e010283, /* 927 */ + 0x4e083010, /* 928 */ + 0x4e0f5c4b, /* 929 */ + 0x4e168735, /* 930 */ + 0x4e1db0cf, /* 931 */ + 0x4e24d918, /* 932 */ + 0x4e2c0012, /* 933 */ + 0x4e3325bd, /* 934 */ + 0x4e3a4a1a, /* 935 */ + 0x4e416d2a, /* 936 */ + 0x4e488eec, /* 937 */ + 0x4e4faf62, /* 938 */ + 0x4e56ce8c, /* 939 */ + 0x4e5dec6b, /* 940 */ + 0x4e6508ff, /* 941 */ + 0x4e6c2449, /* 942 */ + 0x4e733e4a, /* 943 */ + 0x4e7a5702, /* 944 */ + 0x4e816e71, /* 945 */ + 0x4e888498, /* 946 */ + 0x4e8f9979, /* 947 */ + 0x4e96ad13, /* 948 */ + 0x4e9dbf67, /* 949 */ + 0x4ea4d075, /* 950 */ + 0x4eabe03e, /* 951 */ + 0x4eb2eec4, /* 952 */ + 0x4eb9fc05, /* 953 */ + 0x4ec10803, /* 954 */ + 0x4ec812bf, /* 955 */ + 0x4ecf1c39, /* 956 */ + 0x4ed62471, /* 957 */ + 0x4edd2b68, /* 958 */ + 0x4ee4311f, /* 959 */ + 0x4eeb3596, /* 960 */ + 0x4ef238cd, /* 961 */ + 0x4ef93ac6, /* 962 */ + 0x4f003b81, /* 963 */ + 0x4f073afe, /* 964 */ + 0x4f0e393f, /* 965 */ + 0x4f153642, /* 966 */ + 0x4f1c320a, /* 967 */ + 0x4f232c96, /* 968 */ + 0x4f2a25e8, /* 969 */ + 0x4f311dff, /* 970 */ + 0x4f3814dc, /* 971 */ + 0x4f3f0a80, /* 972 */ + 0x4f45feeb, /* 973 */ + 0x4f4cf21f, /* 974 */ + 0x4f53e41a, /* 975 */ + 0x4f5ad4de, /* 976 */ + 0x4f61c46c, /* 977 */ + 0x4f68b2c4, /* 978 */ + 0x4f6f9fe6, /* 979 */ + 0x4f768bd3, /* 980 */ + 0x4f7d768c, /* 981 */ + 0x4f846011, /* 982 */ + 0x4f8b4862, /* 983 */ + 0x4f922f81, /* 984 */ + 0x4f99156d, /* 985 */ + 0x4f9ffa27, /* 986 */ + 0x4fa6ddb0, /* 987 */ + 0x4fadc008, /* 988 */ + 0x4fb4a12f, /* 989 */ + 0x4fbb8127, /* 990 */ + 0x4fc25ff0, /* 991 */ + 0x4fc93d8a, /* 992 */ + 0x4fd019f5, /* 993 */ + 0x4fd6f533, /* 994 */ + 0x4fddcf43, /* 995 */ + 0x4fe4a827, /* 996 */ + 0x4feb7fde, /* 997 */ + 0x4ff2566a, /* 998 */ + 0x4ff92bca, /* 999 */ + 0x50000000, /* 1000 */ + 0x5006d30b, /* 1001 */ + 0x500da4ed, /* 1002 */ + 0x501475a5, /* 1003 */ + 0x501b4535, /* 1004 */ + 0x5022139c, /* 1005 */ + 0x5028e0dc, /* 1006 */ + 0x502facf4, /* 1007 */ + 0x503677e5, /* 1008 */ + 0x503d41b0, /* 1009 */ + 0x50440a55, /* 1010 */ + 0x504ad1d5, /* 1011 */ + 0x50519830, /* 1012 */ + 0x50585d67, /* 1013 */ + 0x505f217a, /* 1014 */ + 0x5065e469, /* 1015 */ + 0x506ca635, /* 1016 */ + 0x507366df, /* 1017 */ + 0x507a2667, /* 1018 */ + 0x5080e4cd, /* 1019 */ + 0x5087a212, /* 1020 */ + 0x508e5e37, /* 1021 */ + 0x5095193c, /* 1022 */ + 0x509bd320, /* 1023 */ + 0x50a28be6, /* 1024 */ +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/iquant_table.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/iquant_table.h new file mode 100644 index 0000000..9f14afb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/iquant_table.h @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: iquant_table.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for iquant_table.c, which contains a table used with + esc_iquant.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef IQUANT_TABLE_H +#define IQUANT_TABLE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const UInt32 inverseQuantTable[]; +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/long_term_prediction.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/long_term_prediction.cpp new file mode 100644 index 0000000..bfd8e06 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/long_term_prediction.cpp @@ -0,0 +1,587 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: long_term_prediction.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + win_seq = type of window sequence (WINDOW_SEQUENCE). + + weight_index = index (Int) of LTP coefficient table for all windows in + current frame. + + delay = buffer (Int) containing delays for each window. + + buffer = history buffer (Int16) containing the reconstructed time domain + signals of previous frames. + + buffer_offset = value (Int) that indicates the location of the first + element in the LTP circular buffer. (Either 0 or 1024) + + time_quant = filterbank buffer (Int32) This buffer is used by the + filterbank, but it's first 1024 elements are equivalent + to the last 1024 elements in the conventionally + implemented LTP buffer. Using this buffer directly avoids + costly duplication of memory. + + predicted_samples = buffer (Int32) with length of 2048 to hold + predicted time domain signals. + + buffer_index = index into buffer where the first sample of data from + the frame (t-2) (two frames ago) resides. (Int) + + frame_length = length of one frame, type of Int. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + Amount of shifting needed to grab the top 16 MSB from teh predicted buffer + + Pointers and Buffers Modified: + predicted_samples contents are the newly calculated predicted time + domain signals + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Long term prediction (LTP) is used to reduce the redundancy of a signal + between successive coding frames. This function performs prediction by + applying 1-tap IIR filtering to calculate the predicted time domain + signals of current frame from previous reconstructed frames stored in + time domain history buffer. + + The equation used for IIR filter is as following. + + y(n) = weight * x(n - delay) + + where y(n) ----- predicted time domain signals + x(n) ----- reconstructed time domain signals + weight ----- LTP coefficient + delay ----- optimal delay from 0 to 2047 + +------------------------------------------------------------------------------ + REQUIREMENTS + + None + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3: Audio + Subpart 4.6.6 Long Term Prediction (LTP) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by Nokia in the course + of development of the MPEG-2 AAC/MPEG-4 Audio standard ISO/IEC13818-7, + 14496-1, 2 and 3. This software module is an implementation of a part + of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the MPEG-2 + aac/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2aac/MPEG-4 + Audio standards free license to this software module or modifications + thereof for use in hardware or software products claiming conformance + to the MPEG-2 aac/MPEG-4 Audio standards. Those intending to use this + software module in hardware or software products are advised that this + use may infringe existing patents. The original developer of this + software module, the subsequent editors and their companies, and ISO/IEC + have no liability for use of this software module or modifications + thereof in an implementation. Copyright is not released for non MPEG-2 + aac/MPEG-4 Audio conforming products. The original developer retains + full right to use the code for the developer's own purpose, assign or + donate the code to a third party and to inhibit third party from using + the code for non MPEG-2 aac/MPEG-4 Audio conforming products. This + copyright notice must be included in all copies or derivative works. + Copyright (c)1997. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pPredicted_samples = &predicted_samples[0]; + + weight = codebook[weight_index]; + + IF (win_seq != EIGHT_SHORT_SEQUENCE) + THEN + + block_length = frame_length << 1; + + lag = delay[0]; + + j = block_length - lag; + + IF (lag < frame_length) + THEN + + num_samples = frame_length + lag; + + ELSE + + num_samples = block_length; + + ENDIF + + pBuffer = &buffer[j]; + + FOR (i = num_samples; i>0; i--) + + *pPredicted_samples = weight * (*pBuffer); + pPredicted_samples = pPredicted_samples + 1; + pBuffer = pBuffer + 1; + + ENDFOR + + FOR (i = block_length - num_samples; i>0; i--) + + *pPredicted_samples = 0; + pPredicted_samples = pPredicted_samples + 1; + + ENDFOR + + ELSE + + FOR (wnd = 0; wnd < short_window_num; wnd++) + + IF (win_prediction_used[wnd] != FALSE) + THEN + + delay[wnd] = delay[0] + ltp_short_lag[wnd]; + + lag = delay[wnd]; + + j = wnd*short_block_length - lag; + + IF (lag < short_frame_length) + THEN + + num_samples = short_frame_length + lag; + + ELSE + + num_samples = short_block_length; + + ENDIF + + pBuffer = &buffer[j]; + + FOR (i = num_samples; i>0; i--) + + *pPredicted_samples = weight * (*pBuffer); + pPredicted_samples = pPredicted_samples + 1; + pBuffer = pBuffer + 1; + + ENDFOR + + FOR (i = short_block_length - num_samples; i>0; i--) + + *pPredicted_samples = 0; + pPredicted_samples = pPredicted_samples + 1; + + ENDFOR + + ELSE + + CALL pv_memset( + pPredicted_samples, + 0, + sizeof(*pPredicted_samples)*short_block_length); + MODIFYING (predicted_samples[]); + + pPredicted_samples = pPredicted_samples + short_block_length; + + ENDIF [ IF (win_prediction_used[wnd] != FALSE) ] + + ENDFOR [ FOR (wnd=0; wnd 0) + { + pBuffer = &(buffer[ltp_buffer_index + buffer_offset]); + + for (k = jump_point; k > 0; k--) + { + /* Q15 = Q15 * Q0 */ + test = (Int32) weight * (*(pBuffer++)); + *(pPredicted_samples++) = test; + max |= (test >> 31) ^ test; + } + + num_samples -= jump_point; + + ltp_buffer_index += jump_point; + } + + /* + * This section of the code handles the t == -1 + * buffer, which corresponds to 1024 <= ltp_buffer_index < 2048 + * + * BUFFER t == -1 + * + * [1024][][][][][][][][][][][...][][][][][][][][][][][][2047] + * + */ + + jump_point = 2 * frame_length - ltp_buffer_index; + + pBuffer = &(buffer[ltp_buffer_index - buffer_offset]); + + if (num_samples < jump_point) + { + jump_point = num_samples; + } + + for (k = jump_point; k > 0; k--) + { + /* Q15 = Q15 * Q0 */ + test = (Int32) weight * (*(pBuffer++)); + *(pPredicted_samples++) = test; + max |= (test >> 31) ^ test; + } + + num_samples -= jump_point; + + ltp_buffer_index += jump_point; + + /* + * This section of the code handles the t == 0 + * buffer, which corresponds to 2048 <= ltp_buffer_index < 3072 + * + * BUFFER t == 0 + * + * [2048][][][][][][][][][][][...][][][][][][][][][][][][3071] + * + */ + for (k = num_samples; k > 0; k--) + { + + datum = *(pTimeQuant++) >> SCALING; + + /* + * Limit the values in the 32-bit filterbank's buffer to + * 16-bit resolution. + * + * Value's greater than 32767 or less than -32768 are saturated + * to 32767 and -32768, respectively. + */ + + test = (Int32)datum * weight; + *(pPredicted_samples++) = test; + max |= (test >> 31) ^ test; + + } + + /* Set any remaining samples in the block to 0. */ + + pv_memset( + pPredicted_samples, + 0, + block_length*sizeof(*pPredicted_samples)); + + } /* if (win_seq != EIGHT_SHORT_SEQUENCE) */ + + + /*****************************************/ + /* LTP decoding process for short window */ + /*****************************************/ + + /* + * For short window LTP, since there is no "ltp_short_lag" + * information being passed, the following code for short + * window LTP will be applied in the future when those + * information are available. + */ + + /* + *---------------------------------------------------------------------------- + * else + * { + * for (wnd = 0; wnd < short_window_num; wnd++) + * { + * if (win_prediction_used[wnd] != FALSE) + * { + * delay[wnd] = delay[0] + ltp_short_lag[wnd]; + * + * lag = delay[wnd]; + * + * j = wnd*short_block_length - lag; + * + * if (lag < short_frame_length) + * { + * num_samples = short_frame_length + lag; + * } + * else + * { + * num_samples = short_block_length; + * } + * + * pBuffer = &buffer[j]; + * + * for(i = num_samples; i>0; i--) + * { + * *(pPredicted_samples++) = weight * (*(pBuffer++)); + * } + * + * for(i = short_block_length - num_samples; i>0; i--) + * { + * *(pPredicted_samples++) = 0; + * } + * } + * else + * { + * pv_memset( + * pPredicted_samples, + * 0, + * sizeof(*pPredicted_samples)*short_block_length); + * + * pPredicted_samples += short_block_length; + * } + * } + * } + *---------------------------------------------------------------------------- + */ + + shift = 16 - pv_normalize(max); + + if (shift < 0) + { + shift = 0; + } + + /*---------------------------------------------------------------------------- + ; Return nothing or data or data pointer + ----------------------------------------------------------------------------*/ + return (shift); +} /* long_term_prediction */ + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/long_term_prediction.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/long_term_prediction.h new file mode 100644 index 0000000..2c039b9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/long_term_prediction.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: long_term_prediction.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes function prototype declaration for long_term_prediction(). + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef LONG_TERM_PREDICTION_H +#define LONG_TERM_PREDICTION_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_window_sequence.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define LTP_Q_FORMAT (15) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + Int long_term_prediction( + WINDOW_SEQUENCE win_seq, + const Int weight_index, + const Int delay[], + const Int16 buffer[], + const Int buffer_offset, + const Int32 time_quant[], + Int32 predicted_samples[], /* Q15 */ + const Int frame_length); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/long_term_synthesis.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/long_term_synthesis.cpp new file mode 100644 index 0000000..cdf0532 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/long_term_synthesis.cpp @@ -0,0 +1,1080 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: long_term_synthesis.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + win_seq = type of window sequence (WINDOW_SEQUENCE). + sfb_per_win = number of scalefactor bands for each window, 1024 for + long window, 128 for short window, type of Int. + win_sfb_top = buffer (Int16) containing the top coefficient per + scalefactor band for each window. + win_prediction_used = buffer (Int) containing the prediction flag + information for short windows. Each item in the + buffer toggles prediction on(1)/off(0) for each + window separately. + sfb_prediction_used = buffer (Int) containing the prediction flag + information for scalefactor band(sfb). Each item + toggle prediction on(1)/off(0) on each scalefactor + band of every window. + current_frame = channel buffer (Int32) containing the dequantized + spectral coefficients or errors of current frame. + q_format = buffer (Int) containing Q format for each scalefactor band of + input current_frame. + predicted_spectral = buffer (Int32) containing predicted spectral + components of current frame. + pred_q_format = Q format (Int) for predicted spectral components of + current frame. + coef_per_win = number of coefficients per window for short windows. + type of Int. + short_window_num = number of short windows, type of Int. + reconstruct_sfb_num = number of scalefactor bands used for reconstruction + for short windows, type of Int. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + current_frame contents are the dequantized spectrum with a prediction + vector added when prediction is turned on. + + q_format contents are updated with the new Q format (Int) for each + scalefactor band of output current_frame buffer. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function performs long term synthesis using transmitted spectral + coeffients or errors and predicted spectral components. + + Long term synthesis is part of long term prediction (LTP) which is used to + reduce the redundancy of a signal between successive coding frames. The + functionality of long term synthesis is to reconstruct the frequency domain + spectral by adding the predicted spectral components and the transmitted + spectral error when prediction is turned on. + +------------------------------------------------------------------------------ + REQUIREMENTS + + None + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3: Audio + Subpart 4.6.6 Long Term Prediction (LTP) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by Nokia in the course + of development of the MPEG-2 AAC/MPEG-4 Audio standard ISO/IEC13818-7, + 14496-1, 2 and 3. This software module is an implementation of a part + of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the MPEG-2 + aac/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2aac/MPEG-4 + Audio standards free license to this software module or modifications + thereof for use in hardware or software products claiming conformance + to the MPEG-2 aac/MPEG-4 Audio standards. Those intending to use this + software module in hardware or software products are advised that this + use may infringe existing patents. The original developer of this + software module, the subsequent editors and their companies, and ISO/IEC + have no liability for use of this software module or modifications + thereof in an implementation. Copyright is not released for non MPEG-2 + aac/MPEG-4 Audio conforming products. The original developer retains + full right to use the code for the developer's own purpose, assign or + donate the code to a third party and to inhibit third party from using + the code for non MPEG-2 aac/MPEG-4 Audio conforming products. This + copyright notice must be included in all copies or derivative works. + Copyright (c)1997. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pPredicted_spectral = &predicted_spectral[0]; + pPredicted_spectral_start = pPredicted_spectral; + pSfb_prediction_used = &sfb_prediction_used[0]; + + IF (win_seq != EIGHT_SHORT_SEQUENCE) + THEN + + sfb_offset = 0; + + pWinSfbTop = &pWin_sfb_top[0]; + + pQ_format = &q_format[0]; + + FOR (i = sfb_per_frame; i>0; i--) + + IF (*(pSfb_prediction_used++) != FALSE) + THEN + + pPredicted_offset = pPredicted_spectral_start + + sfb_offset; + pCurrent_frame = ¤t_frame[sfb_offset]; + + quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2; + + max = 0; + + pPredicted_spectral = pPredicted_offset; + + FOR (j = (*pWinSfbTop - sfb_offset); j>0 ; j--) + + tmpInt32 = *(pPredicted_spectral++); + + IF (tmpInt32 < 0) + THEN + + tmpInt32 = -tmpInt32; + + ENDIF + + max |= tmpInt32; + + ENDFOR + + tmpInt = 0; + + IF (max != 0) + THEN + + WHILE (max < 0x40000000L) + + max <<= 1; + tmpInt++; + + ENDWHILE + + pPredicted_spectral = pPredicted_offset; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + + ENDFOR + + adjusted_pred_q = pred_q_format + tmpInt; + + pPredicted_spectral = pPredicted_offset; + + shift_factor = *(pQ_format) - adjusted_pred_q; + + IF ((shift_factor >= 0) && (shift_factor < 31)) + THEN + + shift_factor = shift_factor + 1; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + + ENDFOR + + *(pQ_format) = adjusted_pred_q - 1; + + ELSEIF (shift_factor >= 31) + THEN + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + + ENDFOR + + *(pQ_format) = adjusted_pred_q; + + ELSEIF ((shift_factor < 0) && (shift_factor > -31)) + THEN + + shift_factor = 1 - shift_factor; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + + ENDFOR + + *(pQ_format) = *(pQ_format) - 1; + + ENDIF + + ENDIF + + ENDIF [ IF (*(pSfb_prediction_used++) != FALSE) ] + + sfb_offset = *pWinSfbTop; + pWinSfbTop = pWinSfbTop + 1; + pQ_format = pQ_format + 1; + + ENDFOR [ FOR (i = sfb_per_frame; i>0; i--) ] + + ELSE + + pCurrent_frame_start = ¤t_frame[0]; + + pQ_format_start = &q_format[0]; + + num_sfb = sfb_per_win[0]; + + FOR (wnd=0; wnd 0; i--) + + pPredicted_offset = pPredicted_spectral_start + + sfb_offset; + pCurrent_frame = pCurrent_frame_start + sfb_offset; + + quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2; + + max = 0; + + pPredicted_spectral = pPredicted_offset; + + FOR (j = (*pWinSfbTop - sfb_offset); j>0 ; j--) + + tmpInt32 = *(pPredicted_spectral++); + + IF (tmpInt32 < 0) + THEN + + tmpInt32 = -tmpInt32; + + ENDIF + + max |= tmpInt32; + + ENDFOR + + tmpInt = 0; + + IF (max != 0) + THEN + + WHILE (max < 0x40000000L) + + max <<= 1; + tmpInt++; + + ENDWHILE + + + pPredicted_spectral = pPredicted_offset; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + + ENDFOR + + adjusted_pred_q = pred_q_format + tmpInt; + + pPredicted_spectral = pPredicted_offset; + + shift_factor = *(pQ_format) - adjusted_pred_q; + + IF ((shift_factor >= 0) && (shift_factor < 31)) + THEN + + shift_factor = shift_factor + 1; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + + ENDFOR + + *(pQ_format) = adjusted_pred_q - 1; + + ELSEIF (shift_factor >= 31) + THEN + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + + ENDFOR + + *(pQ_format) = adjusted_pred_q; + + ELSEIF ((shift_factor < 0) && (shift_factor > -31)) + THEN + + shift_factor = 1 - shift_factor; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + + ENDFOR + + *(pQ_format) = *(pQ_format) - 1; + + ENDIF + + ENDIF + + sfb_offset = *pWinSfbTop; + pWinSfbTop = pWinSfbTop + 1; + pQ_format = pQ_format + 1; + + ENDFOR [ FOR (i = reconstruct_sfb_num; i > 0; i--) ] + + ENDIF [ IF (win_prediction_used[wnd] != FALSE) ] + + pPredicted_spectral_start = pPredicted_spectral_start + num_sfb; + pCurrent_frame_start = pCurrent_frame_start + num_sfb; + wnd_offset = wnd_offset + num_sfb; + pQ_format_start = pQ_format_start + num_sfb; + + ENDFOR [ FOR (wnd=0; wnd 0; i--) + { + /* Check prediction flag for each scalefactor band. */ + if (*(pSfb_prediction_used++) != FALSE) + { + /* + * Prediction is on. Do reconstruction routine. + * Reconstruct spectral component of current + * frame by adding the predicted spectral + * components and the quantized prediction + * errors that reconstructed from transmitted + * data when prediction is turned on. + */ + + /* Set pointers to the offset of scalefactor bands */ + pPredicted_offset = pPredicted_spectral_start + + sfb_offset; + pCurrent_frame = ¤t_frame[sfb_offset]; + + /* + * (*pWinSfbTop - sfb_offset) is number of coefficients + * of the scalefactor band. + * ">>2" is used to set up for later unrolling the loop. + */ + quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2; + + /* + * Adjust pred_q_format and predicted_spectral() to + * maximum resolution. + */ + max = 0; + + pPredicted_spectral = pPredicted_offset; + + /* Find the maximum absolute value */ + for (j = (*pWinSfbTop - sfb_offset); j > 0 ; j--) + { + tmpInt32 = *(pPredicted_spectral++); + + /* + * Note: overflow is protected here even though + * tmpInt32 = 0x80000000 is very rare case. + * + * if (tmpInt32 == LONG_MIN) + * { + * tmpInt32 = LONG_MAX; + * } + * if (tmpInt32 < 0) + * { + * tmpInt32 = -tmpInt32; + * } + */ + + max |= tmpInt32 ^(tmpInt32 >> 31); + } + + /* + * IF the LTP data is all zeros + * (max == 0) - do nothing for this sfb. + */ + + if (max != 0) + { + /* Find the number of bits to reach the max resolution */ + tmpInt = 0; + + while (max < 0x40000000L) + { + max <<= 1; + tmpInt++; + } + + /* + * The following codes are combinded into shift factor + * adjusting and reconstruction section. + * + * pPredicted_spectral = pPredicted_offset; + * for(j = quarter_sfb_width; j>0 ; j--) + * { + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * } + * + */ + + /* Adjust Q format for predicted_spectral() */ + adjusted_pred_q = pred_q_format + tmpInt; + + /* + * Adjust Q format to prevent overflow that may occur during + * frequency domain reconstruction. + * + */ + pPredicted_spectral = pPredicted_offset; + + shift_factor = *(pQ_format) - adjusted_pred_q; + + if ((shift_factor >= 0) && (shift_factor < 31)) + { + shift_factor = shift_factor + 1; + pred_shift = tmpInt - 1; + + if (pred_shift >= 0) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + } + } + else + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + } + } + + /* Updated new Q format for current scalefactor band */ + *(pQ_format) = adjusted_pred_q - 1; + } + else if (shift_factor >= 31) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + } + + /* Updated new Q format for current scalefactor band */ + *(pQ_format) = adjusted_pred_q ; + } + else if ((shift_factor < 0) && (shift_factor > -31)) + { + shift_factor = 1 - shift_factor; + pred_shift = tmpInt - shift_factor; + + if (pred_shift >= 0) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + } + } + else + { + pred_shift = -pred_shift; + + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + } + } + + /* + * Updated new Q format for current scalefactor band + * + * This is NOT a pointer decrement + */ + (*pQ_format)--; + } + + } /* if (max != 0) */ + + /* + * For case (shift_factor <= -31), *pCurrent_frame and + * *pQ_format do not need to be updated. + */ + + } /* if (*(pSfb_prediction_used++) != FALSE) */ + + /* Updated to next scalefactor band. */ + sfb_offset = *(pWinSfbTop++); + + /* Updated pointer to next scalefactor band's Q-format */ + pQ_format++; + + } /* for (i = sfb_per_frame; i>0; i--) */ + + } /* if (win_seq!=EIGHT_SHORT_SEQUENCE) */ + + /**********************************/ + /* LTP synthesis for short window */ + /**********************************/ + else + { + /******************************************************/ + /*Reconstruction of current frequency domain spectrum */ + /******************************************************/ + pCurrent_frame_start = ¤t_frame[0]; + + pQ_format_start = &q_format[0]; + + num_sfb = sfb_per_win; + + /* Reconstruction is processed on window basis */ + for (wnd = 0; wnd < short_window_num; wnd++) + { + pWinSfbTop = &win_sfb_top[0]; + + pQ_format = pQ_format_start; + + /* Check if prediction flag is on for each window */ + if (win_prediction_used[wnd] != FALSE) + { + /* Initialize scalefactor band offset */ + sfb_offset = 0; + + /* + * Reconstruction is processed on scalefactor band basis. + * 1. When prediction is turned on, all the predicted + * spectral components will be used for reconstruction. + * 2. When prediction is turned off, reconstruction is + * not needed. Spectral components of current frame + * will directly come from the transmitted data. + */ + + /* + * According to ISO/IEC 14496-3 pg.91 + * Only the spectral components in first eight scalefactor + * bands are added to the quantized prediction error. + */ + for (i = reconstruct_sfb_num; i > 0; i--) + { + /* Set pointer to the offset of scalefactor bands */ + pPredicted_offset = pPredicted_spectral_start + + sfb_offset; + pCurrent_frame = pCurrent_frame_start + sfb_offset; + + /* + * Prediction is on. Do reconstruction routine. + * Reconstruct spectral component of + * current frame by adding the predicted + * spectral components and the quantized + * prediction errors that reconstructed + * from transmitted data when prediction + * is turned on. + */ + + /* + * (*pWinSfbTop - sfb_offset) is number of coefficients + * of the scalefactor band. + * ">>2" is used to set up for later unrolling the loop. + */ + quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2; + + /* + * Adjust pred_q_format and predicted_spectral() to + * maximum resolution. + */ + max = 0; + pPredicted_spectral = pPredicted_offset; + + /* Find the maximum absolute value */ + for (j = (*pWinSfbTop - sfb_offset); j > 0 ; j--) + { + tmpInt32 = *(pPredicted_spectral++); + + + /* + * Note: overflow is protected here even though + * tmpInt32 = 0x80000000 is very rare case. + * + * if (tmpInt32 == LONG_MIN) + * { + * tmpInt32 = LONG_MAX; + * } + * if (tmpInt32 < 0) + * { + * tmpInt32 = -tmpInt32; + * } + */ + + max |= tmpInt32 ^(tmpInt32 >> 31); + } + + if (max != 0) + { + /* Find the number of bits to reach + * the max resolution + */ + tmpInt = 0; + + while (max < 0x40000000L) + { + max <<= 1; + tmpInt++; + } + /* + * The following codes are combined into shift factor + * adjusting and reconstruction section. + * + * pPredicted_spectral = pPredicted_offset; + * for(j = quarter_sfb_width; j>0 ; j--) + * { + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * } + * + */ + + /* Adjust Q format for predicted_spectral() */ + adjusted_pred_q = pred_q_format + tmpInt; + + /* + * Adjust Q format to prevent overflow that may occur + * during frequency domain reconstruction. + */ + pPredicted_spectral = pPredicted_offset; + + shift_factor = *(pQ_format) - adjusted_pred_q; + + if ((shift_factor >= 0) && (shift_factor < 31)) + { + shift_factor = shift_factor + 1; + + pred_shift = tmpInt - 1; + + if (pred_shift >= 0) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + + } + } + else + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + } + } + + /* Updated new Q format for current scalefactor band*/ + *(pQ_format) = adjusted_pred_q - 1; + } + else if (shift_factor >= 31) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + } + + /* Updated new Q format for current scalefactor band*/ + *(pQ_format) = adjusted_pred_q; + } + else if ((shift_factor < 0) && (shift_factor > -31)) + { + shift_factor = 1 - shift_factor; + + pred_shift = tmpInt - shift_factor; + + if (pred_shift >= 0) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + + } + } + else + { + pred_shift = -pred_shift; + + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + } + } + + /* Updated new Q format for current scalefactor band*/ + *(pQ_format) = *(pQ_format) - 1; + } + + /* + * For case (shift_factor <= -31), *pCurrent_frame and + * *pQ_format do not need to be updated. + */ + + } /* if (max != 0) */ + + /* Updated to next scalefactor band. */ + sfb_offset = *(pWinSfbTop++); + + /* Updated pointer to next scalefactor band's Q-format */ + pQ_format++; + + } /* for (i = reconstruct_sfb_num; i > 0; i--) */ + + } /* if (win_prediction_used[wnd] != FALSE) */ + + /* Updated to next window */ + pPredicted_spectral_start += coef_per_win; + pCurrent_frame_start += coef_per_win; + pQ_format_start += num_sfb; + + } /* for (wnd=0; wndweight_index - updated with index into weight table for LTP. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function decodes the bitstream elements for long term prediction + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by Nokia + in the course of development of the MPEG-2 AAC/MPEG-4 Audio standard + ISO/IEC13818-7, 14496-1, 2 and 3. This software module is an implementation + of a part of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the + MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC gives users of the + MPEG-2aac/MPEG-4 Audio standards free license to this software module or + modifications thereof for use in hardware or software products claiming + conformance to the MPEG-2 aac/MPEG-4 Audio standards. Those intending to + use this software module in hardware or software products are advised that + this use may infringe existing patents. The original developer of this + software module, the subsequent editors and their companies, and ISO/IEC + have no liability for use of this software module or modifications thereof + in an implementation. Copyright is not released for non MPEG-2 aac/MPEG-4 + Audio conforming products. The original developer retains full right to use + the code for the developer's own purpose, assign or donate the code to a + third party and to inhibit third party from using the code for non + MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice + must be included in all copies or derivative works." + Copyright (c)1997. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pDelay[0] = (Int) getbits( + LEN_LTP_LAG, + pInputStream); + + temp_reg = (Int) getbits( + LEN_LTP_COEF, + pInputStream); + + pLt_pred->weight = codebook[temp_reg]; + + last_band = max_sfb; + + IF (win_type != EIGHT_SHORT_SEQUENCE) + + IF (last_band > MAX_LT_PRED_LONG_SFB) + + last_band = MAX_LT_PRED_LONG_SFB; + + ENDIF + + FOR (m = last_band; m > 0; m--) + + *(pSfbPredictionUsed++) = (Int) getbits( + LEN_LTP_LONG_USED, + pInputStream); + ENDFOR + + FOR (m = (max_sfb - last_band); m > 0; m--) + + *(pSfbPredictionUsed++) = 0; + + ENDFOR + + ELSE + + IF (last_band > MAX_LT_PRED_SHORT_SFB) + + last_band = MAX_LT_PRED_SHORT_SFB; + + ENDIF + + prev_subblock = pDelay[0]; + + pWinPredictionUsed++; + + pTempPtr = &pSfbPredictionUsed[0]; + + FOR (m = NUM_SHORT_WINDOWS; m > 0;) + + m--; + temp_reg = (Int) getbits( + LEN_LTP_SHORT_USED, + pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + IF (temp_reg != FALSE) + { + *(pDelay++) = prev_subblock; + + FOR (k = last_band; k > 0; k--) + { + *(pTempPtr++) = 1; + } + break; + ELSE + { + pDelay++; + pTempPtr += last_band; + } + + ENDFOR (m = NUM_SHORT_WINDOWS; m > 0;) + + prev_subblock += LTP_LAG_OFFSET; + + FOR (; m > 0; m--) + + temp_reg = (Int) getbits ( + LEN_LTP_SHORT_USED, + pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + IF (temp_reg != FALSE) + + temp_reg = (Int) getbits( + LEN_LTP_SHORT_LAG_PRESENT, + pInputStream); + IF (temp_reg != 0) + + temp_reg = (Int) getbits( + LEN_LTP_SHORT_LAG, + pInputStream); + + *(pDelay++) = prev_subblock - temp_reg; + + ELSE + + *(pDelay++) = prev_subblock - LTP_LAG_OFFSET; + + ENDIF + + FOR (k = last_band; k > 0; k--) + *(pTempPtr++) = 1; + ENDFOR + + ELSE + + pDelay++; + pTempPtr += last_band; + + ENDIF + + ENDFOR (; m > 0; m--) + + ENDIF (win_type != EIGHT_SHORT_SEQUENCE) + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "lt_decode.h" +#include "ltp_common_internal.h" +#include "window_block_fxp.h" +#include "e_window_sequence.h" +#include "s_lt_pred_status.h" +#include "s_bits.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void lt_decode( + const WINDOW_SEQUENCE win_type, + BITS *pInputStream, + const Int max_sfb, + LT_PRED_STATUS *pLt_pred) +{ + Int wnd_num; + Int k; + Int last_band; + Int prev_subblock; + Int prev_subblock_nonzero; + Int temp_reg; + + Bool *pWinPredictionUsed = pLt_pred->win_prediction_used; + Bool *pSfbPredictionUsed = pLt_pred->sfb_prediction_used; + Int *pTempPtr; + Int *pDelay = pLt_pred->delay; + + pDelay[0] = (Int) get17_n_lessbits( + LEN_LTP_LAG, /* 11 bits */ + pInputStream); + + pLt_pred->weight_index = (Int) get9_n_lessbits( + LEN_LTP_COEF, /* 3 bits */ + pInputStream); + + last_band = max_sfb; + + if (win_type != EIGHT_SHORT_SEQUENCE) + { + + /* last_band = min(MAX_LT_PRED_LONG_SFB, max_sfb) MAX_SCFAC_BANDS */ + if (last_band > MAX_LT_PRED_LONG_SFB) + { + last_band = MAX_LT_PRED_LONG_SFB; + } + + for (k = last_band; k > 0; k--) + { + *(pSfbPredictionUsed++) = (Int) get1bits(pInputStream); + } + + /* + * This is not a call to memset, because + * (max_sfb - last_band) should typically be a small value. + */ + for (k = (max_sfb - last_band); k > 0; k--) + { + *(pSfbPredictionUsed++) = FALSE; + } + } + else /* (win_type == EIGHT_SHORT_SEQUENCE) */ + { + /* last_band = min(MAX_LT_PRED_SHORT_SFB, max_sfb) */ + + if (last_band > MAX_LT_PRED_SHORT_SFB) + { + last_band = MAX_LT_PRED_SHORT_SFB; + } + + /* + * The following two coding constructs are equivalent... + * + * first_time == 1 + * for (wnd_num=NUM_SHORT_WINDOWS; wnd_num > 0; wnd_num--) + * { + * if (condition) + * { + * if (first_time == 1) + * { + * CODE SECTION A + * first_time = 0; + * } + * else + * { + * CODE SECTION B + * } + * } + * } + * + * -----------------------------------EQUIVALENT TO------------ + * + * wnd_num=NUM_SHORT_WINDOWS; + * + * do + * { + * wnd_num--; + * if (condition) + * { + * CODE SECTION A + * break; + * } + * } while( wnd_num > 0) + * + * while (wnd_num > 0) + * { + * if (condition) + * { + * CODE SECTION B + * } + * wnd_num--; + * } + * + */ + + prev_subblock = pDelay[0]; + + pTempPtr = &pSfbPredictionUsed[0]; + + wnd_num = NUM_SHORT_WINDOWS; + + prev_subblock_nonzero = prev_subblock; + prev_subblock += LTP_LAG_OFFSET; + + do + { + /* + * Place decrement of wnd_num here, to insure + * that the decrement occurs before the + * break out of the do-while loop. + */ + wnd_num--; + + temp_reg = (Int) get1bits(pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + if (temp_reg != FALSE) + { + *(pDelay++) = prev_subblock_nonzero; + + for (k = last_band; k > 0; k--) + { + *(pTempPtr++) = TRUE; + } + for (k = (max_sfb - last_band); k > 0; k--) + { + *(pTempPtr++) = FALSE; + } + break; + + } /* if(pWinPredictionUsed) */ + else + { + pDelay++; + pTempPtr += max_sfb; + } + + } + while (wnd_num > 0); + + /* + * This while loop picks up where the previous one left off. + * Notice that the code functions differently inside the loop + */ + + while (wnd_num > 0) + { + temp_reg = (Int) get1bits(pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + if (temp_reg != FALSE) + { + temp_reg = (Int) get1bits(pInputStream); + if (temp_reg != 0) + { + temp_reg = (Int) get9_n_lessbits( + LEN_LTP_SHORT_LAG, + pInputStream); + + *(pDelay++) = prev_subblock - temp_reg; + } + else + { + *(pDelay++) = prev_subblock_nonzero; + } + for (k = last_band; k > 0; k--) + { + *(pTempPtr++) = TRUE; + } + for (k = (max_sfb - last_band); k > 0; k--) + { + *(pTempPtr++) = FALSE; + } + + } /* if (temp_reg) */ + else + { + pDelay++; + pTempPtr += max_sfb; + } + + wnd_num--; + + } /* while(wnd_num) */ + + } /* else (win_type == EIGHT_SHORT_SEQUENCE) */ + +} /* lt_decode */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/lt_decode.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/lt_decode.h new file mode 100644 index 0000000..bf95662 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/lt_decode.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: lt_decode.h + + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the global function declaration for lt_decode + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef LT_DECODE_H +#define LT_DECODE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_window_sequence.h" +#include "s_lt_pred_status.h" +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void lt_decode( + const WINDOW_SEQUENCE win_type, + BITS *pInputStream, + const Int max_sfb, + LT_PRED_STATUS *pLt_pred); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/lt_prediction.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/lt_prediction.h new file mode 100644 index 0000000..e52a1e8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/lt_prediction.h @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/************************************************************************** + +This software module was originally developed by +Nokia in the course of development of the MPEG-2 AAC/MPEG-4 +Audio standard ISO/IEC13818-7, 14496-1, 2 and 3. +This software module is an implementation of a part +of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the +MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC gives users of the +MPEG-2aac/MPEG-4 Audio standards free license to this software module +or modifications thereof for use in hardware or software products +claiming conformance to the MPEG-2 aac/MPEG-4 Audio standards. Those +intending to use this software module in hardware or software products +are advised that this use may infringe existing patents. The original +developer of this software module, the subsequent +editors and their companies, and ISO/IEC have no liability for use of +this software module or modifications thereof in an +implementation. Copyright is not released for non MPEG-2 aac/MPEG-4 +Audio conforming products. The original developer retains full right to +use the code for the developer's own purpose, assign or donate the code to a +third party and to inhibit third party from using the code for non +MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice +must be included in all copies or derivative works. +Copyright (c)1997. + +***************************************************************************/ + +#ifndef _LT_PREDICTION_H +#define _LT_PREDICTION_H + +#include "block.h" +#include "ltp_common.h" +#include "ibstream.h" +#include "lt_decode.h" +#include "s_frameinfo.h" +#include "window_block.h" + +void init_lt_pred(LT_PRED_STATUS * lt_status); + +void lt_predict( + Int object, + FrameInfo *pFrameInfo, + WINDOW_SEQUENCE win_seq, + Wnd_Shape *pWin_shape, + LT_PRED_STATUS *pLt_status, + Real *pPredicted_samples, + Real *pOverlap_buffer, + Real *pCurrent_frame_copy, + Real current_frame[]); + +short double_to_int(double sig_in); + +#endif /* not defined _LT_PREDICTION_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ltp_common_internal.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ltp_common_internal.h new file mode 100644 index 0000000..d76ac75 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ltp_common_internal.h @@ -0,0 +1,115 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/************************************************************************** + +This software module was originally developed by + +Mikko Suonio (Nokia) + +in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard +ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an +implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools +as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives +users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this +software module or modifications thereof for use in hardware or +software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio +standards. Those intending to use this software module in hardware or +software products are advised that this use may infringe existing +patents. The original developer of this software module and his/her +company, the subsequent editors and their companies, and ISO/IEC have +no liability for use of this software module or modifications thereof +in an implementation. Copyright is not released for non MPEG-2 +NBC/MPEG-4 Audio conforming products. The original developer retains +full right to use the code for his/her own purpose, assign or donate +the code to a third party and to inhibit third party from using the +code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This +copyright notice must be included in all copies or derivative works. + +Copyright (c) 1997. + +***************************************************************************/ + +#ifndef _LTP_COMMON_INTERNAL_H +#define _LTP_COMMON_INTERNAL_H + + +/* + Purpose: Number of LTP coefficients. */ +#define LPC 1 + +/* + Purpose: Maximum LTP lag. */ +#define DELAY 2048 + +/* + Purpose: Length of the bitstream element ltp_data_present. */ +#define LEN_LTP_DATA_PRESENT 1 + +/* + Purpose: Length of the bitstream element ltp_lag. */ +#define LEN_LTP_LAG 11 + +/* + Purpose: Length of the bitstream element ltp_coef. */ +#define LEN_LTP_COEF 3 + +/* + Purpose: Length of the bitstream element ltp_short_used. */ +#define LEN_LTP_SHORT_USED 1 + +/* + Purpose: Length of the bitstream element ltp_short_lag_present. */ +#define LEN_LTP_SHORT_LAG_PRESENT 1 + +/* + Purpose: Length of the bitstream element ltp_short_lag. */ +#define LEN_LTP_SHORT_LAG 5 + +/* + Purpose: Offset of the lags written in the bitstream. */ +#define LTP_LAG_OFFSET 16 + +/* + Purpose: Length of the bitstream element ltp_long_used. */ +#define LEN_LTP_LONG_USED 1 + +/* + Purpose: Upper limit for the number of scalefactor bands + which can use lt prediction with long windows. + Explanation: Bands 0..MAX_LT_PRED_SFB-1 can use lt prediction. */ +#define MAX_LT_PRED_LONG_SFB 40 + +/* + Purpose: Upper limit for the number of scalefactor bands + which can use lt prediction with short windows. + Explanation: Bands 0..MAX_LT_PRED_SFB-1 can use lt prediction. */ +#define MAX_LT_PRED_SHORT_SFB 13 + +/* + Purpose: Buffer offset to maintain block alignment. + Explanation: This is only used for a short window sequence. */ +#define SHORT_SQ_OFFSET (BLOCK_LEN_LONG-(BLOCK_LEN_SHORT*4+BLOCK_LEN_SHORT/2)) + +/* + Purpose: Number of codes for LTP weight. */ +#define CODESIZE 8 + +/* number of scalefactor bands used for reconstruction for short windows */ +#define NUM_RECONSTRUCTED_SFB (8) + +#endif /* _LTP_COMMON_INTERNAL_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdct_fxp.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdct_fxp.cpp new file mode 100644 index 0000000..d94700a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdct_fxp.cpp @@ -0,0 +1,428 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mdct_fxp.cpp + Funtions: fft_rx2 + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + data_quant = Input vector, with quantized Q15 spectral lines: + type Int32 + + Q_FFTarray = Scratch memory used for in-place IFFT calculation, + min size required 1024, type Int32 + + n = Length of input vector "data_quant". Currently 256 or 2048. + type const Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + shift = shift factor to reflect scaling introduced by FFT and mdct_fxp, + + Pointers and Buffers Modified: + calculation are done in-place and returned in "data_quant" + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + The MDCT is a linear orthogonal lapped transform, based on the idea of + time domain aliasing cancellation (TDAC). + MDCT is critically sampled, which means that though it is 50% overlapped, + a sequence data after MDCT has the same number of coefficients as samples + before the transform (after overlap-and-add). This means, that a single + block of MDCT data does not correspond to the original block on which the + MDCT was performed. When subsequent blocks of data are added (still using + 50% overlap), the errors introduced by the transform cancels out. + Thanks to the overlapping feature, the MDCT is very useful for + quantization. It effectively removes the otherwise easily detectable + blocking artifact between transform blocks. + N = length of input vector X + X = vector of length N/2, will hold fixed point DCT + k = 0:1:N-1 + + N-1 + X(m) = 2 SUM x(k)*cos(pi/(2*N)*(2*k+1+N/2)*(2*m+1)) + k=0 + + + The window that completes the TDAC is applied before calling this function. + The MDCT can be calculated using an FFT, for this, the MDCT needs to be + rewritten as an odd-time odd-frequency discrete Fourier transform. Thus, + the MDCT can be calculated using only one n/4 point FFT and some pre and + post-rotation of the sample points. + + Computation of the MDCT implies computing + + x = ( y - y ) + j( y + y ) + n 2n N/2-1-2n N-1-2n N/2+2n + + using the Fast discrete cosine transform as described in [2] + + where x(n) is an input with N points + + x(n) ---------------------------- + | + | + Pre-rotation by exp(j(2pi/N)(n+1/8)) + | + | + N/4- point FFT + | + | + Post-rotation by exp(j(2pi/N)(k+1/8)) + | + | + ------------- DCT + + By considering the N/2 overlap, a relation between successive input blocks + is found: + + x (2n) = x (N/2 + 2n) + m+1 m +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should provide a fixed point MDCT with an average + quantization error less than 1 %. + +------------------------------------------------------------------------------ + REFERENCES + + [1] Analysis/Synthesis Filter Bank design based on time domain + aliasing cancellation + Jhon Princen, et. al. + IEEE Transactions on ASSP, vol ASSP-34, No. 5 October 1986 + Pg 1153 - 1161 + + [2] Regular FFT-related transform kernels for DCT/DST based + polyphase filterbanks + Rolf Gluth + Proc. ICASSP 1991, pg. 2205 - 2208 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + Cx, Cy are complex number + + + exp = log2(n)-1 + + FOR ( k=0; k< n/4; k +=2) + + Cx = (data_quant[3n/4 + k] + data_quant[3n/4 - 1 - k]) + + j (data_quant[ n/4 + k] - data_quant[ n/4 - 1 - k]) + + Q_FFTarray = Cx * exp(-j(2pi/n)(k+1/8)) + + ENDFOR + + FOR ( k=n/4; k< n/2; k +=2) + + Cx = (data_quant[3n/4 - 1 - k] + data_quant[ - n/4 + k]) + + j (data_quant[5n/4 - 1 - k] - data_quant[ n/4 + k]) + + Q_FFTarray = Cx * exp(-j(2pi/n)(k+1/8)) + + ENDFOR + + CALL FFT( Q_FFTarray, n/4) + + MODIFYING( Q_FFTarray ) + + RETURNING( shift ) + + FOR ( k=0; k< n/2; k +=2) + + Cx = Q_FFTarray[ k] + j Q_FFTarray[ k+1] + + Cy = 2 * Cx * exp(-j(2pi/n)(k+1/8)) + + data_quant[ k ] = - Real(Cy) + data_quant[ n/2 - 1 - k ] = Imag(Cy) + data_quant[ n/2 + k ] = - Imag(Cy) + data_quant[ n - k ] = Real(Cy) + + ENDFOR + + MODIFIED data_quant[] + + RETURN (-shift-1) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "mdct_fxp.h" +#include "fft_rx4.h" +#include "mix_radix_fft.h" +#include "fwd_long_complex_rot.h" +#include "fwd_short_complex_rot.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define ERROR_IN_FRAME_SIZE 10 + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +Int mdct_fxp( + Int32 data_quant[], + Int32 Q_FFTarray[], + Int n) +{ + + Int32 temp_re; + Int32 temp_im; + + Int32 temp_re_32; + Int32 temp_im_32; + + Int16 cos_n; + Int16 sin_n; + Int32 exp_jw; + Int shift; + + + const Int32 *p_rotate; + + + Int32 *p_data_1; + Int32 *p_data_2; + Int32 *p_data_3; + Int32 *p_data_4; + + Int32 *p_Q_FFTarray; + + Int32 max1; + + Int k; + Int n_2 = n >> 1; + Int n_4 = n >> 2; + Int n_8 = n >> 3; + Int n_3_4 = 3 * n_4; + + switch (n) + { + case SHORT_WINDOW_TYPE: + p_rotate = (Int32 *)exp_rotation_N_256; + break; + + case LONG_WINDOW_TYPE: + p_rotate = (Int32 *)exp_rotation_N_2048; + break; + + default: + /* + * There is no defined behavior for a non supported frame + * size. By returning a fixed scaling factor, the input will + * scaled down and this will be heard as a low level noise + */ + return(ERROR_IN_FRAME_SIZE); + + } + + /*--- Reordering and Pre-rotation by exp(-j(2pi/N)(r+1/8)) */ + p_data_1 = &data_quant[n_3_4]; + p_data_2 = &data_quant[n_3_4 - 1]; + p_data_3 = &data_quant[n_4]; + p_data_4 = &data_quant[n_4 - 1]; + + p_Q_FFTarray = Q_FFTarray; + + max1 = 0; + + for (k = n_8; k > 0; k--) + { + /* + * scale down to ensure numbers are Q15 + * temp_re and temp_im are 32-bit but + * only the lower 16 bits are used + */ + + temp_re = (*(p_data_1++) + *(p_data_2--)) >> 1; + temp_im = (*(p_data_3++) - *(p_data_4--)) >> 1; + + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + exp_jw = *p_rotate++; + + cos_n = (Int16)(exp_jw >> 16); + sin_n = (Int16)(exp_jw & 0xFFFF); + + temp_re_32 = temp_re * cos_n + temp_im * sin_n; + temp_im_32 = temp_im * cos_n - temp_re * sin_n; + *(p_Q_FFTarray++) = temp_re_32; + *(p_Q_FFTarray++) = temp_im_32; + max1 |= (temp_re_32 >> 31) ^ temp_re_32; + max1 |= (temp_im_32 >> 31) ^ temp_im_32; + + + p_data_1++; + p_data_2--; + p_data_4--; + p_data_3++; + } + + + p_data_1 = &data_quant[n - 1]; + p_data_2 = &data_quant[n_2 - 1]; + p_data_3 = &data_quant[n_2]; + p_data_4 = data_quant; + + for (k = n_8; k > 0; k--) + { + /* + * scale down to ensure numbers are Q15 + */ + temp_re = (*(p_data_2--) - *(p_data_4++)) >> 1; + temp_im = (*(p_data_1--) + *(p_data_3++)) >> 1; + + p_data_2--; + p_data_1--; + p_data_4++; + p_data_3++; + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + exp_jw = *p_rotate++; + + cos_n = (Int16)(exp_jw >> 16); + sin_n = (Int16)(exp_jw & 0xFFFF); + + temp_re_32 = temp_re * cos_n + temp_im * sin_n; + temp_im_32 = temp_im * cos_n - temp_re * sin_n; + + *(p_Q_FFTarray++) = temp_re_32; + *(p_Q_FFTarray++) = temp_im_32; + max1 |= (temp_re_32 >> 31) ^ temp_re_32; + max1 |= (temp_im_32 >> 31) ^ temp_im_32; + + + } /* for(k) */ + + + + p_Q_FFTarray = Q_FFTarray; + + if (max1) + { + + if (n != SHORT_WINDOW_TYPE) + { + + shift = mix_radix_fft( + Q_FFTarray, + &max1); + + shift += fwd_long_complex_rot( + Q_FFTarray, + data_quant, + max1); + + } + else /* n_4 is 64 */ + { + + shift = fft_rx4_short( + Q_FFTarray, + &max1); + + shift += fwd_short_complex_rot( + Q_FFTarray, + data_quant, + max1); + } + + } + else + { + shift = -31; + } + + /* + * returns shift introduced by FFT and mdct_fxp, 12 accounts for + * regular downshift (14) and MDCT scale factor (-2) + * number are returned as 16 bits + */ + return (12 - shift); + +} /* mdct_fxp */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdct_fxp.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdct_fxp.h new file mode 100644 index 0000000..854523a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdct_fxp.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mdct_fxp.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function mdct_fxp() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef MDCT_FXP_H +#define MDCT_FXP_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ +#define LONG_WINDOW_TYPE 2048 +#define SHORT_WINDOW_TYPE 256 + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + extern const Int exp_rotation_N_256[128]; + extern const Int exp_rotation_N_2048[1024]; + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int mdct_fxp( + Int32 data_quant[], + Int32 Q_FFTarray[], + Int n); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* MDCT_FXP_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdct_tables_fxp.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdct_tables_fxp.cpp new file mode 100644 index 0000000..ac34521 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdct_tables_fxp.cpp @@ -0,0 +1,243 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mdct_tables_fxp.cpp + Funtions: + +------------------------------------------------------------------------------ + MODULE DESCRIPTION + + MDCT rotation tables fixpoint tables + + For a table with N complex points: + + cos_n + j*sin_n == exp(j(2pi/N)(n+1/8)) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. Include conditional + ; compile variables also. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; LOCAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; LOCAL VARIABLE DEFINITIONS + ; Variable declaration - defined here and used outside this module + ----------------------------------------------------------------------------*/ + + + /*---------------------------------------------------------------------------- + ; EXTERNAL FUNCTION REFERENCES + ; Declare functions defined elsewhere and referenced in this module + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + + + + extern const Int32 exp_rotation_N_256[64] = + { + + 0x5A820047, 0x5A7A0280, 0x5A6304B8, 0x5A3E06EF, + 0x5A0C0926, 0x59CB0B5B, 0x597D0D8E, 0x59210FBF, + 0x58B711EE, 0x5840141A, 0x57BB1643, 0x57281868, + 0x56881A8A, 0x55DB1CA8, 0x55201EC1, 0x545820D5, + 0x538322E5, 0x52A224EF, 0x51B326F3, 0x50B828F1, + 0x4FB12AE9, 0x4E9D2CDA, 0x4D7D2EC5, 0x4C5230A8, + 0x4B1A3284, 0x49D73458, 0x48883624, 0x472F37E7, + 0x45CA39A2, 0x445A3B54, 0x42E03CFD, 0x415C3E9C, + 0x3FCE4032, 0x3E3541BE, 0x3C944340, 0x3AE844B7, + 0x39344624, 0x37774786, 0x35B148DD, 0x33E44A29, + 0x320E4B69, 0x30304C9E, 0x2E4B4DC6, 0x2C5F4EE3, + 0x2A6C4FF4, 0x287250F8, 0x267251F0, 0x246D52DB, + 0x226153BA, 0x2051548B, 0x1E3B5550, 0x1C215607, + 0x1A0256B1, 0x17DF574E, 0x15B957DD, 0x138F585F, + 0x116358D3, 0x0F335939, 0x0D015992, 0x0ACE59DD, + 0x08985A1A, 0x06625A49, 0x042A5A6A, 0x01F25A7D + }; + + + + + + + extern const Int32 exp_rotation_N_2048[512] = + { + + 0x5A820009, 0x5A820050, 0x5A820097, 0x5A8100DE, + 0x5A810125, 0x5A80016C, 0x5A7E01B3, 0x5A7D01FA, + 0x5A7B0242, 0x5A790289, 0x5A7702D0, 0x5A750317, + 0x5A72035E, 0x5A7003A5, 0x5A6D03EC, 0x5A6A0433, + 0x5A66047A, 0x5A6304C1, 0x5A5F0508, 0x5A5B054F, + 0x5A560596, 0x5A5205DD, 0x5A4D0624, 0x5A48066A, + 0x5A4306B1, 0x5A3E06F8, 0x5A38073F, 0x5A320786, + 0x5A2C07CD, 0x5A260814, 0x5A20085A, 0x5A1908A1, + 0x5A1208E8, 0x5A0B092F, 0x5A040975, 0x59FC09BC, + 0x59F40A03, 0x59EC0A49, 0x59E40A90, 0x59DC0AD7, + 0x59D30B1D, 0x59CA0B64, 0x59C10BAA, 0x59B80BF1, + 0x59AE0C37, 0x59A50C7E, 0x599B0CC4, 0x59910D0A, + 0x59860D51, 0x597C0D97, 0x59710DDD, 0x59660E23, + 0x595B0E6A, 0x594F0EB0, 0x59440EF6, 0x59380F3C, + 0x592C0F82, 0x59200FC8, 0x5913100E, 0x59061054, + 0x58F9109A, 0x58EC10E0, 0x58DF1126, 0x58D1116B, + 0x58C411B1, 0x58B611F7, 0x58A7123C, 0x58991282, + 0x588A12C8, 0x587B130D, 0x586C1353, 0x585D1398, + 0x584E13DD, 0x583E1423, 0x582E1468, 0x581E14AD, + 0x580D14F2, 0x57FD1538, 0x57EC157D, 0x57DB15C2, + 0x57CA1607, 0x57B9164C, 0x57A71690, 0x579516D5, + 0x5783171A, 0x5771175F, 0x575E17A3, 0x574C17E8, + 0x5739182C, 0x57261871, 0x571218B5, 0x56FF18FA, + 0x56EB193E, 0x56D71982, 0x56C319C6, 0x56AF1A0A, + 0x569A1A4F, 0x56851A93, 0x56701AD6, 0x565B1B1A, + 0x56461B5E, 0x56301BA2, 0x561A1BE5, 0x56041C29, + 0x55EE1C6D, 0x55D81CB0, 0x55C11CF3, 0x55AA1D37, + 0x55931D7A, 0x557C1DBD, 0x55651E00, 0x554D1E43, + 0x55351E86, 0x551D1EC9, 0x55051F0C, 0x54EC1F4F, + 0x54D31F91, 0x54BB1FD4, 0x54A12016, 0x54882059, + 0x546F209B, 0x545520DE, 0x543B2120, 0x54212162, + 0x540721A4, 0x53EC21E6, 0x53D12228, 0x53B62269, + 0x539B22AB, 0x538022ED, 0x5364232E, 0x53492370, + 0x532D23B1, 0x531123F2, 0x52F42434, 0x52D82475, + 0x52BB24B6, 0x529E24F7, 0x52812538, 0x52642578, + 0x524625B9, 0x522825FA, 0x520B263A, 0x51EC267A, + 0x51CE26BB, 0x51B026FB, 0x5191273B, 0x5172277B, + 0x515327BB, 0x513427FB, 0x5114283A, 0x50F4287A, + 0x50D428BA, 0x50B428F9, 0x50942938, 0x50742978, + 0x505329B7, 0x503229F6, 0x50112A35, 0x4FF02A74, + 0x4FCE2AB2, 0x4FAD2AF1, 0x4F8B2B2F, 0x4F692B6E, + 0x4F472BAC, 0x4F242BEA, 0x4F022C29, 0x4EDF2C67, + 0x4EBC2CA4, 0x4E992CE2, 0x4E752D20, 0x4E522D5D, + 0x4E2E2D9B, 0x4E0A2DD8, 0x4DE62E15, 0x4DC22E53, + 0x4D9D2E90, 0x4D792ECD, 0x4D542F09, 0x4D2F2F46, + 0x4D0A2F83, 0x4CE42FBF, 0x4CBF2FFB, 0x4C993038, + 0x4C733074, 0x4C4D30B0, 0x4C2630EC, 0x4C003127, + 0x4BD93163, 0x4BB2319E, 0x4B8B31DA, 0x4B643215, + 0x4B3D3250, 0x4B15328B, 0x4AED32C6, 0x4AC53301, + 0x4A9D333C, 0x4A753376, 0x4A4C33B1, 0x4A2433EB, + 0x49FB3425, 0x49D2345F, 0x49A83499, 0x497F34D3, + 0x4955350C, 0x492C3546, 0x4902357F, 0x48D835B9, + 0x48AD35F2, 0x4883362B, 0x48583664, 0x482E369C, + 0x480336D5, 0x47D7370E, 0x47AC3746, 0x4781377E, + 0x475537B6, 0x472937EE, 0x46FD3826, 0x46D1385E, + 0x46A43895, 0x467838CD, 0x464B3904, 0x461E393B, + 0x45F13972, 0x45C439A9, 0x459739E0, 0x45693A16, + 0x453C3A4D, 0x450E3A83, 0x44E03AB9, 0x44B13AEF, + 0x44833B25, 0x44553B5B, 0x44263B90, 0x43F73BC6, + 0x43C83BFB, 0x43993C30, 0x43693C65, 0x433A3C9A, + 0x430A3CCF, 0x42DA3D04, 0x42AA3D38, 0x427A3D6C, + 0x424A3DA0, 0x42193DD4, 0x41E93E08, 0x41B83E3C, + 0x41873E6F, 0x41563EA3, 0x41253ED6, 0x40F33F09, + 0x40C23F3C, 0x40903F6F, 0x405E3FA1, 0x402C3FD4, + 0x3FFA4006, 0x3FC74038, 0x3F95406A, 0x3F62409C, + 0x3F2F40CE, 0x3EFC4100, 0x3EC94131, 0x3E964162, + 0x3E634193, 0x3E2F41C4, 0x3DFB41F5, 0x3DC74226, + 0x3D934256, 0x3D5F4286, 0x3D2B42B6, 0x3CF642E6, + 0x3CC24316, 0x3C8D4346, 0x3C584375, 0x3C2343A5, + 0x3BEE43D4, 0x3BB84403, 0x3B834432, 0x3B4D4460, + 0x3B18448F, 0x3AE244BD, 0x3AAC44EB, 0x3A754519, + 0x3A3F4547, 0x3A094575, 0x39D245A2, 0x399B45CF, + 0x396445FD, 0x392D462A, 0x38F64656, 0x38BF4683, + 0x388746B0, 0x385046DC, 0x38184708, 0x37E04734, + 0x37A84760, 0x3770478B, 0x373847B7, 0x36FF47E2, + 0x36C7480D, 0x368E4838, 0x36554863, 0x361D488E, + 0x35E348B8, 0x35AA48E2, 0x3571490C, 0x35384936, + 0x34FE4960, 0x34C44989, 0x348B49B3, 0x345149DC, + 0x34164A05, 0x33DC4A2E, 0x33A24A56, 0x33684A7F, + 0x332D4AA7, 0x32F24ACF, 0x32B74AF7, 0x327C4B1F, + 0x32414B46, 0x32064B6E, 0x31CB4B95, 0x31904BBC, + 0x31544BE3, 0x31184C0A, 0x30DD4C30, 0x30A14C56, + 0x30654C7C, 0x30294CA2, 0x2FEC4CC8, 0x2FB04CEE, + 0x2F734D13, 0x2F374D38, 0x2EFA4D5D, 0x2EBD4D82, + 0x2E804DA7, 0x2E434DCB, 0x2E064DEF, 0x2DC94E13, + 0x2D8C4E37, 0x2D4E4E5B, 0x2D104E7E, 0x2CD34EA2, + 0x2C954EC5, 0x2C574EE8, 0x2C194F0A, 0x2BDB4F2D, + 0x2B9D4F4F, 0x2B5E4F71, 0x2B204F93, 0x2AE14FB5, + 0x2AA34FD7, 0x2A644FF8, 0x2A255019, 0x29E6503A, + 0x29A7505B, 0x2968507C, 0x2929509C, 0x28E950BC, + 0x28AA50DC, 0x286A50FC, 0x282B511C, 0x27EB513B, + 0x27AB515B, 0x276B517A, 0x272B5199, 0x26EB51B7, + 0x26AB51D6, 0x266A51F4, 0x262A5212, 0x25E95230, + 0x25A9524E, 0x2568526B, 0x25275288, 0x24E652A5, + 0x24A652C2, 0x246452DF, 0x242352FB, 0x23E25318, + 0x23A15334, 0x235F5350, 0x231E536B, 0x22DC5387, + 0x229B53A2, 0x225953BD, 0x221753D8, 0x21D553F3, + 0x2193540D, 0x21515427, 0x210F5442, 0x20CD545B, + 0x208B5475, 0x2048548F, 0x200654A8, 0x1FC354C1, + 0x1F8154DA, 0x1F3E54F2, 0x1EFB550B, 0x1EB85523, + 0x1E76553B, 0x1E335553, 0x1DF0556A, 0x1DAC5582, + 0x1D695599, 0x1D2655B0, 0x1CE355C7, 0x1C9F55DD, + 0x1C5C55F4, 0x1C18560A, 0x1BD55620, 0x1B915636, + 0x1B4D564B, 0x1B095661, 0x1AC55676, 0x1A82568B, + 0x1A3E569F, 0x19F956B4, 0x19B556C8, 0x197156DC, + 0x192D56F0, 0x18E95704, 0x18A45717, 0x1860572A, + 0x181B573E, 0x17D75750, 0x17925763, 0x174D5775, + 0x17095788, 0x16C4579A, 0x167F57AB, 0x163A57BD, + 0x15F557CE, 0x15B057DF, 0x156B57F0, 0x15265801, + 0x14E15812, 0x149C5822, 0x14575832, 0x14115842, + 0x13CC5851, 0x13875861, 0x13415870, 0x12FC587F, + 0x12B6588E, 0x1271589D, 0x122B58AB, 0x11E558B9, + 0x11A058C7, 0x115A58D5, 0x111458E2, 0x10CE58F0, + 0x108858FD, 0x1042590A, 0x0FFD5916, 0x0FB75923, + 0x0F71592F, 0x0F2A593B, 0x0EE45947, 0x0E9E5952, + 0x0E58595E, 0x0E125969, 0x0DCC5974, 0x0D85597E, + 0x0D3F5989, 0x0CF95993, 0x0CB2599D, 0x0C6C59A7, + 0x0C2559B1, 0x0BDF59BA, 0x0B9959C4, 0x0B5259CD, + 0x0B0B59D5, 0x0AC559DE, 0x0A7E59E6, 0x0A3859EE, + 0x09F159F6, 0x09AA59FE, 0x09645A05, 0x091D5A0D, + 0x08D65A14, 0x08905A1B, 0x08495A21, 0x08025A28, + 0x07BB5A2E, 0x07745A34, 0x072D5A3A, 0x06E75A3F, + 0x06A05A44, 0x06595A49, 0x06125A4E, 0x05CB5A53, + 0x05845A57, 0x053D5A5C, 0x04F65A60, 0x04AF5A63, + 0x04685A67, 0x04215A6A, 0x03DA5A6D, 0x03935A70, + 0x034C5A73, 0x03055A76, 0x02BE5A78, 0x02775A7A, + 0x02305A7C, 0x01E95A7D, 0x01A25A7F, 0x015B5A80, + 0x01135A81, 0x00CC5A82, 0x00855A82, 0x003E5A82 + }; + + +#ifdef __cplusplus +} +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdst.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdst.cpp new file mode 100644 index 0000000..4f6f813 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdst.cpp @@ -0,0 +1,287 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mdst.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 64 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + mdst + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#include "pv_audio_type_defs.h" +#include "synthesis_sub_band.h" +#include "dct16.h" +#include "dct64.h" +#include "mdst.h" + +#ifdef HQ_SBR + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#include "fxp_mul32.h" +#include "dst32.h" + + +#define Qfmt1(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) +#define Qfmt(a) (Int32)(a*((Int32)1<<27) + (a>=0?0.5F:-0.5F)) + +const Int32 CosTable_32[32] = +{ + Qfmt1(0.50015063602065F), Qfmt1(0.50135845244641F), + Qfmt1(0.50378872568104F), Qfmt1(0.50747117207256F), + Qfmt1(0.51245147940822F), Qfmt1(0.51879271310533F), + Qfmt1(0.52657731515427F), Qfmt1(0.53590981690799F), + Qfmt1(0.54692043798551F), Qfmt1(0.55976981294708F), + Qfmt1(0.57465518403266F), Qfmt1(0.59181853585742F), + Qfmt1(0.61155734788251F), Qfmt1(0.63423893668840F), + Qfmt1(0.66031980781371F), Qfmt1(0.69037212820021F), + Qfmt1(0.72512052237720F), Qfmt1(0.76549416497309F), + Qfmt1(0.81270209081449F), Qfmt1(0.86834471522335F), + Qfmt(0.93458359703641F), Qfmt(1.01440826499705F), + Qfmt(1.11207162057972F), Qfmt(1.23383273797657F), + Qfmt(1.38929395863283F), Qfmt(1.59397228338563F), + Qfmt(1.87467598000841F), Qfmt(2.28205006800516F), + Qfmt(2.92462842815822F), Qfmt(4.08461107812925F), + Qfmt(6.79675071167363F), Qfmt(10.18693908361573F) +}; + + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; mdst_32 +----------------------------------------------------------------------------*/ + +void mdst_32(Int32 vec[], Int32 scratch_mem[]) +{ + + Int i; + const Int32 *pt_cos = CosTable_32; + Int32 *pt_vec = vec; + Int32 tmp1; + Int32 tmp2; + + + + Int32 tmp3; + + tmp3 = *(pt_vec++); + tmp2 = *(pt_vec); + + for (i = 5; i != 0; i--) + { + *(pt_vec++) += tmp3; + tmp1 = *(pt_vec); + *(pt_vec++) += tmp2; + tmp3 = *(pt_vec); + *(pt_vec++) += tmp1; + tmp2 = *(pt_vec); + *(pt_vec++) += tmp3; + tmp1 = *(pt_vec); + *(pt_vec++) += tmp2; + tmp3 = *(pt_vec); + *(pt_vec++) += tmp1; + tmp2 = *(pt_vec); + } + + *(pt_vec) += tmp3; + + dst_32(vec, scratch_mem); + + pt_vec = vec; + + for (i = 5; i != 0; i--) + { + *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) + tmp2, *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) - tmp2, *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) + tmp2, *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) - tmp2, *(pt_cos++)); + pt_vec++; + } + + tmp2 >>= 1; + for (i = 3; i != 0; i--) + { + *(pt_vec) = fxp_mul32_Q27((*(pt_vec) + tmp2), *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27((*(pt_vec) - tmp2), *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27((*(pt_vec) + tmp2), *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27((*(pt_vec) - tmp2), *(pt_cos++)); + pt_vec++; + } + + *(pt_vec - 1) <<= 1; + +} + + + +/*---------------------------------------------------------------------------- +; mdct_32 +----------------------------------------------------------------------------*/ + +void mdct_32(Int32 vec[]) +{ + Int i; + Int32 *pt_vec = vec; + Int32 tmp1, tmp2; + + + const Int32 *pt_CosTable = CosTable_32; + + + for (i = 5; i != 0; i--) + { + *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++)); + pt_vec++; + } + for (i = 3; i != 0; i--) + { + *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++)); + pt_vec++; + } + *(pt_vec - 1) <<= 1; + + + dct_32(vec); + + + pt_vec = &vec[31]; + + tmp1 = *(pt_vec--); + + for (i = 5; i != 0; i--) + { + tmp2 = *(pt_vec); + *(pt_vec--) += tmp1; + tmp1 = *(pt_vec); + *(pt_vec--) += tmp2; + tmp2 = *(pt_vec); + *(pt_vec--) += tmp1; + tmp1 = *(pt_vec); + *(pt_vec--) += tmp2; + tmp2 = *(pt_vec); + *(pt_vec--) += tmp1; + tmp1 = *(pt_vec); + *(pt_vec--) += tmp2; + } + + *(pt_vec) += tmp1; + +} + +#endif /* HQ_SBR */ + + +/*---------------------------------------------------------------------------- +; dct_32 +----------------------------------------------------------------------------*/ + + +void dct_32(Int32 vec[]) +{ + + pv_split(&vec[16]); + + dct_16(&vec[16], 0); + dct_16(vec, 1); // Even terms + + pv_merge_in_place_N32(vec); +} + +#endif /* AAC_PLUS */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdst.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdst.h new file mode 100644 index 0000000..17bcc8c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mdst.h @@ -0,0 +1,68 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mdst.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef MDST_H +#define MDST_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + void mdst_32(Int32 vec[], Int32 scratch_mem[]); + + void dct_32(Int32 vec[]); + + void mdct_32(Int32 vec[]); + + + +#ifdef __cplusplus +} +#endif + +#endif /* MDST_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mix_radix_fft.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mix_radix_fft.cpp new file mode 100644 index 0000000..4c5f275 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mix_radix_fft.cpp @@ -0,0 +1,277 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mix_radix_fft.cpp + Funtions: mix_radix_fft + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Data = Input vector, with quantized spectral with a pre-rotation + by exp(j(2pi/N)(k+1/8)) + type Int32 * + + peak_value = Input, carries the maximum value in input vector "Data" + Output, maximum value computed in the first FFT, used + to set precision on next stages + type Int32 * + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exponent = shift factor to reflect signal scaling + + Pointers and Buffers Modified: + Results are return in "Data" + + Local Stores Modified: + None + + Global Stores Modified: + None +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + mix_radix_fft() mixes radix-2 and radix-4 FFT. This is needed to be able + to use power of 4 length when the input length sequence is a power of 2. +------------------------------------------------------------------------------ + REQUIREMENTS + + mix_radix_fft() should support only the FFT for the long window case of + the inverse modified cosine transform (IMDCT) +------------------------------------------------------------------------------ + REFERENCES + + ------------------------------------------------------------------------------ + PSEUDO-CODE + + + MODIFY( x[] ) + RETURN( exponent ) + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "fft_rx4.h" +#include "mix_radix_fft.h" +#include "pv_normalize.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void digit_reversal_swapping(Int32 *y, Int32 *x); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int mix_radix_fft( + Int32 *Data, + Int32 *peak_value +) + +{ + + const Int32 *p_w; + Int32 *pData_1; + Int32 *pData_2; + + Int32 *pData_3; + Int32 *pData_4; + + Int32 exp_jw; + Int32 max1; + Int32 max2; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 diff1; + Int32 diff2; + Int i; + Int exp; + + max1 = *peak_value; + p_w = w_512rx2; + + pData_1 = Data; + pData_3 = Data + HALF_FFT_RX4_LENGTH_FOR_LONG; + + + /* + * normalization to 0.9999 (0x7FFF) guarantees proper operation + */ + + exp = 8 - pv_normalize(max1); /* use 24 bits for mix radix fft */ + + if (exp < 4) + { + exp = 4; + } + + + temp1 = (*pData_3); + pData_4 = pData_3 + FFT_RX4_LENGTH_FOR_LONG; + temp2 = (*pData_4++); + + + + diff1 = (temp1 - temp2) >> exp; + *pData_3++ = (temp1 + temp2) >> exp; + + temp3 = (*pData_3); + temp4 = (*pData_4); + + *pData_4-- = -diff1; + *pData_3++ = (temp3 + temp4) >> exp; + *pData_4 = (temp3 - temp4) >> exp; + + temp1 = (*pData_1); + pData_2 = pData_1 + FFT_RX4_LENGTH_FOR_LONG; + temp2 = (*pData_2++); + temp4 = (*pData_2); + + *pData_1++ = (temp1 + temp2) >> exp; + + temp3 = (*pData_1); + diff1 = (temp1 - temp2) >> exp ; + + *pData_1++ = (temp3 + temp4) >> exp; + *pData_2-- = (temp3 - temp4) >> exp; + *pData_2 = diff1; + + temp1 = (*pData_3); + pData_4 = pData_3 + FFT_RX4_LENGTH_FOR_LONG; + temp2 = (*pData_4++); + + + for (i = ONE_FOURTH_FFT_RX4_LENGTH_FOR_LONG - 1; i != 0; i--) + { + /* + * radix 2 Butterfly + */ + + diff1 = (temp1 - temp2) >> (exp - 4); + *pData_3++ = (temp1 + temp2) >> exp; + + temp3 = (*pData_3); + temp4 = (*pData_4); + + exp_jw = *p_w++; + + + diff2 = (temp3 - temp4) >> (exp - 4); + *pData_3++ = (temp3 + temp4) >> exp; + + *pData_4-- = -cmplx_mul32_by_16(diff1, diff2, exp_jw) >> 3; + *pData_4 = cmplx_mul32_by_16(diff2, -diff1, exp_jw) >> 3; + + + temp1 = (*pData_1); + pData_2 = pData_1 + FFT_RX4_LENGTH_FOR_LONG; + temp2 = (*pData_2++); + temp4 = (*pData_2); + + *pData_1++ = (temp1 + temp2) >> exp; + + temp3 = (*pData_1); + diff1 = (temp1 - temp2) >> (exp - 4); + + diff2 = (temp3 - temp4) >> (exp - 4); + *pData_1++ = (temp3 + temp4) >> exp; + + *pData_2-- = cmplx_mul32_by_16(diff2, -diff1, exp_jw) >> 3; + *pData_2 = cmplx_mul32_by_16(diff1, diff2, exp_jw) >> 3; + + temp1 = (*pData_3); + pData_4 = pData_3 + FFT_RX4_LENGTH_FOR_LONG; + temp2 = (*pData_4++); + + }/* for i */ + + + fft_rx4_long( + Data, + &max1); + + + fft_rx4_long( + &Data[FFT_RX4_LENGTH_FOR_LONG], + &max2); + + digit_reversal_swapping(Data, &Data[FFT_RX4_LENGTH_FOR_LONG]); + + *peak_value = max1 | max2; + + return(exp); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mix_radix_fft.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mix_radix_fft.h new file mode 100644 index 0000000..bf16205 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/mix_radix_fft.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mix_radix_fft.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions mix_radix_fft + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef MIX_RADIX_FFT_H +#define MIX_RADIX_FFT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define FFT_RX4_LENGTH_FOR_LONG 512 +#define HALF_FFT_RX4_LENGTH_FOR_LONG (FFT_RX4_LENGTH_FOR_LONG>>1) +#define ONE_FOURTH_FFT_RX4_LENGTH_FOR_LONG (FFT_RX4_LENGTH_FOR_LONG>>2) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int mix_radix_fft( + Int32 *Data, + Int32 *peak_value); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* MIX_RADIX_FFT_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ms_map_mask.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ms_map_mask.h new file mode 100644 index 0000000..a45669b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ms_map_mask.h @@ -0,0 +1,71 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef MS_MAP_MASK_H +#define MS_MAP_MASK_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void MS_map_mask( + FrameInfo *info, + Int *group, + Int *mask, + Int *cb_map); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ms_synt.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ms_synt.cpp new file mode 100644 index 0000000..aaf3697 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ms_synt.cpp @@ -0,0 +1,363 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ms_synt.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + wins_in_group = Number of windows in the current group. + [const Int] + + coef_per_win = Number of coefficients per window. + [const Int] + + num_bands = Number of scalefactor bands. + [const Int] + + band_length = Number of coefficients per scalefactor band. + [const Int] + + pFirst_Window_CoefsL = Array containing the spectral coefficients for + the left channel. + [Int32 *, length LN] + pFirst_Window_CoefsR = Array containing the spectral coefficients for + the right channel. + [Int32 *, length LN] + q_formatLeft = Array containing the q-format used to encode each + scalefactor band's data on the left channel. + [Int *, length MAXBANDS] + q_formatRight = Array containing the q-format used to encode each + scalefactor band's data on the right channel. + [Int *, length MAXBANDS] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pFirst_Window_CoefsL The coefficients in the group will be modified per the + formula for M/S stereo on each scalefactor band where + M/S stereo is active. + + pFirst_Window_CoefsR The coefficients in the group will be modified per the + formula for M/S stereo on each scalefactor band where + M/S stereo is active. + + q_formatLeft The q_format may be modified on scalefactor bands + where M/S stereo is active. + + q_formatRight The q_format may be modified on scalefactor bands + where M/S stereo is active. + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This module applies the formula for M/S coding to one grouped scalefactor + band. The ISO code has a similar function which applies M/S coding to an + entire frame. + + It is the calling function's responsibility to check the map_mask array, which + is filled by the function getmask. If a scalefactor band is identified as + using M/S stereo, the coefficients in that array are calculated using + the following formula... + + TempLeft = LeftCoefficient; + + LeftCoefficient = LeftCoefficient + RightCoefficient; + RightCoefficient = TempLeft - RightCoefficient; + + This function should be inlined if the compiler supports C99 inlining, + as this short function is only called by sfb_tools_ms(). + Therefore, inlining will not increase the code size. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.7.1 M/S stereo + Subpart 4.6.2 ScaleFactors + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + start_indx = 0; + + pCoefR = coefLeft; + pCoefL = coefRight; + + FOR (win_indx = wins_in_group; win_indx > 0; win_indx--) + + + tempInt = q_formatLeft[start_indx] - q_formatRight[start_indx]; + + IF (tempInt > 0) + THEN + + shift_left_chan = 1 + tempInt; + shift_right_chan = 1; + + q_formatLeft[start_indx] = (q_formatRight[start_indx] - 1); + q_formatRight[start_indx] = (q_formatRight[start_indx] - 1); + + ELSE + shift_left_chan = 1; + shift_right_chan = 1 - tempInt; + + q_formatRight[start_indx] = (q_formatLeft[start_indx] - 1); + q_formatLeft[start_indx] = (q_formatLeft[start_indx] - 1); + + ENDIF + + FOR (tempInt = band_length; tempInt > 0; tempInt--) + + temp_left = *(pCoefL) >> shift_left_chan; + temp_right = *(pCoefR) >> shift_right_chan; + + *(pCoefL++) = temp_left + temp_right; + *(pCoefR++) = temp_left - temp_right; + + ENDFOR + + tempInt = (coef_per_win - band_length); + + pCoefR = pCoefR + tempInt; + pCoefL = pCoefL + tempInt; + + start_indx = start_indx + num_bands; + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "ms_synt.h" +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" +#include "window_block_fxp.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ms_synt( + const Int wins_in_group, + const Int coef_per_win, + const Int num_bands, + const Int band_length, + Int32 coefLeft[], + Int32 coefRight[], + Int q_formatLeft[], + Int q_formatRight[]) +{ + + Int32 *pCoefL = coefLeft; + Int32 *pCoefR = coefRight; + Int start_indx = 0; + + + if (band_length < 0 || band_length > LONG_WINDOW) + { + return; /* avoid any processing on error condition */ + } + + + Int nextWinPtrUpdate = (coef_per_win - band_length); + + for (Int win_indx = wins_in_group; win_indx > 0; win_indx--) + { + + if (q_formatRight[start_indx] < 31) + { + Int tempInt = q_formatLeft[start_indx] - q_formatRight[start_indx]; + + /* Normalize the left and right channel to the same q-format */ + if (tempInt > 0) + { + /* + * shift_left_chan and shift_right_chan each have an offset + * of 1. Even if the left and right channel share the same + * q-format, we must shift each by 1 to guard against + * overflow. + */ + Int shift_left_chan = 1 + tempInt; + + /* + * Following code line is equivalent to... + * q_formatLeft = q_formatRight - 1; + * q_formatRight = q_formatRight - 1; + */ + q_formatLeft[start_indx] = --(q_formatRight[start_indx]); + + + /* + * band_length is always an even number (check tables in pg.66 IS0 14496-3) + */ + + Int32 temp_left = *(pCoefL) >> shift_left_chan; + Int32 temp_right = *(pCoefR) >> 1; + + + + for (Int i = band_length; i != 0; i--) + { + *(pCoefL++) = temp_left + temp_right; + *(pCoefR++) = temp_left - temp_right; + temp_left = *(pCoefL) >> shift_left_chan; + temp_right = *(pCoefR) >> 1; + + } + + } + else + { + /* + * shift_left_chan and shift_right_chan each have an offset + * of 1. Even if the left and right channel share the same + * q-format, we must shift each by 1 to guard against + * overflow. + */ + Int shift_right_chan = 1 - tempInt; + + /* + * Following code line is equivalent to... + * q_formatRight = q_formatLeft - 1; + * q_formatLeft = q_formatLeft - 1; + */ + q_formatRight[start_indx] = --(q_formatLeft[start_indx]); + + /* + * band_length is always an even number (check tables in pg.66 IS0 14496-3) + */ + + Int32 temp_left = *(pCoefL) >> 1; + Int32 temp_right = *(pCoefR) >> shift_right_chan; + + for (Int i = band_length; i != 0; i--) + { + *(pCoefL++) = temp_left + temp_right; + *(pCoefR++) = temp_left - temp_right; + + temp_left = *(pCoefL) >> 1; + temp_right = *(pCoefR) >> shift_right_chan; + + } + } + + } + else + { + /* + * Nothing on right channel, just copy left into right + */ + q_formatRight[start_indx] = (q_formatLeft[start_indx]); + + pv_memcpy(pCoefR, pCoefL, band_length*sizeof(*pCoefR)); + pCoefR += band_length; + pCoefL += band_length; + } + + /* + * Increment the window pointers so they point + * to the next window in the group + */ + pCoefL += nextWinPtrUpdate; + pCoefR += nextWinPtrUpdate; + + start_indx += num_bands; + + } /* for (win_indx) */ + + return; + +} /* MS_synt */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ms_synt.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ms_synt.h new file mode 100644 index 0000000..e770d72 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ms_synt.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ms_synt.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes the function declaration for ms_synt(). + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef MS_SYNT_H +#define MS_SYNT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void ms_synt( + const Int wins_in_group, + const Int coef_per_win, + const Int num_bands, + const Int band_length, + Int32 spectralCoefLeft[], + Int32 spectralCoefRight[], + Int q_formatLeft[], + Int q_formatRight[]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_corr.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_corr.cpp new file mode 100644 index 0000000..0b8dacf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_corr.cpp @@ -0,0 +1,307 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pns_corr.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + scale = Multiplier used to scale the noise extracted from the left + channel for use on the right. + [const Int] + + coef_per_win = Number of coefficients per window. + (128 for short, 1024 for long) + [const Int] + + sfb_per_win = Number of scalefactors per window. + [const Int] + + wins_in_group = The number of windows in the group being decoded. + [const Int] + + band_length = The length of the scalefactor band being decoded. + [const Int] + + sfb_prediction_used = Flag that denotes the activation of long term + prediction on a per-scalefactor band, + non-grouped basis. + [const Int *, length MAX_SFB] + + q_formatLeft = The Q-format for the left channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [const Int] + + q_formatRight = The Q-format for the right channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAX_SFB] + + coefLeft = Array containing the fixed-point spectral coefficients + for the left channel. + [const Int32 *, length 1024] + + coefRight = Array containing the fixed-point spectral coefficients + for the right channel. + [Int32 *, length 1024] + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + pcoefRight Contains the new spectral information + + q_formatRight Q-format may be updated with changed to fixed-point + data in coefRight. + + sfb_prediction_used LTP may be disabled by presence of PNS tool on the + same scalefactor band. + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function derives noise from the left channel. The PNS tool is assumed + to have been used on the same scalefactor band on the left channel. The + noise on the left/right channels are not necessarily of the same amplitude, + and therefore have separate scalefactors. The noise is thus scaled by the + difference between the two transmitted scalefactors. This scaling is done + in fixed-point using a constant 4-element table. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.7.1 M/S stereo + Subpart 4.6.12.3 Decoding Process (PNS) + Subpart 4.6.2 ScaleFactors + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + q_format = q_formatLeft - (scale >> 2); + q_format = q_format - 1; + q_formatRight = q_format; + + multiplier = hcb2_scale_mod_4[scale & 0x3]; + + pCoefLeft = coefLeft; + pCoefRight = coefRight; + + start_indx = 0; + + FOR (win_indx = wins_in_group; win_indx > 0; win_indx--) + + q_formatRight[start_indx] = q_format; + + sfb_prediction_used[start_indx] = FALSE; + + start_indx = start_indx + sfb_per_win; + + FOR (tempInt = band_length; tempInt > 0; tempInt--) + + *(pCoefRight) = (*(pCoefLeft) >> 9) * multiplier; + pCoefRight = pCoefRight + 1; + pCoefLeft = pCoefLeft + 1; + + ENDFOR + + tempInt = (coef_per_win - band_length); + pCoefRight = pCoefRight + tempInt; + pCoefLeft = pCoefLeft + tempInt; + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "pns_corr.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const UInt hcb2_scale_mod_4[4] = +{ + 32768, /* (2.0^0.00)*2^15 */ + 38968, /* (2.0^0.25)*2^15 */ + 46341, /* (2.0^0.50)*2^15 */ + 55109 +}; /* (2.0^0.75)*2^15 */ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pns_corr( + const Int scale, + const Int coef_per_win, + const Int sfb_per_win, + const Int wins_in_group, + const Int band_length, + const Int q_formatLeft, + Int q_formatRight[], + const Int32 coefLeft[], + Int32 coefRight[]) +{ + Int tempInt; + Int nextWinPtrUpdate; + + Int q_format; + + Int start_indx; + Int win_indx; + + const Int32 *pCoefLeft; + Int32 *pCoefRight; + + UInt multiplier; + + /* + * Generate noise correlated with the noise on the left channel + * + */ + + /* + * scale is interpreted as 2^(scale/4) + * Therefore, we can adjust the q-format by floor(scale/4) + * and save some complexity in the multiplier. + */ + q_format = q_formatLeft - (scale >> 2); + + /* + * Reduce the q-format by 1 to guard against overflow. + * This must be done because the hcb2_scale_mod_4 table + * must be stored in a common q-format, and we must shift + * by 16 to get *pCoefLeft into a 16-bit value, but we + * cannot store 2^0*2^16 and 2^0.75*2^16 in a table. + */ + q_format--; + + multiplier = hcb2_scale_mod_4[scale & 0x3]; + + pCoefLeft = coefLeft; + pCoefRight = coefRight; + + nextWinPtrUpdate = (coef_per_win - band_length); + + /* + * Step through all the windows in this group, replacing this + * band in each window's spectrum with correlated random noise + */ + + start_indx = 0; + + for (win_indx = wins_in_group; win_indx > 0; win_indx--) + { + /* + * Set the q-format for all scalefactor bands in the group. + * Normally, we could not assume that grouped scalefactors + * share the same q-format. + * However, here we can make this assumption. The reason + * being -- if this function is called, it is assumed + * PNS was used on the left channel. When PNS is used, + * all scalefactors in a group share the same q-format. + * + */ + q_formatRight[start_indx] = q_format; + + start_indx += sfb_per_win; + + /* reconstruct right noise values */ + for (tempInt = band_length; tempInt > 0; tempInt--) + { + *(pCoefRight++) = (Int32)(*(pCoefLeft++) >> 16) * multiplier; + } + + pCoefRight += nextWinPtrUpdate; + pCoefLeft += nextWinPtrUpdate; + + } /* for (win_indx) */ + + return; + +} /* void pns_corr */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_corr.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_corr.h new file mode 100644 index 0000000..f5cde3c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_corr.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pns_corr.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Contains the function declaration for pns_corr.c +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PNS_CORR_H +#define PNS_CORR_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void pns_corr( + const Int scale, + const Int coef_per_win, + const Int sfb_per_win, + const Int wins_in_group, + const Int band_length, + const Int q_formatLeft, + Int q_formatRight[], + const Int32 coefLeft[], + Int32 coefRight[]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_intensity_right.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_intensity_right.cpp new file mode 100644 index 0000000..f84b56a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_intensity_right.cpp @@ -0,0 +1,636 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pns_intensity_right.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + hasmask = mask status for the frame. Enumerated. + + pFrameInfo = Pointer to structure that holds information about each group. + (long block flag, number of windows, scalefactor bands + per group, etc.) + [const pFrameInfo * const] + + group = Array that contains indexes of the + first window in the next group. + [const Int *, length num_win] + + mask_map = Array that denotes whether M/S stereo is turned on for + each grouped scalefactor band. + [const Int *, length MAX_SFB] + + codebook_map = Array that denotes which Huffman codebook was used for + the encoding of each grouped scalefactor band. + [const Int *, length MAX_SFB] + + factorsL = Array of grouped scalefactors for left chan. + [const Int *, length MAX_SFB] + + factorsR = Array of scalefactors for right chan. + [const Int *, length MAX_SFB] + + sfb_prediction_used = Flag that denotes the activation of long term prediction + on a per-scalefactor band, non-grouped basis. + [const Int *, length MAX_SFB] + + ltp_data_present = Flag that indicates whether LTP is enbaled for this frame. + [const Bool] + + coefLeft = Array containing the fixed-point spectral coefficients + for the left channel. + [Int32 *, length 1024] + + coefRight = Array containing the fixed-point spectral coefficients + for the right channel. + [Int32 *, length 1024] + + q_formatLeft = The Q-format for the left channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAX_SFB] + + q_formatRight = The Q-format for the right channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAX_SFB] + + pCurrentSeed = Pointer to the current seed for the random number + generator in the function gen_rand_vector(). + [Int32 * const] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coefLeft = Contains the new spectral information. + + coefRight = Contains the new spectral information. + + q_formatLeft = Q-format may be updated with changed to fixed-point + data in coefLeft. + + q_formatRight = Q-format may be updated with changed to fixed-point + data in coefRight. + + pCurrentSeed = Value pointed to by pCurrentSeed updated by calls + to gen_rand_vector(). + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function steps through all of the scalefactor bands, looking for + either PNS or IS to be enabled on the right channel. + + If the codebook used is >= NOISE_HCB, the code then checks for the use + of Huffman codebooks NOISE_HCB, INTENSITY_HCB, or INTENSITY_HCB2. + + When a SFB utilizing the codebook NOISE_HCB is detected, a check is made to + see if M/S has also been enabled for that SFB. + + If M/S is not enabled, the band's spectral information is filled with + scaled random data. The scaled random data is generated by the function + gen_rand_vector. This is done across all windows in the group. + + If M/S is enabled, the band's spectral information is derived from the data + residing in the same band on the left channel. The information on the right + channel has independent scaling, so this is a bit more involved than a + direct copy of the information on the left channel. This is done by calling + the inline function pns_corr(). + + When a SFB utilizing an intensity codebook is detected, the band's spectral + information is generated from the information on the left channel. + This is done across all windows in the group. M/S being enabled has the + effect of reversing the sign of the data on the right channel. This code + resides in the inline function intensity_right(). + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.7.1 M/S stereo + Subpart 4.6.7.2.3 Decoding Process (Intensity Stereo) + Subpart 4.6.12.3 Decoding Process (PNS) + Subpart 4.6.2 ScaleFactors + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + pCoefRight = coefRight; + pCoefLeft = coefLeft; + + window_start = 0; + tot_sfb = 0; + start_indx = 0; + + coef_per_win = pFrameInfo->coef_per_win[0]; + + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + DO + pBand = pFrameInfo->win_sfb_top[window_start]; + + partition = *pGroup; + pGroup = pGroup + 1; + + band_start = 0; + + wins_in_group = (partition - window_start); + + FOR (sfb = sfb_per_win; sfb > 0; sfb--) + + band_stop = *(pBand); + pBand = pBand + 1; + + codebook = *(pCodebookMap); + pCodebookMap = pCodebookMap + 1; + + mask_enabled = *(pMaskMap); + pMaskMap = pMaskMap + 1; + + band_length = band_stop - band_start; + + IF (codebook == NOISE_HCB) + + sfb_prediction_used[tot_sfb] &= ltp_data_present; + + IF (sfb_prediction_used[tot_sfb] == FALSE) + + mask_enabled = mask_enabled AND hasmask; + + IF (mask_enabled == FALSE) + + pWindow_CoefR = &(pCoefRight[band_start]); + + start_indx = tot_sfb; + + FOR (win_indx = wins_in_group; + win_indx > 0; + win_indx--) + + CALL + q_formatRight[start_indx] = + gen_rand_vector( + pWindow_CoefR, + band_length, + pCurrentSeed, + *(pFactorsRight)); + MODIFYING + pCoefRight[band_start] + RETURNING + q_formatRight[start_indx] + + pWindow_CoefR += coef_per_win; + + start_indx = start_indx + sfb_per_win; + + ENDFOR + + ELSE + CALL + pns_corr( + (*(pFactorsRight) - + *(pFactorsLeft) ), + coef_per_win, + sfb_per_win, + wins_in_group, + band_length, + q_formatLeft[tot_sfb], + &(q_formatRight[tot_sfb]), + &(pCoefLeft[band_start]), + &(pCoefRight[band_start])); + + MODIFYING + pCoefRightt[band_start] + q_formatRight[tot_sfb] + RETURNING + NONE + ENDIF + + ENDIF + + ELSE IF (codebook >= INTENSITY_HCB2) + + mask_enabled = mask_enabled AND hasmask; + + CALL + intensity_right( + *(pFactorsRight), + coef_per_win, + sfb_per_win, + wins_in_group, + band_length, + codebook, + mask_enabled, + &(q_formatLeft[tot_sfb]), + &(q_formatRight[tot_sfb]), + &(pCoefLeft[band_start]), + &(pCoefRight[band_start])); + + MODIFYING + pCoefRightt[band_start] + q_formatRight[tot_sfb] + RETURNING + NONE + + ENDIF + + band_start = band_stop; + + tot_sfb = tot_sfb + 1; + + ENDFOR + + coef_per_win = coef_per_win * (wins_in_group); + + wins_in_group = wins_in_group - 1; + + tot_sfb = tot_sfb + sfb_per_win * wins_in_group; + pFactorsRight = pFactorsRight + sfb_per_win * wins_in_group; + pFactorsLeft = pFactorsLeft + sfb_per_win * wins_in_group; + + pCoefRight = pCoefRight + coef_per_win; + pCoefLeft = pCoefLeft + coef_per_win; + + window_start = partition; + + WHILE (partition < pFrameInfo->num_win); + + return; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "pns_intensity_right.h" +#include "e_huffmanconst.h" +#include "gen_rand_vector.h" +#include "intensity_right.h" +#include "pns_corr.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pns_intensity_right( + const Int hasmask, + const FrameInfo * const pFrameInfo, + const Int group[], + const Bool mask_map[], + const Int codebook_map[], + const Int factorsL[], + const Int factorsR[], + Int sfb_prediction_used[], + const Bool ltp_data_present, + Int32 coefLeft[], + Int32 coefRight[], + Int q_formatLeft[MAXBANDS], + Int q_formatRight[MAXBANDS], + Int32 * const pCurrentSeed) +{ + + Int32 *pCoefRight; + Int32 *pWindow_CoefR; + + Int32 *pCoefLeft; + + Int tot_sfb; + Int start_indx; + Int sfb; + + Int band_length = 0; + Int band_start; + Int band_stop; + Int coef_per_win; + + Int codebook; + Int partition; + Int window_start; + + Int sfb_per_win; + Int wins_in_group; + Int win_indx; + + const Int16 *pBand; + const Int *pFactorsLeft = factorsL; + const Int *pFactorsRight = factorsR; + const Int *pCodebookMap = codebook_map; + const Int *pGroup = group; + const Bool *pMaskMap = mask_map; + + Bool mask_enabled; + + pCoefRight = coefRight; + pCoefLeft = coefLeft; + + window_start = 0; + tot_sfb = 0; + start_indx = 0; + + /* + * Each window in the frame should have the same number of coef's, + * so coef_per_win is constant in all the loops + */ + coef_per_win = pFrameInfo->coef_per_win[0]; + + /* + * Because the number of scalefactor bands per window should be + * constant for each frame, sfb_per_win can be determined outside + * of the loop. + * + * For 44.1 kHz sampling rate sfb_per_win = 14 for short windows + * sfb_per_win = 49 for long windows + */ + + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + do + { + pBand = pFrameInfo->win_sfb_top[window_start]; + + /*---------------------------------------------------------- + Partition is equal to the first window in the next group + + { Group 0 }{ Group 1 }{ Group 2 }{Group 3} + [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7] + + pGroup[0] = 2 + pGroup[1] = 5 + pGroup[2] = 7 + pGroup[3] = 8 + -----------------------------------------------------------*/ + partition = *(pGroup++); + + if (partition == 0) + { + break; /* error condition */ + } + + band_start = 0; + + wins_in_group = (partition - window_start); + + for (sfb = sfb_per_win; sfb > 0; sfb--) + { + /* band is offset table, band_stop is last coef in band */ + band_stop = *(pBand++); + + codebook = *(pCodebookMap++); + + mask_enabled = *(pMaskMap++); + + /* + * When a tool utilizing sfb is found, apply the correct tool + * to that sfb in each window in the group + * + * Example... sfb[3] == NOISE_HCB + * + * [ Group 1 ] + * [win 0 ][win 1 ] + * [0][1][2][X][4][5][6][7][0][1][2][X][4][5][6][7] + * + * The for(sfb) steps through the sfb's 0-7 in win 0. + * + * Finding sfb[3]'s codebook == NOISE_HCB, the code + * steps through all the windows in the group (they share + * the same scalefactors) and replaces that sfb with noise. + */ + + /* + * Experimental results suggest that ms_synt is the most + * commonly used tool, so check for it first. + * + */ + + band_length = band_stop - band_start; + + if (codebook == NOISE_HCB) + { + sfb_prediction_used[tot_sfb] &= ltp_data_present; + + if (sfb_prediction_used[tot_sfb] == FALSE) + { + /* + * The branch and the logical AND interact in the + * following manner... + * + * mask_enabled == 0 hasmask == X -- gen_rand_vector + * mask_enabled == 1 hasmask == 1 -- pns_corr + * mask_enabled == 0 hasmask == 1 -- gen_rand_vector + * mask_enabled == 1 hasmask == 2 -- gen_rand_vector + * mask_enabled == 0 hasmask == 2 -- gen_rand_vector + */ + + mask_enabled &= hasmask; + + if (mask_enabled == FALSE) + { + pWindow_CoefR = &(pCoefRight[band_start]); + + /* + * Step through all the windows in this group, + * replacing this band in each window's + * spectrum with random noise + */ + start_indx = tot_sfb; + + for (win_indx = wins_in_group; + win_indx > 0; + win_indx--) + { + + /* generate random noise */ + q_formatRight[start_indx] = + gen_rand_vector( + pWindow_CoefR, + band_length, + pCurrentSeed, + *(pFactorsRight)); + + pWindow_CoefR += coef_per_win; + + start_indx += sfb_per_win; + } + + } + else + { + pns_corr( + (*(pFactorsRight) - + *(pFactorsLeft)), + coef_per_win, + sfb_per_win, + wins_in_group, + band_length, + q_formatLeft[tot_sfb], + &(q_formatRight[tot_sfb]), + &(pCoefLeft[band_start]), + &(pCoefRight[band_start])); + + } /* if (mask_map == FALSE) */ + + } /* if (sfb_prediction_used[tot_sfb] == FALSE) */ + + } /* if (codebook == 0) */ + else if (codebook >= INTENSITY_HCB2) + { + /* + * The logical AND flags the inversion of intensity + * in the following manner. + * + * mask_enabled == X hasmask == 0 -- DO NOT INVERT + * mask_enabled == 0 hasmask == X -- DO NOT INVERT + * mask_enabled == 1 hasmask == 1 -- DO INVERT + * mask_enabled == 0 hasmask == 1 -- DO NOT INVERT + * mask_enabled == 1 hasmask == 2 -- DO NOT INVERT + * mask_enabled == 0 hasmask == 2 -- DO NOT INVERT + */ + + mask_enabled &= hasmask; + + intensity_right( + *(pFactorsRight), + coef_per_win, + sfb_per_win, + wins_in_group, + band_length, + codebook, + mask_enabled, + &(q_formatLeft[tot_sfb]), + &(q_formatRight[tot_sfb]), + &(pCoefLeft[band_start]), + &(pCoefRight[band_start])); + + } /* END else codebook must be INTENSITY_HCB or ... */ + + band_start = band_stop; + + tot_sfb++; + + pFactorsLeft++; + pFactorsRight++; + + } /* for (sfb) */ + + /* + * Increment pCoefRight and pCoefLeft by + * coef_per_win * the number of windows + */ + + pCoefRight += coef_per_win * wins_in_group; + pCoefLeft += coef_per_win * wins_in_group--; + + /* + * Increase tot_sfb by sfb_per_win times the number of windows minus 1. + * The minus 1 comes from the fact that tot_sfb is already pointing + * to the first sfb in the 2nd window of the group. + */ + tot_sfb += sfb_per_win * wins_in_group; + + pFactorsRight += sfb_per_win * wins_in_group; + pFactorsLeft += sfb_per_win * wins_in_group; + + window_start = partition; + + } + while (partition < pFrameInfo->num_win); + + /* pFrameInfo->num_win = 1 for long windows, 8 for short_windows */ + + return; + +} /* pns_intensity_right() */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_intensity_right.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_intensity_right.h new file mode 100644 index 0000000..869367c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_intensity_right.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pns_intensity_right.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the function declaration for + pns_intensity_right.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PNS_INTENSITY_RIGHT_H +#define PNS_INTENSITY_RIGHT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void pns_intensity_right( + const Int hasmask, + const FrameInfo * const pFrameInfo, + const Int group[], + const Bool mask_map[], + const Int codebook_map[], + const Int factorsL[], + const Int factorsR[], + Int sfb_prediction_used[], + const Bool ltp_data_present, + Int32 spectralCoefLeft[], + Int32 spectralCoefRight[], + Int q_formatLeft[MAXBANDS], + Int q_formatRight[MAXBANDS], + Int32 * const pCurrentSeed); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_left.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_left.cpp new file mode 100644 index 0000000..4ccaa23 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_left.cpp @@ -0,0 +1,378 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: pns_left.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + const FrameInfo *pFrameInfo = Pointer to structure that holds + information about each group. + (long block flag, + number of windows, + scalefactor bands per group, etc.) + + const Int group[] = Array that contains indexes of the + the first window in the next group. + + const Int codebook_map[] = Array that denotes which Huffman + codebook was used for the encoding + of each scalefactor band. + + const Int factors[] = Array of scalefactors + + Int sfb_prediction_used[] = Flag that denotes the activation + of long term prediction on a sfb + basis. + + Bool ltp_data_present = Flag that denotes whether LTP + is active for the entire frame. If + this flag is FALSE, + sfb_prediction_used is garbage. + + Int32 spectral_coef[] = Array of pointers pointing to the + spectral coef's for the LEFT channel. + + Int q_format[] = Q-format for the information + pointed to by spectral_coef. + Indexed by scalefactor band. + + Int32 *pCurrentSeed = Pointer to the current seed for the + random number generator. + (gen_rand_vector) + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + Int32 spectral_coef[] = Contains the new spectral information + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + The function steps through each scalefactor band in the group, and + checks for the use of Huffman codebook NOISE_HCB. + + When a SFB utilizing NOISE_HCB is detected, the band in every window in the + group has its spectral information filled with scaled random data. + + The scaled random data is generated by the function gen_rand_vector. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This module shall replace bands that were encoded with the Huffman codebook + NOISE_HCB with random noise as returned from gen_rand_vector(). The result + shall be perceptually indistinguishable from the result obtained by the + ISO decoder. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.5.5 Figures + Subpart 4.6.2 ScaleFactors + Subpart 4.6.12 Perceptual Noise Substituion (PNS) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pFirst_Window_Coefs = spectral_coef; + + window_start = 0; + + tot_sfb = 0; + + DO + + num_bands = pFrameInfo->sfb_per_win[window_start]; + pBand = pFrameInfo->win_sfb_top[window_start]; + + partition = *(pGroup); + pGroup = pGroup + 1; + + band_start = 0; + + coef_per_win = pFrameInfo->coef_per_win[window_start]; + + wins_in_group = (partition - window_start); + + FOR (sfb = num_bands; sfb > 0; sfb--) + + band_stop = *pBand; + pBand = pBand + 1; + + IF (*(pCodebookMap++) == NOISE_HCB ) + + tempInt = sfb_prediction_used[tot_sfb] AND ltp_data_present; + + IF (tempInt == FALSE) + + pWindow_Coef = pFirst_Window_Coefs + band_start; + + band_length = (band_stop - band_start); + + start_indx = tot_sfb; + + tempInt = *(pFactors); + + FOR (win_indx = wins_in_group; win_indx > 0; win_indx--) + + CALL gen_rand_vector( pWindow_CoefR, + band_length, + pCurrentSeed, + tempInt); + + MODIFYING pWindow_CoefR = scaled random noise + pCurrentSeed = current state of the random + noise generator. + + RETURNING q_format[start_indx] = q-format for this sfb. + + pWindow_Coef = pWindow_Coef + coef_per_win; + + start_indx = start_indx + + pFrameInfo->sfb_per_win[win_indx]; + + ENDFOR + + ENDIF + + ENDIF + + band_start = band_stop; + + tot_sfb = tot_sfb + 1; + + pFactors = pFactors + 1; + + ENDFOR + + coef_per_win = coef_per_win * wins_in_group; + wins_in_group = wins_in_group - 1; + + tot_sfb = tot_sfb + num_bands * wins_in_group; + pFactors = pFactors + num_bands * wins_in_group; + + pFirst_Window_Coefs = pFirst_Window_Coefs + coef_per_win; + + window_start = partition; + + WHILE (partition < pFrameInfo->num_win); + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "pns_left.h" +#include "e_huffmanconst.h" +#include "gen_rand_vector.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pns_left( + const FrameInfo *pFrameInfo, + const Int group[], + const Int codebook_map[], + const Int factors[], + const Int sfb_prediction_used[], + const Bool ltp_data_present, + Int32 spectral_coef[], + Int q_format[], + Int32 *pCurrentSeed) +{ + + Int tot_sfb; + Int start_indx; + + Int sfb; + Int band_stop; + + const Int16 *pBand; + + const Int *pCodebookMap = &(codebook_map[0]); + const Int *pGroup = &(group[0]); + const Int *pFactors = &(factors[0]); + + Int tempInt; + Int32 *pWindow_Coef; + + + Int32 *spec; + + Int partition; + Int win_indx; + + tot_sfb = 0; + + spec = spectral_coef; + + /* PNS goes by group */ + win_indx = 0; + partition = 0; + do + { + Int num_bands = pFrameInfo->sfb_per_win[partition]; + pBand = pFrameInfo->win_sfb_top[partition]; + + /*---------------------------------------------------------- + Partition is equal to the first window in the next group + + { Group 0 }{ Group 1 }{ Group 2 }{Group 3} + [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7] + + pGroup[0] = 2 + pGroup[1] = 5 + pGroup[2] = 7 + pGroup[3] = 8 + -----------------------------------------------------------*/ + + partition = *pGroup++; /* partition = index of last sbk in group */ + + if (partition == 0) + { + break; /* error condition */ + } + + do + { + Int band_start = 0; + for (sfb = 0; sfb < num_bands; sfb++) + { + band_stop = pBand[sfb]; /* band is offset table, band_stop is last coef in band */ + + Int band_length = band_stop - band_start; + if (pCodebookMap[sfb] == NOISE_HCB) + { + + tempInt = sfb_prediction_used[tot_sfb] & ltp_data_present; + + if (tempInt == FALSE) + { + /* generate random noise */ + pWindow_Coef = spec + band_start; + + tempInt = pFactors[sfb]; + + start_indx = tot_sfb++; + + /* reconstruct noise substituted values */ + /* generate random noise */ + + q_format[start_indx] = gen_rand_vector(pWindow_Coef, + band_length, + pCurrentSeed, + tempInt); + + } /* if (sfb_prediction_used[tot_sfb] == FALSE) */ + + } /* if (*(pCodebookMap++) == NOISE_HCB) */ + else + { + tot_sfb ++; /* update absolute sfb counter */ + } + + band_start = band_stop; + + } /* for (sfb) */ + + spec += pFrameInfo->coef_per_win[win_indx++]; + pFactors += num_bands; + + } + while (win_indx < partition); + + pCodebookMap += pFrameInfo->sfb_per_win[win_indx-1]; + + } + while (partition < pFrameInfo->num_win); + + + return; + +} /* pns */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_left.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_left.h new file mode 100644 index 0000000..a8c6c3c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pns_left.h @@ -0,0 +1,105 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pns_left.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Contains the function definition for pns_left.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PNS_LEFT_H +#define PNS_LEFT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pns_left( + const FrameInfo *pFrameInfo, + const Int group[], + const Int codebook_map[], + const Int factors[], + const Int sfb_prediction_used[], + const Bool ltp_data_present, + Int32 spectral_coef[], + Int q_format[], + Int32 *pCurrentSeed); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.cpp new file mode 100644 index 0000000..0cd2172 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.cpp @@ -0,0 +1,304 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_all_pass_filter_coeff.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decorrelation is achieved by means of all-pass filtering + + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_all_pass_fract_delay_filter.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +const Int16 aRevLinkDecaySerCoeff[NO_ALLPASS_CHANNELS][NO_SERIAL_ALLPASS_LINKS] = +{ + + + { Qfmt15(0.74915491616071f), Qfmt15(0.64942584030892f), Qfmt15(0.56297290849050f) }, + { Qfmt15(0.71658296328416f), Qfmt15(0.62118993420853f), Qfmt15(0.53849582551265f) }, + { Qfmt15(0.68401101040761f), Qfmt15(0.59295402810815f), Qfmt15(0.51401874253480f) }, + { Qfmt15(0.65143905753106f), Qfmt15(0.56471812200776f), Qfmt15(0.97908331911390f) }, /* 3 */ + { Qfmt15(0.61886710465450f), Qfmt15(0.53648221590737f), Qfmt15(0.93012915315822f) }, + { Qfmt15(0.58629515177795f), Qfmt15(0.50824630980698f), Qfmt15(0.88117498720252f) }, + { Qfmt15(0.55372319890140f), Qfmt15(0.48001040370660f), Qfmt15(0.83222082124682f) }, + { Qfmt15(0.52115124602484f), Qfmt15(0.45177449760621f), Qfmt15(0.78326665529112f) }, + { Qfmt15(0.48857929314829f), Qfmt15(0.42353859150582f), Qfmt15(0.73431248933542f) }, + { Qfmt15(0.45600734027174f), Qfmt15(0.39530268540543f), Qfmt15(0.68535832337974f) }, + { Qfmt15(0.42343538739519f), Qfmt15(0.36706677930504f), Qfmt15(0.63640415742404f) }, + { Qfmt15(0.39086343451863f), Qfmt15(0.33883087320466f), Qfmt15(0.58744999146834f) }, + { Qfmt15(0.35829148164208f), Qfmt15(0.31059496710427f), Qfmt15(0.53849582551265f) }, + { Qfmt15(0.32571952876553f), Qfmt15(0.28235906100388f), Qfmt15(0.48954165955695f) }, + { Qfmt15(0.29314757588898f), Qfmt15(0.25412315490349f), Qfmt15(0.44058749360126f) }, + { Qfmt15(0.26057562301242f), Qfmt15(0.22588724880310f), Qfmt15(0.39163332764556f) }, + { Qfmt15(0.22800367013587f), Qfmt15(0.19765134270272f), Qfmt15(0.34267916168986f) }, + { Qfmt15(0.19543171725932f), Qfmt15(0.16941543660233f), Qfmt15(0.29372499573418f) }, + { Qfmt15(0.16285976438276f), Qfmt15(0.14117953050194f), Qfmt15(0.24477082977848f) }, + { Qfmt15(0.13028781150621f), Qfmt15(0.11294362440155f), Qfmt15(0.19581666382278f) }, + { Qfmt15(0.09771585862966f), Qfmt15(0.08470771830116f), Qfmt15(0.14686249786708f) }, + { Qfmt15(0.06514390575311f), Qfmt15(0.05647181220078f), Qfmt15(0.09790833191140f) }, + { Qfmt15(0.03257195287655f), Qfmt15(0.02823590610039f), Qfmt15(0.04895416595570f) } + +}; + + + + + +const Char groupBorders[NO_IID_GROUPS + 1] = +{ + 4, 5, 0, 1, 2, 3, 7, 6, 8, 9, 3, 4, + 5, 6, 7, 8, 9, 11, 14, 18, 23, 35, 64 +}; + +const Char bins2groupMap[NO_IID_GROUPS] = +{ + 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 +}; + + + + +/* + * q_phi = 0.39 + * + * cos(pi*([3:22]+0.5)*q_phi) + */ + + +/* + * sin(-pi*([3:22]+0.5)*q_phi) + */ + + +const Int32 aFractDelayPhaseFactor[NO_QMF_ALLPASS_CHANNELS] = +{ + 0xCB5474A9, 0x5BEC5914, 0x72F3C7B0, 0xF1F480C6, 0x8389E21E, + 0xB9BA6AFC, 0x4CDB665C, 0x7A57DA5D, 0x06088024, 0x89BECF04, + 0xA9DB5EAC, 0x3BE5711F, 0x7EB9EDF7, 0x19F582A9, 0x92DDBD1F, + 0x9C1B5008, 0x29767919, 0x7FFC0203, 0x2D3F8843, 0x9EABACDF +}; + +/* + * q(m) = { 0.43, 0.75, 0.347 } + * + * cos(pi*([3:22]+0.5)*q(m)) cos(pi*([3:22]+0.5)'*q) + * + * sin(-pi*([3:22]+0.5)*q(m)) + * + */ + + +const Int32 aaFractDelayPhaseFactorSerQmf[NO_QMF_ALLPASS_CHANNELS][3] = +{ + { 0x02037FFC, 0xCF0489BE, 0x9BFB4FE0 }, + { 0x7D5719F5, 0xCF047642, 0x18947D9E }, + { 0x34AD8B57, 0x7642CF04, 0x7ABF244A }, + { 0x99A4B325, 0x89BECF04, 0x58EFA3F1 }, + { 0x9EAB5321, 0x30FC7642, 0xD77E8694 }, + { 0x3BE5711F, 0x30FC89BE, 0x819CEBC7 }, + { 0x7B77DE39, 0x89BE30FC, 0xB3A166B8 }, + { 0xF9F88024, 0x764230FC, 0x37C57336 }, + { 0x81E8E9FE, 0xCF0489BE, 0x7FF103D2 }, + { 0xCF047642, 0xCF047642, 0x3E8B9052 }, + { 0x68B9499A, 0x7642CF04, 0xB9E594E8 }, + { 0x5EACA9DB, 0x89BECF04, 0x80A00CA5 }, + { 0xC09590D1, 0x30FC7642, 0xD05276CA }, + { 0x85A925A3, 0x30FC89BE, 0x53486134 }, + { 0x0A0B7F9B, 0x89BE30FC, 0x7CB2E319 }, + { 0x7EB91209, 0x764230FC, 0x20078412 }, + { 0x2D3F8843, 0xCF0489BE, 0xA0ECAA4D }, + { 0x9504B9BA, 0xCF047642, 0x880D2CAE }, + { 0xA4145914, 0x7642CF04, 0xF0287F04 }, + { 0x42E16D23, 0x89BECF04, 0x694C48C7 } +}; + +/* + * Fractional delay vector + * + * phi_fract(k) = exp(-j*pi*q_phi*f_center(k)) 0<= k <= SUBQMF_GROUPS + * + * q_phi = 0.39 + * f_center(k) frequency vector + * + * + * f_center(k) = {0.5/4, 1.5/4, 2.5/4, 3.5/4, + * -1.5/4, -0.5/4, + * 3.5/2, 2.5/2, 4.5/2, 5.5/2}; + */ + + + +const Int32 aFractDelayPhaseFactorSubQmf[SUBQMF_GROUPS] = +{ + 0x7E80EC79, 0x72BAC73D, 0x5C45A749, 0x3D398F97, 0x72BA38C3, + 0x7E801387, 0xBA919478, 0x05068019, 0x895DCFF2, 0x834E1CE7, +}; + + + + + +/* + * Fractional delay length matrix + * + * Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k)) + * + * q(m) = { 0.43, 0.75, 0.347 } + * f_center(k) frequency vector + * + * + * f_center(k) = { 0.5/4, 1.5/4, 2.5/4, 3.5/4, + * -1.5/4, -0.5/4, + * 3.5/2, 2.5/2, 4.5/2, 5.5/2}; + */ + +const Int32 aaFractDelayPhaseFactorSerSubQmf[SUBQMF_GROUPS][3] = +{ + + { 0x7E2EEA7D, 0x7A7DDAD8, 0x7ED0EE9D }, + { 0x6FEDC1E5, 0x51349D0E, 0x7574CD1E }, + { 0x5506A052, 0x0C8C809E, 0x636CAF62 }, + { 0x3085898D, 0xC3A98F1D, 0x4A0D9799 }, + { 0x6FED3E1B, 0x513462F2, 0x757432E2 }, + { 0x7E2E1583, 0x7A7D2528, 0x7ED01163 }, + { 0xA4C8A634, 0xB8E36A6E, 0xD5AF8732 }, + { 0xF0F580E3, 0x8276E707, 0x1A7382C3 }, + { 0x80ABF2F4, 0x471D6A6E, 0x9D2FAEA4 }, + { 0x9478456F, 0x7D8AE707, 0x8152EDAB } +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.h new file mode 100644 index 0000000..b97ba0c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_all_pass_filter_coeff.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for all pass filter coefficients + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_ALL_PASS_FILTER_COEFF_H +#define PS_ALL_PASS_FILTER_COEFF_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +extern const Char groupBorders[NO_IID_GROUPS + 1]; +extern const Int16 aRevLinkDecaySerCoeff[NO_ALLPASS_CHANNELS][NO_SERIAL_ALLPASS_LINKS]; +extern const Int32 aRevLinkDelaySer[]; +extern const Int16 aFractDelayPhaseFactorReQmf[NO_QMF_ALLPASS_CHANNELS]; +extern const Int16 aFractDelayPhaseFactorImQmf[NO_QMF_ALLPASS_CHANNELS]; +/* the old center frequencies (found in "else") were too small (factor 1/2) */ +extern const Int16 aFractDelayPhaseFactorReSubQmf[SUBQMF_GROUPS]; +extern const Int16 aFractDelayPhaseFactorImSubQmf[SUBQMF_GROUPS]; +extern const Int32 aFractDelayPhaseFactorSubQmf[SUBQMF_GROUPS]; +extern const Int32 aFractDelayPhaseFactor[NO_QMF_ALLPASS_CHANNELS]; +extern const Int32 aaFractDelayPhaseFactorSerQmf[NO_QMF_ALLPASS_CHANNELS][3]; +extern const Int32 aaFractDelayPhaseFactorSerSubQmf[SUBQMF_GROUPS][3]; +extern const Char bins2groupMap[NO_IID_GROUPS]; +extern const Int32 aaFractDelayPhaseFactorSerReQmf[NO_QMF_ALLPASS_CHANNELS][3]; +extern const Int32 aaFractDelayPhaseFactorSerImQmf[NO_QMF_ALLPASS_CHANNELS][3]; +extern const Int32 aaFractDelayPhaseFactorSerReSubQmf[SUBQMF_GROUPS][3]; +extern const Int32 aaFractDelayPhaseFactorSerImSubQmf[SUBQMF_GROUPS][3]; + + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_ALL_PASS_FILTER_COEFF_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.cpp new file mode 100644 index 0000000..d6b6895 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.cpp @@ -0,0 +1,384 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_all_pass_fract_delay_filter.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decorrelation + Decorrelation is achieved by means of all-pass filtering and delaying + Sub-band samples s_k(n) are converted into de-correlated sub-bands samples + d_k(n). k index for frequency, n time index + + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + + Delay is introduced to compensate QMF bands not passed through Hybrid + Analysis + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "ps_decorrelate.h" +#include "aac_mem_funcs.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_pwr_transient_detection.h" +#include "ps_all_pass_fract_delay_filter.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +/* + * For lower subbands + * Apply all-pass filtering + * + */ + + +void ps_all_pass_fract_delay_filter_type_I(UInt32 *delayBufIndex, + Int32 sb_delay, + const Int32 *ppFractDelayPhaseFactorSer, + Int32 ***pppRealDelayRBufferSer, + Int32 ***pppImagDelayRBufferSer, + Int32 *rIn, + Int32 *iIn) +{ + + Int32 cmplx; + Int16 rTmp0; + Int32 rTmp; + Int32 iTmp; + Int32 *pt_rTmp; + Int32 *pt_iTmp; + + + + /* + * All pass filters + * 2 + * ___ Q_fract(k,m)*z^(-d(m)) - a(m)*g_decay_slope(k) + * z^(-2)*phi_fract(k)* | | ------------------------------------------------ + * m=0 1 - a(m)*g_decay_slope(k)*Q_fract(k,m)*z^(-d(m)) + * + * + * Fractional delay matrix: + * + * Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k)) 0<= k <= SUBQMF_GROUPS + * + * Vectors: a(m), q(m), d(m) are constants + * + * m m 0 1 2 + * ------------------------------- + * delay length d(m) == 3 4 5 (Fs > 32 KHz) + * fractional delay length q(m) == 0.43 0.75 0.347 + * filter coefficient a(m) == 0.65144 0.56472 0.48954 + * + * g_decay_slope(k) is given + */ + + + Int32 tmp_r; + Int32 tmp_i; + + pt_rTmp = &pppRealDelayRBufferSer[0][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[0][*(delayBufIndex++)][sb_delay]; + + cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */ + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = Qfmt15(0.65143905753106f); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + + + iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp; + + rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn); + + *rIn = rTmp; + + pt_rTmp = &pppRealDelayRBufferSer[1][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[1][*(delayBufIndex++)][sb_delay]; + + + + cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */ + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = Qfmt15(0.56471812200776f); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + + + iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp; + + rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn); + *rIn = rTmp; + + pt_rTmp = &pppRealDelayRBufferSer[2][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[2][*(delayBufIndex)][sb_delay]; + + + cmplx = *(ppFractDelayPhaseFactorSer); /* Q_fract(k,m) */ + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = Qfmt15(0.97908331911390f); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + + + iTmp = fxp_mac32_by_16(-*iIn, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp << 2; + + rTmp = fxp_mac32_by_16(-*rIn, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp, rTmp0, *rIn); + *rIn = rTmp << 2; +} + + +void ps_all_pass_fract_delay_filter_type_II(UInt32 *delayBufIndex, + Int32 sb_delay, + const Int32 *ppFractDelayPhaseFactorSer, + Int32 ***pppRealDelayRBufferSer, + Int32 ***pppImagDelayRBufferSer, + Int32 *rIn, + Int32 *iIn, + Int32 decayScaleFactor) +{ + + Int32 cmplx; + Int16 rTmp0; + Int32 rTmp; + Int32 iTmp; + Int32 *pt_rTmp; + Int32 *pt_iTmp; + const Int16 *pt_delay; + + + + /* + * All pass filters + * 2 + * ___ Q_fract(k,m)*z^(-d(m)) - a(m)*g_decay_slope(k) + * z^(-2)*phi_fract(k)* | | ------------------------------------------------ + * m=0 1 - a(m)*g_decay_slope(k)*Q_fract(k,m)*z^(-d(m)) + * + * + * Fractional delay matrix: + * + * Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k)) 0<= k <= SUBQMF_GROUPS + * + * Vectors: a(m), q(m), d(m) are constants + * + * m m 0 1 2 + * ------------------------------- + * delay length d(m) == 3 4 5 (Fs > 32 KHz) + * fractional delay length q(m) == 0.43 0.75 0.347 + * filter coefficient a(m) == 0.65144 0.56472 0.48954 + * + * g_decay_slope(k) is given + */ + + + Int32 tmp_r; + Int32 tmp_i; + + pt_rTmp = &pppRealDelayRBufferSer[0][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[0][*(delayBufIndex++)][sb_delay]; + + cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */ + pt_delay = aRevLinkDecaySerCoeff[decayScaleFactor]; + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = *(pt_delay++); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + + + iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp; + + rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn); + *rIn = rTmp; + + pt_rTmp = &pppRealDelayRBufferSer[1][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[1][*(delayBufIndex++)][sb_delay]; + + + cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */ + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = *(pt_delay++); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp; + + rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn); + *rIn = rTmp; + + pt_rTmp = &pppRealDelayRBufferSer[2][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[2][*(delayBufIndex)][sb_delay]; + + + cmplx = *(ppFractDelayPhaseFactorSer); /* Q_fract(k,m) */ + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = *(pt_delay); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + + + iTmp = fxp_mac32_by_16(-*iIn, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp << 2; + + rTmp = fxp_mac32_by_16(-*rIn, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp, rTmp0, *rIn); + *rIn = rTmp << 2; + +} + + + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.h new file mode 100644 index 0000000..30feccf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.h @@ -0,0 +1,111 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_all_pass_fract_delay_filter.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_all_pass_fract_delay_filter() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_ALL_PASS_FRACT_DELAY_FILTER_H +#define PS_ALL_PASS_FRACT_DELAY_FILTER_H + + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define R_SHIFT 29 +#define Q29_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + void ps_all_pass_fract_delay_filter_type_I(UInt32 *delayBufIndex, + Int32 sb_delay, + const Int32 *ppFractDelayPhaseFactorSer, + Int32 ***pppRealDelayRBufferSer, + Int32 ***pppImagDelayRBufferSer, + Int32 *rIn, + Int32 *iIn); + + + void ps_all_pass_fract_delay_filter_type_II(UInt32 *delayBufIndex, + Int32 sb_delay, + const Int32 *ppFractDelayPhaseFactorSer, + Int32 ***pppRealDelayRBufferSer, + Int32 ***pppImagDelayRBufferSer, + Int32 *rIn, + Int32 *iIn, + Int32 decayScaleFactor); + +#ifdef __cplusplus +} +#endif + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_ALL_PASS_FRACT_DELAY_FILTER_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.cpp new file mode 100644 index 0000000..7cc93d0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.cpp @@ -0,0 +1,334 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_allocate_decoder.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reuses AAC+ HQ right channel, which is not used when PS is enabled + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef HQ_SBR + +#ifdef PARAMETRICSTEREO + +#include "s_sbr_channel.h" +#include "aac_mem_funcs.h" +#include "ps_hybrid_filter_bank_allocation.h" +#include "s_ps_dec.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_allocate_decoder.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define R_SHIFT 30 +#define Q30_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const Int32 aRevLinkDelaySer[] = {3, 4, 5}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 ps_allocate_decoder(SBRDECODER_DATA *self, + UInt32 noSubSamples) +{ + Int32 i, j; + Int32 status; + + Int32 *ptr1; + Int32 *ptr2; + Int32 *ptr3; + Int32 *ptr4; + Int32 *ptr5; + Int32 *ptr6; + Int32 *ptr7; + + const Int32 pHybridResolution[] = { HYBRID_8_CPLX, + HYBRID_2_REAL, + HYBRID_2_REAL + }; + + STRUCT_PS_DEC *h_ps_dec = self->hParametricStereoDec; + + /* initialisation */ + h_ps_dec->noSubSamples = noSubSamples; + + h_ps_dec->invNoSubSamples = Q30_fmt(1.0f) / noSubSamples; + + /* + * Reuse AAC+ HQ right channel, which is not used when PS is enabled + */ + ptr1 = (Int32 *)(self->SbrChannel[1].frameData.codecQmfBufferReal[0]); /* reuse un-used right channel QMF_FILTER Synthesis buffer */ + + ptr2 = (&ptr1[658]); /* reuse un-used right channel QMF_FILTER Synthesis buffer */ + /* 1162 - 658 = 504 + * = NO_QMF_ALLPASS_CHANNELS*2 (Re&Im)*( 3 + 4 + 5) + ( 3 + 4 + 5)*2 (Re&Im) + */ + + ptr3 = (&ptr1[1162]); /* reuse un-used right channel QMF_FILTER Synthesis buffer */ + /* 1426 - 1162 = 264 + * = SUBQMF_GROUPS*2 (Re&Im)*( 3 + 4 + 5) + ( 3 + 4 + 5)*2 (Re&Im) + */ + + ptr4 = (&ptr1[1426]); /* high freq generation buffers */ + + ptr5 = (&ptr1[1490]); /* high freq generation buffers */ + + ptr6 = (&ptr1[1618]); /* high freq generation buffers */ + + ptr7 = (&ptr1[1810]); /* high freq generation buffers */ + + /* whole allocation requires 1871 words, sbrQmfBufferImag has 1920 words */ + + + h_ps_dec->aPeakDecayFast = ptr1; + ptr1 += NO_BINS; + + h_ps_dec->aPrevNrg = ptr1; + ptr1 += NO_BINS; + + h_ps_dec->aPrevPeakDiff = ptr1; + ptr1 += NO_BINS; + + + + status = ps_hybrid_filter_bank_allocation(&h_ps_dec->hHybrid, + NO_QMF_CHANNELS_IN_HYBRID, + pHybridResolution, + &ptr1); + h_ps_dec->mHybridRealLeft = ptr1; + ptr1 += SUBQMF_GROUPS; + + h_ps_dec->mHybridImagLeft = ptr1; + ptr1 += SUBQMF_GROUPS; + + h_ps_dec->mHybridRealRight = ptr1; + ptr1 += SUBQMF_GROUPS; + + h_ps_dec->mHybridImagRight = ptr1; + ptr1 += SUBQMF_GROUPS; + + + h_ps_dec->delayBufIndex = 0; + + + + for (i = 0 ; i < NO_DELAY_CHANNELS ; i++) /* 41 */ + { + if (i < SHORT_DELAY_START) /* 12 */ + { + h_ps_dec->aNoSampleDelay[i] = LONG_DELAY; + } + else + { + h_ps_dec->aNoSampleDelay[i] = SHORT_DELAY; + } + } + + + h_ps_dec->aaRealDelayBufferQmf = (Int32 **)ptr6; + ptr6 += NO_QMF_ICC_CHANNELS * sizeof(Int32 *) / sizeof(Int32); + + h_ps_dec->aaImagDelayBufferQmf = (Int32 **)ptr7; + ptr7 += NO_QMF_ICC_CHANNELS * sizeof(Int32 *) / sizeof(Int32); + + h_ps_dec->aaRealDelayBufferSubQmf = (Int32 **)ptr1; + ptr1 += SUBQMF_GROUPS * sizeof(Int32 *) / sizeof(Int32); + + h_ps_dec->aaImagDelayBufferSubQmf = (Int32 **)ptr1; + ptr1 += SUBQMF_GROUPS * sizeof(Int32 *) / sizeof(Int32); + + for (i = 0; i < NO_QMF_ICC_CHANNELS; i++) /* 61 */ + { + int delay; + + if (i < NO_QMF_ALLPASS_CHANNELS) /* 20 */ + { + delay = 2; + h_ps_dec->aaRealDelayBufferQmf[i] = (Int32 *)ptr4; + ptr4 += delay; + + h_ps_dec->aaImagDelayBufferQmf[i] = (Int32 *)ptr5; + ptr5 += delay; + } + else + { + + if (i >= (NO_QMF_ALLPASS_CHANNELS + SHORT_DELAY_START)) + { + delay = SHORT_DELAY; + } + else + { + delay = LONG_DELAY; + } + + h_ps_dec->aaRealDelayBufferQmf[i] = (Int32 *)ptr1; + ptr1 += delay; + + h_ps_dec->aaImagDelayBufferQmf[i] = (Int32 *)ptr1; + ptr1 += delay; + } + } + + for (i = 0; i < SUBQMF_GROUPS; i++) + { + h_ps_dec->aaRealDelayBufferSubQmf[i] = (Int32 *)ptr1; + ptr1 += DELAY_ALLPASS; + + h_ps_dec->aaImagDelayBufferSubQmf[i] = (Int32 *)ptr1; + ptr1 += DELAY_ALLPASS; + + } + + for (i = 0 ; i < NO_SERIAL_ALLPASS_LINKS ; i++) /* NO_SERIAL_ALLPASS_LINKS == 3 */ + { + + h_ps_dec->aDelayRBufIndexSer[i] = 0; + + h_ps_dec->aaaRealDelayRBufferSerQmf[i] = (Int32 **)ptr2; + ptr2 += aRevLinkDelaySer[i]; + + h_ps_dec->aaaImagDelayRBufferSerQmf[i] = (Int32 **)ptr2; + ptr2 += aRevLinkDelaySer[i]; + + h_ps_dec->aaaRealDelayRBufferSerSubQmf[i] = (Int32 **)ptr3; + ptr3 += aRevLinkDelaySer[i]; + + h_ps_dec->aaaImagDelayRBufferSerSubQmf[i] = (Int32 **)ptr3; + ptr3 += aRevLinkDelaySer[i]; + + for (j = 0; j < aRevLinkDelaySer[i]; j++) + { + h_ps_dec->aaaRealDelayRBufferSerQmf[i][j] = ptr2; + ptr2 += NO_QMF_ALLPASS_CHANNELS; /* NO_QMF_ALLPASS_CHANNELS == 20 */ + + h_ps_dec->aaaImagDelayRBufferSerQmf[i][j] = ptr2; + ptr2 += NO_QMF_ALLPASS_CHANNELS; + + h_ps_dec->aaaRealDelayRBufferSerSubQmf[i][j] = ptr3; + ptr3 += SUBQMF_GROUPS; + + h_ps_dec->aaaImagDelayRBufferSerSubQmf[i][j] = ptr3; + ptr3 += SUBQMF_GROUPS; + + } + } + + + for (i = 0; i < NO_IID_GROUPS; i++) /* NO_IID_GROUPS == 22 */ + { + h_ps_dec->h11Prev[i] = Q30_fmt(1.0f); + h_ps_dec->h12Prev[i] = Q30_fmt(1.0f); + } + + + + return status; +} /*END CreatePsDec*/ +#endif + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.h new file mode 100644 index 0000000..db3f470 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_allocate_decoder.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_allocate_decoder() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_ALLOCATE_DECODER_H +#define PS_ALLOCATE_DECODER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int32 ps_allocate_decoder(SBRDECODER_DATA *self, + UInt32 noSubSamples); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_ALLOCATE_DECODER_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_applied.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_applied.cpp new file mode 100644 index 0000000..07271cb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_applied.cpp @@ -0,0 +1,209 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_applied.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Applies Parametric Stereo Tool to a QMF-analized mono signal + providing a stereo image as output + + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO +#include "aac_mem_funcs.h" +#include "ps_stereo_processing.h" +#include "ps_decorrelate.h" +#include "ps_hybrid_synthesis.h" +#include "ps_hybrid_analysis.h" +#include "ps_applied.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ps_applied(STRUCT_PS_DEC *h_ps_dec, + Int32 rIntBufferLeft[][64], + Int32 iIntBufferLeft[][64], + Int32 *rIntBufferRight, + Int32 *iIntBufferRight, + Int32 scratch_mem[], + Int32 band) + +{ + + /* + * Get higher frequency resolution in the lower QMF subbands + * creating sub-subbands + */ + ps_hybrid_analysis(rIntBufferLeft, + iIntBufferLeft, + h_ps_dec->mHybridRealLeft, + h_ps_dec->mHybridImagLeft, + h_ps_dec->hHybrid, + scratch_mem, + band); + + /* + * By means of delaying and all-pass filtering, sub-subbands of + * left ch. are decorrelate to creates right ch. sub-subbands + */ + + ps_decorrelate(h_ps_dec, + *rIntBufferLeft, + *iIntBufferLeft, + rIntBufferRight, + iIntBufferRight, + scratch_mem); + + /* + * sub-subbands of left and right ch. are processed according to + * stereo clues. + */ + + ps_stereo_processing(h_ps_dec, + *rIntBufferLeft, + *iIntBufferLeft, + rIntBufferRight, + iIntBufferRight); + + /* + * Reconstruct stereo signals + */ + + ps_hybrid_synthesis((const Int32*)h_ps_dec->mHybridRealLeft, + (const Int32*)h_ps_dec->mHybridImagLeft, + *rIntBufferLeft, + *iIntBufferLeft, + h_ps_dec->hHybrid); + + ps_hybrid_synthesis((const Int32*)h_ps_dec->mHybridRealRight, + (const Int32*)h_ps_dec->mHybridImagRight, + rIntBufferRight, + iIntBufferRight, + h_ps_dec->hHybrid); + +}/* END ps_applied */ +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_applied.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_applied.h new file mode 100644 index 0000000..66e5d6c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_applied.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_applied.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions ps_applied() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_APPLIED_H +#define PS_APPLIED_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_applied(STRUCT_PS_DEC *h_ps_dec, + Int32 rIntBufferLeft[][64], + Int32 iIntBufferLeft[][64], + Int32 *rIntBufferRight, + Int32 *iIntBufferRight, + Int32 scratch_mem[], + Int32 band); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_APPLIED_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.cpp new file mode 100644 index 0000000..bfcab02 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.cpp @@ -0,0 +1,297 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_bstr_decoding.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decodes parametric stereo + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "aac_mem_funcs.h" +#include "ps_bstr_decoding.h" +#include "ps_decode_bs_utils.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const Int32 aNoIidBins[3] = {NO_LOW_RES_IID_BINS, NO_IID_BINS, NO_HI_RES_BINS}; +const Int32 aNoIccBins[3] = {NO_LOW_RES_ICC_BINS, NO_ICC_BINS, NO_HI_RES_BINS}; +const Int32 aFixNoEnvDecode[4] = {0, 1, 2, 4}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ps_bstr_decoding(STRUCT_PS_DEC *ps_dec) +{ + UInt32 env; + Int32 noIidSteps; + + if (!ps_dec->bPsDataAvail) + { + ps_dec->noEnv = 0; + } + + noIidSteps = ps_dec->bFineIidQ ? NO_IID_STEPS_FINE : NO_IID_STEPS; + + for (env = 0; env < ps_dec->noEnv; env++) + { + Int32 *aPrevIidIndex; + Int32 *aPrevIccIndex; + if (env == 0) + { + aPrevIidIndex = ps_dec->aIidPrevFrameIndex; + aPrevIccIndex = ps_dec->aIccPrevFrameIndex; + } + else + { + aPrevIidIndex = ps_dec->aaIidIndex[env-1]; + aPrevIccIndex = ps_dec->aaIccIndex[env-1]; + } + + /* + * Differential Decoding of IID parameters over time/frequency + */ + differential_Decoding(ps_dec->bEnableIid, + ps_dec->aaIidIndex[env], + aPrevIidIndex, + ps_dec->abIidDtFlag[env], + aNoIidBins[ps_dec->freqResIid], + (ps_dec->freqResIid) ? 1 : 2, + -noIidSteps, + noIidSteps); + + /* + * Differential Decoding of ICC parameters over time/frequency + */ + differential_Decoding(ps_dec->bEnableIcc, + ps_dec->aaIccIndex[env], + aPrevIccIndex, + ps_dec->abIccDtFlag[env], + aNoIccBins[ps_dec->freqResIcc], + (ps_dec->freqResIcc) ? 1 : 2, + 0, + NO_ICC_STEPS - 1); + + + } /* for (env=0; envnoEnv; env++) */ + + if (ps_dec->noEnv == 0) + { + ps_dec->noEnv = 1; + + if (ps_dec->bEnableIid) + { /* NO_HI_RES_BINS == 34 */ + pv_memmove(ps_dec->aaIidIndex[ps_dec->noEnv-1], + ps_dec->aIidPrevFrameIndex, + NO_HI_RES_BINS*sizeof(*ps_dec->aIidPrevFrameIndex)); + + } + else + { + pv_memset((void *)ps_dec->aaIidIndex[ps_dec->noEnv-1], + 0, + NO_HI_RES_BINS*sizeof(**ps_dec->aaIidIndex)); + } + if (ps_dec->bEnableIcc) + { + pv_memmove(ps_dec->aaIccIndex[ps_dec->noEnv-1], + ps_dec->aIccPrevFrameIndex, + NO_HI_RES_BINS*sizeof(*ps_dec->aIccPrevFrameIndex)); + } + else + { + pv_memset((void *)ps_dec->aaIccIndex[ps_dec->noEnv-1], + 0, + NO_HI_RES_BINS*sizeof(**ps_dec->aaIccIndex)); + } + } + + pv_memmove(ps_dec->aIidPrevFrameIndex, + ps_dec->aaIidIndex[ps_dec->noEnv-1], + NO_HI_RES_BINS*sizeof(*ps_dec->aIidPrevFrameIndex)); + + pv_memmove(ps_dec->aIccPrevFrameIndex, + ps_dec->aaIccIndex[ps_dec->noEnv-1], + NO_HI_RES_BINS*sizeof(*ps_dec->aIccPrevFrameIndex)); + + ps_dec->bPsDataAvail = 0; + + if (ps_dec->bFrameClass == 0) + { + Int32 shift; + + shift = ps_dec->noEnv >> 1; + + ps_dec->aEnvStartStop[0] = 0; + + for (env = 1; env < ps_dec->noEnv; env++) + { + ps_dec->aEnvStartStop[env] = + (env * ps_dec->noSubSamples) >> shift; + } + + ps_dec->aEnvStartStop[ps_dec->noEnv] = ps_dec->noSubSamples; + } + else + { /* if (ps_dec->bFrameClass != 0) */ + ps_dec->aEnvStartStop[0] = 0; + + if (ps_dec->aEnvStartStop[ps_dec->noEnv] < ps_dec->noSubSamples) + { + ps_dec->noEnv++; + ps_dec->aEnvStartStop[ps_dec->noEnv] = ps_dec->noSubSamples; + + pv_memmove(ps_dec->aaIidIndex[ps_dec->noEnv], + ps_dec->aaIidIndex[ps_dec->noEnv-1], + NO_HI_RES_BINS*sizeof(**ps_dec->aaIidIndex)); + + pv_memmove(ps_dec->aaIccIndex[ps_dec->noEnv], + ps_dec->aaIccIndex[ps_dec->noEnv-1], + NO_HI_RES_BINS*sizeof(**ps_dec->aaIccIndex)); + } + + for (env = 1; env < ps_dec->noEnv; env++) + { + UInt32 thr; + thr = ps_dec->noSubSamples - ps_dec->noEnv + env; + + if (ps_dec->aEnvStartStop[env] > thr) + { + ps_dec->aEnvStartStop[env] = thr; + } + else + { + thr = ps_dec->aEnvStartStop[env-1] + 1; + + if (ps_dec->aEnvStartStop[env] < thr) + { + ps_dec->aEnvStartStop[env] = thr; + } + } + } + } /* if (ps_dec->bFrameClass == 0) ... else */ + + for (env = 0; env < ps_dec->noEnv; env++) + { + if (ps_dec->freqResIid == 2) + { + map34IndexTo20(ps_dec->aaIidIndex[env]); + } + if (ps_dec->freqResIcc == 2) + { + map34IndexTo20(ps_dec->aaIccIndex[env]); + } + } + + +} + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.h new file mode 100644 index 0000000..e68ace9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_bstr_decoding.h +j +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions ps_bstr_decoding() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_BSTR_DECODING_H +#define PS_BSTR_DECODING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const Int32 aNoIidBins[3]; +extern const Int32 aNoIccBins[3]; + +extern const Int32 aFixNoEnvDecode[4]; + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_bstr_decoding(STRUCT_PS_DEC *h_ps_dec); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_BSTR_DECODING_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_channel_filtering.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_channel_filtering.cpp new file mode 100644 index 0000000..033592f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_channel_filtering.cpp @@ -0,0 +1,274 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_channel_filtering.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Does Hybrid analysis + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "s_hybrid.h" +#include "aac_mem_funcs.h" +#include "ps_fft_rx8.h" +#include "ps_channel_filtering.h" +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define R_SHIFT 29 +#define Q29_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt31(a) (Int32)(-a*((Int32)1<<31) + (a>=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void two_ch_filtering(const Int32 *pQmf_r, + const Int32 *pQmf_i, + Int32 *mHybrid_r, + Int32 *mHybrid_i) +{ + + Int32 cum0; + Int32 cum1; + Int32 cum2; + Int32 tmp1; + Int32 tmp2; + + tmp1 = pQmf_r[ 1] + pQmf_r[11]; + tmp2 = pQmf_i[ 1] + pQmf_i[11]; + cum1 = fxp_mul32_Q31(Qfmt31(0.03798975052098f), tmp1); + cum2 = fxp_mul32_Q31(Qfmt31(0.03798975052098f), tmp2); + tmp1 = pQmf_r[ 3] + pQmf_r[ 9]; + tmp2 = pQmf_i[ 3] + pQmf_i[ 9]; + cum1 = fxp_msu32_Q31(cum1, Qfmt31(0.14586278335076f), tmp1); + cum2 = fxp_msu32_Q31(cum2, Qfmt31(0.14586278335076f), tmp2); + tmp1 = pQmf_r[ 5] + pQmf_r[ 7]; + tmp2 = pQmf_i[ 5] + pQmf_i[ 7]; + cum1 = fxp_mac32_Q31(cum1, Qfmt31(0.61193261090336f), tmp1); + cum2 = fxp_mac32_Q31(cum2, Qfmt31(0.61193261090336f), tmp2); + + cum0 = pQmf_r[HYBRID_FILTER_DELAY] >> 1; /* HYBRID_FILTER_DELAY == 6 */ + + mHybrid_r[0] = (cum0 + cum1); + mHybrid_r[1] = (cum0 - cum1); + + cum0 = pQmf_i[HYBRID_FILTER_DELAY] >> 1; /* HYBRID_FILTER_DELAY == 6 */ + + mHybrid_i[0] = (cum0 + cum2); + mHybrid_i[1] = (cum0 - cum2); + +} + + + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void eight_ch_filtering(const Int32 *pQmfReal, + const Int32 *pQmfImag, + Int32 *mHybridReal, + Int32 *mHybridImag, + Int32 scratch_mem[]) + +{ + + Int32 real; + Int32 imag; + Int32 tmp1; + Int32 tmp2; + + real = fxp_mul32_Q29(Q29_fmt(-0.06989827306334f), pQmfReal[ 4]); + + real = fxp_mac32_Q31(real, Qfmt31(0.01055120626280f), pQmfReal[12]); + imag = fxp_mul32_Q29(Q29_fmt(-0.06989827306334f), pQmfImag[ 4]); + + imag = fxp_mac32_Q31(imag, Qfmt31(0.01055120626280f), pQmfImag[12]); + + mHybridReal[2] = (imag - real); + mHybridImag[2] = -(imag + real); + + real = fxp_mul32_Q29(Q29_fmt(-0.07266113929591f), pQmfReal[ 3]); + + real = fxp_mac32_Q31(real, Qfmt31(0.04540841899650f), pQmfReal[11]); + imag = fxp_mul32_Q29(Q29_fmt(-0.07266113929591f), pQmfImag[ 3]); + + imag = fxp_mac32_Q31(imag, Qfmt31(0.04540841899650f), pQmfImag[11]); + + tmp1 = fxp_mul32_Q29(Q29_fmt(-0.38268343236509f), real); + mHybridReal[3] = fxp_mac32_Q29(Q29_fmt(0.92387953251129f), imag, tmp1); + tmp2 = fxp_mul32_Q29(Q29_fmt(-0.92387953251129f), real); + mHybridImag[3] = fxp_mac32_Q29(Q29_fmt(-0.38268343236509f), imag, tmp2); + + + mHybridImag[4] = fxp_mul32_Q31(Qfmt31(0.09093731860946f), (pQmfReal[ 2] - pQmfReal[10])); + mHybridReal[4] = fxp_mul32_Q31(Qfmt31(0.09093731860946f), (pQmfImag[10] - pQmfImag[ 2])); + + + real = fxp_mul32_Q29(Q29_fmt(-0.02270420949825f), pQmfReal[ 1]); + + real = fxp_mac32_Q31(real, Qfmt31(0.14532227859182f), pQmfReal[ 9]); + imag = fxp_mul32_Q29(Q29_fmt(-0.02270420949825f), pQmfImag[ 1]); + + imag = fxp_mac32_Q31(imag, Qfmt31(0.14532227859182f), pQmfImag[ 9]); + + tmp1 = fxp_mul32_Q29(Q29_fmt(0.92387953251129f), imag); + + mHybridReal[5] = fxp_mac32_Q31(tmp1, Qfmt31(0.76536686473018f), real); + tmp2 = fxp_mul32_Q29(Q29_fmt(-0.92387953251129f), real); + + mHybridImag[5] = fxp_mac32_Q31(tmp2, Qfmt31(0.76536686473018f), imag); + + real = fxp_mul32_Q29(Q29_fmt(-0.00527560313140f), pQmfReal[ 0]); + + real = fxp_mac32_Q31(real, Qfmt31(0.13979654612668f), pQmfReal[ 8]); + imag = fxp_mul32_Q29(Q29_fmt(-0.00527560313140f), pQmfImag[ 0]); + + imag = fxp_mac32_Q31(imag, Qfmt31(0.13979654612668f), pQmfImag[ 8]); + + mHybridReal[6] = (imag + real); + mHybridImag[6] = (imag - real); + + + tmp1 = fxp_mul32_Q31(Qfmt31(0.21791935610828f), pQmfReal[ 7]); + mHybridReal[7] = fxp_mac32_Q31(tmp1, Qfmt31(0.09026515280366f), pQmfImag[ 7]); + + tmp2 = fxp_mul32_Q29(Q29_fmt(-0.04513257640183f), pQmfReal[ 7]); + + mHybridImag[7] = fxp_mac32_Q31(tmp2, Qfmt31(0.21791935610828f), pQmfImag[ 7]); + + mHybridReal[0] = pQmfReal[HYBRID_FILTER_DELAY] >> 3; + mHybridImag[0] = pQmfImag[HYBRID_FILTER_DELAY] >> 3; + + tmp1 = fxp_mul32_Q29(Q29_fmt(-0.04513257640183f), pQmfImag[ 5]); + + mHybridReal[1] = fxp_mac32_Q31(tmp1, Qfmt31(0.21791935610828f), pQmfReal[ 5]); + + + tmp2 = fxp_mul32_Q31(Qfmt31(0.21791935610828f), pQmfImag[ 5]); + mHybridImag[1] = fxp_mac32_Q31(tmp2, Qfmt31(0.09026515280366f), pQmfReal[ 5]); + + /* + * 8*ifft + */ + + ps_fft_rx8(mHybridReal, mHybridImag, scratch_mem); + +} + + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_channel_filtering.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_channel_filtering.h new file mode 100644 index 0000000..94c3615 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_channel_filtering.h @@ -0,0 +1,98 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_channel_filtering.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions two_ch_filtering() + and eight_ch_filtering() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_CHANNEL_FILTERING_H +#define PS_CHANNEL_FILTERING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void two_ch_filtering(const Int32 *pQmf_r, + const Int32 *pQmf_i, + Int32 *mHybrid_r, + Int32 *mHybrid_i); + + + void eight_ch_filtering(const Int32 *pQmfReal, + const Int32 *pQmfImag, + Int32 *mHybridReal, + Int32 *mHybridImag, + Int32 scratch_mem[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_CHANNEL_FILTERING_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_constants.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_constants.h new file mode 100644 index 0000000..d5b2ad4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_constants.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/**************************************************************************** +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. +*******************************************************************************/ +/* +*/ +#ifndef PS_CONSTANTS_H +#define PS_CONSTANTS_H + + +#define NO_SUB_QMF_CHANNELS 12 +#define NO_QMF_CHANNELS_IN_HYBRID 3 +#define NO_QMF_CHANNELS 64 +#define NO_ALLPASS_CHANNELS 23 +#define NO_DELAY_CHANNELS (NO_QMF_CHANNELS-NO_ALLPASS_CHANNELS) +#define DELAY_ALLPASS 2 +#define SHORT_DELAY_START 12 +#define SHORT_DELAY 1 +#define LONG_DELAY 14 +#define NO_QMF_ALLPASS_CHANNELS (NO_ALLPASS_CHANNELS-NO_QMF_CHANNELS_IN_HYBRID) +#define NO_QMF_ICC_CHANNELS (NO_QMF_ALLPASS_CHANNELS+NO_DELAY_CHANNELS) +#define HYBRIDGROUPS 8 +#define DECAY_CUTOFF 3 +#define NO_SERIAL_ALLPASS_LINKS 3 +#define MAX_NO_PS_ENV 5 +#define NEGATE_IPD_MASK ( 0x00001000 ) +#define NO_BINS ( 20 ) +#define NO_HI_RES_BINS ( 34 ) +#define NO_LOW_RES_BINS ( NO_IID_BINS / 2 ) +#define NO_IID_BINS ( NO_BINS ) +#define NO_ICC_BINS ( NO_BINS ) +#define NO_LOW_RES_IID_BINS ( NO_LOW_RES_BINS ) +#define NO_LOW_RES_ICC_BINS ( NO_LOW_RES_BINS ) +#define SUBQMF_GROUPS ( 10 ) +#define QMF_GROUPS ( 12 ) +#define NO_IID_GROUPS ( SUBQMF_GROUPS + QMF_GROUPS ) +#define NO_IID_STEPS ( 7 ) +#define NO_IID_STEPS_FINE ( 15 ) +#define NO_ICC_STEPS ( 8 ) +#define NO_IID_LEVELS ( 2 * NO_IID_STEPS + 1 ) +#define NO_IID_LEVELS_FINE ( 2 * NO_IID_STEPS_FINE + 1 ) +#define NO_ICC_LEVELS ( NO_ICC_STEPS ) + + + +#endif /* PS_CONSTANTS_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.cpp new file mode 100644 index 0000000..8bcc779 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.cpp @@ -0,0 +1,267 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_decode_bs_utils.cpp + + Functions: + GetNrBitsAvailable + differential_Decoding + map34IndexTo20 + limitMinMax + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decode bitstream parametric stereo's utilities + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "aac_mem_funcs.h" +#include "s_ps_dec.h" +#include "ps_decode_bs_utils.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 GetNrBitsAvailable(HANDLE_BIT_BUFFER hBitBuf) +{ + + return (hBitBuf->bufferLen - hBitBuf->nrBitsRead); +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +; +; Differential Decoding of parameters over time/frequency +----------------------------------------------------------------------------*/ + +void differential_Decoding(Int32 enable, + Int32 *aIndex, + Int32 *aPrevFrameIndex, + Int32 DtDf, + Int32 nrElements, + Int32 stride, + Int32 minIdx, + Int32 maxIdx) +{ + Int32 i; + Int32 *ptr_aIndex; + + if (enable == 1) + { + ptr_aIndex = aIndex; + + if (DtDf == 0) + { + *(ptr_aIndex) = limitMinMax(*ptr_aIndex, minIdx, maxIdx); + ptr_aIndex++; + + for (i = 1; i < nrElements; i++) + { + *(ptr_aIndex) = limitMinMax(aIndex[i-1] + *ptr_aIndex, minIdx, maxIdx); + ptr_aIndex++; + } + } + else + { + if (stride == 1) + { + for (i = 0; i < nrElements; i++) + { + *(ptr_aIndex) = limitMinMax(aPrevFrameIndex[i] + *ptr_aIndex, minIdx, maxIdx); + ptr_aIndex++; + } + } + else + { + for (i = 0; i < nrElements; i++) + { + *(ptr_aIndex) = limitMinMax(aPrevFrameIndex[(i<<1)] + *ptr_aIndex, minIdx, maxIdx); + ptr_aIndex++; + } + } + } + } + else + { + pv_memset((void *)aIndex, 0, nrElements*sizeof(*aIndex)); + } + if (stride == 2) + { + for (i = (nrElements << 1) - 1; i > 0; i--) + { + aIndex[i] = aIndex[(i>>1)]; + } + } +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE + map34IndexTo20 +----------------------------------------------------------------------------*/ + +void map34IndexTo20(Int32 *aIndex) +{ + + aIndex[ 0] = ((aIndex[0] << 1) + aIndex[1]) / 3; + aIndex[ 1] = (aIndex[1] + (aIndex[2] << 1)) / 3; + aIndex[ 2] = ((aIndex[3] << 1) + aIndex[4]) / 3; + aIndex[ 3] = (aIndex[4] + (aIndex[5] << 1)) / 3; + aIndex[ 4] = (aIndex[ 6] + aIndex[7]) >> 1; + aIndex[ 5] = (aIndex[ 8] + aIndex[9]) >> 1; + aIndex[ 6] = aIndex[10]; + aIndex[ 7] = aIndex[11]; + aIndex[ 8] = (aIndex[12] + aIndex[13]) >> 1; + aIndex[ 9] = (aIndex[14] + aIndex[15]) >> 1; + aIndex[10] = aIndex[16]; + aIndex[11] = aIndex[17]; + aIndex[12] = aIndex[18]; + aIndex[13] = aIndex[19]; + aIndex[14] = (aIndex[20] + aIndex[21]) >> 1; + aIndex[15] = (aIndex[22] + aIndex[23]) >> 1; + aIndex[16] = (aIndex[24] + aIndex[25]) >> 1; + aIndex[17] = (aIndex[26] + aIndex[27]) >> 1; + aIndex[18] = (aIndex[28] + aIndex[29] + aIndex[30] + aIndex[31]) >> 2; + aIndex[19] = (aIndex[32] + aIndex[33]) >> 1; +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE + limitMinMax +----------------------------------------------------------------------------*/ + + +Int32 limitMinMax(Int32 i, + Int32 min, + Int32 max) +{ + if (i < max) + { + if (i > min) + { + return i; + } + else + { + return min; + } + } + else + { + return max; + } +} + + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.h new file mode 100644 index 0000000..188d9a9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.h @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_decode_bs_utils.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions differential_Decoding(), limitMinMax(), + GetNrBitsAvailable(), map34IndexTo20() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_DECODE_BS_UTILS_H +#define PS_DECODE_BS_UTILS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" +#include "s_bit_buffer.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void differential_Decoding(Int32 enable, + Int32 *aIndex, + Int32 *aPrevFrameIndex, + Int32 DtDf, + Int32 nrElements, + Int32 stride, + Int32 minIdx, + Int32 maxIdx); + + Int32 limitMinMax(Int32 i, + Int32 min, + Int32 max); + + Int32 GetNrBitsAvailable(HANDLE_BIT_BUFFER hBitBuf); + + void map34IndexTo20(Int32 *aIndex); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_DECODE_BS_UTILS_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decorrelate.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decorrelate.cpp new file mode 100644 index 0000000..63d2648 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decorrelate.cpp @@ -0,0 +1,492 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_decorrelate.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decorrelation + Decorrelation is achieved by means of all-pass filtering and delaying + Sub-band samples s_k(n) are converted into de-correlated sub-bands samples + d_k(n). k index for frequency, n time index + + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + + Delay is introduced to compensate QMF bands not passed through Hybrid + Analysis + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO +#include "pv_audio_type_defs.h" +#include "ps_decorrelate.h" +#include "aac_mem_funcs.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_pwr_transient_detection.h" +#include "ps_all_pass_fract_delay_filter.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void ps_decorrelate(STRUCT_PS_DEC *h_ps_dec, + Int32 *rIntBufferLeft, + Int32 *iIntBufferLeft, + Int32 *rIntBufferRight, + Int32 *iIntBufferRight, + Int32 scratch_mem[]) +{ + Int32 sb; + Int32 maxsb; + Int32 gr; + Int32 sb_delay; + Int32 bin; + + + + + Int32 *aLeftReal; + Int32 *aLeftImag; + Int32 *aRightReal; + Int32 *aRightImag; + + Int32 *aTransRatio = scratch_mem; /* use NO_BINS == 20 */ + + + Int32 ***pppRealDelayRBufferSer; + Int32 ***pppImagDelayRBufferSer; + + Int32 **ppRealDelayBuffer; + Int32 **ppImagDelayBuffer; + + const Int32(*ppFractDelayPhaseFactorSer)[3]; + /* + * Power transient estimation and detection + */ + + + ps_pwr_transient_detection(h_ps_dec, + rIntBufferLeft, + iIntBufferLeft, + aTransRatio); + + + aLeftReal = h_ps_dec->mHybridRealLeft; + aLeftImag = h_ps_dec->mHybridImagLeft; + aRightReal = h_ps_dec->mHybridRealRight; + aRightImag = h_ps_dec->mHybridImagRight; + + pppRealDelayRBufferSer = h_ps_dec->aaaRealDelayRBufferSerSubQmf; + pppImagDelayRBufferSer = h_ps_dec->aaaImagDelayRBufferSerSubQmf; + + ppRealDelayBuffer = h_ps_dec->aaRealDelayBufferSubQmf; + ppImagDelayBuffer = h_ps_dec->aaImagDelayBufferSubQmf; + + + + ppFractDelayPhaseFactorSer = aaFractDelayPhaseFactorSerSubQmf; + + + /* + * NO_IID_GROUPS (SUBQMF_GROUPS (12) + QMF_GROUPS (10)) == 22 + */ + + for (gr = 0; gr < SUBQMF_GROUPS; gr++) /* 0 to 9 */ + { + Int32 rIn; + Int32 iIn; + Int32 *pt_rTmp; + Int32 *pt_iTmp; + Int32 rTmp; + Int32 cmplx; + Int32 tmp1, tmp2; + + /* sb = subQMF/QMF subband */ + + sb = groupBorders[gr]; + + /* + * For lower subbands + * Apply all-pass filtering + * + */ + pt_rTmp = &ppRealDelayBuffer[sb][h_ps_dec->delayBufIndex]; + pt_iTmp = &ppImagDelayBuffer[sb][h_ps_dec->delayBufIndex]; + + tmp1 = aLeftReal[sb]; + tmp2 = aLeftImag[sb]; + rIn = *pt_rTmp >> 1; + iIn = *pt_iTmp >> 1; + + + *pt_rTmp = tmp1; + *pt_iTmp = tmp2; + + /* + * Fractional delay vector + * + * phi_fract(k) = exp(-j*pi*q_phi*f_center(k)) 0<= k <= SUBQMF_GROUPS + * + * q_phi = 0.39 + * f_center(k) frequency vector + */ + + cmplx = aFractDelayPhaseFactorSubQmf[sb]; + + aRightReal[sb] = cmplx_mul32_by_16(rIn, -iIn, cmplx); + aRightImag[sb] = cmplx_mul32_by_16(iIn, rIn, cmplx); + + ps_all_pass_fract_delay_filter_type_I(h_ps_dec->aDelayRBufIndexSer, + sb, + ppFractDelayPhaseFactorSer[sb], + pppRealDelayRBufferSer, + pppImagDelayRBufferSer, + &aRightReal[sb], + &aRightImag[sb]); + + bin = bins2groupMap[gr]; + rTmp = aTransRatio[bin]; + + if (rTmp != 0x7FFFFFFF) + { + aRightReal[sb] = fxp_mul32_Q31(rTmp, aRightReal[sb]) << 1; + aRightImag[sb] = fxp_mul32_Q31(rTmp, aRightImag[sb]) << 1; + } + + + } /* gr */ + + aLeftReal = rIntBufferLeft; + aLeftImag = iIntBufferLeft; + aRightReal = rIntBufferRight; + aRightImag = iIntBufferRight; + + pppRealDelayRBufferSer = h_ps_dec->aaaRealDelayRBufferSerQmf; + pppImagDelayRBufferSer = h_ps_dec->aaaImagDelayRBufferSerQmf; + + ppRealDelayBuffer = h_ps_dec->aaRealDelayBufferQmf; + ppImagDelayBuffer = h_ps_dec->aaImagDelayBufferQmf; + + + + ppFractDelayPhaseFactorSer = aaFractDelayPhaseFactorSerQmf; + + + for (gr = SUBQMF_GROUPS; gr < NO_BINS; gr++) /* 10 to 20 */ + { + + maxsb = min(h_ps_dec->usb, groupBorders[gr+1]); + + /* sb = subQMF/QMF subband */ + + for (sb = groupBorders[gr]; sb < maxsb; sb++) + { + + Int32 rIn, iIn; + Int32 *pt_rTmp, *pt_iTmp; + Int32 cmplx; + Int32 tmp1, tmp2; + Int32 rTmp; + + + sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID; /* NO_QMF_CHANNELS_IN_HYBRID == 3 */ + + /* + * For lower subbands + * Apply all-pass filtering + * + */ + pt_rTmp = &ppRealDelayBuffer[sb_delay][h_ps_dec->delayBufIndex]; + pt_iTmp = &ppImagDelayBuffer[sb_delay][h_ps_dec->delayBufIndex]; + + rIn = *pt_rTmp >> 1; + iIn = *pt_iTmp >> 1; + + tmp1 = aLeftReal[sb]; + tmp2 = aLeftImag[sb]; + *pt_rTmp = tmp1; + *pt_iTmp = tmp2; + + /* + * Fractional delay vector + * + * phi_fract(k) = exp(-j*pi*q_phi*f_center(k)) 0<= k <= SUBQMF_GROUPS + * + * q_phi = 0.39 + * f_center(k) frequency vector + */ + + cmplx = aFractDelayPhaseFactor[sb_delay]; + aRightReal[sb] = cmplx_mul32_by_16(rIn, -iIn, cmplx); + aRightImag[sb] = cmplx_mul32_by_16(iIn, rIn, cmplx); + + ps_all_pass_fract_delay_filter_type_II(h_ps_dec->aDelayRBufIndexSer, + sb_delay, + ppFractDelayPhaseFactorSer[sb_delay], + pppRealDelayRBufferSer, + pppImagDelayRBufferSer, + &aRightReal[sb], + &aRightImag[sb], + sb); + + rTmp = aTransRatio[gr-2]; + if (rTmp != 0x7FFFFFFF) + { + aRightReal[sb] = fxp_mul32_Q31(rTmp, aRightReal[sb]) << 1; + aRightImag[sb] = fxp_mul32_Q31(rTmp, aRightImag[sb]) << 1; + } + + + } /* sb */ + + } + + + maxsb = min(h_ps_dec->usb, 35); /* 35 == groupBorders[NO_BINS + 1] */ + + /* sb = subQMF/QMF subband */ + { + Int32 factor = aTransRatio[NO_BINS-2]; + + for (sb = 23; sb < maxsb; sb++) /* 23 == groupBorders[NO_BINS] */ + { + + Int32 tmp, tmp2; + Int32 *pt_rTmp, *pt_iTmp; + + sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID; /* == 3 */ + + /* + * For the Upper Bands apply delay only + * -D(k) + * Apply Delay H_k(z) = z , D(k) == 1 or 14 + * + */ + Int32 k = sb - NO_ALLPASS_CHANNELS; /* == 23 */ + + + pt_rTmp = &ppRealDelayBuffer[sb_delay][h_ps_dec->aDelayBufIndex[ k]]; + pt_iTmp = &ppImagDelayBuffer[sb_delay][h_ps_dec->aDelayBufIndex[ k]]; + + if (++h_ps_dec->aDelayBufIndex[ k] >= LONG_DELAY) /* == 14 */ + { + h_ps_dec->aDelayBufIndex[ k] = 0; + } + + + tmp = *pt_rTmp; + tmp2 = *pt_iTmp; + + if (aTransRatio[NO_BINS-2] < 0x7FFFFFFF) + { + aRightReal[sb] = fxp_mul32_Q31(factor, tmp) << 1; + aRightImag[sb] = fxp_mul32_Q31(factor, tmp2) << 1; + } + else + { + aRightReal[sb] = tmp; + aRightImag[sb] = tmp2; + } + + + tmp = aLeftReal[sb]; + tmp2 = aLeftImag[sb]; + *pt_rTmp = tmp; + *pt_iTmp = tmp2; + + + } /* sb */ + } + + + maxsb = min(h_ps_dec->usb, 64); /* 64 == groupBorders[NO_BINS+2] */ + + /* sb = subQMF/QMF subband */ + + { + + for (sb = 35; sb < maxsb; sb++) /* 35 == groupBorders[NO_BINS+1] */ + { + + Int32 *pt_rTmp, *pt_iTmp; + + sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID; /* == 3 */ + + /* + * For the Upper Bands apply delay only + * -D(k) + * Apply Delay H_k(z) = z , D(k) == 1 or 14 + * + */ + + pt_rTmp = &ppRealDelayBuffer[sb_delay][0]; + pt_iTmp = &ppImagDelayBuffer[sb_delay][0]; + + aRightReal[sb] = *pt_rTmp; + aRightImag[sb] = *pt_iTmp; + + + if (aTransRatio[NO_BINS-1] < 0x7FFFFFFF) + { + aRightReal[sb] = fxp_mul32_Q31(aTransRatio[NO_BINS-1], aRightReal[sb]) << 1; + aRightImag[sb] = fxp_mul32_Q31(aTransRatio[NO_BINS-1], aRightImag[sb]) << 1; + } + + *pt_rTmp = aLeftReal[sb]; + *pt_iTmp = aLeftImag[sb]; + + + } /* sb */ + } + + + if (++h_ps_dec->delayBufIndex >= DELAY_ALLPASS) + { + h_ps_dec->delayBufIndex = 0; + } + + if (++h_ps_dec->aDelayRBufIndexSer[0] >= 3) + { + h_ps_dec->aDelayRBufIndexSer[0] = 0; + } + if (++h_ps_dec->aDelayRBufIndexSer[1] >= 4) + { + h_ps_dec->aDelayRBufIndexSer[1] = 0; + } + if (++h_ps_dec->aDelayRBufIndexSer[2] >= 5) + { + h_ps_dec->aDelayRBufIndexSer[2] = 0; + } + + +} /* END deCorrelate */ +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decorrelate.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decorrelate.h new file mode 100644 index 0000000..550195b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_decorrelate.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_decorrelate.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_decorrelate() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_DECORRELATE_H +#define PS_DECORRELATE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_decorrelate(STRUCT_PS_DEC *h_ps_dec, + Int32 *rIntBufferLeft, + Int32 *iIntBufferLeft, + Int32 *rIntBufferRight, + Int32 *iIntBufferRight, + Int32 scratch_mem[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_DECORRELATE_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_fft_rx8.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_fft_rx8.cpp new file mode 100644 index 0000000..83fde10 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_fft_rx8.cpp @@ -0,0 +1,288 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_fft_rx8.cpp + Functions: ps_fft_rx8 + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Real Vector of Real components size 8 + + Imag Vector of Imag components size 8 + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + scratch_mem size 32 + + Outputs: + In-place calculation of a 8-point FFT (radix-8) + + Pointers and Buffers Modified: + calculation are done in-place and returned in Data + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + 8-point DFT, radix 8 with Decimation in Frequency + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should provide a fixed point FFT for any input array + of size power of 8. + +------------------------------------------------------------------------------ + REFERENCES + + [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling, + C. Nikias, Macmillan Pub. Co. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + + MODIFY( x[] ) + RETURN( exponent ) + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#ifdef PARAMETRICSTEREO + + +#include "pv_audio_type_defs.h" +#include "ps_fft_rx8.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define R_SHIFT 29 +#define Q29_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ps_fft_rx8(Int32 Re[], Int32 Im[], Int32 scratch_mem[]) + +/* scratch_mem size 32 */ +{ + + Int i; + Int32 *Q = &scratch_mem[0]; + Int32 *Z = &scratch_mem[16]; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 aux_r[2]; + Int32 aux_i[2]; + Int32 *pt_r1 = &Re[0]; + Int32 *pt_r2 = &Re[4]; + Int32 *pt_i1 = &Im[0]; + Int32 *pt_i2 = &Im[4]; + + Int32 *pt_Q = Q; + Int32 *pt_Z = Z; + + + temp1 = *(pt_r1++); /* Real */ + temp2 = *(pt_r2++); /* Real */ + temp3 = *(pt_i1++); /* Imag */ + temp4 = *(pt_i2++); /* Imag */ + /* + * Vector Q stores data as Real, Imag, Real, Imag,.... + */ + + *(pt_Q++) = temp1 + temp2; /* Q(0) = v(0) + v(4) */ + *(pt_Q++) = temp3 + temp4; + *(pt_Q++) = temp1 - temp2; /* Q(1) = v(0) - v(4) */ + *(pt_Q++) = temp3 - temp4; + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_i1++); + temp4 = *(pt_i2++); + + *(pt_Q++) = temp1 + temp2; /* Q(2) = v(1) + v(5) */ + *(pt_Q++) = temp3 + temp4; + aux_r[0] = temp1 - temp2; /* aux[0] = v(1) - v(5) */ + aux_i[0] = temp3 - temp4; + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_i1++); + temp4 = *(pt_i2++); + + *(pt_Q++) = temp1 + temp2; /* Q(3) = v(2) + v(6) */ + *(pt_Q++) = temp3 + temp4; + *(pt_Q++) = temp4 - temp3; /* Q(4) = (v(2) - v(6))*j */ + *(pt_Q++) = temp1 - temp2; + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_i1++); + temp4 = *(pt_i2++); + + + *(pt_Q++) = temp1 + temp2; /* Q(5) = v(3) + v(7) */ + *(pt_Q++) = temp3 + temp4; + aux_r[1] = temp1 - temp2; /* aux[1] = v(3) - v(7) */ + aux_i[1] = temp3 - temp4; + /* Q(6) = (aux[0] - aux[1])/sqrt(2); */ + *(pt_Q++) = fxp_mul32_Q29((aux_r[0] - aux_r[1]), Q29_fmt(0.70710678118655f)); + *(pt_Q++) = fxp_mul32_Q29((aux_i[0] - aux_i[1]), Q29_fmt(0.70710678118655f)); + + /* Q(7) = (aux[0] + aux[1])*j/sqrt(2); */ + *(pt_Q++) = fxp_mul32_Q29((aux_i[0] + aux_i[1]), Q29_fmt(-0.70710678118655f)); + *(pt_Q) = fxp_mul32_Q29((aux_r[0] + aux_r[1]), Q29_fmt(0.70710678118655f)); + + pt_r1 = &Q[0]; /* reset pointer */ + pt_r2 = &Q[6]; /* reset pointer */ + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_r1++); + temp4 = *(pt_r2++); + + /* + * Vector Z stores data as Real, Imag, Real, Imag,.... + */ + + *(pt_Z++) = temp1 + temp2; /* Q(0) + Q(3) */ + *(pt_Z++) = temp3 + temp4; + aux_r[0] = temp1 - temp2; + aux_i[0] = temp3 - temp4; + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_r1++); + temp4 = *(pt_r2++); + + *(pt_Z++) = temp1 + temp2; /* Q(1) + Q(4) */ + *(pt_Z++) = temp3 + temp4; + *(pt_Z++) = aux_r[0]; /* Q(0) - Q(3) */ + *(pt_Z++) = aux_i[0]; + *(pt_Z++) = temp1 - temp2; /* Q(1) - Q(4) */ + *(pt_Z++) = temp3 - temp4; + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_r1); + temp4 = *(pt_r2++); + + *(pt_Z++) = temp1 + temp2; /* Q(2) + Q(5) */ + *(pt_Z++) = temp3 + temp4; + aux_r[0] = temp1 - temp2; + aux_i[0] = temp3 - temp4; + + temp1 = *(pt_r2++); + temp3 = *(pt_r2++); + temp2 = *(pt_r2++); + temp4 = *(pt_r2); + + *(pt_Z++) = temp1 + temp2; /* Q(6) + Q(7) */ + *(pt_Z++) = temp3 + temp4; + + *(pt_Z++) = -aux_i[0]; /* (Q(2) - Q(5))*j */ + *(pt_Z++) = aux_r[0]; + + *(pt_Z++) = temp2 - temp1; /* -Q(6) + Q(7) */ + *(pt_Z) = temp4 - temp3; + + pt_Z = &Z[0]; /* reset pointer */ + pt_Q = &Z[8]; /* reset pointer */ + + pt_r1 = &Re[0]; + pt_r2 = &Re[4]; + pt_i1 = &Im[0]; + pt_i2 = &Im[4]; + + + for (i = 4; i != 0; i--) + { + temp1 = *(pt_Z++); + temp2 = *(pt_Q++); + temp3 = *(pt_Z++); + temp4 = *(pt_Q++); + + *(pt_r1++) = temp1 + temp2; /* Z(n) + Z(n+4) */ + *(pt_i1++) = temp3 + temp4; + *(pt_r2++) = temp1 - temp2; /* Z(n) - Z(n+4) */ + *(pt_i2++) = temp3 - temp4; + } + +} + +#endif /* PARAMETRICSTEREO */ + + +#endif /* AAC_PLUS */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_fft_rx8.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_fft_rx8.h new file mode 100644 index 0000000..616c216 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_fft_rx8.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_fft_rx8.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions ps_fft_rx8() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_FFT_RX8_H +#define PS_FFT_RX8_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_fft_rx8(Int32 Re[], Int32 Im[], Int32 scratch_mem[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_FFT_RX4_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.cpp new file mode 100644 index 0000000..64d59a8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.cpp @@ -0,0 +1,277 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_analysis.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Does Hybrid analysis: + + Get higher frequency resolution in the lower QMF subbands + creating sub-subbands. This is done by low frequency filtering. + Lower QMF subbands are further split in order to obtain a higher + frequency resolution, enabling a proper stereo analysis and synthesis + for the lower frequencies. + Two hybrid are defined. Both filters have length 13 and a delay of 6. + In this implementation, the symmetry of the filters helps to simplify + the design. + + + Increase Freq. Resolution + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + + + subband k QMF channel + 0 ................. 0 ----------- + 1 ................. 0 + 2 ................. 0 + 3 ................. 0 + 4 ................. 0 + 5 ................. 0 Sub-QMF ( Increase Freq. Resolution) + 6 ................. 1 + 7 ................. 1 + 8 ................. 2 + 9 ................. 2 + 10 ................. 3 ----------- + 11 ................. 4 + 12 ................. 5 + 13 ................. 6 + 14 ................. 7 + 15 ................. 8 QMF + 16-17 ................. 9-10 + 18-20 ................. 11-13 + 21-24 ................. 14-17 + 25-29 ................. 18-22 + 30-41 ................. 23-34 + 42-70 ................. 35-63 ----------- + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "s_hybrid.h" +#include "aac_mem_funcs.h" +#include "ps_channel_filtering.h" +#include "ps_hybrid_analysis.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ps_hybrid_analysis(const Int32 mQmfReal[][64], + const Int32 mQmfImag[][64], + Int32 *mHybridReal, + Int32 *mHybridImag, + HYBRID *pHybrid, + Int32 scratch_mem[], + Int32 i) + +{ + + Int32 band; + HYBRID_RES hybridRes; + Int32 chOffset = 0; + + Int32 *ptr_mHybrid_Re; + Int32 *ptr_mHybrid_Im; + + Int32 *pt_mQmfBufferReal; + Int32 *pt_mQmfBufferImag; + + pt_mQmfBufferReal = &scratch_mem[32 + i]; + + for (band = 0; band < pHybrid->nQmfBands; band++) + { + pt_mQmfBufferImag = pt_mQmfBufferReal + 44; + + + pt_mQmfBufferReal[HYBRID_FILTER_LENGTH_m_1] = mQmfReal[HYBRID_FILTER_DELAY][band]; + pt_mQmfBufferImag[HYBRID_FILTER_LENGTH_m_1] = mQmfImag[HYBRID_FILTER_DELAY][band]; + + + ptr_mHybrid_Re = &mHybridReal[ chOffset]; + ptr_mHybrid_Im = &mHybridImag[ chOffset]; + + hybridRes = (HYBRID_RES)pHybrid->pResolution[band]; + switch (hybridRes) + { + /* + * For QMF band = 1 and 2 + */ + + case HYBRID_2_REAL: + + two_ch_filtering(pt_mQmfBufferReal, + pt_mQmfBufferImag, + ptr_mHybrid_Re, + ptr_mHybrid_Im); + chOffset += 2; + + break; + + /* + * For QMF band = 0 + */ + + case HYBRID_8_CPLX: + + eight_ch_filtering(pt_mQmfBufferReal, + pt_mQmfBufferImag, + pHybrid->mTempReal, + pHybrid->mTempImag, + scratch_mem); + + pv_memmove(ptr_mHybrid_Re, pHybrid->mTempReal, 4*sizeof(*pHybrid->mTempReal)); + + ptr_mHybrid_Re += 2; + + *(ptr_mHybrid_Re++) += pHybrid->mTempReal[5]; + *(ptr_mHybrid_Re++) += pHybrid->mTempReal[4]; + *(ptr_mHybrid_Re++) = pHybrid->mTempReal[6]; + *(ptr_mHybrid_Re) = pHybrid->mTempReal[7]; + + pv_memmove(ptr_mHybrid_Im, pHybrid->mTempImag, 4*sizeof(*pHybrid->mTempImag)); + ptr_mHybrid_Im += 2; + + *(ptr_mHybrid_Im++) += pHybrid->mTempImag[5]; + *(ptr_mHybrid_Im++) += pHybrid->mTempImag[4]; + *(ptr_mHybrid_Im++) = pHybrid->mTempImag[6]; + *(ptr_mHybrid_Im) = pHybrid->mTempImag[7]; + + chOffset += 6; + + break; + + default: + ; + } + + pt_mQmfBufferReal = pt_mQmfBufferImag + 44; + + } + + +} +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.h new file mode 100644 index 0000000..0964d30 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_analysis.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_hybrid_analysis() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_HYBRID_ANALYSIS_H +#define PS_HYBRID_ANALYSIS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_hybrid.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_hybrid_analysis(const Int32 mQmfReal[][64], + const Int32 mQmfImag[][64], + Int32 *mHybridReal, + Int32 *mHybridImag, + HYBRID *pHybrid, + Int32 scratch_mem[], + Int32 band); +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_HYBRID_ANALYSIS_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.cpp new file mode 100644 index 0000000..81006d6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.cpp @@ -0,0 +1,206 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_filter_bank_allocation.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Does Hybrid filter bank memory allocation + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO +#include "aac_mem_funcs.h" +#include "ps_hybrid_filter_bank_allocation.h" +#include "ps_all_pass_filter_coeff.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 ps_hybrid_filter_bank_allocation(HYBRID **phHybrid, + Int32 noBands, + const Int32 *pResolution, + Int32 **pPtr) +{ + Int32 i; + Int32 tmp; + Int32 maxNoChannels = 0; + HYBRID *hs; + Int32 *ptr = *pPtr; + + + *phHybrid = (HYBRID *)NULL; + + hs = (HYBRID *)ptr; + + ptr += sizeof(HYBRID) / sizeof(*ptr); + + hs->pResolution = (Int32*)ptr; + + ptr += noBands * sizeof(Int32) / sizeof(*ptr); + + for (i = 0; i < noBands; i++) + { + + hs->pResolution[i] = pResolution[i]; + + if (pResolution[i] != HYBRID_8_CPLX && + pResolution[i] != HYBRID_2_REAL && + pResolution[i] != HYBRID_4_CPLX) + { + return 1; + } + + if (pResolution[i] > maxNoChannels) + { + maxNoChannels = pResolution[i]; + } + } + + hs->nQmfBands = noBands; + hs->qmfBufferMove = HYBRID_FILTER_LENGTH - 1; + + hs->mQmfBufferReal = (Int32 **)ptr; + ptr += noBands * sizeof(ptr) / sizeof(*ptr); + + hs->mQmfBufferImag = (Int32 **)ptr; + ptr += noBands * sizeof(ptr) / sizeof(*ptr); + + tmp = hs->qmfBufferMove; /* HYBRID_FILTER_LENGTH == 13 */ + + for (i = 0; i < noBands; i++) + { + hs->mQmfBufferReal[i] = ptr; + ptr += tmp; + + hs->mQmfBufferImag[i] = ptr; + ptr += tmp; + + } + + hs->mTempReal = ptr; + ptr += maxNoChannels; + + + hs->mTempImag = ptr; + ptr += maxNoChannels; + + + *phHybrid = hs; + *pPtr = ptr; + + return 0; +} + + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.h new file mode 100644 index 0000000..41691ec --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.h @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_filter_bank_allocation.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for ps_hybrid_filter_bank_allocation + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_HYBRID_FILTER_BANK_ALLOCATION_H +#define PS_HYBRID_FILTER_BANK_ALLOCATION_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_hybrid.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int32 ps_hybrid_filter_bank_allocation(HYBRID **phHybrid, + Int32 noBands, + const Int32 *pResolution, + Int32 **pPtr); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_HYBRID_FILTER_BANK_ALLOCATION_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.cpp new file mode 100644 index 0000000..9b167dc --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.cpp @@ -0,0 +1,185 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_synthesis.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Hybrid synthesis + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "s_hybrid.h" +#include "ps_hybrid_synthesis.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void ps_hybrid_synthesis(const Int32 *mHybridReal, + const Int32 *mHybridImag, + Int32 *mQmfReal, + Int32 *mQmfImag, + HYBRID *hHybrid) +{ + Int32 k; + Int32 band; + HYBRID_RES hybridRes; + + Int32 real; + Int32 imag; + Int32 *ptr_mQmfReal = mQmfReal; + Int32 *ptr_mQmfImag = mQmfImag; + const Int32 *ptr_mHybrid_Re = mHybridReal; + const Int32 *ptr_mHybrid_Im = mHybridImag; + + for (band = 0; band < hHybrid->nQmfBands; band++) + { + hybridRes = (HYBRID_RES)(min(hHybrid->pResolution[band], 6) - 2); + + real = *(ptr_mHybrid_Re++); + real += *(ptr_mHybrid_Re++); + imag = *(ptr_mHybrid_Im++); + imag += *(ptr_mHybrid_Im++); + + for (k = (hybridRes >> 1); k != 0; k--) /* hybridRes = { 2,4,6 } */ + { + real += *(ptr_mHybrid_Re++); + real += *(ptr_mHybrid_Re++); + imag += *(ptr_mHybrid_Im++); + imag += *(ptr_mHybrid_Im++); + } + + *(ptr_mQmfReal++) = real; + *(ptr_mQmfImag++) = imag; + } +} + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.h new file mode 100644 index 0000000..921ce94 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.h @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_synthesis.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_hybrid_synthesis() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_HYBRID_SYNTHESIS_H +#define PS_HYBRID_SYNTHESIS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_hybrid.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_hybrid_synthesis(const Int32 *mHybridReal, + const Int32 *mHybridImag, + Int32 *mQmfReal, + Int32 *mQmfImag, + HYBRID *hHybrid); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_HYBRID_SYNTHESIS_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.cpp new file mode 100644 index 0000000..4e365cb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.cpp @@ -0,0 +1,489 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_init_stereo_mixing.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + initialize mixing procedure type Ra, type Rb is not supported + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" + +#include "aac_mem_funcs.h" +#include "pv_sine.h" +#include "s_ps_dec.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_init_stereo_mixing.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/* +; +; c(b) = 10^(iid(b)/20) +; +; Intensity differences +; +; sqrt(2) +; c_1(b) = ---------------- +; sqrt( 1 + c^2(b)) +; +; sqrt(2)*c(b) +; c_2(b) = ---------------- +; sqrt( 1 + c^2(b)) +; +*/ + + + +#define R_SHIFT 30 +#define Q30_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +const Int32 scaleFactors[NO_IID_LEVELS] = +{ + Q30_fmt(1.411983f), Q30_fmt(1.403138f), Q30_fmt(1.386877f), + Q30_fmt(1.348400f), Q30_fmt(1.291249f), Q30_fmt(1.196037f), + Q30_fmt(1.107372f), Q30_fmt(1.000000f), Q30_fmt(0.879617f), + Q30_fmt(0.754649f), Q30_fmt(0.576780f), Q30_fmt(0.426401f), + Q30_fmt(0.276718f), Q30_fmt(0.176645f), Q30_fmt(0.079402f) +}; + +const Int32 scaleFactorsFine[NO_IID_LEVELS_FINE] = +{ + Q30_fmt(1.414207f), Q30_fmt(1.414191f), Q30_fmt(1.414143f), + Q30_fmt(1.413990f), Q30_fmt(1.413507f), Q30_fmt(1.411983f), + Q30_fmt(1.409773f), Q30_fmt(1.405395f), Q30_fmt(1.396780f), + Q30_fmt(1.380053f), Q30_fmt(1.348400f), Q30_fmt(1.313920f), + Q30_fmt(1.264310f), Q30_fmt(1.196037f), Q30_fmt(1.107372f), + Q30_fmt(1.000000f), Q30_fmt(0.879617f), Q30_fmt(0.754649f), + Q30_fmt(0.633656f), Q30_fmt(0.523081f), Q30_fmt(0.426401f), + Q30_fmt(0.308955f), Q30_fmt(0.221375f), Q30_fmt(0.157688f), + Q30_fmt(0.111982f), Q30_fmt(0.079402f), Q30_fmt(0.044699f), + Q30_fmt(0.025145f), Q30_fmt(0.014141f), Q30_fmt(0.007953f), + Q30_fmt(0.004472f) +}; + + +/* + * alphas ranged between 0 and pi/2 + * alpha(b) = (1/2)*arccos( gamma(b)) + * + * b 0 1 2 3 4 5 6 7 + * gamma 1 0.937 0.84118 0.60092 0.36764 0 -0.589 -1 + * + */ + + + +const Int32 scaled_alphas[NO_ICC_LEVELS] = +{ + Q30_fmt(0.00000000000000f), Q30_fmt(0.12616764875355f), + Q30_fmt(0.20199707286122f), Q30_fmt(0.32744135137762f), + Q30_fmt(0.42225800677370f), Q30_fmt(0.55536025173035f), + Q30_fmt(0.77803595530059f), Q30_fmt(1.11072050346071f) +}; + +const Int32 cos_alphas[NO_ICC_LEVELS] = +{ + Q30_fmt(1.00000000000000f), Q30_fmt(0.98412391153249f), + Q30_fmt(0.95947390717984f), Q30_fmt(0.89468446298319f), + Q30_fmt(0.82693418207478f), Q30_fmt(0.70710689672598f), + Q30_fmt(0.45332071670080f), Q30_fmt(0.00000032679490f) +}; + +const Int32 sin_alphas[NO_ICC_LEVELS] = +{ + Q30_fmt(0.00000000000000f), Q30_fmt(0.17748275057029f), + Q30_fmt(0.28179748302823f), Q30_fmt(0.44669868110000f), + Q30_fmt(0.56229872711603f), Q30_fmt(0.70710666564709f), + Q30_fmt(0.89134747871404f), Q30_fmt(1.00000000000000f) +}; + + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 ps_init_stereo_mixing(STRUCT_PS_DEC *pms, + Int32 env, + Int32 usb) +{ + Int32 group; + Int32 bin; + Int32 noIidSteps; + Int32 tmp; + + Int32 invEnvLength; + const Int32 *pScaleFactors; + Int32 scaleR; + Int32 scaleL; + Int32 cos_alpha; + Int32 sin_alpha; + Int32 beta; + Int32 cos_beta; + Int32 sin_beta; + Int32 temp1; + Int32 temp2; + Int32 *ptr_tmp; + Int32 h11; + Int32 h12; + Int32 h21; + Int32 h22; + + if (pms->bFineIidQ) + { + noIidSteps = NO_IID_STEPS_FINE; /* NO_IID_STEPS_FINE == 15 */ + pScaleFactors = scaleFactorsFine; + } + else + { + noIidSteps = NO_IID_STEPS; /* NO_IID_STEPS == 7 */ + pScaleFactors = scaleFactors; + } + + if (env == 0) + { + pms->lastUsb = pms->usb; + pms->usb = usb; + if (usb != pms->lastUsb && pms->lastUsb != 0) + { + return(-1); + + } + } + + invEnvLength = pms->aEnvStartStop[env + 1] - pms->aEnvStartStop[env]; + + if (invEnvLength == (Int32) pms->noSubSamples) + { + invEnvLength = pms->invNoSubSamples; + } + else + { + invEnvLength = Q30_fmt(1.0f) / invEnvLength; + } + + if (invEnvLength == 32) /* more likely value */ + { + for (group = 0; group < NO_IID_GROUPS; group++) /* == 22 */ + { + bin = bins2groupMap[group]; + + /* + * c(b) = 10^(iid(b)/20) + */ + + tmp = pms->aaIidIndex[env][bin]; + + /* + * Intensity differences + * + * sqrt(2) + * c_1(b) = ---------------- + * sqrt( 1 + c^2(b)) + * + */ + scaleR = pScaleFactors[noIidSteps + tmp]; + + /* + * sqrt(2)*c(b) + * c_2(b) = ---------------- + * sqrt( 1 + c^2(b)) + * + */ + + scaleL = pScaleFactors[noIidSteps - tmp]; + + + /* + * alpha(b) = (1/2)*arccos( gamma(b)) + */ + tmp = pms->aaIccIndex[env][bin]; + + cos_alpha = cos_alphas[ tmp]; + sin_alpha = sin_alphas[ tmp]; + + /* + * beta(b) = alpha(b)/sqrt(2)*( c_1(b) - c_2(b)) + */ + + beta = fxp_mul32_Q30(scaled_alphas[ tmp], (scaleR - scaleL)); + + cos_beta = pv_cosine(beta); + sin_beta = pv_sine(beta); + + temp1 = fxp_mul32_Q30(cos_beta, cos_alpha); + temp2 = fxp_mul32_Q30(sin_beta, sin_alpha); + + + /* + * h11(b) = cos( alpha(b) + beta(b))* c_2(b) + * h12(b) = cos( beta(b) - alpha(b))* c_1(b) + */ + + h11 = fxp_mul32_Q30(scaleL, (temp1 - temp2)); + h12 = fxp_mul32_Q30(scaleR, (temp1 + temp2)); + + temp1 = fxp_mul32_Q30(sin_beta, cos_alpha); + temp2 = fxp_mul32_Q30(cos_beta, sin_alpha); + + /* + * h21(b) = sin( alpha(b) + beta(b))* c_2(b) + * h22(b) = sin( beta(b) - alpha(b))* c_1(b) + */ + + h21 = fxp_mul32_Q30(scaleL, (temp1 + temp2)); + h22 = fxp_mul32_Q30(scaleR, (temp1 - temp2)); + + + /* + * Linear interpolation + * + * Hij(k, n_e+1) - Hij(k, n_e) + * Hij(k,n) = Hij(k, n_e) + (n - n_e)*--------------------------- + * n_e+1 - n_e + */ + + ptr_tmp = &pms->h11Prev[group]; + pms->H11[group] = *ptr_tmp; + pms->deltaH11[group] = (h11 - *ptr_tmp) >> 5; + *ptr_tmp = h11; + + ptr_tmp = &pms->h12Prev[group]; + pms->H12[group] = *ptr_tmp; + pms->deltaH12[group] = (h12 - *ptr_tmp) >> 5; + *ptr_tmp = h12; + + ptr_tmp = &pms->h21Prev[group]; + pms->H21[group] = *ptr_tmp; + pms->deltaH21[group] = (h21 - *ptr_tmp) >> 5; + *ptr_tmp = h21; + + ptr_tmp = &pms->h22Prev[group]; + pms->H22[group] = *ptr_tmp; + pms->deltaH22[group] = (h22 - *ptr_tmp) >> 5; + *ptr_tmp = h22; + + + } /* groups loop */ + } + else + { + + for (group = 0; group < NO_IID_GROUPS; group++) /* == 22 */ + { + bin = bins2groupMap[group]; + + /* + * c(b) = 10^(iid(b)/20) + */ + + tmp = pms->aaIidIndex[env][bin]; + + /* + * Intensity differences + * + * sqrt(2) + * c_1(b) = ---------------- + * sqrt( 1 + c^2(b)) + * + */ + scaleR = pScaleFactors[noIidSteps + tmp]; + + /* + * sqrt(2)*c(b) + * c_2(b) = ---------------- + * sqrt( 1 + c^2(b)) + * + */ + + scaleL = pScaleFactors[noIidSteps - tmp]; + + + /* + * alpha(b) = (1/2)*arccos( gamma(b)) + */ + tmp = pms->aaIccIndex[env][bin]; + + cos_alpha = cos_alphas[ tmp]; + sin_alpha = sin_alphas[ tmp]; + + /* + * beta(b) = alpha(b)/sqrt(2)*( c_1(b) - c_2(b)) + */ + + beta = fxp_mul32_Q30(scaled_alphas[ tmp], (scaleR - scaleL)); + + cos_beta = pv_cosine(beta); + sin_beta = pv_sine(beta); + + temp1 = fxp_mul32_Q30(cos_beta, cos_alpha); + temp2 = fxp_mul32_Q30(sin_beta, sin_alpha); + + + /* + * h11(b) = cos( alpha(b) + beta(b))* c_2(b) + * h12(b) = cos( beta(b) - alpha(b))* c_1(b) + */ + + h11 = fxp_mul32_Q30(scaleL, (temp1 - temp2)); + h12 = fxp_mul32_Q30(scaleR, (temp1 + temp2)); + + temp1 = fxp_mul32_Q30(sin_beta, cos_alpha); + temp2 = fxp_mul32_Q30(cos_beta, sin_alpha); + + /* + * h21(b) = sin( alpha(b) + beta(b))* c_2(b) + * h22(b) = sin( beta(b) - alpha(b))* c_1(b) + */ + + h21 = fxp_mul32_Q30(scaleL, (temp1 + temp2)); + h22 = fxp_mul32_Q30(scaleR, (temp1 - temp2)); + + + /* + * Linear interpolation + * + * Hij(k, n_e+1) - Hij(k, n_e) + * Hij(k,n) = Hij(k, n_e) + (n - n_e)*--------------------------- + * n_e+1 - n_e + */ + + ptr_tmp = &pms->h11Prev[group]; + pms->deltaH11[group] = fxp_mul32_Q30((h11 - *ptr_tmp), invEnvLength); + pms->H11[group] = *ptr_tmp; + *ptr_tmp = h11; + + ptr_tmp = &pms->h12Prev[group]; + pms->deltaH12[group] = fxp_mul32_Q30((h12 - *ptr_tmp), invEnvLength); + pms->H12[group] = *ptr_tmp; + *ptr_tmp = h12; + + ptr_tmp = &pms->h21Prev[group]; + pms->deltaH21[group] = fxp_mul32_Q30((h21 - *ptr_tmp), invEnvLength); + pms->H21[group] = *ptr_tmp; + *ptr_tmp = h21; + + ptr_tmp = &pms->h22Prev[group]; + pms->deltaH22[group] = fxp_mul32_Q30((h22 - *ptr_tmp), invEnvLength); + pms->H22[group] = *ptr_tmp; + *ptr_tmp = h22; + + + } /* groups loop */ + } + + + return (0); + +} /* END ps_init_stereo_mixing */ + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.h new file mode 100644 index 0000000..52c0b66 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.h @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_init_stereo_mixing.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions ps_init_stereo_mixing() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_INIT_STEREO_MIXING_H +#define PS_INIT_STEREO_MIXING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int32 ps_init_stereo_mixing(STRUCT_PS_DEC *pms, + Int32 env, + Int32 usb); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_INIT_STEREO_MIXING_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.cpp new file mode 100644 index 0000000..a9d1f19 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.cpp @@ -0,0 +1,333 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_pwr_transient_detection.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decorrelation + Decorrelation is achieved by means of all-pass filtering and delaying + Sub-band samples s_k(n) are converted into de-correlated sub-bands samples + d_k(n). k index for frequency, n time index + + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + + To handle transients and other fast time-envelopes, the output of the all + pass filters has to be attenuated at those signals. + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" +#include "aac_mem_funcs.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_pwr_transient_detection.h" + +#include "fxp_mul32.h" +#include "pv_div.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define R_SHIFT 29 +#define Q29_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt31(a) (Int32)(-a*((Int32)1<<31) - 1 + (a>=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void ps_pwr_transient_detection(STRUCT_PS_DEC *h_ps_dec, + Int32 *rIntBufferLeft, + Int32 *iIntBufferLeft, + Int32 aTransRatio[]) +{ + + Int32 sb; + Int32 maxsb; + Int32 gr; + Int32 bin; + + + + Int32 *aLeftReal; + Int32 *aLeftImag; + Int32 temp_r; + Int32 temp_i; + Int32 accu; + Int32 *aPower = aTransRatio; + Quotient result; + + Int32 nrg; + Int32 *ptr_aPrevNrg; + Int32 peakDiff; + Int32 *ptr_PrevPeakDiff; + + + aLeftReal = rIntBufferLeft; + aLeftImag = iIntBufferLeft; + + /* + * Input Power Matrix + * 2 + * Power(i,n) = SUM | s_k(n)| + * i + */ + + for (gr = SUBQMF_GROUPS; gr < NO_IID_GROUPS; gr++) /* 10 to 22 */ + { + maxsb = min(h_ps_dec->usb, groupBorders[ gr+1]); + + accu = 0; + + for (sb = groupBorders[gr]; sb < maxsb; sb++) + { + + temp_r = aLeftReal[sb]; + temp_i = aLeftImag[sb]; + accu = fxp_mac32_Q31(accu, temp_r, temp_r); + accu = fxp_mac32_Q31(accu, temp_i, temp_i); + + } /* sb */ + aPower[gr - 2] = accu >> 1; + } /* gr */ + + aLeftReal = h_ps_dec->mHybridRealLeft; + aLeftImag = h_ps_dec->mHybridImagLeft; + + + temp_r = aLeftReal[0]; + temp_i = aLeftImag[0]; + accu = fxp_mul32_Q31(temp_r, temp_r); + accu = fxp_mac32_Q31(accu, temp_i, temp_i); + temp_r = aLeftReal[5]; + temp_i = aLeftImag[5]; + accu = fxp_mac32_Q31(accu, temp_r, temp_r); + aPower[0] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[1]; + temp_i = aLeftImag[1]; + accu = fxp_mul32_Q31(temp_r, temp_r); + accu = fxp_mac32_Q31(accu, temp_i, temp_i); + temp_r = aLeftReal[4]; + temp_i = aLeftImag[4]; + accu = fxp_mac32_Q31(accu, temp_r, temp_r); + aPower[1] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[2]; + temp_i = aLeftImag[2]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[2] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[3]; + temp_i = aLeftImag[3]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[3] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + + + temp_r = aLeftReal[6]; + temp_i = aLeftImag[6]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[5] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[7]; + temp_i = aLeftImag[7]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[4] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[8]; + temp_i = aLeftImag[8]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[6] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[9]; + temp_i = aLeftImag[9]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[7] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + + /* + * Power transient detection + */ + + ptr_aPrevNrg = h_ps_dec->aPrevNrg; + + ptr_PrevPeakDiff = h_ps_dec->aPrevPeakDiff; + + for (bin = 0; bin < NO_BINS; bin++) /* NO_BINS = 20 */ + { + + peakDiff = *ptr_PrevPeakDiff; + + + /* PEAK_DECAY_FACTOR 0.765928338364649f @ 48 KHz for Fs > 32 Khz */ + accu = h_ps_dec->aPeakDecayFast[bin]; + peakDiff -= peakDiff >> 2; + + accu = fxp_mul32_Q31(accu, Qfmt31(0.765928338364649f)) << 1; + + if (accu < *aPower) + { + accu = *aPower; + } + else + { + peakDiff += ((accu - *aPower) >> 2); + } + + h_ps_dec->aPeakDecayFast[bin] = accu; + + *(ptr_PrevPeakDiff++) = peakDiff; + + nrg = *ptr_aPrevNrg + ((*aPower - *ptr_aPrevNrg) >> 2); + + *(ptr_aPrevNrg++) = nrg; + + peakDiff += peakDiff >> 1; /* transient impact factor == 1.5 */ + + if (peakDiff <= nrg) + { + *(aPower++) = 0x7FFFFFFF; /* in Q31 */ + } + else + { + pv_div(nrg, peakDiff, &result); + *(aPower++) = (result.quotient >> (result.shift_factor)) << 1; /* in Q31 */ + } + + } /* bin */ + +} + + +#endif + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.h new file mode 100644 index 0000000..57bf5f6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.h @@ -0,0 +1,90 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_pwr_transient_detection.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_pwr_transient_detection() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_PWR_TRANSIENT_DETECTION_H +#define PS_PWR_TRANSIENT_DETECTION_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_pwr_transient_detection(STRUCT_PS_DEC *h_ps_dec, + Int32 *rIntBufferLeft, + Int32 *iIntBufferLeft, + Int32 aTransRatio[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_PWR_TRANSIENT_DETECTION_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_read_data.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_read_data.cpp new file mode 100644 index 0000000..4e5c9f1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_read_data.cpp @@ -0,0 +1,380 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_read_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decodes parametric stereo + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "buf_getbits.h" +#include "s_bit_buffer.h" +#include "s_huffman.h" +#include "aac_mem_funcs.h" +#include "s_ps_dec.h" +#include "sbr_decode_huff_cw.h" +#include "ps_decode_bs_utils.h" +#include "ps_bstr_decoding.h" +#include "ps_read_data.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/* IID & ICC Huffman codebooks */ +const Char aBookPsIidTimeDecode[28][2] = +{ + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { -61, 7 }, { -68, 8 }, + { -60, 9 }, { -69, 10 }, { -59, 11 }, { -70, 12 }, + { -58, 13 }, { -57, 14 }, { -71, 15 }, { 16, 17 }, + { -56, -72 }, { 18, 21 }, { 19, 20 }, { -55, -78 }, + { -77, -76 }, { 22, 25 }, { 23, 24 }, { -75, -74 }, + { -73, -54 }, { 26, 27 }, { -53, -52 }, { -51, -50 } +}; + +const Char aBookPsIidFreqDecode[28][2] = +{ + { -64, 1 }, { 2, 3 }, { -63, -65 }, { 4, 5 }, + { -62, -66 }, { 6, 7 }, { -61, -67 }, { 8, 9 }, + { -68, -60 }, { -59, 10 }, { -69, 11 }, { -58, 12 }, + { -70, 13 }, { -71, 14 }, { -57, 15 }, { 16, 17 }, + { -56, -72 }, { 18, 19 }, { -55, -54 }, { 20, 21 }, + { -73, -53 }, { 22, 24 }, { -74, 23 }, { -75, -78 }, + { 25, 26 }, { -77, -76 }, { -52, 27 }, { -51, -50 } +}; + +const Char aBookPsIccTimeDecode[14][2] = +{ + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 }, + { -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 }, + { -68, 9 }, { -59, 10 }, { -69, 11 }, { -58, 12 }, + { -70, 13 }, { -71, -57 } +}; + +const Char aBookPsIccFreqDecode[14][2] = +{ + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 }, + { -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 }, + { -59, 9 }, { -68, 10 }, { -58, 11 }, { -69, 12 }, + { -57, 13 }, { -70, -71 } +}; + +const Char aBookPsIidFineTimeDecode[60][2] = +{ + { 1, -64 }, { -63, 2 }, { 3, -65 }, { 4, 59 }, + { 5, 7 }, { 6, -67 }, { -68, -60 }, { -61, 8 }, + { 9, 11 }, { -59, 10 }, { -70, -58 }, { 12, 41 }, + { 13, 20 }, { 14, -71 }, { -55, 15 }, { -53, 16 }, + { 17, -77 }, { 18, 19 }, { -85, -84 }, { -46, -45 }, + { -57, 21 }, { 22, 40 }, { 23, 29 }, { -51, 24 }, + { 25, 26 }, { -83, -82 }, { 27, 28 }, { -90, -38 }, + { -92, -91 }, { 30, 37 }, { 31, 34 }, { 32, 33 }, + { -35, -34 }, { -37, -36 }, { 35, 36 }, { -94, -93 }, + { -89, -39 }, { 38, -79 }, { 39, -81 }, { -88, -40 }, + { -74, -54 }, { 42, -69 }, { 43, 44 }, { -72, -56 }, + { 45, 52 }, { 46, 50 }, { 47, -76 }, { -49, 48 }, + { -47, 49 }, { -87, -41 }, { -52, 51 }, { -78, -50 }, + { 53, -73 }, { 54, -75 }, { 55, 57 }, { 56, -80 }, + { -86, -42 }, { -48, 58 }, { -44, -43 }, { -66, -62 } +}; + +const Char aBookPsIidFineFreqDecode[60][2] = +{ + { 1, -64 }, { 2, 4 }, { 3, -65 }, { -66, -62 }, + { -63, 5 }, { 6, 7 }, { -67, -61 }, { 8, 9 }, + { -68, -60 }, { 10, 11 }, { -69, -59 }, { 12, 13 }, + { -70, -58 }, { 14, 18 }, { -57, 15 }, { 16, -72 }, + { -54, 17 }, { -75, -53 }, { 19, 37 }, { -56, 20 }, + { 21, -73 }, { 22, 29 }, { 23, -76 }, { 24, -78 }, + { 25, 28 }, { 26, 27 }, { -85, -43 }, { -83, -45 }, + { -81, -47 }, { -52, 30 }, { -50, 31 }, { 32, -79 }, + { 33, 34 }, { -82, -46 }, { 35, 36 }, { -90, -89 }, + { -92, -91 }, { 38, -71 }, { -55, 39 }, { 40, -74 }, + { 41, 50 }, { 42, -77 }, { -49, 43 }, { 44, 47 }, + { 45, 46 }, { -86, -42 }, { -88, -87 }, { 48, 49 }, + { -39, -38 }, { -41, -40 }, { -51, 51 }, { 52, 59 }, + { 53, 56 }, { 54, 55 }, { -35, -34 }, { -37, -36 }, + { 57, 58 }, { -94, -93 }, { -84, -44 }, { -80, -48 } +}; + + + + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 ps_read_data(STRUCT_PS_DEC *ps_dec, + BIT_BUFFER * hBitBuf, + Int32 nBitsLeft) + +{ + Int gr; + UInt32 env; + UInt32 dtFlag; + Int32 startbits; + SbrHuffman CurrentTable; + + if (!ps_dec) + { + return 0; + } + + startbits = GetNrBitsAvailable(hBitBuf); + + if (buf_get_1bit(hBitBuf)) /* Enable Header */ + { + ps_dec->bEnableIid = buf_get_1bit(hBitBuf); + + if (ps_dec->bEnableIid) + { + ps_dec->freqResIid = buf_getbits(hBitBuf, 3); + + if (ps_dec->freqResIid > 2) + { + ps_dec->bFineIidQ = 1; + ps_dec->freqResIid -= 3; + } + else + { + ps_dec->bFineIidQ = 0; + } + } + + ps_dec->bEnableIcc = buf_get_1bit(hBitBuf); + if (ps_dec->bEnableIcc) + { + ps_dec->freqResIcc = buf_getbits(hBitBuf, 3); + + if (ps_dec->freqResIcc > 2) + { + ps_dec->freqResIcc -= 3; + } + } + ps_dec->bEnableExt = buf_get_1bit(hBitBuf); + } + + ps_dec->bFrameClass = buf_get_1bit(hBitBuf); + if (ps_dec->bFrameClass == 0) + { + ps_dec->noEnv = aFixNoEnvDecode[ buf_getbits(hBitBuf, 2)]; + } + else + { + ps_dec->noEnv = 1 + buf_getbits(hBitBuf, 2); + for (env = 1; env < ps_dec->noEnv + 1; env++) + { + ps_dec->aEnvStartStop[env] = (buf_getbits(hBitBuf, 5)) + 1; + } + } + + if ((ps_dec->freqResIid > 2) || (ps_dec->freqResIcc > 2)) + { + + ps_dec->bPsDataAvail = 0; + + nBitsLeft -= startbits - GetNrBitsAvailable(hBitBuf); + while (nBitsLeft) + { + int i = nBitsLeft; + if (i > 8) + { + i = 8; + } + buf_getbits(hBitBuf, i); + nBitsLeft -= i; + } + return (startbits - GetNrBitsAvailable(hBitBuf)); + } + + if (ps_dec->bEnableIid) + { + for (env = 0; env < ps_dec->noEnv; env++) + { + dtFlag = buf_get_1bit(hBitBuf); + + if (!dtFlag) + { + if (ps_dec->bFineIidQ) + { + CurrentTable = aBookPsIidFineFreqDecode; + } + else + { + CurrentTable = aBookPsIidFreqDecode; + } + } + else + { + if (ps_dec->bFineIidQ) + { + CurrentTable = aBookPsIidFineTimeDecode; + } + else + { + CurrentTable = aBookPsIidTimeDecode; + } + } + + for (gr = 0; gr < aNoIidBins[ps_dec->freqResIid]; gr++) + { + ps_dec->aaIidIndex[env][gr] = sbr_decode_huff_cw(CurrentTable, hBitBuf); + } + + ps_dec->abIidDtFlag[env] = dtFlag; + } + } + + if (ps_dec->bEnableIcc) + { + for (env = 0; env < ps_dec->noEnv; env++) + { + dtFlag = buf_get_1bit(hBitBuf); + if (!dtFlag) + { + CurrentTable = aBookPsIccFreqDecode; + } + else + { + CurrentTable = aBookPsIccTimeDecode; + } + for (gr = 0; gr < aNoIccBins[ps_dec->freqResIcc]; gr++) + { + ps_dec->aaIccIndex[env][gr] = sbr_decode_huff_cw(CurrentTable, hBitBuf); + } + + ps_dec->abIccDtFlag[env] = dtFlag; + } + } + + if (ps_dec->bEnableExt) + { + + int cnt; + + cnt = (int)buf_getbits(hBitBuf, 4); + + if (cnt == 15) + { + cnt += (int)buf_getbits(hBitBuf, 8); + } + + hBitBuf->nrBitsRead += (cnt << 3); + } + + ps_dec->bPsDataAvail = 1; + + return (startbits - GetNrBitsAvailable(hBitBuf)); +} + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_read_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_read_data.h new file mode 100644 index 0000000..c73f38b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_read_data.h @@ -0,0 +1,94 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_read_data.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions ps_read_data() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_READ_DATA_H +#define PS_READ_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +#define EXTENSION_ID_PS_CODING 2 + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int32 ps_read_data(STRUCT_PS_DEC *ps_dec, + BIT_BUFFER * hBitBuf, + Int32 nBitsLeft); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_READ_DATA_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_stereo_processing.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_stereo_processing.cpp new file mode 100644 index 0000000..d4f3863 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_stereo_processing.cpp @@ -0,0 +1,365 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_stereo_processing.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Stereo Process or reconstruction + + l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n) + + r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n) + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO +#include "pv_audio_type_defs.h" +#include "ps_stereo_processing.h" +#include "fxp_mul32.h" +#include "ps_all_pass_filter_coeff.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ps_stereo_processing(STRUCT_PS_DEC *pms, + Int32 *qmfLeftReal, + Int32 *qmfLeftImag, + Int32 *qmfRightReal, + Int32 *qmfRightImag) +{ + Int32 group; + Int32 subband; + Int32 maxSubband; + Int32 usb; + Char index; + + + Int32 *hybrLeftReal; + Int32 *hybrLeftImag; + Int32 *hybrRightReal; + Int32 *hybrRightImag; + Int32 *ptr_hybrLeftReal; + Int32 *ptr_hybrLeftImag; + Int32 *ptr_hybrRightReal; + Int32 *ptr_hybrRightImag; + + + Int16 h11; + Int16 h12; + Int16 h21; + Int16 h22; + + Int32 temp1; + Int32 temp2; + Int32 temp3; + + usb = pms->usb; + + /* + * Complete Linear interpolation + */ + + hybrLeftReal = pms->mHybridRealLeft; + hybrLeftImag = pms->mHybridImagLeft; + hybrRightReal = pms->mHybridRealRight; + hybrRightImag = pms->mHybridImagRight; + + for (group = 0; group < SUBQMF_GROUPS; group++) /* SUBQMF_GROUPS == 10 */ + { + + temp1 = pms->deltaH11[group]; + temp2 = pms->deltaH12[group]; + + pms->H11[group] += temp1; + h11 = (Int16)(pms->H11[group] >> 16); + pms->H12[group] += temp2; + h12 = (Int16)(pms->H12[group] >> 16); + + temp1 = pms->deltaH21[group]; + temp2 = pms->deltaH22[group]; + + pms->H21[group] += temp1; + h21 = (Int16)(pms->H21[group] >> 16); + pms->H22[group] += temp2; + h22 = (Int16)(pms->H22[group] >> 16); + + index = groupBorders[group]; + + /* + * Reconstruction of Stereo sub-band signal + * + * l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n) + * + * r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n) + */ + ptr_hybrLeftReal = &hybrLeftReal[ index]; + ptr_hybrRightReal = &hybrRightReal[ index]; + + temp1 = *(ptr_hybrLeftReal) << 1; + temp2 = *(ptr_hybrRightReal) << 1; + + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftReal) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightReal) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + + + ptr_hybrLeftImag = &hybrLeftImag[ index]; + ptr_hybrRightImag = &hybrRightImag[ index]; + + temp1 = *(ptr_hybrLeftImag) << 1; + temp2 = *(ptr_hybrRightImag) << 1; + + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftImag) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightImag) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + + + } /* groups loop */ + + temp1 = pms->deltaH11[SUBQMF_GROUPS]; + temp2 = pms->deltaH12[SUBQMF_GROUPS]; + + pms->H11[SUBQMF_GROUPS] += temp1; + h11 = (Int16)(pms->H11[SUBQMF_GROUPS] >> 16); + pms->H12[SUBQMF_GROUPS] += temp2; + h12 = (Int16)(pms->H12[SUBQMF_GROUPS] >> 16); + + temp1 = pms->deltaH21[SUBQMF_GROUPS]; + temp2 = pms->deltaH22[SUBQMF_GROUPS]; + + pms->H21[SUBQMF_GROUPS] += temp1; + h21 = (Int16)(pms->H21[SUBQMF_GROUPS] >> 16); + pms->H22[SUBQMF_GROUPS] += temp2; + h22 = (Int16)(pms->H22[SUBQMF_GROUPS] >> 16); + + + ptr_hybrLeftReal = &qmfLeftReal[ 3]; + ptr_hybrRightReal = &qmfRightReal[ 3]; + + /* + * Reconstruction of Stereo sub-band signal + * + * l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n) + * + * r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n) + */ + temp1 = *(ptr_hybrLeftReal) << 1; + temp2 = *(ptr_hybrRightReal) << 1; + + + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftReal) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightReal) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + + ptr_hybrLeftImag = &qmfLeftImag[ 3]; + ptr_hybrRightImag = &qmfRightImag[ 3]; + + + temp1 = *(ptr_hybrLeftImag) << 1; + temp2 = *(ptr_hybrRightImag) << 1; + + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftImag) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightImag) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + + + for (group = SUBQMF_GROUPS + 1; group < NO_IID_GROUPS; group++) /* 11 to NO_IID_GROUPS == 22 */ + { + temp1 = pms->deltaH11[group]; + temp2 = pms->deltaH12[group]; + + pms->H11[group] += temp1; + h11 = (Int16)(pms->H11[group] >> 16); + pms->H12[group] += temp2; + h12 = (Int16)(pms->H12[group] >> 16); + + temp1 = pms->deltaH21[group]; + temp2 = pms->deltaH22[group]; + + pms->H21[group] += temp1; + h21 = (Int16)(pms->H21[group] >> 16); + pms->H22[group] += temp2; + h22 = (Int16)(pms->H22[group] >> 16); + + index = groupBorders[group]; + maxSubband = groupBorders[group + 1]; + maxSubband = min(usb, maxSubband); + + /* + * Reconstruction of Stereo sub-band signal + * + * l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n) + * + * r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n) + */ + + ptr_hybrLeftReal = &qmfLeftReal[ index]; + ptr_hybrRightReal = &qmfRightReal[ index]; + + for (subband = index; subband < maxSubband; subband++) + { + temp1 = *(ptr_hybrLeftReal) << 1; + temp2 = *(ptr_hybrRightReal) << 1; + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftReal++) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightReal++) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + } + + ptr_hybrLeftImag = &qmfLeftImag[ index]; + ptr_hybrRightImag = &qmfRightImag[ index]; + + for (subband = index; subband < maxSubband; subband++) + { + temp1 = *(ptr_hybrLeftImag) << 1; + temp2 = *(ptr_hybrRightImag) << 1; + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftImag++) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightImag++) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + + } /* subband loop */ + + } /* groups loop */ + +} /* END ps_stereo_processing */ + + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_stereo_processing.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_stereo_processing.h new file mode 100644 index 0000000..c698886 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/ps_stereo_processing.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_stereo_processing.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_stereo_processing() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_STEREO_PROCESSING_H +#define PS_STEREO_PROCESSING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_stereo_processing(STRUCT_PS_DEC *pms, + Int32 *qmfLeftReal, + Int32 *qmfLeftImag, + Int32 *qmfRightReal, + Int32 *qmfRightImag); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_STEREO_PROCESSING_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pulse_nc.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pulse_nc.cpp new file mode 100644 index 0000000..148e34e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pulse_nc.cpp @@ -0,0 +1,259 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pulse_nc.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + coef[] = Array of quantized spectral coefficents. + (Int []) + + pPulseInfo = Pointer to structure which contains noiseless + encoding info, includes information about the pulse data, + pulse amplitude, etc. + (const PulseInfo *) + + pLongFrameInfo = Pointer to structure that holds information about + each group. (long block flag, number of windows, + scalefactor bands per group, etc.) + + Variable is named (pLongFrameInfo) because this function + is only used for LONG windows. + (FrameInfo *) + max = Pointer to the maximum value of coef[] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coef[] = coefficient contents are modified by the encoded pulse + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function adds pulses to defined ranges of coefficients in the window, + for the case of LONG windows. The pulses are unsigned, so + negative coefficients subtract the pulse, and positive coefficients add it. + (The ampltiude of the coefficient is always increased by the pulse) + + A maximum of 4 coefficients may be modified by a pulse, and these + coefficients must all occur in the same scalefactor band. + + The number of pulse-encoded coefficients to be processed by this function + is communicated to this function via pPulseInfo->number_pulse + + This value is equal to the actual number of pulses - 1. + (e.g if pPulseInfo->number_pulse == 0, one pulse is assumed) + This function must not be called if no pulse encoded data exists. + The function assumes that at least one pulse exists. +------------------------------------------------------------------------------ + REQUIREMENTS + + This module shall correctly add transmitted pulse(s) to the correct + coefficients in a LONG window. + +------------------------------------------------------------------------------ + REFERENCES + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.3.3 Decoding Process + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + index = pLongFrameInfo->win_sfb_top[0][pPulseInfo->pulse_start_sfb]; + + pPulseOffset = &(pPulseInfo->pulse_offset[0]); + + pPulseAmp = &(pPulseInfo->pulse_amp[0]); + + pCoef = &(Coef[index]); + + FOR (index = pPulseInfo->number_pulse; index >= 0; index--) + + pCoef = pCoef + *(pPulseOffset); + pPulseOffset = pPulseOffset + 1; + + IF (*pCoef > 0) + *(pCoef) = *(pCoef) + *(pPulseAmp); + pPulseAmp = pPulseAmp + 1; + ELSE + *(pCoef) = *(pCoef) - *(pPulseAmp); + pPulseAmp = pPulseAmp + 1; + ENDIF + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" +#include "s_pulseinfo.h" +#include "pulse_nc.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*--------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pulse_nc( + Int16 coef[], + const PulseInfo *pPulseInfo, + const FrameInfo *pLongFrameInfo, + Int *max) +{ + Int index; + + Int16 *pCoef; + Int temp; + + const Int *pPulseOffset; + const Int *pPulseAmp; + + /*--- Find the scalefactor band where pulse-encoded data starts ---*/ + + if (pPulseInfo->pulse_start_sfb > 0) + { + index = pLongFrameInfo->win_sfb_top[0][pPulseInfo->pulse_start_sfb - 1]; + } + else + { + index = 0; + } + + /*------------------------------------------------------------------------- + Each pulse index is stored as an offset from the previous pulse + + Example - here we have a sfb that is 20 coefficients in length: + + [0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19] + [ ][ ][ ][ ][ ][P][P][ ][ ][ ][ ][ ][ ][ ][ ][ P][ ][ ][ ][ P] + + The array pointed to by pPulseOffset == [5][1][9][4] + + pPulseAmp is of the same length as pPulseOffset, and contains + an individual pulse amplitude for each coefficient. + --------------------------------------------------------------------------*/ + + pCoef = &(coef[index]); + + pPulseOffset = &(pPulseInfo->pulse_offset[0]); + + pPulseAmp = &(pPulseInfo->pulse_amp[0]); + + for (index = pPulseInfo->number_pulse; index > 0; index--) + { + pCoef += *pPulseOffset++; + + temp = *pCoef; + + if (temp > 0) + { + temp += *(pPulseAmp++); + *pCoef = (Int16)temp; + if (temp > *max) + { + *max = temp; + } + } + else + { + temp -= *(pPulseAmp++); + *pCoef = (Int16)temp; + if (-temp > *max) + { + *max = -temp; + } + } + + } /* for() */ + + return; + +} /* pulse_nc */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pulse_nc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pulse_nc.h new file mode 100644 index 0000000..16a7a52 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pulse_nc.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pulse_nc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the global function declaration for pulse_nc + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PULSE_NC_H +#define PULSE_NC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" +#include "s_pulseinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pulse_nc( + Int16 coef[], + const PulseInfo *pPulseInfo, + const FrameInfo *pLongFrameInfo, + Int *max); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_div.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_div.cpp new file mode 100644 index 0000000..d3df615 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_div.cpp @@ -0,0 +1,181 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_div.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer numerator + Int32 y 32-bit integer denominator + Quotient *result structure that hold result and shift factor + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement division of two Int32 numbers, provides back quotient and a + shift factor +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#ifdef AAC_PLUS + + +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" +#include "pv_div.h" +#include "pv_normalize.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void pv_div(Int32 x, Int32 y, Quotient *result) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + Int32 quotient; + Int32 i; + Int32 j; + Int32 y_ov_y_hi; + Int32 flag = 0; /* carries negative sign, if any */ + + + result->shift_factor = 0; /* default */ + + if (y == 0) + { + x = 0; /* this will return 0 for any div/0 */ + } + /* + * make sure x and y are both positive + */ + + if (y < 0) + { + y = -y; + flag ^= 1; + } + + + if (x < 0) + { + x = -x; + flag ^= 1; + } + + if (x != 0) + { + /*---------------------------------------------------------------------------- + ; Scale the input to get maximum precision for x + ----------------------------------------------------------------------------*/ + + i = pv_normalize(x); + + x <<= i; + + + /*---------------------------------------------------------------------------- + ; Scale the input to get maximum precision for y + ----------------------------------------------------------------------------*/ + + j = pv_normalize(y); + + y <<= j; + + result->shift_factor = i - j; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + /*--------------------------------------------------------------- + ; take the inverse of the 16 MSB of y + ---------------------------------------------------------------*/ + + quotient = (0x40000000 / (y >> 15)); + + y_ov_y_hi = fxp_mul32_Q15(y, quotient); /* y*(1/y_hi) */ + + y_ov_y_hi = 0x7FFFFFFF - y_ov_y_hi; /* 2 - y*(1/y_hi) */ + y_ov_y_hi = fxp_mul32_Q14(quotient, y_ov_y_hi); + i = fxp_mul32_Q31(y_ov_y_hi, x) << 1; + + result->quotient = flag ? -i : i; + } + else + { + result->quotient = 0; + } + + + +} + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_div.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_div.h new file mode 100644 index 0000000..fbdb0e9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_div.h @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_div.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_DIV_H +#define PV_DIV_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + struct intg_div + { + Int32 quotient; + Int32 shift_factor; + }; + typedef struct intg_div Quotient; + + + void pv_div(Int32 x, Int32 y, Quotient *quotient); + +#ifdef __cplusplus +} +#endif + +#endif /* PV_DIV_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_log2.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_log2.cpp new file mode 100644 index 0000000..5c72bf4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_log2.cpp @@ -0,0 +1,161 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_log2.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement the logarithm base 2 of a number +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "pv_log2.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +#define R_SHIFT 20 +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +const Int32 log_table[9] = +{ + Q_fmt(-0.00879832091331F), Q_fmt(0.12022974263833F), + Q_fmt(-0.72883958314294F), Q_fmt(2.57909824242332F), + Q_fmt(-5.90041216630330F), Q_fmt(9.15023342527264F), + Q_fmt(-9.90616619500413F), Q_fmt(8.11228968755409F), + Q_fmt(-3.41763474309898F) +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +Int32 pv_log2(Int32 z) +{ + const Int32 *pt_table = log_table; + Int32 y; + Int32 i; + + Int32 int_log2 = 0; + + if (z > Q_fmt(2.0f)) + { + while (z > Q_fmt(2.0f)) + { + z >>= 1; + int_log2++; + } + } + else if (z < Q_fmt(1.0f)) + { + { + while (z < Q_fmt(1.0f)) + { + z <<= 1; + int_log2--; + } + } + } + + /* + * at this point, input limited to 1=5) && ((PV_COMPILER == EPV_ARM_RVCT) || (PV_COMPILER == EPV_ARM_GNUC))) +/* function is inlined in header file */ +#else + +Int pv_normalize(Int32 x) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + Int i; + + + if (x > 0x0FFFFFFF) + { + i = 0; /* most likely case */ + } + else if (x > 0x00FFFFFF) + { + i = 3; /* second most likely case */ + } + else if (x > 0x0000FFFF) + { + i = x > 0x000FFFFF ? 7 : 11; + } + else + { + if (x > 0x000000FF) + { + i = x > 0x00000FFF ? 15 : 19; + } + else + { + i = x > 0x0000000F ? 23 : 27; + } + } + + + x <<= i; + + switch (x & 0x78000000) + { + case 0x08000000: + i += 3; + break; + + case 0x18000000: + case 0x10000000: + i += 2; + break; + case 0x28000000: + case 0x20000000: + case 0x38000000: + case 0x30000000: + i++; + + default: + ; + } + + return i; + +} + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_normalize.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_normalize.h new file mode 100644 index 0000000..ad03948 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_normalize.h @@ -0,0 +1,83 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_normalize.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_NORMALIZE_H +#define PV_NORMALIZE_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +#if ((PV_CPU_ARCH_VERSION >=5) && (PV_COMPILER == EPV_ARM_GNUC)) + +__inline Int pv_normalize(Int32 x) +{ + register Int32 y; + register Int32 ra = x; + + + asm volatile( + "clz %0, %1\n\t" + "sub %0, %0, #1" + : "=&r*i"(y) + : "r"(ra)); + return (y); + +} + +#else + +#ifdef __cplusplus +extern "C" +{ +#endif + /*C Equivalent code*/ + Int pv_normalize(Int32 x); +#ifdef __cplusplus +} +#endif + +#endif + + +#endif /* PV_NORMALIZE_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_pow2.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_pow2.cpp new file mode 100644 index 0000000..0529922 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_pow2.cpp @@ -0,0 +1,162 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_pow2.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + Int32 x 32-bit integer input Q27 + +Output + Int32 32-bit integer in Q25 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement the power base 2 for positive numbers lesser than 5.999999 +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ +#ifdef AAC_PLUS + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_pow2.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#define POW_2_TABLE_LENGTH 6 +#define POW_2_TABLE_LENGTH_m_2 (POW_2_TABLE_LENGTH - 2) + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +#define R_SHIFT 29 +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Q27fmt(x) (Int32)(x*((Int32)1<<27) + (x>=0?0.5F:-0.5F)) + +const Int32 pow2_table[6] = +{ + Q_fmt(0.00224510927441F), Q_fmt(0.00777943379416F), + Q_fmt(0.05737929218747F), Q_fmt(0.23918017179889F), + Q_fmt(0.69345251849351F), Q_fmt(0.99996347120248F) +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +/* + * z in Q27 format + */ + +Int32 pv_pow2(Int32 z) +{ + const Int32 *pt_table = pow2_table; + Int32 multiplier = 0; + Int32 shift_factor; + Int32 i; + Int32 v_q; + Int32 y; + + + if (z > Q27fmt(1.0f)) + { + v_q = z - (z & 0xF8000000); + shift_factor = z >> 27; + } + else + { + v_q = z; + shift_factor = 0; + } + + if (v_q < Q27fmt(0.5f)) + { + v_q += Q27fmt(0.5f); + multiplier = Q_fmt(0.70710678118655F); + } + + v_q = v_q << 2; + + y = fxp_mul32_Q29(*(pt_table++), v_q); + + for (i = POW_2_TABLE_LENGTH_m_2; i != 0; i--) + { + y += *(pt_table++); + y = fxp_mul32_Q29(y, v_q); + } + y += *(pt_table++); + + if (multiplier) + { + y = fxp_mul32_Q29(y, multiplier); + } + + /* + * returns number on Q25 + */ + return (y >> (4 - shift_factor)); + +} + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_pow2.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_pow2.h new file mode 100644 index 0000000..6533840 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_pow2.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_pow2.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_POW2_H +#define PV_POW2_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + Int32 pv_pow2(Int32 z); + + +#ifdef __cplusplus +} +#endif + +#endif /* PV_POW2_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sine.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sine.cpp new file mode 100644 index 0000000..fd36e89 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sine.cpp @@ -0,0 +1,175 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_sine.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer angle (in Q30) between 0 and pi/2 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Find the sine of a number between 0 and pi/2 +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" +#include "pv_sine.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +#define R_SHIFT 30 + +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +const Int32 sin_table[9] = +{ + Q_fmt(0.00001724684028), Q_fmt(-0.00024606242846), + Q_fmt(0.00007297328923), Q_fmt(0.00826706596417), + Q_fmt(0.00003585160465), Q_fmt(-0.16667772526248), + Q_fmt(0.00000174197440), Q_fmt(0.99999989138797), + Q_fmt(0.00000000110513) +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +Int32 pv_sine(Int32 z) +{ + Int32 sine; + Int32 i; + const Int32 *pt_table = sin_table; + Int32 sign = 0; + + if (z < 0) + { + z = -z; + sign = 1; + } + + if (z > Q_fmt(0.0015)) + { + sine = fxp_mul32_Q30(*(pt_table++), z); + + for (i = 7; i != 0; i--) + { + sine += *(pt_table++); + sine = fxp_mul32_Q30(sine, z); + } + + } + else + { + sine = z; /* better approximation in this range */ + } + + if (sign) + { + sine = -sine; + } + + return sine; +} + + + +Int32 pv_cosine(Int32 z) +{ + Int32 cosine; + + if (z < 0) + { + z = -z; /* sign does not play a role in cosine */ + } + + if (z > Q_fmt(0.0015)) + { + z = Q_fmt(1.57079632679490) - z; /* pi/2 - z */ + + cosine = pv_sine(z); + } + else + { /* better approximation in this range */ + cosine = Q_fmt(0.99999999906868) - (fxp_mul32_Q30(z, z) >> 1); + } + + return cosine; +} + +#endif + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sine.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sine.h new file mode 100644 index 0000000..14681d7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sine.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_sine.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_SINE_H +#define PV_SINE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + Int32 pv_sine(Int32 x); + Int32 pv_cosine(Int32 x); + +#ifdef __cplusplus +} +#endif + +#endif /* PV_SINE_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sqrt.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sqrt.cpp new file mode 100644 index 0000000..6628488 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sqrt.cpp @@ -0,0 +1,211 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_sqrt.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer + + Int32 y 32-bit integer + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement root squared of a number + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "pv_audio_type_defs.h" + +#include "fxp_mul32.h" +#include "pv_sqrt.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#define R_SHIFT 28 +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + + +const Int32 sqrt_table[9] = +{ + Q_fmt(-0.13829740941110F), Q_fmt(0.95383399963991F), + Q_fmt(-2.92784603873353F), Q_fmt(5.27429191920042F), + Q_fmt(-6.20272445821478F), Q_fmt(5.04717433019620F), + Q_fmt(-3.03362807640415F), Q_fmt(1.86178814410910F), + Q_fmt(0.16540758699193F) +}; + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void pv_sqrt(Int32 man, Int32 exp, Root_sq *result, Int32 *sqrt_cache) +{ + + Int32 y; + Int32 xx; + Int32 nn; + Int32 i; + const Int32 *pt_table = sqrt_table; + + + if (sqrt_cache[0] == man && sqrt_cache[1] == exp) + { + result->root = sqrt_cache[2]; + result->shift_factor = (Int16)sqrt_cache[3]; + } + else + { + + sqrt_cache[0] = man; + sqrt_cache[1] = exp; + + + if (man > 0) + { + xx = man; + if (man >= Q_fmt(1.0f)) + { + nn = exp + 1; + while ((xx >>= 1) > Q_fmt(1.0f)) + { + nn++; + } + } + else if (man < Q_fmt(0.5f)) + { + nn = exp - 1; + while ((xx <<= 1) < Q_fmt(0.5f)) + { + nn--; + } + } + else + { + nn = exp; + } + + + y = fxp_mul32_Q28(*(pt_table++), xx); + + for (i = 3; i != 0; i--) + { + y += *(pt_table++); + y = fxp_mul32_Q28(y, xx); + y += *(pt_table++); + y = fxp_mul32_Q28(y, xx); + } + y += *(pt_table++); + y = fxp_mul32_Q28(y, xx) + *(pt_table++); + + if (nn >= 0) + { + if (nn&1) + { + y = fxp_mul32_Q29(y, Q_fmt(1.41421356237310F)); + result->shift_factor = (nn >> 1) - 28; + } + else + { + result->shift_factor = (nn >> 1) - 29; + } + } + else + { + if (nn&1) + { + y = fxp_mul32_Q28(y, Q_fmt(0.70710678118655F)); + } + + result->shift_factor = -((-nn) >> 1) - 29; + } + + result->root = y; + + } + else + { + result->root = 0; + result->shift_factor = 0; + } + + } + + sqrt_cache[2] = result->root; + sqrt_cache[3] = result->shift_factor; + +} + + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sqrt.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sqrt.h new file mode 100644 index 0000000..7c0a4cd --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pv_sqrt.h @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_sqrt.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_SQRT_H +#define PV_SQRT_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + struct intg_sqrt + { + Int32 root; + Int32 shift_factor; + }; + typedef struct intg_sqrt Root_sq; + + void pv_sqrt(Int32 man, Int32 exp, Root_sq *result, Int32 *sqrt_cache); + + +#ifdef __cplusplus +} +#endif + +#endif /* PV_SQRT_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderconfig.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderconfig.cpp new file mode 100644 index 0000000..c6b6d0f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderconfig.cpp @@ -0,0 +1,249 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecoderconfig.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external interface structure. See the file + PVMP4AudioDecoder_API.h for a description of each field. + Data type of pointer to a tPVMP4AudioDecoderExternal + structure. + + pExt->pInputBuffer: pointer to input buffer containing input + bitstream + + pExt->inputBufferCurrentLength: number of bytes in the input buffer + + pExt->inputBufferUsedLength: number of bytes already consumed in + input buffer + + pExt->remainderBits: number of bits consumed in addition to + pExt->inputBufferUsedLength + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tDec_Int_File structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tDec_Int_File + structure. + + Local Stores/Buffers/Pointers Needed: None + (The memory set aside in pMem performs this task) + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 if no error occurred + MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred + MP4AUDEC_RECOVERABLE if a recoverable error occurred. + Presently a recoverable error does not exist, but this + was a requirement. + + + Pointers and Buffers Modified: + pMem contents are modified. + pExt: (more detail in the file PVMP4AudioDecoder_API.h) + inputBufferUsedLength - number of array elements used up by the stream. + remainderBits - remaining bits in the next UInt32 buffer + samplingRate - sampling rate in samples per sec + encodedChannels - channels found on the file (informative) + frameLength - length of the frame + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + PacketVideo Document # CCC-AUD-AAC-ERS-0003 + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + subclause 1.6 + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "ibstream.h" /* where #define INBUF_ARRAY_INDEX_SHIFT */ +#include "sfb.h" /* Where samp_rate_info[] is declared */ + +#include "get_audio_specific_config.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +OSCL_EXPORT_REF Int PVMP4AudioDecoderConfig( + tPVMP4AudioDecoderExternal *pExt, + void *pMem) +{ + + UInt initialUsedBits; /* Unsigned for C55x */ + tDec_Int_File *pVars; /* Helper pointer */ + + Int status = MP4AUDEC_INCOMPLETE_FRAME; + + /* + * Initialize "helper" pointers to existing memory. + */ + pVars = (tDec_Int_File *)pMem; + /* + * Translate input buffer variables. + */ + pVars->inputStream.pBuffer = pExt->pInputBuffer; + + pVars->inputStream.inputBufferCurrentLength = + (UInt)pExt->inputBufferCurrentLength; + + pVars->inputStream.availableBits = + (UInt)(pExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT); + + initialUsedBits = + (UInt)((pExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) + + pExt->remainderBits); + + pVars->inputStream.usedBits = initialUsedBits; + + if (initialUsedBits <= pVars->inputStream.availableBits) + { + + /* + * Buffer is not overrun, then + * decode the AudioSpecificConfig() structure + */ + + pVars->aacConfigUtilityEnabled = false; /* set aac dec mode */ + + status = get_audio_specific_config(pVars); + + } + + byte_align(&pVars->inputStream); + + + if (status == SUCCESS) + { + + pVars->bno++; + + /* + * A possible improvement would be to set these values only + * when they change. + */ + pExt->samplingRate = + samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate; + + /* + * we default to 2 channel, even for mono files, (where channels have same content) + * this is done to ensure support for enhanced aac+ with implicit signalling + */ + pExt->aacPlusEnabled = pVars->aacPlusEnabled; + +// pExt->encodedChannels = pVars->mc_info.nch; + + pExt->encodedChannels = 2; + + pExt->frameLength = pVars->frameLength; +#ifdef AAC_PLUS + pExt->aacPlusUpsamplingFactor = pVars->mc_info.upsamplingFactor; +#endif + + } + else + { + /* + * Default to nonrecoverable error status unless there is a Buffer overrun + */ + status = MP4AUDEC_INVALID_FRAME; + + if (pVars->inputStream.usedBits > pVars->inputStream.availableBits) + { + /* all bits were used but were not enough to complete parsing */ + pVars->inputStream.usedBits = pVars->inputStream.availableBits; + + status = MP4AUDEC_INCOMPLETE_FRAME; /* audio config too small */ + } + + } + + /* + * Translate from units of bits back into units of words. + */ + + pExt->inputBufferUsedLength = + pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT; + + pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK; + + pVars->status = status; + + return (status); + +} /* PVMP4AudioDecoderDecodeFrame */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderframe.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderframe.cpp new file mode 100644 index 0000000..3dc1e57 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderframe.cpp @@ -0,0 +1,1339 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecoderframe.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external interface structure. See the file + PVMP4AudioDecoder_API.h for a description of each field. + Data type of pointer to a tPVMP4AudioDecoderExternal + structure. + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tDec_Int_File structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tDec_Int_File + structure. + + Local Stores/Buffers/Pointers Needed: None + (The memory set aside in pMem performs this task) + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 if no error occurred + MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred + MP4AUDEC_RECOVERABLE if a recoverable error occurred. + Presently a recoverable error does not exist, but this + was a requirement. + + + Pointers and Buffers Modified: + pMem contents are modified. + pExt: (more detail in the file PVMP4AudioDecoder_API.h) + inputBufferUsedLength - number of array elements used up by the stream. + remainderBits - remaining bits in the next UInt32 buffer + samplingRate - sampling rate in samples per sec + bitRate - bit rate in bits per second, varies frame to frame. + encodedChannels - channels found on the file (informative) + frameLength - length of the frame + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decodes one frame of an MPEG-2/MPEG-4 encoded audio bitstream. + + This function calls the various components of the decoder in the proper order. + + + Left Channel Right Channel + | | + | | + | | + \|/ \|/ + #1 ____________________ #2 ____________________ + | | | | + | Huffman Decoding | | Huffman Decoding | + |__________________| |__________________| + | | + | | + | | + \|/ | + #3 ____________________ | + | | | + | PNS LEFT | | + |__________________| | + | | + | | + | | + \|/ \|/ + #4 ______________________________________________________________________ + | | + | Apply MS_Synt | + |____________________________________________________________________| + | | + | | + \|/ | + #5 ____________________ | + | | W + | LTP | A + |__________________| I + | T + | | + | F + \|/ O + #6 ____________________ R + | | | + | Time -> Freq | L + |__________________| E + | F + | T + | | + \|/ C + #7 ____________________ H + | | A + | TNS Inverse | N + |__________________| N + | E + | L + | | + \|/ | + #8 ____________________ | + | | | + | Long Term Synth | | + |__________________| | + | | + | \|/ + | #9 ____________________ + | | | + |--DATA ON LEFT CHANNEL MAY BE USED----->| PNS/Intensity Rt | + | |__________________| + | | + | | + | \|/ + | #10 ____________________ + W | | + A | LTP | + I |__________________| + T | + | | + F | + O \|/ + R #11 ____________________ + | | | + R | Time -> Freq | + I |__________________| + G | + H | + T | + | \|/ + C #12 ____________________ + H | | + A | TNS Inverse | + N |__________________| + N | + E | + L | + | \|/ + | #13 ____________________ + | | | + | | Long Term Synth | + | |__________________| + | | + | | + | | + \|/ \|/ +#14 ____________________ #18 ____________________ + | | | | + | TNS | | TNS | + |__________________| |__________________| + | | + | | + | | + \|/ \|/ +#15 ____________________ #19 ____________________ + | | | | + | qFormatNorm | | qFormatNorm | + |__________________| |__________________| + | | + | | + | | + \|/ \|/ +#16 ____________________ #20 ____________________ + | | | | + | Freq / Time | | Freq / Time | + |__________________| |__________________| + | | + | | + | | + \|/ \|/ +#17 ____________________ #21 ____________________ + | | | | + | Limit Buffer | | Limit Buffer | + |__________________| |__________________| + | | + | | + | | + \|/ \|/ +#22 ______________________________________________________________________ + | | + | Write Output | + |____________________________________________________________________| + + +------------------------------------------------------------------------------ + REQUIREMENTS + + PacketVideo Document # CCC-AUD-AAC-ERS-0003 + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +#include "s_tdec_int_chan.h" +#include "s_tdec_int_file.h" +#include "aac_mem_funcs.h" +#include "sfb.h" /* Where samp_rate_info[] is declared */ +#include "e_tmp4audioobjecttype.h" +#include "e_elementid.h" + + +#include "get_adif_header.h" +#include "get_adts_header.h" +#include "get_audio_specific_config.h" +#include "ibstream.h" /* where getbits is declared */ + +#include "huffman.h" /* where huffdecode is declared */ +#include "get_prog_config.h" +#include "getfill.h" +#include "pns_left.h" + +#include "apply_ms_synt.h" +#include "pns_intensity_right.h" +#include "q_normalize.h" +#include "long_term_prediction.h" +#include "long_term_synthesis.h" +#include "ltp_common_internal.h" +#include "apply_tns.h" + +#include "window_block_fxp.h" + +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ +#include "get_dse.h" + +#include "sbr_applied.h" +#include "sbr_open.h" +#include "get_sbr_bitstream.h" +#include "e_sbr_element_id.h" + +#include "get_cce.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +OSCL_EXPORT_REF Int PVMP4AudioDecodeFrame( + tPVMP4AudioDecoderExternal *pExt, + void *pMem) +{ + Int frameLength; /* Helper variable */ + Int ch; + Int id_syn_ele; + UInt initialUsedBits; /* Unsigned for C55x */ + Int qFormatNorm; + Int qPredictedSamples; + Bool leaveGetLoop; + MC_Info *pMC_Info; /* Helper pointer */ + FrameInfo *pFrameInfo; /* Helper pointer */ + tDec_Int_File *pVars; /* Helper pointer */ + tDec_Int_Chan *pChVars[Chans]; /* Helper pointer */ + + per_chan_share_w_fxpCoef *pChLeftShare; /* Helper pointer */ + per_chan_share_w_fxpCoef *pChRightShare; /* Helper pointer */ + + + + Int status = MP4AUDEC_SUCCESS; + + + Bool empty_frame; + +#ifdef AAC_PLUS + + SBRDECODER_DATA *sbrDecoderData; + SBR_DEC *sbrDec; + SBRBITSTREAM *sbrBitStream; + +#endif + /* + * Initialize "helper" pointers to existing memory. + */ + pVars = (tDec_Int_File *)pMem; + + + + pMC_Info = &pVars->mc_info; + + pChVars[LEFT] = &pVars->perChan[LEFT]; + pChVars[RIGHT] = &pVars->perChan[RIGHT]; + + pChLeftShare = pChVars[LEFT]->pShareWfxpCoef; + pChRightShare = pChVars[RIGHT]->pShareWfxpCoef; + + +#ifdef AAC_PLUS + + sbrDecoderData = (SBRDECODER_DATA *) & pVars->sbrDecoderData; + sbrDec = (SBR_DEC *) & pVars->sbrDec; + sbrBitStream = pVars->sbrBitStr; + +#ifdef PARAMETRICSTEREO + sbrDecoderData->hParametricStereoDec = (HANDLE_PS_DEC) & pVars->sbrDecoderData.ParametricStereoDec; +#endif + +#endif + /* + * Translate input buffer variables. + */ + pVars->inputStream.pBuffer = pExt->pInputBuffer; + + pVars->inputStream.inputBufferCurrentLength = (UInt)pExt->inputBufferCurrentLength; + + pVars->inputStream.availableBits = + (UInt)(pExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT); + + initialUsedBits = + (UInt)((pExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) + + pExt->remainderBits); + + pVars->inputStream.usedBits = initialUsedBits; + + /* + * Verified that vital parameters have not changed, after they were set + */ + if (pVars->parameters_acquired) + { + Int32 temp = samp_rate_info[pVars->mc_info.sampling_rate_idx].samp_rate; + +#ifdef AAC_PLUS + temp <<= (pVars->mc_info.upsamplingFactor - 1); +#endif + + if (pExt->samplingRate != temp) + { + status = MP4AUDEC_INVALID_FRAME; + } + + + if ((pExt->audioObjectType != pVars->mc_info.audioObjectType) || + (pExt->encodedChannels != pVars->mc_info.nch)) + { + status = MP4AUDEC_INVALID_FRAME; + } + + } + + + + if (initialUsedBits > pVars->inputStream.availableBits) + { + status = MP4AUDEC_INVALID_FRAME; + } + else if (pVars->bno == 0) + { + /* + * Attempt to read in ADIF format first because it is easily identified. + * If its not an ADIF bitstream, get_adif_header rewinds the "pointer" + * (actually usedBits). + */ + status = + get_adif_header( + pVars, + &(pVars->scratch.scratch_prog_config)); + + byte_align(&pVars->inputStream); + + if (status == SUCCESS) + { + pVars->prog_config.file_is_adts = FALSE; + } + else /* we've tried simple audio config, adif, then it should be adts */ + { + pVars->prog_config.file_is_adts = TRUE; + } + } + else if ((pVars->bno == 1) && (pVars->prog_config.file_is_adts == FALSE)) + { + + /* + * There might be an ID_END element following immediately after the + * AudioSpecificConfig header. This syntactic element should be read + * and byte_aligned before proceeds to decode "real" AAC raw data. + */ + id_syn_ele = (Int)getbits(LEN_SE_ID, &pVars->inputStream) ; + + if (id_syn_ele == ID_END) + { + + byte_align(&pVars->inputStream); + + pExt->inputBufferUsedLength = + pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT; + + pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK; + + pVars->bno++; + + return(status); + } + else + { + /* + * Rewind bitstream pointer so that the syntactic element can be + * read when decoding raw bitstream + */ + pVars->inputStream.usedBits -= LEN_SE_ID; + } + + } + + if (pVars->prog_config.file_is_adts == TRUE) + { + /* + * If file is adts format, let the decoder handle only on data raw + * block at the time, once the last (or only) data block has been + * processed, then synch on the next header + */ + if (pVars->prog_config.headerless_frames) + { + pVars->prog_config.headerless_frames--; /* raw data block counter */ + } + else + { + status = get_adts_header(pVars, + &(pVars->syncword), + &(pVars->invoke), + 3); /* CorrectlyReadFramesCount */ + + if (status != SUCCESS) + { + status = MP4AUDEC_LOST_FRAME_SYNC; /* we lost track of header */ + } + } + } + else + { + byte_align(&pVars->inputStream); + } + +#ifdef AAC_PLUS + sbrBitStream->NrElements = 0; + sbrBitStream->NrElementsCore = 0; + +#endif + + /* + * The variable leaveGetLoop is used to signal that the following + * loop can be left, which retrieves audio syntatic elements until + * an ID_END is found, or an error occurs. + */ + leaveGetLoop = FALSE; + empty_frame = TRUE; + + + + + while ((leaveGetLoop == FALSE) && (status == SUCCESS)) + { + /* get audio syntactic element */ + id_syn_ele = (Int)get9_n_lessbits(LEN_SE_ID, &pVars->inputStream); + + /* + * As fractional frames are a possible input, check that parsing does not + * go beyond the available bits before parsing the syntax. + */ + if (pVars->inputStream.usedBits > pVars->inputStream.availableBits) + { + status = MP4AUDEC_INCOMPLETE_FRAME; /* possible EOF or fractional frame */ + id_syn_ele = ID_END; /* quit while-loop */ + } + + switch (id_syn_ele) + { + case ID_END: /* terminator field */ + leaveGetLoop = TRUE; + break; + + case ID_SCE: /* single channel */ + case ID_CPE: /* channel pair */ + empty_frame = FALSE; + status = huffdecode(id_syn_ele, + &(pVars->inputStream), + pVars, + pChVars + ); + +#ifdef AAC_PLUS + sbrBitStream->sbrElement[sbrBitStream->NrElements].ElementID = id_syn_ele; + sbrBitStream->NrElementsCore++; +#endif + break; + + + + case ID_PCE: /* program config element */ + /* + * PCE are not accepted in the middle of a + * raw_data_block. If found, a possible error may happen + * If a PCE is encountered during the first 2 frames, + * it will be read and accepted + * if its tag matches the first, with no error checking + * (inside of get_prog_config). Redundant PCE will be accepted too + */ + + + status = get_prog_config(pVars, + &(pVars->scratch.scratch_prog_config)); + + if (status != SUCCESS) + { + status = MP4AUDEC_PCE_CHANGE_REQUEST; + } + + break; + + case ID_FIL: /* fill element */ +#ifdef AAC_PLUS + if (pExt->aacPlusEnabled == true) + { + get_sbr_bitstream(sbrBitStream, &pVars->inputStream); + } + else + { + getfill(&pVars->inputStream); + } +#else + getfill(&pVars->inputStream); +#endif + + break; + + case ID_DSE: /* Data Streaming element */ + get_dse(pVars->share.data_stream_bytes, + &pVars->inputStream); + break; + + + + default: /* Unsupported element, including ID_LFE */ + status = -1; /* ERROR CODE needs to be updated */ + break; + + } /* end switch() */ + + } /* end while() */ + + byte_align(&pVars->inputStream); + + /* + + After parsing the first frame ( bno=0 (adif), bno=1 (raw)) + verify if implicit signalling is forcing to upsample AAC with + no AAC+/eAAC+ content. Verify that the frame is not empty + If so, disable upsampling + */ + +#ifdef AAC_PLUS + if ((pVars->bno <= 1) && (empty_frame == FALSE)) + { + if (!sbrBitStream->NrElements) + { + PVMP4AudioDecoderDisableAacPlus(pExt, pMem); + } + } +#endif + + /* + * There might be an empty raw data block with only a + * ID_END element or non audio ID_DSE, ID_FIL + * This is an "illegal" condition but this trap + * avoids any further processing + */ + + if (empty_frame == TRUE) + { + pExt->inputBufferUsedLength = + pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT; + + pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK; + + pVars->bno++; + + return(status); + + } + +#ifdef AAC_PLUS + if (sbrBitStream->NrElements) + { + if (pExt->aacPlusEnabled == true) + { + /* for every core SCE or CPE there must be an SBR element, otherwise sths. wrong */ + if (sbrBitStream->NrElements != sbrBitStream->NrElementsCore) + { + if (pVars->bno <= 1) + { + /* + * Mismatch information indicate a problem on stream + * then default back to AAC + */ + pVars->mc_info.audioObjectType = MP4AUDIO_AAC_LC; + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_AAC_LC; + + PVMP4AudioDecoderDisableAacPlus(pExt, pMem); + + sbrBitStream->NrElements = 0; /* disable aac processing */ + } + else + { + status = MP4AUDEC_INVALID_FRAME; + } + } // else this is what is expected + } + + } + else + { + /* + * This is AAC, but if aac+/eaac+ was declared in the stream, and there is not sbr content + * something is wrong + */ + if ((pMC_Info->sbrPresentFlag || pMC_Info->psPresentFlag) && (pExt->aacPlusEnabled == true)) + { + status = MP4AUDEC_INVALID_FRAME; + } + } +#endif + + + /* + * Signal processing section. + */ + frameLength = pVars->frameLength; + + if (status == SUCCESS) + { + /* + * PNS and INTENSITY STEREO and MS + */ + + pFrameInfo = pVars->winmap[pChVars[LEFT]->wnd]; + + pns_left(pFrameInfo, + pChLeftShare->group, + pChLeftShare->cb_map, + pChLeftShare->factors, + pChLeftShare->lt_status.sfb_prediction_used, + pChLeftShare->lt_status.ltp_data_present, + pChVars[LEFT]->fxpCoef, + pChLeftShare->qFormat, + &(pVars->pns_cur_noise_state)); + + /* + * For dual-mono clips, process second channel as well + */ + + if ((pMC_Info->ch_info[0].cpe == ID_SCE) && (pMC_Info->nch > 1)) + { + pFrameInfo = pVars->winmap[pChVars[RIGHT]->wnd]; + + pns_left(pFrameInfo, + pChRightShare->group, + pChRightShare->cb_map, + pChRightShare->factors, + pChRightShare->lt_status.sfb_prediction_used, + pChRightShare->lt_status.ltp_data_present, + pChVars[RIGHT]->fxpCoef, + pChRightShare->qFormat, + &(pVars->pns_cur_noise_state)); + } + + + /* + * apply_ms_synt can only be ran for common windows. + * (where both the left and right channel share the + * same grouping, window length, etc. + * + * pVars->hasmask will be > 0 only if + * common windows are enabled for this frame. + */ + + if (pVars->hasmask > 0) + { + apply_ms_synt(pFrameInfo, + pChLeftShare->group, + pVars->mask, + pChLeftShare->cb_map, + pChVars[LEFT]->fxpCoef, + pChVars[RIGHT]->fxpCoef, + pChLeftShare->qFormat, + pChRightShare->qFormat); + } + + for (ch = 0; (ch < pMC_Info->nch); ch++) + { + pFrameInfo = pVars->winmap[pChVars[ch]->wnd]; + + /* + * Apply right channel properties only if channel is stereo + * avoid for dual-mono cases + */ + + if ((ch > 0) && (pMC_Info->ch_info[0].cpe == ID_CPE)) + { + pns_intensity_right( + pVars->hasmask, + pFrameInfo, + pChRightShare->group, + pVars->mask, + pChRightShare->cb_map, + pChLeftShare->factors, + pChRightShare->factors, + pChRightShare->lt_status.sfb_prediction_used, + pChRightShare->lt_status.ltp_data_present, + pChVars[LEFT]->fxpCoef, + pChVars[RIGHT]->fxpCoef, + pChLeftShare->qFormat, + pChRightShare->qFormat, + &(pVars->pns_cur_noise_state)); + } + + if (pChVars[ch]->pShareWfxpCoef->lt_status.ltp_data_present != FALSE) + { + /* + * LTP - Long Term Prediction + */ + + qPredictedSamples = long_term_prediction( + pChVars[ch]->wnd, + pChVars[ch]->pShareWfxpCoef->lt_status. + weight_index, + pChVars[ch]->pShareWfxpCoef->lt_status. + delay, + pChVars[ch]->ltp_buffer, + pVars->ltp_buffer_state, + pChVars[ch]->time_quant, + pVars->share.predictedSamples, /* Scratch */ + frameLength); + + trans4m_time_2_freq_fxp( + pVars->share.predictedSamples, + pChVars[ch]->wnd, + pChVars[ch]->wnd_shape_prev_bk, + pChVars[ch]->wnd_shape_this_bk, + &qPredictedSamples, + pVars->scratch.fft); /* scratch memory for FFT */ + + + /* + * To solve a potential problem where a pointer tied to + * the qFormat was being incremented, a pointer to + * pChVars[ch]->qFormat is passed in here rather than + * the address of qPredictedSamples. + * + * Neither values are actually needed in the case of + * inverse filtering, but the pointer was being + * passed (and incremented) regardless. + * + * So, the solution is to pass a space of memory + * that a pointer can happily point to. + */ + + /* This is the inverse filter */ + apply_tns( + pVars->share.predictedSamples, /* scratch re-used for each ch */ + pChVars[ch]->pShareWfxpCoef->qFormat, /* Not used by the inv_filter */ + pFrameInfo, + &(pChVars[ch]->pShareWfxpCoef->tns), + TRUE, /* TRUE is FIR */ + pVars->scratch.tns_inv_filter); + + /* + * For the next function long_term_synthesis, + * the third param win_sfb_top[], and + * the tenth param coef_per_win, + * are used differently that in the rest of the project. This + * is because originally the ISO code was going to have + * these parameters change as the "short window" changed. + * These are all now the same value for each of the eight + * windows. This is why there is a [0] at the + * end of each of theses parameters. + * Note in particular that win_sfb_top was originally an + * array of pointers to arrays, but inside long_term_synthesis + * it is now a simple array. + * When the rest of the project functions are changed, the + * structure FrameInfo changes, and the [0]'s are removed, + * this comment could go away. + */ + long_term_synthesis( + pChVars[ch]->wnd, + pChVars[ch]->pShareWfxpCoef->max_sfb, + pFrameInfo->win_sfb_top[0], /* Look above */ + pChVars[ch]->pShareWfxpCoef->lt_status.win_prediction_used, + pChVars[ch]->pShareWfxpCoef->lt_status.sfb_prediction_used, + pChVars[ch]->fxpCoef, /* input and output */ + pChVars[ch]->pShareWfxpCoef->qFormat, /* input and output */ + pVars->share.predictedSamples, + qPredictedSamples, /* q format for previous aray */ + pFrameInfo->coef_per_win[0], /* Look above */ + NUM_SHORT_WINDOWS, + NUM_RECONSTRUCTED_SFB); + + } /* end if (pChVars[ch]->lt_status.ltp_data_present != FALSE) */ + + } /* for(ch) */ + + for (ch = 0; (ch < pMC_Info->nch); ch++) + { + + pFrameInfo = pVars->winmap[pChVars[ch]->wnd]; + + /* + * TNS - Temporal Noise Shaping + */ + + /* This is the forward filter + * + * A special note: Scratch memory is not used by + * the forward filter, but is passed in to maintain + * common interface for inverse and forward filter + */ + apply_tns(pChVars[ch]->fxpCoef, + pChVars[ch]->pShareWfxpCoef->qFormat, + pFrameInfo, + &(pChVars[ch]->pShareWfxpCoef->tns), + FALSE, /* FALSE is IIR */ + pVars->scratch.tns_inv_filter); + + /* + * Normalize the q format across all scale factor bands + * to one value. + */ + qFormatNorm = q_normalize(pChVars[ch]->pShareWfxpCoef->qFormat, + pFrameInfo, + pChVars[ch]->abs_max_per_window, + pChVars[ch]->fxpCoef); + + /* + * filterbank - converts frequency coeficients to time domain. + */ + +#ifdef AAC_PLUS + if (sbrBitStream->NrElements == 0 && pMC_Info->upsamplingFactor == 1) + { + trans4m_freq_2_time_fxp_2( + pChVars[ch]->fxpCoef, + pChVars[ch]->time_quant, + pChVars[ch]->wnd, /* window sequence */ + pChVars[ch]->wnd_shape_prev_bk, + pChVars[ch]->wnd_shape_this_bk, + qFormatNorm, + pChVars[ch]->abs_max_per_window, + pVars->scratch.fft, + &pExt->pOutputBuffer[ch]); + /* + * Update LTP buffers if needed + */ + + if (pVars->mc_info.audioObjectType == MP4AUDIO_LTP) + { + Int16 * pt = &pExt->pOutputBuffer[ch]; + Int16 * ptr = &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state]); + Int16 x, y; + for (Int32 i = HALF_LONG_WINDOW; i != 0; i--) + { + x = *pt; + pt += 2; + y = *pt; + pt += 2; + *(ptr++) = x; + *(ptr++) = y; + } + } + } + else + { + trans4m_freq_2_time_fxp_1( + pChVars[ch]->fxpCoef, + pChVars[ch]->time_quant, + &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state + 288]), + pChVars[ch]->wnd, /* window sequence */ + pChVars[ch]->wnd_shape_prev_bk, + pChVars[ch]->wnd_shape_this_bk, + qFormatNorm, + pChVars[ch]->abs_max_per_window, + pVars->scratch.fft); + + } +#else + + trans4m_freq_2_time_fxp_2( + pChVars[ch]->fxpCoef, + pChVars[ch]->time_quant, + pChVars[ch]->wnd, /* window sequence */ + pChVars[ch]->wnd_shape_prev_bk, + pChVars[ch]->wnd_shape_this_bk, + qFormatNorm, + pChVars[ch]->abs_max_per_window, + pVars->scratch.fft, + &pExt->pOutputBuffer[ch]); + /* + * Update LTP buffers only if needed + */ + + if (pVars->mc_info.audioObjectType == MP4AUDIO_LTP) + { + Int16 * pt = &pExt->pOutputBuffer[ch]; + Int16 * ptr = &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state]); + Int16 x, y; + for (Int32 i = HALF_LONG_WINDOW; i != 0; i--) + { + x = *pt; + pt += 2; + y = *pt; + pt += 2; + *(ptr++) = x; + *(ptr++) = y; + } + + } + +#endif + /* Update the window shape */ + pChVars[ch]->wnd_shape_prev_bk = pChVars[ch]->wnd_shape_this_bk; + + } /* end for() */ + + /* + * Copy to the final output buffer, taking into account the desired + * channels from the calling environment, the actual channels, and + * whether the data should be interleaved or not. + * + * If the stream had only one channel, write_output will not use + * the right channel data. + * + */ + + + /* CONSIDER USE OF DMA OPTIMIZATIONS WITHIN THE write_output FUNCTION. + * + * It is presumed that the ltp_buffer will reside in internal (fast) + * memory, while the pExt->pOutputBuffer will reside in external + * (slow) memory. + * + */ + +#ifdef AAC_PLUS + + if (sbrBitStream->NrElements || pMC_Info->upsamplingFactor == 2) + { + + if (pVars->bno <= 1) /* allows console to operate with ADIF and audio config */ + { + if (sbrDec->outSampleRate == 0) /* do it only once (disregarding of signaling type) */ + { + sbr_open(samp_rate_info[pVars->mc_info.sampling_rate_idx].samp_rate, + sbrDec, + sbrDecoderData, + pVars->mc_info.bDownSampledSbr); + } + } + pMC_Info->upsamplingFactor = + sbrDecoderData->SbrChannel[0].frameData.sbr_header.sampleRateMode; + + /* reuse right aac spectrum channel */ + { + Int16 *pt_left = &(pChVars[LEFT ]->ltp_buffer[pVars->ltp_buffer_state]); + Int16 *pt_right = &(pChVars[RIGHT]->ltp_buffer[pVars->ltp_buffer_state]); + + if (sbr_applied(sbrDecoderData, + sbrBitStream, + pt_left, + pt_right, + pExt->pOutputBuffer, + sbrDec, + pVars, + pMC_Info->nch) != SBRDEC_OK) + { + status = MP4AUDEC_INVALID_FRAME; + } + } + + + } /* if( pExt->aacPlusEnabled == FALSE) */ +#endif + + /* + * Copied mono data in both channels or just leave it as mono, + * according with desiredChannels (default is 2) + */ + + if (pExt->desiredChannels == 2) + { + +#if defined(AAC_PLUS) +#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR) + if (pMC_Info->nch != 2 && pMC_Info->psPresentFlag != 1) +#else + if (pMC_Info->nch != 2) +#endif +#else + if (pMC_Info->nch != 2) +#endif + { + /* mono */ + + + Int16 * pt = &pExt->pOutputBuffer[0]; + Int16 * pt2 = &pExt->pOutputBuffer[1]; + Int i; + if (pMC_Info->upsamplingFactor == 2) + { + for (i = 0; i < 1024; i++) + { + *pt2 = *pt; + pt += 2; + pt2 += 2; + } + pt = &pExt->pOutputBuffer_plus[0]; + pt2 = &pExt->pOutputBuffer_plus[1]; + + for (i = 0; i < 1024; i++) + { + *pt2 = *pt; + pt += 2; + pt2 += 2; + } + } + else + { + for (i = 0; i < 1024; i++) + { + *pt2 = *pt; + pt += 2; + pt2 += 2; + } + } + + } + +#if defined(AAC_PLUS) +#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR) + + else if (pMC_Info->psPresentFlag == 1) + { + Int32 frameSize = 0; + if (pExt->aacPlusEnabled == false) + { + /* + * Decoding eaac+ when only aac is enabled, copy L into R + */ + frameSize = 1024; + } + else if (sbrDecoderData->SbrChannel[0].syncState != SBR_ACTIVE) + { + /* + * Decoding eaac+ when no PS data was found, copy upsampled L into R + */ + frameSize = 2048; + } + + Int16 * pt = &pExt->pOutputBuffer[0]; + Int16 * pt2 = &pExt->pOutputBuffer[1]; + Int i; + for (i = 0; i < frameSize; i++) + { + *pt2 = *pt; + pt += 2; + pt2 += 2; + } + } +#endif +#endif + + } + else + { + +#if defined(AAC_PLUS) +#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR) + if (pMC_Info->nch != 2 && pMC_Info->psPresentFlag != 1) +#else + if (pMC_Info->nch != 2) +#endif +#else + if (pMC_Info->nch != 2) +#endif + { + /* mono */ + Int16 * pt = &pExt->pOutputBuffer[0]; + Int16 * pt2 = &pExt->pOutputBuffer[0]; + Int i; + + if (pMC_Info->upsamplingFactor == 2) + { + for (i = 0; i < 1024; i++) + { + *pt2++ = *pt; + pt += 2; + } + + pt = &pExt->pOutputBuffer_plus[0]; + pt2 = &pExt->pOutputBuffer_plus[0]; + + for (i = 0; i < 1024; i++) + { + *pt2++ = *pt; + pt += 2; + } + } + else + { + for (i = 0; i < 1024; i++) + { + *pt2++ = *pt; + pt += 2; + } + } + + } + + } + + /* pVars->ltp_buffer_state cycles between 0 and 1024. The value + * indicates the location of the data corresponding to t == -2. + * + * | t == -2 | t == -1 | pVars->ltp_buffer_state == 0 + * + * | t == -1 | t == -2 | pVars->ltp_buffer_state == 1024 + * + */ + +#ifdef AAC_PLUS + if (sbrBitStream->NrElements == 0 && pMC_Info->upsamplingFactor == 1) + { + pVars->ltp_buffer_state ^= frameLength; + } + else + { + pVars->ltp_buffer_state ^= (frameLength + 288); + } +#else + pVars->ltp_buffer_state ^= frameLength; +#endif + + if (pVars->bno <= 1) + { + /* + * to set these values only during the second call + * when they change. + */ + + pVars->parameters_acquired = true; + + pExt->samplingRate = + samp_rate_info[pVars->mc_info.sampling_rate_idx].samp_rate; + + pVars->mc_info.implicit_channeling = 0; /* disable flag, as this is allowed + * only the first time + */ + +#ifdef AAC_PLUS + + if (pMC_Info->upsamplingFactor == 2) + { + pExt->samplingRate *= pMC_Info->upsamplingFactor; + pExt->aacPlusUpsamplingFactor = pMC_Info->upsamplingFactor; + } +#endif + + pExt->extendedAudioObjectType = pMC_Info->ExtendedAudioObjectType; + pExt->audioObjectType = pMC_Info->audioObjectType; + + pExt->encodedChannels = pMC_Info->nch; + pExt->frameLength = pVars->frameLength; + + + pExt->multichannel_detected = pVars->multichannel_detected; + if (pVars->multichannel_detected) + { + pExt->multichannel_numChannels = pVars->multichannel_numChannels ; + } + } + + pVars->bno++; + + + /* + * Using unit analysis, the bitrate is a function of the sampling rate, bits, + * points in a frame + * + * bits samples frame + * ---- = --------- * bits * ------- + * sec sec sample + * + * To save a divide, a shift is used. Presently only the value of + * 1024 is used by this library, so make it the most accurate for that + * value. This may need to be updated later. + */ + + pExt->bitRate = (pExt->samplingRate * + (pVars->inputStream.usedBits - initialUsedBits)) >> 10; /* LONG_WINDOW 1024 */ + + pExt->bitRate >>= (pMC_Info->upsamplingFactor - 1); + + + } /* end if (status == SUCCESS) */ + + + if (status != MP4AUDEC_SUCCESS) + { + /* + * A non-SUCCESS decoding could be due to an error on the bitstream or + * an incomplete frame. As access to the bitstream beyond frame boundaries + * are not allowed, in those cases the bitstream reading routine return a 0 + * Zero values guarantees that the data structures are filled in with values + * that eventually will signal an error (like invalid parameters) or that allow + * completion of the parsing routine. Either way, the partial frame condition + * is verified at this time. + */ + if (pVars->prog_config.file_is_adts == TRUE) + { + status = MP4AUDEC_LOST_FRAME_SYNC; + pVars->prog_config.headerless_frames = 0; /* synchronization forced */ + } + else + { + /* + * Check if the decoding error was due to buffer overrun, if it was, + * update status + */ + if (pVars->inputStream.usedBits > pVars->inputStream.availableBits) + { + /* all bits were used but were not enough to complete decoding */ + pVars->inputStream.usedBits = pVars->inputStream.availableBits; + + status = MP4AUDEC_INCOMPLETE_FRAME; /* possible EOF or fractional frame */ + } + } + } + + /* + * Translate from units of bits back into units of words. + */ + + pExt->inputBufferUsedLength = + pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT; + + pExt->remainderBits = (Int)(pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK); + + + + return (status); + +} /* PVMP4AudioDecoderDecodeFrame */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecodergetmemrequirements.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecodergetmemrequirements.cpp new file mode 100644 index 0000000..fed8828 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecodergetmemrequirements.cpp @@ -0,0 +1,119 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecodergetmemrequirements.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: None + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + size = amount of memory needed to be allocated by the calling + environment. + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function returns the amount of internal memory needed by the library. + Presently this is a constant value, but could later be more sophisticated + by taking into account mono or stereo, and whether LTP is to be used. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + +------------------------------------------------------------------------------ + PSEUDO-CODE + + size = sizeof(tDec_Int_File); + + RETURN (size) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +OSCL_EXPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void) +{ + UInt32 size; + + size = (UInt32) sizeof(tDec_Int_File); + + + return (size); + +} /* PVMP4AudioDecoderGetMemRequirements() */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderinitlibrary.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderinitlibrary.cpp new file mode 100644 index 0000000..fbeb088 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderinitlibrary.cpp @@ -0,0 +1,369 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecoderinitlibrary.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external application-program interface (API) + structure that a client program uses to communicate information + with this library. Among the items in this structure is a pointer + to the input and output buffers, data for handling the input buffer + and output information. Look in PVMP4AudioDecoder_API.h for all the + fields to this structure. Data type pointer to a + tPVMP4AudioDecoderExternal structure. + + pMem = pointer to allocated memory, of the size returned by the function + PVMP4AudioDecoderGetMemRequirements. This is a void pointer for + two reasons: + 1) So the external program does not need all of the header files + for all of the fields in the structure tDec_Int_File + 2) To hide data and the implementation of the program. Even knowing + how data is stored can help in reverse engineering software. + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 (SUCCESS). Presently there is no error checking in this + function. + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Initializes the internal memory for the MP4 Audio Decoder library. + Also sets relevant values for the external interface structure, clears + the bit rate, channel count, sampling rate, and number of used buffer + elements. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. +------------------------------------------------------------------------------ + PSEUDO-CODE + + pVars = pMem; + + CALL pv_memset( + to = pVars, + c = 0, + n = sizeof(tDec_Int_File)) + MODIFYING(*pVars = 0) + RETURNING(nothing) + + pVars->current_program = -1 + pVars->mc_info.sampling_rate_idx = Fs_44 + pVars->frameLength = LONG_WINDOW + + + pVars->winmap[ONLY_LONG_SEQUENCE] = &pVars->longFrameInfo; + pVars->winmap[LONG_START_SEQUENCE] = &pVars->longFrameInfo; + pVars->winmap[EIGHT_SHORT_SEQUENCE] = &pVars->shortFrameInfo; + pVars->winmap[LONG_STOP_SEQUENCE] = &pVars->longFrameInfo; + + CALL infoinit( + samp_rate_indx = pVars->mc_info.sampling_rate_idx, + ppWin_seq_info = pVars->winmap, + pSfbwidth128 = pVars->SFBWidth128) + MODIFYING(ppWinSeq_info) + MODIFYING(pSfbwidth128) + RETURNING(nothing) + + pExt->bitRate = 0; + pExt->encodedChannels = 0; + pExt->samplingRate = 0; + pExt->inputBufferUsedLength = 0; + + MODIFY(pExt) + MODIFY(pMem) + RETURN(SUCCESS) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "e_progconfigconst.h" + +#include "huffman.h" /* For the definition of infoinit */ +#include "aac_mem_funcs.h" /* For pv_memset */ +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ +#include "s_tdec_int_chan.h" +#include "sfb.h" /* samp_rate_info[] is declared here */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +OSCL_EXPORT_REF Int PVMP4AudioDecoderInitLibrary( + tPVMP4AudioDecoderExternal *pExt, + void *pMem) +{ + tDec_Int_File *pVars; + + pVars = (tDec_Int_File *)pMem; + + /* + * Initialize all memory. The pointers to channel memory will be + * set to zero also. + */ + pv_memset( + pVars, + 0, + sizeof(tDec_Int_File)); + + /* + * Pick default values for the library. + */ + pVars->perChan[0].fxpCoef = pVars->fxpCoef[0]; + pVars->perChan[1].fxpCoef = pVars->fxpCoef[1]; + + /* Here, the "shared memory" pointer is set to point + * at the 1024th element of fxpCoef, because those spaces + * in memory are not used until the filterbank is called. + * + * Therefore, any variables that are only used before + * the filterbank can occupy this same space in memory. + */ + + pVars->perChan[0].pShareWfxpCoef = (per_chan_share_w_fxpCoef *) + & (pVars->perChan[0].fxpCoef[1024]); + + pVars->perChan[1].pShareWfxpCoef = (per_chan_share_w_fxpCoef *) + & (pVars->perChan[1].fxpCoef[1024]); + + /* + * This next line informs the function get_prog_config that no + * configuration has been found thus far, so it is a default + * configuration. + */ + + pVars->current_program = -1; + pVars->mc_info.sampling_rate_idx = Fs_44; /* Fs_44 = 4, 44.1kHz */ + + pVars->mc_info.ch_info[0].tag = 0; + + pVars->parameters_acquired = false; + + + /* + * In the future, the frame length will change with MP4 file format. + * Presently this variable is used to simply the unit test for + * the function PVMP4AudioDecodeFrame() .. otherwise the test would + * have to pass around 1024 length arrays. + */ + pVars->frameLength = LONG_WINDOW; /* 1024*/ + + /* + * The window types ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE, and + * LONG_STOP_SEQUENCE share the same information. The only difference + * between the windows is accounted for in the "filterbank", in + * the function trans4m_freq_2_time_fxp() + */ + + pVars->winmap[ONLY_LONG_SEQUENCE] /* 0 */ = &pVars->longFrameInfo; + pVars->winmap[LONG_START_SEQUENCE] /* 1 */ = &pVars->longFrameInfo; + pVars->winmap[EIGHT_SHORT_SEQUENCE] /* 2 */ = &pVars->shortFrameInfo; + pVars->winmap[LONG_STOP_SEQUENCE] /* 3 */ = &pVars->longFrameInfo; + + infoinit( + pVars->mc_info.sampling_rate_idx, + (FrameInfo **)pVars->winmap, + pVars->SFBWidth128); + + + /* + * Clear out external output values. These values are set later at the end + * of PVMP4AudioDecodeFrames() + */ + pExt->bitRate = 0; + pExt->encodedChannels = 0; + pExt->samplingRate = 0; + pExt->aacPlusUpsamplingFactor = 1; /* Default for regular AAC */ + pVars->aacPlusEnabled = pExt->aacPlusEnabled; + + + pVars->multichannel_detected = false; + +#if defined(AAC_PLUS) + pVars->sbrDecoderData.setStreamType = 1; /* Enable Lock for AAC stream type setting */ +#endif + + /* + * Initialize input buffer variable. + */ + + pExt->inputBufferUsedLength = 0; + + + return (MP4AUDEC_SUCCESS); + +} /* PVMP4AudioDecoderInitLibrary */ + + +/* +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external application-program interface (API) + structure that a client program uses to communicate information + with this library. Among the items in this structure is a pointer + to the input and output buffers, data for handling the input buffer + and output information. Look in PVMP4AudioDecoder_API.h for all the + fields to this structure. Data type pointer to a + tPVMP4AudioDecoderExternal structure. + + pMem = pointer to allocated memory, of the size returned by the function + PVMP4AudioDecoderGetMemRequirements. This is a void pointer for + two reasons: + 1) So the external program does not need all of the header files + for all of the fields in the structure tDec_Int_File + 2) To hide data and the implementation of the program. Even knowing + how data is stored can help in reverse engineering software. + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 (SUCCESS). Presently there is no error checking in this + function. + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Disable SBR decoding functionality and set parameters accordingly + +------------------------------------------------------------------------------ + REQUIREMENTS + + +---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +OSCL_EXPORT_REF void PVMP4AudioDecoderDisableAacPlus( + tPVMP4AudioDecoderExternal *pExt, + void *pMem) +{ + tDec_Int_File *pVars; + + pVars = (tDec_Int_File *)pMem; + + if ((pVars->aacPlusEnabled == true) && (pExt->aacPlusEnabled == true)) + { + // disable only when makes sense + pVars->aacPlusEnabled = false; + pExt->aacPlusEnabled = false; + +#if defined(AAC_PLUS) + pVars->mc_info.upsamplingFactor = 1; + pVars->mc_info.psPresentFlag = 0; + pVars->mc_info.sbrPresentFlag = 0; + pVars->prog_config.sampling_rate_idx += 3; + pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED; + pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED; + + + pExt->samplingRate = samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate; + pExt->aacPlusUpsamplingFactor = 1; +#endif + } +} /* PVMP4AudioDecoderDisableAacPlus */ + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderresetbuffer.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderresetbuffer.cpp new file mode 100644 index 0000000..a5ff84f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderresetbuffer.cpp @@ -0,0 +1,321 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecoderresetbuffer.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tDec_Int_File structure. This structure + contains information that needs to persist between calls to + PVMP4AudioDecodeFrame + Data type void pointer, internally pointer to a tDec_Int_File + structure. + + Local Stores/Buffers/Pointers Needed: None + (The memory set aside in pMem performs this task) + + Global Stores/Buffers/Pointers Needed: None + + Outputs: None + + Pointers and Buffers Modified: + pMem contents are modified. + pMem->perChan[0].time_quant[0-1023]: contents are set to zero + pMem->perChan[1].time_quant[0-1023]: contents are set to zero + pMem->bno = 1 + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function is called when the same audio clip will be played again from + the begining. This situation happens when the "stop" button is pressed or + the "loop-mode" is selected on PVPlayer. Since it is the same audio clip to + be played again, the decoder does not need to reset the audioSpecificInfo. + However, the overlap-and-add buffer of the filterbank output needs to be + cleared, so that the decoder can re-start properly from the begining of + the audio. The frame number counter, pVars->bno, is set to 1 because the + audioSpecificInfo is decoded on pVars->bno==0 + +------------------------------------------------------------------------------ + REQUIREMENTS + + PacketVideo Document # CCC-AUD-AAC-ERS-0003 + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + subclause 1.6 + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ +#include "aac_mem_funcs.h" + +#ifdef AAC_PLUS +#include "s_sbr_frame_data.h" +#endif + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +OSCL_EXPORT_REF void PVMP4AudioDecoderResetBuffer(void *pMem) +{ + + tDec_Int_File *pVars; /* Helper pointer */ + +#ifdef AAC_PLUS + SBR_FRAME_DATA * hFrameData_1; + SBR_FRAME_DATA * hFrameData_2; +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + SBRDECODER_DATA *sbrDecoderData; +#endif +#endif + +#endif + /* + * Initialize "helper" pointers to existing memory. + */ + pVars = (tDec_Int_File *)pMem; + + /* + * Clear the overlap-and-add buffer of filterbank output. The audio + * clip will be played again from the beginning. + */ + pv_memset(pVars->perChan[LEFT].time_quant, + 0, + LONG_WINDOW*sizeof(pVars->perChan[LEFT].time_quant[0])); + + pv_memset(pVars->perChan[RIGHT].time_quant, + 0, + LONG_WINDOW*sizeof(pVars->perChan[RIGHT].time_quant[0])); + + +#ifdef AAC_PLUS + + if (!pVars->sbrDecoderData.setStreamType) /* reset only when stream type is defined */ + { + if (pVars->aacPlusEnabled == true) /* clear buffer only if they were used */ + { + + hFrameData_1 = (SBR_FRAME_DATA *) & pVars->sbrDecoderData.SbrChannel[LEFT].frameData; + hFrameData_2 = (SBR_FRAME_DATA *) & pVars->sbrDecoderData.SbrChannel[RIGHT].frameData; +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + sbrDecoderData = (SBRDECODER_DATA *) & pVars->sbrDecoderData; + sbrDecoderData->hParametricStereoDec = (HANDLE_PS_DEC) & pVars->sbrDecoderData.ParametricStereoDec; +#endif +#endif + + + pv_memset(&pVars->perChan[LEFT].ltp_buffer[0], + 0, + 288*sizeof(pVars->perChan[LEFT].ltp_buffer[0])); + pv_memset(&pVars->perChan[LEFT].ltp_buffer[1024 + 288], + 0, + 288*sizeof(pVars->perChan[LEFT].ltp_buffer[0])); + pv_memset(hFrameData_1->V, + 0, + 1152*sizeof(hFrameData_1->V[0])); + pv_memset(hFrameData_1->prevNoiseLevel_man, + 0, + MAX_NUM_NOISE_VALUES*sizeof(hFrameData_1->prevNoiseLevel_man[0])); + + + pv_memset(&pVars->perChan[RIGHT].ltp_buffer[0], + 0, + 288*sizeof(pVars->perChan[RIGHT].ltp_buffer[0])); + pv_memset(&pVars->perChan[RIGHT].ltp_buffer[1024 + 288], + 0, + 288*sizeof(pVars->perChan[RIGHT].ltp_buffer[0])); + pv_memset(hFrameData_2->V, + 0, + 1152*sizeof(hFrameData_2->V[0])); + + pv_memset(hFrameData_2->prevNoiseLevel_man, + 0, + MAX_NUM_NOISE_VALUES*sizeof(hFrameData_2->prevNoiseLevel_man[0])); + + + int i; + for (i = 0; i < 8; i++) + { + pv_memset((void *)&hFrameData_1->codecQmfBufferReal[i], + 0, + sizeof(**hFrameData_1->codecQmfBufferReal) << 5); + } + + + /* ---- */ + pv_memset((void *)hFrameData_1->BwVectorOld, + 0, + sizeof(*hFrameData_1->BwVectorOld)*MAX_NUM_PATCHES); + +#ifdef HQ_SBR + + for (i = 0; i < 5; i++) + { + pv_memset((void *)&hFrameData_1->fBuffer_man[i], + 0, + sizeof(**hFrameData_1->fBuffer_man)*64); + pv_memset((void *)&hFrameData_1->fBufferN_man[i], + 0, + sizeof(**hFrameData_1->fBufferN_man)*64); + } +#endif + + + /* ---- */ + + + + pv_memset((void *)hFrameData_1->HistsbrQmfBufferReal, + 0, + sizeof(*hFrameData_1->HistsbrQmfBufferReal)*6*SBR_NUM_BANDS); + +#ifdef HQ_SBR + pv_memset((void *)hFrameData_1->HistsbrQmfBufferImag, + 0, + sizeof(*hFrameData_1->HistsbrQmfBufferImag)*6*SBR_NUM_BANDS); +#endif + + if (pVars->sbrDec.LC_aacP_DecoderFlag == 1) /* clear buffer only for LC decoding */ + { + + for (i = 0; i < 8; i++) + { + pv_memset((void *)&hFrameData_2->codecQmfBufferReal[i], + 0, + sizeof(**hFrameData_1->codecQmfBufferReal) << 5); + } + + pv_memset((void *)hFrameData_2->HistsbrQmfBufferReal, + 0, + sizeof(*hFrameData_2->HistsbrQmfBufferReal)*6*SBR_NUM_BANDS); + + + pv_memset((void *)hFrameData_2->BwVectorOld, + 0, + sizeof(*hFrameData_2->BwVectorOld)*MAX_NUM_PATCHES); + +#ifdef HQ_SBR + + for (i = 0; i < 5; i++) + { + pv_memset((void *)&hFrameData_2->fBuffer_man[i], + 0, + sizeof(**hFrameData_2->fBuffer_man)*64); + pv_memset((void *)&hFrameData_2->fBufferN_man[i], + 0, + sizeof(**hFrameData_2->fBufferN_man)*64); + } +#endif + + } + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + else if (pVars->mc_info.psPresentFlag == 1) + { + for (i = 0; i < 3; i++) + { + pv_memset(sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferReal[i], + 0, + HYBRID_FILTER_LENGTH_m_1*sizeof(*sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferReal)); + pv_memset(sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferImag[i], + 0, + HYBRID_FILTER_LENGTH_m_1*sizeof(*sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferImag)); + } + } +#endif +#endif + + /* + * default to UPSAMPLING, as if the file is SBR_ACTIVE, this will be fine and will be + * fixed onced the new sbr header is found + * SBR headers contain SBT freq. range as well as control signals that do not require + * frequent changes. + * For streaming, the SBR header is sent twice per second. Also, an SBR header can be + * inserted at any time, if a change of parameters is needed. + */ + + pVars->sbrDecoderData.SbrChannel[LEFT].syncState = UPSAMPLING; + pVars->sbrDecoderData.SbrChannel[RIGHT].syncState = UPSAMPLING; + + } + } +#endif /* #ifdef AAC_PLUS */ + + /* reset frame count to 1 */ + pVars->bno = 1; + /* reset ADTS validation counter to force a clean search */ + pVars->invoke = 0; + + return ; + +} /* PVMP4AudioDecoderDecodeFrame */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4setaudioconfig.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4setaudioconfig.cpp new file mode 100644 index 0000000..bded4f0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/pvmp4setaudioconfig.cpp @@ -0,0 +1,340 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4setaudioconfig.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external interface structure. See the file + PVMP4AudioDecoder_API.h for a description of each field. + Data type of pointer to a tPVMP4AudioDecoderExternal + structure. + + pExt->pInputBuffer: pointer to input buffer containing input + bitstream + + pExt->inputBufferCurrentLength: number of bytes in the input buffer + + pExt->inputBufferUsedLength: number of bytes already consumed in + input buffer + + pExt->remainderBits: number of bits consumed in addition to + pExt->inputBufferUsedLength + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tDec_Int_File structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tDec_Int_File + structure. + + Local Stores/Buffers/Pointers Needed: None + (The memory set aside in pMem performs this task) + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 if no error occurred + MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred + MP4AUDEC_RECOVERABLE if a recoverable error occurred. + Presently a recoverable error does not exist, but this + was a requirement. + + + Pointers and Buffers Modified: + pMem contents are modified. + pExt: (more detail in the file PVMP4AudioDecoder_API.h) + inputBufferUsedLength - number of array elements used up by the stream. + remainderBits - remaining bits in the next UInt32 buffer + samplingRate - sampling rate in samples per sec + encodedChannels - channels found on the file (informative) + frameLength - length of the frame + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + PacketVideo Document # CCC-AUD-AAC-ERS-0003 + +------------------------------------------------------------------------------ + REFERENCES + + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "ibstream.h" /* where #define INBUF_ARRAY_INDEX_SHIFT */ +#include "sfb.h" /* Where samp_rate_info[] is declared */ + +#include "get_audio_specific_config.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ +#include "set_mc_info.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int PVMP4SetAudioConfig( + tPVMP4AudioDecoderExternal *pExt, + void *pMem, + Int upsamplingFactor, + Int samp_rate, + Int num_ch, + tMP4AudioObjectType audioObjectType) + +{ + + tDec_Int_File *pVars; /* Helper pointer */ + + Int status = MP4AUDEC_INCOMPLETE_FRAME; + + /* + * Initialize "helper" pointers to existing memory. + */ + pVars = (tDec_Int_File *)pMem; + /* + * Translate input buffer variables. + */ + pVars->inputStream.pBuffer = pExt->pInputBuffer; + + pVars->inputStream.availableBits = 0; + + pVars->inputStream.usedBits = 0; + + + + /* + * get sampling rate index + */ + + switch (samp_rate) + { + case 96000: + pVars->prog_config.sampling_rate_idx = 0; + break; + case 88200: + pVars->prog_config.sampling_rate_idx = 1; + break; + case 64000: + pVars->prog_config.sampling_rate_idx = 2; + break; + case 48000: + pVars->prog_config.sampling_rate_idx = 3; + break; + case 44100: + pVars->prog_config.sampling_rate_idx = 4; + break; + case 32000: + pVars->prog_config.sampling_rate_idx = 5; + break; + case 24000: + pVars->prog_config.sampling_rate_idx = 6; + break; + case 22050: + pVars->prog_config.sampling_rate_idx = 7; + break; + case 16000: + pVars->prog_config.sampling_rate_idx = 8; + break; + case 12000: + pVars->prog_config.sampling_rate_idx = 9; + break; + case 11025: + pVars->prog_config.sampling_rate_idx = 10; + break; + case 8000: + pVars->prog_config.sampling_rate_idx = 11; + break; + case 7350: + pVars->prog_config.sampling_rate_idx = 12; + break; + default: + status = -1; + + break; + } + + pVars->mc_info.sbrPresentFlag = 0; + pVars->mc_info.psPresentFlag = 0; +#ifdef AAC_PLUS + pVars->mc_info.bDownSampledSbr = 0; +#endif + pVars->mc_info.implicit_channeling = 0; + pVars->mc_info.nch = num_ch; + pVars->mc_info.upsamplingFactor = upsamplingFactor; + + + /* + * Set number of channels + */ + + if (num_ch == 2) + { + pVars->prog_config.front.ele_is_cpe[0] = 1; + } + else if (num_ch == 1) + { + pVars->prog_config.front.ele_is_cpe[0] = 0; + } + else + { + status = -1; /* do not support more than two channels */ + pVars->status = status; + return (status); + } + + + /* + * Set AAC bitstream + */ + + if ((audioObjectType == MP4AUDIO_AAC_LC) || + (audioObjectType == MP4AUDIO_LTP)) + { + pVars->aacPlusEnabled = false; + + status = set_mc_info(&(pVars->mc_info), + audioObjectType, /* previously profile */ + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[0], + pVars->prog_config.front.ele_is_cpe[0], + pVars->winmap, /*pVars->pWinSeqInfo,*/ + pVars->SFBWidth128); + } + else if ((audioObjectType == MP4AUDIO_SBR) || + (audioObjectType == MP4AUDIO_PS)) + { + pVars->aacPlusEnabled = true; + + + status = set_mc_info(&(pVars->mc_info), + MP4AUDIO_AAC_LC, + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[0], + pVars->prog_config.front.ele_is_cpe[0], + pVars->winmap, /*pVars->pWinSeqInfo,*/ + pVars->SFBWidth128); + + pVars->mc_info.sbrPresentFlag = 1; + if (audioObjectType == MP4AUDIO_PS) + { + pVars->mc_info.psPresentFlag = 1; + } + + if (upsamplingFactor == 1) + { +#ifdef AAC_PLUS + pVars->mc_info.bDownSampledSbr = 1; +#endif + + /* + * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz + */ + if (pVars->prog_config.sampling_rate_idx < 6) + { + pVars->aacPlusEnabled = false; + } + } + + } + else + { + status = -1; + } + + + /* + * Translate from units of bits back into units of words. + */ + pExt->inputBufferUsedLength = 0; + + pExt->remainderBits = 0; + + pVars->bno++; + + pExt->samplingRate = samp_rate * upsamplingFactor; + + pExt->aacPlusEnabled = pVars->aacPlusEnabled; + + /* + * we default to 2 channel, even for mono files, (where channels have same content) + * this is done to ensure support for enhanced aac+ with implicit signalling + */ + + pExt->encodedChannels = 2; + + pExt->frameLength = 1024; +#ifdef AAC_PLUS + pExt->aacPlusUpsamplingFactor = upsamplingFactor; +#endif + + pVars->status = status; + + return (status); + +} /* PVMP4AudioDecoderDecodeFrame */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/q_normalize.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/q_normalize.cpp new file mode 100644 index 0000000..673db9c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/q_normalize.cpp @@ -0,0 +1,331 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: q_normalize.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + qFormat[] = Array of qFormats, one per scalefactor band. [ Int ] + + pFrameInfo = Pointer to structure that holds information about each group. + (long block flag, number of windows, scalefactor bands, etc.) + [const FrameInfo] + + coef[] = Array of the spectral coefficients for one channel. [ Int32 ] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + min_q = The common q-format for the entire frame. [Int] + + Pointers and Buffers Modified: + coef[] = Array of spectral data, now normalized to one q-format. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This module first scans every scalefactor band for the frame, insuring that + at least one element in that scalefactor band is using all available bits. + If not, the elements in the scalefactor band are shifted up to use all 31 + data bits. The q-format is adjusted accordingly. + + This module then scans the q-formats for each scalefactor band. + Upon finding the minimum q-format in the frame, the coefficients in each + scalefactor band are normalized to the minimum q-format. + The minimum q-format is then returned to the calling function, which is now + the q-format for the entire frame. + +------------------------------------------------------------------------------ + REQUIREMENTS + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + + nwin = pFrameInfo->num_win; + + pQformat = &(qFormat[0]); + pSfbPerWin = &(pFrameInfo->sfb_per_win[0]); + pCoef = &(coef[0]); + + FOR (win = nwin; win > 0; win--) + + nsfb = *(pSfbPerWin++); + + FOR (sfb = nsfb; sfb > 0; sfb--) + + IF ( *(pQformat) < min_q) + min_q = *(pQformat); + ENDIF + + pQformat++; + + ENDFOR + + ENDFOR + + pQformat = &(qFormat[0]); + pSfbPerWin = &(pFrameInfo->sfb_per_win[0]); + pCoef = &(coef[0]); + + FOR (win = 0; win < nwin; win++) + + stop_idx = 0; + + nsfb = *(pSfbPerWin++); + + pWinSfbTop = &(pFrameInfo->win_sfb_top[win][0]); + + FOR (sfb = nsfb; sfb > 0; sfb--) + + sfbWidth = *(pWinSfbTop++) - stop_idx; + + stop_idx += sfbWidth; + + k = *(pQformat++) - min_q; + + IF (k < 32) + THEN + FOR (; sfbWidth > 0; sfbWidth--) + *(pCoef++) >>= k; + ENDFOR + ELSE + FOR (; sfbWidth > 0; sfbWidth--) + *(pCoef++) = 0; + ENDFOR + ENDIF + + ENDFOR + + ENDFOR + + return min_q; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" +#include "q_normalize.h" +#include "aac_mem_funcs.h" /* For pv_memset */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int q_normalize( + Int qFormat[], + const FrameInfo *pFrameInfo, + Int32 abs_max_per_window[], + Int32 coef[]) +{ + Int sfb; + Int nsfb; + Int win; + Int nwin; + Int sfbWidth; + + Int shift_amt; + + /* Initialize min_q to a very large value */ + Int min_q = 1000; + + Int stop_idx = 0; + + const Int *pSfbPerWin; + const Int16 *pWinSfbTop; + + Int *pQformat; + Int32 *pCoef; + + nwin = pFrameInfo->num_win; + + /* Find the minimum q format */ + pQformat = &(qFormat[0]); + pSfbPerWin = &(pFrameInfo->sfb_per_win[0]); + + for (win = nwin; win != 0; win--) + { + + nsfb = *(pSfbPerWin++); + + if (nsfb < 0 || nsfb > MAXBANDS) + { + break; /* avoid any processing on error condition */ + } + + for (sfb = nsfb; sfb != 0; sfb--) + { + Int qformat = *(pQformat++); + if (qformat < min_q) + { + min_q = qformat; + } + } + + } /* for(win) */ + + /* Normalize the coefs in each scalefactor band to one q-format */ + pQformat = &(qFormat[0]); + pSfbPerWin = &(pFrameInfo->sfb_per_win[0]); + pCoef = &(coef[0]); + + for (win = 0; win < nwin; win++) + { + + Int32 max = 0; + stop_idx = 0; + + nsfb = *(pSfbPerWin++); + + if (nsfb < 0 || nsfb > MAXBANDS) + { + break; /* avoid any processing on error condition */ + } + + pWinSfbTop = &(pFrameInfo->win_sfb_top[win][0]); + + for (sfb = nsfb; sfb != 0; sfb--) + { + Int tmp1, tmp2; + tmp1 = *(pWinSfbTop++); + tmp2 = *(pQformat++); + sfbWidth = tmp1 - stop_idx; + + if (sfbWidth < 2) + { + break; /* will lead to error condition */ + } + + stop_idx += sfbWidth; + + shift_amt = tmp2 - min_q; + + if (shift_amt == 0) + { + Int32 tmp1, tmp2; + tmp1 = *(pCoef++); + tmp2 = *(pCoef++); + /* + * sfbWidth is always an even number + * (check tables in pg.66 IS0 14496-3) + */ + for (Int i = (sfbWidth >> 1) - 1; i != 0; i--) + { + max |= (tmp1 >> 31) ^ tmp1; + max |= (tmp2 >> 31) ^ tmp2; + tmp1 = *(pCoef++); + tmp2 = *(pCoef++); + } + max |= (tmp1 >> 31) ^ tmp1; + max |= (tmp2 >> 31) ^ tmp2; + + } + else + { + if (shift_amt < 31) + { + Int32 tmp1, tmp2; + tmp1 = *(pCoef++) >> shift_amt; + tmp2 = *(pCoef--) >> shift_amt; + /* + * sfbWidth is always an even number + * (check tables in pg.66 IS0 14496-3) + */ + for (Int i = (sfbWidth >> 1) - 1; i != 0; i--) + { + *(pCoef++) = tmp1; + *(pCoef++) = tmp2; + + max |= (tmp1 >> 31) ^ tmp1; + max |= (tmp2 >> 31) ^ tmp2; + tmp1 = *(pCoef++) >> shift_amt; + tmp2 = *(pCoef--) >> shift_amt; + + } + *(pCoef++) = tmp1; + *(pCoef++) = tmp2; + max |= (tmp1 >> 31) ^ tmp1; + max |= (tmp2 >> 31) ^ tmp2; + + } + else + { + pv_memset(pCoef, 0, sizeof(Int32)*sfbWidth); + pCoef += sfbWidth; + } + } + + abs_max_per_window[win] = max; + + } + + } /* for (win) */ + + return min_q; + +} /* normalize() */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/q_normalize.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/q_normalize.h new file mode 100644 index 0000000..305840a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/q_normalize.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: q_normalize.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes the function definition for q_normalize.h +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef Q_NORMALIZE_H +#define Q_NORMALIZE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int q_normalize( + Int qFormat[], + const FrameInfo *pFrameInfo, + Int32 abs_max_per_window[], + Int32 coef[]); + +#ifdef __cplusplus +} +#endif + + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.cpp new file mode 100644 index 0000000..5c77a9f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.cpp @@ -0,0 +1,292 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: qmf_filterbank_coeff.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function defines the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "qmf_filterbank_coeff.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + + +const Int32 sbrDecoderFilterbankCoefficients[155] = +{ + /* 5*sqrt(2)/9*table */ + + + 0xFFF00048, 0x017306F0, 0x257355D7, 0xDCCC0733, 0xFEC50040, + 0xFFF0004C, 0x019106C9, 0x269555CB, 0xDDEB0750, 0xFEE0003C, + 0xFFF20051, 0x01AF069E, 0x27B755B6, 0xDF070768, 0xFEFA0038, + 0xFFF20055, 0x01CE066F, 0x28DB559A, 0xE022077E, 0xFF130034, + 0xFFF20059, 0x01EE063C, 0x29FE5575, 0xE13B078F, 0xFF2C0030, + 0xFFF2005D, 0x020F0604, 0x2B225548, 0xE252079E, 0xFF44002C, + 0xFFF10061, 0x023005C9, 0x2C475514, 0xE36707AA, 0xFF5A0028, + 0xFFF00065, 0x0252058A, 0x2D6B54D7, 0xE47907B2, 0xFF700024, + 0xFFF0006A, 0x02750546, 0x2E8E5492, 0xE58907B8, 0xFF850021, + 0xFFEF006D, 0x029804FD, 0x2FB25445, 0xE69607BA, 0xFF99001D, + 0xFFEF0071, 0x02BC04B1, 0x30D453F1, 0xE7A107BA, 0xFFAC001A, + 0xFFEE0075, 0x02E10460, 0x31F55395, 0xE8A807B7, 0xFFBF0017, + 0xFFEE0078, 0x0306040A, 0x33165331, 0xE9AC07B2, 0xFFD00014, + 0xFFED007C, 0x032B03B0, 0x343552C5, 0xEAAD07AA, 0xFFE10011, + 0xFFED007F, 0x03510351, 0x35535252, 0xEBAB07A0, 0xFFF0000E, + 0xFFEC0082, 0x037802ED, 0x366F51D8, 0xECA50793, 0x0001000B, + 0xFFEC0085, 0x039F0285, 0x37895156, 0xED9C0785, 0x00100008, + 0xFFEB0088, 0x03C50218, 0x38A150CD, 0xEE8F0774, 0x001D0006, + 0xFFEB008A, 0x03ED01A6, 0x39B6503C, 0xEF7E0761, 0x00290003, + 0xFFEB008C, 0x0414012F, 0x3AC94FA5, 0xF069074D, 0x00350001, + 0xFFEB008E, 0x043B00B4, 0x3BD94F07, 0xF1500736, 0x0040FFFD, + 0xFFEA008F, 0x04630033, 0x3CE74E62, 0xF234071E, 0x004AFFFB, + 0xFFEA0091, 0x048BFFAC, 0x3DF14DB7, 0xF3120704, 0x0053FFF9, + 0xFFEA0091, 0x04B2FF22, 0x3EF84D05, 0xF3ED06E9, 0x005CFFF7, + 0xFFEA0092, 0x04DAFE93, 0x3FFB4C4D, 0xF4C306CD, 0x0064FFF5, + 0xFFEB0092, 0x0501FDFF, 0x40FB4B8E, 0xF59506AF, 0x006BFFF4, + 0xFFEB0091, 0x0528FD66, 0x41F64ACA, 0xF6630690, 0x0071FFF3, + 0xFFEB0090, 0x054FFCC8, 0x42EE4A00, 0xF72B066F, 0x0077FFF1, + 0xFFEC008F, 0x0575FC25, 0x43E14930, 0xF7EF064E, 0x007CFFF0, + 0xFFEC008D, 0x059BFB7E, 0x44D0485A, 0xF8AF062C, 0x0081FFEF, + 0xFFED008B, 0x05C0FAD1, 0x45BA477F, 0xF96A0609, 0x0085FFEE +}; + + +const Int32 sbrDecoderFilterbankCoefficients_down_smpl[160] = +{ + 0x0000FFEE, 0xFFF0FFEF, 0xFFEEFFED, 0xFFEBFFEA, + 0xFFE9FFE8, 0xFFE7FFE6, 0xFFE6FFE7, 0xFFE7FFE8, + 0xFFEAFFED, 0xFFEFFFF3, 0xFFF7FFFB, 0x00000007, + 0x000D0014, 0x001C0025, 0x002E0037, 0x0041004B, + 0x00560061, 0x006B0076, 0x0080008A, 0x0094009D, + 0x00A500AC, 0x00B200B6, 0x00B800B9, 0x00B700B3, + 0x00AD00A3, 0x00970087, 0x0074005D, 0x00420024, + 0x0001FFDA, 0xFFAFFF7F, 0xFF4BFF12, 0xFED5FE93, + 0x01B301FD, 0x024C029E, 0x02F4034D, 0x03A90408, + 0x046904CC, 0x05300595, 0x05FA065E, 0x06C10722, + 0x078007DA, 0x08300881, 0x08CB090F, 0x094A097C, + 0x09A409C1, 0x09D209D5, 0x09CB09B2, 0x0988094D, + 0x090108A2, 0x082F07A8, 0x070C0659, 0x059104B1, + 0x03B902AA, 0x01810041, 0xFEE7FD74, 0xFBE9FA45, + 0xF887F6B2, 0xF4C4F2BF, 0xF0A4EE72, 0xEC2AE9CF, + 0xE760E4DE, 0xE24CDFA9, 0xDCF9DA3B, 0xD772D4A0, + 0x2E3A311B, 0x33FF36E7, 0x39CE3CB4, 0x3F964273, + 0x45484813, 0x4AD24D84, 0x502552B4, 0x55305795, + 0x59E35C17, 0x5E2F602B, 0x620863C4, 0x655F66D7, + 0x682B6959, 0x6A626B43, 0x6BFC6C8C, 0x6CF46D32, + 0x6D476D32, 0x6CF46C8C, 0x6BFC6B43, 0x6A626959, + 0x682B66D7, 0x655F63C4, 0x6208602B, 0x5E2F5C17, + 0x59E35795, 0x553052B4, 0x50254D84, 0x4AD24813, + 0x45484273, 0x3F963CB4, 0x39CE36E7, 0x33FF311B, + 0xD1C6D4A0, 0xD772DA3B, 0xDCF9DFA9, 0xE24CE4DE, + 0xE760E9CF, 0xEC2AEE72, 0xF0A4F2BF, 0xF4C4F6B2, + 0xF887FA45, 0xFBE9FD74, 0xFEE70041, 0x018102AA, + 0x03B904B1, 0x05910659, 0x070C07A8, 0x082F08A2, + 0x0901094D, 0x098809B2, 0x09CB09D5, 0x09D209C1, + 0x09A4097C, 0x094A090F, 0x08CB0881, 0x083007DA, + 0x07800722, 0x06C1065E, 0x05FA0595, 0x053004CC, + 0x04690408, 0x03A9034D, 0x02F4029E, 0x024C01FD, + 0xFE4DFE93, 0xFED5FF12, 0xFF4BFF7F, 0xFFAFFFDA, + 0x00010024, 0x0042005D, 0x00740087, 0x009700A3, + 0x00AD00B3, 0x00B700B9, 0x00B800B6, 0x00B200AC, + 0x00A5009D, 0x0094008A, 0x00800076, 0x006B0061, + 0x0056004B, 0x00410037, 0x002E0025, 0x001C0014, + 0x000D0007, 0x0000FFFB, 0xFFF7FFF3, 0xFFEFFFED, + 0xFFEAFFE8, 0xFFE7FFE7, 0xFFE6FFE6, 0xFFE7FFE8, + 0xFFE9FFEA, 0xFFEBFFED, 0xFFEEFFEF, 0xFFF0FFEE +}; + +const Int32 sbrDecoderFilterbankCoefficients_an_filt_LC[155] = +{ + + Qfmt27(-0.00079446133872F), Qfmt27(0.02197766364781F), Qfmt27(0.54254182141522F), Qfmt27(-0.47923775873194F), + Qfmt27(-0.01574239605130F), Qfmt27(-0.00068946163857F), Qfmt27(0.02537571195384F), Qfmt27(0.57449847577240F), + Qfmt27(-0.44806230039026F), Qfmt27(-0.01291535202742F), Qfmt27(-0.00071286404460F), Qfmt27(0.02892516313544F), + Qfmt27(0.60657315615086F), Qfmt27(-0.41729436041451F), Qfmt27(-0.01026942774868F), Qfmt27(-0.00077308974337F), + Qfmt27(0.03262310249845F), Qfmt27(0.63865835544980F), Qfmt27(-0.38701849746199F), Qfmt27(-0.00782586328859F), + Qfmt27(-0.00083027488297F), Qfmt27(0.03646915244785F), Qfmt27(0.67068416485018F), Qfmt27(-0.35729827194706F), + Qfmt27(-0.00557215982767F), Qfmt27(-0.00089272089703F), Qfmt27(0.04045671426315F), Qfmt27(0.70254003810627F), + Qfmt27(-0.32819525024294F), Qfmt27(-0.00351102841332F), Qfmt27(-0.00095851011196F), Qfmt27(0.04455021764484F), + Qfmt27(0.73415149000395F), Qfmt27(-0.29977591877185F), Qfmt27(-0.00163598204794F), Qfmt27(-0.00101225729839F), + Qfmt27(0.04873676213679F), Qfmt27(0.76545064960593F), Qfmt27(-0.27208998714049F), Qfmt27(0.00003903936539F), + Qfmt27(-0.00105230782648F), Qfmt27(0.05300654158217F), Qfmt27(0.79631383686511F), Qfmt27(-0.24519750285673F), + Qfmt27(0.00154182229475F), Qfmt27(-0.00108630976316F), Qfmt27(0.05732502937107F), Qfmt27(0.82666485395476F), + Qfmt27(-0.21914753347432F), Qfmt27(0.00286720203220F), Qfmt27(-0.00110794157381F), Qfmt27(0.06167350555855F), + Qfmt27(0.85641712130638F), Qfmt27(-0.19396671004887F), Qfmt27(0.00402297937976F), Qfmt27(-0.00110360418081F), + Qfmt27(0.06602157445253F), Qfmt27(0.88547343436495F), Qfmt27(-0.16971665552213F), Qfmt27(0.00500649278750F), + Qfmt27(-0.00109714405326F), Qfmt27(0.07034096875232F), Qfmt27(0.91376152398903F), Qfmt27(-0.14641770628514F), + Qfmt27(0.00583386287581F), Qfmt27(-0.00106490281247F), Qfmt27(0.07461825625751F), Qfmt27(0.94117890777861F), + Qfmt27(-0.12410396326951F), Qfmt27(0.00651097277313F), Qfmt27(-0.00102041023958F), Qfmt27(0.07879625324269F), + Qfmt27(0.96765488212662F), Qfmt27(-0.10280530739363F), Qfmt27(0.00704839655425F), Qfmt27(-0.00094051141595F), + Qfmt27(0.08286099010631F), Qfmt27(0.99311573680798F), Qfmt27(-0.08254839941155F), Qfmt27(0.00745513427428F), + Qfmt27(-0.00084090835475F), Qfmt27(0.08675566213219F), Qfmt27(1.01745066253324F), Qfmt27(-0.06332944781672F), + Qfmt27(0.00774335382672F), Qfmt27(-0.00072769348801F), Qfmt27(0.09046949018457F), Qfmt27(1.04060828658052F), + Qfmt27(-0.04518854556363F), Qfmt27(0.00790787636150F), Qfmt27(-0.00057913742435F), Qfmt27(0.09395575430420F), + Qfmt27(1.06251808919053F), Qfmt27(-0.02811939233087F), Qfmt27(0.00797463714114F), Qfmt27(-0.00040969484059F), + Qfmt27(0.09716267023308F), Qfmt27(1.08310018709600F), Qfmt27(-0.01212147193047F), Qfmt27(0.00795079915733F), + Qfmt27(-0.00020454902123F), Qfmt27(0.10007381188066F), Qfmt27(1.10227871198194F), Qfmt27(0.00279527795884F), + Qfmt27(0.00784545014643F), Qfmt27(0.00001908481202F), Qfmt27(0.10262701466139F), Qfmt27(1.12001978353403F), + Qfmt27(0.01663452156443F), Qfmt27(0.00766458213130F), Qfmt27(0.00028892665922F), Qfmt27(0.10479373974558F), + Qfmt27(1.13624787143434F), Qfmt27(0.02941522773279F), Qfmt27(0.00741912981120F), Qfmt27(0.00056943874774F), + Qfmt27(0.10650970405576F), Qfmt27(1.15091404672203F), Qfmt27(0.04112872592057F), Qfmt27(0.00712664923329F), + Qfmt27(0.00088238158168F), Qfmt27(0.10776200996423F), Qfmt27(1.16395714324633F), Qfmt27(0.05181934748033F), + Qfmt27(0.00677868764313F), Qfmt27(0.00121741725989F), Qfmt27(0.10848340171661F), Qfmt27(1.17535833075364F), + Qfmt27(0.06148559051724F), Qfmt27(0.00639363830229F), Qfmt27(0.00159101288509F), Qfmt27(0.10864412991640F), + Qfmt27(1.18507099110810F), Qfmt27(0.07014197759039F), Qfmt27(0.00597707038378F), Qfmt27(0.00196610899088F), + Qfmt27(0.10819451041273F), Qfmt27(1.19306425909871F), Qfmt27(0.07784680399703F), Qfmt27(0.00554476792518F), + Qfmt27(0.00238550675072F), Qfmt27(0.10709920766553F), Qfmt27(1.19929775892826F), Qfmt27(0.08459352758522F), + Qfmt27(0.00509233837916F), Qfmt27(0.00280596092809F), Qfmt27(0.10531144797543F), Qfmt27(1.20377455661175F), + Qfmt27(0.09043115226911F), Qfmt27(0.00463008004888F), Qfmt27(0.00325513071185F), Qfmt27(0.10278145526768F), + Qfmt27(1.20646855283790F), Qfmt27(0.09539224314440F), Qfmt27(0.00416760958657F) +}; + + + +#ifdef HQ_SBR + + +const Int32 sbrDecoderFilterbankCoefficients_an_filt[155] = +{ + Qfmt27(-0.000561769F), Qfmt27(+ 0.015540555F), Qfmt27(+ 0.383635001F), Qfmt27(-0.338872269F), Qfmt27(-0.011131555F), + Qfmt27(-0.000487523F), Qfmt27(+ 0.017943338F), Qfmt27(+ 0.406231768F), Qfmt27(-0.316827891F), Qfmt27(-0.009132533F), + Qfmt27(-0.000504071F), Qfmt27(+ 0.020453179F), Qfmt27(+ 0.428911992F), Qfmt27(-0.295071672F), Qfmt27(-0.007261582F), + Qfmt27(-0.000546657F), Qfmt27(+ 0.023068017F), Qfmt27(+ 0.451599654F), Qfmt27(-0.273663404F), Qfmt27(-0.005533721F), + Qfmt27(-0.000587093F), Qfmt27(+ 0.025787585F), Qfmt27(+ 0.474245321F), Qfmt27(-0.252648031F), Qfmt27(-0.003940112F), + Qfmt27(-0.000631249F), Qfmt27(+ 0.028607217F), Qfmt27(+ 0.496770825F), Qfmt27(-0.232069087F), Qfmt27(-0.002482672F), + Qfmt27(-0.000677769F), Qfmt27(+ 0.031501761F), Qfmt27(+ 0.519123497F), Qfmt27(-0.211973585F), Qfmt27(-0.001156814F), + Qfmt27(-0.000715774F), Qfmt27(+ 0.034462095F), Qfmt27(+ 0.541255345F), Qfmt27(-0.192396675F), Qfmt27(+ 0.000027605F), + Qfmt27(-0.000744094F), Qfmt27(+ 0.037481285F), Qfmt27(+ 0.563078914F), Qfmt27(-0.173380817F), Qfmt27(+ 0.001090233F), + Qfmt27(-0.000768137F), Qfmt27(+ 0.040534917F), Qfmt27(+ 0.584540324F), Qfmt27(-0.154960707F), Qfmt27(+ 0.002027418F), + Qfmt27(-0.000783433F), Qfmt27(+ 0.043609754F), Qfmt27(+ 0.605578354F), Qfmt27(-0.137155176F), Qfmt27(+ 0.002844676F), + Qfmt27(-0.000780366F), Qfmt27(+ 0.046684303F), Qfmt27(+ 0.626124270F), Qfmt27(-0.120007798F), Qfmt27(+ 0.003540125F), + Qfmt27(-0.000775798F), Qfmt27(+ 0.049738576F), Qfmt27(+ 0.646126970F), Qfmt27(-0.103532953F), Qfmt27(+ 0.004125164F), + Qfmt27(-0.000753000F), Qfmt27(+ 0.052763075F), Qfmt27(+ 0.665513988F), Qfmt27(-0.087754754F), Qfmt27(+ 0.004603953F), + Qfmt27(-0.000721539F), Qfmt27(+ 0.055717365F), Qfmt27(+ 0.684235329F), Qfmt27(-0.072694330F), Qfmt27(+ 0.004983969F), + Qfmt27(-0.000665042F), Qfmt27(+ 0.058591568F), Qfmt27(+ 0.702238872F), Qfmt27(-0.058370533F), Qfmt27(+ 0.005271576F), + Qfmt27(-0.000594612F), Qfmt27(+ 0.061345517F), Qfmt27(+ 0.719446263F), Qfmt27(-0.044780682F), Qfmt27(+ 0.005475378F), + Qfmt27(-0.000514557F), Qfmt27(+ 0.063971590F), Qfmt27(+ 0.735821176F), Qfmt27(-0.031953127F), Qfmt27(+ 0.005591713F), + Qfmt27(-0.000409512F), Qfmt27(+ 0.066436751F), Qfmt27(+ 0.751313746F), Qfmt27(-0.019883413F), Qfmt27(+ 0.005638920F), + Qfmt27(-0.000289698F), Qfmt27(+ 0.068704383F), Qfmt27(+ 0.765867487F), Qfmt27(-0.008571175F), Qfmt27(+ 0.005622064F), + Qfmt27(-0.000144638F), Qfmt27(+ 0.070762871F), Qfmt27(+ 0.779428752F), Qfmt27(+ 0.001976560F), Qfmt27(+ 0.005547571F), + Qfmt27(+ 0.000013495F), Qfmt27(+ 0.072568258F), Qfmt27(+ 0.791973584F), Qfmt27(+ 0.011762383F), Qfmt27(+ 0.005419678F), + Qfmt27(+ 0.000204302F), Qfmt27(+ 0.074100364F), Qfmt27(+ 0.803448575F), Qfmt27(+ 0.020799707F), Qfmt27(+ 0.005246117F), + Qfmt27(+ 0.000402654F), Qfmt27(+ 0.075313734F), Qfmt27(+ 0.813819127F), Qfmt27(+ 0.029082401F), Qfmt27(+ 0.005039302F), + Qfmt27(+ 0.000623938F), Qfmt27(+ 0.076199248F), Qfmt27(+ 0.823041989F), Qfmt27(+ 0.036641812F), Qfmt27(+ 0.004793256F), + Qfmt27(+ 0.000860844F), Qfmt27(+ 0.076709349F), Qfmt27(+ 0.831103846F), Qfmt27(+ 0.043476878F), Qfmt27(+ 0.004520985F), + Qfmt27(+ 0.001125016F), Qfmt27(+ 0.076823001F), Qfmt27(+ 0.837971734F), Qfmt27(+ 0.049597868F), Qfmt27(+ 0.004226427F), + Qfmt27(+ 0.001390249F), Qfmt27(+ 0.076505072F), Qfmt27(+ 0.843623828F), Qfmt27(+ 0.055046003F), Qfmt27(+ 0.003920743F), + Qfmt27(+ 0.001686808F), Qfmt27(+ 0.075730576F), Qfmt27(+ 0.848031578F), Qfmt27(+ 0.059816657F), Qfmt27(+ 0.003600827F), + Qfmt27(+ 0.001984114F), Qfmt27(+ 0.074466439F), Qfmt27(+ 0.851197152F), Qfmt27(+ 0.063944481F), Qfmt27(+ 0.003273961F), + Qfmt27(+ 0.002301725F), Qfmt27(+ 0.072677464F), Qfmt27(+ 0.853102095F), Qfmt27(+ 0.067452502F), Qfmt27(+ 0.002946945F) +}; + + + +#endif /* HQ_SBR */ + + +#endif /* AAC_PLUS */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.h new file mode 100644 index 0000000..c1971a9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: qmf_filterbank_coeff.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + this file declares the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef QMF_FILTERBANK_COEFF_H +#define QMF_FILTERBANK_COEFF_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +#define Qfmt(x) (Int16)(x*(((Int32)1<<15)*0.78567420131839F) + (x>=0?0.5F:-0.5F)) + + +#define Qfmt30(x) (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F)) +#define Qfmt27(x) (Int32)(x*(((Int32)1<<27)) + (x>=0?0.5F:-0.5F)) + +extern const Int32 sbrDecoderFilterbankCoefficients[155]; + + +extern const Int32 sbrDecoderFilterbankCoefficients_down_smpl[160]; +extern const Int32 sbrDecoderFilterbankCoefficients_an_filt_LC[155]; + +#ifdef HQ_SBR +extern const Int32 sbrDecoderFilterbankCoefficients_an_filt[155]; +#endif + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_adif_header.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_adif_header.h new file mode 100644 index 0000000..5294a87 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_adif_header.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_adif_header.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, ADIF_Header + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_ADIF_HEADER_H +#define S_ADIF_HEADER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_adif_const.h" +#include "e_rawbitstreamconst.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +typedef struct +{ + Char adif_id[LEN_ADIF_ID+1]; + Int copy_id_present; + Char copy_id[LEN_COPYRT_ID+1]; + Int original_copy; + Int home; + Int bitstream_type; + Int32 bitrate; + Int num_pce; + Int prog_tags[(1< 0) */ + /* int cch[CChans];*/ /* coupling channel idx */ + /* int cc_dom[CChans];*/ /* coupling channel domain */ + /* int cc_ind[CChans];*/ /* independently switched coupling channel flag */ + /* #endif */ +// Char *fext; /* filename extension */ + +} Ch_Info; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_crc_buffer.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_crc_buffer.h new file mode 100644 index 0000000..40696e7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_crc_buffer.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_crc_buffer.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_CRC_BUFFER_H +#define S_CRC_BUFFER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef struct +{ + unsigned short crcState; + unsigned short crcMask; + unsigned short crcPoly; +} +CRC_BUFFER; + +typedef CRC_BUFFER *HANDLE_CRC; + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_elelist.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_elelist.h new file mode 100644 index 0000000..a1c4d69 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_elelist.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_elelist.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, EleList + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_ELELIST_H +#define S_ELELIST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_rawbitstreamconst.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +typedef struct +{ + Int num_ele; + Int ele_is_cpe[(1<>2) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +struct PATCH +{ + Int32 noOfPatches; + Int32 targetStartBand[MAX_NUM_PATCHES]; +}; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_progconfig.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_progconfig.h new file mode 100644 index 0000000..05b56c1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_progconfig.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_progconfig.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, ProgConfig + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_PROGCONFIG_H +#define S_PROGCONFIG_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_mixdown.h" +#include "s_elelist.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef struct +{ + Int profile; + Int sampling_rate_idx; + EleList front; + EleList side; + EleList back; + EleList lfe; + EleList data; + EleList coupling; + MIXdown mono_mix; + MIXdown stereo_mix; + MIXdown matrix_mix; + + Char comments[(1<bufReadOffs (2) and + * sbrDec->noCols (32) + sbrDec->bufWriteOffs (6) + */ + Int32 codecQmfBufferReal[40][32]; + Int32 *sbrQmfBufferReal; + Int32 HistsbrQmfBufferReal[6*SBR_NUM_BANDS]; +#ifdef HQ_SBR + Int32 codecQmfBufferImag[40][32]; + Int32 *sbrQmfBufferImag; + Int32 HistsbrQmfBufferImag[6*SBR_NUM_BANDS]; +#endif + Int16 V[1152]; /* Used by calc_sbr_synfilterbank as freq. history buffer */ + + + Int32 degreeAlias[64]; + + +#ifdef HQ_SBR + + Int32 fBuffer_man[5][64]; /* smoothing history buffers */ + Int32 fBufferN_man[5][64]; + Int32 fBuffer_exp[5][64]; /* smoothing history buffers */ + Int32 fBufferN_exp[5][64]; + + Int32 *fBuf_man[64]; /* pointer to smoothing history buffers */ + Int32 *fBuf_exp[64]; /* pointer to smoothing history buffers */ + Int32 *fBufN_man[64]; + Int32 *fBufN_exp[64]; + + +#endif + +} +SBR_FRAME_DATA; + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sbr_header_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sbr_header_data.h new file mode 100644 index 0000000..3cd1bf2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sbr_header_data.h @@ -0,0 +1,103 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_sbr_header_data.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_SBR_HEADER_DATA_H +#define S_SBR_HEADER_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_sbr_header_status.h" +#include "e_sbr_master_status.h" +#include "e_sr_mode.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef struct +{ + SBR_HEADER_STATUS status; /* the current status of the header */ + SBR_MASTER_STATUS masterStatus;/* status of v_k_master freq table */ + + /* Changes in these variables indicates an error */ + Int32 crcEnable; + SR_MODE sampleRateMode; + Int32 ampResolution; + + /* Changes in these variables causes a reset of the decoder */ + Int32 startFreq; + Int32 stopFreq; + Int32 xover_band; + Int32 freqScale; + Int32 alterScale; + Int32 noise_bands; /* noise bands per octave, read from bitstream */ + + /* Helper variable*/ + Int32 noNoiseBands; /* actual number of noise bands to read from the bitstream */ + + Int32 limiterBands; + Int32 limiterGains; + Int32 interpolFreq; + Int32 smoothingLength; +} +SBR_HEADER_DATA; + +typedef SBR_HEADER_DATA *HANDLE_SBR_HEADER_DATA; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sbrbitstream.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sbrbitstream.h new file mode 100644 index 0000000..a8cd45c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sbrbitstream.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_sbrbitstream.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_SBRBITSTREAM_H +#define S_SBRBITSTREAM_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "s_sbr_element_stream.h" +#include "s_sbr_channel.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +typedef struct +{ + Int32 NrElements; + Int32 NrElementsCore; + SBR_ELEMENT_STREAM sbrElement[MAXNRELEMENTS]; +} +SBRBITSTREAM; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sectinfo.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sectinfo.h new file mode 100644 index 0000000..d96146a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sectinfo.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_sectinfo.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + defines a structre that holds the Huffman codebook index and section + boundary information for each Frame. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_SECTINFO_H +#define S_SECTINFO_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef struct +{ + Int sect_cb; + Int sect_end; +} SectInfo; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sr_info.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sr_info.h new file mode 100644 index 0000000..709a547 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_sr_info.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_sr_info.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, SR_Info + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_SR_INFO_H +#define S_SR_INFO_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef struct +{ + Int32 samp_rate; + Int nsfb1024; + Int nsfb128; +} SR_Info; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_tdec_int_chan.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_tdec_int_chan.h new file mode 100644 index 0000000..4828a70 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_tdec_int_chan.h @@ -0,0 +1,148 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_tdec_int_chan.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, tDec_Int_Chan + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_TDEC_INT_CHAN_H +#define S_TDEC_INT_CHAN_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_rawbitstreamconst.h" +#include "s_tns_frame_info.h" +#include "s_wnd_shape.h" +#include "s_lt_pred_status.h" +#include "s_sectinfo.h" +#include "s_frameinfo.h" +#include "e_window_shape.h" +#include "e_window_sequence.h" +#include "window_block_fxp.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /* This structure was created with the specific goal in mind of sharing memory + * with the last 1024 data elements in fxpCoef. + * + * The size of this structure must NOT exceed 4 kilobytes + * Also, the size of the fxpCoef array cannot be less than 8 kilobytes + * + * The fxpCoef array is declared as an Int32, so its size should not vary + * from platform to platform. + * + * The shared structure is 3,640 bytes (3.55 KB), on a 32-bit platform, + * which represents the worst case. + */ + typedef struct + { + TNS_frame_info tns; + + FrameInfo frameInfo; + + Int factors[MAXBANDS]; + Int cb_map[MAXBANDS]; + Int group[NSHORT]; + Int qFormat[MAXBANDS]; + + Int max_sfb; + LT_PRED_STATUS lt_status; + + } per_chan_share_w_fxpCoef; + + /* + * This structure contains one per channel. + */ + typedef struct + { +#ifdef AAC_PLUS + Int16 ltp_buffer[LT_BLEN + 2*288]; /* LT_BLEN = 2048 + 2*288 */ +#else + Int16 ltp_buffer[LT_BLEN]; /* LT_BLEN = 2048 */ +#endif + + + Int32 time_quant[LONG_WINDOW]; /* 1024 holds overlap&add */ + + Int32 *fxpCoef; /* Spectrum coeff.*/ + + per_chan_share_w_fxpCoef * pShareWfxpCoef; + + Int32 abs_max_per_window[NUM_SHORT_WINDOWS]; + + WINDOW_SEQUENCE wnd; + + + WINDOW_SHAPE wnd_shape_prev_bk; + WINDOW_SHAPE wnd_shape_this_bk; + + } tDec_Int_Chan; + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* S_TDEC_INT_CHAN_H */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_tdec_int_file.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_tdec_int_file.h new file mode 100644 index 0000000..c8d3a73 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/s_tdec_int_file.h @@ -0,0 +1,240 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_tdec_int_file.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, tDec_Int_Chan + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_TDEC_INT_FILE_H +#define S_TDEC_INT_FILE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_progconfig.h" +#include "s_frameinfo.h" +#include "s_mc_info.h" +#include "s_adif_header.h" +#include "s_tdec_int_chan.h" +#include "s_pulseinfo.h" +#include "s_bits.h" +#include "s_hcb.h" +#include "e_infoinitconst.h" + +#include "s_sbr_channel.h" +#include "s_sbr_dec.h" +#include "s_sbrbitstream.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + + + + /* + * Note: most of the names of the variables put into this structure were kept + * the same because the name is also used in called functions. + * + * bno - block number + * + */ + typedef struct + { + UInt32 bno; + Int status; /* save the status */ + + bool parameters_acquired; + bool aacPlusEnabled; + bool aacConfigUtilityEnabled; + + bool multichannel_detected; + Int multichannel_numChannels; + + Int current_program; + Int frameLength; + Int adif_test; + + + BITS inputStream; + + ProgConfig prog_config; + + Int SFBWidth128[(1<=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +#include "pv_normalize.h" +#include "sbr_constants.h" + +/******************************************************************************* + Functionname: sbr_aliasing_reduction + ******************************************************************************* + Description: + Arguments: + + Return: none +*******************************************************************************/ +void sbr_aliasing_reduction(Int32 *degreeAlias, + Int32 * nrg_gain_man, + Int32 * nrg_gain_exp, + Int32 * nrg_est_man, + Int32 * nrg_est_exp, + Int32 * dontUseTheseGainValues, + Int32 noSubbands, + Int32 lowSubband, + Int32 sqrt_cache[][4], + Int32 * groupVector) +{ + + Int32 temp1; + Int32 est_total; + Int32 ref_total_man; + Int32 ref_total_exp; + Int32 tmp_q1; + Int32 tmp_q2; + Int32 tmp_q3; + Int32 tmp_q4; + Int32 bst_man; + Int32 bst_exp; + struct intg_div quotient; + struct intg_sqrt root_sq; + Int32 group; + Int32 grouping = 0; + Int32 index = 0; + Int32 noGroups; + Int32 k; + + + /* Calculate grouping*/ + for (k = 0; k < noSubbands - 1; k++) + { + if (degreeAlias[k + lowSubband + 1] && dontUseTheseGainValues[k] == 0) + { + if (grouping == 0) + { + groupVector[index] = k + lowSubband; + grouping = 1; + index++; + } + } + else + { + if (grouping) + { + groupVector[index] = k + lowSubband; + + if (! dontUseTheseGainValues[k]) + { + (groupVector[index])++; + } + grouping = 0; + index++; + } + } + } + + if (grouping) + { + groupVector[index] = noSubbands + lowSubband; + index++; + } + noGroups = (index >> 1); + + + + /*Calculate new gain*/ + for (group = 0; group < noGroups; group ++) + { + + int startGroup = groupVector[(group<<1)] - lowSubband; + int stopGroup = groupVector[(group<<1)+1] - lowSubband; + + + est_total = 0; + ref_total_man = 0; + + tmp_q1 = -100; + tmp_q2 = -100; + + for (k = startGroup; k < stopGroup; k++) + { + if (tmp_q1 < nrg_est_exp[k]) + { + tmp_q1 = nrg_est_exp[k]; /* max */ + } + if (tmp_q2 < (nrg_est_exp[k] + (nrg_gain_exp[k] << 1))) + { + tmp_q2 = (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)); /* max */ + } + } + + + k -= startGroup; /* number of element used in the addition */ + /* adjust Q format */ + tmp_q2 += 59 - pv_normalize(k); + + for (k = startGroup; k < stopGroup; k++) + { + /* + * est_total += nrg_est[k] + * ref_total += nrg_est[k]*nrg_gain[k]*nrg_gain[k + */ + est_total += nrg_est_man[k] >> (tmp_q1 - nrg_est_exp[k]); + + if (tmp_q2 - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)) < 60) + { + nrg_gain_man[k] = fxp_mul32_Q28(nrg_gain_man[k], nrg_gain_man[k]); + nrg_gain_exp[k] = (nrg_gain_exp[k] << 1) + 28; + tmp_q3 = fxp_mul32_Q28(nrg_gain_man[k], nrg_est_man[k]); + ref_total_man += tmp_q3 >> (tmp_q2 - (nrg_est_exp[k] + nrg_gain_exp[k])); + } + } + + ref_total_exp = tmp_q2 + 28; + + pv_div(ref_total_man, est_total, "ient); + + tmp_q2 += - tmp_q1 - quotient.shift_factor - 2; + + + + for (k = startGroup; k < stopGroup; k++) + { + Int32 alpha; + temp1 = k + lowSubband; + if (k < noSubbands - 1) + { + alpha = degreeAlias[temp1 + 1] > degreeAlias[temp1 ] ? + degreeAlias[temp1 + 1] : degreeAlias[temp1 ]; + } + else + { + alpha = degreeAlias[temp1]; + } + + /* + * nrg_gain[k] = alpha*newGain + (1.0f-alpha)*nrg_gain[k]*nrg_gain[k]; + */ + + tmp_q1 = tmp_q2 > nrg_gain_exp[k] ? tmp_q2 : nrg_gain_exp[k]; + tmp_q1++; + + tmp_q3 = fxp_mul32_Q30(alpha, quotient.quotient); + tmp_q4 = fxp_mul32_Q30(Q30fmt(1.0f) - alpha, nrg_gain_man[k]); + + nrg_gain_man[k] = (tmp_q3 >> (tmp_q1 - tmp_q2)) + + (tmp_q4 >> (tmp_q1 - nrg_gain_exp[k])); + + nrg_gain_exp[k] = tmp_q1; + } + + + bst_exp = -100; + + for (k = startGroup; k < stopGroup; k++) + { + if (bst_exp < nrg_gain_exp[k] + nrg_est_exp[k]) + { + bst_exp = nrg_gain_exp[k] + nrg_est_exp[k]; /* max */ + } + } + + k -= startGroup; /* number of element used in the addition */ + + while (k != 0) /* bit guard protection depends on log2(k) */ + { + k >>= 1; + bst_exp++; /* add extra bit-overflow-guard */ + } + + bst_man = 0; + + for (k = startGroup; k < stopGroup; k++) + { + tmp_q2 = fxp_mul32_Q28(nrg_gain_man[k], nrg_est_man[k]); + bst_man += tmp_q2 >> (bst_exp - nrg_gain_exp[k] - nrg_est_exp[k]); + } + + bst_exp += 28; /* compensate for shift down */ + + if (bst_man) + { + /* + * bst = ref_total / bst + */ + + pv_div(ref_total_man, bst_man, "ient); + bst_exp = ref_total_exp - bst_exp - quotient.shift_factor - 30; + bst_man = quotient.quotient; /* Q30 */ + + for (k = startGroup; k < stopGroup; k++) + { + tmp_q1 = fxp_mul32_Q30(bst_man, nrg_gain_man[k]); + pv_sqrt(tmp_q1, (bst_exp + nrg_gain_exp[k] + 60), &root_sq, sqrt_cache[0]); + nrg_gain_man[k] = root_sq.root; + nrg_gain_exp[k] = root_sq.shift_factor; + } + } + else + { + pv_memset((void *)&nrg_gain_man[startGroup], + 0, + (stopGroup - startGroup)*sizeof(nrg_gain_man[0])); + + pv_memset((void *)&nrg_gain_exp[startGroup], + 0, + (stopGroup - startGroup)*sizeof(nrg_gain_exp[0])); + + } + + } +} + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.h new file mode 100644 index 0000000..ca3d489 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.h @@ -0,0 +1,83 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_aliasing_reduction.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_ALIASING_REDUCTION_H +#define SBR_ALIASING_REDUCTION_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_aliasing_reduction(Int32 *degreeAlias, + Int32 * nrg_gain_man, + Int32 * nrg_gain_exp, + Int32 * nrg_est_man, + Int32 * nrg_est_exp, + Int32 * dontUseTheseGainValues, + Int32 noSubbands, + Int32 lowSubband, + Int32 sqrt_cache[][4], + Int32 * groupVector); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_applied.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_applied.cpp new file mode 100644 index 0000000..187e8a3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_applied.cpp @@ -0,0 +1,442 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_applied.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + INPUT + + SBRDECODER self, + SBRBITSTREAM * stream, + float *timeData, + int numChannels + + OUTPUT + + errorCode, noError if successful + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + sbr decoder processing, set up SBR decoder phase 2 in case of + different cotrol data + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#ifdef AAC_PLUS + + +#include "sbr_applied.h" +#include "sbr_read_data.h" + +#include "sbr_decode_envelope.h" +#include "decode_noise_floorlevels.h" +#include "sbr_requantize_envelope_data.h" +#include "sbr_envelope_unmapping.h" +#include "sbr_dec.h" +#include "e_sbr_element_id.h" +#include "aac_mem_funcs.h" + +#ifdef PARAMETRICSTEREO +#include "ps_bstr_decoding.h" +#include "ps_allocate_decoder.h" + +#endif + +#include "init_sbr_dec.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_applied(SBRDECODER_DATA * self, + SBRBITSTREAM * stream, + Int16 *ch_left, + Int16 *ch_right, + Int16 *timeData, + SBR_DEC *sbrDec, + tDec_Int_File *pVars, + Int32 numChannels) +{ + SBR_ERROR err = SBRDEC_OK ; + + Int32 eleChannels = 0; + + SBR_CHANNEL *SbrChannel = self->SbrChannel; + + /* Get SBR or PS Data only when available */ + if (stream->NrElements) + { + /* read frame data from bitstream */ + + eleChannels = (stream->sbrElement [LEFT].ElementID == SBR_ID_CPE) ? 2 : 1; + + + err = sbr_read_data(self, + sbrDec, + stream); + + if (err != SBRDEC_OK) + { + /* + * This error condition disables any further SBR processing + */ + self->SbrChannel[LEFT].syncState = UPSAMPLING; + if (eleChannels == 2) + { + self->SbrChannel[RIGHT].syncState = UPSAMPLING; + } + } + + /* + * Setting bistream and decoding type is only done once, + */ + if (SbrChannel[LEFT].syncState == SBR_ACTIVE && self->setStreamType) + { + self->setStreamType = 0; /* Disable Lock for AAC stream type setting */ + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + + Int sbrEnablePS = self->hParametricStereoDec->psDetected; + + pVars->mc_info.psPresentFlag = sbrEnablePS; + + if (sbrEnablePS) /* Initialize PS arrays */ + { + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS; + ps_allocate_decoder(self, 32); + + /* Disable LC (or Enable HQ) if PS is detected */ + sbrDec->LC_aacP_DecoderFlag = OFF; + } + else + { + /* + * Do not downgrade stream type from eaac+, if it has been explicitly declared + */ + if (pVars->mc_info.ExtendedAudioObjectType != MP4AUDIO_PS) + { + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + + if (pVars->mc_info.nch > 1) + { + sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for stereo */ + } + else + { + sbrDec->LC_aacP_DecoderFlag = OFF; /* Disable LC, Enable HQ for mono */ + } + } + else + { + sbrEnablePS = 1; /* Force this condition as it was explicititly declared */ + pVars->mc_info.psPresentFlag = sbrEnablePS; + + } + } +#else + + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + + if (pVars->mc_info.nch > 1) + { + sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for stereo */ + } + else + { + sbrDec->LC_aacP_DecoderFlag = OFF; /* Disable LC, Enable HQ for mono */ + } +#endif + +#else + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + + sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for all sbr decoding */ + +#endif + + } /* (SbrChannel[LEFT].syncState == SBR_ACTIVE && lock) */ + else + { + /* + * Default setting for upsampler + */ + if (pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_AAC_LC) + { + /* + * Change only in implicit signalling, otherwise keep original declaration + */ + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + } + +#ifdef HQ_SBR +/* 2012-06-28 Vaclav Bartacek { */ +#ifdef PARAMETRICSTEREO + if (self->hParametricStereoDec->psDetected) + { + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS; + + if (!pVars->mc_info.psPresentFlag) + { + pVars->mc_info.psPresentFlag = 1; + ps_allocate_decoder(self, 32); + } + } +#endif +/* 2012-06-28 Vaclav Bartacek } */ + if (pVars->mc_info.nch > 1) + { + sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for stereo */ + } + else + { + sbrDec->LC_aacP_DecoderFlag = OFF; /* Disable LC, Enable HQ for mono */ + } +#else + sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for all sbr decoding */ + +#endif + /* mask error and let upsampler run */ + err = SBRDEC_OK; + + } + + /* decoding */ + + if (SbrChannel[LEFT].syncState == SBR_ACTIVE) + { + + sbr_decode_envelope(&(SbrChannel[LEFT].frameData)); + + decode_noise_floorlevels(&(SbrChannel[LEFT].frameData)); + + if (! SbrChannel[LEFT].frameData.coupling) + { + sbr_requantize_envelope_data(&(SbrChannel[LEFT].frameData)); + } + + if (eleChannels == 2) + { + + sbr_decode_envelope(&(SbrChannel[RIGHT].frameData)); + + decode_noise_floorlevels(&(SbrChannel[RIGHT].frameData)); + + if (SbrChannel[RIGHT].frameData.coupling) + { + sbr_envelope_unmapping(&(SbrChannel[ LEFT].frameData), + &(SbrChannel[RIGHT].frameData)); + } + else + { + sbr_requantize_envelope_data(&(SbrChannel[RIGHT].frameData)); + } + } + } + else /* enable upsampling until valid SBR is obtained */ + { + /* + * Incomplete sbr frame, or disabled SBR section + * Set the decoder to act as a regular upsampler + */ + + init_sbr_dec((sbrDec->outSampleRate >> 1), + pVars->mc_info.upsamplingFactor, + sbrDec, + &(self->SbrChannel[LEFT].frameData)); + + if ((eleChannels == 2) && (SbrChannel[RIGHT].syncState != SBR_ACTIVE)) + { + init_sbr_dec((sbrDec->outSampleRate >> 1), + pVars->mc_info.upsamplingFactor, + sbrDec, + &(self->SbrChannel[RIGHT].frameData)); + + } + + } + + } + + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + if (pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_PS) + { + ps_bstr_decoding(self->hParametricStereoDec); + /* allocate pointer for rigth channel qmf filter history */ + Int16 *tempInt16Ptr = (Int16 *)SbrChannel[RIGHT].frameData.V; + self->hParametricStereoDec->R_ch_qmf_filter_history = (Int32 *)tempInt16Ptr; + + + /* + * 1824 (48*38) Int32 needed by each matrix sbrQmfBufferReal, sbrQmfBufferImag + * pVars->share.predictedSamples has 2048 available + * pVars->fxpCoef[1] has 2048 available + */ + SbrChannel[LEFT].frameData.sbrQmfBufferReal = pVars->share.predictedSamples; + SbrChannel[LEFT].frameData.sbrQmfBufferImag = &pVars->fxpCoef[0][920]; + + sbr_dec(ch_left, + timeData, + &(SbrChannel[LEFT].frameData), + (SbrChannel[LEFT].syncState == SBR_ACTIVE), + sbrDec, + &timeData[RIGHT], + self->hParametricStereoDec, + pVars); + } + else + { +#endif +#endif + + SbrChannel[LEFT].frameData.sbrQmfBufferReal = pVars->fxpCoef[LEFT]; +#ifdef HQ_SBR + SbrChannel[LEFT].frameData.sbrQmfBufferImag = pVars->fxpCoef[RIGHT]; +#endif + + sbr_dec(ch_left, + timeData, + &(SbrChannel[LEFT].frameData), + (SbrChannel[LEFT].syncState == SBR_ACTIVE), + sbrDec, +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + NULL, + NULL, +#endif +#endif + pVars); + + if (numChannels == 2) + { + SbrChannel[RIGHT].frameData.sbrQmfBufferReal = pVars->fxpCoef[LEFT]; +#ifdef HQ_SBR + SbrChannel[RIGHT].frameData.sbrQmfBufferImag = pVars->fxpCoef[RIGHT]; +#endif + + sbr_dec(ch_right, + &timeData[RIGHT], + &(SbrChannel[RIGHT].frameData), + (SbrChannel[RIGHT].syncState == SBR_ACTIVE), + sbrDec, +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + NULL, + NULL, +#endif +#endif + pVars); + + } + + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + } +#endif +#endif + + return err; +} + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_applied.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_applied.h new file mode 100644 index 0000000..6cf1543 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_applied.h @@ -0,0 +1,130 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_applied.h + Funtions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_APPLIED_H +#define SBR_APPLIED_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "e_sbr_error.h" +#include "s_sbr_channel.h" +#include "s_sbrbitstream.h" +#include "sbr_dec.h" +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define MAX_FRAME_SIZE 1024 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + + SBR_ERROR sbr_applied(SBRDECODER_DATA * self, + SBRBITSTREAM * stream, + Int16 *ch_left, + Int16 *ch_right, + Int16 *timeData, + SBR_DEC *sbrDec, + tDec_Int_File *pVars, + Int32 numChannels); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.cpp new file mode 100644 index 0000000..12d9908 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.cpp @@ -0,0 +1,396 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_code_book_envlevel.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "pv_audio_type_defs.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. Include conditional + ; compile variables also. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; LOCAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; LOCAL STORE/BUFFER/POINTER DEFINITIONS + ; Variable declaration - defined here and used outside this module + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL FUNCTION REFERENCES + ; Declare functions defined elsewhere and referenced in this module + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + /*******************************************************************************/ + /* table : envelope level, 1.5 dB */ + /* theor range : [-58,58], CODE_BOOK_SCF_LAV = 58 */ + /* implem range: [-60,60], CODE_BOOK_SCF_LAV10 = 60 */ + /* raw stats : envelopeLevel_00 (yes, wrong suffix in name) KK 01-03-09 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode3C2FIX.m/envelopeLevel_00T_cF.mat/m_hALC_cF + built by : FH 01-07-05 */ + + extern const Char bookSbrEnvLevel10T[120][2] = + { + { 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 }, + { 5, 6 }, { -62, -67 }, { 7, 8 }, { -61, -68 }, + { 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 }, + { 13, 14 }, { -58, -71 }, { 15, 16 }, { -57, -72 }, + { 17, 18 }, { -73, -56 }, { 19, 21 }, { -74, 20 }, + { -55, -75 }, { 22, 26 }, { 23, 24 }, { -54, -76 }, + { -77, 25 }, { -53, -78 }, { 27, 34 }, { 28, 29 }, + { -52, -79 }, { 30, 31 }, { -80, -51 }, { 32, 33 }, + { -83, -82 }, { -81, -50 }, { 35, 57 }, { 36, 40 }, + { 37, 38 }, { -88, -84 }, { -48, 39 }, { -90, -85 }, + { 41, 46 }, { 42, 43 }, { -49, -87 }, { 44, 45 }, + { -89, -86 }, { -124, -123 }, { 47, 50 }, { 48, 49 }, + { -122, -121 }, { -120, -119 }, { 51, 54 }, { 52, 53 }, + { -118, -117 }, { -116, -115 }, { 55, 56 }, { -114, -113 }, + { -112, -111 }, { 58, 89 }, { 59, 74 }, { 60, 67 }, + { 61, 64 }, { 62, 63 }, { -110, -109 }, { -108, -107 }, + { 65, 66 }, { -106, -105 }, { -104, -103 }, { 68, 71 }, + { 69, 70 }, { -102, -101 }, { -100, -99 }, { 72, 73 }, + { -98, -97 }, { -96, -95 }, { 75, 82 }, { 76, 79 }, + { 77, 78 }, { -94, -93 }, { -92, -91 }, { 80, 81 }, + { -47, -46 }, { -45, -44 }, { 83, 86 }, { 84, 85 }, + { -43, -42 }, { -41, -40 }, { 87, 88 }, { -39, -38 }, + { -37, -36 }, { 90, 105 }, { 91, 98 }, { 92, 95 }, + { 93, 94 }, { -35, -34 }, { -33, -32 }, { 96, 97 }, + { -31, -30 }, { -29, -28 }, { 99, 102 }, { 100, 101 }, + { -27, -26 }, { -25, -24 }, { 103, 104 }, { -23, -22 }, + { -21, -20 }, { 106, 113 }, { 107, 110 }, { 108, 109 }, + { -19, -18 }, { -17, -16 }, { 111, 112 }, { -15, -14 }, + { -13, -12 }, { 114, 117 }, { 115, 116 }, { -11, -10 }, + { -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 } + }; + + /* direction: freq + raw table: HuffCode3C2FIX.m/envelopeLevel_00F_cF.mat/m_hALC_cF + built by : FH 01-07-05 */ + + extern const Char bookSbrEnvLevel10F[120][2] = + { + { 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 }, + { 5, 6 }, { -67, -62 }, { 7, 8 }, { -68, -61 }, + { 9, 10 }, { -69, -60 }, { 11, 13 }, { -70, 12 }, + { -59, -71 }, { 14, 16 }, { -58, 15 }, { -72, -57 }, + { 17, 19 }, { -73, 18 }, { -56, -74 }, { 20, 23 }, + { 21, 22 }, { -55, -75 }, { -54, -53 }, { 24, 27 }, + { 25, 26 }, { -76, -52 }, { -77, -51 }, { 28, 31 }, + { 29, 30 }, { -50, -78 }, { -79, -49 }, { 32, 36 }, + { 33, 34 }, { -48, -47 }, { -80, 35 }, { -81, -82 }, + { 37, 47 }, { 38, 41 }, { 39, 40 }, { -83, -46 }, + { -45, -84 }, { 42, 44 }, { -85, 43 }, { -44, -43 }, + { 45, 46 }, { -88, -87 }, { -86, -90 }, { 48, 66 }, + { 49, 56 }, { 50, 53 }, { 51, 52 }, { -92, -42 }, + { -41, -39 }, { 54, 55 }, { -105, -89 }, { -38, -37 }, + { 57, 60 }, { 58, 59 }, { -94, -91 }, { -40, -36 }, + { 61, 63 }, { -20, 62 }, { -115, -110 }, { 64, 65 }, + { -108, -107 }, { -101, -97 }, { 67, 89 }, { 68, 75 }, + { 69, 72 }, { 70, 71 }, { -95, -93 }, { -34, -27 }, + { 73, 74 }, { -22, -17 }, { -16, -124 }, { 76, 82 }, + { 77, 79 }, { -123, 78 }, { -122, -121 }, { 80, 81 }, + { -120, -119 }, { -118, -117 }, { 83, 86 }, { 84, 85 }, + { -116, -114 }, { -113, -112 }, { 87, 88 }, { -111, -109 }, + { -106, -104 }, { 90, 105 }, { 91, 98 }, { 92, 95 }, + { 93, 94 }, { -103, -102 }, { -100, -99 }, { 96, 97 }, + { -98, -96 }, { -35, -33 }, { 99, 102 }, { 100, 101 }, + { -32, -31 }, { -30, -29 }, { 103, 104 }, { -28, -26 }, + { -25, -24 }, { 106, 113 }, { 107, 110 }, { 108, 109 }, + { -23, -21 }, { -19, -18 }, { 111, 112 }, { -15, -14 }, + { -13, -12 }, { 114, 117 }, { 115, 116 }, { -11, -10 }, + { -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 } + }; + + /*******************************************************************************/ + /* table : envelope balance, 1.5 dB */ + /* theor range : [-48,48], CODE_BOOK_SCF_LAV = 48 */ + /* implem range: same but mapped to [-24,24], CODE_BOOK_SCF_LAV_BALANCE10 = 24 */ + /* raw stats : envelopePan_00 (yes, wrong suffix in name) KK 01-03-09 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode3C.m/envelopePan_00T.mat/v_hALB + built by : FH 01-05-15 */ + + extern const Char bookSbrEnvBalance10T[48][2] = + { + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 }, + { -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 }, + { -68, 9 }, { 10, 11 }, { -69, -59 }, { 12, 13 }, + { -70, -58 }, { 14, 28 }, { 15, 21 }, { 16, 18 }, + { -57, 17 }, { -71, -56 }, { 19, 20 }, { -88, -87 }, + { -86, -85 }, { 22, 25 }, { 23, 24 }, { -84, -83 }, + { -82, -81 }, { 26, 27 }, { -80, -79 }, { -78, -77 }, + { 29, 36 }, { 30, 33 }, { 31, 32 }, { -76, -75 }, + { -74, -73 }, { 34, 35 }, { -72, -55 }, { -54, -53 }, + { 37, 41 }, { 38, 39 }, { -52, -51 }, { -50, 40 }, + { -49, -48 }, { 42, 45 }, { 43, 44 }, { -47, -46 }, + { -45, -44 }, { 46, 47 }, { -43, -42 }, { -41, -40 } + }; + + /* direction: freq + raw table: HuffCode3C.m/envelopePan_00T.mat/v_hALB + built by : FH 01-05-15 */ + + extern const Char bookSbrEnvBalance10F[48][2] = + { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 11 }, { -69, -59 }, { -70, 12 }, + { -58, 13 }, { 14, 17 }, { -71, 15 }, { -57, 16 }, + { -56, -73 }, { 18, 32 }, { 19, 25 }, { 20, 22 }, + { -72, 21 }, { -88, -87 }, { 23, 24 }, { -86, -85 }, + { -84, -83 }, { 26, 29 }, { 27, 28 }, { -82, -81 }, + { -80, -79 }, { 30, 31 }, { -78, -77 }, { -76, -75 }, + { 33, 40 }, { 34, 37 }, { 35, 36 }, { -74, -55 }, + { -54, -53 }, { 38, 39 }, { -52, -51 }, { -50, -49 }, + { 41, 44 }, { 42, 43 }, { -48, -47 }, { -46, -45 }, + { 45, 46 }, { -44, -43 }, { -42, 47 }, { -41, -40 } + }; + + /*******************************************************************************/ + /* table : envelope level, 3.0 dB */ + /* theor range : [-29,29], CODE_BOOK_SCF_LAV = 29 */ + /* implem range: [-31,31], CODE_BOOK_SCF_LAV11 = 31 */ + /* raw stats : envelopeLevel_11 KK 00-02-03 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode2.m + built by : FH 00-02-04 */ + + extern const Char bookSbrEnvLevel11T[62][2] = + { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { -61, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 11 }, { -69, -59 }, { 12, 14 }, + { -70, 13 }, { -71, -58 }, { 15, 18 }, { 16, 17 }, + { -72, -57 }, { -73, -74 }, { 19, 22 }, { -56, 20 }, + { -55, 21 }, { -54, -77 }, { 23, 31 }, { 24, 25 }, + { -75, -76 }, { 26, 27 }, { -78, -53 }, { 28, 29 }, + { -52, -95 }, { -94, 30 }, { -93, -92 }, { 32, 47 }, + { 33, 40 }, { 34, 37 }, { 35, 36 }, { -91, -90 }, + { -89, -88 }, { 38, 39 }, { -87, -86 }, { -85, -84 }, + { 41, 44 }, { 42, 43 }, { -83, -82 }, { -81, -80 }, + { 45, 46 }, { -79, -51 }, { -50, -49 }, { 48, 55 }, + { 49, 52 }, { 50, 51 }, { -48, -47 }, { -46, -45 }, + { 53, 54 }, { -44, -43 }, { -42, -41 }, { 56, 59 }, + { 57, 58 }, { -40, -39 }, { -38, -37 }, { 60, 61 }, + { -36, -35 }, { -34, -33 } + }; + + /* direction: freq + raw table: HuffCode2.m + built by : FH 00-02-04 */ + + extern const Char bookSbrEnvLevel11F[62][2] = + { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 }, + { 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 }, + { 13, 14 }, { -58, -71 }, { 15, 16 }, { -57, -72 }, + { 17, 19 }, { -56, 18 }, { -55, -73 }, { 20, 24 }, + { 21, 22 }, { -74, -54 }, { -53, 23 }, { -75, -76 }, + { 25, 30 }, { 26, 27 }, { -52, -51 }, { 28, 29 }, + { -77, -79 }, { -50, -49 }, { 31, 39 }, { 32, 35 }, + { 33, 34 }, { -78, -46 }, { -82, -88 }, { 36, 37 }, + { -83, -48 }, { -47, 38 }, { -86, -85 }, { 40, 47 }, + { 41, 44 }, { 42, 43 }, { -80, -44 }, { -43, -42 }, + { 45, 46 }, { -39, -87 }, { -84, -40 }, { 48, 55 }, + { 49, 52 }, { 50, 51 }, { -95, -94 }, { -93, -92 }, + { 53, 54 }, { -91, -90 }, { -89, -81 }, { 56, 59 }, + { 57, 58 }, { -45, -41 }, { -38, -37 }, { 60, 61 }, + { -36, -35 }, { -34, -33 } + }; + + /*******************************************************************************/ + /* table : envelope balance, 3.0 dB */ + /* theor range : [-24,24], CODE_BOOK_SCF_LAV = 24 */ + /* implem range: same but mapped to [-12,12], CODE_BOOK_SCF_LAV_BALANCE11 = 12 */ + /* raw stats : envelopeBalance_11 KK 00-02-03 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode3C.m/envelopeBalance_11T.mat/v_hALB + built by : FH 01-05-15 */ + + extern const Char bookSbrEnvBalance11T[24][2] = + { + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 }, + { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 16 }, { 11, 13 }, { -69, 12 }, + { -76, -75 }, { 14, 15 }, { -74, -73 }, { -72, -71 }, + { 17, 20 }, { 18, 19 }, { -70, -59 }, { -58, -57 }, + { 21, 22 }, { -56, -55 }, { -54, 23 }, { -53, -52 } + }; + + /* direction: time (?) + raw table: HuffCode3C.m/envelopeBalance_11T.mat/v_hALB + built by : FH 01-05-15 */ + + extern const Char bookSbrEnvBalance11F[24][2] = + { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 13 }, { -69, 11 }, { -59, 12 }, + { -58, -76 }, { 14, 17 }, { 15, 16 }, { -75, -74 }, + { -73, -72 }, { 18, 21 }, { 19, 20 }, { -71, -70 }, + { -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 } + }; + + /*******************************************************************************/ + /* table : noise level, 3.0 dB */ + /* theor range : [-29,29], CODE_BOOK_SCF_LAV = 29 */ + /* implem range: [-31,31], CODE_BOOK_SCF_LAV11 = 31 */ + /* raw stats : noiseLevel_11 KK 00-02-03 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode2.m + built by : FH 00-02-04 */ + + extern const Char bookSbrNoiseLevel11T[62][2] = + { + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 }, + { 9, 30 }, { 10, 15 }, { -60, 11 }, { -69, 12 }, + { 13, 14 }, { -59, -53 }, { -95, -94 }, { 16, 23 }, + { 17, 20 }, { 18, 19 }, { -93, -92 }, { -91, -90 }, + { 21, 22 }, { -89, -88 }, { -87, -86 }, { 24, 27 }, + { 25, 26 }, { -85, -84 }, { -83, -82 }, { 28, 29 }, + { -81, -80 }, { -79, -78 }, { 31, 46 }, { 32, 39 }, + { 33, 36 }, { 34, 35 }, { -77, -76 }, { -75, -74 }, + { 37, 38 }, { -73, -72 }, { -71, -70 }, { 40, 43 }, + { 41, 42 }, { -58, -57 }, { -56, -55 }, { 44, 45 }, + { -54, -52 }, { -51, -50 }, { 47, 54 }, { 48, 51 }, + { 49, 50 }, { -49, -48 }, { -47, -46 }, { 52, 53 }, + { -45, -44 }, { -43, -42 }, { 55, 58 }, { 56, 57 }, + { -41, -40 }, { -39, -38 }, { 59, 60 }, { -37, -36 }, + { -35, 61 }, { -34, -33 } + }; + + /*******************************************************************************/ + /* table : noise balance, 3.0 dB */ + /* theor range : [-24,24], CODE_BOOK_SCF_LAV = 24 */ + /* implem range: same but mapped to [-12,12], CODE_BOOK_SCF_LAV_BALANCE11 = 12 */ + /* raw stats : noiseBalance_11 KK 00-02-03 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode3C.m/noiseBalance_11.mat/v_hALB + built by : FH 01-05-15 */ + + extern const Char bookSbrNoiseBalance11T[24][2] = + { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { 4, 9 }, + { -66, 5 }, { -62, 6 }, { 7, 8 }, { -76, -75 }, + { -74, -73 }, { 10, 17 }, { 11, 14 }, { 12, 13 }, + { -72, -71 }, { -70, -69 }, { 15, 16 }, { -68, -67 }, + { -61, -60 }, { 18, 21 }, { 19, 20 }, { -59, -58 }, + { -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 } + }; + +#ifdef __cplusplus +} +#endif + + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.h new file mode 100644 index 0000000..6250331 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_code_book_envlevel.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + this file declares the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_CODE_BOOK_ENVLEVEL_H +#define SBR_CODE_BOOK_ENVLEVEL_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + extern const Char bookSbrEnvLevel10T[120][2]; + extern const Char bookSbrEnvLevel10F[120][2]; + extern const Char bookSbrEnvBalance10T[48][2]; + extern const Char bookSbrEnvBalance10F[48][2]; + extern const Char bookSbrEnvLevel11T[62][2]; + extern const Char bookSbrEnvLevel11F[62][2]; + extern const Char bookSbrEnvBalance11T[24][2]; + extern const Char bookSbrEnvBalance11F[24][2]; + extern const Char bookSbrNoiseLevel11T[62][2]; + extern const Char bookSbrNoiseBalance11T[24][2]; + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_constants.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_constants.h new file mode 100644 index 0000000..6312dd8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_constants.h @@ -0,0 +1,202 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_constants.h + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_CONSTANTS_H +#define SBR_CONSTANTS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + + +#define SBR_AMP_RES_1_5 0 +#define SBR_AMP_RES_3_0 1 + +#define MAX_NOISE_ENVELOPES 2 +#define MAX_NOISE_COEFFS 5 +#define MAX_NUM_NOISE_VALUES (MAX_NOISE_ENVELOPES * MAX_NOISE_COEFFS) + +#define MAX_ENVELOPES 5 +#define MAX_FREQ_COEFFS 58 +#define MAX_NUM_ENVELOPE_VALUES (MAX_ENVELOPES * MAX_FREQ_COEFFS) + +#define MAX_NUM_CHANNELS 2 +#define NOISE_FLOOR_OFFSET 6 +#define NOISE_FLOOR_OFFSET_PLUS_1 7 + +#define LOW_RES 0 +#define HIGH_RES 1 + +#define LO 0 +#define HI 1 + +#define TIME 1 +#define FREQ 0 + +#define LENGTH_FRAME_INFO 35 + +#define SI_SBR_CRC_BITS 10 + +#define SBR_FREQ_SCALE_DEFAULT 2 +#define SBR_ALTER_SCALE_DEFAULT 1 +#define SBR_NOISE_BANDS_DEFAULT 2 + +#define SBR_LIMITER_BANDS_DEFAULT 2 +#define SBR_LIMITER_GAINS_DEFAULT 2 +#define SBR_INTERPOL_FREQ_DEFAULT 1 +#define SBR_SMOOTHING_LENGTH_DEFAULT 1 + +/* header */ +#define SI_SBR_AMP_RES_BITS 1 +#define SI_SBR_START_FREQ_BITS 4 +#define SI_SBR_STOP_FREQ_BITS 4 +#define SI_SBR_XOVER_BAND_BITS 3 +#define SI_SBR_RESERVED_BITS_HDR 2 +#define SI_SBR_DATA_EXTRA_BITS 1 +#define SI_SBR_HEADER_EXTRA_1_BITS 1 +#define SI_SBR_HEADER_EXTRA_2_BITS 1 + +#define SI_SBR_FREQ_SCALE_BITS 2 +#define SI_SBR_ALTER_SCALE_BITS 1 +#define SI_SBR_NOISE_BANDS_BITS 2 + +#define SI_SBR_LIMITER_BANDS_BITS 2 +#define SI_SBR_LIMITER_GAINS_BITS 2 +#define SI_SBR_INTERPOL_FREQ_BITS 1 +#define SI_SBR_SMOOTHING_LENGTH_BITS 1 + + +/* data */ +#define SI_SBR_RESERVED_PRESENT 1 +#define SI_SBR_RESERVED_BITS_DATA 4 + +#define SI_SBR_COUPLING_BITS 1 + +#define SI_SBR_INVF_MODE_BITS 2 + +#define SI_SBR_EXTENDED_DATA_BITS 1 +#define SI_SBR_EXTENSION_SIZE_BITS 4 +#define SI_SBR_EXTENSION_ESC_COUNT_BITS 8 +#define SI_SBR_EXTENSION_ID_BITS 2 + +#define SI_SBR_NOISE_MODE_BITS 1 +#define SI_SBR_DOMAIN_BITS 1 + +#define SI_SBR_START_ENV_BITS_AMP_RES_3_0 6 +#define SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_3_0 5 +#define SI_SBR_START_NOISE_BITS_AMP_RES_3_0 5 +#define SI_SBR_START_NOISE_BITS_BALANCE_AMP_RES_3_0 5 + +#define SI_SBR_START_ENV_BITS_AMP_RES_1_5 7 +#define SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_1_5 6 + + +#define SBR_CLA_BITS 2 +#define SBR_ABS_BITS 2 +#define SBR_RES_BITS 1 +#define SBR_REL_BITS 2 +#define SBR_ENV_BITS 2 +#define SBR_NUM_BITS 2 + + +#define FIXFIX 0 +#define FIXVAR 1 +#define VARFIX 2 +#define VARVAR 3 + + +#define LEN_EX_TYPE (4) +#define LEN_NIBBLE (4) + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_crc_check.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_crc_check.cpp new file mode 100644 index 0000000..6c14e33 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_crc_check.cpp @@ -0,0 +1,184 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_crc_check.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_crc_check.h" +#include "s_crc_buffer.h" +#include "buf_getbits.h" +#include "sbr_constants.h" +#include "check_crc.h" + + + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const unsigned short MAXCRCSTEP = 16; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 sbr_crc_check(BIT_BUFFER * hBitBuf, UInt32 NrBits) +{ + Int32 crcResult = 1; + BIT_BUFFER BitBufferCRC; + UInt32 NrCrcBits; + + UInt32 crcCheckSum; + + Int32 i; + CRC_BUFFER CrcBuf; + UInt32 bValue; + Int32 CrcStep; + Int32 CrcNrBitsRest; + + crcCheckSum = buf_getbits(hBitBuf, SI_SBR_CRC_BITS); + + + /* + * Copy Bit buffer State + */ + + BitBufferCRC.char_ptr = hBitBuf->char_ptr; + BitBufferCRC.buffer_word = hBitBuf->buffer_word; + BitBufferCRC.buffered_bits = hBitBuf->buffered_bits; + BitBufferCRC.nrBitsRead = hBitBuf->nrBitsRead; + BitBufferCRC.bufferLen = hBitBuf->bufferLen; + + + NrCrcBits = min(NrBits, BitBufferCRC.bufferLen - BitBufferCRC.nrBitsRead); + + + CrcStep = NrCrcBits / MAXCRCSTEP; + CrcNrBitsRest = (NrCrcBits - CrcStep * MAXCRCSTEP); + + CrcBuf.crcState = CRCSTART; + CrcBuf.crcMask = CRCMASK; + CrcBuf.crcPoly = CRCPOLY; + + for (i = 0; i < CrcStep; i++) + { + bValue = buf_getbits(&BitBufferCRC, MAXCRCSTEP); + check_crc(&CrcBuf, bValue, MAXCRCSTEP); + } + + bValue = buf_getbits(&BitBufferCRC, CrcNrBitsRest); + check_crc(&CrcBuf, bValue, CrcNrBitsRest); + + if ((UInt32)(CrcBuf.crcState & CRCRANGE) != crcCheckSum) + { + crcResult = 0; + } + + return (crcResult); +} + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_crc_check.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_crc_check.h new file mode 100644 index 0000000..f0f338e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_crc_check.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_crc_check.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_CRC_CHECK_H +#define SBR_CRC_CHECK_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define CRCPOLY 0x0233 +#define CRCMASK 0x0200 +#define CRCSTART 0x0000 +#define CRCRANGE 0x03FF + +#define SBR_EXTENSION 13 /* 1101 */ +#define SBR_EXTENSION_CRC 14 /* 1110 */ + + + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int32 sbr_crc_check(BIT_BUFFER * hBitBuf, + UInt32 NrBits); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.cpp new file mode 100644 index 0000000..f151742 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.cpp @@ -0,0 +1,246 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_create_limiter_bands.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_create_limiter_bands.h" +#include "shellsort.h" +#include "s_patch.h" +#include "pv_log2.h" + +#include "fxp_mul32.h" + +#define R_SHIFT 29 +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_create_limiter_bands(Int32 limSbc[][13], + Int32 *gateMode, + Int *freqTable, + struct PATCH Patch, + const Int32 noBands) +{ + Int32 i; + Int32 j; + Int32 k; + Int isPatchBorder[2]; + Int32 patchBorders[MAX_NUM_PATCHES + 1]; + Int32 workLimiterBandTable[32 + MAX_NUM_PATCHES + 1]; + + Int32 nOctaves; + const Int32 limiterBandsPerOctave[4] = + {Q_fmt(0.0F), Q_fmt(1.2F), + Q_fmt(2.0F), Q_fmt(3.0F) + }; + + Int32 tmp_q1; + + Int32 noPatches = Patch.noOfPatches; + Int32 lowSubband = freqTable[0]; + Int32 highSubband = freqTable[noBands]; + + + for (i = 0; i < noPatches; i++) + { + patchBorders[i] = Patch.targetStartBand[i] - lowSubband; + } + patchBorders[i] = highSubband - lowSubband; + + /* First band: 1 limiter band. */ + limSbc[0][0] = freqTable[0] - lowSubband; + limSbc[0][1] = freqTable[noBands] - lowSubband; + gateMode[0] = 1; + + /* Next three bands: 1.2, 2, 3 limiter bands/octave plus bandborders at patchborders. */ + for (i = 1; i < 4; i++) + { + + for (k = 0; k <= noBands; k++) + { + workLimiterBandTable[k] = freqTable[k] - lowSubband; + } + + for (k = 1; k < noPatches; k++) + { + workLimiterBandTable[noBands+k] = patchBorders[k]; + } + + gateMode[i] = noBands + noPatches - 1; + shellsort(workLimiterBandTable, gateMode[i] + 1); + + for (j = 1; j <= gateMode[i]; j++) + { + tmp_q1 = ((workLimiterBandTable[j] + lowSubband) << 20) / (workLimiterBandTable[j-1] + lowSubband); + + nOctaves = pv_log2(tmp_q1); + + tmp_q1 = fxp_mul32_Q20(nOctaves, limiterBandsPerOctave[i]); + if (tmp_q1 < Q_fmt(0.49)) + { + if (workLimiterBandTable[j] == workLimiterBandTable[j-1]) + { + workLimiterBandTable[j] = highSubband; + shellsort(workLimiterBandTable, gateMode[i] + 1); + gateMode[i]--; + j--; + continue; + } + + isPatchBorder[0] = isPatchBorder[1] = 0; + + for (k = 0; k <= noPatches; k++) + { + if (workLimiterBandTable[j-1] == patchBorders[k]) + { + isPatchBorder[0] = 1; + break; + } + } + + for (k = 0; k <= noPatches; k++) + { + if (workLimiterBandTable[j] == patchBorders[k]) + { + isPatchBorder[1] = 1; + break; + } + } + + if (!isPatchBorder[1]) + { + workLimiterBandTable[j] = highSubband; + shellsort(workLimiterBandTable, gateMode[i] + 1); + gateMode[i]--; + j--; + } + else if (!isPatchBorder[0]) + { + workLimiterBandTable[j-1] = highSubband; + shellsort(workLimiterBandTable, gateMode[i] + 1); + gateMode[i]--; + j--; + } + } + } + for (k = 0; k <= gateMode[i]; k++) + { + limSbc[i][k] = workLimiterBandTable[k]; + } + } +} + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.h new file mode 100644 index 0000000..acae11b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_create_limiter_bands.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_CREATE_LIMITER_BANDS_H +#define SBR_CREATE_LIMITER_BANDS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "sbr_generate_high_freq.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void sbr_create_limiter_bands(Int32 limSbc[4][12 + 1], + Int32 gateMode[4], + Int *freqTable, + struct PATCH Patch, + const Int32 noBands); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_dec.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_dec.cpp new file mode 100644 index 0000000..0d2dd62 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_dec.cpp @@ -0,0 +1,959 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_dec.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + sbr decoder core function + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#ifdef AAC_PLUS + + +#include "s_sbr_frame_data.h" +#include "calc_sbr_synfilterbank.h" +#include "calc_sbr_anafilterbank.h" +#include "calc_sbr_envelope.h" +#include "sbr_generate_high_freq.h" +#include "sbr_dec.h" +#include "decode_noise_floorlevels.h" +#include "aac_mem_funcs.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +#ifdef PARAMETRICSTEREO + +#include "ps_applied.h" +#include "ps_init_stereo_mixing.h" + +#endif + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_dec(Int16 *inPcmData, + Int16 *ftimeOutPtr, + SBR_FRAME_DATA * hFrameData, + Int32 applyProcessing, + SBR_DEC *sbrDec, +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + Int16 * ftimeOutPtrPS, + HANDLE_PS_DEC hParametricStereoDec, +#endif +#endif + tDec_Int_File *pVars) +{ + Int32 i; + Int32 j; + Int32 m; + + Int32 *frameInfo = hFrameData->frameInfo; + Int num_qmf_bands; + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + + Int32 env; + + Int32 *qmf_PS_generated_Real; + Int32 *qmf_PS_generated_Imag; + + Int32 *Sr_x; + Int32 *Si_x; + + +#endif +#endif + + Int32(*scratch_mem)[64]; + Int16 *circular_buffer_s; + + Int32 k; + Int32 *Sr; + Int32 *Si; + Int32 *ptr_tmp1; + Int32 *ptr_tmp2; + scratch_mem = pVars->scratch.scratch_mem; + + + if (applyProcessing) + { + num_qmf_bands = sbrDec->lowSubband; + } + else + { + num_qmf_bands = 32; /* becomes a resampler by 2 */ + } + + /* -------------------------------------------------- */ + /* + * Re-Load Buffers + */ + pv_memmove(&hFrameData->sbrQmfBufferReal[0], + &hFrameData->HistsbrQmfBufferReal[0], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal)); +#ifdef HQ_SBR + + + if (sbrDec->LC_aacP_DecoderFlag == OFF) + { + pv_memmove(&hFrameData->sbrQmfBufferImag[0], + &hFrameData->HistsbrQmfBufferImag[0], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag)); + } +#endif + /* -------------------------------------------------- */ + + + /* + * low band codec signal subband filtering + */ + + for (i = 0; i < 32; i++) + { + + if (sbrDec->LC_aacP_DecoderFlag == ON) + { + + calc_sbr_anafilterbank_LC(hFrameData->codecQmfBufferReal[sbrDec->bufWriteOffs + i], + &inPcmData[319] + (i << 5), + scratch_mem, + num_qmf_bands); + + } +#ifdef HQ_SBR + else + { + + calc_sbr_anafilterbank(hFrameData->codecQmfBufferReal[sbrDec->bufWriteOffs + i], + hFrameData->codecQmfBufferImag[sbrDec->bufWriteOffs + i], + &inPcmData[319] + (i << 5), + scratch_mem, + num_qmf_bands); + } +#endif + + } + + if (pVars->ltp_buffer_state) + { + pv_memcpy(&inPcmData[-1024-288], &inPcmData[1024], 288*sizeof(*inPcmData)); + } + else + { + pv_memcpy(&inPcmData[1024 + 288], &inPcmData[1024], 288*sizeof(*inPcmData)); + } + + + if (applyProcessing) + { + + /* + * Inverse filtering of lowband + HF generation + */ + + if (sbrDec->LC_aacP_DecoderFlag == ON) + { + + sbr_generate_high_freq((Int32(*)[32])(hFrameData->codecQmfBufferReal + sbrDec->bufReadOffs), + NULL, + (Int32 *)(hFrameData->sbrQmfBufferReal), + NULL, + hFrameData->sbr_invf_mode, + hFrameData->sbr_invf_mode_prev, + &(sbrDec->FreqBandTableNoise[1]), + sbrDec->NoNoiseBands, + sbrDec->lowSubband, + sbrDec->V_k_master, + sbrDec->Num_Master, + sbrDec->outSampleRate, + frameInfo, + hFrameData->degreeAlias, + scratch_mem, + hFrameData->BwVector,/* */ + hFrameData->BwVectorOld, + &(sbrDec->Patch), + sbrDec->LC_aacP_DecoderFlag, + &(sbrDec->highSubband)); + + + /* + * Adjust envelope of current frame. + */ + + calc_sbr_envelope(hFrameData, + (Int32 *)(hFrameData->sbrQmfBufferReal), + NULL, + sbrDec->FreqBandTable, + sbrDec->NSfb, + sbrDec->FreqBandTableNoise, + sbrDec->NoNoiseBands, + hFrameData->reset_flag, + hFrameData->degreeAlias, + &(hFrameData->harm_index), + &(hFrameData->phase_index), + hFrameData->hFp, + &(hFrameData->sUp), + sbrDec->limSbc, + sbrDec->gateMode, +#ifdef HQ_SBR + NULL, + NULL, + NULL, + NULL, +#endif + scratch_mem, + sbrDec->Patch, + sbrDec->sqrt_cache, + sbrDec->LC_aacP_DecoderFlag); + } +#ifdef HQ_SBR + else + { + + sbr_generate_high_freq((Int32(*)[32])(hFrameData->codecQmfBufferReal + sbrDec->bufReadOffs), + (Int32(*)[32])(hFrameData->codecQmfBufferImag + sbrDec->bufReadOffs), + (Int32 *)(hFrameData->sbrQmfBufferReal), + (Int32 *)(hFrameData->sbrQmfBufferImag), + hFrameData->sbr_invf_mode, + hFrameData->sbr_invf_mode_prev, + &(sbrDec->FreqBandTableNoise[1]), + sbrDec->NoNoiseBands, + sbrDec->lowSubband, + sbrDec->V_k_master, + sbrDec->Num_Master, + sbrDec->outSampleRate, + frameInfo, + NULL, + scratch_mem, + hFrameData->BwVector, + hFrameData->BwVectorOld, + &(sbrDec->Patch), + sbrDec->LC_aacP_DecoderFlag, + &(sbrDec->highSubband)); + + /* + * Adjust envelope of current frame. + */ + + calc_sbr_envelope(hFrameData, + (Int32 *)(hFrameData->sbrQmfBufferReal), + (Int32 *)(hFrameData->sbrQmfBufferImag), + sbrDec->FreqBandTable, + sbrDec->NSfb, + sbrDec->FreqBandTableNoise, + sbrDec->NoNoiseBands, + hFrameData->reset_flag, + NULL, + &(hFrameData->harm_index), + &(hFrameData->phase_index), + hFrameData->hFp, + &(hFrameData->sUp), + sbrDec->limSbc, + sbrDec->gateMode, + hFrameData->fBuf_man, + hFrameData->fBuf_exp, + hFrameData->fBufN_man, + hFrameData->fBufN_exp, + scratch_mem, + sbrDec->Patch, + sbrDec->sqrt_cache, + sbrDec->LC_aacP_DecoderFlag); + + } +#endif + + + } + else /* else for applyProcessing */ + { + /* no sbr, set high band buffers to zero */ + + for (i = 0; i < SBR_NUM_COLUMNS; i++) + { + pv_memset((void *)&hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS], + 0, + SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal)); + +#ifdef HQ_SBR + pv_memset((void *)&hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS], + 0, + SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag)); + +#endif + } + + } + + + /* + * Synthesis subband filtering. + */ + +#ifdef HQ_SBR + +#ifdef PARAMETRICSTEREO + + + /* + * psPresentFlag set implies hParametricStereoDec !=NULL, second condition is + * is just here to prevent CodeSonar warnings. + */ + if ((pVars->mc_info.psPresentFlag) && (applyProcessing) && + (hParametricStereoDec != NULL)) + { + + /* + * qmfBufferReal uses the rigth aac channel ( perChan[1] is not used) + * followed by the buffer fxpCoef[2][2048] which makes a total of + * 2349 + 2048*2 = 6445 + * These 2 matrices (qmfBufferReal & qmfBufferImag) are + * [2][38][64] == 4864 Int32 + */ + + + tDec_Int_Chan *tmpx = &pVars->perChan[1]; + /* + * dereferencing type-punned pointer avoid + * breaking strict-aliasing rules + */ + Int32 *tmp = (Int32 *)tmpx; + hParametricStereoDec->qmfBufferReal = (Int32(*)[64]) tmp; + + tmp = (Int32 *) & hParametricStereoDec->qmfBufferReal[38][0]; + hParametricStereoDec->qmfBufferImag = (Int32(*)[64]) tmp; + + for (i = 0; i < 32; i++) + { + Int xoverBand; + + if (i < ((hFrameData->frameInfo[1]) << 1)) + { + xoverBand = sbrDec->prevLowSubband; + } + else + { + xoverBand = sbrDec->lowSubband; + } + + if (xoverBand > sbrDec->highSubband) + { + // 2012-06-16 Vaclav Bartacek { + /* + * error condition, default to upsampling mode + * and make sure that the number of bands for xover does + * not exceed the number of high freq bands. + */ + // xoverBand = 32; /* error condition, default to upsampling mode */ + xoverBand = (sbrDec->highSubband > 32)? 32: sbrDec->highSubband; + // 2012-06-16 Vaclav Bartacek } + } + + m = sbrDec->bufReadOffs + i; /* 2 + i */ + + Sr_x = hParametricStereoDec->qmfBufferReal[i]; + Si_x = hParametricStereoDec->qmfBufferImag[i]; + + + + for (int32 j = 0; j < xoverBand; j++) + { + Sr_x[j] = shft_lft_1(hFrameData->codecQmfBufferReal[m][j]); + Si_x[j] = shft_lft_1(hFrameData->codecQmfBufferImag[m][j]); + } + + + + + pv_memcpy(&Sr_x[xoverBand], + &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS], + (sbrDec->highSubband - xoverBand)*sizeof(*Sr_x)); + + pv_memcpy(&Si_x[xoverBand], + &hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS], + (sbrDec->highSubband - xoverBand)*sizeof(*Si_x)); + + pv_memset((void *)&Sr_x[sbrDec->highSubband], + 0, + (64 - sbrDec->highSubband)*sizeof(*Sr_x)); + + pv_memset((void *)&Si_x[sbrDec->highSubband], + 0, + (64 - sbrDec->highSubband)*sizeof(*Si_x)); + + + } + + for (i = 32; i < 32 + 6; i++) + { + m = sbrDec->bufReadOffs + i; /* 2 + i */ + + for (int32 j = 0; j < 5; j++) + { + hParametricStereoDec->qmfBufferReal[i][j] = shft_lft_1(hFrameData->codecQmfBufferReal[m][j]); + hParametricStereoDec->qmfBufferImag[i][j] = shft_lft_1(hFrameData->codecQmfBufferImag[m][j]); + } + + } + + + /* + * Update Buffers + */ + for (i = 0; i < sbrDec->bufWriteOffs; i++) /* sbrDec->bufWriteOffs set to 8 and unchanged */ + { + j = sbrDec->noCols + i; /* sbrDec->noCols set to 32 and unchanged */ + + pv_memmove(hFrameData->codecQmfBufferReal[i], /* to */ + hFrameData->codecQmfBufferReal[j], /* from */ + sizeof(*hFrameData->codecQmfBufferReal[i]) << 5); + + pv_memmove(hFrameData->codecQmfBufferImag[i], + hFrameData->codecQmfBufferImag[j], + sizeof(*hFrameData->codecQmfBufferImag[i]) << 5); + } + + + pv_memmove(&hFrameData->HistsbrQmfBufferReal[0], + &hFrameData->sbrQmfBufferReal[32*SBR_NUM_BANDS], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal)); + + pv_memmove(&hFrameData->HistsbrQmfBufferImag[0], + &hFrameData->sbrQmfBufferImag[32*SBR_NUM_BANDS], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag)); + + + /* + * Needs whole QMF matrix formed before applying + * Parametric stereo processing. + */ + + qmf_PS_generated_Real = scratch_mem[0]; + qmf_PS_generated_Imag = scratch_mem[1]; + env = 0; + + /* + * Set circular buffer for Left channel + */ + + circular_buffer_s = (Int16 *)scratch_mem[7]; + + + if (pVars->mc_info.bDownSampledSbr) + { + pv_memmove(&circular_buffer_s[2048], + hFrameData->V, + 640*sizeof(*circular_buffer_s)); + } + else + { + pv_memmove(&circular_buffer_s[4096], + hFrameData->V, + 1152*sizeof(*circular_buffer_s)); + + } + + + /* + * Set Circular buffer for PS hybrid analysis + */ + + Int32 *pt_temp = &scratch_mem[2][32]; + + for (i = 0, j = 0; i < 3; i++) + { + + pv_memmove(&pt_temp[ j], + hParametricStereoDec->hHybrid->mQmfBufferReal[i], + HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferReal)); + pv_memmove(&pt_temp[ j + 44], + hParametricStereoDec->hHybrid->mQmfBufferImag[i], + HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferImag)); + j += 88; + } + + + pv_memset((void *)&qmf_PS_generated_Real[hParametricStereoDec->usb], + 0, + (64 - hParametricStereoDec->usb)*sizeof(*qmf_PS_generated_Real)); + + pv_memset((void *)&qmf_PS_generated_Imag[hParametricStereoDec->usb], + 0, + (64 - hParametricStereoDec->usb)*sizeof(*qmf_PS_generated_Imag)); + + + for (i = 0; i < 32; i++) + { + if (i == (Int)hParametricStereoDec-> aEnvStartStop[env]) + { + ps_init_stereo_mixing(hParametricStereoDec, env, sbrDec->highSubband); + env++; + } + + + ps_applied(hParametricStereoDec, + &hParametricStereoDec->qmfBufferReal[i], + &hParametricStereoDec->qmfBufferImag[i], + qmf_PS_generated_Real, + qmf_PS_generated_Imag, + scratch_mem[2], + i); + + /* Create time samples for regular mono channel */ + + if (pVars->mc_info.bDownSampledSbr) + { + calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */ + hParametricStereoDec->qmfBufferImag[i], /* imagSamples */ + ftimeOutPtr + (i << 6), + &circular_buffer_s[1984 - (i<<6)], + pVars->mc_info.bDownSampledSbr); + } + else + { + calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */ + hParametricStereoDec->qmfBufferImag[i], /* imagSamples */ + ftimeOutPtr + (i << 7), + &circular_buffer_s[3968 - (i<<7)], + pVars->mc_info.bDownSampledSbr); + + } + + pv_memmove(hParametricStereoDec->qmfBufferReal[i], qmf_PS_generated_Real, 64*sizeof(*qmf_PS_generated_Real)); + pv_memmove(hParametricStereoDec->qmfBufferImag[i], qmf_PS_generated_Imag, 64*sizeof(*qmf_PS_generated_Real)); + + } + + + /* + * Save Circular buffer history used on PS hybrid analysis + */ + + + pt_temp = &scratch_mem[2][64]; + + for (i = 0, j = 0; i < 3; i++) + { + pv_memmove(hParametricStereoDec->hHybrid->mQmfBufferReal[i], + &pt_temp[ j], + HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferReal)); + + pv_memmove(hParametricStereoDec->hHybrid->mQmfBufferImag[i], + &pt_temp[ j + 44], + HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferImag)); + + j += 88; + } + + + pv_memmove(hFrameData->V, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s)); + + /* + * Set circular buffer for Right channel + */ + + circular_buffer_s = (Int16 *)scratch_mem[5]; + + if (pVars->mc_info.bDownSampledSbr) + { + pv_memmove(&circular_buffer_s[2048], + (Int32 *)hParametricStereoDec->R_ch_qmf_filter_history, + 640*sizeof(*circular_buffer_s)); + } + else + { + pv_memmove(&circular_buffer_s[4096], + (Int32 *)hParametricStereoDec->R_ch_qmf_filter_history, + 1152*sizeof(*circular_buffer_s)); + + } + + + for (i = 0; i < 32; i++) + { + if (pVars->mc_info.bDownSampledSbr) + { + + calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */ + hParametricStereoDec->qmfBufferImag[i], /* imagSamples */ + ftimeOutPtrPS + (i << 6), + &circular_buffer_s[1984 - (i<<6)], + pVars->mc_info.bDownSampledSbr); + } + else + { + calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */ + hParametricStereoDec->qmfBufferImag[i], /* imagSamples */ + ftimeOutPtrPS + (i << 7), + &circular_buffer_s[3968 - (i<<7)], + pVars->mc_info.bDownSampledSbr); + } + + } + + if (pVars->mc_info.bDownSampledSbr) + { + pv_memmove((Int32 *)hParametricStereoDec->R_ch_qmf_filter_history, &circular_buffer_s[0], 640*sizeof(*circular_buffer_s)); + } + else + { + pv_memmove((Int32 *)hParametricStereoDec->R_ch_qmf_filter_history, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s)); + } + + + + + + } + else /* else -- sbrEnablePS */ + { + +#endif /* PARAMETRICSTEREO */ +#endif /* HQ_SBR */ + + /* + * Use shared aac memory as continuous buffer + */ + + + Sr = scratch_mem[0]; + Si = scratch_mem[1]; + + circular_buffer_s = (Int16*)scratch_mem[2]; + + if (pVars->mc_info.bDownSampledSbr) + { + + pv_memmove(&circular_buffer_s[2048], + hFrameData->V, + 640*sizeof(*circular_buffer_s)); + } + else + { + pv_memmove(&circular_buffer_s[4096], + hFrameData->V, + 1152*sizeof(*circular_buffer_s)); + } + + for (i = 0; i < 32; i++) + { + Int xoverBand; + + if (applyProcessing) + { + if (i < ((hFrameData->frameInfo[1]) << 1)) + { + xoverBand = sbrDec->prevLowSubband; + + } + else + { + xoverBand = sbrDec->lowSubband; + } + + if (xoverBand > sbrDec->highSubband) + { + // 2012-06-16 Vaclav Bartacek { + /* + * error condition, default to upsampling mode + * and make sure that the number of bands for xover does + * not exceed the number of high freq bands. + */ + // xoverBand = 32; /* error condition, default to upsampling mode */ + xoverBand = (sbrDec->highSubband > 32)? 32: sbrDec->highSubband; + // 2012-06-16 Vaclav Bartacek } + } + } + else + { + xoverBand = 32; + sbrDec->highSubband = 32; + } + + + m = sbrDec->bufReadOffs + i; /* sbrDec->bufReadOffs == 2 */ + + + ptr_tmp1 = (hFrameData->codecQmfBufferReal[m]); + ptr_tmp2 = Sr; + + if (sbrDec->LC_aacP_DecoderFlag == ON) + { + + for (k = (xoverBand >> 1); k != 0; k--) + { + *(ptr_tmp2++) = (*(ptr_tmp1++)) >> 9; + *(ptr_tmp2++) = (*(ptr_tmp1++)) >> 9; + } + if (xoverBand & 1) + { + *(ptr_tmp2++) = (*(ptr_tmp1)) >> 9; + } + + ptr_tmp1 = &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS]; + + + for (k = xoverBand; k < sbrDec->highSubband; k++) + { + *(ptr_tmp2++) = (*(ptr_tmp1++)) << 1; + } + + pv_memset((void *)ptr_tmp2, + 0, + (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2)); + + + if (pVars->mc_info.bDownSampledSbr) + { + calc_sbr_synfilterbank_LC(Sr, /* realSamples */ + ftimeOutPtr + (i << 6), + &circular_buffer_s[1984 - (i<<6)], + pVars->mc_info.bDownSampledSbr); + } + else + { + calc_sbr_synfilterbank_LC(Sr, /* realSamples */ + ftimeOutPtr + (i << 7), + &circular_buffer_s[3968 - (i<<7)], + pVars->mc_info.bDownSampledSbr); + } + } +#ifdef HQ_SBR + else + { + + for (k = xoverBand; k != 0; k--) + { + *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++)); + } + + ptr_tmp1 = &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS]; + ptr_tmp2 = &Sr[xoverBand]; + + + for (k = xoverBand; k < sbrDec->highSubband; k++) + { + *(ptr_tmp2++) = (*(ptr_tmp1++)); + } + + pv_memset((void *)ptr_tmp2, + 0, + (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2)); + + + ptr_tmp1 = (hFrameData->codecQmfBufferImag[m]); + ptr_tmp2 = Si; + + for (k = (xoverBand >> 1); k != 0; k--) + { + *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++)); + *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++)); + } + if (xoverBand & 1) + { + *(ptr_tmp2) = shft_lft_1(*(ptr_tmp1)); + } + + ptr_tmp1 = &hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS]; + ptr_tmp2 = &Si[xoverBand]; + + for (k = xoverBand; k < sbrDec->highSubband; k++) + { + *(ptr_tmp2++) = (*(ptr_tmp1++)); + } + + pv_memset((void *)ptr_tmp2, + 0, + (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2)); + + + if (pVars->mc_info.bDownSampledSbr) + { + calc_sbr_synfilterbank(Sr, /* realSamples */ + Si, /* imagSamples */ + ftimeOutPtr + (i << 6), + &circular_buffer_s[1984 - (i<<6)], + pVars->mc_info.bDownSampledSbr); + } + else + { + calc_sbr_synfilterbank(Sr, /* realSamples */ + Si, /* imagSamples */ + ftimeOutPtr + (i << 7), + &circular_buffer_s[3968 - (i<<7)], + pVars->mc_info.bDownSampledSbr); + } + } +#endif + + } + + if (pVars->mc_info.bDownSampledSbr) + { + pv_memmove(hFrameData->V, &circular_buffer_s[0], 640*sizeof(*circular_buffer_s)); + } + else + { + pv_memmove(hFrameData->V, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s)); + } + + + + + /* + * Update Buffers + */ + for (i = 0; i < sbrDec->bufWriteOffs; i++) /* sbrDec->bufWriteOffs set to 8 and unchanged */ + { + j = sbrDec->noCols + i; /* sbrDec->noCols set to 32 and unchanged */ + + pv_memmove(hFrameData->codecQmfBufferReal[i], /* to */ + hFrameData->codecQmfBufferReal[j], /* from */ + sizeof(*hFrameData->codecQmfBufferReal[i]) << 5); + } + + + pv_memmove(&hFrameData->HistsbrQmfBufferReal[0], + &hFrameData->sbrQmfBufferReal[32*SBR_NUM_BANDS], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal)); + +#ifdef HQ_SBR + if (sbrDec->LC_aacP_DecoderFlag == OFF) + { + for (i = 0; i < sbrDec->bufWriteOffs; i++) /* sbrDec->bufWriteOffs set to 6 and unchanged */ + { + j = sbrDec->noCols + i; /* sbrDec->noCols set to 32 and unchanged */ + + + pv_memmove(hFrameData->codecQmfBufferImag[i], + hFrameData->codecQmfBufferImag[j], + sizeof(*hFrameData->codecQmfBufferImag[i]) << 5); + + } + + pv_memmove(&hFrameData->HistsbrQmfBufferImag[0], + &hFrameData->sbrQmfBufferImag[32*SBR_NUM_BANDS], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag)); + } +#endif + + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + } +#endif +#endif + + + hFrameData->reset_flag = 0; + if (applyProcessing) + { + sbrDec->prevLowSubband = sbrDec->lowSubband; + } + +} + + +#endif /* AAC_PLUS */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_dec.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_dec.h new file mode 100644 index 0000000..d1369f6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_dec.h @@ -0,0 +1,138 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_dec.h + Functions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_DEC_H +#define SBR_DEC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "s_sbr_frame_data.h" +#include "pv_audio_type_defs.h" +#include "s_patch.h" +#include "e_blockswitching.h" +#include "s_sbr_dec.h" +#include "s_tdec_int_file.h" +#ifdef PARAMETRICSTEREO +#include "s_ps_dec.h" +#endif + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + + void sbr_dec(Int16 *inPcmData, + Int16 *ftimeOutPtr, + SBR_FRAME_DATA * hFrameData, + Int32 applyProcessing, + SBR_DEC *sbrDec, +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + Int16 * ftimeOutPtrPS, + HANDLE_PS_DEC hParametricStereoDec, +#endif +#endif + tDec_Int_File *pVars); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.cpp new file mode 100644 index 0000000..e2dc82b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.cpp @@ -0,0 +1,279 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_decode_envelope.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_decode_envelope.h" +#include "sbr_constants.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void mapLowResEnergyVal( + Int32 currVal, + Int32 *prevData, + Int32 offset, + Int32 index, + Int32 res); + +Int32 indexLow2High(Int32 offset, + Int32 index, + Int32 res); + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void sbr_decode_envelope(SBR_FRAME_DATA * hFrameData) + +{ + Int32 i; + Int32 no_of_bands; + Int32 band; + Int32 freqRes; + Int32 *iEnvelope = hFrameData->iEnvelope_man; + Int32 *sfb_nrg_prev = hFrameData->sfb_nrg_prev_man; + + Int32 offset = hFrameData->offset; + Int32 *nSfb = hFrameData->nSfb; + Int32 *domain_vec = hFrameData->domain_vec1; + Int32 *frameInfo = hFrameData->frameInfo; + + + + for (i = 0; i < frameInfo[0]; i++) + { + freqRes = frameInfo[frameInfo[0] + i + 2]; + no_of_bands = nSfb[freqRes]; + + if (domain_vec[i] == 0) + { + mapLowResEnergyVal(*iEnvelope, + sfb_nrg_prev, + offset, + 0, + freqRes); + iEnvelope++; + + for (band = 1; band < no_of_bands; band++) + { + *iEnvelope += *(iEnvelope - 1); + + mapLowResEnergyVal(*iEnvelope, + sfb_nrg_prev, + offset, + band, + freqRes); + iEnvelope++; + } + } + else + { + for (band = 0; band < no_of_bands; band++) + { + *iEnvelope += sfb_nrg_prev[ indexLow2High(offset, band, freqRes)]; + + mapLowResEnergyVal(*iEnvelope, + sfb_nrg_prev, + offset, + band, + freqRes); + iEnvelope++; + } + } + } +} + + + +void mapLowResEnergyVal( + Int32 currVal, + Int32 *prevData, + Int32 offset, + Int32 index, + Int32 res) +{ + Int32 tmp; + + if (res == LO) + { + if (offset >= 0) + { + if (index < offset) + { + prevData[index] = currVal; + } + else + { + tmp = (index << 1) - offset; + prevData[tmp ] = currVal; + prevData[tmp +1 ] = currVal; + } + } + else + { + offset = -offset; + if (index < offset) + { + tmp = (index << 1) + index; + prevData[tmp ] = currVal; + prevData[tmp + 1] = currVal; + prevData[tmp + 2] = currVal; + } + else + { + tmp = (index << 1) + offset; + prevData[tmp ] = currVal; + prevData[tmp + 1] = currVal; + } + } + } + else + { + prevData[index] = currVal; + } +} + + +Int32 indexLow2High(Int32 offset, + Int32 index, + Int32 res) +{ + if (res == LO) + { + if (offset >= 0) + { + if (index < offset) + { + return(index); + } + else + { + return((index << 1) - offset); + } + } + else + { + offset = -offset; + if (index < offset) + { + return((index << 1) + index); + } + else + { + return((index << 1) + offset); + } + } + } + else + { + return(index); + } +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.h new file mode 100644 index 0000000..a415e0e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_decode_envelope.h + Funtions: + decodeEnvelope + +------------------------------------------------------------------------------ + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_DECODE_ENVELOPE_H +#define SBR_DECODE_ENVELOPE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void sbr_decode_envelope(SBR_FRAME_DATA * hFrameData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.cpp new file mode 100644 index 0000000..720cb90 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.cpp @@ -0,0 +1,142 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_decode_huff_cw.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + SbrHuffman h, pointer to huffman codebook table + BIT_BUFFER * hBitBuf pointer to Bitbuffer + + return decoded value +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decodes one huffman code word + + Reads bits from the bitstream until a valid codeword is found. + The table entries are interpreted either as index to the next entry + or - if negative - as the codeword. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_decode_huff_cw.h" +#include "buf_getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 sbr_decode_huff_cw(SbrHuffman h, + BIT_BUFFER * hBitBuf) +{ + Int32 bits; + Char index = 0; + + while (index >= 0) + { + bits = buf_get_1bit(hBitBuf); + index = h[index][bits]; + } + + return((Int32)index + 64); /* Add offset */ +} + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.h new file mode 100644 index 0000000..c039cb7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_decode_huff_cw.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_DECODE_HUFF_CW_H +#define SBR_DECODE_HUFF_CW_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int32 sbr_decode_huff_cw(SbrHuffman h, + BIT_BUFFER * hBitBuf); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.cpp new file mode 100644 index 0000000..1f7758f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.cpp @@ -0,0 +1,155 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_downsample_lo_res.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_downsample_lo_res.h" +#include "sbr_constants.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_downsample_lo_res(Int32 v_result[], + Int32 num_result, + Int freqBandTableRef[], + Int32 num_Ref) +{ + Int32 step; + Int32 i, j; + Int32 org_length; + Int32 result_length; + Int32 v_index[MAX_FREQ_COEFFS/2]; + + /* init */ + org_length = num_Ref; + result_length = num_result; + + v_index[0] = 0; /* Always use left border */ + i = 0; + while (org_length > 0) /* Create downsample vector */ + { + i++; + step = org_length / result_length; /* floor; */ + org_length = org_length - step; + result_length--; + v_index[i] = v_index[i-1] + step; + } + + for (j = 0; j <= i; j++) /* Use downsample vector to index LoResolution vector. */ + { + v_result[j] = freqBandTableRef[ v_index[j]]; + } + +} /* End downSampleLoRes */ + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.h new file mode 100644 index 0000000..69f0604 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_downsample_lo_res.h + Functions: + get_dse + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_DOWNSAMPLE_LO_RES_H +#define SBR_DOWNSAMPLE_LO_RES_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void sbr_downsample_lo_res(Int32 v_result[], + Int32 num_result, + Int freqBandTableRef[], + Int32 num_Ref); + +#ifdef __cplusplus +} +#endif + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.cpp new file mode 100644 index 0000000..06b022a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.cpp @@ -0,0 +1,401 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_envelope_calc_tbl.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_envelope_calc_tbl.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +#define Q30_fmt(x) (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F)) +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + + +const Int32 limGains[5] = { Q30_fmt(0.70795f), Q30_fmt(1.0f), + Q30_fmt(1.41254f), Q30_fmt(1.16415321826935f), 33 + }; + +const Int32 smoothLengths[2] = { 4, 0 }; + +const Int16 rP_LCx[512] = +{ + Qfmt15(-0.99948153278296f), Qfmt15(0.97113454393991f), Qfmt15(0.14130051758487f), Qfmt15(-0.47005496701697f), + Qfmt15(0.80705063769351f), Qfmt15(-0.38981478896926f), Qfmt15(-0.01053049862020f), Qfmt15(-0.91266367957293f), + Qfmt15(0.54840422910309f), Qfmt15(0.40009252867955f), Qfmt15(-0.99867974711855f), Qfmt15(-0.95531076805040f), + Qfmt15(-0.45725933317144f), Qfmt15(-0.72929675029275f), Qfmt15(0.75622801399036f), Qfmt15(0.07069442601050f), + Qfmt15(0.74496252926055f), Qfmt15(-0.96440182703856f), Qfmt15(0.30424629369539f), Qfmt15(0.66565033746925f), + Qfmt15(0.91697008020594f), Qfmt15(-0.70774918760427f), Qfmt15(-0.70051415345560f), Qfmt15(-0.99496513054797f), + Qfmt15(0.98164490790123f), Qfmt15(-0.54671580548181f), Qfmt15(-0.01689629065389f), Qfmt15(-0.86110349531986f), + Qfmt15(-0.98892980586032f), Qfmt15(0.51756627678691f), Qfmt15(-0.99635026409640f), Qfmt15(-0.99969370862163f), + Qfmt15(0.55266258627194f), Qfmt15(0.34581177741673f), Qfmt15(0.62664209577999f), Qfmt15(-0.77149701404973f), + Qfmt15(-0.91592244254432f), Qfmt15(-0.76285492357887f), Qfmt15(0.79788337195331f), Qfmt15(0.54473080610200f), + Qfmt15(-0.85639281671058f), Qfmt15(-0.92882402971423f), Qfmt15(-0.11708371046774f), Qfmt15(0.21356749817493f), + Qfmt15(-0.76191692573909f), Qfmt15(0.98111043100884f), Qfmt15(-0.85913269895572f), Qfmt15(-0.93307242253692f), + Qfmt15(0.30485754879632f), Qfmt15(0.85289650925190f), Qfmt15(0.91328082618125f), Qfmt15(-0.05890199924154f), + Qfmt15(0.28398686150148f), Qfmt15(0.95258164539612f), Qfmt15(-0.78566324168507f), Qfmt15(-0.95789495447877f), + Qfmt15(0.82411158711197f), Qfmt15(-0.65185446735885f), Qfmt15(-0.93643603134666f), Qfmt15(0.91427159529618f), + Qfmt15(-0.70395684036886f), Qfmt15(0.00563771969365f), Qfmt15(0.89065051931895f), Qfmt15(-0.68683707712762f), + Qfmt15(0.72165342518718f), Qfmt15(-0.62928247730667f), Qfmt15(0.29938434065514f), Qfmt15(-0.91781958879280f), + Qfmt15(0.99298717043688f), Qfmt15(0.82368298622748f), Qfmt15(-0.98512833386833f), Qfmt15(-0.95915368242257f), + Qfmt15(-0.21411126572790f), Qfmt15(-0.68821476106884f), Qfmt15(0.91851997982317f), Qfmt15(-0.96062769559127f), + Qfmt15(0.51646184922287f), Qfmt15(0.61130721139669f), Qfmt15(0.47336129371299f), Qfmt15(0.90998308703519f), + Qfmt15(0.44844799194357f), Qfmt15(0.66614891079092f), Qfmt15(0.74922239129237f), Qfmt15(-0.99571588506485f), + Qfmt15(0.97401082477563f), Qfmt15(0.72683747733879f), Qfmt15(0.95432193457128f), Qfmt15(-0.72962208425191f), + Qfmt15(-0.85359479233537f), Qfmt15(-0.81412430338535f), Qfmt15(-0.87930772356786f), Qfmt15(-0.71573331064977f), + Qfmt15(0.83524300028228f), Qfmt15(-0.48086065601423f), Qfmt15(0.97139128574778f), Qfmt15(0.51992825347895f), + Qfmt15(-0.00848591195325f), Qfmt15(-0.70294374303036f), Qfmt15(-0.95894428168140f), Qfmt15(0.97079252950321f), + Qfmt15(-0.92404293670797f), Qfmt15(-0.69506469500450f), Qfmt15(0.26559203620024f), Qfmt15(0.28038443336943f), + Qfmt15(-0.74138124825523f), Qfmt15(-0.01752795995444f), Qfmt15(-0.55126773094930f), Qfmt15(0.97960898850996f), + Qfmt15(-0.99196309146936f), Qfmt15(-0.67684928085260f), Qfmt15(0.09140039465500f), Qfmt15(-0.71658965751996f), + Qfmt15(0.81014640078925f), Qfmt15(0.40616991671205f), Qfmt15(-0.67680188682972f), Qfmt15(0.86849774348749f), + Qfmt15(-0.99500381284851f), Qfmt15(0.84329189340667f), Qfmt15(-0.09215968531446f), Qfmt15(0.99956173327206f), + Qfmt15(-0.79732779473535f), Qfmt15(0.96349973642406f), Qfmt15(-0.79942778496547f), Qfmt15(-0.11566039853896f), + Qfmt15(-0.39922954514662f), Qfmt15(0.99089197565987f), Qfmt15(0.28631285179909f), Qfmt15(-0.83302725605608f), + Qfmt15(0.95404443402072f), Qfmt15(-0.06449863579434f), Qfmt15(-0.99575054486311f), Qfmt15(-0.65501142790847f), + Qfmt15(-0.81254441908887f), Qfmt15(-0.99646369485481f), Qfmt15(0.00287840603348f), Qfmt15(0.70176989408455f), + Qfmt15(0.96361882270190f), Qfmt15(-0.68883758192426f), Qfmt15(-0.34875585502238f), Qfmt15(0.91980081243087f), + Qfmt15(-0.99009048343881f), Qfmt15(0.68865791458395f), Qfmt15(-0.99484402129368f), Qfmt15(0.94214511408023f), + Qfmt15(-0.67414626793544f), Qfmt15(-0.47339353684664f), Qfmt15(0.14323651387360f), Qfmt15(-0.29268293575672f), + Qfmt15(0.43793861458754f), Qfmt15(-0.36345126374441f), Qfmt15(-0.08750604656825f), Qfmt15(-0.96495267812511f), + Qfmt15(0.55526940659947f), Qfmt15(0.73538215752630f), Qfmt15(-0.30889773919437f), Qfmt15(0.03574995626194f), + Qfmt15(0.98720684660488f), Qfmt15(-0.81689296271203f), Qfmt15(0.67866860118215f), Qfmt15(-0.15808569732583f), + Qfmt15(0.80723395114371f), Qfmt15(0.47788757329038f), Qfmt15(0.96367554763201f), Qfmt15(-0.99143875716818f), + Qfmt15(0.83081876925833f), Qfmt15(-0.58753191905341f), Qfmt15(0.95538108220960f), Qfmt15(-0.96490920476211f), + Qfmt15(-0.97327101028521f), Qfmt15(0.91400366022124f), Qfmt15(-0.99925837363824f), Qfmt15(-0.86875903507313f), + Qfmt15(-0.26240034795124f), Qfmt15(-0.24664412953388f), Qfmt15(0.02416275806869f), Qfmt15(0.82068619590515f), + Qfmt15(0.88547373760759f), Qfmt15(-0.18173078152226f), Qfmt15(0.09355476558534f), Qfmt15(-0.54668414224090f), + Qfmt15(0.37050990604091f), Qfmt15(-0.70373594262891f), Qfmt15(-0.34600785879594f), Qfmt15(-0.68774481731008f), + Qfmt15(-0.26843291251234f), Qfmt15(0.49072334613242f), Qfmt15(0.38975993093975f), Qfmt15(-0.97757125224150f), + Qfmt15(-0.17325552859616f), Qfmt15(0.99948035025744f), Qfmt15(-0.64946246527458f), Qfmt15(-0.12016920576437f), + Qfmt15(-0.58947456517751f), Qfmt15(-0.41815140454465f), Qfmt15(0.99885650204884f), Qfmt15(-0.56649614128386f), + Qfmt15(0.94138021032330f), Qfmt15(-0.75725076534641f), Qfmt15(0.20541973692630f), Qfmt15(0.99980371023351f), + Qfmt15(0.29078277605775f), Qfmt15(-0.62858772103030f), Qfmt15(0.43440904467688f), Qfmt15(-0.98298583762390f), + Qfmt15(0.19513029146934f), Qfmt15(-0.95476662400101f), Qfmt15(0.93379635304810f), Qfmt15(-0.85235410573336f), + Qfmt15(-0.86425093011245f), Qfmt15(0.38879779059045f), Qfmt15(0.92045124735495f), Qfmt15(0.89162532251878f), + Qfmt15(-0.36834336949252f), Qfmt15(0.93891760988045f), Qfmt15(0.99267657565094f), Qfmt15(-0.94063471614176f), + Qfmt15(0.99740224117019f), Qfmt15(-0.35899413170555f), Qfmt15(0.05237237274947f), Qfmt15(0.36703583957424f), + Qfmt15(0.91653180367913f), Qfmt15(0.69000803499316f), Qfmt15(-0.38658751133527f), Qfmt15(-0.29250814029851f), + Qfmt15(-0.60182204677608f), Qfmt15(-0.97418588163217f), Qfmt15(0.88461574003963f), Qfmt15(0.05198933055162f), + Qfmt15(-0.53499621979720f), Qfmt15(-0.49429560226497f), Qfmt15(-0.98935142339139f), Qfmt15(-0.98081380091130f), + Qfmt15(-0.27338148835532f), Qfmt15(0.06310802338302f), Qfmt15(-0.20461677199539f), Qfmt15(0.66223843141647f), + Qfmt15(-0.84764345483665f), Qfmt15(-0.89039863483811f), Qfmt15(0.95903308477986f), Qfmt15(0.73504123909879f), + Qfmt15(-0.31744434966056f), Qfmt15(-0.34110827591623f), Qfmt15(0.47803883714199f), Qfmt15(0.98299195879514f), + Qfmt15(-0.30963073129751f), Qfmt15(0.99992588229018f), Qfmt15(-0.93149731080767f), Qfmt15(0.99923472302773f), + Qfmt15(-0.26024169633417f), Qfmt15(-0.35712514743563f), Qfmt15(-0.99899084509530f), Qfmt15(0.86557171579452f), + Qfmt15(0.33408042438752f), Qfmt15(0.99010736374716f), Qfmt15(-0.66694269691195f), Qfmt15(0.64016792079480f), + Qfmt15(0.99570534804836f), Qfmt15(-0.63431466947340f), Qfmt15(-0.07706847005931f), Qfmt15(0.98590090577724f), + Qfmt15(0.80099335254678f), Qfmt15(0.78368131392666f), Qfmt15(0.08707806671691f), Qfmt15(-0.86811883080712f), + Qfmt15(-0.39466529740375f), Qfmt15(0.97875325649683f), Qfmt15(-0.95038560288864f), Qfmt15(0.17005239424212f), + Qfmt15(-0.76910792026848f), Qfmt15(0.99743281016846f), Qfmt15(0.95437383549973f), Qfmt15(0.99578905365569f), + Qfmt15(0.28058259829990f), Qfmt15(0.85256524470573f), Qfmt15(-0.50608540105128f), Qfmt15(-0.97210735183243f), + Qfmt15(0.95424048234441f), Qfmt15(-0.96926570524023f), Qfmt15(0.30872163214726f), Qfmt15(-0.24523839572639f), + Qfmt15(-0.33813265086024f), Qfmt15(-0.05826828420146f), Qfmt15(-0.22898461455054f), Qfmt15(-0.18509915019881f), + Qfmt15(-0.10488238045009f), Qfmt15(-0.71886586182037f), Qfmt15(0.99793873738654f), Qfmt15(0.57563307626120f), + Qfmt15(0.28909646383717f), Qfmt15(0.42188998312520f), Qfmt15(0.93335049681047f), Qfmt15(-0.97087374418267f), + Qfmt15(0.36722871286923f), Qfmt15(-0.81093025665696f), Qfmt15(-0.26240603062237f), Qfmt15(0.83996497984604f), + Qfmt15(-0.99909615720225f), Qfmt15(0.74649464155061f), Qfmt15(-0.74774595569805f), Qfmt15(0.95781667469567f), + Qfmt15(0.95472308713099f), Qfmt15(0.48708332746299f), Qfmt15(0.46332038247497f), Qfmt15(-0.76497004940162f), + Qfmt15(0.57397389364339f), Qfmt15(0.75374316974495f), Qfmt15(-0.59174397685714f), Qfmt15(0.75087906691890f), + Qfmt15(-0.98607857336230f), Qfmt15(-0.40761056640505f), Qfmt15(0.66929266740477f), Qfmt15(-0.97463695257310f), + Qfmt15(0.90145509409859f), Qfmt15(-0.87259289048043f), Qfmt15(-0.91529461447692f), Qfmt15(-0.03305738840705f), + Qfmt15(0.07223051368337f), Qfmt15(0.99498012188353f), Qfmt15(-0.74904939500519f), Qfmt15(0.04585228574211f), + Qfmt15(-0.89054954257993f), Qfmt15(-0.83782144651251f), Qfmt15(0.33454804933804f), Qfmt15(-0.99707579362824f), + Qfmt15(-0.22827527843994f), Qfmt15(0.67248046289143f), Qfmt15(-0.05146538187944f), Qfmt15(0.99947295749905f), + Qfmt15(0.66951124390363f), Qfmt15(-0.99602956559179f), Qfmt15(0.82104905483590f), Qfmt15(0.99186510988782f), + Qfmt15(-0.65284592392918f), Qfmt15(0.93885443798188f), Qfmt15(0.96735248738388f), Qfmt15(-0.22225968841114f), + Qfmt15(-0.44132783753414f), Qfmt15(-0.85694974219574f), Qfmt15(0.91783042091762f), Qfmt15(0.72556974415690f), + Qfmt15(-0.99711581834508f), Qfmt15(0.77638976371966f), Qfmt15(0.07717324253925f), Qfmt15(-0.56049829194163f), + Qfmt15(0.98398893639988f), Qfmt15(0.47546946844938f), Qfmt15(0.65675089314631f), Qfmt15(0.03273375457980f), + Qfmt15(-0.38684144784738f), Qfmt15(-0.97346267944545f), Qfmt15(-0.53282156061942f), Qfmt15(0.99817310731176f), + Qfmt15(-0.50254500772635f), Qfmt15(0.01995873238855f), Qfmt15(0.99930381973804f), Qfmt15(0.82907767600783f), + Qfmt15(-0.58660709669728f), Qfmt15(-0.17573736667267f), Qfmt15(0.83434292401346f), Qfmt15(0.05946491307025f), + Qfmt15(0.81505484574602f), Qfmt15(-0.44976380954860f), Qfmt15(-0.89746474625671f), Qfmt15(0.39677256130792f), + Qfmt15(-0.07588948563079f), Qfmt15(0.76343198951445f), Qfmt15(-0.74490104699626f), Qfmt15(0.64880119792759f), + Qfmt15(0.62319537462542f), Qfmt15(0.42215817594807f), Qfmt15(0.02704554141885f), Qfmt15(0.80001773566818f), + Qfmt15(-0.79351832348816f), Qfmt15(0.63872359151636f), Qfmt15(0.52890520960295f), Qfmt15(0.74238552914587f), + Qfmt15(0.99096131449250f), Qfmt15(-0.80412329643109f), Qfmt15(-0.64612616129736f), Qfmt15(0.11657770663191f), + Qfmt15(-0.95053182488101f), Qfmt15(-0.62228872928622f), Qfmt15(0.03004475787316f), Qfmt15(-0.97987214341034f), + Qfmt15(-0.99986980746200f), Qfmt15(0.89110648599879f), Qfmt15(0.10407960510582f), Qfmt15(0.95964737821728f), + Qfmt15(0.50843233159162f), Qfmt15(0.17006334670615f), Qfmt15(0.25872675063360f), Qfmt15(-0.01115998681937f), + Qfmt15(-0.79598702973261f), Qfmt15(-0.99264708948101f), Qfmt15(-0.99829663752818f), Qfmt15(-0.70801016548184f), + Qfmt15(-0.70467057786826f), Qfmt15(0.99846021905254f), Qfmt15(-0.63364968534650f), Qfmt15(-0.16258217500792f), + Qfmt15(-0.43645594360633f), Qfmt15(-0.99848471702976f), Qfmt15(-0.16796458968998f), Qfmt15(-0.87979225745213f), + Qfmt15(0.44183099021786f), Qfmt15(0.93310180125532f), Qfmt15(-0.93941931782002f), Qfmt15(-0.88590003188677f), + Qfmt15(0.99971463703691f), Qfmt15(-0.75376385639978f), Qfmt15(0.93887685615875f), Qfmt15(0.85126435782309f), + Qfmt15(0.39701421446381f), Qfmt15(-0.37024464187437f), Qfmt15(-0.36024828242896f), Qfmt15(-0.93388812549209f), + Qfmt15(-0.65298804552119f), Qfmt15(0.11960319006843f), Qfmt15(0.94292565553160f), Qfmt15(0.75081145286948f), + Qfmt15(0.56721979748394f), Qfmt15(0.46857766746029f), Qfmt15(0.97312313923635f), Qfmt15(-0.38299976567017f), + Qfmt15(0.41025800019463f), Qfmt15(0.09638062008048f), Qfmt15(-0.85283249275397f), Qfmt15(0.88866808958124f), + Qfmt15(-0.48202429536989f), Qfmt15(0.27572582416567f), Qfmt15(-0.65889129659168f), Qfmt15(0.98838086953732f), + Qfmt15(-0.20651349620689f), Qfmt15(-0.62126416356920f), Qfmt15(0.20320105410437f), Qfmt15(-0.97790548600584f), + Qfmt15(0.11112534735126f), Qfmt15(-0.41368337314182f), Qfmt15(0.24133038992960f), Qfmt15(-0.66393410674885f), + Qfmt15(-0.53697829178752f), Qfmt15(-0.97224737889348f), Qfmt15(0.87392477144549f), Qfmt15(0.19050361015753f), + Qfmt15(-0.46353441212724f), Qfmt15(-0.07064096339021f), Qfmt15(-0.92444085484466f), Qfmt15(-0.83822593578728f), + Qfmt15(0.75214681811150f), Qfmt15(-0.42102998829339f), Qfmt15(-0.72094786237696f), Qfmt15(0.78843311019251f), + Qfmt15(0.97394027897442f), Qfmt15(0.99206463477946f), Qfmt15(0.76789609461795f), Qfmt15(-0.82002421836409f), + Qfmt15(0.81924990025724f), Qfmt15(-0.26719850873357f), Qfmt15(-0.43311260380975f), Qfmt15(0.99194979673836f), + Qfmt15(-0.80692001248487f), Qfmt15(0.43080003649976f), Qfmt15(0.67709491937357f), Qfmt15(0.56151770568316f), + Qfmt15(0.10831862810749f), Qfmt15(0.91229417540436f), Qfmt15(-0.48972893932274f), Qfmt15(-0.89033658689697f), + Qfmt15(0.65269447475094f), Qfmt15(0.67439478141121f), Qfmt15(-0.47770832416973f), Qfmt15(-0.99715979260878f), + Qfmt15(-0.90889593602546f), Qfmt15(-0.06618622548177f), Qfmt15(0.99430266919728f), Qfmt15(0.97686402381843f), + Qfmt15(0.94813650221268f), Qfmt15(-0.95434497492853f), Qfmt15(-0.49104783137150f), Qfmt15(0.99881175120751f), + Qfmt15(0.50449166760303f), Qfmt15(0.47162891065108f), Qfmt15(-0.62081581361840f), Qfmt15(-0.43867015250812f), + Qfmt15(0.98630563232075f), Qfmt15(-0.61510362277374f), Qfmt15(-0.03841517601843f), Qfmt15(-0.30102157304644f), + Qfmt15(0.41881284182683f), Qfmt15(-0.86135454941237f), Qfmt15(0.67226861393788f), Qfmt15(-0.70737398842068f), + Qfmt15(0.94044946687963f), Qfmt15(-0.82386352534327f), Qfmt15(-0.32070666698656f), Qfmt15(0.57593163224487f), + Qfmt15(-0.36326018419965f), Qfmt15(0.99979044674350f), Qfmt15(-0.92366023326932f), Qfmt15(-0.44607178518598f), + Qfmt15(0.44226800932956f), Qfmt15(0.03671907158312f), Qfmt15(0.52175424682195f), Qfmt15(-0.94701139690956f), + Qfmt15(-0.98759606946049f), Qfmt15(0.87434794743625f), Qfmt15(-0.93412041758744f), Qfmt15(0.96063943315511f), + Qfmt15(0.97534253457837f), Qfmt15(0.99642466504163f), Qfmt15(-0.94705089665984f), Qfmt15(0.91599807087376f) +}; + + +#ifdef HQ_SBR + +const Int32 rPxx[512] = +{ + + 0x8010B3DB, 0x7C4DA98F, 0x12168648, 0xC3D4D033, + 0x674D25F5, 0xCE1972A6, 0xFEA5AA4A, 0x8B2DF13E, + 0x46326048, 0x3336815E, 0x802A8F2B, 0x85B7745C, + 0xC577B766, 0xA2A5828C, 0x60CB1AD1, 0x090C9BD7, + 0x5F5A8B4D, 0x848D86BB, 0x26F1C0B7, 0x553352C1, + 0x755E166B, 0xA5674343, 0xA654C5F5, 0x80A48CB4, + 0x7DA69CD8, 0xBA04FCB4, 0xFDD4005E, 0x91C63676, + 0x816A8F82, 0x423F55AA, 0x8077B59E, 0x80097DE9, + 0x46BD4C18, 0x2C437971, 0x5035A0C2, 0x9D3ED49F, + 0x8AC204B8, 0x9E5A8B0A, 0x662088B9, 0x45B9F0BC, + 0x9261364F, 0x891B23AD, 0xF1028040, 0x1B568BE1, + 0x9E787FB3, 0x7D94854D, 0x92077A94, 0x88903F45, + 0x2705A5B4, 0x6D2B3BDC, 0x74E58034, 0xF8745A8C, + 0x24592C54, 0x79EDB9BB, 0x9B6E9F44, 0x8563E5DA, + 0x697C7BB7, 0xAC8F8E6A, 0x88227FD5, 0x7506822F, + 0xA5E34B42, 0x00B94F10, 0x72004390, 0xA814676E, + 0x5C5EA758, 0xAF721171, 0x2652C50C, 0x8A84A142, + 0x7F19343E, 0x696EA13B, 0x81E68008, 0x853980F9, + 0xE4968869, 0xA7E7DD92, 0x75910BFA, 0x85092E35, + 0x421BA4A3, 0x4E3F3C18, 0x3C97DD02, 0x74797BCB, + 0x39667EFD, 0x55447BA2, 0x5FE68CF3, 0x808B4390, + 0x7CABEA6B, 0x5D08C27A, 0x7A265820, 0xA29A9DF0, + 0x92BC7195, 0x97CA8338, 0x8F725FAD, 0xA46281D3, + 0x6AE86B23, 0xC2728178, 0x7C566684, 0x428C66B7, + 0xFEE89DDB, 0xA60546DC, 0x8540C89D, 0x7C420BF0, + 0x89B86D72, 0xA7077E3F, 0x21FF5DD7, 0x23E3129C, + 0xA1197F1D, 0xFDC0963F, 0xB96F8168, 0x7D6387A6, + 0x810655C8, 0xA95C102B, 0x0BB3E5B4, 0xA44682D4, + 0x67B244C3, 0x33FDDE1D, 0xA95D78F5, 0x6F2AE887, + 0x80A3FC9F, 0x6BF00D52, 0xF4325902, 0x7FF1F02C, + 0x99F08AC5, 0x7B537BB2, 0x99AB5255, 0xF1302497, + 0xCCE4787B, 0x7ED58A28, 0x24A68B79, 0x955EA9D0, + 0x7A1D3EED, 0xF7BD0429, 0x808A3642, 0xAC2769A8, + 0x97FDBDE9, 0x80736C25, 0x005E52E7, 0x59D3E5D0, + 0x7B57341A, 0xA7D374E9, 0xD35A5B7B, 0x75BB5520, + 0x81446DE8, 0x5825473E, 0x80A8E653, 0x78978062, + 0xA9B43F6B, 0xC366920A, 0x1255877D, 0xDA88075F, + 0x380E9AFF, 0xD1795309, 0xF4CB7D09, 0x847BBAED, + 0x471364FA, 0x5E207B74, 0xD87498BF, 0x0493836B, + 0x7E5C3DF6, 0x976F8BBC, 0x56DE680A, 0xEBC26D28, + 0x6753E05B, 0x3D2BC4B0, 0x7B593143, 0x8118E010, + 0x6A5786AD, 0xB4CA01A7, 0x7A49927C, 0x847DAE0C, + 0x836B0FD8, 0x74FD4A34, 0x80175AFC, 0x90CBE605, + 0xDE68A89E, 0xE06C8FD0, 0x031822CE, 0x690B9315, + 0x71568D43, 0xE8BBDE85, 0x0BFA4633, 0xBA057ADA, + 0x2F6CB34F, 0xA5EB74C5, 0xD3B480B6, 0xA7F7D94A, + 0xDDA26A63, 0x3ED0C5EF, 0x31E37A42, 0x82DE06CB, + 0xE9D18940, 0x7FEE4A9A, 0xACDD57DD, 0xF09CB6D9, + 0xB48BD364, 0xCA7814D5, 0x7FDA0E41, 0xB77C8C2A, + 0x787E2D29, 0x9F1144AC, 0x1A4B871E, 0x7FF96630, + 0x25382D4D, 0xAF89319E, 0x379A81DB, 0x822D1AE8, + 0x18FA875E, 0x85C97DE7, 0x7786A544, 0x92E5F550, + 0x915FC560, 0x31C47C82, 0x75D0B014, 0x72204656, + 0xD0D87B76, 0x782E8CD6, 0x7F0FFB2F, 0x879834E7, + 0x7FAAEA73, 0xD20BC44E, 0x06B4DF2C, 0x2EFBCE84, + 0x7550D8D7, 0x5851746A, 0xCE837F5C, 0xDA8D2FEE, + 0xB2F66F13, 0x834D7B7A, 0x713A499C, 0x06A81B39, + 0xBB847C77, 0xC0B97DAC, 0x815CCC7A, 0x8274A2BD, + 0xDD007FEF, 0x0814BA2F, 0xE5CDEDCE, 0x54C45CD5, + 0x937F0309, 0x8E0671BF, 0x7AC1623B, 0x5E15FB32, + 0xD75CD0D9, 0xD4553378, 0x3D30CD88, 0x7DD2028C, + 0xD85CE8DB, 0x7FFDDE5A, 0x88C48228, 0x7FE6996A, + 0xDEAF9EB7, 0xD24818B4, 0x80205F8B, 0x6ECA4728, + 0x2AC36E51, 0x7EBB05E4, 0xAAA08AB1, 0x51F01408, + 0x7F723AAE, 0xAECD1AFB, 0xF6218D55, 0x7E3170F2, + 0x6686D0D3, 0x644F3A3F, 0x0B256799, 0x90E0325D, + 0xCD7AAA7B, 0x7D47A33C, 0x865972A3, 0x15C445FE, + 0x9D8D84D3, 0x7FAB36A7, 0x7A287C29, 0x7F75BABD, + 0x23EA92BC, 0x6D20AD59, 0xBF37ABB6, 0x8391E26E, + 0x7A2480F8, 0x83EE5E6E, 0x27843523, 0xE09A50E7, + 0xD4B6CE82, 0xF889F71C, 0xE2AF7C3A, 0xE84D3CE2, + 0xF2918FA6, 0xA3FB63E0, 0x7FBB7340, 0x49AE8B79, + 0x25017B45, 0x36003DA1, 0x7777C844, 0x83B96EE4, + 0x2F015392, 0x98320B3C, 0xDE68893F, 0x6B834779, + 0x801D8516, 0x5F8C0F8C, 0xA049DD90, 0x7A999AD0, + 0x7A33F500, 0x3E587FFF, 0x3B4E0E09, 0x9E147230, + 0x49772D2B, 0x607A7BC7, 0xB4408D8F, 0x601CDA17, + 0x81C7200B, 0xCBD28CBD, 0x55AB7E3E, 0x833EFFC0, + 0x73627FB7, 0x904E7F04, 0x8AD7EBE6, 0xFBC3D05F, + 0x093F8E53, 0x7F5B7C47, 0xA01E7FFA, 0x05DE7FC2, + 0x8E01D74D, 0x94C17CF9, 0x2AD2919F, 0x805F7757, + 0xE2C61829, 0x5613FB53, 0xF9688978, 0x7FEE77D6, + 0x55B27E98, 0x8081C6D6, 0x69177F69, 0x7EF45C30, + 0xAC6E42CC, 0x782BA021, 0x7BD17457, 0xE38B491E, + 0xC781895B, 0x924E71B8, 0x757BC4A8, 0x5CDF8020, + 0x805E4A82, 0x636078BA, 0x09E14B0E, 0xB84069A0, + 0x7DF23284, 0x3CDC57D2, 0x54101777, 0x0431A015, + 0xCE7A41B6, 0x8365846A, 0xBBCB8AF9, 0x7FC34E40, + 0xBFAB8E4B, 0x028E6D15, 0x7FE8790F, 0x6A1EF7E6, + 0xB4E97BF4, 0xE980C257, 0x6ACBEF53, 0x079C1A41, + 0x685386CC, 0xC66D3458, 0x8D1F7FCD, 0x32C9A02E, + 0xF6475ED7, 0x61B7356F, 0xA0A6793F, 0x530B34E9, + 0x4FC488D4, 0x3609F61F, 0x0376F90F, 0x6666752C, + 0x9A6DD1A5, 0x51C10A67, 0x43B34CDC, 0x5F0605C0, + 0x7ED7E718, 0x99118EB3, 0xAD4A5C69, 0x0EEC94E8, + 0x865483EA, 0xB05769F0, 0x03D88055, 0x82932EC1, + 0x8003D1E3, 0x720F82B1, 0x0D526304, 0x7AD5D2A3, + 0x41147B04, 0x15C49D9F, 0x211E7FDC, 0xFE907E12, + 0x9A1C7C55, 0x80F08095, 0x80370267, 0xA55F2B1C, + 0xA5CC7763, 0x7FCD81A1, 0xAEE3EAE8, 0xEB2F8532, + 0xC82186A5, 0x80317B31, 0xEA7E814B, 0x8F62A430, + 0x388D883A, 0x776F801B, 0x87C0B7CA, 0x8E9A3CF5, + 0x7FF6949E, 0x9F83010B, 0x782CF18C, 0x6CF54301, + 0x32D168AD, 0xD09A908B, 0xD1E22C5C, 0x887593DE, + 0xAC6AE864, 0x0F4F7FDE, 0x78B16A72, 0x601AD283, + 0x489AE12D, 0x3BFAD96A, 0x7C8E8093, 0xCEF87E19, + 0x348302B6, 0x0C5605A6, 0x92D57516, 0x71BF8056, + 0xC24C8416, 0x234B4B0D, 0xABA84B4F, 0x7E827FFD, + 0xE58F45E1, 0xB079B355, 0x1A0290CA, 0x82D37B40, + 0x0E391B80, 0xCB0B241E, 0x1EE441A8, 0xAB03F56F, + 0xBB438301, 0x838C1C43, 0x6FDCEF9D, 0x1862020D, + 0xC4A98614, 0xF6F38710, 0x89ABF29B, 0x94B4FDD3, + 0x6046800E, 0xCA1A7FA4, 0xA3B7D32F, 0x64EB43A6, + 0x7CA9DDD3, 0x7EFBB705, 0x624A9E0D, 0x9708A1E0, + 0x68DC7F9C, 0xDDCB5832, 0xC88E6D35, 0x7EF77599, + 0x98B6D63B, 0x3724E3F0, 0x56AA85C9, 0x47DFA582, + 0x0DDDF4F3, 0x74C5AB88, 0xC14F480C, 0x8E08A446, + 0x538B545F, 0x56529770, 0xC2D9EA81, 0x805C883B, + 0x8BA84F67, 0xF785E183, 0x7F441814, 0x7D09DB4D, + 0x795C8330, 0x85D79A19, 0xC1242A1B, 0x7FD871E9, + 0x409391EC, 0x3C5EE815, 0xB0885FFF, 0xC7D87FFE, + 0x7E3EBB6A, 0xB1438D6B, 0xFB13A68A, 0xD976F62D, + 0x359B02CD, 0x91BE7EA6, 0x560CEEB8, 0xA5739E04, + 0x78600B8E, 0x968A0B6C, 0xD6F1402E, 0x49B88152, + 0xD17F0986, 0x7FF8EDE8, 0x89C48295, 0xC6E6BA93, + 0x389C5B4C, 0x04B3516A, 0x42C892B0, 0x86C7FDA8, + 0x81956954, 0x6FEA726E, 0x886E34F5, 0x7AF57730, + 0x7CD76E45, 0x7F8A59D7, 0x86C6DA22, 0x753F825E +}; + + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.h new file mode 100644 index 0000000..a2ae260 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_envelope_calc_tbl.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_ENVELOPE_CALC_TBL_H +#define SBR_ENVELOPE_CALC_TBL_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +extern const Int32 limGains[5]; + +extern const Int32 smoothLengths[2]; + +extern const Int16 rP_LCx[512]; + +#ifdef HQ_SBR + +extern const Int32 rPxx[512]; + +#endif + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.cpp new file mode 100644 index 0000000..f834cfb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.cpp @@ -0,0 +1,420 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_envelope_unmapping.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_envelope_unmapping.h" +#include "sbr_constants.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +#define R_SHIFT 30 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +/* + * 1./(1+2.^-[0:10]) + */ +const Int32 one_over_one_plus_two_to_n[11] = +{ + Qfmt(0.50000000000000F), Qfmt(0.66666666666667F), Qfmt(0.80000000000000F), + Qfmt(0.88888888888889F), Qfmt(0.94117647058824F), Qfmt(0.96969696969697F), + Qfmt(0.98461538461538F), Qfmt(0.99224806201550F), Qfmt(0.99610894941634F), + Qfmt(0.99805068226121F), Qfmt(0.99902439024390F) +}; + +/* + * 1./(1+2.^[0.5:-1:-10.5]) + */ +const Int32 one_over_one_plus_sq_2_by_two_to_n[12] = +{ + Qfmt(0.41421356237310F), Qfmt(0.58578643762690F), Qfmt(0.73879612503626F), + Qfmt(0.84977889517767F), Qfmt(0.91878969685839F), Qfmt(0.95767628767521F), + Qfmt(0.97838063800882F), Qfmt(0.98907219289563F), Qfmt(0.99450607818892F), + Qfmt(0.99724547251514F), Qfmt(0.99862083678608F), Qfmt(0.99930994254211F) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_envelope_unmapping(SBR_FRAME_DATA * hFrameData1, + SBR_FRAME_DATA * hFrameData2) + +{ + Int32 i; + Int32 tempLeft; + Int32 tempRight; + + Int32 tmp; + Int32 *iEnvelopeLeft_man = hFrameData1->iEnvelope_man; + Int32 *iEnvelopeLeft_exp = hFrameData1->iEnvelope_exp; + Int32 *noiseFloorLeft_man = hFrameData1->sbrNoiseFloorLevel_man; + Int32 *noiseFloorLeft_exp = hFrameData1->sbrNoiseFloorLevel_exp; + + Int32 *iEnvelopeRight_man = hFrameData2->iEnvelope_man; + Int32 *iEnvelopeRight_exp = hFrameData2->iEnvelope_exp; + Int32 *noiseFloorRight_man = hFrameData2->sbrNoiseFloorLevel_man; + Int32 *noiseFloorRight_exp = hFrameData2->sbrNoiseFloorLevel_exp; + + + if (hFrameData2->ampRes) + { + for (i = 0; i < hFrameData1->nScaleFactors; i++) + { + tempRight = iEnvelopeRight_man[i]; + tempLeft = iEnvelopeLeft_man[i]; + /* iEnvelope[i] always positive 6 bits max */ + + iEnvelopeLeft_exp[i] = tempLeft + 7; + + iEnvelopeRight_exp[i] = tempRight - 12; + iEnvelopeRight_man[i] = Qfmt(1.000F); + + /* + * iEnvelopeRight[i] = tempLeft / (1 + tempRight); + * iEnvelopeLeft[i] = tempRight * iEnvelopeRight[i]; + * + * + * iEnvelopeRight[i] = k*2^n/(1+2^m) = k*2^(n-m)/(1 + 2^-m); + * where k = 1 or sqrt(2) + */ + if (iEnvelopeRight_exp[i] >= 0) + { + if (iEnvelopeRight_exp[i] < 11) + { + iEnvelopeRight_man[i] = one_over_one_plus_two_to_n[ iEnvelopeRight_exp[i]]; + } + else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 10 */ + { + iEnvelopeRight_man[i] -= (Qfmt(1.000F) >> iEnvelopeRight_exp[i]); + } + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i]; + } + else + { + if (iEnvelopeRight_exp[i] > -11) + { + iEnvelopeRight_man[i] -= one_over_one_plus_two_to_n[ -iEnvelopeRight_exp[i]]; + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i]; + + } + else /* 1/(1+2^m) == 2^-m ; for m >= 10 */ + { + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i]; + iEnvelopeLeft_exp[i] = 0; + } + } + + iEnvelopeLeft_man[i] = iEnvelopeRight_man[i]; + } + } + else + { + for (i = 0; i < hFrameData1->nScaleFactors; i++) + { + /* iEnvelope[i] always positive 7 bits max */ + tempRight = iEnvelopeRight_man[i]; + tempLeft = iEnvelopeLeft_man[i]; + + iEnvelopeLeft_exp[i] = (tempLeft >> 1) + 7; + if (tempLeft & 0x1) /* odd */ + { + iEnvelopeLeft_man[i] = Qfmt(1.41421356237310F); + } + else + { + iEnvelopeLeft_man[i] = Qfmt(1.000F); + } + + iEnvelopeRight_exp[i] = (tempRight >> 1) - 12; + if (tempRight & 0x1) /* odd */ + { + if (iEnvelopeRight_exp[i] > 0) + { + iEnvelopeRight_man[i] = Qfmt(1.41421356237310F); + } + else + { + iEnvelopeRight_man[i] = Qfmt(0.7071067811865F); + } + } + else + { + iEnvelopeRight_man[i] = Qfmt(1.000F); + } + + if (iEnvelopeRight_man[i] == Qfmt(1.000F)) + { + + /* + * iEnvelopeRight[i] = tempLeft / (1 + tempRight); + * iEnvelopeLeft[i] = tempRight * iEnvelopeRight[i]; + * + * + * iEnvelopeRight[i] = k*2^n/(1+2^m) = k*2^(n-m)/(1 + 2^-m); + * where k = 1 or sqrt(2) + */ + if (iEnvelopeRight_exp[i] >= 0) + { + if (iEnvelopeRight_exp[i] < 11) + { + iEnvelopeRight_man[i] = one_over_one_plus_two_to_n[ iEnvelopeRight_exp[i]]; + } + else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 10 */ + { + iEnvelopeRight_man[i] -= (Qfmt(1.000F) >> iEnvelopeRight_exp[i]); + } + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i]; + + } + else + { + if (iEnvelopeRight_exp[i] > -11) + { + iEnvelopeRight_man[i] -= one_over_one_plus_two_to_n[ -iEnvelopeRight_exp[i]]; + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i]; + } + else /* 1/(1+2^m) == 2^-m ; for m >= 10 */ + { + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i]; + iEnvelopeLeft_exp[i] = 0; + } + } + + /* + * apply "k" factor 1 or sqrt(2) + * + * (2^m)*2*k*2^n/(1+2^m) = k*2^(n+1)/(1 + 2^-m); + * + */ + if (iEnvelopeLeft_man[i] != Qfmt(1.000F)) + { + iEnvelopeRight_man[i] = fxp_mul32_Q30(iEnvelopeLeft_man[i], iEnvelopeRight_man[i]); + } + + iEnvelopeLeft_man[i] = iEnvelopeRight_man[i]; + + } + else + { + + /* + * iEnvelopeRight[i] = tempLeft / (1 + tempRight); + * iEnvelopeLeft[i] = tempRight * iEnvelopeRight[i]; + * + * + * iEnvelopeRight[i] = k*2^n/(1+q2^m) = k*2^(n-m)/(1 + q2^-m); + * where k = 1 or sqrt(2) + * and q = sqrt(2) + */ + if (iEnvelopeRight_exp[i] >= 0) + { + if (iEnvelopeRight_exp[i] < 12) + { + iEnvelopeRight_man[i] = one_over_one_plus_sq_2_by_two_to_n[ iEnvelopeRight_exp[i]]; + } + else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 11 */ + { + iEnvelopeRight_man[i] = Qfmt(1.000F) - (Qfmt(1.000F) >> iEnvelopeRight_exp[i]); + } + } + else + { + if (iEnvelopeRight_exp[i] > -12) + { + iEnvelopeRight_man[i] = Qfmt(1.000F) - one_over_one_plus_sq_2_by_two_to_n[ -iEnvelopeRight_exp[i]]; + } + else /* 1/(1+2^m) == 2^-m ; for m >= 11 */ + { + iEnvelopeRight_man[i] = Qfmt(1.000F); + iEnvelopeRight_exp[i] = 0; + } + } + + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i]; + + /* + * apply "k" factor 1 or sqrt(2) + * + * Right == k*2^(n-m)/(1 + q2^-m) + * Left == (q2^m)*k*2^n/(1 + q2^m) = qk*2^n/(1 + q2^-m); + */ + if (iEnvelopeLeft_man[i] != Qfmt(1.000F)) + { + /* + * k/(1 + q2^-m); + */ + tmp = iEnvelopeRight_man[i]; + iEnvelopeRight_man[i] = fxp_mul32_Q30(iEnvelopeLeft_man[i], iEnvelopeRight_man[i]); + iEnvelopeLeft_man[i] = tmp; + iEnvelopeLeft_exp[i] += 1; /* extra one due to sqrt(2)^2 */ + } + else + { + iEnvelopeLeft_man[i] = fxp_mul32_Q30(iEnvelopeRight_man[i], Qfmt(1.41421356237310F)); + } + + } /* end of if (iEnvelopeRight_man[i] == Qfmt( 1.000F) ) */ + } /* end of for loop */ + } /* end if (hFrameData2->ampRes) */ + + + for (i = 0; i < hFrameData1->nNoiseFactors; i++) + { + + noiseFloorLeft_exp[i] = NOISE_FLOOR_OFFSET_PLUS_1 - noiseFloorLeft_man[i]; + noiseFloorRight_exp[i] = noiseFloorRight_man[i] - SBR_ENERGY_PAN_OFFSET_INT; + + + /* + * noiseFloorRight[i] = tempLeft / (1.0f + tempRight); + * noiseFloorLeft[i] = tempRight*noiseFloorRight[i]; + * + * + * noiseFloorRight[i] = 2^n/(1+2^m) = 2^(n-m)/(1 + 2^-m); + */ + if (noiseFloorRight_exp[i] >= 0) + { + if (noiseFloorRight_exp[i] < 11) + { + noiseFloorRight_man[i] = one_over_one_plus_two_to_n[ noiseFloorRight_exp[i]]; + } + else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 10 */ + { + noiseFloorRight_man[i] = Qfmt(1.000F) - (Qfmt(1.000F) >> noiseFloorRight_exp[i]); + } + } + else + { + if (noiseFloorRight_exp[i] > -11) + { + noiseFloorRight_man[i] = Qfmt(1.000F) - one_over_one_plus_two_to_n[ -noiseFloorRight_exp[i]]; + } + else /* 1/(1+2^m) == 2^-m ; for m >= 10 */ + { + noiseFloorRight_man[i] = Qfmt(1.000F); + noiseFloorRight_exp[i] = 0; + } + } + + noiseFloorRight_exp[i] = noiseFloorLeft_exp[i] - noiseFloorRight_exp[i]; + + /* + * (2^m)*2^n/(1+2^m) = 2^n/(1 + 2^-m); + */ + + noiseFloorLeft_man[i] = noiseFloorRight_man[i]; + noiseFloorLeft_exp[i] = noiseFloorLeft_exp[i]; + + } +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.h new file mode 100644 index 0000000..4ae8e2e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_envelope_unmapping.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_ENVELOPE_UNMAPPING_H +#define SBR_ENVELOPE_UNMAPPING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +#define UNMAPPING_SCALE_INT (-18) /* factor's 2-exponent */ +#define SBR_ENERGY_PAN_OFFSET_INT 12 + + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_envelope_unmapping(SBR_FRAME_DATA * hFrameData1, + SBR_FRAME_DATA * hFrameData2); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.cpp new file mode 100644 index 0000000..552e445 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.cpp @@ -0,0 +1,218 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_extract_extended_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + SBR_FRAME_DATA *hFrameData, Destination for extracted data of left channel + SBR_FRAME_DATA *hFrameDataRight Destination for extracted data of right channel + BIT_BUFFER hBitBuf pointer to bit buffer + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads extension data from the bitstream + + The bitstream format allows up to 4 kinds of extended data element. + Extended data may contain several elements, each identified by a 2-bit-ID. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_extract_extended_data.h" +#include "buf_getbits.h" + +#ifdef PARAMETRICSTEREO +#include "ps_read_data.h" +#endif + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_extract_extended_data(BIT_BUFFER * hBitBuf +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO /* Parametric Stereo Decoder */ + , HANDLE_PS_DEC hParametricStereoDec +#endif +#endif + ) +{ + Int32 extended_data; + Int32 i; + Int32 nBitsLeft; + Int32 extension_id; + + extended_data = buf_get_1bit(hBitBuf); /* SI_SBR_EXTENDED_DATA_BITS */ + + if (extended_data) + { + Int32 cnt; + + cnt = buf_getbits(hBitBuf, SI_SBR_EXTENSION_SIZE_BITS); + if (cnt == (1 << SI_SBR_EXTENSION_SIZE_BITS) - 1) + { + cnt += buf_getbits(hBitBuf, SI_SBR_EXTENSION_ESC_COUNT_BITS); + } + + nBitsLeft = (cnt << 3); + while (nBitsLeft > 7) + { + extension_id = buf_getbits(hBitBuf, SI_SBR_EXTENSION_ID_BITS); + nBitsLeft -= SI_SBR_EXTENSION_ID_BITS; + + switch (extension_id) + { +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + + /* + * Parametric Coding supports the Transient, Sinusoidal, Noise, and + * Parametric Stereo tools (MPEG4). + * 3GPP use aac+ hq along with ps for enhanced aac+ + * The PS tool uses complex-value QMF data, therefore can not be used + * with low power version of aac+ + */ + case EXTENSION_ID_PS_CODING: + + if (hParametricStereoDec != NULL) + { + if (!hParametricStereoDec->psDetected) + { + /* parametric stereo detected */ + hParametricStereoDec->psDetected = 1; + } + + nBitsLeft -= ps_read_data(hParametricStereoDec, + hBitBuf, + nBitsLeft); + + } + + break; +#endif +#endif + case 0: + + default: + /* An unknown extension id causes the remaining extension data + * to be skipped + */ + cnt = nBitsLeft >> 3; /* number of remaining bytes */ + + for (i = 0; i < cnt; i++) + { + buf_getbits(hBitBuf, 8); + } + + nBitsLeft -= (cnt << 3); + } + } + /* read fill bits for byte alignment */ + buf_getbits(hBitBuf, nBitsLeft); + } +} + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.h new file mode 100644 index 0000000..cc9a7cf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_extract_extended_data.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_EXTRACT_EXTENDED_DATA_H +#define SBR_EXTRACT_EXTENDED_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" + +#ifdef PARAMETRICSTEREO +#include "s_ps_dec.h" +#endif + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_extract_extended_data(BIT_BUFFER * hBitBuf +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO /* Parametric Stereo Decoder */ + , HANDLE_PS_DEC hParametricStereoDec +#endif +#endif + ); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.cpp new file mode 100644 index 0000000..696bce9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.cpp @@ -0,0 +1,191 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_find_start_andstop_band.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_find_start_andstop_band.h" +#include "get_sbr_startfreq.h" +#include "get_sbr_stopfreq.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_find_start_andstop_band(const Int32 samplingFreq, + const Int32 startFreq, + const Int32 stopFreq, + Int *lsbM, + Int *usb) +{ + /* Update startFreq struct */ + *lsbM = get_sbr_startfreq(samplingFreq, startFreq); + + if (*lsbM == 0) + { + return(SBRDEC_ILLEGAL_SCFACTORS); + } + + /*Update stopFreq struct */ + if (stopFreq < 13) + { + *usb = get_sbr_stopfreq(samplingFreq, stopFreq); + } + else if (stopFreq == 13) + { + *usb = 64; + } + else if (stopFreq == 14) + { + *usb = (*lsbM) << 1; + } + else + { + *usb = 3 * *lsbM; + } + + /* limit to Nyqvist */ + if (*usb > 64) + { + *usb = 64; + } + + /* test for invalid lsb, usb combinations */ + if ((*usb - *lsbM) > 48) + { + /* + * invalid SBR bitstream ? + */ + return(SBRDEC_INVALID_BITSTREAM); + } + + if ((samplingFreq == 44100) && ((*usb - *lsbM) > 35)) + { + /* + * invalid SBR bitstream ? + */ + return(SBRDEC_INVALID_BITSTREAM); + } + + if ((samplingFreq >= 48000) && ((*usb - *lsbM) > 32)) + { + /* + * invalid SBR bitstream ? + */ + return(SBRDEC_INVALID_BITSTREAM); + } + + return(SBRDEC_OK); + +} + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.h new file mode 100644 index 0000000..6169fa1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: sbr_find_start_andstop_band.h + Functions: + get_dse + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_FIND_START_ANDSTOP_BAND_H +#define SBR_FIND_START_ANDSTOP_BAND_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_sbr_error.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_find_start_andstop_band(const Int32 samplingFreq, + const Int32 startFreq, + const Int32 stopFreq, + Int *lsbM, + Int *usb); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.cpp new file mode 100644 index 0000000..47e5195 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.cpp @@ -0,0 +1,1028 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_generate_high_freq.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + HF generator with built-in QMF bank inverse filtering function + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#ifdef AAC_PLUS + + + +#include "sbr_generate_high_freq.h" +#include "calc_auto_corr.h" +#include "sbr_inv_filt_levelemphasis.h" +#include "pv_div.h" +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" +#include "sbr_constants.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void high_freq_coeff_LC(Int32 sourceBufferReal[][32], + Int32 *alphar[2], + Int32 *degreeAlias, + Int32 *v_k_master, + Int32 *scratch_mem); + + + void high_freq_generation_LC(Int32 sourceBufferReal[][32], + Int32 *targetBufferReal, + Int32 *alphar[2], + Int32 *degreeAlias, + Int32 *invFiltBandTable, + Int32 targetStopBand, + Int32 patchDistance, + Int32 numBandsInPatch, + Int32 startSample, + Int32 slopeLength, + Int32 stopSample, + Int32 *BwVector, + Int32 sbrStartFreqOffset); + + +#ifdef HQ_SBR + + void high_freq_coeff(Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *alphar[2], + Int32 *alphai[2], + Int32 *v_k_master); + + void high_freq_generation(Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *targetBufferReal, + Int32 *targetBufferImag, + Int32 *alphar[2], + Int32 *alphai[2], + Int32 *invFiltBandTable, + Int32 targetStopBand, + Int32 patchDistance, + Int32 numBandsInPatch, + Int32 startSample, + Int32 slopeLength, + Int32 stopSample, + Int32 *BwVector, + Int32 sbrStartFreqOffset); + + +#endif + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_generate_high_freq(Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *targetBufferReal, + Int32 *targetBufferImag, + INVF_MODE *invFiltMode, + INVF_MODE *prevInvFiltMode, + Int32 *invFiltBandTable, + Int32 noInvFiltBands, + Int32 highBandStartSb, + Int32 *v_k_master, + Int32 numMaster, + Int32 fs, + Int32 *frameInfo, + Int32 *degreeAlias, + Int32 scratch_mem[][64], + Int32 BwVector[MAX_NUM_PATCHES], + Int32 BwVectorOld[MAX_NUM_PATCHES], + struct PATCH *Patch, + Int32 LC_flag, + Int32 *highBandStopSb) +{ + Int32 i; + Int32 patch; + Int32 startSample; + Int32 stopSample; + Int32 goalSb; + Int32 targetStopBand; + Int32 sourceStartBand; + Int32 patchDistance; + Int32 numBandsInPatch; + Int32 sbrStartFreqOffset; + + Int32 *alphar[2]; + Int32 *alphai[2]; + + Int32 lsb = v_k_master[0]; /* Lowest subband related to the synthesis filterbank */ + Int32 usb = v_k_master[numMaster]; /* Stop subband related to the synthesis filterbank */ + Int32 xoverOffset = highBandStartSb - v_k_master[0]; /* Calculate distance in subbands between k0 and kx */ + + + + Int slopeLength = 0; + + Int32 firstSlotOffs = frameInfo[1]; + Int32 lastSlotOffs = frameInfo[frameInfo[0] + 1] - 16; + + + alphar[0] = scratch_mem[0]; + alphar[1] = scratch_mem[1]; + alphai[0] = scratch_mem[2]; + alphai[1] = scratch_mem[3]; + + + startSample = (firstSlotOffs << 1); + stopSample = (lastSlotOffs << 1) + 32; + + + sbr_inv_filt_levelemphasis(invFiltMode, + prevInvFiltMode, + noInvFiltBands, + BwVector, + BwVectorOld); + + + if (LC_flag == ON) + { + /* Set subbands to zero */ + + pv_memset((void *)&targetBufferReal[startSample*SBR_NUM_BANDS], + 0, + (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferReal[0])); + + high_freq_coeff_LC(sourceBufferReal, + alphar, + degreeAlias, + v_k_master, + scratch_mem[4]); + } +#ifdef HQ_SBR + else + { + /* Set subbands to zero */ + + pv_memset((void *)&targetBufferReal[startSample*SBR_NUM_BANDS], + 0, + (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferReal[0])); + pv_memset((void *)&targetBufferImag[startSample*SBR_NUM_BANDS], + 0, + (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferImag[0])); + + high_freq_coeff(sourceBufferReal, + sourceBufferImag, + alphar, + alphai, + v_k_master); + + } +#endif /* #ifdef HQ_SBR */ + + + + + /* + * Initialize the patching parameter + */ + switch (fs) + + { + /* + * goalSb = (int)( 2.048e6f / fs + 0.5f ); + */ + case 48000: + goalSb = 43; /* 16 kHz band */ + break; + case 32000: + goalSb = 64; /* 16 kHz band */ + break; + case 24000: + goalSb = 85; /* 16 kHz band */ + break; + case 22050: + goalSb = 93; /* 16 kHz band */ + break; + case 16000: + goalSb = 128; /* 16 kHz band */ + break; + case 44100: + default: + goalSb = 46; /* 16 kHz band */ + break; + } + + i = 0; + + if (goalSb > v_k_master[0]) + { + if (goalSb < v_k_master[numMaster]) + { + while (v_k_master[i] < goalSb) + { + i++; + } + } + else + { + i = numMaster; + } + } + + goalSb = v_k_master[i]; + + /* First patch */ + sourceStartBand = xoverOffset + 1; + targetStopBand = lsb + xoverOffset; + + /* even (odd) numbered channel must be patched to even (odd) numbered channel */ + patch = 0; + + + sbrStartFreqOffset = targetStopBand; + + while (targetStopBand < usb) + { + Patch->targetStartBand[patch] = targetStopBand; + + numBandsInPatch = goalSb - targetStopBand; /* get the desired range of the patch */ + + if (numBandsInPatch >= lsb - sourceStartBand) + { + /* desired number bands are not available -> patch whole source range */ + patchDistance = targetStopBand - sourceStartBand; /* get the targetOffset */ + patchDistance = patchDistance & ~1; /* rounding off odd numbers and make all even */ + numBandsInPatch = lsb - (targetStopBand - patchDistance); + + if (targetStopBand + numBandsInPatch > v_k_master[0]) + { + i = numMaster; + if (targetStopBand + numBandsInPatch < v_k_master[numMaster]) + { + while (v_k_master[i] > targetStopBand + numBandsInPatch) + { + i--; + } + } + } + else + { + i = 0; + } + numBandsInPatch = v_k_master[i] - targetStopBand; + } + + /* desired number bands are available -> get the minimal even patching distance */ + patchDistance = numBandsInPatch + targetStopBand - lsb; /* get minimal distance */ + patchDistance = (patchDistance + 1) & ~1; /* rounding up odd numbers and make all even */ + + /* All patches but first */ + sourceStartBand = 1; + + /* Check if we are close to goalSb */ + if (goalSb - (targetStopBand + numBandsInPatch) < 3) + { /* MPEG doc */ + goalSb = usb; + } + + + if ((numBandsInPatch < 3) && (patch > 0)) + { + if (LC_flag == ON) + { + + pv_memset((void *) °reeAlias[targetStopBand], 0, numBandsInPatch*sizeof(*degreeAlias)); + } + break; + } + + if (numBandsInPatch <= 0) + { + continue; + } + + + /* + * High Frequency generation + */ + + if (LC_flag == ON) + { + + high_freq_generation_LC(sourceBufferReal, + (Int32 *)targetBufferReal, + alphar, + degreeAlias, + invFiltBandTable, + targetStopBand, + patchDistance, + numBandsInPatch, + startSample, + slopeLength, + stopSample, + BwVector, + sbrStartFreqOffset); + + } +#ifdef HQ_SBR + else + { + + high_freq_generation(sourceBufferReal, + sourceBufferImag, + (Int32 *)targetBufferReal, + (Int32 *)targetBufferImag, + alphar, + alphai, + invFiltBandTable, + targetStopBand, + patchDistance, + numBandsInPatch, + startSample, + slopeLength, + stopSample, + BwVector, + sbrStartFreqOffset); + + } +#endif + + targetStopBand += numBandsInPatch; + + patch++; + + } /* targetStopBand */ + + Patch->noOfPatches = patch; + + pv_memmove(BwVectorOld, BwVector, noInvFiltBands*sizeof(BwVector[0])); + + *highBandStopSb = goalSb; + + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void high_freq_coeff_LC(Int32 sourceBufferReal[][32], + Int32 *alphar[2], + Int32 *degreeAlias, + Int32 *v_k_master, + Int32 *scratch_mem) +{ + + Int32 fac; + Int32 *k1; + struct ACORR_COEFS ac; + struct intg_div quotient; + + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 autoCorrLength; + Int32 loBand; + + k1 = scratch_mem; + + + autoCorrLength = 38; + + for (loBand = 1; loBand < v_k_master[0]; loBand++) + { + + calc_auto_corr_LC(&ac, + sourceBufferReal, + loBand, + autoCorrLength); + + if (ac.r11r && ac.det) + { + + pv_div(ac.r01r, ac.r11r, "ient); + + fac = -(quotient.quotient >> 2); /* Q28 */ + + if (quotient.shift_factor > 0) + { + fac >>= quotient.shift_factor; /* Q28 */ + } + else if (quotient.shift_factor < 0) + { + if (quotient.shift_factor > -4) /* |fac| < 8 */ + { + fac <<= (-quotient.shift_factor); /* Q28 */ + } + else + { + fac = 0x80000000; /* overshoot possible fac = -8 */ + } + } + + /* + * prevent for overflow of reflection coefficients + */ + if (quotient.shift_factor > 0) + { + k1[loBand] = - quotient.quotient >> quotient.shift_factor; + } + else if (quotient.shift_factor == 0) + { + if (quotient.quotient >= 0x40000000) + { + k1[loBand] = (Int32)0xC0000000; /* -1.0 in Q30 */ + } + else if (quotient.quotient <= (Int32)0xC0000000) + { + k1[loBand] = 0x40000000; /* 1.0 in Q30 */ + } + else + { + k1[loBand] = -quotient.quotient; + } + } + else + { + if (quotient.quotient > 0) + { + k1[loBand] = (Int32)0xC0000000; /* -1.0 in Q30 */ + } + else + { + k1[loBand] = 0x40000000; /* 1.0 in Q30 */ + } + } + /* + * alphar[1][loBand] = ( ac.r01r * ac.r12r - ac.r02r * ac.r11r ) / ac.det; + */ + + temp1 = -fxp_mul32_Q30(ac.r02r, ac.r11r); + temp1 = fxp_mac32_Q30(ac.r01r, ac.r12r, temp1); + + temp2 = ac.det; + temp3 = temp1 > 0 ? temp1 : -temp1; + temp2 = temp2 > 0 ? temp2 : -temp2; + + /* prevent for shootovers */ + if ((temp3 >> 2) >= temp2 || fac == (Int32)0x80000000) + { + alphar[0][loBand] = 0; + alphar[1][loBand] = 0; + } + else + { + pv_div(temp1, ac.det, "ient); + /* + * alphar[1][loBand] is lesser than 4.0 + */ + alphar[1][loBand] = quotient.quotient; + quotient.shift_factor += 2; /* Q28 */ + + if (quotient.shift_factor > 0) + { + alphar[1][loBand] >>= quotient.shift_factor; /* Q28 */ + } + else if (quotient.shift_factor < 0) /* at this point can only be -1 */ + { + alphar[1][loBand] <<= (-quotient.shift_factor); /* Q28 */ + } + + /* + * alphar[0][loBand] = - ( ac.r01r + alphar[1][loBand] * ac.r12r ) / ac.r11r; + */ + + pv_div(ac.r12r, ac.r11r, "ient); + + temp3 = (quotient.quotient >> 2); /* Q28 */ + + if (quotient.shift_factor > 0) + { + temp3 >>= quotient.shift_factor; /* Q28 */ + } + else if (quotient.shift_factor < 0) + { + temp3 <<= (-quotient.shift_factor); /* Q28 */ + } + + alphar[0][loBand] = fac - fxp_mul32_Q28(alphar[1][loBand], temp3) ; /* Q28 */ + + if ((alphar[0][loBand] >= 0x40000000) || (alphar[0][loBand] <= (Int32)0xC0000000)) + { + alphar[0][loBand] = 0; + alphar[1][loBand] = 0; + } + + } + + } + else + { + alphar[0][loBand] = 0; + alphar[1][loBand] = 0; + + k1[loBand] = 0; + } + + } + + k1[0] = 0; + degreeAlias[1] = 0; + for (loBand = 2; loBand < v_k_master[0]; loBand++) + { + degreeAlias[loBand] = 0; + if ((!(loBand & 1)) && (k1[loBand] < 0)) + { + if (k1[loBand-1] < 0) + { // 2-CH Aliasing Detection + degreeAlias[loBand] = 0x40000000; + if (k1[loBand-2] > 0) + { // 3-CH Aliasing Detection + degreeAlias[loBand-1] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]); + + } + } + else if (k1[loBand-2] > 0) + { // 3-CH Aliasing Detection + degreeAlias[loBand] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]); + } + } + if ((loBand & 1) && (k1[loBand] > 0)) + { + if (k1[loBand-1] > 0) + { // 2-CH Aliasing Detection + degreeAlias[loBand] = 0x40000000; + if (k1[loBand-2] < 0) + { // 3-CH Aliasing Detection + degreeAlias[loBand-1] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]); + } + } + else if (k1[loBand-2] < 0) + { // 3-CH Aliasing Detection + degreeAlias[loBand] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]); + } + } + } + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void high_freq_generation_LC(Int32 sourceBufferReal[][32], + Int32 *targetBufferReal, + Int32 *alphar[2], + Int32 *degreeAlias, + Int32 *invFiltBandTable, + Int32 targetStopBand, + Int32 patchDistance, + Int32 numBandsInPatch, + Int32 startSample, + Int32 slopeLength, + Int32 stopSample, + Int32 *BwVector, + Int32 sbrStartFreqOffset) +{ + + Int32 temp1; + Int32 temp2; + Int32 temp3; + + + Int32 a0r; + Int32 a1r; + Int32 i; + Int32 bw; + Int32 hiBand; + Int32 bwIndex; + Int32 loBand; + Int32 j; + + bwIndex = 0; + + for (hiBand = targetStopBand; hiBand < targetStopBand + numBandsInPatch; hiBand++) + { + loBand = hiBand - patchDistance; + + if (hiBand != targetStopBand) + { + degreeAlias[hiBand] = degreeAlias[loBand]; + } + else + { + degreeAlias[hiBand] = 0; + } + + while (hiBand >= invFiltBandTable[bwIndex]) + { + bwIndex++; + } + + bw = BwVector[bwIndex]; + + /* + * Inverse Filtering + */ + + + j = hiBand - sbrStartFreqOffset; + + if (bw > 0 && (alphar[0][loBand] | alphar[1][loBand])) + { + /* Apply current bandwidth expansion factor */ + a0r = fxp_mul32_Q29(bw, alphar[0][loBand]); + + bw = fxp_mul32_Q31(bw, bw) << 2; + + a1r = fxp_mul32_Q28(bw, alphar[1][loBand]); + + i = startSample + slopeLength; + + temp1 = sourceBufferReal[i ][loBand]; + temp2 = sourceBufferReal[i - 1][loBand]; + temp3 = sourceBufferReal[i - 2][loBand]; + + for (; i < stopSample + slopeLength - 1; i++) + { + + + targetBufferReal[i*SBR_NUM_BANDS + j] = temp1 + fxp_mul32_Q28(a0r, temp2) + + fxp_mul32_Q28(a1r, temp3); + + + temp3 = temp2; + temp2 = temp1; + temp1 = sourceBufferReal[i + 1][loBand]; + } + targetBufferReal[i*SBR_NUM_BANDS + j] = temp1 + fxp_mul32_Q28(a0r, temp2) + + fxp_mul32_Q28(a1r, temp3); + + } + else + { + + for (i = startSample + slopeLength; i < stopSample + slopeLength; i++) + { + targetBufferReal[i*SBR_NUM_BANDS + j] = sourceBufferReal[i][loBand]; + } + } + + + } /* hiBand */ + +} + + +#ifdef HQ_SBR + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void high_freq_coeff(Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *alphar[2], + Int32 *alphai[2], + Int32 *v_k_master) +{ + + Int32 overflow_flag; + + Int32 temp1r; + Int32 temp1i; + Int32 temp0r; + Int32 temp0i; + Int32 loBand; + + struct ACORR_COEFS ac; + struct intg_div quotient; + + Int32 autoCorrLength; + + autoCorrLength = 38; + + for (loBand = 1; loBand < v_k_master[0]; loBand++) + { + + calc_auto_corr(&ac, + sourceBufferReal, + sourceBufferImag, + loBand, + autoCorrLength); + + + overflow_flag = 0; + + if (ac.det < 1) + { + /* --- */ + temp1r = 0; + temp1i = 0; + alphar[1][loBand] = 0; + alphai[1][loBand] = 0; + + } + else + { + + temp1r = fxp_mul32_Q29(ac.r01r, ac.r12r); + temp1r = fxp_msu32_Q29(ac.r01i, ac.r12i, temp1r); + temp1r = fxp_msu32_Q29(ac.r02r, ac.r11r, temp1r); + + temp1i = fxp_mul32_Q29(ac.r01r, ac.r12i); + temp1i = fxp_msu32_Q29(ac.r02i, ac.r11r, temp1i); + temp1i = fxp_mac32_Q29(ac.r01i, ac.r12r, temp1i); + + pv_div(temp1r, ac.det, "ient); + overflow_flag = (quotient.shift_factor < -2) ? 1 : 0; + temp1r = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */ + pv_div(temp1i, ac.det, "ient); + overflow_flag = (quotient.shift_factor < -2) ? 1 : 0; + temp1i = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */ + + alphar[1][loBand] = temp1r; + alphai[1][loBand] = temp1i; + + } + + if (ac.r11r == 0) + { + temp0r = 0; + temp0i = 0; + alphar[0][loBand] = 0; + alphai[0][loBand] = 0; + + } + else + { + temp0r = - (ac.r01r + fxp_mul32_Q28(temp1r, ac.r12r) + fxp_mul32_Q28(temp1i, ac.r12i)); + temp0i = - (ac.r01i + fxp_mul32_Q28(temp1i, ac.r12r) - fxp_mul32_Q28(temp1r, ac.r12i)); + + pv_div(temp0r, ac.r11r, "ient); + overflow_flag = (quotient.shift_factor < -2) ? 1 : 0; + temp0r = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */ + pv_div(temp0i, ac.r11r, "ient); + overflow_flag = (quotient.shift_factor < -2) ? 1 : 0; + temp0i = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */ + + alphar[0][loBand] = temp0r; + alphai[0][loBand] = temp0i; + + } + + /* prevent for shootovers */ + + if (fxp_mul32_Q28((temp0r >> 2), (temp0r >> 2)) + fxp_mul32_Q28((temp0i >> 2), (temp0i >> 2)) >= 0x10000000 || + fxp_mul32_Q28((temp1r >> 2), (temp1r >> 2)) + fxp_mul32_Q28((temp1i >> 2), (temp1i >> 2)) >= 0x10000000 || + overflow_flag) /* 0x10000000 == 1 in Q28 */ + + { + alphar[0][loBand] = 0; + alphar[1][loBand] = 0; + alphai[0][loBand] = 0; + alphai[1][loBand] = 0; + + } + } +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void high_freq_generation(Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *targetBufferReal, + Int32 *targetBufferImag, + Int32 *alphar[2], + Int32 *alphai[2], + Int32 *invFiltBandTable, + Int32 targetStopBand, + Int32 patchDistance, + Int32 numBandsInPatch, + Int32 startSample, + Int32 slopeLength, + Int32 stopSample, + Int32 *BwVector, + Int32 sbrStartFreqOffset) +{ + Int32 temp1_r; + Int32 temp2_r; + Int32 temp3_r; + Int32 temp1_i; + Int32 temp2_i; + Int32 temp3_i; + + + Int32 a0i; + Int32 a1i; + Int32 a0r; + Int32 a1r; + Int32 i; + Int32 bw; + Int32 hiBand; + Int32 bwIndex; + Int32 loBand; + Int32 j; + + int64 tmp; + + bwIndex = 0; + + for (hiBand = targetStopBand; hiBand < targetStopBand + numBandsInPatch; hiBand++) + { + + loBand = hiBand - patchDistance; + + while (hiBand >= invFiltBandTable[bwIndex]) + { + bwIndex++; + } + + bw = BwVector[bwIndex]; + + /* + * Inverse Filtering + */ + + + j = hiBand - sbrStartFreqOffset; + + if (bw >= 0 && (alphar[0][loBand] | alphar[1][loBand] | + alphai[0][loBand] | alphai[1][loBand])) + { + /* Apply current bandwidth expansion factor */ + a0r = fxp_mul32_Q29(bw, alphar[0][loBand]); + a0i = fxp_mul32_Q29(bw, alphai[0][loBand]); + + + bw = fxp_mul32_Q30(bw, bw); + + + a1r = fxp_mul32_Q28(bw, alphar[1][loBand]); + a1i = fxp_mul32_Q28(bw, alphai[1][loBand]); + + + i = startSample + slopeLength; + j += i * SBR_NUM_BANDS; + + temp1_r = sourceBufferReal[i ][loBand]; + temp2_r = sourceBufferReal[i - 1][loBand]; + temp3_r = sourceBufferReal[i - 2][loBand]; + + temp1_i = sourceBufferImag[i ][loBand]; + temp2_i = sourceBufferImag[i - 1][loBand]; + temp3_i = sourceBufferImag[i - 2][loBand]; + + while (i < stopSample + slopeLength) + { + tmp = fxp_mac64_Q31(((int64)temp1_r << 28), a0r, temp2_r); + tmp = fxp_mac64_Q31(tmp, -a0i, temp2_i); + tmp = fxp_mac64_Q31(tmp, a1r, temp3_r); + targetBufferReal[j] = (Int32)(fxp_mac64_Q31(tmp, -a1i, temp3_i) >> 28); + + tmp = fxp_mac64_Q31(((int64)temp1_i << 28), a0i, temp2_r); + tmp = fxp_mac64_Q31(tmp, a0r, temp2_i); + tmp = fxp_mac64_Q31(tmp, a1i, temp3_r); + targetBufferImag[j] = (Int32)(fxp_mac64_Q31(tmp, a1r, temp3_i) >> 28); + + i++; + j += SBR_NUM_BANDS; + + temp3_r = temp2_r; + temp2_r = temp1_r; + temp1_r = sourceBufferReal[i ][loBand]; + + temp3_i = temp2_i; + temp2_i = temp1_i; + temp1_i = sourceBufferImag[i ][loBand]; + + } + + } + else + { + i = startSample + slopeLength; + j += i * SBR_NUM_BANDS; + + for (; i < stopSample + slopeLength; i++) + { + targetBufferReal[j] = sourceBufferReal[i][loBand]; + targetBufferImag[j] = sourceBufferImag[i][loBand]; + j += SBR_NUM_BANDS; + } + } + } +} + +#endif + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.h new file mode 100644 index 0000000..b7d6012 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.h @@ -0,0 +1,137 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_generate_high_freq.h + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GENERATE_HIGH_FREQ_H +#define SBR_GENERATE_HIGH_FREQ_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "e_invf_mode.h" +#include "s_patch.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + + + + void sbr_generate_high_freq( + Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *targetBufferReal, + Int32 *targetBufferImag, + INVF_MODE *invFiltMode, + INVF_MODE *prevInvFiltMode, + Int32 *invFiltBandTable, + Int32 noInvFiltBands, + Int32 highBandStartSb, + Int32 *v_k_master, + Int32 numMaster, + Int32 fs, + Int32 *frameInfo, + Int32 *degreeAlias, + Int32 scratch_mem[][64], + Int32 BwVector[MAX_NUM_PATCHES], + Int32 BwVectorOld[MAX_NUM_PATCHES], + struct PATCH * Patch, + Int32 LC_flag, + Int32 *highBandStopSb); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.cpp new file mode 100644 index 0000000..1b788fe --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.cpp @@ -0,0 +1,138 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_additional_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_get_additional_data.h" +#include "buf_getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_get_additional_data(SBR_FRAME_DATA * hFrameData, + BIT_BUFFER * hBitBuf) +{ + Int32 i; + + Int32 flag = buf_getbits(hBitBuf, 1); + + if (flag) + { + for (i = 0; i < hFrameData->nSfb[HI]; i++) + { + hFrameData->addHarmonics[i] = buf_getbits(hBitBuf, 1); + } + } +} + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.h new file mode 100644 index 0000000..a34bd5f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.h @@ -0,0 +1,76 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_additional_data.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_ADDITIONAL_DATA_H +#define SBR_GET_ADDITIONAL_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_header_data.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_get_additional_data(SBR_FRAME_DATA * hFrameData, + BIT_BUFFER * hBitBuf); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_cpe.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_cpe.cpp new file mode 100644 index 0000000..45dd687 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_cpe.cpp @@ -0,0 +1,261 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_cpe.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: hFrameDataLeft - handle to struct SBR_FRAME_DATA for first channel + hFrameDataRight - handle to struct SBR_FRAME_DATA for first channel + hBitBuf - handle to struct BIT_BUF + + Return: SbrFrameOK + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_get_cpe.h" +#include "buf_getbits.h" +#include "extractframeinfo.h" +#include "sbr_get_dir_control_data.h" +#include "sbr_get_envelope.h" +#include "sbr_get_noise_floor_data.h" +#include "sbr_get_additional_data.h" +#include "sbr_extract_extended_data.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +SBR_ERROR sbr_get_cpe(SBR_FRAME_DATA * hFrameDataLeft, + SBR_FRAME_DATA * hFrameDataRight, + BIT_BUFFER * hBitBuf) +{ + Int32 i; + Int32 bits; + SBR_ERROR err = SBRDEC_OK; + + /* reserved bits */ + bits = buf_getbits(hBitBuf, SI_SBR_RESERVED_PRESENT); + + if (bits) + { + buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA); + buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA); + } + + /* Read coupling flag */ + bits = buf_getbits(hBitBuf, SI_SBR_COUPLING_BITS); + + if (bits) + { + hFrameDataLeft->coupling = COUPLING_LEVEL; + hFrameDataRight->coupling = COUPLING_BAL; + } + else + { + hFrameDataLeft->coupling = COUPLING_OFF; + hFrameDataRight->coupling = COUPLING_OFF; + } + + + err = extractFrameInfo(hBitBuf, hFrameDataLeft); + + if (err != SBRDEC_OK) + { + return err; + } + + if (hFrameDataLeft->coupling) + { + + pv_memcpy(hFrameDataRight->frameInfo, + hFrameDataLeft->frameInfo, + LENGTH_FRAME_INFO * sizeof(Int32)); + + hFrameDataRight->nNoiseFloorEnvelopes = hFrameDataLeft->nNoiseFloorEnvelopes; + hFrameDataRight->frameClass = hFrameDataLeft->frameClass; + + + sbr_get_dir_control_data(hFrameDataLeft, hBitBuf); + sbr_get_dir_control_data(hFrameDataRight, hBitBuf); + + for (i = 0; i < hFrameDataLeft->nNfb; i++) + { + hFrameDataLeft->sbr_invf_mode_prev[i] = hFrameDataLeft->sbr_invf_mode[i]; + hFrameDataRight->sbr_invf_mode_prev[i] = hFrameDataRight->sbr_invf_mode[i]; + + hFrameDataLeft->sbr_invf_mode[i] = (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS); + hFrameDataRight->sbr_invf_mode[i] = hFrameDataLeft->sbr_invf_mode[i]; + } + + sbr_get_envelope(hFrameDataLeft, hBitBuf); + sbr_get_noise_floor_data(hFrameDataLeft, hBitBuf); + sbr_get_envelope(hFrameDataRight, hBitBuf); + + } + else + { + err = extractFrameInfo(hBitBuf, hFrameDataRight); + + if (err != SBRDEC_OK) + { + return err; + } + + + sbr_get_dir_control_data(hFrameDataLeft, hBitBuf); + sbr_get_dir_control_data(hFrameDataRight, hBitBuf); + + for (i = 0; i < hFrameDataLeft->nNfb; i++) + { + hFrameDataLeft->sbr_invf_mode_prev[i] = hFrameDataLeft->sbr_invf_mode[i]; + hFrameDataLeft->sbr_invf_mode[i] = + (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS); + } + + for (i = 0; i < hFrameDataRight->nNfb; i++) + { + hFrameDataRight->sbr_invf_mode_prev[i] = hFrameDataRight->sbr_invf_mode[i]; + + hFrameDataRight->sbr_invf_mode[i] = + (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS); + } + sbr_get_envelope(hFrameDataLeft, hBitBuf); + sbr_get_envelope(hFrameDataRight, hBitBuf); + + sbr_get_noise_floor_data(hFrameDataLeft, hBitBuf); + + } + + sbr_get_noise_floor_data(hFrameDataRight, hBitBuf); + + pv_memset((void *)hFrameDataLeft->addHarmonics, + 0, + hFrameDataLeft->nSfb[HI]*sizeof(Int32)); + + pv_memset((void *)hFrameDataRight->addHarmonics, + 0, + hFrameDataRight->nSfb[HI]*sizeof(Int32)); + + sbr_get_additional_data(hFrameDataLeft, hBitBuf); + sbr_get_additional_data(hFrameDataRight, hBitBuf); + + sbr_extract_extended_data(hBitBuf +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + , NULL +#endif +#endif + ); + + return SBRDEC_OK; + +} + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_cpe.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_cpe.h new file mode 100644 index 0000000..7ecddd5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_cpe.h @@ -0,0 +1,78 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_cpe.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_CPE_H +#define SBR_GET_CPE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" +#include "e_sbr_error.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_get_cpe(SBR_FRAME_DATA * hFrameDataLeft, + SBR_FRAME_DATA * hFrameDataRight, + BIT_BUFFER * hBitBuf); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.cpp new file mode 100644 index 0000000..c114941 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.cpp @@ -0,0 +1,146 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_dir_control_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: h_frame_data - handle to struct SBR_FRAME_DATA + hBitBuf - handle to struct BIT_BUF + + Return: void + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads direction control data from bitstream + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_get_dir_control_data.h" +#include "buf_getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_get_dir_control_data(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf) +{ + Int32 i; + + h_frame_data->nNoiseFloorEnvelopes = h_frame_data->frameInfo[0] > 1 ? 2 : 1; + + + for (i = 0; i < h_frame_data->frameInfo[0]; i++) + { + h_frame_data->domain_vec1[i] = buf_getbits(hBitBuf, SI_SBR_DOMAIN_BITS); + } + + for (i = 0; i < h_frame_data->nNoiseFloorEnvelopes; i++) + { + h_frame_data->domain_vec2[i] = buf_getbits(hBitBuf, SI_SBR_DOMAIN_BITS); + } +} + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.h new file mode 100644 index 0000000..b201e4d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.h @@ -0,0 +1,76 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_dir_control_data.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_DIR_CONTROL_DATA_H +#define SBR_GET_DIR_CONTROL_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_get_dir_control_data(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_envelope.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_envelope.cpp new file mode 100644 index 0000000..8ed945e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_envelope.cpp @@ -0,0 +1,258 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_envelope.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: h_frame_data - handle to struct SBR_FRAME_DATA + hBitBuf - handle to struct BIT_BUF + channel - channel number + + Return: void + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads envelope data from bitstream + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_get_envelope.h" +#include "s_huffman.h" +#include "e_coupling_mode.h" +#include "sbr_code_book_envlevel.h" +#include "buf_getbits.h" +#include "sbr_decode_huff_cw.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_get_envelope(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf) +{ + Int32 i; + Int32 j; + Int32 tmp; + Int32 no_band[MAX_ENVELOPES]; + Int32 delta = 0; + Int32 offset = 0; + Int32 ampRes; + Int32 envDataTableCompFactor; + Int32 start_bits; + Int32 start_bits_balance; + SbrHuffman hcb_t; + SbrHuffman hcb_f; + COUPLING_MODE coupling = h_frame_data->coupling; + + h_frame_data->nScaleFactors = 0; + + if ((h_frame_data->frameClass == FIXFIX) && + (h_frame_data->frameInfo[0] == 1)) + { + h_frame_data->ampRes = SBR_AMP_RES_1_5; + } + else + { + h_frame_data->ampRes = h_frame_data->sbr_header.ampResolution; + } + + ampRes = h_frame_data->ampRes; + + /* + * Set number of bits for first value depending on amplitude resolution + */ + if (ampRes == SBR_AMP_RES_3_0) + { + start_bits = SI_SBR_START_ENV_BITS_AMP_RES_3_0; + start_bits_balance = SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_3_0; + } + else + { + start_bits = SI_SBR_START_ENV_BITS_AMP_RES_1_5; + start_bits_balance = SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_1_5; + } + + /* + * Calculate number of values for each envelope and alltogether + */ + for (i = 0; i < h_frame_data->frameInfo[0]; i++) + { + no_band[i] = + h_frame_data->nSfb[h_frame_data->frameInfo[h_frame_data->frameInfo[0] + 2 + i]]; + h_frame_data->nScaleFactors += no_band[i]; + } + + + /* + * Select huffman codebook depending on coupling mode and amplitude resolution + */ + if (coupling == COUPLING_BAL) + { + envDataTableCompFactor = 1; + if (ampRes == SBR_AMP_RES_1_5) + { + hcb_t = bookSbrEnvBalance10T; + hcb_f = bookSbrEnvBalance10F; + } + else + { + hcb_t = bookSbrEnvBalance11T; + hcb_f = bookSbrEnvBalance11F; + } + } + else + { + envDataTableCompFactor = 0; + if (ampRes == SBR_AMP_RES_1_5) + { + hcb_t = bookSbrEnvLevel10T; + hcb_f = bookSbrEnvLevel10F; + } + else + { + hcb_t = bookSbrEnvLevel11T; + hcb_f = bookSbrEnvLevel11F; + } + } + + /* + * Now read raw envelope data + */ + for (j = 0; j < h_frame_data->frameInfo[0]; j++) + { + if (h_frame_data->domain_vec1[j] == FREQ) + { + if (coupling == COUPLING_BAL) + { + tmp = buf_getbits(hBitBuf, start_bits_balance); + h_frame_data->iEnvelope_man[offset] = tmp << envDataTableCompFactor; + } + else + { + tmp = buf_getbits(hBitBuf, start_bits); + h_frame_data->iEnvelope_man[offset] = tmp; + } + } + + for (i = (1 - h_frame_data->domain_vec1[j]); i < no_band[j]; i++) + { + + if (h_frame_data->domain_vec1[j] == FREQ) + { + delta = sbr_decode_huff_cw(hcb_f, hBitBuf); + } + else + { + delta = sbr_decode_huff_cw(hcb_t, hBitBuf); + } + + h_frame_data->iEnvelope_man[offset + i] = delta << envDataTableCompFactor; + } + offset += no_band[j]; + } + +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_envelope.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_envelope.h new file mode 100644 index 0000000..873212d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_envelope.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_envelope.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_ENVELOPE_H +#define SBR_GET_ENVELOPE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void sbr_get_envelope(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_header_data.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_header_data.cpp new file mode 100644 index 0000000..eefa53d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_header_data.cpp @@ -0,0 +1,214 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_header_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: h_sbr_header - handle to struct SBR_HEADER_DATA + hBitBuf - handle to struct BIT_BUFFER + id_sbr - SBR_ELEMENT_ID + + Return: error status - 0 if ok + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads header data from bitstream + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_get_header_data.h" +#include "sbr_constants.h" +#include "buf_getbits.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_HEADER_STATUS sbr_get_header_data(SBR_HEADER_DATA * h_sbr_header, + BIT_BUFFER * hBitBuf, + SBR_SYNC_STATE syncState) +{ + SBR_HEADER_DATA lastHeader; + Int32 headerExtra1, headerExtra2; + + + /* Copy header to temporary header */ + if (syncState == SBR_ACTIVE) + { + pv_memcpy(&lastHeader, h_sbr_header, sizeof(SBR_HEADER_DATA)); + } + else + { + pv_memset((void *)&lastHeader, 0, sizeof(SBR_HEADER_DATA)); + } + + + /* Read new header from bitstream */ + h_sbr_header->ampResolution = buf_getbits(hBitBuf, SI_SBR_AMP_RES_BITS); + h_sbr_header->startFreq = buf_getbits(hBitBuf, SI_SBR_START_FREQ_BITS); + h_sbr_header->stopFreq = buf_getbits(hBitBuf, SI_SBR_STOP_FREQ_BITS); + h_sbr_header->xover_band = buf_getbits(hBitBuf, SI_SBR_XOVER_BAND_BITS); + + buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_HDR); + + headerExtra1 = buf_getbits(hBitBuf, SI_SBR_HEADER_EXTRA_1_BITS); + headerExtra2 = buf_getbits(hBitBuf, SI_SBR_HEADER_EXTRA_2_BITS); + + /* handle extra header information */ + if (headerExtra1) + { + h_sbr_header->freqScale = buf_getbits(hBitBuf, SI_SBR_FREQ_SCALE_BITS); + h_sbr_header->alterScale = buf_getbits(hBitBuf, SI_SBR_ALTER_SCALE_BITS); + h_sbr_header->noise_bands = buf_getbits(hBitBuf, SI_SBR_NOISE_BANDS_BITS); + } + else + { /* Set default values.*/ + h_sbr_header->freqScale = SBR_FREQ_SCALE_DEFAULT; + h_sbr_header->alterScale = SBR_ALTER_SCALE_DEFAULT; + h_sbr_header->noise_bands = SBR_NOISE_BANDS_DEFAULT; + } + + + if (headerExtra2) + { + h_sbr_header->limiterBands = buf_getbits(hBitBuf, SI_SBR_LIMITER_BANDS_BITS); + h_sbr_header->limiterGains = buf_getbits(hBitBuf, SI_SBR_LIMITER_GAINS_BITS); + h_sbr_header->interpolFreq = buf_getbits(hBitBuf, SI_SBR_INTERPOL_FREQ_BITS); + h_sbr_header->smoothingLength = buf_getbits(hBitBuf, SI_SBR_SMOOTHING_LENGTH_BITS); + } + else + { /* Set default values.*/ + h_sbr_header->limiterBands = SBR_LIMITER_BANDS_DEFAULT; + h_sbr_header->limiterGains = SBR_LIMITER_GAINS_DEFAULT; + h_sbr_header->interpolFreq = SBR_INTERPOL_FREQ_DEFAULT; + h_sbr_header->smoothingLength = SBR_SMOOTHING_LENGTH_DEFAULT; + } + + if (syncState == SBR_ACTIVE) + { + h_sbr_header->status = HEADER_OK; + + /* look for new settings */ + if (lastHeader.startFreq != h_sbr_header->startFreq || + lastHeader.stopFreq != h_sbr_header->stopFreq || + lastHeader.xover_band != h_sbr_header->xover_band || + lastHeader.freqScale != h_sbr_header->freqScale || + lastHeader.alterScale != h_sbr_header->alterScale || + lastHeader.noise_bands != h_sbr_header->noise_bands) + { + h_sbr_header->status = HEADER_RESET; + } + } + else + { + h_sbr_header->status = HEADER_RESET; + } + + return h_sbr_header->status; +} + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_header_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_header_data.h new file mode 100644 index 0000000..1b299f9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_header_data.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_header_data.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_HEADER_DATA_H +#define SBR_GET_HEADER_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_header_data.h" +#include "e_sbr_element_id.h" +#include "e_sbr_sync_state.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +SBR_HEADER_STATUS sbr_get_header_data(SBR_HEADER_DATA *h_sbr_header, + BIT_BUFFER * hBitBuf, + SBR_SYNC_STATE syncState); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.cpp new file mode 100644 index 0000000..50680e4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.cpp @@ -0,0 +1,210 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_noise_floor_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: h_frame_data - handle to struct SBR_FRAME_DATA + hBitBuf - handle to struct BIT_BUF + + Return: void + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads noise-floor-level data from bitstream + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_get_noise_floor_data.h" +#include "e_coupling_mode.h" +#include "buf_getbits.h" +#include "sbr_code_book_envlevel.h" +#include "s_huffman.h" +#include "sbr_decode_huff_cw.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_get_noise_floor_data(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf) +{ + Int32 i; + Int32 j; + Int32 k; + Int32 tmp; + Int32 delta; + Int32 noNoiseBands = h_frame_data->nNfb; + Int32 envDataTableCompFactor; + + COUPLING_MODE coupling = h_frame_data->coupling; + + SbrHuffman hcb_noiseF; + SbrHuffman hcb_noise; + + + if (coupling == COUPLING_BAL) + { + hcb_noise = bookSbrNoiseBalance11T; + hcb_noiseF = bookSbrEnvBalance11F; /* "bookSbrNoiseBalance11F" */ + envDataTableCompFactor = 1; + } + else + { + hcb_noise = bookSbrNoiseLevel11T; + hcb_noiseF = bookSbrEnvLevel11F; /* "bookSbrNoiseLevel11F" */ + envDataTableCompFactor = 0; + } + + /* + * Calculate number of values alltogether + */ + h_frame_data->nNoiseFactors = h_frame_data->frameInfo[((h_frame_data->frameInfo[0]) << 1) + 3] * noNoiseBands; + + + for (i = 0; i < h_frame_data->nNoiseFloorEnvelopes; i++) + { + k = i * noNoiseBands; + if (h_frame_data->domain_vec2[i] == FREQ) + { + if (coupling == COUPLING_BAL) + { + tmp = buf_getbits(hBitBuf, SI_SBR_START_NOISE_BITS_BALANCE_AMP_RES_3_0) << 1; /* max. 62 */ + h_frame_data->sbrNoiseFloorLevel_man[k] = tmp; + h_frame_data->sbrNoiseFloorLevel_exp[k] = 0; + } + else + { + tmp = buf_getbits(hBitBuf, SI_SBR_START_NOISE_BITS_AMP_RES_3_0); /* max. 31 */ + h_frame_data->sbrNoiseFloorLevel_man[k] = tmp; + h_frame_data->sbrNoiseFloorLevel_exp[k] = 0; + } + + for (j = 1; j < noNoiseBands; j++) + { + delta = sbr_decode_huff_cw(hcb_noiseF, hBitBuf); /* + * -31 < delta < 31 + * -24 < delta < 24 COUPLING_BAL (incl. <<1) + */ + h_frame_data->sbrNoiseFloorLevel_man[k+j] = delta << envDataTableCompFactor; + h_frame_data->sbrNoiseFloorLevel_exp[k+j] = 0; + } + } + else + { + for (j = 0; j < noNoiseBands; j++) + { + delta = sbr_decode_huff_cw(hcb_noise, hBitBuf); /* + * -31 < delta < 31 + * -24 < delta < 24 COUPLING_BAL (incl. <<1) + */ + h_frame_data->sbrNoiseFloorLevel_man[k+j] = delta << envDataTableCompFactor; + h_frame_data->sbrNoiseFloorLevel_exp[k+j] = 0; + } + } + } +} + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.h new file mode 100644 index 0000000..fe7262f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_noise_floor_data.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_NOISE_FLOOR_DATA_H +#define SBR_GET_NOISE_FLOOR_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void sbr_get_noise_floor_data(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_sce.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_sce.cpp new file mode 100644 index 0000000..36b89fc --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_sce.cpp @@ -0,0 +1,195 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_sce.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: hFrameData - handle to struct SBR_FRAME_DATA + hBitBuf - handle to struct BIT_BUF + + Return: SbrFrameOK + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + + +#include "sbr_get_sce.h" +#include "sbr_get_additional_data.h" +#include "sbr_extract_extended_data.h" +#include "buf_getbits.h" +#include "sbr_get_envelope.h" +#include "sbr_get_noise_floor_data.h" +#include "extractframeinfo.h" +#include "sbr_get_dir_control_data.h" +#include "e_invf_mode.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_get_sce(SBR_FRAME_DATA * hFrameData, + BIT_BUFFER * hBitBuf +#ifdef PARAMETRICSTEREO + , HANDLE_PS_DEC hParametricStereoDec +#endif + ) +{ + Int32 i; + Int32 bits; + SBR_ERROR err = SBRDEC_OK; + + /* reserved bits */ + bits = buf_getbits(hBitBuf, SI_SBR_RESERVED_PRESENT); + + if (bits) + { + buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA); + } + + /* side info */ + err = extractFrameInfo(hBitBuf, hFrameData); + + if (err != SBRDEC_OK) + { + return err; + } + + + sbr_get_dir_control_data(hFrameData, hBitBuf); + + for (i = 0; i < hFrameData->nNfb; i++) + { + hFrameData->sbr_invf_mode_prev[i] = hFrameData->sbr_invf_mode[i]; + hFrameData->sbr_invf_mode[i] = + (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS); + } + + + /* raw data */ + sbr_get_envelope(hFrameData, hBitBuf); + + sbr_get_noise_floor_data(hFrameData, hBitBuf); + + pv_memset((void *)hFrameData->addHarmonics, + 0, + hFrameData->nSfb[HI]*sizeof(Int32)); + + sbr_get_additional_data(hFrameData, hBitBuf); + + sbr_extract_extended_data(hBitBuf +#ifdef PARAMETRICSTEREO + , hParametricStereoDec +#endif + ); + + hFrameData->coupling = COUPLING_OFF; + + return SBRDEC_OK; + +} + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_sce.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_sce.h new file mode 100644 index 0000000..a8f30d2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_get_sce.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_sce.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_SCE_H +#define SBR_GET_SCE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" +#include "e_sbr_error.h" + +#ifdef PARAMETRICSTEREO +#include "s_ps_dec.h" +#endif + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + SBR_ERROR sbr_get_sce(SBR_FRAME_DATA * hFrameData, + BIT_BUFFER * hBitBuf +#ifdef PARAMETRICSTEREO + , HANDLE_PS_DEC hParametricStereoDec +#endif + ); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.cpp new file mode 100644 index 0000000..327f666 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.cpp @@ -0,0 +1,207 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_inv_filt_levelemphasis.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_inv_filt_levelemphasis.h" +#include "sbr_generate_high_freq.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" + +#define R_SHIFT 29 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +const Int32 InvFiltFactors[5] = {Qfmt(0.00f), /* OFF_LEVEL */ + Qfmt(0.60f), /* TRANSITION_LEVEL */ + Qfmt(0.75f), /* LOW_LEVEL */ + Qfmt(0.90f), /* MID_LEVEL */ + Qfmt(0.98f) + }; /* HIGH_LEVEL */ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_inv_filt_levelemphasis(INVF_MODE *invFiltMode, + INVF_MODE *prevInvFiltMode, + Int32 nNfb, + Int32 BwVector[MAX_NUM_PATCHES], + Int32 BwVectorOld[MAX_NUM_PATCHES]) +{ + Int32 i; + Int32 j; + Int32 tmp; + + for (i = 0; i < nNfb; i++) + { + switch (invFiltMode[i]) + { + case INVF_LOW_LEVEL: + if (prevInvFiltMode[i] == INVF_OFF) + { + j = 1; + } + else + { + j = 2; + } + break; + + case INVF_MID_LEVEL: + j = 3; + break; + + case INVF_HIGH_LEVEL: + j = 4; + break; + + default: + if (prevInvFiltMode[i] == INVF_LOW_LEVEL) + { + j = 1; + } + else + { + j = 0; + } + } + + tmp = InvFiltFactors[j]; + + if (tmp < BwVectorOld[i]) + { + tmp = ((tmp << 1) + tmp + BwVectorOld[i]) >> 2; + } + else + { + tmp = fxp_mul32_Q29(Qfmt(0.90625f), tmp); + tmp = fxp_mac32_Q29(Qfmt(0.09375f), BwVectorOld[i], tmp); + } + + if (tmp < Qfmt(0.015625F)) + { + tmp = 0; + } + + if (tmp >= Qfmt(0.99609375f)) + { + tmp = Qfmt(0.99609375f); + } + + BwVector[i] = tmp; + } +} + + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.h new file mode 100644 index 0000000..7c1524d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_inv_filt_levelemphasis.h + Functions: + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_INV_FILT_LEVELEMPHASIS_H +#define SBR_INV_FILT_LEVELEMPHASIS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_invf_mode.h" +#include "sbr_generate_high_freq.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +void sbr_inv_filt_levelemphasis(INVF_MODE *invFiltMode, + INVF_MODE *prevInvFiltMode, + Int32 nNfb, + Int32 BwVector[MAX_NUM_PATCHES], + Int32 BwVectorOld[MAX_NUM_PATCHES]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_open.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_open.cpp new file mode 100644 index 0000000..b31af9a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_open.cpp @@ -0,0 +1,188 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_open.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_open.h" +#include "s_sbr_header_data.h" +#include "init_sbr_dec.h" +#include "e_sbr_error.h" +#include "aac_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const SBR_HEADER_DATA defaultHeader = +{ + HEADER_NOT_INITIALIZED, /* status */ + MASTER_RESET, /* masterStatus */ + 0, /* crcEnable */ + UP_BY_2, /* sampleRateMode */ + SBR_AMP_RES_3_0, /* ampResolution */ + 5, /* startFreq */ + 0, /* stopFreq */ + 0, /* xover_band */ + SBR_FREQ_SCALE_DEFAULT, /* freqScale */ + SBR_ALTER_SCALE_DEFAULT, /* alterScale */ + SBR_NOISE_BANDS_DEFAULT, /* noise_bands */ + 0, /* noNoiseBands */ + SBR_LIMITER_BANDS_DEFAULT, + SBR_LIMITER_GAINS_DEFAULT, + SBR_INTERPOL_FREQ_DEFAULT, + SBR_SMOOTHING_LENGTH_DEFAULT +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_open(Int32 sampleRate, + SBR_DEC *sbrDec, + SBRDECODER_DATA * self, + bool bDownSampledSbr) + +{ + Int16 i ; + + SBR_CHANNEL *SbrChannel; + + + SbrChannel = self->SbrChannel; + + for (i = 0; i < MAX_NUM_CHANNELS; i++) + { + pv_memset((void *)&(SbrChannel[i]), + 0, + sizeof(SBR_CHANNEL)); + + /* init a default header such that we can at least do upsampling later */ + + pv_memcpy(&(SbrChannel[i].frameData.sbr_header), + &defaultHeader, + sizeof(SBR_HEADER_DATA)); + + /* should be handled by sample rate mode bit */ + if (sampleRate > 24000 || bDownSampledSbr) + { + SbrChannel[i].frameData.sbr_header.sampleRateMode = SINGLE_RATE; + } + + + SbrChannel[i].outFrameSize = + init_sbr_dec(sampleRate, + self->SbrChannel[0].frameData.sbr_header.sampleRateMode, + sbrDec, + &(SbrChannel[i].frameData)); + + SbrChannel[i].syncState = UPSAMPLING; + + SbrChannel[i].frameData.sUp = 1; /* reset mode */ + } +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_open.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_open.h new file mode 100644 index 0000000..2eabf34 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_open.h @@ -0,0 +1,109 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_open.h + Functions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_OPEN_H +#define SBR_OPEN_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_sbr_channel.h" +#include "sbr_dec.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void sbr_open(Int32 sampleRate, + SBR_DEC *sbrDec, + SBRDECODER_DATA * self, + bool bDownSampledSbr); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_read_data.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_read_data.cpp new file mode 100644 index 0000000..52cc7aa --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_read_data.cpp @@ -0,0 +1,317 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_read_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + INPUT + + SBRDECODER self, + SBRBITSTREAM * stream, + float *timeData, + int numChannels + + OUTPUT + + errorCode, noError if successful + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + sbr decoder processing, set up SBR decoder phase 2 in case of + different cotrol data + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_read_data.h" +#include "s_bit_buffer.h" +#include "buf_getbits.h" +#include "sbr_get_sce.h" +#include "sbr_get_cpe.h" +#include "sbr_reset_dec.h" +#include "sbr_get_header_data.h" +#include "sbr_crc_check.h" +#include "aac_mem_funcs.h" + + +#include "init_sbr_dec.h" /* !!! */ + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_read_data(SBRDECODER_DATA * self, + SBR_DEC * sbrDec, + SBRBITSTREAM *stream) +{ + SBR_ERROR sbr_err = SBRDEC_OK; + Int32 SbrFrameOK = 1; + Int32 sbrCRCAlwaysOn = 0; + + UInt32 bs_header_flag = 0; + + SBR_HEADER_STATUS headerStatus = HEADER_OK; + + SBR_CHANNEL *SbrChannel = self->SbrChannel; + + int32 zeropadding_bits; + + BIT_BUFFER bitBuf ; + + /* + * evaluate Bitstream + */ + + bitBuf.buffer_word = 0; + bitBuf.buffered_bits = 0; + bitBuf.nrBitsRead = 0; + + bitBuf.char_ptr = stream->sbrElement[0].Data; + bitBuf.bufferLen = (stream->sbrElement[0].Payload) << 3; + + + /* + * we have to skip a nibble because the first element of Data only + * contains a nibble of data ! + */ + buf_getbits(&bitBuf, LEN_NIBBLE); + + if ((stream->sbrElement[0].ExtensionType == SBR_EXTENSION_CRC) || + sbrCRCAlwaysOn) + { + Int32 CRCLen = ((stream->sbrElement[0].Payload - 1) << 3) + 4 - SI_SBR_CRC_BITS; + SbrFrameOK = sbr_crc_check(&bitBuf, CRCLen); + } + + + if (SbrFrameOK) + { + /* + * The sbr data seems ok, if the header flag is set we read the header + * and check if vital parameters have changed since the previous frame. + * If the syncState equals UPSAMPLING, the SBR Tool has not been + * initialised by SBR header data, and can only do upsampling + */ + + bs_header_flag = buf_getbits(&bitBuf, 1); /* read Header flag */ + + if (bs_header_flag) + { + /* + * If syncState == SBR_ACTIVE, it means that we've had a SBR header + * before, and we will compare with the previous header to see if a + * reset is required. If the syncState equals UPSAMPLING this means + * that the SBR-Tool so far is only initialised to do upsampling + * and hence we need to do a reset, and initialise the system + * according to the present header. + */ + + headerStatus = sbr_get_header_data(&(SbrChannel[0].frameData.sbr_header), + &bitBuf, + SbrChannel[0].syncState); + } /* if (bs_header_flag) */ + + + switch (stream->sbrElement[0].ElementID) + { + case SBR_ID_SCE : + + /* change of control data, reset decoder */ + if (headerStatus == HEADER_RESET) + { + sbr_err = sbr_reset_dec(&(SbrChannel[0].frameData), + sbrDec, + self->SbrChannel[0].frameData.sbr_header.sampleRateMode); + + if (sbr_err != SBRDEC_OK) + { + break; + } + /* + * At this point we have a header and the system has been reset, + * hence syncState from now on will be SBR_ACTIVE. + */ + SbrChannel[0].syncState = SBR_ACTIVE; + } + + if ((SbrChannel[0].syncState == SBR_ACTIVE)) + { + sbr_err = sbr_get_sce(&(SbrChannel[0].frameData), + &bitBuf +#ifdef PARAMETRICSTEREO + , self->hParametricStereoDec +#endif + ); + + if (sbr_err != SBRDEC_OK) + { + break; + } + } + + break; + + case SBR_ID_CPE : + + if (bs_header_flag) + { + pv_memcpy(&(SbrChannel[1].frameData.sbr_header), + &(SbrChannel[0].frameData.sbr_header), + sizeof(SBR_HEADER_DATA)); + } + + /* change of control data, reset decoder */ + if (headerStatus == HEADER_RESET) + { + for (Int32 lr = 0 ; lr < 2 ; lr++) + { + sbr_err = sbr_reset_dec(&(SbrChannel[lr].frameData), + sbrDec, + self->SbrChannel[0].frameData.sbr_header.sampleRateMode); + + if (sbr_err != SBRDEC_OK) + { + break; + } + + SbrChannel[lr].syncState = SBR_ACTIVE; + } + } + + if (SbrChannel[0].syncState == SBR_ACTIVE) + { + sbr_err = sbr_get_cpe(&(SbrChannel[0].frameData), + &(SbrChannel[1].frameData), + &bitBuf); + + if (sbr_err != SBRDEC_OK) + { + break; + } + + } + break; + + default: + sbr_err = SBRDEC_ILLEGAL_PLUS_ELE_ID; + break; + } + + } /* if (SbrFrameOK) */ + + /* + * Check that the bits read did not go beyond SBR frame boundaries + */ + + zeropadding_bits = (8 - (bitBuf.nrBitsRead & 0x7)) & 0x7; + + if ((bitBuf.nrBitsRead + zeropadding_bits) > bitBuf.bufferLen) + { + sbr_err = SBRDEC_INVALID_BITSTREAM; + } + + return sbr_err; +} + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_read_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_read_data.h new file mode 100644 index 0000000..b12f8c2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_read_data.h @@ -0,0 +1,121 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_read_data.h + Functions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_READ_DATA +#define SBR_READ_DATA + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "e_sbr_error.h" +#include "s_sbr_channel.h" +#include "s_sbrbitstream.h" +#include "sbr_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + SBR_ERROR sbr_read_data(SBRDECODER_DATA * self, + SBR_DEC * sbrDec, + SBRBITSTREAM *stream); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.cpp new file mode 100644 index 0000000..80c260c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.cpp @@ -0,0 +1,176 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_requantize_envelope_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_constants.h" +#include "sbr_requantize_envelope_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define R_SHIFT 30 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_requantize_envelope_data(SBR_FRAME_DATA * hFrameData) + +{ + Int32 i; + + + Int32 nScaleFactors = hFrameData->nScaleFactors; + Int32 nNoiseFactors = hFrameData->nNoiseFactors; + Int32 ampRes = hFrameData->ampRes; + Int32 *iEnvelope_man = hFrameData->iEnvelope_man; + Int32 *iEnvelope_exp = hFrameData->iEnvelope_exp; + Int32 *sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man; + Int32 *sbrNoiseFloorLevel_exp = hFrameData->sbrNoiseFloorLevel_exp; + + /* + * ampRes could be 0 (resolution step = 1.5 dB) or + * 1 (resolution step = 3 dB) + */ + if (ampRes) + { + /* iEnvelope[i] always positive 6 bits max */ + for (i = 0; i < nScaleFactors; i++) + { + + iEnvelope_exp[i] = iEnvelope_man[i] + 6; + iEnvelope_man[i] = Qfmt(1.000F); + } + } + else + { + /* iEnvelope[i] always positive 7 bits max */ + for (i = 0; i < nScaleFactors; i++) + { + iEnvelope_exp[i] = (iEnvelope_man[i] >> 1) + 6; + if (iEnvelope_man[i] & 0x1) /* odd */ + { + iEnvelope_man[i] = Qfmt(1.41421356237310F); + } + else + { + iEnvelope_man[i] = Qfmt(1.000F); + } + } + + } + for (i = 0; i < nNoiseFactors; i++) + { + /* sbrNoiseFloorLevel[i] varies from -31 to 31 if no coupling is used */ + + sbrNoiseFloorLevel_exp[i] = NOISE_FLOOR_OFFSET - sbrNoiseFloorLevel_man[i]; + sbrNoiseFloorLevel_man[i] = 0x40000000; + } +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.h new file mode 100644 index 0000000..61d889a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.h @@ -0,0 +1,74 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_requantize_envelope_data.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_REQUANTIZE_ENVELOPE_DATA_H +#define SBR_REQUANTIZE_ENVELOPE_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_requantize_envelope_data(SBR_FRAME_DATA * hFrameData); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_reset_dec.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_reset_dec.cpp new file mode 100644 index 0000000..87891f1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_reset_dec.cpp @@ -0,0 +1,262 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_reset_dec.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + resets sbr decoder structure +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#ifdef AAC_PLUS + +#include "sbr_dec.h" + +#include "pv_log2.h" +#include "fxp_mul32.h" + + +#include "sbr_reset_dec.h" +#include "sbr_find_start_andstop_band.h" +#include "sbr_update_freq_scale.h" +#include "sbr_downsample_lo_res.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_reset_dec(SBR_FRAME_DATA * hFrameData, + SBR_DEC * sbrDec, + Int32 upsampleFac) +{ + + SBR_ERROR err = SBRDEC_OK; + Int lsbM; + Int lsb; + Int usb; + Int32 i; + Int32 tmp_q1; + + SBR_HEADER_DATA *headerData = &(hFrameData->sbr_header); + Int32 samplingFreq = sbrDec->outSampleRate; + + hFrameData->reset_flag = 1; + + /*Calculate master frequency function */ + err = sbr_find_start_andstop_band(samplingFreq, + headerData->startFreq, + headerData->stopFreq, + &lsbM, + &usb); + + if (err != SBRDEC_OK) + { + return err; + } + + /* Calculate new v_k_master if needed */ + if (headerData->masterStatus == MASTER_RESET) + { + sbr_update_freq_scale(sbrDec->V_k_master, + &(sbrDec->Num_Master), + lsbM, + usb, + headerData->freqScale, + headerData->alterScale, + 0); + + } + + /*Derive Hiresolution from master frequency function*/ + + sbrDec->NSfb[HI] = sbrDec->Num_Master - headerData->xover_band; + + for (i = headerData->xover_band; i <= sbrDec->Num_Master; i++) + { + sbrDec->FreqBandTable[HI][i-headerData->xover_band] = (Int)sbrDec->V_k_master[i]; + } + + + if ((sbrDec->NSfb[HI] & 0x01) == 0) /* if even number of hires bands */ + { + + sbrDec->NSfb[LO] = sbrDec->NSfb[HI] >> 1; + /* Use every second lo-res=hi-res[0,2,4...] */ + for (i = 0; i <= sbrDec->NSfb[LO]; i++) + { + sbrDec->FreqBandTable[LO][i] = sbrDec->FreqBandTable[HI][(i<<1)]; + } + } + else + { /* odd number of hi-res which means xover is odd */ + + sbrDec->NSfb[LO] = (sbrDec->NSfb[HI] + 1) >> 1; + /* Use lo-res=hi-res[0,1,3,5 ...] */ + sbrDec->FreqBandTable[LO][0] = sbrDec->FreqBandTable[HI][0]; + for (i = 1; i <= sbrDec->NSfb[LO]; i++) + { + sbrDec->FreqBandTable[LO][i] = sbrDec->FreqBandTable[HI][(i<<1)-1]; + } + + } + + lsb = sbrDec->FreqBandTable[LOW_RES][0]; + usb = sbrDec->FreqBandTable[LOW_RES][sbrDec->NSfb[LOW_RES]]; + + sbrDec->lowSubband = lsb; + sbrDec->highSubband = usb; + sbrDec->noSubbands = usb - lsb; + + if ((lsb > 32) || (sbrDec->noSubbands <= 0)) + { + return SBRDEC_ILLEGAL_SCFACTORS; /* invalid bands */ + } + + /* Calculate number of noise bands */ + if (headerData->noise_bands == 0) + { + sbrDec->NoNoiseBands = 1; + } + else /* Calculate number of noise bands 1,2 or 3 bands/octave */ + { + + if (! lsb) + { + return SBRDEC_ILLEGAL_SCFACTORS; /* avoid div by 0 */ + } + + tmp_q1 = pv_log2((usb << 20) / lsb); + + tmp_q1 = fxp_mul32_Q15(headerData->noise_bands, tmp_q1); + + sbrDec->NoNoiseBands = (tmp_q1 + 16) >> 5; + + if (sbrDec->NoNoiseBands == 0) + { + sbrDec->NoNoiseBands = 1; + } + } + + headerData->noNoiseBands = sbrDec->NoNoiseBands; + + /* Get noise bands */ + sbr_downsample_lo_res(sbrDec->FreqBandTableNoise, + sbrDec->NoNoiseBands, + sbrDec->FreqBandTable[LO], + sbrDec->NSfb[LO]); + + sbrDec->sbStopCodec = sbrDec->lowSubband; + + if (sbrDec->sbStopCodec > (upsampleFac << 5)) + { + sbrDec->sbStopCodec = (upsampleFac << 5); + } + + hFrameData->nSfb[LO] = sbrDec->NSfb[LO]; + hFrameData->nSfb[HI] = sbrDec->NSfb[HI]; + hFrameData->nNfb = hFrameData->sbr_header.noNoiseBands; + hFrameData->offset = ((hFrameData->nSfb[LO]) << 1) - hFrameData->nSfb[HI]; + + return (SBRDEC_OK); +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_reset_dec.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_reset_dec.h new file mode 100644 index 0000000..2dc0416 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_reset_dec.h @@ -0,0 +1,112 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_reset_dec.h + Functions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_RESET_DEC_H +#define SBR_RESET_DEC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "s_sbr_frame_data.h" +#include "sbr_dec.h" +#include "e_sbr_error.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +SBR_ERROR sbr_reset_dec(SBR_FRAME_DATA * hFrameData, + SBR_DEC * sbrDec, + Int32 upsampleFac); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.cpp new file mode 100644 index 0000000..428b59a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.cpp @@ -0,0 +1,357 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_update_freq_scale.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "sbr_update_freq_scale.h" +#include "shellsort.h" + +#include "pv_pow2.h" +#include "pv_log2.h" + +#include "fxp_mul32.h" +#define R_SHIFT 30 +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) +#define Q28fmt(x) (Int32)(x*((Int32)1<<28) + (x>=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void sbr_update_freq_scale(Int32 * v_k_master, + Int32 *h_num_bands, + const Int32 lsbM, + const Int32 usb, + const Int32 freqScale, + const Int32 alterScale, + const Int32 channelOffset) +{ + Int32 i; + Int32 numBands = 0; + Int32 numBands2; + Int32 tmp_q1; + + if (freqScale > 0) /*Bark mode*/ + { + Int32 reg; + Int32 regions; + Int32 b_p_o; + Int32 k[3]; + Int32 d[MAX_SECOND_REGION]; + Int32 d2[MAX_SECOND_REGION]; + Int32 w[2] = {Q_fmt(1.0F), Q_fmt(1.0F)}; + + + k[0] = lsbM; + k[1] = usb; + k[2] = usb; + + b_p_o = (freqScale == 1) ? 12 : 8; + b_p_o = (freqScale == 2) ? 10 : b_p_o; + + w[1] = (alterScale == 0) ? Q_fmt(0.5f) : Q_fmt(0.384615384615386f); + + if (usb > fxp_mul32_Q28(lsbM, Q28fmt(2.2449))) + { + regions = 2; + k[1] = (lsbM << 1); + } + else + { + regions = 1; + } + + *h_num_bands = 0; + for (reg = 0; reg < regions; reg++) + { + if (reg == 0) + { + + tmp_q1 = pv_log2((k[1] << 20) / k[0]); + + tmp_q1 = fxp_mul32_Q15(tmp_q1, b_p_o); + tmp_q1 = (tmp_q1 + 32) >> 6; + + numBands = tmp_q1 << 1; + + + CalcBands(d, k[0], k[1], numBands); /* CalcBands => d */ + shellsort(d, numBands); /* SortBands sort d */ + cumSum(k[0] - channelOffset, + d, + numBands, + (v_k_master + *h_num_bands)); /* cumsum */ + + *h_num_bands += numBands; /* Output nr of bands */ + } + else + { + tmp_q1 = pv_log2((k[reg + 1] << 20) / k[reg]); + + tmp_q1 = fxp_mul32_Q30(tmp_q1, w[reg]); + tmp_q1 = fxp_mul32_Q15(tmp_q1, b_p_o); + tmp_q1 = (tmp_q1 + 16) >> 5; + + numBands2 = tmp_q1 << 1; + + CalcBands(d2, k[reg], k[reg+1], numBands2); /* CalcBands => d */ + shellsort(d2, numBands2); /* SortBands sort d */ + if (d[numBands-1] > d2[0]) + { + + Int32 change = d[numBands-1] - d2[0]; + /* Limit the change so that the last band cannot get narrower than the first one */ + if (change > (d2[numBands2-1] - d2[0]) >> 1) + { + change = (d2[numBands2-1] - d2[0]) >> 1; + } + + d2[0] += change; + d2[numBands2-1] -= change; + shellsort(d2, numBands2); + + } + cumSum(k[reg] - channelOffset, + d2, + numBands2, + v_k_master + *h_num_bands); /* cumsum */ + + *h_num_bands += numBands2; /* Output nr of bands */ + } + } + } + else + { /* Linear mode */ + Int32 k2_achived; + Int32 k2_diff; + Int32 diff_tot[MAX_OCTAVE + MAX_SECOND_REGION]; + Int32 dk; + Int32 incr = 0; + + + if (alterScale) + { + numBands = (usb - lsbM) >> 1; + dk = 1; + k2_achived = lsbM + numBands; + } + else + { + numBands = usb - lsbM; + if (numBands & 0x1) /* equivalent rounding */ + { + numBands--; + } + dk = 2; + k2_achived = lsbM + (numBands << 1); + } + + k2_diff = usb - k2_achived; + + for (i = 0; i < numBands; i++) + { + diff_tot[i] = dk; + } + + if (k2_diff < 0) /* If linear scale wasn't achived */ + { + incr = 1; /* and we got too large SBR area */ + i = 0; + } + + if (k2_diff > 0) /* If linear scale wasn't achived */ + { + incr = -1; /* and we got too small SBR area */ + i = numBands - 1; + } + + /* Adjust diff vector to get spec. SBR range */ + while (k2_diff != 0) + { + diff_tot[i] -= incr; + i += incr; + k2_diff += incr; + } + + cumSum(lsbM, + diff_tot, + numBands, + v_k_master); /* cumsum */ + + *h_num_bands = numBands; /* Output nr of bands */ + } +} + + +void CalcBands(Int32 * diff, + Int32 start, + Int32 stop, + Int32 num_bands) +{ + Int32 i; + Int32 previous; + Int32 current; + Int32 tmp_q1; + + + previous = start; + + for (i = 1; i <= num_bands; i++) + { + /* float temp=(start * pow( (float)stop/start, (float)i/num_bands)); */ + + tmp_q1 = pv_log2((stop << 20) / start); + + tmp_q1 = fxp_mul32_Q20(tmp_q1, (i << 27) / num_bands); + tmp_q1 = pv_pow2(tmp_q1); + + tmp_q1 = fxp_mul32_Q20(tmp_q1, start); + + current = (tmp_q1 + 16) >> 5; + + diff[i-1] = current - previous; + previous = current; + } + +} /* End CalcBands */ + + +void cumSum(Int32 start_value, + Int32 * diff, + Int32 length, + Int32 * start_adress) +{ + Int32 i; + Int32 *pt_start_adress = start_adress; + Int32 *pt_start_adress_1 = start_adress; + Int32 *pt_diff = diff; + + if (length > 0) /* avoid possible error on loop */ + { + *(pt_start_adress_1++) = start_value; + + for (i = (length >> 1); i != 0; i--) + { + *(pt_start_adress_1++) = *(pt_start_adress++) + *(pt_diff++); + *(pt_start_adress_1++) = *(pt_start_adress++) + *(pt_diff++); + } + + if (length&1) + { + *(pt_start_adress_1) = *(pt_start_adress) + *(pt_diff); + } + } + +} /* End cumSum */ + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.h new file mode 100644 index 0000000..221460d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_update_freq_scale.h + Functions: + get_dse + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_UPDATE_FREQ_SCALE_H +#define SBR_UPDATE_FREQ_SCALE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define MAX_OCTAVE 29 +#define MAX_SECOND_REGION 50 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_update_freq_scale(Int32 * v_k_master, + Int32 *h_num_bands, + const Int32 lsbM, + const Int32 usb, + const Int32 freqScale, + const Int32 alterScale, + const Int32 channelOffset); + + +void CalcBands(Int32 * diff, + Int32 start, + Int32 stop, + Int32 num_bands); + +void cumSum(Int32 start_value, + Int32 * diff, + Int32 length, + Int32 * start_adress); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/set_mc_info.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/set_mc_info.cpp new file mode 100644 index 0000000..e481673 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/set_mc_info.cpp @@ -0,0 +1,278 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: set_mc_info.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pMC_Info = pointer to structure MC_Info that holds information of + multiple channels' configurations + Data type pointer to MC_Info + + objectType = variable that holds the Audio Object Type of current + file/bitstream. + Data type Int + + sampling_rate_idx = variable that indicates the sampling rate of the + source file being encoded + Data Type Int + + tag = variable that stores the element instance tag of the + first (front) channel element. + Data type Int + + is_cpe = variable that indicates if a Channel Pair Element (CPE) + or a Single Channel Element (SCE) is used. + Data type Int (maybe Boolean) + + pWinSeqInfo = array of pointers that points to structures holding + frame information of long and short window sequences. + Data type FrameInfo + + pSfbwidth128 = array that will store the scalefactor bandwidth of + short window sequence frame. + Data type Int array + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + return SUCCESS + + Pointers and Buffers Modified: + pMC_Info->nch contains the number of channels depending + upon if CPE or SCE is used + pMC_Info->objectType contents updated with the decoded Audio + Object Type + + pMC_Info->ch_info.tag contents updated with the value of decoded + channel element tag + + PMC_Info->ch_info.cpe contents updated depending upon if CPE or + SCE is used + + pWinSeqInfo contents updated by calling infoinit if + sampling_rate_idx is different from + previous value + + pSfbWidth128 contents updated by calling infoinit if + sampling_rate_idx is different from + previous value + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function initializes the channel configuration information. The + structure MC_Info stores the number of channels, channel element tag. + If sampling rate index is different from the previous value, + The frame information will be updated by calling infoinit.c + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall update the relevant information on channel configs + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 1 p20 Table 1.6.3 + Subpart 4 p30 5.1.2.1 + Subpart 4 p31 4.5.2.1.1 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pMC_Info->nch = 0; + + pMC_Info->profile = objectType; + + IF (pMC_Info->sampling_rate_idx != sampling_rate_idx) + THEN + pMC_Info->sampling_rate_idx = sampling_rate_idx; + + CALL infoinit( + samp_rate_idx = sampling_rate_idx + ppWin_seq_info= pWinSeqInfo + pSfbwidth128 = pSfbwidth128) + MODIFYING(pWinSeqInfo, pSfbwidth128) + RETURNING(None) + ENDIF + + pCh_Info = &pMC_Info->ch_info[0]; + pCh_Info->tag = tag; + + IF (is_cpe == FALSE) + THEN + pCh_Info->cpe = FALSE; + + pMC_Info->nch = 1; + + ELSE + pCh_Info->cpe = TRUE; + pCh_Info = &pMC_Info->ch_info[1]; + pCh_Info->tag = tag; + pCh_Info->cpe = TRUE; + + pMC_Info->nch = 2; + + ENDIF + + RETURN(SUCCESS) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "set_mc_info.h" +#include "huffman.h" +#include "s_ch_info.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int set_mc_info( + MC_Info *pMC_Info, + const tMP4AudioObjectType audioObjectType, /* used to be profile */ + const Int sampling_rate_idx, + const Int tag, /* always pass-in last element's value */ + const Int is_cpe, + FrameInfo *pWinSeqInfo[], + Int sfbwidth128[] +) +{ + Ch_Info *pCh_Info; /*optional task: eliminate this structure */ + + /* + * audioObjectType and sampling rate + * re-configure if new sampling rate + * + */ + pMC_Info->audioObjectType = audioObjectType; + + if (pMC_Info->sampling_rate_idx != sampling_rate_idx) + { + pMC_Info->sampling_rate_idx = sampling_rate_idx; + + Int status; + status = infoinit(sampling_rate_idx, + pWinSeqInfo, + sfbwidth128); + if (SUCCESS != status) + { + return 1; + } + } + + /* + * first setup values for mono config, Single Channel Element (SCE) + * then if stereo, go inside if(is_cpe != FALSE) branch to setup + * values for stereo. + * set the channel counts + * save tag for left channel + */ + pMC_Info->nch = 1 + is_cpe; + + pCh_Info = &pMC_Info->ch_info[0]; + pCh_Info->tag = tag; + pCh_Info->cpe = is_cpe; + + /* This if branch maybe deleted in the future */ + if (is_cpe != FALSE) + { + /* Channel Pair Element (CPE) */ + /* right channel*/ + pCh_Info = &pMC_Info->ch_info[1]; + pCh_Info->cpe = TRUE; + + } + + + return(SUCCESS); /* possible future error checkings */ +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/set_mc_info.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/set_mc_info.h new file mode 100644 index 0000000..8d8cf16 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/set_mc_info.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: set_mc_info.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes function declaration for set_mc_info.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SET_MC_INFO_H +#define SET_MC_INFO_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_mc_info.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int set_mc_info( + MC_Info *pMC_Info, + const tMP4AudioObjectType objectType, /* used to be profile */ + const Int sampling_rate_idx, + const Int tag, /* always pass-in last element's value */ + const Int is_cpe, + FrameInfo *pWinSeqInfo[], + Int pSfbwidth128[] +); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sfb.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sfb.cpp new file mode 100644 index 0000000..6a0cff0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sfb.cpp @@ -0,0 +1,234 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sfb.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function defines the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + Subpart 4 p66 (sfb tables) + p111 (4.6.10) + p200 (Annex 4.B.5) + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "sfb.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const Int16 sfb_96_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 96, 108, 120, + 132, 144, 156, 172, 188, 212, 240, + 276, 320, 384, 448, 512, 576, 640, + 704, 768, 832, 896, 960, 1024 +}; /* 41 scfbands */ + +const Int16 sfb_64_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 100, 112, 124, + 140, 156, 172, 192, 216, 240, 268, + 304, 344, 384, 424, 464, 504, 544, + 584, 624, 664, 704, 744, 784, 824, + 864, 904, 944, 984, 1024 +}; /* 41 scfbands 47 */ + +const Int16 sfb_64_128[] = +{ + 4, 8, 12, 16, 20, 24, 32, + 40, 48, 64, 92, 128 +}; /* 12 scfbands */ + + +const Int16 sfb_48_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 48, 56, 64, 72, + 80, 88, 96, 108, 120, 132, 144, + 160, 176, 196, 216, 240, 264, 292, + 320, 352, 384, 416, 448, 480, 512, + 544, 576, 608, 640, 672, 704, 736, + 768, 800, 832, 864, 896, 928, 1024 +}; +/* 49 scfbands*/ + +const Int16 sfb_48_128[] = +{ + 4, 8, 12, 16, 20, 28, 36, + 44, 56, 68, 80, 96, 112, 128 +}; /* 14 scfbands */ + +const Int16 sfb_32_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 48, 56, 64, 72, + 80, 88, 96, 108, 120, 132, 144, + 160, 176, 196, 216, 240, 264, 292, + 320, 352, 384, 416, 448, 480, 512, + 544, 576, 608, 640, 672, 704, 736, + 768, 800, 832, 864, 896, 928, 960, + 992, 1024 +}; /* 51 scfbands */ + +const Int16 sfb_24_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 52, 60, 68, + 76, 84, 92, 100, 108, 116, 124, + 136, 148, 160, 172, 188, 204, 220, + 240, 260, 284, 308, 336, 364, 396, + 432, 468, 508, 552, 600, 652, 704, + 768, 832, 896, 960, 1024 +}; /* 47 scfbands */ + +const Int16 sfb_24_128[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 36, 44, 52, 64, 76, 92, 108, + 128 +}; /* 15 scfbands */ + +const Int16 sfb_16_1024[] = +{ + 8, 16, 24, 32, 40, 48, 56, + 64, 72, 80, 88, 100, 112, 124, + 136, 148, 160, 172, 184, 196, 212, + 228, 244, 260, 280, 300, 320, 344, + 368, 396, 424, 456, 492, 532, 572, + 616, 664, 716, 772, 832, 896, 960, + 1024 +}; /* 43 scfbands */ + +const Int16 sfb_16_128[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 40, 48, 60, 72, 88, 108, + 128 +}; /* 15 scfbands */ + +const Int16 sfb_8_1024[] = +{ + 12, 24, 36, 48, 60, 72, 84, + 96, 108, 120, 132, 144, 156, 172, + 188, 204, 220, 236, 252, 268, 288, + 308, 328, 348, 372, 396, 420, 448, + 476, 508, 544, 580, 620, 664, 712, + 764, 820, 880, 944, 1024 +}; /* 40 scfbands */ + +const Int16 sfb_8_128[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 36, 44, 52, 60, 72, 88, 108, + 128 +}; /* 15 scfbands */ + +const SR_Info samp_rate_info[12] = +{ + /* sampling_frequency, #long sfb, #short sfb */ + /* samp_rate, nsfb1024, nsfb128 */ + {96000, 41, 12}, /* 96000 */ + {88200, 41, 12}, /* 88200 */ + {64000, 47, 12}, /* 64000 */ + {48000, 49, 14}, /* 48000 */ + {44100, 49, 14}, /* 44100 */ + {32000, 51, 14}, /* 32000 */ + {24000, 47, 15}, /* 24000 */ + {22050, 47, 15}, /* 22050 */ + {16000, 43, 15}, /* 16000 */ + {12000, 43, 15}, /* 12000 */ + {11025, 43, 15}, /* 11025 */ + { 8000, 40, 15}, /* 8000 */ +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sfb.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sfb.h new file mode 100644 index 0000000..179e88c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/sfb.h @@ -0,0 +1,107 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sfb.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + this file declares the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SFB_H +#define SFB_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sr_info.h" +#include "e_progconfigconst.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const Int16 sfb_96_1024[]; /* 41 scfbands */ + +extern const Int16 sfb_64_1024[]; /* 41 scfbands 47 */ + +extern const Int16 sfb_64_128[]; /* 12 scfbands */ + + +extern const Int16 sfb_48_1024[]; /* 49 scfbands */ + +extern const Int16 sfb_48_128[]; /* 14 scfbands */ + +extern const Int16 sfb_32_1024[]; /* 51 scfbands */ + +extern const Int16 sfb_24_1024[]; /* 47 scfbands */ + +extern const Int16 sfb_24_128[]; /* 15 scfbands */ + +extern const Int16 sfb_16_1024[]; /* 43 scfbands */ + +extern const Int16 sfb_16_128[]; /* 15 scfbands */ + +extern const Int16 sfb_8_1024[]; /* 40 scfbands */ + +extern const Int16 sfb_8_128[]; /* 15 scfbands */ + +extern const SR_Info samp_rate_info[12]; + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/shellsort.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/shellsort.cpp new file mode 100644 index 0000000..8cec406 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/shellsort.cpp @@ -0,0 +1,131 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: shellsort.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Sorting routine +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "shellsort.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void shellsort(Int32 in[], Int32 n) +{ + + Int32 i; + Int32 j; + Int32 v; + Int32 inc = 1; + + do + { + inc = 3 * inc + 1; + } + while (inc <= n); + + do + { + inc = inc / 3; + for (i = inc + 1; i <= n; i++) + { + v = in[i-1]; + j = i; + while (in[j-inc-1] > v) + { + in[j-1] = in[j-inc-1]; + j -= inc; + if (j <= inc) + { + break; + } + } + in[j-1] = v; + } + } + while (inc > 1); + +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/shellsort.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/shellsort.h new file mode 100644 index 0000000..21d2dc4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/shellsort.h @@ -0,0 +1,75 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: shellsort.h + Functions: + get_dse + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SHELLSORT_H +#define SHELLSORT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void shellsort(Int32 in[], Int32 n); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/synthesis_sub_band.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/synthesis_sub_band.cpp new file mode 100644 index 0000000..7215383 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/synthesis_sub_band.cpp @@ -0,0 +1,488 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: synthesis_sub_band.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 vec[], Input vector, 32-bit + const Int32 *cosTerms, Cosine Terms + Int32 *scratch_mem Scratch memory + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement root squared of a number + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" +#include "dct64.h" +#include "synthesis_sub_band.h" +#include "mdst.h" +#include "dct16.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define Qfmt_30(x) (Int32)(x*((Int32)(1<<30)) + (x>=0?0.5F:-0.5F)) +#define Qfmt_25(x) (Int32)(x*((Int32)(1<<25))*(1.5625F) + (x>=0?0.5F:-0.5F)) + +#define SCALE_DOWN_LP Qfmt_30(0.10606601717250F) /* 3/40*sqrt(2) */ +#define SCALE_DOWN_HQ Qfmt_30(0.00848528137380F) /* 3/320*sqrt(2) */ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const Int32 CosTable_64[64] = +{ + Qfmt_25(0.50003765191555F), Qfmt_25(40.74468810335183F), Qfmt_25(0.50033903744282F), Qfmt_25(13.58429025728446F), + Qfmt_25(0.50094271763809F), Qfmt_25(8.15384860246681F), Qfmt_25(0.50185051748424F), Qfmt_25(5.82768837784465F), + Qfmt_25(0.50306519130137F), Qfmt_25(4.53629093696936F), Qfmt_25(0.50459044322165F), Qfmt_25(3.71524273832697F), + Qfmt_25(0.50643095492855F), Qfmt_25(3.14746219178191F), Qfmt_25(0.50859242104981F), Qfmt_25(2.73164502877394F), + Qfmt_25(0.51108159270668F), Qfmt_25(2.41416000025008F), Qfmt_25(0.51390632984754F), Qfmt_25(2.16395781875198F), + Qfmt_25(0.51707566313349F), Qfmt_25(1.96181784857117F), Qfmt_25(0.52059986630189F), Qfmt_25(1.79520521907789F), + Qfmt_25(0.52449054011472F), Qfmt_25(1.65559652426412F), Qfmt_25(0.52876070920749F), Qfmt_25(1.53699410085250F), + Qfmt_25(0.53342493339713F), Qfmt_25(1.43505508844143F), Qfmt_25(0.53849943529198F), Qfmt_25(1.34655762820629F), + Qfmt_25(0.54400224638178F), Qfmt_25(1.26906117169912F), Qfmt_25(0.54995337418324F), Qfmt_25(1.20068325572942F), + Qfmt_25(0.55637499348989F), Qfmt_25(1.13994867510150F), Qfmt_25(0.56329166534170F), Qfmt_25(1.08568506425801F), + Qfmt_25(0.57073058801215F), Qfmt_25(1.03694904091039F), Qfmt_25(0.57872188513482F), Qfmt_25(0.99297296126755F), + Qfmt_25(0.58729893709379F), Qfmt_25(0.95312587439212F), Qfmt_25(0.59649876302446F), Qfmt_25(0.91688444618465F), + Qfmt_25(0.60636246227215F), Qfmt_25(0.88381100455962F), Qfmt_25(0.61693572600507F), Qfmt_25(0.85353675100661F), + Qfmt_25(0.62826943197077F), Qfmt_25(0.82574877386279F), Qfmt_25(0.64042033824166F), Qfmt_25(0.80017989562169F), + Qfmt_25(0.65345189537513F), Qfmt_25(0.77660065823396F), Qfmt_25(0.66743520092634F), Qfmt_25(0.75481293911653F), + Qfmt_25(0.68245012597642F), Qfmt_25(0.73464482364786F), Qfmt_25(0.69858665064723F), Qfmt_25(0.71594645497057F), +}; +#define MAX_16BITS_INT 0x7FFF + +inline Int16 saturate16(Int32 sample) +{ + if ((sample >> 15) ^(sample >> 31)) + { + sample = MAX_16BITS_INT ^(sample >> 31); + } + return (Int16)(sample - (sample >> 15)); +} + + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void synthesis_sub_band_LC(Int32 Sr[], Int16 data[]) +{ + + Int32 *temp_o1 = (Int32 *) & data[0]; + + Int i; + Int32 *pt_temp_e; + Int32 *pt_temp_o = temp_o1; + Int32 *pt_temp_x = &Sr[63]; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp11; + + Int16 *pt_data_1; + Int16 *pt_data_2; + + Int32 *pt_Sr_1 = Sr; + Int16 tmp1; + Int16 tmp2; + Int16 tmp11; + Int16 tmp22; + const Int32 *pt_cosTerms = CosTable_48; + + + temp2 = *(pt_temp_x--); + for (i = 20; i != 0; i--) + { + temp1 = *(pt_Sr_1); + temp3 = *(pt_cosTerms++); + *(pt_Sr_1++) = temp1 + temp2; + *(pt_temp_o++) = fxp_mul32_Q31((temp1 - temp2), temp3) << 1; + temp2 = *(pt_temp_x--); + } + + for (i = 12; i != 0; i--) + { + temp1 = *(pt_Sr_1); + temp3 = *(pt_cosTerms++); + *(pt_Sr_1++) = temp1 + temp2; + *(pt_temp_o++) = fxp_mul32_Q26((temp1 - temp2), temp3); + temp2 = *(pt_temp_x--); + } + + + pv_split_LC(temp_o1, &Sr[32]); + + dct_16(temp_o1, 1); // Even terms + dct_16(&Sr[32], 1); // Odd terms + + /* merge */ + + + pt_Sr_1 = &temp_o1[31]; + pt_temp_e = &temp_o1[15]; + pt_temp_o = &Sr[47]; + + temp1 = *(pt_temp_o--); + *(pt_Sr_1--) = temp1; + for (i = 5; i != 0; i--) + { + temp2 = *(pt_temp_o--); + *(pt_Sr_1--) = *(pt_temp_e--); + *(pt_Sr_1--) = temp1 + temp2; + temp3 = *(pt_temp_o--); + *(pt_Sr_1--) = *(pt_temp_e--); + *(pt_Sr_1--) = temp2 + temp3; + temp1 = *(pt_temp_o--); + *(pt_Sr_1--) = *(pt_temp_e--); + *(pt_Sr_1--) = temp1 + temp3; + } + + + pv_split_LC(Sr, &Sr[32]); + + dct_16(Sr, 1); // Even terms + dct_16(&Sr[32], 1); // Odd terms + + + pt_temp_x = &temp_o1[31]; + pt_temp_e = &Sr[15]; + pt_temp_o = &Sr[47]; + + pt_data_1 = &data[95]; + + temp2 = *(pt_temp_x--); + temp11 = *(pt_temp_x--); + temp1 = *(pt_temp_o--); + + *(pt_data_1--) = saturate16(fxp_mul32_Q31(temp2, SCALE_DOWN_LP)); + *(pt_data_1--) = saturate16(fxp_mul32_Q31(temp1, SCALE_DOWN_LP)); + + for (i = 5; i != 0; i--) + { + *(pt_data_1--) = saturate16(fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP)); + temp3 = *(pt_temp_x--); + *(pt_data_1--) = saturate16(fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP)); + temp2 = *(pt_temp_o--); + *(pt_data_1--) = saturate16(fxp_mul32_Q31((temp11 + temp3), SCALE_DOWN_LP)); + temp11 = *(pt_temp_x--); + *(pt_data_1--) = saturate16(fxp_mul32_Q31((temp1 + temp2), SCALE_DOWN_LP)); + + + *(pt_data_1--) = saturate16(fxp_mul32_Q31((temp11 + temp3), SCALE_DOWN_LP)); + temp1 = *(pt_temp_x--); + *(pt_data_1--) = saturate16(fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP)); + temp3 = *(pt_temp_o--); + *(pt_data_1--) = saturate16(fxp_mul32_Q31((temp11 + temp1), SCALE_DOWN_LP)); + temp11 = *(pt_temp_x--); + *(pt_data_1--) = saturate16(fxp_mul32_Q31((temp2 + temp3), SCALE_DOWN_LP)); + + + *(pt_data_1--) = saturate16(fxp_mul32_Q31((temp11 + temp1), SCALE_DOWN_LP)); + temp2 = *(pt_temp_x--); + *(pt_data_1--) = saturate16(fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP)); + temp1 = *(pt_temp_o--); + *(pt_data_1--) = saturate16(fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP)); + temp11 = *(pt_temp_x--); + *(pt_data_1--) = saturate16(fxp_mul32_Q31((temp1 + temp3), SCALE_DOWN_LP)); + } + + *(pt_data_1--) = saturate16(fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP)); + *(pt_data_1--) = saturate16(fxp_mul32_Q31(*(pt_temp_e), SCALE_DOWN_LP)); + + + /* ---- merge ends---- */ + + + pt_data_1 = &data[95]; + pt_data_2 = &data[96]; + + *(pt_data_2++) = 0; + tmp1 = *(pt_data_1--); + tmp2 = *(pt_data_1--); + tmp11 = *(pt_data_1--); + tmp22 = *(pt_data_1--); + + for (i = 7; i != 0; i--) + { + *(pt_data_2++) = -(tmp1); + *(pt_data_2++) = -(tmp2); + *(pt_data_2++) = -(tmp11); + *(pt_data_2++) = -(tmp22); + + tmp1 = *(pt_data_1--); + tmp2 = *(pt_data_1--); + tmp11 = *(pt_data_1--); + tmp22 = *(pt_data_1--); + } + + *(pt_data_2++) = -(tmp1); + *(pt_data_2++) = -(tmp2); + *(pt_data_2++) = -(tmp11); + + pt_data_2 = &data[0]; + + *(pt_data_2++) = tmp22; + tmp1 = *(pt_data_1--); + tmp2 = *(pt_data_1--); + tmp11 = *(pt_data_1--); + tmp22 = *(pt_data_1--); + + for (i = 7; i != 0; i--) + { + *(pt_data_2++) = tmp1; + *(pt_data_2++) = tmp2; + *(pt_data_2++) = tmp11; + *(pt_data_2++) = tmp22; + tmp1 = *(pt_data_1--); + tmp2 = *(pt_data_1--); + tmp11 = *(pt_data_1--); + tmp22 = *(pt_data_1--); + } + + *(pt_data_2++) = tmp1; + *(pt_data_2++) = tmp2; + *(pt_data_2++) = tmp11; + *(pt_data_2) = tmp22; + +} + + +void synthesis_sub_band_LC_down_sampled(Int32 Sr[], Int16 data[]) +{ + + Int i ; + Int16 *pt_data_1; + + pt_data_1 = &data[0]; + + dct_32(Sr); + + for (i = 0; i < 16; i++) + { + pt_data_1[ i] = (Int16)(Sr[16-i] >> 5); + pt_data_1[16+i] = (Int16)(Sr[i] >> 5); + pt_data_1[32+i] = (Int16)(Sr[16+i] >> 5); + } + for (i = 0; i < 15; i++) + { + pt_data_1[49+i] = (Int16)(-Sr[31-i] >> 5); + } + pt_data_1[48] = 0; +} + + +#ifdef HQ_SBR + +void synthesis_sub_band(Int32 Sr[], Int32 Si[], Int16 data[]) +{ + + + Int32 i ; + Int16 *pt_data_1; + Int16 *pt_data_2; + Int32 *pt_Sr_1; + Int32 *pt_Sr_2; + Int32 *pt_Si_1; + Int32 *pt_Si_2; + + Int32 tmp1; + Int32 tmp2; + Int32 tmp3; + Int32 tmp4; + + Int32 cosx; + const Int32 *pt_CosTable = CosTable_64; + + + pt_Sr_1 = &Sr[0]; + pt_Sr_2 = &Sr[63]; + + pt_Si_1 = &Si[0]; + pt_Si_2 = &Si[63]; + + + tmp3 = *pt_Sr_1; + + for (i = 32; i != 0; i--) + { + tmp4 = *pt_Si_2; + cosx = *(pt_CosTable++); + *(pt_Sr_1++) = fxp_mul32_Q31(tmp3, cosx); + tmp3 = *pt_Si_1; + *(pt_Si_1++) = fxp_mul32_Q31(tmp4, cosx); + tmp4 = *pt_Sr_2; + cosx = *(pt_CosTable++); + *(pt_Si_2--) = fxp_mul32_Q31(tmp3, cosx); + *(pt_Sr_2--) = fxp_mul32_Q31(tmp4, cosx); + tmp3 = *pt_Sr_1; + } + + + dct_64(Sr, (Int32 *)data); + dct_64(Si, (Int32 *)data); + + + pt_data_1 = &data[0]; + pt_data_2 = &data[127]; + + pt_Sr_1 = &Sr[0]; + pt_Si_1 = &Si[0]; + + tmp1 = *(pt_Sr_1++); + tmp3 = *(pt_Sr_1++); + tmp2 = *(pt_Si_1++); + tmp4 = *(pt_Si_1++); + + for (i = 32; i != 0; i--) + { + *(pt_data_1++) = (Int16) fxp_mul32_Q31((tmp2 - tmp1), SCALE_DOWN_HQ); + *(pt_data_1++) = (Int16) fxp_mul32_Q31(-(tmp3 + tmp4), SCALE_DOWN_HQ); + *(pt_data_2--) = (Int16) fxp_mul32_Q31((tmp1 + tmp2), SCALE_DOWN_HQ); + *(pt_data_2--) = (Int16) fxp_mul32_Q31((tmp3 - tmp4), SCALE_DOWN_HQ); + + tmp1 = *(pt_Sr_1++); + tmp3 = *(pt_Sr_1++); + tmp2 = *(pt_Si_1++); + tmp4 = *(pt_Si_1++); + } + +} + + +const Int32 exp_m0_25_phi[32] = +{ + + 0x7FFEFE6E, 0x7FEAFB4A, 0x7FC2F827, 0x7F87F505, + 0x7F38F1E4, 0x7ED6EEC6, 0x7E60EBAB, 0x7DD6E892, + 0x7D3AE57D, 0x7C89E26D, 0x7BC6DF61, 0x7AEFDC59, + 0x7A06D958, 0x790AD65C, 0x77FBD367, 0x76D9D079, + 0x75A6CD92, 0x7460CAB2, 0x7308C7DB, 0x719EC50D, + 0x7023C248, 0x6E97BF8C, 0x6CF9BCDA, 0x6B4BBA33, + 0x698CB796, 0x67BDB505, 0x65DEB27F, 0x63EFB005, + 0x61F1AD97, 0x5FE4AB36, 0x5DC8A8E2, 0x5B9DA69C +}; + +void synthesis_sub_band_down_sampled(Int32 Sr[], Int32 Si[], Int16 data[]) +{ + + Int16 k; + Int16 *pt_data_1; + Int32 exp_m0_25; + const Int32 *pt_exp = exp_m0_25_phi; + + Int32 *XX = Sr; + Int32 *YY = (Int32 *)data; + Int32 tmp1; + Int32 tmp2; + + for (k = 0; k < 32; k++) + { + exp_m0_25 = *(pt_exp++); + tmp1 = Sr[k]; + tmp2 = Si[k]; + XX[k] = cmplx_mul32_by_16(-tmp1, tmp2, exp_m0_25); + YY[31-k] = cmplx_mul32_by_16(tmp2, tmp1, exp_m0_25); + } + + mdct_32(XX); + mdct_32(YY); + + for (k = 0; k < 32; k++) + { + Si[k] = YY[k]; + } + + pt_data_1 = data; + + for (k = 0; k < 16; k++) + { + *(pt_data_1++) = (Int16)((XX[2*k ] + Si[2*k ]) >> 14); + *(pt_data_1++) = (Int16)((XX[2*k+1] - Si[2*k+1]) >> 14); + } + + for (k = 15; k > -1; k--) + { + *(pt_data_1++) = (Int16)(-(XX[2*k+1] + Si[2*k+1]) >> 14); + *(pt_data_1++) = (Int16)(-(XX[2*k ] - Si[2*k ]) >> 14); + } + +} + + +#endif /* HQ_SBR */ + +#endif /* AAC_PLUS */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/synthesis_sub_band.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/synthesis_sub_band.h new file mode 100644 index 0000000..38b766d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/synthesis_sub_band.h @@ -0,0 +1,73 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: synthesis_sub_band.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef SYNTHESIS_SUB_BAND_H +#define SYNTHESIS_SUB_BAND_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + void synthesis_sub_band_LC(Int32 Sr[], Int16 data[]); + void synthesis_sub_band_LC_down_sampled(Int32 Sr[], Int16 data[]); + + +#ifdef HQ_SBR + + void synthesis_sub_band(Int32 Sr[], Int32 Si[], Int16 data[]); + void synthesis_sub_band_down_sampled(Int32 Sr[], Int32 Si[], Int16 data[]); + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* SYNTHESIS_SUB_BAND_H */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_ar_filter.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_ar_filter.cpp new file mode 100644 index 0000000..68c6956 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_ar_filter.cpp @@ -0,0 +1,389 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_ar_filter.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + spec = spectral input to be shaped by the filter. + Fixed point format + Int32[] + length = spec_length + + spec_length = length of spec array. + const Int + + direction = direction for application of tns filter. + +1 filters spectrum from low to high frequencies + (first input to filter is spec[0]) + -1 filters spectrum from high to low frequencies + (first input to filter is spec[spec_length-1]) + const Int + + lpc = array of lpc coefficients, minus lpc[0] which is assumed to be "1" + Fixed point format + const Int[] + length = TNS_MAX_ORDER + + Q_lpc = Q format for the lpc coeffcients (for max. precision, it assumes + that all 16 bits are used) + const Int + + order = order of the TNS filter (Range of 1 - TNS_MAX_ORDER) + Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + spec = contains spectral data after application of TNS filter + Int32 array + length = spec_length + + + Local Stores Modified: + + Global Stores Modified: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + A block of spectral data (Int32 spec[]) of length (const Int spec_length) + is processed by a simple all-pole filter defined by + LPC coefficients passed via (const Int lpc[]) + + TNS filter equation + y(n) = x(n) - lpc(2)*y(n-1) - ... - lpc(order+1)*y(n-order) + + The filter calculation is performed in place, i.e. the output is passed + back to the calling function via (Int32 spec[]) + + The filter's order is defined by the variable (const Int order) + The direction of the filter's application is defined by (const Int inc) + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should match the functionality of the ISO code. + The implementation does support filter orders bigger or equal to 1. + The size of the spectral coeffcients has to be bigger or equal than 1. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.8 (Temporal Noise Shaping) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + + FOR (i=0; i0; j--) + + state[j] = state[j-1]; + + ENDFOR + + state[0] = y; + + *spec = y; + + spec = spec + inc; + + ENDFOR + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_tns_const.h" +#include "tns_ar_filter.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define MASK_LOW16 0xFFFF +#define UPPER16 16 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int tns_ar_filter( + Int32 spec[], + const Int spec_length, + const Int direction, + const Int32 lpc[], + const Int Q_lpc, + const Int order) +{ + + Int i; + Int j; + + /* + * Multiplication related variables + */ + + Int32 temp; + + /* + * Filter related variables + */ + Int32 y0; + + /* + * Circular buffer to hold the filter's state + * (y[n-1],y[n-2],y[n-3],etc.) + * + * p_state and p_lpc should take advantage + * of any special circular buffer instructions + * if this code is hand-optimized in assembly. + */ + + Int32 *p_state = NULL; + + const Int32 *p_lpc; + + + Int shift_up; + Int shift_down_amount; + + /* + * Pointer to the I/O memory space + */ + Int32 *p_spec = spec; + + + i = 0; + j = order; + + /* + * get the power of 2 that is bigger than the order + * i is the bit counter and j is modified until exceed + * the power of 2 corresponding to TNS_MAX_ORDER + */ + + while (j < 0x010) + { + j <<= 1; + i++; + } + + /* + * 5 is the number of bits needed to represent 0x010 + * TNS_MAX_ORDER = 20, power of 2 that include 20 is 5 + */ + shift_down_amount = 4 - i; + + shift_up = UPPER16 - Q_lpc; + + /* + * shift_down_amount == power of 2 that is bigger than the order - 1 + */ + + shift_down_amount += shift_up; + + if (direction == -1) + { + p_spec += spec_length - 1; + + for (i = order; i != 0; i--) + { + + y0 = *p_spec >> shift_down_amount; + + p_lpc = lpc; + + /* 32 by 32 bit multiplication */ + for (j = order; j > i; j--) + { + temp = *p_state++; + y0 -= fxp_mul32_Q31(temp, *(p_lpc++)) << shift_up; + } + + /* + * Record the output in-place + */ + p_state = p_spec; + *(p_spec--) = y0; + + } + + if (spec_length > order) + { + for (i = (spec_length - order); i != 0; i--) + { + y0 = *p_spec >> shift_down_amount; + + p_lpc = &(lpc[0]); + + /* 32 by 32 bit multiplication */ + for (j = order; j != 0; j--) + { + temp = *p_state++; + y0 -= fxp_mul32_Q31(temp, *(p_lpc++)) << shift_up; + } + + /* + * Record the output in-place + */ + p_state = p_spec; + *(p_spec--) = y0; + + } /* END for (i = (spec_length - order); i>0; i--) */ + } + + } + else + { + for (i = order; i != 0; i--) + { + + p_lpc = lpc; + + y0 = 0; + + /* 32 by 32 bit multiplication */ + for (j = order; j > i; j--) + { + y0 -= fxp_mul32_Q31(*p_state--, *(p_lpc++)); + } + + p_state = p_spec; + /* + * Record the output in-place + */ + *(p_spec) = (*p_spec >> shift_down_amount) + (y0 << shift_up); + p_spec++; + } + + if (spec_length > order) + { + for (i = (spec_length - order); i != 0; i--) + { + p_lpc = lpc; + + y0 = 0; + + /* 32 by 32 bit multiplication */ + for (j = order; j != 0; j--) + { + y0 -= fxp_mul32_Q31(*p_state--, *(p_lpc++)); + } + + p_state = p_spec; + /* + * Record the output in-place + */ + *(p_spec) = (*p_spec >> shift_down_amount) + (y0 << shift_up); + p_spec++; + + } /* END for (i = (spec_length - order); i>0; i--) */ + } + } + + return(shift_down_amount); + + +} /* tns_ar_filter */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_ar_filter.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_ar_filter.h new file mode 100644 index 0000000..48eca7d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_ar_filter.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_ar_filter.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This function includes the function declaration for tns_ar_filter() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef TNS_AR_FILTER_H +#define TNS_AR_FILTER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "e_tns_const.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int tns_ar_filter( + Int32 spec[], + const Int spec_length, + const Int inc, + const Int32 lpc[], + const Int lpc_qformat, + const Int order); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_decode_coef.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_decode_coef.cpp new file mode 100644 index 0000000..d655036 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_decode_coef.cpp @@ -0,0 +1,456 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_decode_coef.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + The inputs and their range are defined in ISO/IEC 14496-3:1999(E) + Part 3 MPEG-4 Audio + Subpart 4 + + Inputs: order = RANGE = 1-20 + const Int + + coef_res = RANGE = 0-1 + const Int + + lpc_coef = RANGE = -8 to 7 if coef_res = 1 compression OFF + -4 to 3 if coef_res = 1 compression ON + -4 to 3 if coef_res = 0 compression OFF + -2 to 1 if coef_res = 0 compression ON + + [Int *, length TNS_MAX_ORDER] + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + q_lpc = q_format for the calculated LPC coefs. + Int + + Pointers and Buffers Modified: + lpc_coef = used to return the calculated LPC coefs in-place. + Int * + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + +This function calculates the LPC coefs from the encoded coefs... + +------------------------------------------------------------------------------ + REQUIREMENTS + +This function should match the functionality of the ISO source code within +a reasonable tolerance for fixed point errors. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.8 (Temporal Noise Shaping) + (2) Markel & Gray Page 95 + As referenced in the ISO source code + + (3) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- + PSEUDOCODE: (ISO Reference Code) + + int i, m; + Real iqfac, iqfac_m; + Real lpc_fp[TNS_MAX_ORDER+1]; + Real sin_result_fp[TNS_MAX_ORDER+1], b[TNS_MAX_ORDER+1]; + + Inverse quantization + iqfac = (Real)(((1 << (coef_res-1)) - 0.5) / (PI/2.0)); + iqfac_m = (Real)(((1 << (coef_res-1)) + 0.5) / (PI/2.0)); + + for (i=0; i= 0) ? iqfac : iqfac_m) ); + } + + lpc[0] = 1; + for (m=1; m<=order; m++) + { + + b[0] = lpc[0]; + for (i=1; i 0; i--) + { + + /* + * temp_ptr used to optimize index into pA + * mult = (Int32)( pA[m-i] * sin_result); + */ + + mult_high = fxp_mul32_Q31(*(temp_ptr--), sin_result); + + /* + * pB[i] = pA[i] + sin_result * pA[m-i] + * + * (mult_high <<1) eliminates extra sign bit + */ + + *(pB++) = *(pA++) + (mult_high << 1); + + } /* END for (i=m; i > 0; i--) */ + + + /* Shift to place pB[m] in q_lpc format */ + + *pB = sin_result >> 12; + + /* + * Swapping the pointers here has the same effect + * as specifically copying the data from b to a + */ + + temp_ptr = pA; + pA = pB; + pB = temp_ptr; + + /* + * At this point, pA = pA[m] + * and pB = pB[m] + */ + temp_ptr = pA; + + tempInt32 = *(pA); + + mask = tempInt32 >> 31; + tempInt32 ^= mask; + + max = tempInt32; + + /* + * It is important that this for loop is not entered on the first + * iteration of the do-while( m < order ) loop. + */ + for (i = m; i > 0; i--) + { + tempInt32 = *(--pA); + + mask = tempInt32 >> 31; + tempInt32 ^= mask; + + max |= tempInt32; + } + + pB -= m; + + /* + * Here, pA = &(pA[0]) + * and pB = &(pB[0]) + */ + + if (max >= 0x40000000L) + { + max >>= 1; + + for (i = m; i > 0; i--) + { + *(pA++) >>= 1; + *(pB++) >>= 1; + } + + /* Shift the most recent entry down also */ + *(pA) >>= 1; + + q_lpc--; + + pA -= m; + pB -= m; + } + + m++; + + } + while (m < order); + + + /* + * The following code compacts + * 32-bit LPC coefficients into 16-bit numbers, + * shifting by the minimum amount necessary. + */ + + shift_amount = 0; + + while (max > 32767) + { + max >>= 1; + shift_amount++; + } + + /* + * This while loop is for protective purposes only. + * I have not found data that causes it to be entered. + * + */ + if (max != 0) + { + while (max < 16384) + { + max <<= 1; + shift_amount--; + } + } + + + pLPC = lpc_coef; + + if (shift_amount >= 0) + { + + for (m = order; m > 0; m--) + { + *(pLPC++) = *(pA++) << (16 - shift_amount); + } + } + + + q_lpc -= shift_amount; + + /* + * make sure that the numbers have some meaning, q_lpc can not be + * bigger than 15 (15 bits + sign) + */ + + if (q_lpc > 15) + { + shift_amount = q_lpc - 15; + pLPC = lpc_coef; + + for (m = order; m > 0; m--) + { + *(pLPC++) >>= shift_amount; + } + + q_lpc -= shift_amount; + } + + return (q_lpc); + +} /* tns_decode_coef */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_decode_coef.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_decode_coef.h new file mode 100644 index 0000000..6d22805 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_decode_coef.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_decode_coef.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This function includes the function declaration for tns_decode_coef() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef TNS_DECODE_COEF_H +#define TNS_DECODE_COEF_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int tns_decode_coef( + const Int order, + const Int coef_res, + Int32 lpc_coef[], + Int32 scratchTnsDecCoefMem[]); + +#ifdef __cplusplus +} +#endif + +#endif /* TNS_DECODE_COEF */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_inv_filter.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_inv_filter.cpp new file mode 100644 index 0000000..9364b14 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_inv_filter.cpp @@ -0,0 +1,378 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_inv_filter.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + coef = spectral input to be shaped by the filter. + Fixed point format + [Int32[], length = num_coef] + + num_coef = length of spec array. + [const Int] + + direction = direction for application of tns filter. + +1 applies forward filter + (first input to filter is coef[0]) + -1 applies reversed filter + (first input to filter is coef[num_coef-1]) + [const Int] + + lpc = array of lpc coefficients. + Fixed point format Q-11 + [const Int[], length = TNS_MAX_ORDER] + + lpc_qformat = The q-format of the lpc coefficients. + [const Int] + + order = order of the TNS filter (Range of 1 : TNS_MAX_ORDER) + [const Int] + + scratch_memory = scratch_memory needed for filter operation + [Int[], length = TNS_MAX_ORDER] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coef = contains spectral data after application of TNS filter + q-format is not modified. + Int32 array + length = num_coef + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + A block of spectral data (Int32 coef[]) of length (const Int num_coef) + is processed by a simple all-zero filter defined by + LPC coefficients passed via (const Int lpc[]) + + TNS filter equation + y(n) = x(n) + lpc(2)*x(n-1) + ... + lpc(order+1)*x(n-order) + + The filter calculation is performed in place, i.e. the output is passed + back to the calling function via (Int32 coef[]) + + In order to avoid overflow, the filter input (Int32 coef[]) must utilize + only the lower 16-bits. The upper 16-bits must be available. + + The filter's order is defined by the variable (const Int order) + + The direction of the filter's application is defined by + (const Int direction) + +------------------------------------------------------------------------------ + REQUIREMENTS + + [Int32 coef] must store no more than 16 bits of data. + + This is required to utilize methods that do not change the q-format of + the input data [Int32 coef], and to make use of a fast + 16 x 16 bit multiply. + + This function should not be called for order <= 0. + + This function must not be called with lpc_qformat < 5 +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.6.4.1 (LTP with TNS) + Subpart 4.6.8 (Temporal Noise Shaping) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF (direction == -1) + THEN + pCoef = pCoef + (num_coef - 1); + END IF + + FOR (i = order; i > 0; i--) + + *(pFilterInput) = 0; + pFilterInput = pFilterInput + 1; + + END FOR + + wrap_point = 0; + + shift_amt = (lpc_qformat - 5); + + FOR (i = num_coef; i > 0; i--) + + pLPC = lpc; + + mult = 0; + + FOR (j = wrap_point; j>0; j--) + + tempInt32 = (Int32)(*(pLPC) * *(pFilterInput)); + tempInt32 = tempInt32 >> 5; + + mult = mult + tempInt32; + + pFilterInput = pFilterInput + 1; + pLPC = pLPC + 1; + + ENDFOR + + pFilterInput = scratch_memory; + + FOR (j = (order - wrap_point); j>0; j--) + + tempInt32 = (Int32)(*(pLPC) * *(pFilterInput)); + tempInt32 = tempInt32 >> 5; + + mult = mult + tempInt32; + + pFilterInput = pFilterInput + 1; + pLPC = pLPC + 1; + + ENDFOR + + pFilterInput = pFilterInput - 1; + *(pFilterInput) = (Int)(*pCoef); + + mult = mult >> shift_amt; + + *(pCoef) = *(pCoef) + mult; + + pCoef = pCoef + direction; + + wrap_point = wrap_point + 1; + + IF (wrap_point == order) + THEN + wrap_point = 0; + END IF + + END FOR + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "tns_inv_filter.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void tns_inv_filter( + Int32 coef[], + const Int num_coef, + const Int direction, + const Int32 lpc[], + const Int lpc_qformat, + const Int order, + Int32 scratch_memory[]) +{ + + Int i; + Int j; + Int shift_amt; + Int wrap_point; + + Int32 mult; + + /* + * Circular buffer to hold the filter's input + * + * (x[n-1],x[n-2],x[n-3],etc.) + * + * This scratch space is necessary, because + * the filter's output is returned in-place. + * + * pFilterInput and pLPC should take advantage + * of any special circular buffer instructions + * if this code is hand-optimized in assembly. + * + */ + Int32 *pFilterInput = scratch_memory; + + const Int32 *pLPC; + + /* + * Pointer to the I/O memory space + */ + Int32 *pCoef = coef; + + if (direction == -1) + { + pCoef += (num_coef - 1); + } + + /* Make sure the scratch memory is "clean" */ + for (i = order; i != 0; i--) + { + *(pFilterInput++) = 0; + } + + wrap_point = 0; + + shift_amt = (lpc_qformat - 5); + + for (i = num_coef; i > 0; i--) + { + /* + * Copy spectral input into special + * filter input buffer. + */ + pLPC = lpc; + + mult = 0; + + /* + * wrap_point = 0 when this code is + * entered for the first iteration of + * for(i=num_coef; i>0; i--) + * + * So, this first for-loop will be + * skipped when i == num_coef. + */ + + for (j = wrap_point; j > 0; j--) + { + mult += fxp_mul32_Q31(*(pLPC++), *(pFilterInput++)) >> 5; + + } /* for (j = wrap_point; j>0; j--) */ + + /* + * pFilterInput has reached &scratch_memory[order-1] + * Reset pointer to beginning of filter's state memory + */ + pFilterInput = scratch_memory; + + for (j = (order - wrap_point); j > 0; j--) + { + mult += fxp_mul32_Q31(*(pLPC++), *(pFilterInput++)) >> 5; + + } /* for (j = wrap_point; j>0; j--) */ + + + /* + * Fill the filter's state buffer + * avoid obvious casting + */ + *(--pFilterInput) = (*pCoef); + + + /* Scale the data down so the output q-format is not adjusted. + * + * Here is an equation, which shows how the spectral coefficients + * and lpc coefficients are multiplied and the spectral + * coefficient's q-format does not change. + * + * Q-(coef) * Q-(lpc_qformat) >> 5 = Q-(coef + lpc_q_format - 5) + * + * Q-(coef + lpc_q_format - 5) >> (lpc_qformat - 5) = Q-(coef) + */ + + /* Store output in place */ + *(pCoef) += (mult >> shift_amt); + + /* Adjust pointers and placeholders */ + pCoef += direction; + + wrap_point++; + + if (wrap_point == order) + { + wrap_point = 0; + } + + } /* for (i = num_coef; i > 0; i--) */ + +} /* tns_inv_filter */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_inv_filter.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_inv_filter.h new file mode 100644 index 0000000..d325793 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/tns_inv_filter.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_inv_filter.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the function declaration for + tns_inv_filter.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef TNS_INV_FILTER_H +#define TNS_INV_FILTER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void tns_inv_filter( + Int32 coef[], + const Int num_coef, + const Int inc, + const Int32 lpc[], + const Int lpc_qformat, + const Int order, + Int32 scratch_memory[]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/trans4m_freq_2_time_fxp.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/trans4m_freq_2_time_fxp.cpp new file mode 100644 index 0000000..4357416 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/trans4m_freq_2_time_fxp.cpp @@ -0,0 +1,2412 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: trans4m_freq_2_time_fxp.cpp + Function: trans4m_freq_2_time_fxp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Frequency_data = vector with spectral information, size 2048 + type Int32 + + Time_data = buffer with data from previous Frequency to Time + conversion, used for overlap and add, size 1024 + type Int32 + + Output_buffer = place holder for current output, size 1024 + type Int16 + + wnd_seq = window sequence + type WINDOW_SEQUENCE + + wnd_shape_prev_bk = previous window shape type + type Int + + wnd_shape_this_bk = current window shape type + type Int + + Q_format = Q format for the input frequency data + type Int + + freq_2_time_buffer[] = scratch memory for computing FFT + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + Output_buffer + Time_data + Frequency_data + pWnd_shape_prev_bk + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + +The time/frequency representation of the signal is mapped onto the time +domain by feeding it into the filterbank module. This module consists of +an inverse modified discrete cosine transform (IMDCT), and a window and an +overlap-add function. In order to adapt the time/frequency resolution of the +filterbank to the characteristics of the input signal, a block switching tool +is also adopted. N represents the window length, where N is a function of the +window_sequence. For each channel, the N/2 time-frequency values are +transformed into the N time domain values via the IMDCT. After applying the +window function, for each channel, the first half of the sequence is added to +the second half of the previous block windowed sequence to reconstruct the +output samples for each channel outi,n. + +The adaptation of the time-frequency resolution of the filterbank to the +characteristics of the input signal is done by shifting between transforms +whose input lengths are either 2048 or 256 samples. By enabling the block +switching tool, the following transitions are meaningful: + +from ONLY_LONG_SEQUENCE to { LONG_START_SEQUENCE + ONLY_LONG_SEQUENCE + +from LONG_START_SEQUENCE to { LONG_STOP_SEQUENCE + EIGHT_SHORT_SEQUENCE + +from LONG_STOP_SEQUENCE to { LONG_START_SEQUENCE + ONLY_LONG_SEQUENCE + +from EIGHT_SHORT_SEQUENCE to { LONG_STOP_SEQUENCE + EIGHT_SHORT_SEQUENCE + +Window shape decisions are made by the encoder on a frame-by-frame-basis. +The window selected is applicable to the second half of the window function +only, since the first half is constrained to use the appropriate window +shape from the preceding frame. +The 2048 time-domain values x'(i)(n), (i window, n sample) to be windowed are +the last 1024 values of the previous window_sequence concatenated with 1024 +values of the current block. The formula below shows this fact: + + | x(i-1)(n+1024) for 0 < n < 1024 + x'(i)(n) { + | x(i)(n) for 1024 < n < 2048 + + +Buffer Time_data data from previous Frequency to Time conversion, used +for overlap and add + +Once the window shape is selected, the window_shape syntax element is +initialized. Together with the chosen window_sequence all information needed +for windowing exist. +With the window halves described below all window_sequences can be assembled. +For window_shape == 1, the window coefficients are given by the Kaiser - +Bessel derived (KBD) window. +Otherwise, for window_shape == 0, a sine window is employed. + +The window length N can be 2048 or 256 for the KBD and the sine window. +All four window_sequences explained below have a total length of 2048 +samples. +For all kinds of window_sequences the window_shape of the left half of +the first transform window is determined by the window shape of the previous +block. + +In the case of EIGHT_SHORT_SEQUENCE the processing is done in-place and +in descendent order to avoid using extra memory. +The ordering is as follows: + + Pn: Previous data for window n + Cn: Current data for window n + + + 128 freq. + samples + FREQ ++++++ +IN =========================== + \ + \ + -> 256 time + samples + + P8 C8 + 8 #######++++++ + P7 C7 + 7 #######++++++ + : : + : : + P2 C2 + 2 #######++++++ + P1 C1 + 1 #######++++++ + TIME +OUT ============================================================== + +------------------------------------------------------------------------------ + REQUIREMENTS + + This module shall implement a scheme to switch between window types + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO 14496-3:1999, pag 111 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + + + IF ( wnd_seq == EIGHT_SHORT_SEQUENCE) + THEN + + FOR ( i=0; i=0; wnd--) + + pFreqInfo = &Frequency_data[ wnd*SHORT_WINDOW]; + + CALL IMDCT( pFreqInfo, SHORT_BLOCK1); + MODIFYING(pFreqInfo) + + + IF (wnd == 0) + THEN + pShort_Window_1 = &Short_Window[wnd_shape_prev_bk][0]; + ELSE + pShort_Window_1 = &Short_Window[wnd_shape_this_bk][0]; + ENDIF + + pShort_Window_2 = + &Short_Window[wnd_shape->this_bk][SHORT_WINDOW_m_1]; + + FOR( i=0, j=SHORT_WINDOW; i>SCALING); \ + if ((z>>15) != (z>>31)) \ + { \ + z = (z >> 31) ^ INT16_MAX; \ + } \ + y = (Int16)(z); + + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +#ifdef AAC_PLUS + + +void trans4m_freq_2_time_fxp_1( + Int32 Frequency_data[], + Int32 Time_data[], + Int16 Output_buffer[], + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int Q_format, + Int32 abs_max_per_window[], + Int32 freq_2_time_buffer[]) + +{ + Int exp; + Int shift; + + Int i; + Int wnd; +#if !((PV_CPU_ARCH_VERSION >=5) && (PV_COMPILER == EPV_ARM_RVCT)) + Int32 z; +#endif + + Int16 *pFreqInfo; + Int32 temp; + Int32 test; + + Int16 *pFreq_2_Time_data_1; + Int16 *pFreq_2_Time_data_2; + + const Int16 *pLong_Window_1; + const Int16 *pLong_Window_2; + const Int16 *pShort_Window_1; + const Int16 *pShort_Window_2; + + Int32 *pOverlap_and_Add_Buffer_1; + Int32 *pOverlap_and_Add_Buffer_2; + + Int16 *pOutput_buffer; + Int16 *pOutput_buffer_2; + + const Int16 * Long_Window_fxp[NUM_WINDOW_SHAPES]; + const Int16 * Short_Window_fxp[NUM_WINDOW_SHAPES]; + + Long_Window_fxp[0] = Long_Window_sine_fxp; + Long_Window_fxp[1] = Long_Window_KBD_fxp; + Short_Window_fxp[0] = Short_Window_sine_fxp; + Short_Window_fxp[1] = Short_Window_KBD_fxp; + + + if (wnd_seq != EIGHT_SHORT_SEQUENCE) + { + + pFreqInfo = (Int16 *)Frequency_data; + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + LONG_BLOCK1, + Q_format, + abs_max_per_window[0]); + + + + /* + * The C Programming Language, Second Edition, Kernighan & Ritchie, + * page 206. + * "The result [of a shift] is undefined if the right operand is + * negative, or greater than or equal to the number of bits in the + * left expression's type" + * => avoid shift by 32 or 16 + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = pFreqInfo; + + switch (wnd_seq) + { + + case ONLY_LONG_SEQUENCE: + default: + + pOutput_buffer = Output_buffer; + + pOverlap_and_Add_Buffer_1 = Time_data; + + { + const Int16 *pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0]; + const Int16 *pLong_Window_2 = &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + Int32 * pFreq2T = (Int32 *)pFreqInfo; + Int shift = exp + 15 - SCALING; + + + Int32 * pFreq2T_2 = &pFreq2T[HALF_LONG_WINDOW]; + + + for (i = HALF_LONG_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int32 temp2, test2; + + temp2 = *(pFreq2T++); + win1 = *(pLong_Window_1++); + win2 = *(pLong_Window_1++); + + test = *(pOverlap_and_Add_Buffer_1); + test2 = *(pOverlap_and_Add_Buffer_1 + 1); + temp = fxp_mul_16_by_16bb(temp2, win1); + temp2 = fxp_mul_16_by_16tb(temp2, win2); + limiter(*(pOutput_buffer++), test + (temp >> shift)); + limiter(*(pOutput_buffer++), test2 + (temp2 >> shift)); + + temp2 = *(pFreq2T_2++); + + win1 = *(pLong_Window_2--); + win2 = *(pLong_Window_2--); + temp = fxp_mul_16_by_16bb(temp2, win1) >> shift; + test2 = fxp_mul_16_by_16tb(temp2, win2) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp; + *(pOverlap_and_Add_Buffer_1++) = test2; + + } + } + + break; + + case LONG_START_SEQUENCE: + + + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[ HALF_LONG_WINDOW]; + + pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0]; + pLong_Window_2 = &pLong_Window_1[ HALF_LONG_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + pOverlap_and_Add_Buffer_2 = &Time_data[HALF_LONG_WINDOW]; + + pOutput_buffer = Output_buffer; + pOutput_buffer_2 = pOutput_buffer + HALF_LONG_WINDOW; + + + shift = exp + 15 - SCALING; + + for (i = HALF_LONG_WINDOW; i != 0; i--) + { + + Int16 win1, win2; + Int16 dat1, dat2; + Int32 test1, test2; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pLong_Window_1++); + test1 = *(pOverlap_and_Add_Buffer_1++); + + dat2 = *(pFreq_2_Time_data_2++); + win2 = *(pLong_Window_2++); + test2 = *(pOverlap_and_Add_Buffer_2++); + + limiter(*(pOutput_buffer++), (test1 + (fxp_mul_16_by_16(dat1, win1) >> shift))); + + limiter(*(pOutput_buffer_2++), (test2 + (fxp_mul_16_by_16(dat2, win2) >> shift))); + + } + + /* + * data unchanged from LONG_WINDOW to W_L_START_1 + * only scaled accordingly + */ + + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + pFreq_2_Time_data_1 = &pFreqInfo[LONG_WINDOW]; + + exp -= SCALING; + + if (exp >= 0) + { + + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++) >> exp; + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++) >> exp; + + } + + } + else if (exp < 0) + { + + Int shift = -exp; + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0 ; i--) + { + Int32 temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + *(pOverlap_and_Add_Buffer_1++) = temp2; + temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + *(pOverlap_and_Add_Buffer_1++) = temp2; + } + + } + else + { + + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++); + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++); + + } + + } + + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_START_1]; + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[HALF_SHORT_WINDOW]; + + pShort_Window_1 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + pShort_Window_2 = pShort_Window_1 - HALF_SHORT_WINDOW; + + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int16 dat1, dat2; + Int32 temp2; + dat1 = (*pFreq_2_Time_data_1++); + dat2 = (*pFreq_2_Time_data_2++); + win1 = *(pShort_Window_1--); + win2 = *(pShort_Window_2--); + + temp = fxp_mul_16_by_16(dat1, win1) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp; + + temp2 = fxp_mul_16_by_16(dat2, win2) >> shift; + *(pOverlap_and_Add_Buffer_2++) = temp2; + + + } + + + pOverlap_and_Add_Buffer_1 += HALF_SHORT_WINDOW; + + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + (LONG_BLOCK1 - W_L_START_2) + *sizeof(*pOverlap_and_Add_Buffer_1)); + + + break; + + + case LONG_STOP_SEQUENCE: + + pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_2]; + + pOutput_buffer = &Output_buffer[W_L_STOP_2]; + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_2]; + + exp -= SCALING; /* !!!! */ + + if (exp > 0) + { + Int16 tmp1 = (*(pFreq_2_Time_data_1++) >> exp); + temp = *(pOverlap_and_Add_Buffer_1++); + + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pOutput_buffer++), (temp + tmp1)); + + tmp1 = *(pFreq_2_Time_data_1++) >> exp; + temp = *(pOverlap_and_Add_Buffer_1++); + + } + } + else if (exp < 0) + { + shift = -exp; + Int32 temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + temp = *(pOverlap_and_Add_Buffer_1++); + + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pOutput_buffer++), (temp + temp1)); + + temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + temp = *(pOverlap_and_Add_Buffer_1++); + + } + } + else + { + Int16 tmp1 = *(pFreq_2_Time_data_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pOutput_buffer++), (temp + tmp1)); + + tmp1 = *(pFreq_2_Time_data_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + + } + } + + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0]; + pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW]; + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_1]; + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[HALF_SHORT_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_1]; + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + pOutput_buffer = &Output_buffer[W_L_STOP_1]; + pOutput_buffer_2 = pOutput_buffer + HALF_SHORT_WINDOW; + + exp += SCALING; /* +8 back to what it was */ + + shift = exp + 15 - SCALING; + + + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + Int16 win1; + Int16 dat1; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + + test = fxp_mul_16_by_16(dat1, win1); + + limiter(*(pOutput_buffer++), (temp + (test >> shift))); + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2++); + temp = *(pOverlap_and_Add_Buffer_2++); + test = fxp_mul_16_by_16(dat1, win1); + limiter(*(pOutput_buffer_2++), (temp + (test >> shift))); + + } + + + pFreq_2_Time_data_2 = &pFreqInfo[LONG_WINDOW]; + + pOverlap_and_Add_Buffer_1 = Time_data; + + pOutput_buffer = Output_buffer; + + pLong_Window_2 = + &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + + /* + * Copy previous time in current buffer, also copy overlap + * and add buffer + */ + + for (i = W_L_STOP_1; i != 0; i--) + { + Int16 win1; + Int16 dat1; + + win1 = *(pLong_Window_2--); + dat1 = *pFreq_2_Time_data_2++; + + limiter(*(pOutput_buffer++), *(pOverlap_and_Add_Buffer_1)); + + + temp = fxp_mul_16_by_16(dat1, win1) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp ; + + } + + for (i = (LONG_WINDOW - W_L_STOP_1); i != 0; i--) + { + temp = fxp_mul_16_by_16(*pFreq_2_Time_data_2++, *(pLong_Window_2--)) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp ; + } + + + break; + + + + } /* switch (wnd_seq) */ + + } /* if (exp < 16) */ + + else + { + /* all zeros buffer or excessive down shift */ + + /* Overlap and add, setup buffer for next iteration */ + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + + pOutput_buffer = Output_buffer; + + temp = (*pOverlap_and_Add_Buffer_1++); + + for (i = LONG_WINDOW; i != 0; i--) + { + + limiter(*(pOutput_buffer++), temp); + + temp = (*pOverlap_and_Add_Buffer_1++); + + } + + pv_memset(Time_data, 0, LONG_WINDOW*sizeof(Time_data[0])); + + + } + + } + else + { + + Int32 *pScrath_mem; + Int32 *pScrath_mem_entry; + Int32 *pFrequency_data = Frequency_data; + + Int32 * pOverlap_and_Add_Buffer_1; + Int32 * pOverlap_and_Add_Buffer_2; + Int32 * pOverlap_and_Add_Buffer_1x; + Int32 * pOverlap_and_Add_Buffer_2x; + + /* + * Frequency_data is 2*LONG_WINDOW length but only + * the first LONG_WINDOW elements are filled in, + * then the second part can be used as scratch mem, + * then grab data from one window at a time in + * reverse order. + * The upper LONG_WINDOW Int32 are used to hold the + * computed overlap and add, used in the next call to + * this function, and also as sctrach memory + */ + + /* + * Frequency_data usage for the case EIGHT_SHORT_SEQUENCE + + |<----- Input Freq. data ----->|< Overlap & Add ->| Unused |-Scratch-| + | | Store for next | | memory | + | | call | | | + | | | | | + |//////////////////////////////|\\\\\\\\\\\\\\\\\\|--------|+++++++++| + | | | | | + 0 LONG_WINDOW LONG_WINDOW | 2*LONG_WINDOW + + | | + W_L_STOP_2 | | + |<-- -->| + SHORT_WINDOW + + HALF_SHORT_WINDOW + * + */ + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ + LONG_WINDOW + 3*SHORT_WINDOW + HALF_SHORT_WINDOW]; + + /* + * Initialize to zero, only the firt short window used in overlap + * and add + */ + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + + /* + * Showt windows are evaluated in decresing order. Windows from 7 + * to 0 are break down in four cases: window numbers 7 to 5, 4, 3, + * and 2 to 0. + * The data from short windows 3 and 4 is situated at the boundary + * between the 'overlap and add' buffer and the output buffer. + */ + for (wnd = NUM_SHORT_WINDOWS - 1; wnd >= NUM_SHORT_WINDOWS / 2 + 1; wnd--) + { + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + pOverlap_and_Add_Buffer_1 = + &pFrequency_data[ W_L_STOP_1 + SHORT_WINDOW*wnd]; + + + pOverlap_and_Add_Buffer_2 = + pOverlap_and_Add_Buffer_1 + SHORT_WINDOW; + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * Each of the eight short blocks is windowed separately. + * Window shape decisions are made on a frame-by-frame + * basis. + */ + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + + + /* + * For short windows from 7 to 5 + * | ========================= + * | | 5 6 7 + * _--_ _--_ _--_ _--_ | _-|-_ _--_ _--_ _--_ + * / \/ \/ \/ \|/ | \/ \/ \/ \ + * / /\ /\ /\ /|\ | /\ /\ /\ \ + * / / \ / \ / \ / | \ | / \ / \ / \ \ + * / / \/ \/ \/ | \|/ \/ \ \ \ + * --------------------------------|---[///////////////////////]-------- + * + */ + + + shift = exp + 15 - SCALING; + + + for (i = SHORT_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int16 dat1, dat2; + + dat2 = *(pFreq_2_Time_data_2++); + win2 = *(pShort_Window_2--); + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + + *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat2, win2) >> shift); + + *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift; + + } + + } /* if (exp < 16) */ + else + { + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + } + + + }/* for ( wnd=NUM_SHORT_WINDOWS-1; wnd>=NUM_SHORT_WINDOWS/2; wnd--) */ + + + wnd = NUM_SHORT_WINDOWS / 2; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + /* + * scratch memory is allocated in an unused part of memory + */ + + + pScrath_mem = &pFrequency_data[ 2*LONG_WINDOW - HALF_SHORT_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW]; + + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + /* + * For short window 4 + * ====|=========== + * | 4 + * | | | | + * _--_ _--_ _--_ _-|-_ | _-|-_ _-|-_ _--_ _--_ + * / \/ \/ \/ | \|/ | \/ | \/ \/ \ + * / /\ /\ /\ | /|\ | /\ | /\ /\ \ + * / / \ / \ / \ | / | \ | / \ | / \ / \ \ + * / / \/ \/ \|/ | \|/ \|/ \/ \ \ + * ------------------------------[\\\|\\\|//////]------------------- + * | | A | B | C | + * | + * W_L_STOP_1 + */ + + shift = exp + 15 - SCALING; + { + Int16 win1; + Int16 dat1; + /* -------- segment A ---------------*/ + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> (shift); + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + /* -------- segment B ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + /* -------- segment C ---------------*/ + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + for (i = SHORT_WINDOW; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat1, win1) >> shift); + + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + } + } + + } /* if (exp < 16) */ + else + { + pv_memset( + pScrath_mem, + 0, + HALF_SHORT_WINDOW*sizeof(*pScrath_mem)); + + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + HALF_SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + } + + + wnd = NUM_SHORT_WINDOWS / 2 - 1; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + pScrath_mem_entry = + &pFrequency_data[2*LONG_WINDOW - HALF_SHORT_WINDOW - SHORT_WINDOW]; + pScrath_mem = pScrath_mem_entry; + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW]; + + /* point to end of buffer less HALF_SHORT_WINDOW */ + + pOutput_buffer_2 = &Output_buffer[LONG_WINDOW - HALF_SHORT_WINDOW]; + pOutput_buffer = pOutput_buffer_2; + + pOverlap_and_Add_Buffer_1x = &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)]; /* !!!! */ + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * For short window 3 + * ===========|==== + * 3 | + * | | | | + * _--_ _--_ _-|-_ _-|-_ | _-|-_ _--_ _--_ _--_ + * / \/ \/ | \/ | \|/ | \/ \/ \/ \ + * / /\ /\ | /\ | /|\ | /\ /\ /\ \ + * / / \ / \ | / \ | / | \ | / \ / \ / \ \ + * / / \/ \|/ \|/ | \|/ \/ \ \ \ + * -----|------------------[\\\\\\|///|///]-------------------------- + * | | A | B | C | + * + * W_L_STOP_1 + */ + + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + shift = exp + 15 - SCALING; + + + Int16 win1; + Int16 dat1; + /* -------- segment A ---------------*/ + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + for (i = SHORT_WINDOW; i != 0; i--) + { + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + /* -------- segment B ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + test = fxp_mul_16_by_16(dat1, win1) >> shift; + + temp = *(pScrath_mem++) + test; + + + test = *(pOverlap_and_Add_Buffer_1x++); /* !!!! */ + + limiter(*(pOutput_buffer++), (temp + test)); + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + } + + /* -------- segment C ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + temp = fxp_mul_16_by_16(dat1, win1) >> (shift); + + *(pOverlap_and_Add_Buffer_1++) += temp; + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + } + + } /* if (exp < 16) */ + else + { + + pv_memset( + pScrath_mem, + 0, + SHORT_WINDOW*sizeof(*pScrath_mem)); + + pScrath_mem += SHORT_WINDOW; + + temp = *(pScrath_mem++); + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + limiter(*(pOutput_buffer++), temp); + temp = *(pScrath_mem++); + + + } + } + + + for (wnd = NUM_SHORT_WINDOWS / 2 - 2; wnd >= 0; wnd--) + { + + + pOutput_buffer_2 -= SHORT_WINDOW; + pOutput_buffer = pOutput_buffer_2; + + /* + * The same memory is used as scratch in every iteration + */ + pScrath_mem = pScrath_mem_entry; + + pOverlap_and_Add_Buffer_2x = + &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)]; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * Each of the eight short blocks is windowed separately. + * Window shape decisions are made on a frame-by-frame + * basis. + */ + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + if (wnd == 0) + { + pShort_Window_1 = + &Short_Window_fxp[wnd_shape_prev_bk][0]; + } + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + /* + * For short windows from 2 to 0 + * + * ========================= + * | + * 0 1 2 | | + * _--_ _--_ _--_ _-|-_ | _--_ _--_ _--_ _--_ + * / \/ \/ \/ | \|/ \/ \/ \/ \ + * / /\ /\ /\ | /|\ /\ /\ /\ \ + * / / \ / \ / \ | / | \ / \ / \ / \ \ + * / / \/ \/ \|/ | \/ \/ \ \ \ + * ----[\\\\\\\\\\\\\\\\\\\\\\\\]---|----------------------------- + * | + * + * W_L_STOP_1 + */ + + shift = exp + 15 - SCALING; + + Int16 dat1 = *(pFreq_2_Time_data_2++); + Int16 win1 = *(pShort_Window_2--); + + temp = *(pScrath_mem); + for (i = SHORT_WINDOW; i != 0; i--) + { + test = fxp_mul_16_by_16(dat1, win1) >> shift; + + temp += test; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + + limiter(*(pOutput_buffer++), (temp + *(pOverlap_and_Add_Buffer_2x++))); + + + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + temp = *(pScrath_mem); + + } + + } /* if (exp < 16) */ + else + { + test = *(pScrath_mem); + temp = *(pOverlap_and_Add_Buffer_2x++); + + for (i = SHORT_WINDOW; i != 0; i--) + { + limiter(*(pOutput_buffer++), (temp + test)); + + *(pScrath_mem++) = 0; + test = *(pScrath_mem); + temp = *(pOverlap_and_Add_Buffer_2x++); + + } + } + + } /* for ( wnd=NUM_SHORT_WINDOWS/2-1; wnd>=0; wnd--) */ + + pOverlap_and_Add_Buffer_2x = &Time_data[W_L_STOP_1]; + + pScrath_mem = pScrath_mem_entry; + + pOutput_buffer_2 -= SHORT_WINDOW; + pOutput_buffer = pOutput_buffer_2; + + test = *(pScrath_mem++); + temp = *(pOverlap_and_Add_Buffer_2x++); + + for (i = SHORT_WINDOW; i != 0; i--) + { + limiter(*(pOutput_buffer++), (temp + test)); + + test = *(pScrath_mem++); + temp = *(pOverlap_and_Add_Buffer_2x++); + + } + + pOverlap_and_Add_Buffer_1x = Time_data; + + pOutput_buffer = Output_buffer; + + + temp = *(pOverlap_and_Add_Buffer_1x++); + + for (i = W_L_STOP_1; i != 0; i--) + { + limiter(*(pOutput_buffer++), temp); + + temp = *(pOverlap_and_Add_Buffer_1x++); + } + + pOverlap_and_Add_Buffer_1x = &Time_data[0]; + + pOverlap_and_Add_Buffer_2 = &pFrequency_data[LONG_WINDOW]; + + /* + * update overlap and add buffer, + * so is ready for next iteration + */ + + for (int i = 0; i < W_L_STOP_2; i++) + { + temp = *(pOverlap_and_Add_Buffer_2++); + *(pOverlap_and_Add_Buffer_1x++) = temp; + } + + pv_memset( + pOverlap_and_Add_Buffer_1x, + 0, + W_L_STOP_1*sizeof(*pOverlap_and_Add_Buffer_1x)); + + } /* if ( wnd_seq != EIGHT_SHORT_SEQUENCE) */ + +} + +#endif +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void trans4m_freq_2_time_fxp_2( + Int32 Frequency_data[], + Int32 Time_data[], + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int Q_format, + Int32 abs_max_per_window[], + Int32 freq_2_time_buffer[], + Int16 *Interleaved_output) + +{ + + Int exp; + Int shift; + + Int i; + Int wnd; +#if !((PV_CPU_ARCH_VERSION >=5) && (PV_COMPILER == EPV_ARM_RVCT)) + Int32 z; +#endif + Int16 *pFreqInfo; + Int32 temp; + Int32 test; + + Int16 *pFreq_2_Time_data_1; + Int16 *pFreq_2_Time_data_2; + + const Int16 *pLong_Window_1; + const Int16 *pLong_Window_2; + const Int16 *pShort_Window_1; + const Int16 *pShort_Window_2; + + Int32 *pOverlap_and_Add_Buffer_1; + Int32 *pOverlap_and_Add_Buffer_2; + + Int16 *pInterleaved_output; + Int16 *pInterleaved_output_2; + + + const Int16 * Long_Window_fxp[NUM_WINDOW_SHAPES]; + const Int16 * Short_Window_fxp[NUM_WINDOW_SHAPES]; + + Long_Window_fxp[0] = Long_Window_sine_fxp; + Long_Window_fxp[1] = Long_Window_KBD_fxp; + Short_Window_fxp[0] = Short_Window_sine_fxp; + Short_Window_fxp[1] = Short_Window_KBD_fxp; + + if (wnd_seq != EIGHT_SHORT_SEQUENCE) + { + + pFreqInfo = (Int16 *)Frequency_data; + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + LONG_BLOCK1, + Q_format, + abs_max_per_window[0]); + + + /* + * The C Programming Language, Second Edition, Kernighan & Ritchie, + * page 206. + * "The result [of a shift] is undefined if the right operand is + * negative, or greater than or equal to the number of bits in the + * left expression's type" + * => avoid shift by 32 or 16 + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = pFreqInfo; + + + switch (wnd_seq) + { + + case ONLY_LONG_SEQUENCE: + default: + + { + pOverlap_and_Add_Buffer_1 = Time_data; + + pInterleaved_output = Interleaved_output; + + { + + const Int16 *pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0]; + const Int16 *pLong_Window_2 = &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + Int32 * pFreq2T = (Int32 *)pFreqInfo; + Int32 * pFreq2T_2 = &pFreq2T[HALF_LONG_WINDOW]; + + Int shift = exp + 15 - SCALING; + + + for (i = HALF_LONG_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int32 temp2, test2; + + temp2 = *(pFreq2T++); + + test = *(pOverlap_and_Add_Buffer_1); + test2 = *(pOverlap_and_Add_Buffer_1 + 1); + + win1 = *(pLong_Window_1++); + win2 = *(pLong_Window_1++); + temp = fxp_mul_16_by_16bb(temp2, win1); + temp2 = fxp_mul_16_by_16tb(temp2, win2); + + limiter(*(pInterleaved_output), test + (temp >> shift)); + limiter(*(pInterleaved_output + 2), test2 + (temp2 >> shift)); + pInterleaved_output += 4; + + temp2 = *(pFreq2T_2++); + + win1 = *(pLong_Window_2--); + win2 = *(pLong_Window_2--); + temp = fxp_mul_16_by_16bb(temp2, win1) >> shift; + test2 = fxp_mul_16_by_16tb(temp2, win2) >> shift; + + *(pOverlap_and_Add_Buffer_1++) = temp; + *(pOverlap_and_Add_Buffer_1++) = test2; + } + } + + } + + break; + + case LONG_START_SEQUENCE: + + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[ HALF_LONG_WINDOW]; + + pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0]; + pLong_Window_2 = &pLong_Window_1[ HALF_LONG_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + pOverlap_and_Add_Buffer_2 = &Time_data[HALF_LONG_WINDOW]; + + + pInterleaved_output = Interleaved_output; + pInterleaved_output_2 = pInterleaved_output + (2 * HALF_LONG_WINDOW); + + + /* + * process first LONG_WINDOW elements + */ + + shift = exp + 15 - SCALING; + + for (i = HALF_LONG_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int16 dat1, dat2; + Int32 test1, test2; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pLong_Window_1++); + test1 = *(pOverlap_and_Add_Buffer_1++); + + dat2 = *(pFreq_2_Time_data_2++); + win2 = *(pLong_Window_2++); + test2 = *(pOverlap_and_Add_Buffer_2++); + + limiter(*(pInterleaved_output), (test1 + (fxp_mul_16_by_16(dat1, win1) >> shift))); + + pInterleaved_output += 2; + + limiter(*(pInterleaved_output_2), (test2 + (fxp_mul_16_by_16(dat2, win2) >> shift))); + + pInterleaved_output_2 += 2; + } + + + /* + * data unchanged from LONG_WINDOW to W_L_START_1 + * only scaled accordingly + */ + + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + pFreq_2_Time_data_1 = &pFreqInfo[LONG_WINDOW]; + + exp -= SCALING; + + if (exp >= 0) + { + + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++) >> exp; + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++) >> exp; + + } + + } + else if (exp < 0) + { + + Int shift = -exp; + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0 ; i--) + { + Int32 temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + *(pOverlap_and_Add_Buffer_1++) = temp2; + temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + *(pOverlap_and_Add_Buffer_1++) = temp2; + } + + } + else + { + + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++); + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++); + + } + + } + + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_START_1]; + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[HALF_SHORT_WINDOW]; + + pShort_Window_1 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + pShort_Window_2 = pShort_Window_1 - HALF_SHORT_WINDOW; + + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + { + Int16 win1, win2; + Int16 dat1, dat2; + Int32 temp2; + + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + + dat1 = (*pFreq_2_Time_data_1++); + dat2 = (*pFreq_2_Time_data_2++); + win1 = *(pShort_Window_1--); + win2 = *(pShort_Window_2--); + + temp = fxp_mul_16_by_16(dat1, win1) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp; + + temp2 = fxp_mul_16_by_16(dat2, win2) >> shift; + *(pOverlap_and_Add_Buffer_2++) = temp2; + + } + } + + pOverlap_and_Add_Buffer_1 += HALF_SHORT_WINDOW; + + + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + (LONG_BLOCK1 - W_L_START_2) + *sizeof(*pOverlap_and_Add_Buffer_1)); + + + break; + + + case LONG_STOP_SEQUENCE: + + pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_2]; + + pInterleaved_output = &Interleaved_output[2*W_L_STOP_2]; + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_2]; + + exp -= SCALING; + + + if (exp > 0) + { + Int16 tmp1 = (*(pFreq_2_Time_data_1++) >> exp); + temp = *(pOverlap_and_Add_Buffer_1++); + + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pInterleaved_output), (temp + tmp1)); + + pInterleaved_output += 2; + tmp1 = *(pFreq_2_Time_data_1++) >> exp; + temp = *(pOverlap_and_Add_Buffer_1++); + } + } + else if (exp < 0) + { + shift = -exp; + + Int32 temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + temp = *(pOverlap_and_Add_Buffer_1++); + + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pInterleaved_output), (temp + temp1)); + + pInterleaved_output += 2; + temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + temp = *(pOverlap_and_Add_Buffer_1++); + } + } + else + { + Int16 tmp1 = *(pFreq_2_Time_data_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pInterleaved_output), (temp + tmp1)); + + pInterleaved_output += 2; + tmp1 = *(pFreq_2_Time_data_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + } + } + + + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0]; + pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW]; + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_1]; + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[HALF_SHORT_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_1]; + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + + pInterleaved_output = &Interleaved_output[2*W_L_STOP_1]; + pInterleaved_output_2 = pInterleaved_output + (2 * HALF_SHORT_WINDOW); + + exp += SCALING; /* +8 back to what it was */ + shift = exp + 15 - SCALING; + + + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + + Int16 win1; + Int16 dat1; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + + test = fxp_mul_16_by_16(dat1, win1); + + limiter(*(pInterleaved_output), (temp + (test >> shift))); + + pInterleaved_output += 2; + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2++); + temp = *(pOverlap_and_Add_Buffer_2++); + test = fxp_mul_16_by_16(dat1, win1); + + limiter(*(pInterleaved_output_2), (temp + (test >> shift))); + + pInterleaved_output_2 += 2; + + } + + + + pFreq_2_Time_data_2 = &pFreqInfo[LONG_WINDOW]; + + pOverlap_and_Add_Buffer_1 = Time_data; + + + pInterleaved_output = Interleaved_output; + + pLong_Window_2 = + &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + + /* + * Copy previous time in current buffer, also copy overlap + * and add buffer + */ + + for (i = W_L_STOP_1; i != 0; i--) + { + + Int16 win1; + Int16 dat1; + + win1 = *(pLong_Window_2--); + dat1 = *pFreq_2_Time_data_2++; + + limiter(*(pInterleaved_output), *(pOverlap_and_Add_Buffer_1)); + + pInterleaved_output += 2; + + temp = fxp_mul_16_by_16(dat1, win1) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp ; + + } + + for (i = (LONG_WINDOW - W_L_STOP_1); i != 0; i--) + { + + temp = fxp_mul_16_by_16(*pFreq_2_Time_data_2++, *(pLong_Window_2--)) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp ; + + } + + break; + + + + } /* switch (wnd_seq) */ + + } /* if (exp < 16) */ + + else + { + /* all zeros buffer or excessive down shift */ + + /* Overlap and add, setup buffer for next iteration */ + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + + pInterleaved_output = Interleaved_output; + + + temp = (*pOverlap_and_Add_Buffer_1++); + for (i = LONG_WINDOW; i != 0; i--) + { + + limiter(*(pInterleaved_output), temp); + + pInterleaved_output += 2; + temp = (*pOverlap_and_Add_Buffer_1++); + } + pv_memset(Time_data, 0, LONG_WINDOW*sizeof(Time_data[0])); + } + + } + else + { + + Int32 *pScrath_mem; + Int32 *pScrath_mem_entry; + Int32 *pFrequency_data = Frequency_data; + + Int32 * pOverlap_and_Add_Buffer_1; + Int32 * pOverlap_and_Add_Buffer_2; + Int32 * pOverlap_and_Add_Buffer_1x; + Int32 * pOverlap_and_Add_Buffer_2x; + + + /* + * Frequency_data is 2*LONG_WINDOW length but only + * the first LONG_WINDOW elements are filled in, + * then the second part can be used as scratch mem, + * then grab data from one window at a time in + * reverse order. + * The upper LONG_WINDOW Int32 are used to hold the + * computed overlap and add, used in the next call to + * this function, and also as sctrach memory + */ + + /* + * Frequency_data usage for the case EIGHT_SHORT_SEQUENCE + + |<----- Input Freq. data ----->|< Overlap & Add ->| Unused |-Scratch-| + | | Store for next | | memory | + | | call | | | + | | | | | + |//////////////////////////////|\\\\\\\\\\\\\\\\\\|--------|+++++++++| + | | | | | + 0 LONG_WINDOW LONG_WINDOW | 2*LONG_WINDOW + + | | + W_L_STOP_2 | | + |<-- -->| + SHORT_WINDOW + + HALF_SHORT_WINDOW + * + */ + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ + LONG_WINDOW + 3*SHORT_WINDOW + HALF_SHORT_WINDOW]; + + /* + * Initialize to zero, only the firt short window used in overlap + * and add + */ + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + + /* + * Showt windows are evaluated in decresing order. Windows from 7 + * to 0 are break down in four cases: window numbers 7 to 5, 4, 3, + * and 2 to 0. + * The data from short windows 3 and 4 is situated at the boundary + * between the 'overlap and add' buffer and the output buffer. + */ + for (wnd = NUM_SHORT_WINDOWS - 1; wnd >= NUM_SHORT_WINDOWS / 2 + 1; wnd--) + { + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* W_L_STOP_1 == (LONG_WINDOW - SHORT_WINDOW)>>1 */ + pOverlap_and_Add_Buffer_1 = + &pFrequency_data[ W_L_STOP_1 + SHORT_WINDOW*wnd]; + + + pOverlap_and_Add_Buffer_2 = + pOverlap_and_Add_Buffer_1 + SHORT_WINDOW; + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * Each of the eight short blocks is windowed separately. + * Window shape decisions are made on a frame-by-frame + * basis. + */ + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + + + /* + * For short windows from 7 to 5 + * | ========================= + * | | 5 6 7 + * _--_ _--_ _--_ _--_ | _-|-_ _--_ _--_ _--_ + * / \/ \/ \/ \|/ | \/ \/ \/ \ + * / /\ /\ /\ /|\ | /\ /\ /\ \ + * / / \ / \ / \ / | \ | / \ / \ / \ \ + * / / \/ \/ \/ | \|/ \/ \ \ \ + * --------------------------------|---[///////////////////////]-------- + * + */ + + + shift = exp + 15 - SCALING; + + + for (i = SHORT_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int16 dat1, dat2; + + dat2 = *(pFreq_2_Time_data_2++); + win2 = *(pShort_Window_2--); + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + + *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat2, win2) >> shift); + + *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift; + + } + + } /* if (exp < 16) */ + else + { + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + } + + + }/* for ( wnd=NUM_SHORT_WINDOWS-1; wnd>=NUM_SHORT_WINDOWS/2; wnd--) */ + + + wnd = NUM_SHORT_WINDOWS / 2; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + /* + * scratch memory is allocated in an unused part of memory + */ + + + pScrath_mem = &pFrequency_data[ 2*LONG_WINDOW - HALF_SHORT_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW]; + + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + /* + * For short window 4 + * ====|=========== + * | 4 + * | | | | + * _--_ _--_ _--_ _-|-_ | _-|-_ _-|-_ _--_ _--_ + * / \/ \/ \/ | \|/ | \/ | \/ \/ \ + * / /\ /\ /\ | /|\ | /\ | /\ /\ \ + * / / \ / \ / \ | / | \ | / \ | / \ / \ \ + * / / \/ \/ \|/ | \|/ \|/ \/ \ \ + * ------------------------------[\\\|\\\|//////]------------------- + * | | A | B | C | + * | + * W_L_STOP_1 + */ + + shift = exp + 15 - SCALING; + { + Int16 win1; + Int16 dat1; + /* -------- segment A ---------------*/ + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + /* -------- segment B ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + /* -------- segment C ---------------*/ + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + for (i = SHORT_WINDOW; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat1, win1) >> shift); + + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + } + } + + } /* if (exp < 16) */ + else + { + pv_memset( + pScrath_mem, + 0, + HALF_SHORT_WINDOW*sizeof(*pScrath_mem)); + + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + HALF_SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + } + + + wnd = NUM_SHORT_WINDOWS / 2 - 1; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + pScrath_mem_entry = + &pFrequency_data[2*LONG_WINDOW - HALF_SHORT_WINDOW - SHORT_WINDOW]; + + + pScrath_mem = pScrath_mem_entry; + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW]; + + /* point to end of buffer less HALF_SHORT_WINDOW */ + + pInterleaved_output_2 = &Interleaved_output[2*(LONG_WINDOW - HALF_SHORT_WINDOW)]; + pInterleaved_output = pInterleaved_output_2; + + pOverlap_and_Add_Buffer_1x = &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)]; + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * For short window 3 + * ===========|==== + * 3 | + * | | | | + * _--_ _--_ _-|-_ _-|-_ | _-|-_ _--_ _--_ _--_ + * / \/ \/ | \/ | \|/ | \/ \/ \/ \ + * / /\ /\ | /\ | /|\ | /\ /\ /\ \ + * / / \ / \ | / \ | / | \ | / \ / \ / \ \ + * / / \/ \|/ \|/ | \|/ \/ \ \ \ + * -----|------------------[\\\\\\|///|///]-------------------------- + * | | A | B | C | + * + * W_L_STOP_1 + */ + + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + shift = exp + 15 - SCALING; + + Int16 win1; + Int16 dat1; + /* -------- segment A ---------------*/ + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + for (i = SHORT_WINDOW; i != 0; i--) + { + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + + /* -------- segment B ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + test = fxp_mul_16_by_16(dat1, win1) >> shift; + + temp = *(pScrath_mem++) + test; + + test = *(pOverlap_and_Add_Buffer_1x++); + limiter(*(pInterleaved_output), (temp + test)); + + + pInterleaved_output += 2; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + } + + /* -------- segment C ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + + temp = fxp_mul_16_by_16(dat1, win1) >> shift; + + *(pOverlap_and_Add_Buffer_1++) += temp; + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + } + + + } /* if (exp < 16) */ + else + { + + pv_memset( + pScrath_mem, + 0, + SHORT_WINDOW*sizeof(*pScrath_mem)); + + pScrath_mem += SHORT_WINDOW; + + temp = *(pScrath_mem++); + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + limiter(*(pInterleaved_output), (temp)); + + pInterleaved_output += 2; + temp = *(pScrath_mem++); + + } + } + + + for (wnd = NUM_SHORT_WINDOWS / 2 - 2; wnd >= 0; wnd--) + { + + + pInterleaved_output_2 -= (SHORT_WINDOW * 2); + pInterleaved_output = pInterleaved_output_2; + + /* + * The same memory is used as scratch in every iteration + */ + pScrath_mem = pScrath_mem_entry; + + pOverlap_and_Add_Buffer_2x = + &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)]; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * Each of the eight short blocks is windowed separately. + * Window shape decisions are made on a frame-by-frame + * basis. + */ + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + if (wnd == 0) + { + pShort_Window_1 = + &Short_Window_fxp[wnd_shape_prev_bk][0]; + } + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + /* + * For short windows from 2 to 0 + * + * ========================= + * | + * 0 1 2 | | + * _--_ _--_ _--_ _-|-_ | _--_ _--_ _--_ _--_ + * / \/ \/ \/ | \|/ \/ \/ \/ \ + * / /\ /\ /\ | /|\ /\ /\ /\ \ + * / / \ / \ / \ | / | \ / \ / \ / \ \ + * / / \/ \/ \|/ | \/ \/ \ \ \ + * ----[\\\\\\\\\\\\\\\\\\\\\\\\]---|----------------------------- + * | + * + * W_L_STOP_1 + */ + + shift = exp + 15 - SCALING; + + Int16 dat1 = *(pFreq_2_Time_data_2++); + Int16 win1 = *(pShort_Window_2--); + + temp = *(pScrath_mem); + for (i = SHORT_WINDOW; i != 0; i--) + { + test = fxp_mul_16_by_16(dat1, win1) >> shift; + + temp += test; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + + limiter(*(pInterleaved_output), (temp + *(pOverlap_and_Add_Buffer_2x++))); + + pInterleaved_output += 2; + + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + temp = *(pScrath_mem); + + } + + } /* if (exp < 16) */ + else + { + test = *(pScrath_mem); + temp = *(pOverlap_and_Add_Buffer_2x++); + + for (i = SHORT_WINDOW; i != 0; i--) + { + limiter(*(pInterleaved_output), (temp + test)); + + pInterleaved_output += 2; + + *(pScrath_mem++) = 0; + test = *(pScrath_mem); + temp = *(pOverlap_and_Add_Buffer_2x++); + } + } + + } /* for ( wnd=NUM_SHORT_WINDOWS/2-1; wnd>=0; wnd--) */ + + pOverlap_and_Add_Buffer_2x = &Time_data[W_L_STOP_1]; + + pScrath_mem = pScrath_mem_entry; + + pInterleaved_output_2 -= (SHORT_WINDOW * 2); + pInterleaved_output = pInterleaved_output_2; + + test = *(pScrath_mem++); + temp = *(pOverlap_and_Add_Buffer_2x++); + + for (i = SHORT_WINDOW; i != 0; i--) + { + limiter(*(pInterleaved_output), (temp + test)); + + pInterleaved_output += 2; + test = *(pScrath_mem++); + temp = *(pOverlap_and_Add_Buffer_2x++); + + } + + pOverlap_and_Add_Buffer_1x = Time_data; + + pInterleaved_output = Interleaved_output; + + + temp = *(pOverlap_and_Add_Buffer_1x++); + for (i = W_L_STOP_1; i != 0; i--) + { + limiter(*(pInterleaved_output), temp); + + pInterleaved_output += 2; + temp = *(pOverlap_and_Add_Buffer_1x++); + + } + + pOverlap_and_Add_Buffer_1x = &Time_data[0]; + + pOverlap_and_Add_Buffer_2 = &pFrequency_data[LONG_WINDOW]; + + /* + * update overlap and add buffer, + * so is ready for next iteration + */ + + for (int i = 0; i < W_L_STOP_2; i++) + { + temp = *(pOverlap_and_Add_Buffer_2++); + *(pOverlap_and_Add_Buffer_1x++) = temp; + } + + pv_memset( + pOverlap_and_Add_Buffer_1x, + 0, + W_L_STOP_1*sizeof(*pOverlap_and_Add_Buffer_1x)); + + } /* if ( wnd_seq != EIGHT_SHORT_SEQUENCE) */ + + + + +} /* trans4m_freq_2_time_fxp */ + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/trans4m_time_2_freq_fxp.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/trans4m_time_2_freq_fxp.cpp new file mode 100644 index 0000000..b52fb31 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/trans4m_time_2_freq_fxp.cpp @@ -0,0 +1,600 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: trans4m_time_2_freq_fxp.cpp + Function: trans4m_time_2_freq_fxp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Time2Freq_data = buffer with data in the time domain, it holds 2048 + points of input time data + Output holds frequency (first 1024 points ) + type Int32 + + wnd_seq = window sequence + type WINDOW_SEQUENCE + + wnd_shape_prev_bk = previous window shape type + type Int + + wnd_shape_this_bk = current window shape type + type Int + + pQ_format = Holds the Q format of the data in, and data out + type Int * + + mem_4_in_place_FFT[] = scratch memory for computing FFT, 1024 point + type Int32 + + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + Frequency information (1024 pts.) is returned in Time2Freq_data + pQ_format content spectral coefficients Q format + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + +The time/frequency representation of the signal is mapped onto the frequency +domain by feeding it into the filterbank module. This module consists of +a modified discrete cosine transform (MDCT), (windowing and DCT). +In order to adapt the time/frequency resolution of the filterbank to the + characteristics of the input signal, a block switching tool is also +adopted. N represents the window length, where N is a function of the +window_sequence. For each channel, the N time values are transformed into the +N/2 frequency domain values via the MDCT. + +The adaptation of the time-frequency resolution of the filterbank to the +characteristics of the input signal is done by shifting between transforms +whose input lengths are either 2048 or 256 samples. By enabling the block +switching tool, the following transitions are meaningful: + +from ONLY_LONG_SEQUENCE to { LONG_START_SEQUENCE + ONLY_LONG_SEQUENCE + +from LONG_START_SEQUENCE to { LONG_STOP_SEQUENCE + EIGHT_SHORT_SEQUENCE + +from LONG_STOP_SEQUENCE to { LONG_START_SEQUENCE + ONLY_LONG_SEQUENCE + +from EIGHT_SHORT_SEQUENCE to { LONG_STOP_SEQUENCE + EIGHT_SHORT_SEQUENCE + +Window shape decisions are made by the encoder on a frame-by-frame-basis. +The window selected is applicable to the second half of the window function +only, since the first half is constrained to use the appropriate window +shape from the preceding frame. +The 2048 time-domain values x'(i)(n), (i window, n sample) to be windowed are +the last 1024 values of the previous window_sequence concatenated with 1024 +values of the current block. The formula below shows this fact: + + | x(i-1)(n+1024) for 0 < n < 1024 + x'(i)(n) { + | x(i)(n) for 1024 < n < 2048 + + + +Once the window shape is selected, the window_shape syntax element is +initialized. Together with the chosen window_sequence all information needed +for windowing exist. +With the window halves described below all window_sequences can be assembled. +For window_shape == 1, the window coefficients are given by the Kaiser - +Bessel derived (KBD) window. +Otherwise, for window_shape == 0, a sine window is employed. + +The window length N can be 2048 or 256 for the KBD and the sine window. +All four window_sequences explained below have a total length of 2048 +samples. +For all kinds of window_sequences the window_shape of the left half of +the first transform window is determined by the window shape of the previous +block. +------------------------------------------------------------------------------ + REQUIREMENTS + + This module shall implement a scheme to switch between window types and + in turn perform time to frequency transformations + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO 14496-3:1999, pag 111 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF ( wnd_seq == EIGHT_SHORT_SEQUENCE) + THEN + + + FOR ( wnd=0; wndthis_bk][SHORT_WINDOW_m_1] + + FOR( i=0, j=SHORT_WINDOW; ithis_bk][SHORT_WINDOW_m_1]; + + FOR ( i=0; iprev_bk][0]; + + FOR ( i=0; ithis_bk][LONG_WINDOW_m_1]; + + FOR ( i=0; i 0; i--) + { + + *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1++) >> shift; + pAux_temp_1++; + *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2++) >> shift; + pAux_temp_2++; + + } + + + /* data unchanged from LONG_WINDOW to W_L_START_1 */ + pAux_temp_1 = &pAux_temp[LONG_WINDOW]; + if (shift) + { + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--) + { + *(pAux_temp_1++) >>= shift; + *(pAux_temp_1++) >>= shift; + } + } + + + pAux_temp_1 = &pAux_temp[W_L_START_1]; + pAux_temp_2 = &pAux_temp_1[HALF_SHORT_WINDOW]; + + pShort_Window_1 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + pShort_Window_2 = pShort_Window_1 - HALF_SHORT_WINDOW; + + for (i = HALF_SHORT_WINDOW; i > 0; i--) + { + + *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pShort_Window_1--) >> shift; + pAux_temp_1++; + *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pShort_Window_2--) >> shift; + pAux_temp_2++; + + } + + pAux_temp_1 = &pAux_temp[W_L_START_2]; + + pv_memset( + pAux_temp_1, + 0, + (LONG_BLOCK1 - W_L_START_2)*sizeof(*pAux_temp_1)); + + break; + + + case LONG_STOP_SEQUENCE: + + pv_memset( + pAux_temp_1, + 0, + (W_L_STOP_1)*sizeof(*pAux_temp_1)); + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0]; + pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW]; + + pAux_temp_1 = &pAux_temp_1[W_L_STOP_1]; + pAux_temp_2 = pAux_temp_1 + HALF_SHORT_WINDOW; + + for (i = HALF_SHORT_WINDOW; i > 0; i--) + { + + *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pShort_Window_1++) >> shift; + pAux_temp_1++; + *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pShort_Window_2++) >> shift; + pAux_temp_2++; + + + } + + /* data unchanged from W_L_STOP_2 to LONG_WINDOW */ + pAux_temp_1 = &pAux_temp[W_L_STOP_2]; + + if (shift) + { + for (i = ((LONG_WINDOW - W_L_STOP_2) >> 1); i != 0; i--) + { + *(pAux_temp_1++) >>= shift; + *(pAux_temp_1++) >>= shift; + } + } + + + + pAux_temp_1 = &pAux_temp[LONG_WINDOW]; + pAux_temp_2 = pAux_temp_1 + HALF_LONG_WINDOW; + + pLong_Window_1 = + &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + + pLong_Window_2 = &pLong_Window_1[-HALF_LONG_WINDOW]; + + for (i = HALF_LONG_WINDOW; i > 0; i--) + { + *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1--) >> shift; + pAux_temp_1++; + *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2--) >> shift; + pAux_temp_2++; + + } + + break; + + case ONLY_LONG_SEQUENCE: + default: + + pAux_temp_2 = &pAux_temp[LONG_WINDOW]; + + pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0]; + + + pLong_Window_2 = + &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + + for (i = LONG_WINDOW; i > 0; i--) + { + + *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1++) >> shift; + pAux_temp_1++; + *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2--) >> shift; + pAux_temp_2++; + } + + break; + + } /* end switch ( wnd_seq) */ + + + + *pQ_format += mdct_fxp( + pAux_temp, + mem_4_in_place_FFT, + LONG_BLOCK1); + + + } /* end if( wnd_seq != EIGHT_SHORT_SEQUENCE) */ + + + + /*****************************************/ + /* decoding process for short window */ + /*****************************************/ + + /* + * For short window the following code will be applied + * in the future when short window is supported in the + * standards + */ + /*------------------------------------------------------------------------- + + * pAux_temp = &mem_4_in_place_FFT[(2*SHORT_BLOCK1)]; + * + * for ( wnd=0; wnd0; i--) + * { + * temp = (*pAux_temp_1) * *pShort_Window_1++; + * *pAux_temp_1++ = (temp + 0x08000L) >> 16; + * + * temp = (*pAux_temp_2) * *pShort_Window_2--; + * *pAux_temp_2++ = (temp + 0x08000L) >> 16; + * + * } + * + * + * exp = mdct_fxp( + * pAux_temp, + * mem_4_in_place_FFT, + * SHORT_BLOCK1); + * + * + * exp += Q_aux; + * + * pAux_temp_1 = pAux_temp; + * pAux_temp_2 = pAux_temp_1 + HALF_SHORT_WINDOW; + * pTime_data_1 = &Time2Freq_data[wnd*SHORT_WINDOW]; + * pTime_data_2 = pTime_data_1 + HALF_SHORT_WINDOW; + * + * + * if (exp > 0) + * { + * for ( i=HALF_SHORT_WINDOW; i>0; i--) + * { + * *pTime_data_1++ = (*pAux_temp_1++>>exp); + * *pTime_data_2++ = (*pAux_temp_2++>>exp); + * } + * } + * else if (exp < 0) + * { + * exp = -exp; + * for ( i=HALF_SHORT_WINDOW; i>0; i--) + * { + * *pTime_data_1++ = (*pAux_temp_1++<0; i--) + * { + * *pTime_data_1++ = (*pAux_temp_1++); + * *pTime_data_2++ = (*pAux_temp_2++); + * } + * } + * + * } + * + * } + * + *--------------------------------------------------------------------------*/ + +} /* trans4m_time_2_freq_fxp */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/unpack_idx.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/unpack_idx.cpp new file mode 100644 index 0000000..d4672e0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/unpack_idx.cpp @@ -0,0 +1,584 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: unpack_idx.cpp + Function: unpack_idx + unpack_idx_sgn + unpack_idx_esc + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Int quant_spec[] = Array for storage of the quantized + spectral coefficients. Length is either 2 or 4. + See Ref #1, Page 76 for a complete description. + + Int codeword_indx = The index into the Huffman table. + Range is [1-288] + + const Hcb *pHuffCodebook = Pointer to HuffmanCodebook information. + + BITS *pInputStream = Pointer to the bitstream buffer. + Int *max = Pointer to maximum coefficient value. + + Local Stores/Buffers/Pointers Needed: + const UInt div_mod[18] = An array with the values for 1/mod + stored in Q-formats 13. + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + Int quant_spec[] = Output (the quantized and signed spectral coefficients) + returned via this pointer. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function decodes quantized spectral coefficients and decode their signs + from the input bitstream. Quantized spectral coefficients are transmitted as + four-tuples or 2-tuples, and this information is conveyed to the function via + the variable HuffCodebook->dim. + + See Reference #1 for a complete description +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall correctly calculate pQuantSpec[], given the inputs + + codeword_indx = {1-288}; + HuffCodebook->off = {0, 1, 4}; + HuffCodebook->mod = {3, 8, 9, 13, 17}; + + mod = LAV + 1 if unsigned codebook + mod = 2*LAV + 1 if signed codebook + + Range of values for LAV is {2,7,12,16} if unsigned + {1,4} if signed + + Additionally, + LAV <= 2 if dim == 4 + + This restricts mod == 3 if dim == 4 + and mod == {3, 8, 9, 13, 17} if dim == 2 + + This function will NOT function correctly if fed values that do not + meet the requirements as stated above. + + This limitation on the range of values was determined by analysis + of Reference #1 (see below.) + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.3.3 Decoding Process + Subpart 4.6.4 Tables + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF (pHuffCodebook->dim == 4) + *(pQuantSpec) = codeword_indx/(3^3); + codeword_indx = codeword_indx - *(pQuantSpec)*(3^3); + *(pQuantSpec) = *(pQuantSpec) - off; + + pQuantSpec = pQuantSpec + 1; + + *(pQuantSpec) = codeword_indx/(3^2); + codeword_indx = codeword_indx - *(pQuantSpec)*(3^2); + *(pQuantSpec) = *(pQuantSpec) - off; + + pQuantSpec = pQuantSpec + 1; + ENDIF + + *(pQuantSpec) = codeword_indx/mod; + codeword_indx = codeword_indx - (*pQuantSpec)*mod; + *(pQuantSpec) = *(pQuantSpec) - off; + + pQuantSpec = pQuantSpec + 1; + + *(pQuantSpec) = codeword_indx - off; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_hcb.h" +#include "ibstream.h" +#include "unpack_idx.h" + +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define DIV_3_CUBED 19 /* 19 = 1/27 in Q-9 format */ +#define THREE_CUBED 27 /* 27 = 3^3 */ + +#define DIV_3_SQUARED 57 /* 57 = 1/9 in Q-9 format */ +#define THREE_SQUARED 9 /* 9 = 3^2 */ + +#define Q_FORMAT_MOD 13 /* Q-format for 1/mod table */ +#define Q_FORMAT_MOD2 9 /* Q-format for DIV_3_SQUARED */ +#define Q_FORMAT_MOD3 9 /* Q-format for DIV_3_CUBED */ + +#define LOWER_5_BITS_MASK 0x1F + + + +#define pv_abs(x) ((x) > 0)? (x) : (-x) + + + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------- + Possible values for mod = {3,8,9,13,17} + + There exists "empty" spaces in the table. These can potentially + be utilized by other const tables, if available memory becomes an issue. +---------------------------------------------------------------------------*/ + +const Int div_mod[18] = /* mod index Q-format */ + { + /* ----------------------- */ + 0xCC, /* | | 0 | */ + 0xCC, /* | | 1 | */ + 0xCC, /* | | 2 | */ + 2731, /* | 3 | 3 | 13 */ + 0xCC, /* | | 4 | */ + 0xCC, /* | | 5 | */ + 0xCC, /* | | 6 | */ + 0xCC, /* | | 7 | */ + 1025, /* | 8 | 8 | 13 */ + 911, /* | 9 | 9 | 13 */ + 0xCC, /* | | 10 | */ + 0xCC, /* | | 11 | */ + 0xCC, /* | | 12 | */ + 631, /* | 13 | 13 | 13 */ + 0xCC, /* | | 14 | */ + 0xCC, /* | | 15 | */ + 0xCC, /* | | 16 | */ + 482, /* | 17 | 17 | 13 */ + }; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void unpack_idx( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max) +{ + Int16 *pQuantSpec = &quant_spec[0]; + Int temp_spec; + + const Int mod = pHuffCodebook->mod; + const Int off = pHuffCodebook->off; + + OSCL_UNUSED_ARG(pInputStream); + + + if (pHuffCodebook->dim == DIMENSION_4) + { + /* Calculate pQuantSpec[0] */ + + temp_spec = (codeword_indx * DIV_3_CUBED) >> Q_FORMAT_MOD3; + + codeword_indx -= temp_spec * THREE_CUBED; + + temp_spec -= off; + *pQuantSpec++ = (Int16)temp_spec; + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + + /* Calculate pQuantSpec[1] */ + temp_spec = (codeword_indx * DIV_3_SQUARED) >> Q_FORMAT_MOD2; + + codeword_indx -= temp_spec * THREE_SQUARED; + + temp_spec -= off; + *pQuantSpec++ = (Int16)temp_spec; + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + } + + /* + * Calculate pQuantSpec[2] if dim == 4 + * Calculate pQuantSpec[0] if dim == 2 + */ + + temp_spec = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD; + + codeword_indx -= temp_spec * mod; + + temp_spec -= off; + *pQuantSpec++ = (Int16)temp_spec; + + temp_spec = pv_abs(temp_spec); + + + if (temp_spec > *max) + { + *max = temp_spec; + } + + /* + * Calculate pQuantSpec[3] if dim == 4 + * Calculate pQuantSpec[1] if dim == 2 + */ + codeword_indx -= off; + *pQuantSpec = (Int16)codeword_indx ; + + + codeword_indx = pv_abs(codeword_indx); + + if (codeword_indx > *max) + { + *max = codeword_indx; + } + + + return ; +} /* unpack_idx */ + + +void unpack_idx_sgn( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max) +{ + Int16 *pQuantSpec = &quant_spec[0]; + Int temp_spec; + Int sgn; + + const Int mod = pHuffCodebook->mod; + const Int off = pHuffCodebook->off; + + + + if (pHuffCodebook->dim == DIMENSION_4) + { + /* Calculate pQuantSpec[0] */ + preload_cache((Int32 *)pQuantSpec); + temp_spec = (codeword_indx * DIV_3_CUBED) >> Q_FORMAT_MOD3; + + codeword_indx -= temp_spec * THREE_CUBED; + + temp_spec -= off; + if (temp_spec) + { + sgn = get1bits(pInputStream); + + + *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec); + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + + } + else + { + *pQuantSpec++ = 0; + } + + /* Calculate pQuantSpec[1] */ + temp_spec = (codeword_indx * DIV_3_SQUARED) >> Q_FORMAT_MOD2; + + codeword_indx -= temp_spec * THREE_SQUARED; + + temp_spec -= off; + if (temp_spec) + { + + sgn = get1bits(pInputStream); + + *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec); + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + } + else + { + *pQuantSpec++ = 0; + } + } + + /* + * Calculate pQuantSpec[2] if dim == 4 + * Calculate pQuantSpec[0] if dim == 2 + */ + + temp_spec = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD; + + codeword_indx -= temp_spec * mod; + + temp_spec -= off; + if (temp_spec) + { + + sgn = get1bits(pInputStream); + + *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec); + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + } + else + { + *pQuantSpec++ = 0; + } + + /* + * Calculate pQuantSpec[3] if dim == 4 + * Calculate pQuantSpec[1] if dim == 2 + */ + codeword_indx -= off; + if (codeword_indx) + { + + sgn = get1bits(pInputStream); + + *pQuantSpec = (Int16)((sgn) ? -codeword_indx : codeword_indx); + + codeword_indx = pv_abs(codeword_indx); + + if (codeword_indx > *max) + { + *max = codeword_indx; + } + } + else + { + *pQuantSpec = 0; + } + + return ; +} /* unpack_idx_sgn */ + + +void unpack_idx_esc( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max) +{ + Int temp_spec; + Int sgn1 = 0, sgn2 = 0; + Int N; + Int32 esc_seq; + + const Int mod = pHuffCodebook->mod; + const Int off = pHuffCodebook->off; + + + temp_spec = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD; + + codeword_indx -= temp_spec * mod; + + temp_spec -= off; + if (temp_spec) + { + sgn1 = get1bits(pInputStream); + } + + codeword_indx -= off; + if (codeword_indx) + { + sgn2 = get1bits(pInputStream); + } + + + if ((temp_spec & LOWER_5_BITS_MASK) == 16) + { + N = 3; + do + { + N++; + + esc_seq = get1bits(pInputStream); + + } + while (esc_seq != 0); + + esc_seq = getbits(N, pInputStream); + + esc_seq += (1 << N); + + + temp_spec = (Int)((temp_spec * esc_seq) >> 4); + + } + + + if (sgn1) + { + quant_spec[0] = (Int16)(-temp_spec); + } + else + { + quant_spec[0] = (Int16)temp_spec; + } + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + + if ((codeword_indx & LOWER_5_BITS_MASK) == 16) + { + N = 3; + do + { + N++; + + esc_seq = get1bits(pInputStream); + + } + while (esc_seq != 0); + + esc_seq = getbits(N, pInputStream); + + esc_seq += (1 << N); + + codeword_indx = (Int)((codeword_indx * esc_seq) >> 4); + } + + + + + if (sgn2) + { + quant_spec[1] = (Int16)(-codeword_indx); + } + else + { + quant_spec[1] = (Int16)codeword_indx; + } + + + codeword_indx = pv_abs(codeword_indx); + + if (codeword_indx > *max) + { + *max = codeword_indx; + } + + + return ; +} /* unpack_idx_esc */ + + +/*############################################################################################*/ + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/unpack_idx.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/unpack_idx.h new file mode 100644 index 0000000..0b4bb24 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/unpack_idx.h @@ -0,0 +1,118 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: unpack_idx.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This header file includes the function definition for unpack_idx() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef UNPACK_IDX_H +#define UNPACK_IDX_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_hcb.h" +#include "s_bits.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define DIMENSION_4 4 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + void unpack_idx( + Int16 QuantSpec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max); + void unpack_idx_sgn( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max); + void unpack_idx_esc( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max); + + + void unpack_idx_sgn_parse_bits( + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream); + void unpack_idx_esc_parse_bits( + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/window_block_fxp.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/window_block_fxp.h new file mode 100644 index 0000000..0d59b7c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/window_block_fxp.h @@ -0,0 +1,206 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: window_block_fxp.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for window and block switch + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7 Part 7: Advanced Audo Coding (AAC) + + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef WINDOW_BLOCK_FXP_H +#define WINDOW_BLOCK_FXP_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_window_shape.h" +#include "e_window_sequence.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ +#define LONG_WINDOW (1024) +#define SHORT_WINDOW (128) + +#define HALF_LONG_WINDOW (LONG_WINDOW>>1) +#define HALF_SHORT_WINDOW (SHORT_WINDOW>>1) + +#define NUM_SHORT_WINDOWS (8) +#define LONG_WINDOW_m_1 (LONG_WINDOW-1) +#define SHORT_WINDOW_m_1 (SHORT_WINDOW-1) + + /* + * Limits for window sequences, they are used to build + * each long window, they are defined in the standards + */ +#define W_L_START_1 ((3*LONG_WINDOW - SHORT_WINDOW)>>1) +#define W_L_START_2 ((3*LONG_WINDOW + SHORT_WINDOW)>>1) +#define W_L_STOP_1 ((LONG_WINDOW - SHORT_WINDOW)>>1) +#define W_L_STOP_2 ((LONG_WINDOW + SHORT_WINDOW)>>1) + + +#define LONG_BLOCK1 (2*LONG_WINDOW) +#define SHORT_BLOCK1 (2*SHORT_WINDOW) + + +#define SCALING 10 +#define ROUNDING (1<<(SCALING-1)) + + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + extern const Int16 Short_Window_KBD_fxp[ SHORT_WINDOW]; + extern const Int16 Long_Window_KBD_fxp[ LONG_WINDOW]; + extern const Int16 Short_Window_sine_fxp[ SHORT_WINDOW]; + extern const Int16 Long_Window_sine_fxp[ LONG_WINDOW]; + + extern const Int16 * const Long_Window_fxp[]; + extern const Int16 * const Short_Window_fxp[]; + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + void trans4m_freq_2_time_fxp( + Int32 Frequency_data[], + Int32 Time_data[], +#ifdef AAC_PLUS + Int32 Output_buffer[], +#else + Int16 Output_buffer[], +#endif + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int Q_format, + Int32 abs_max_per_window[], + Int32 freq_2_time_buffer[] , + Int16 *Interleave_output + ); + + + + void trans4m_freq_2_time_fxp_1( + Int32 Frequency_data[], + Int32 Time_data[], + Int16 Output_buffer[], + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int Q_format, + Int32 abs_max_per_window[], + Int32 freq_2_time_buffer[] + ); + + + void trans4m_freq_2_time_fxp_2( + Int32 Frequency_data[], + Int32 Time_data[], + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int Q_format, + Int32 abs_max_per_window[], + Int32 freq_2_time_buffer[] , + Int16 *Interleave_output + ); + + void trans4m_time_2_freq_fxp( + Int32 Time2Freq_data[], + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int *pQ_format, + Int32 mem_4_in_place_FFT[]); + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif /* WINDOW_BLOCK_FXP_H */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/window_tables_fxp.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/window_tables_fxp.cpp new file mode 100644 index 0000000..e031fd1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/src/window_tables_fxp.cpp @@ -0,0 +1,706 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: window_tables_fxp.cpp + Functions: + + ------------------------------------------------------------------------------ + MODULE DESCRIPTION + + Window tables + + For a sine table with N points: + + w_left = sin(pi/N (n + 1/2)) for 0 =< n < N/2 + + w_rigth = sin(pi/N (n + 1/2)) for N/2 =< n < N + + + For Kaiser-Bessel derived (KBD) + + n N/2 + w_left = sqrt(( SUM W(p,a) )/( SUM W(p,a) ) for 0 =< n < N/2 + p=0 p=0 + + + N-n-1 N/2 + w_rigth = sqrt(( SUM W(p,a) )/( SUM W(p,a) ) for N/2 =< n < N + p=0 p=0 + + + W(p,a) see ISO 14496-3, pag 113 + +------------------------------------------------------------------------------ + REQUIREMENTS + + This module shall implement the fix point verwion of the windowing tables + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO 14496-3, pag 113 + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "window_block_fxp.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +const Int16 Long_Window_sine_fxp[LONG_WINDOW] = +{ + + + 0x0019, 0x004B, 0x007E, 0x00B0, + 0x00E2, 0x0114, 0x0147, 0x0179, + 0x01AB, 0x01DD, 0x0210, 0x0242, + 0x0274, 0x02A7, 0x02D9, 0x030B, + 0x033D, 0x0370, 0x03A2, 0x03D4, + 0x0406, 0x0438, 0x046B, 0x049D, + 0x04CF, 0x0501, 0x0534, 0x0566, + 0x0598, 0x05CA, 0x05FC, 0x062F, + 0x0661, 0x0693, 0x06C5, 0x06F7, + 0x072A, 0x075C, 0x078E, 0x07C0, + 0x07F2, 0x0825, 0x0857, 0x0889, + 0x08BB, 0x08ED, 0x091F, 0x0951, + 0x0984, 0x09B6, 0x09E8, 0x0A1A, + 0x0A4C, 0x0A7E, 0x0AB0, 0x0AE2, + 0x0B14, 0x0B46, 0x0B78, 0x0BAB, + 0x0BDD, 0x0C0F, 0x0C41, 0x0C73, + 0x0CA5, 0x0CD7, 0x0D09, 0x0D3B, + 0x0D6D, 0x0D9F, 0x0DD1, 0x0E03, + 0x0E35, 0x0E67, 0x0E99, 0x0ECA, + 0x0EFC, 0x0F2E, 0x0F60, 0x0F92, + 0x0FC4, 0x0FF6, 0x1028, 0x105A, + 0x108B, 0x10BD, 0x10EF, 0x1121, + 0x1153, 0x1185, 0x11B6, 0x11E8, + 0x121A, 0x124C, 0x127D, 0x12AF, + 0x12E1, 0x1312, 0x1344, 0x1376, + 0x13A8, 0x13D9, 0x140B, 0x143C, + 0x146E, 0x14A0, 0x14D1, 0x1503, + 0x1534, 0x1566, 0x1598, 0x15C9, + 0x15FB, 0x162C, 0x165E, 0x168F, + 0x16C1, 0x16F2, 0x1724, 0x1755, + 0x1786, 0x17B8, 0x17E9, 0x181B, + 0x184C, 0x187D, 0x18AF, 0x18E0, + 0x1911, 0x1942, 0x1974, 0x19A5, + 0x19D6, 0x1A07, 0x1A39, 0x1A6A, + 0x1A9B, 0x1ACC, 0x1AFD, 0x1B2E, + 0x1B60, 0x1B91, 0x1BC2, 0x1BF3, + 0x1C24, 0x1C55, 0x1C86, 0x1CB7, + 0x1CE8, 0x1D19, 0x1D4A, 0x1D7B, + 0x1DAC, 0x1DDC, 0x1E0D, 0x1E3E, + 0x1E6F, 0x1EA0, 0x1ED1, 0x1F01, + 0x1F32, 0x1F63, 0x1F94, 0x1FC4, + 0x1FF5, 0x2026, 0x2056, 0x2087, + 0x20B7, 0x20E8, 0x2119, 0x2149, + 0x217A, 0x21AA, 0x21DB, 0x220B, + 0x223C, 0x226C, 0x229C, 0x22CD, + 0x22FD, 0x232E, 0x235E, 0x238E, + 0x23BE, 0x23EF, 0x241F, 0x244F, + 0x247F, 0x24AF, 0x24E0, 0x2510, + 0x2540, 0x2570, 0x25A0, 0x25D0, + 0x2600, 0x2630, 0x2660, 0x2690, + 0x26C0, 0x26F0, 0x2720, 0x274F, + 0x277F, 0x27AF, 0x27DF, 0x280F, + 0x283E, 0x286E, 0x289E, 0x28CD, + 0x28FD, 0x292D, 0x295C, 0x298C, + 0x29BB, 0x29EB, 0x2A1A, 0x2A4A, + 0x2A79, 0x2AA8, 0x2AD8, 0x2B07, + 0x2B37, 0x2B66, 0x2B95, 0x2BC4, + 0x2BF4, 0x2C23, 0x2C52, 0x2C81, + 0x2CB0, 0x2CDF, 0x2D0E, 0x2D3D, + 0x2D6C, 0x2D9B, 0x2DCA, 0x2DF9, + 0x2E28, 0x2E57, 0x2E86, 0x2EB5, + 0x2EE3, 0x2F12, 0x2F41, 0x2F70, + 0x2F9E, 0x2FCD, 0x2FFC, 0x302A, + 0x3059, 0x3087, 0x30B6, 0x30E4, + 0x3113, 0x3141, 0x316F, 0x319E, + 0x31CC, 0x31FA, 0x3229, 0x3257, + 0x3285, 0x32B3, 0x32E1, 0x330F, + 0x333E, 0x336C, 0x339A, 0x33C8, + 0x33F6, 0x3423, 0x3451, 0x347F, + 0x34AD, 0x34DB, 0x3509, 0x3536, + 0x3564, 0x3592, 0x35BF, 0x35ED, + 0x361A, 0x3648, 0x3676, 0x36A3, + 0x36D0, 0x36FE, 0x372B, 0x3759, + 0x3786, 0x37B3, 0x37E0, 0x380E, + 0x383B, 0x3868, 0x3895, 0x38C2, + 0x38EF, 0x391C, 0x3949, 0x3976, + 0x39A3, 0x39D0, 0x39FD, 0x3A29, + 0x3A56, 0x3A83, 0x3AB0, 0x3ADC, + 0x3B09, 0x3B35, 0x3B62, 0x3B8E, + 0x3BBB, 0x3BE7, 0x3C14, 0x3C40, + 0x3C6C, 0x3C99, 0x3CC5, 0x3CF1, + 0x3D1D, 0x3D4A, 0x3D76, 0x3DA2, + 0x3DCE, 0x3DFA, 0x3E26, 0x3E52, + 0x3E7D, 0x3EA9, 0x3ED5, 0x3F01, + 0x3F2D, 0x3F58, 0x3F84, 0x3FB0, + 0x3FDB, 0x4007, 0x4032, 0x405E, + 0x4089, 0x40B5, 0x40E0, 0x410B, + 0x4136, 0x4162, 0x418D, 0x41B8, + 0x41E3, 0x420E, 0x4239, 0x4264, + 0x428F, 0x42BA, 0x42E5, 0x4310, + 0x433B, 0x4365, 0x4390, 0x43BB, + 0x43E5, 0x4410, 0x443B, 0x4465, + 0x448F, 0x44BA, 0x44E4, 0x450F, + 0x4539, 0x4563, 0x458D, 0x45B8, + 0x45E2, 0x460C, 0x4636, 0x4660, + 0x468A, 0x46B4, 0x46DE, 0x4707, + 0x4731, 0x475B, 0x4785, 0x47AE, + 0x47D8, 0x4802, 0x482B, 0x4855, + 0x487E, 0x48A7, 0x48D1, 0x48FA, + 0x4923, 0x494D, 0x4976, 0x499F, + 0x49C8, 0x49F1, 0x4A1A, 0x4A43, + 0x4A6C, 0x4A95, 0x4ABE, 0x4AE6, + 0x4B0F, 0x4B38, 0x4B61, 0x4B89, + 0x4BB2, 0x4BDA, 0x4C03, 0x4C2B, + 0x4C53, 0x4C7C, 0x4CA4, 0x4CCC, + 0x4CF4, 0x4D1D, 0x4D45, 0x4D6D, + 0x4D95, 0x4DBD, 0x4DE5, 0x4E0D, + 0x4E34, 0x4E5C, 0x4E84, 0x4EAB, + 0x4ED3, 0x4EFB, 0x4F22, 0x4F4A, + 0x4F71, 0x4F99, 0x4FC0, 0x4FE7, + 0x500E, 0x5036, 0x505D, 0x5084, + 0x50AB, 0x50D2, 0x50F9, 0x5120, + 0x5147, 0x516D, 0x5194, 0x51BB, + 0x51E2, 0x5208, 0x522F, 0x5255, + 0x527C, 0x52A2, 0x52C8, 0x52EF, + 0x5315, 0x533B, 0x5361, 0x5387, + 0x53AE, 0x53D4, 0x53FA, 0x541F, + 0x5445, 0x546B, 0x5491, 0x54B7, + 0x54DC, 0x5502, 0x5527, 0x554D, + 0x5572, 0x5598, 0x55BD, 0x55E2, + 0x5608, 0x562D, 0x5652, 0x5677, + 0x569C, 0x56C1, 0x56E6, 0x570B, + 0x5730, 0x5754, 0x5779, 0x579E, + 0x57C2, 0x57E7, 0x580C, 0x5830, + 0x5854, 0x5879, 0x589D, 0x58C1, + 0x58E5, 0x590A, 0x592E, 0x5952, + 0x5976, 0x599A, 0x59BD, 0x59E1, + 0x5A05, 0x5A29, 0x5A4C, 0x5A70, + 0x5A94, 0x5AB7, 0x5ADA, 0x5AFE, + 0x5B21, 0x5B44, 0x5B68, 0x5B8B, + 0x5BAE, 0x5BD1, 0x5BF4, 0x5C17, + 0x5C3A, 0x5C5D, 0x5C7F, 0x5CA2, + 0x5CC5, 0x5CE7, 0x5D0A, 0x5D2C, + 0x5D4F, 0x5D71, 0x5D94, 0x5DB6, + 0x5DD8, 0x5DFA, 0x5E1C, 0x5E3E, + 0x5E60, 0x5E82, 0x5EA4, 0x5EC6, + 0x5EE8, 0x5F09, 0x5F2B, 0x5F4D, + 0x5F6E, 0x5F90, 0x5FB1, 0x5FD2, + 0x5FF4, 0x6015, 0x6036, 0x6057, + 0x6078, 0x6099, 0x60BA, 0x60DB, + 0x60FC, 0x611D, 0x613D, 0x615E, + 0x617F, 0x619F, 0x61C0, 0x61E0, + 0x6200, 0x6221, 0x6241, 0x6261, + 0x6281, 0x62A1, 0x62C1, 0x62E1, + 0x6301, 0x6321, 0x6341, 0x6360, + 0x6380, 0x63A0, 0x63BF, 0x63DF, + 0x63FE, 0x641D, 0x643D, 0x645C, + 0x647B, 0x649A, 0x64B9, 0x64D8, + 0x64F7, 0x6516, 0x6535, 0x6554, + 0x6572, 0x6591, 0x65AF, 0x65CE, + 0x65EC, 0x660B, 0x6629, 0x6647, + 0x6666, 0x6684, 0x66A2, 0x66C0, + 0x66DE, 0x66FC, 0x6719, 0x6737, + 0x6755, 0x6772, 0x6790, 0x67AE, + 0x67CB, 0x67E8, 0x6806, 0x6823, + 0x6840, 0x685D, 0x687A, 0x6897, + 0x68B4, 0x68D1, 0x68EE, 0x690B, + 0x6927, 0x6944, 0x6961, 0x697D, + 0x699A, 0x69B6, 0x69D2, 0x69EE, + 0x6A0B, 0x6A27, 0x6A43, 0x6A5F, + 0x6A7B, 0x6A97, 0x6AB2, 0x6ACE, + 0x6AEA, 0x6B05, 0x6B21, 0x6B3C, + 0x6B58, 0x6B73, 0x6B8E, 0x6BAA, + 0x6BC5, 0x6BE0, 0x6BFB, 0x6C16, + 0x6C31, 0x6C4C, 0x6C66, 0x6C81, + 0x6C9C, 0x6CB6, 0x6CD1, 0x6CEB, + 0x6D06, 0x6D20, 0x6D3A, 0x6D54, + 0x6D6E, 0x6D88, 0x6DA2, 0x6DBC, + 0x6DD6, 0x6DF0, 0x6E0A, 0x6E23, + 0x6E3D, 0x6E56, 0x6E70, 0x6E89, + 0x6EA2, 0x6EBC, 0x6ED5, 0x6EEE, + 0x6F07, 0x6F20, 0x6F39, 0x6F52, + 0x6F6B, 0x6F83, 0x6F9C, 0x6FB4, + 0x6FCD, 0x6FE5, 0x6FFE, 0x7016, + 0x702E, 0x7046, 0x705F, 0x7077, + 0x708F, 0x70A6, 0x70BE, 0x70D6, + 0x70EE, 0x7105, 0x711D, 0x7134, + 0x714C, 0x7163, 0x717A, 0x7192, + 0x71A9, 0x71C0, 0x71D7, 0x71EE, + 0x7205, 0x721C, 0x7232, 0x7249, + 0x7260, 0x7276, 0x728D, 0x72A3, + 0x72B9, 0x72D0, 0x72E6, 0x72FC, + 0x7312, 0x7328, 0x733E, 0x7354, + 0x7369, 0x737F, 0x7395, 0x73AA, + 0x73C0, 0x73D5, 0x73EB, 0x7400, + 0x7415, 0x742A, 0x743F, 0x7454, + 0x7469, 0x747E, 0x7493, 0x74A8, + 0x74BC, 0x74D1, 0x74E5, 0x74FA, + 0x750E, 0x7522, 0x7537, 0x754B, + 0x755F, 0x7573, 0x7587, 0x759B, + 0x75AE, 0x75C2, 0x75D6, 0x75E9, + 0x75FD, 0x7610, 0x7624, 0x7637, + 0x764A, 0x765E, 0x7671, 0x7684, + 0x7697, 0x76A9, 0x76BC, 0x76CF, + 0x76E2, 0x76F4, 0x7707, 0x7719, + 0x772C, 0x773E, 0x7750, 0x7762, + 0x7774, 0x7786, 0x7798, 0x77AA, + 0x77BC, 0x77CE, 0x77DF, 0x77F1, + 0x7803, 0x7814, 0x7825, 0x7837, + 0x7848, 0x7859, 0x786A, 0x787B, + 0x788C, 0x789D, 0x78AE, 0x78BE, + 0x78CF, 0x78E0, 0x78F0, 0x7901, + 0x7911, 0x7921, 0x7931, 0x7941, + 0x7952, 0x7962, 0x7971, 0x7981, + 0x7991, 0x79A1, 0x79B0, 0x79C0, + 0x79CF, 0x79DF, 0x79EE, 0x79FD, + 0x7A0D, 0x7A1C, 0x7A2B, 0x7A3A, + 0x7A49, 0x7A57, 0x7A66, 0x7A75, + 0x7A83, 0x7A92, 0x7AA0, 0x7AAF, + 0x7ABD, 0x7ACB, 0x7AD9, 0x7AE7, + 0x7AF5, 0x7B03, 0x7B11, 0x7B1F, + 0x7B2D, 0x7B3A, 0x7B48, 0x7B55, + 0x7B63, 0x7B70, 0x7B7D, 0x7B8B, + 0x7B98, 0x7BA5, 0x7BB2, 0x7BBF, + 0x7BCB, 0x7BD8, 0x7BE5, 0x7BF1, + 0x7BFE, 0x7C0A, 0x7C17, 0x7C23, + 0x7C2F, 0x7C3B, 0x7C47, 0x7C53, + 0x7C5F, 0x7C6B, 0x7C77, 0x7C83, + 0x7C8E, 0x7C9A, 0x7CA5, 0x7CB1, + 0x7CBC, 0x7CC7, 0x7CD2, 0x7CDD, + 0x7CE8, 0x7CF3, 0x7CFE, 0x7D09, + 0x7D14, 0x7D1E, 0x7D29, 0x7D33, + 0x7D3E, 0x7D48, 0x7D52, 0x7D5C, + 0x7D67, 0x7D71, 0x7D7B, 0x7D84, + 0x7D8E, 0x7D98, 0x7DA2, 0x7DAB, + 0x7DB5, 0x7DBE, 0x7DC8, 0x7DD1, + 0x7DDA, 0x7DE3, 0x7DEC, 0x7DF5, + 0x7DFE, 0x7E07, 0x7E10, 0x7E18, + 0x7E21, 0x7E29, 0x7E32, 0x7E3A, + 0x7E42, 0x7E4B, 0x7E53, 0x7E5B, + 0x7E63, 0x7E6B, 0x7E73, 0x7E7A, + 0x7E82, 0x7E8A, 0x7E91, 0x7E99, + 0x7EA0, 0x7EA7, 0x7EAF, 0x7EB6, + 0x7EBD, 0x7EC4, 0x7ECB, 0x7ED2, + 0x7ED8, 0x7EDF, 0x7EE6, 0x7EEC, + 0x7EF3, 0x7EF9, 0x7EFF, 0x7F05, + 0x7F0C, 0x7F12, 0x7F18, 0x7F1E, + 0x7F23, 0x7F29, 0x7F2F, 0x7F35, + 0x7F3A, 0x7F40, 0x7F45, 0x7F4A, + 0x7F50, 0x7F55, 0x7F5A, 0x7F5F, + 0x7F64, 0x7F69, 0x7F6D, 0x7F72, + 0x7F77, 0x7F7B, 0x7F80, 0x7F84, + 0x7F88, 0x7F8D, 0x7F91, 0x7F95, + 0x7F99, 0x7F9D, 0x7FA1, 0x7FA4, + 0x7FA8, 0x7FAC, 0x7FAF, 0x7FB3, + 0x7FB6, 0x7FB9, 0x7FBD, 0x7FC0, + 0x7FC3, 0x7FC6, 0x7FC9, 0x7FCC, + 0x7FCE, 0x7FD1, 0x7FD4, 0x7FD6, + 0x7FD9, 0x7FDB, 0x7FDD, 0x7FE0, + 0x7FE2, 0x7FE4, 0x7FE6, 0x7FE8, + 0x7FEA, 0x7FEB, 0x7FED, 0x7FEF, + 0x7FF0, 0x7FF2, 0x7FF3, 0x7FF5, + 0x7FF6, 0x7FF7, 0x7FF8, 0x7FF9, + 0x7FFA, 0x7FFB, 0x7FFC, 0x7FFC, + 0x7FFD, 0x7FFD, 0x7FFE, 0x7FFE, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF + +}; + + +const Int16 Short_Window_sine_fxp[SHORT_WINDOW] = +{ + + 0x00C9, 0x025B, 0x03ED, 0x057F, + 0x0711, 0x08A2, 0x0A33, 0x0BC4, + 0x0D54, 0x0EE3, 0x1072, 0x1201, + 0x138F, 0x151C, 0x16A8, 0x1833, + 0x19BE, 0x1B47, 0x1CCF, 0x1E57, + 0x1FDD, 0x2161, 0x22E5, 0x2467, + 0x25E8, 0x2767, 0x28E5, 0x2A61, + 0x2BDC, 0x2D55, 0x2ECC, 0x3041, + 0x31B5, 0x3326, 0x3496, 0x3604, + 0x376F, 0x38D9, 0x3A40, 0x3BA5, + 0x3D07, 0x3E68, 0x3FC5, 0x4121, + 0x427A, 0x43D0, 0x4524, 0x4675, + 0x47C3, 0x490F, 0x4A58, 0x4B9D, + 0x4CE0, 0x4E20, 0x4F5D, 0x5097, + 0x51CE, 0x5302, 0x5432, 0x5560, + 0x568A, 0x57B0, 0x58D3, 0x59F3, + 0x5B0F, 0x5C28, 0x5D3E, 0x5E4F, + 0x5F5D, 0x6068, 0x616E, 0x6271, + 0x6370, 0x646C, 0x6563, 0x6656, + 0x6746, 0x6832, 0x6919, 0x69FD, + 0x6ADC, 0x6BB7, 0x6C8E, 0x6D61, + 0x6E30, 0x6EFB, 0x6FC1, 0x7083, + 0x7140, 0x71F9, 0x72AE, 0x735E, + 0x740A, 0x74B2, 0x7555, 0x75F3, + 0x768D, 0x7722, 0x77B3, 0x783F, + 0x78C7, 0x794A, 0x79C8, 0x7A41, + 0x7AB6, 0x7B26, 0x7B91, 0x7BF8, + 0x7C59, 0x7CB6, 0x7D0E, 0x7D62, + 0x7DB0, 0x7DFA, 0x7E3E, 0x7E7E, + 0x7EB9, 0x7EEF, 0x7F21, 0x7F4D, + 0x7F74, 0x7F97, 0x7FB4, 0x7FCD, + 0x7FE1, 0x7FF0, 0x7FF9, 0x7FFE +}; + + + +const Int16 Long_Window_KBD_fxp[LONG_WINDOW] = +{ + + 0x000A, 0x000E, 0x0012, 0x0015, + 0x0019, 0x001C, 0x0020, 0x0023, + 0x0026, 0x002A, 0x002D, 0x0030, + 0x0034, 0x0038, 0x003B, 0x003F, + 0x0043, 0x0047, 0x004B, 0x004F, + 0x0053, 0x0057, 0x005B, 0x0060, + 0x0064, 0x0069, 0x006D, 0x0072, + 0x0077, 0x007C, 0x0081, 0x0086, + 0x008B, 0x0091, 0x0096, 0x009C, + 0x00A1, 0x00A7, 0x00AD, 0x00B3, + 0x00B9, 0x00BF, 0x00C6, 0x00CC, + 0x00D3, 0x00DA, 0x00E0, 0x00E7, + 0x00EE, 0x00F5, 0x00FD, 0x0104, + 0x010C, 0x0113, 0x011B, 0x0123, + 0x012B, 0x0133, 0x013C, 0x0144, + 0x014D, 0x0156, 0x015F, 0x0168, + 0x0171, 0x017A, 0x0183, 0x018D, + 0x0197, 0x01A1, 0x01AB, 0x01B5, + 0x01BF, 0x01CA, 0x01D4, 0x01DF, + 0x01EA, 0x01F5, 0x0200, 0x020C, + 0x0217, 0x0223, 0x022F, 0x023B, + 0x0247, 0x0253, 0x0260, 0x026D, + 0x027A, 0x0287, 0x0294, 0x02A1, + 0x02AF, 0x02BC, 0x02CA, 0x02D8, + 0x02E7, 0x02F5, 0x0304, 0x0312, + 0x0321, 0x0331, 0x0340, 0x034F, + 0x035F, 0x036F, 0x037F, 0x038F, + 0x03A0, 0x03B0, 0x03C1, 0x03D2, + 0x03E3, 0x03F5, 0x0406, 0x0418, + 0x042A, 0x043C, 0x044F, 0x0461, + 0x0474, 0x0487, 0x049A, 0x04AE, + 0x04C1, 0x04D5, 0x04E9, 0x04FD, + 0x0512, 0x0526, 0x053B, 0x0550, + 0x0566, 0x057B, 0x0591, 0x05A7, + 0x05BD, 0x05D3, 0x05EA, 0x0601, + 0x0618, 0x062F, 0x0646, 0x065E, + 0x0676, 0x068E, 0x06A6, 0x06BF, + 0x06D8, 0x06F1, 0x070A, 0x0723, + 0x073D, 0x0757, 0x0771, 0x078C, + 0x07A6, 0x07C1, 0x07DC, 0x07F7, + 0x0813, 0x082F, 0x084B, 0x0867, + 0x0884, 0x08A0, 0x08BD, 0x08DA, + 0x08F8, 0x0916, 0x0933, 0x0952, + 0x0970, 0x098F, 0x09AE, 0x09CD, + 0x09EC, 0x0A0C, 0x0A2C, 0x0A4C, + 0x0A6C, 0x0A8D, 0x0AAD, 0x0ACF, + 0x0AF0, 0x0B11, 0x0B33, 0x0B55, + 0x0B78, 0x0B9A, 0x0BBD, 0x0BE0, + 0x0C03, 0x0C27, 0x0C4B, 0x0C6F, + 0x0C93, 0x0CB8, 0x0CDD, 0x0D02, + 0x0D27, 0x0D4D, 0x0D73, 0x0D99, + 0x0DBF, 0x0DE6, 0x0E0C, 0x0E33, + 0x0E5B, 0x0E82, 0x0EAA, 0x0ED2, + 0x0EFB, 0x0F23, 0x0F4C, 0x0F75, + 0x0F9F, 0x0FC8, 0x0FF2, 0x101C, + 0x1047, 0x1071, 0x109C, 0x10C7, + 0x10F3, 0x111E, 0x114A, 0x1176, + 0x11A3, 0x11D0, 0x11FC, 0x122A, + 0x1257, 0x1285, 0x12B3, 0x12E1, + 0x130F, 0x133E, 0x136D, 0x139C, + 0x13CB, 0x13FB, 0x142B, 0x145B, + 0x148B, 0x14BC, 0x14ED, 0x151E, + 0x1550, 0x1581, 0x15B3, 0x15E5, + 0x1618, 0x164A, 0x167D, 0x16B0, + 0x16E3, 0x1717, 0x174B, 0x177F, + 0x17B3, 0x17E8, 0x181D, 0x1852, + 0x1887, 0x18BC, 0x18F2, 0x1928, + 0x195E, 0x1995, 0x19CB, 0x1A02, + 0x1A39, 0x1A71, 0x1AA8, 0x1AE0, + 0x1B18, 0x1B50, 0x1B89, 0x1BC1, + 0x1BFA, 0x1C34, 0x1C6D, 0x1CA7, + 0x1CE0, 0x1D1A, 0x1D55, 0x1D8F, + 0x1DCA, 0x1E05, 0x1E40, 0x1E7B, + 0x1EB7, 0x1EF2, 0x1F2E, 0x1F6B, + 0x1FA7, 0x1FE4, 0x2020, 0x205D, + 0x209B, 0x20D8, 0x2116, 0x2153, + 0x2191, 0x21D0, 0x220E, 0x224D, + 0x228B, 0x22CA, 0x2309, 0x2349, + 0x2388, 0x23C8, 0x2408, 0x2448, + 0x2488, 0x24C9, 0x2509, 0x254A, + 0x258B, 0x25CC, 0x260E, 0x264F, + 0x2691, 0x26D3, 0x2715, 0x2757, + 0x2799, 0x27DC, 0x281F, 0x2861, + 0x28A4, 0x28E8, 0x292B, 0x296E, + 0x29B2, 0x29F6, 0x2A3A, 0x2A7E, + 0x2AC2, 0x2B06, 0x2B4B, 0x2B8F, + 0x2BD4, 0x2C19, 0x2C5E, 0x2CA3, + 0x2CE9, 0x2D2E, 0x2D74, 0x2DB9, + 0x2DFF, 0x2E45, 0x2E8B, 0x2ED1, + 0x2F18, 0x2F5E, 0x2FA5, 0x2FEB, + 0x3032, 0x3079, 0x30C0, 0x3107, + 0x314E, 0x3195, 0x31DD, 0x3224, + 0x326C, 0x32B4, 0x32FB, 0x3343, + 0x338B, 0x33D3, 0x341B, 0x3463, + 0x34AC, 0x34F4, 0x353D, 0x3585, + 0x35CE, 0x3616, 0x365F, 0x36A8, + 0x36F1, 0x373A, 0x3783, 0x37CC, + 0x3815, 0x385E, 0x38A7, 0x38F0, + 0x393A, 0x3983, 0x39CC, 0x3A16, + 0x3A5F, 0x3AA9, 0x3AF2, 0x3B3C, + 0x3B86, 0x3BCF, 0x3C19, 0x3C63, + 0x3CAC, 0x3CF6, 0x3D40, 0x3D8A, + 0x3DD3, 0x3E1D, 0x3E67, 0x3EB1, + 0x3EFB, 0x3F45, 0x3F8E, 0x3FD8, + 0x4022, 0x406C, 0x40B6, 0x4100, + 0x414A, 0x4193, 0x41DD, 0x4227, + 0x4271, 0x42BB, 0x4304, 0x434E, + 0x4398, 0x43E1, 0x442B, 0x4475, + 0x44BE, 0x4508, 0x4551, 0x459B, + 0x45E4, 0x462E, 0x4677, 0x46C0, + 0x4709, 0x4753, 0x479C, 0x47E5, + 0x482E, 0x4877, 0x48C0, 0x4909, + 0x4951, 0x499A, 0x49E3, 0x4A2B, + 0x4A74, 0x4ABC, 0x4B04, 0x4B4D, + 0x4B95, 0x4BDD, 0x4C25, 0x4C6D, + 0x4CB5, 0x4CFC, 0x4D44, 0x4D8C, + 0x4DD3, 0x4E1A, 0x4E62, 0x4EA9, + 0x4EF0, 0x4F37, 0x4F7E, 0x4FC4, + 0x500B, 0x5051, 0x5098, 0x50DE, + 0x5124, 0x516A, 0x51B0, 0x51F6, + 0x523B, 0x5281, 0x52C6, 0x530B, + 0x5351, 0x5396, 0x53DA, 0x541F, + 0x5464, 0x54A8, 0x54EC, 0x5530, + 0x5574, 0x55B8, 0x55FC, 0x563F, + 0x5683, 0x56C6, 0x5709, 0x574C, + 0x578F, 0x57D1, 0x5814, 0x5856, + 0x5898, 0x58DA, 0x591B, 0x595D, + 0x599E, 0x59E0, 0x5A21, 0x5A61, + 0x5AA2, 0x5AE3, 0x5B23, 0x5B63, + 0x5BA3, 0x5BE3, 0x5C22, 0x5C62, + 0x5CA1, 0x5CE0, 0x5D1F, 0x5D5D, + 0x5D9C, 0x5DDA, 0x5E18, 0x5E56, + 0x5E93, 0x5ED1, 0x5F0E, 0x5F4B, + 0x5F87, 0x5FC4, 0x6000, 0x603D, + 0x6079, 0x60B4, 0x60F0, 0x612B, + 0x6166, 0x61A1, 0x61DC, 0x6216, + 0x6250, 0x628A, 0x62C4, 0x62FE, + 0x6337, 0x6370, 0x63A9, 0x63E2, + 0x641A, 0x6452, 0x648A, 0x64C2, + 0x64F9, 0x6531, 0x6568, 0x659E, + 0x65D5, 0x660B, 0x6641, 0x6677, + 0x66AD, 0x66E2, 0x6717, 0x674C, + 0x6781, 0x67B5, 0x67E9, 0x681D, + 0x6851, 0x6885, 0x68B8, 0x68EB, + 0x691D, 0x6950, 0x6982, 0x69B4, + 0x69E6, 0x6A17, 0x6A48, 0x6A79, + 0x6AAA, 0x6ADB, 0x6B0B, 0x6B3B, + 0x6B6A, 0x6B9A, 0x6BC9, 0x6BF8, + 0x6C27, 0x6C55, 0x6C83, 0x6CB1, + 0x6CDF, 0x6D0D, 0x6D3A, 0x6D67, + 0x6D93, 0x6DC0, 0x6DEC, 0x6E18, + 0x6E44, 0x6E6F, 0x6E9A, 0x6EC5, + 0x6EF0, 0x6F1A, 0x6F44, 0x6F6E, + 0x6F98, 0x6FC1, 0x6FEA, 0x7013, + 0x703C, 0x7064, 0x708C, 0x70B4, + 0x70DB, 0x7103, 0x712A, 0x7151, + 0x7177, 0x719D, 0x71C3, 0x71E9, + 0x720F, 0x7234, 0x7259, 0x727E, + 0x72A2, 0x72C7, 0x72EB, 0x730E, + 0x7332, 0x7355, 0x7378, 0x739B, + 0x73BD, 0x73E0, 0x7402, 0x7424, + 0x7445, 0x7466, 0x7487, 0x74A8, + 0x74C9, 0x74E9, 0x7509, 0x7529, + 0x7548, 0x7568, 0x7587, 0x75A5, + 0x75C4, 0x75E2, 0x7601, 0x761E, + 0x763C, 0x7659, 0x7676, 0x7693, + 0x76B0, 0x76CC, 0x76E9, 0x7705, + 0x7720, 0x773C, 0x7757, 0x7772, + 0x778D, 0x77A8, 0x77C2, 0x77DC, + 0x77F6, 0x780F, 0x7829, 0x7842, + 0x785B, 0x7874, 0x788C, 0x78A5, + 0x78BD, 0x78D5, 0x78EC, 0x7904, + 0x791B, 0x7932, 0x7949, 0x795F, + 0x7976, 0x798C, 0x79A2, 0x79B7, + 0x79CD, 0x79E2, 0x79F7, 0x7A0C, + 0x7A21, 0x7A35, 0x7A4A, 0x7A5E, + 0x7A72, 0x7A85, 0x7A99, 0x7AAC, + 0x7ABF, 0x7AD2, 0x7AE5, 0x7AF7, + 0x7B09, 0x7B1B, 0x7B2D, 0x7B3F, + 0x7B51, 0x7B62, 0x7B73, 0x7B84, + 0x7B95, 0x7BA5, 0x7BB6, 0x7BC6, + 0x7BD6, 0x7BE6, 0x7BF6, 0x7C05, + 0x7C15, 0x7C24, 0x7C33, 0x7C42, + 0x7C50, 0x7C5F, 0x7C6D, 0x7C7B, + 0x7C89, 0x7C97, 0x7CA5, 0x7CB2, + 0x7CC0, 0x7CCD, 0x7CDA, 0x7CE7, + 0x7CF3, 0x7D00, 0x7D0C, 0x7D18, + 0x7D25, 0x7D31, 0x7D3C, 0x7D48, + 0x7D53, 0x7D5F, 0x7D6A, 0x7D75, + 0x7D80, 0x7D8B, 0x7D95, 0x7DA0, + 0x7DAA, 0x7DB4, 0x7DBE, 0x7DC8, + 0x7DD2, 0x7DDC, 0x7DE5, 0x7DEF, + 0x7DF8, 0x7E01, 0x7E0A, 0x7E13, + 0x7E1C, 0x7E25, 0x7E2D, 0x7E36, + 0x7E3E, 0x7E46, 0x7E4E, 0x7E56, + 0x7E5E, 0x7E66, 0x7E6D, 0x7E75, + 0x7E7C, 0x7E83, 0x7E8B, 0x7E92, + 0x7E99, 0x7EA0, 0x7EA6, 0x7EAD, + 0x7EB3, 0x7EBA, 0x7EC0, 0x7EC6, + 0x7ECD, 0x7ED3, 0x7ED9, 0x7EDE, + 0x7EE4, 0x7EEA, 0x7EF0, 0x7EF5, + 0x7EFA, 0x7F00, 0x7F05, 0x7F0A, + 0x7F0F, 0x7F14, 0x7F19, 0x7F1E, + 0x7F23, 0x7F27, 0x7F2C, 0x7F30, + 0x7F35, 0x7F39, 0x7F3D, 0x7F41, + 0x7F46, 0x7F4A, 0x7F4E, 0x7F52, + 0x7F55, 0x7F59, 0x7F5D, 0x7F60, + 0x7F64, 0x7F68, 0x7F6B, 0x7F6E, + 0x7F72, 0x7F75, 0x7F78, 0x7F7B, + 0x7F7E, 0x7F81, 0x7F84, 0x7F87, + 0x7F8A, 0x7F8D, 0x7F90, 0x7F92, + 0x7F95, 0x7F97, 0x7F9A, 0x7F9C, + 0x7F9F, 0x7FA1, 0x7FA4, 0x7FA6, + 0x7FA8, 0x7FAA, 0x7FAC, 0x7FAE, + 0x7FB1, 0x7FB3, 0x7FB5, 0x7FB6, + 0x7FB8, 0x7FBA, 0x7FBC, 0x7FBE, + 0x7FBF, 0x7FC1, 0x7FC3, 0x7FC4, + 0x7FC6, 0x7FC8, 0x7FC9, 0x7FCB, + 0x7FCC, 0x7FCD, 0x7FCF, 0x7FD0, + 0x7FD1, 0x7FD3, 0x7FD4, 0x7FD5, + 0x7FD6, 0x7FD8, 0x7FD9, 0x7FDA, + 0x7FDB, 0x7FDC, 0x7FDD, 0x7FDE, + 0x7FDF, 0x7FE0, 0x7FE1, 0x7FE2, + 0x7FE3, 0x7FE4, 0x7FE4, 0x7FE5, + 0x7FE6, 0x7FE7, 0x7FE8, 0x7FE8, + 0x7FE9, 0x7FEA, 0x7FEA, 0x7FEB, + 0x7FEC, 0x7FEC, 0x7FED, 0x7FEE, + 0x7FEE, 0x7FEF, 0x7FEF, 0x7FF0, + 0x7FF0, 0x7FF1, 0x7FF1, 0x7FF2, + 0x7FF2, 0x7FF3, 0x7FF3, 0x7FF4, + 0x7FF4, 0x7FF4, 0x7FF5, 0x7FF5, + 0x7FF6, 0x7FF6, 0x7FF6, 0x7FF7, + 0x7FF7, 0x7FF7, 0x7FF8, 0x7FF8, + 0x7FF8, 0x7FF8, 0x7FF9, 0x7FF9, + 0x7FF9, 0x7FF9, 0x7FFA, 0x7FFA, + 0x7FFA, 0x7FFA, 0x7FFA, 0x7FFB, + 0x7FFB, 0x7FFB, 0x7FFB, 0x7FFB, + 0x7FFC, 0x7FFC, 0x7FFC, 0x7FFC, + 0x7FFC, 0x7FFC, 0x7FFC, 0x7FFC, + 0x7FFD, 0x7FFD, 0x7FFD, 0x7FFD, + 0x7FFD, 0x7FFD, 0x7FFD, 0x7FFD, + 0x7FFD, 0x7FFD, 0x7FFE, 0x7FFE, + 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE, + 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE, + 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE, + 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF + +}; + + + + +const Int16 Short_Window_KBD_fxp[SHORT_WINDOW] = +{ + + 0x0001, 0x0004, 0x0008, 0x000D, + 0x0014, 0x001D, 0x0029, 0x0039, + 0x004C, 0x0063, 0x0080, 0x00A2, + 0x00CB, 0x00FB, 0x0133, 0x0174, + 0x01BE, 0x0214, 0x0275, 0x02E3, + 0x035E, 0x03E8, 0x0481, 0x052B, + 0x05E7, 0x06B4, 0x0795, 0x088A, + 0x0993, 0x0AB2, 0x0BE7, 0x0D32, + 0x0E94, 0x100E, 0x119F, 0x1347, + 0x1507, 0x16DE, 0x18CC, 0x1AD0, + 0x1CEB, 0x1F1A, 0x215F, 0x23B6, + 0x2620, 0x289C, 0x2B27, 0x2DC0, + 0x3066, 0x3317, 0x35D2, 0x3894, + 0x3B5C, 0x3E28, 0x40F6, 0x43C4, + 0x468F, 0x4956, 0x4C18, 0x4ED1, + 0x5181, 0x5425, 0x56BC, 0x5944, + 0x5BBB, 0x5E21, 0x6073, 0x62B1, + 0x64DA, 0x66EC, 0x68E7, 0x6ACB, + 0x6C96, 0x6E49, 0x6FE4, 0x7166, + 0x72D0, 0x7421, 0x755B, 0x767E, + 0x778A, 0x7881, 0x7962, 0x7A30, + 0x7AEA, 0x7B92, 0x7C29, 0x7CB0, + 0x7D28, 0x7D92, 0x7DF0, 0x7E42, + 0x7E89, 0x7EC7, 0x7EFC, 0x7F2A, + 0x7F50, 0x7F71, 0x7F8C, 0x7FA3, + 0x7FB6, 0x7FC5, 0x7FD2, 0x7FDC, + 0x7FE4, 0x7FEB, 0x7FF0, 0x7FF4, + 0x7FF7, 0x7FF9, 0x7FFB, 0x7FFC, + 0x7FFD, 0x7FFE, 0x7FFE, 0x7FFE, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF +}; + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk new file mode 100644 index 0000000..67b39b8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk @@ -0,0 +1,42 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/getactualaacconfig.cpp \ + src/byte_align.cpp \ + src/get_audio_specific_config.cpp \ + src/get_ele_list.cpp \ + src/get_ga_specific_config.cpp \ + src/get_ics_info.cpp \ + src/get_prog_config.cpp \ + src/getgroup.cpp \ + src/lt_decode.cpp \ + src/infoinit.cpp \ + src/pvmp4audiodecodergetmemrequirements.cpp \ + src/pvmp4audiodecoderinitlibrary.cpp \ + src/set_mc_info.cpp \ + src/sfb.cpp + + +LOCAL_MODULE := libgetactualaacconfig + +LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO $(PV_CFLAGS) +LOCAL_ARM_MODE := arm + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/codecs_v2/audio/aac/dec/util/getactualaacconfig/src \ + $(PV_TOP)/codecs_v2/audio/aac/dec/util/getactualaacconfig/include \ + $(PV_TOP)/codecs_v2/audio/aac/dec/include \ + $(PV_TOP)/codecs_v2/audio/aac/dec/src \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + include/getactualaacconfig.h + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make/local.mk new file mode 100644 index 0000000..5be5f12 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make/local.mk @@ -0,0 +1,38 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + +TARGET := getactualaacconfig + + +OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true + +XCPPFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO + +XINCDIRS := ../../../../include ../../../../src + + +SRCDIR := ../../src +INCSRCDIR := ../../include +SRCS := getactualaacconfig.cpp\ + byte_align.cpp\ + get_audio_specific_config.cpp\ + get_ele_list.cpp\ + get_ga_specific_config.cpp\ + get_ics_info.cpp\ + get_prog_config.cpp\ + getgroup.cpp\ + lt_decode.cpp\ + infoinit.cpp\ + pvmp4audiodecodergetmemrequirements.cpp\ + pvmp4audiodecoderinitlibrary.cpp\ + set_mc_info.cpp\ + sfb.cpp + + +HDRS := getactualaacconfig.h + +include $(MK)/library.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/include/getactualaacconfig.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/include/getactualaacconfig.h new file mode 100644 index 0000000..21159ff --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/include/getactualaacconfig.h @@ -0,0 +1,47 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getactualaacconfig.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + getaacaudioinfo definition function + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ + +#ifndef GETACTUALAACCONFIG_H +#define GETACTUALAACCONFIG_H + +#include "oscl_base.h" + +OSCL_IMPORT_REF int32 GetActualAacConfig(uint8* aConfigHeader, + uint8* aAudioObjectType, + int32* aConfigHeaderSize, + uint8* SamplingRateIndex, + uint32* NumChannels, + uint32* aSamplesPerFrame); + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/byte_align.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/byte_align.cpp new file mode 100644 index 0000000..76db1bc --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/byte_align.cpp @@ -0,0 +1,166 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to a BITS structure that holds information + regarding the input stream. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pInputStream->usedBits is rounded up to a number that represents the next + byte boundary. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Makes the input stream structure pointed to align to the next byte boundary. + If it is already at a byte boundary it is left alone. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global or static variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +void byte_align( + BITS *pInputStream) + + MODIFYING(pInputStream->usedBits = pInputStream->usedBits + + (pInputStream->usedBits + 7) % 8) + + RETURN(nothing) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + + + +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/* + * A negative number was used for this mask so that it works on both + * 16-bit or 32-bit machines. The mask must be cast to unsigned int to + * work with TI compiler, ver 1.80. + */ +#define BYTE_ALIGN_MASK ((UInt)(-8)) + +#define BYTE_ALIGN_ROUNDUP 7 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void byte_align( + BITS *pInputStream) +{ + /* + * Round up to the next byte by adding 7 and masking off with + * FFF8 or FFFFFFF8. The masking operation is a faster way to + * perform modulo arithmetic if the number is a power of 2. + * + * This code is the same as + * pInputStream->usedBits += (pInputStream->usedBits + 7) % 8 + */ + pInputStream->usedBits += BYTE_ALIGN_ROUNDUP; + pInputStream->usedBits &= BYTE_ALIGN_MASK; + + return; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_audio_specific_config.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_audio_specific_config.cpp new file mode 100644 index 0000000..3ccd493 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_audio_specific_config.cpp @@ -0,0 +1,669 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_audio_specific_config.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that holds all information for + this instance of the library. pVars->prog_config is directly + used, and pVars->mc_info, pVars->prog_config, + pVars->pWinSeqInfo, pVars->SFBWidth128 are needed indirectly + for calling set_mc_info. Data type pointer to tDec_Int_File + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + status = 0 if successfully decoded AudioSpecificConfig + 1 if un-supported config is used for this release + + Pointers and Buffers Modified: + pVars->prog_config contents are updated with the information read in. + pVars->mc_info contents are updated with channel information. + pVars->pWinSeqInfo contents are updated with window information. + pVars->SFBWidth128 contents are updated with scale factor band width data. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads the bitstream for the structure "AudioSpecificConfig", + and sets the decoder configuration that is needed by the decoder to be able + to decode the media properly. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global variables + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + Part 3 + Subpart 1 p18 1.6 Interface to MPEG-4 Systems + Subpart 4 p13 4.4.1 GA Specific Configuration + Amendment p10 6.2.1 AudioSpecificInfo + Amendment p78 8.2 Decoder configuration (GASpecificConfig) + + (2) AAC DecoderSpecificInfo Information + PacketVideo descriptions - San Diego + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = SUCCESS; + + pInputStream = &(pVars->inputStream); + + temp = CALL getbits( + neededBits = LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX, + pInputStream = pInputStream) + MODIFYING (pInputStream) + RETURNING (temp) + + audioObjectType = (temp & 0x1f0) >> 4; + + pVars->prog_config.profile = audioObjectType; + + pVars->prog_config.sampling_rate_idx = temp & 0xf; + + IF (pVars->prog_config.sampling_rate_idx == 0xf) + THEN + sampling_rate = CALL getbits( + neededBits = LEN_SAMP_RATE, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (sampling_rate) + ENDIF + + channel_config = CALL getbits( + neededBits = LEN_CHAN_CONFIG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (channel_config) + + IF (channel_config > 2) + THEN + status = 1; + ENDIF + + IF (((audioObjectType == MP4AUDIO_AAC_MAIN) OR + (audioObjectType == MP4AUDIO_AAC_LC) OR + (audioObjectType == MP4AUDIO_AAC_SSR) OR + (audioObjectType == MP4AUDIO_LTP) OR + (audioObjectType == MP4AUDIO_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_TWINVQ)) AND (status == -1)) + THEN + status = CALL get_GA_specific_config( + pVars = pVars, + channel_config = channel_config, + audioObjectType = audioObjectType, + pInputStream = pInputStream); + MODIFYING (pVars->mc_info,channel_config,pInputStream) + RETURNING (status) + + ENDIF + + IF (audioObjectType == MP4AUDIO_CELP) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_HVXC) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_TTSI) + THEN + status = 1; + ENDIF + + IF ((audioObjectType == 13) OR (audioObjectType == 14) OR + (audioObjectType == 15) OR (audioObjectType == 16)) + THEN + status = 1; + ENDIF + + IF (((audioObjectType == MP4AUDIO_ER_AAC_LC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LTP) OR + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_ER_TWINVQ) OR + (audioObjectType == MP4AUDIO_ER_BSAC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LD)) AND (status == -1)) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_ER_CELP) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_ER_HVXC) + THEN + status = 1; + ENDIF + + IF ((audioObjectType == MP4AUDIO_ER_HILN) OR + (audioObjectType == MP4AUDIO_PARAMETRIC)) + THEN + status = 1; + ENDIF + + IF ((audioObjectType == MP4AUDIO_ER_AAC_LC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LTP) OR + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_ER_TWINVQ) OR + (audioObjectType == MP4AUDIO_ER_BSAC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LD) OR + (audioObjectType == MP4AUDIO_ER_CELP) OR + (audioObjectType == MP4AUDIO_ER_HVXC) OR + (audioObjectType == MP4AUDIO_ER_HILN) OR + (audioObjectType == MP4AUDIO_PARAMETRIC)) + THEN + epConfig = CALL getbits( + neededBits = LEN_EP_CONFIG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (epConfig) + + IF (epConfig == 2) + THEN + status = 1; + ENDIF + + ENDIF + + RETURN status; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_mp4ff_const.h" +#include "e_tmp4audioobjecttype.h" +#include "get_audio_specific_config.h" +#include "get_ga_specific_config.h" +#include "ibstream.h" +#include "sfb.h" /* Where samp_rate_info[] is declared */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int get_audio_specific_config(tDec_Int_File * const pVars) +{ + + UInt temp; + tMP4AudioObjectType audioObjectType; + //UInt32 sampling_rate; + UInt channel_config; + UInt syncExtensionType; + UInt extensionAudioObjectType = 0; + UInt extensionSamplingFrequencyIndex = 0; + BITS *pInputStream; + Int status; + + status = SUCCESS; + + pInputStream = &(pVars->inputStream); + + pVars->mc_info.upsamplingFactor = 1; /* default to regular AAC */ + + temp = get9_n_lessbits(LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX, + pInputStream); + + /* + * The following code can directly set the values of elements in + * MC_Info, rather than first setting the values in pVars->prog_config + * and then copy these values to MC_Info by calling set_mc_info. + * In order to keep consistent with get_prog_config (ADIF) and + * get_adts_header (ADTS), the code here is still copying + * the info, and set the pVars->current_program = 0 + */ + + /* AudioObjectType */ + audioObjectType = (tMP4AudioObjectType)((temp & 0x1f0) >> 4); + + pVars->mc_info.ExtendedAudioObjectType = audioObjectType; /* default */ + /* saving an audioObjectType into a profile field */ + /* pVars->prog_config.profile = audioObjectType; */ + + /* sampling rate index */ + pVars->prog_config.sampling_rate_idx = temp & 0xf; + + if (pVars->prog_config.sampling_rate_idx > 0xb) + { + /* + * Only support 12 sampling frequencies from array samp_rate_info ( see sfb.cpp) + * 7350 Hz (index 0xc) is not supported, the other indexes are reserved or escape + */ + if (pVars->prog_config.sampling_rate_idx == 0xf) /* escape sequence */ + { + /* + * sampling rate not listed in Table 1.6.2, + * this release does not support this + */ + /*sampling_rate = getbits( LEN_SAMP_RATE, + pInputStream);*/ + getbits(LEN_SAMP_RATE, pInputStream); /* future use */ + } + + status = 1; + } + + channel_config = get9_n_lessbits(LEN_CHAN_CONFIG, + pInputStream); + + if ((channel_config > 2) && (!pVars->aacConfigUtilityEnabled)) + { + /* + * AAC lib does not support more than two channels + * signal error when in decoder mode + * do not test when in utility mode + */ + status = 1; + + } + + if (audioObjectType == MP4AUDIO_SBR || audioObjectType == MP4AUDIO_PS) + { + /* to disable explicit backward compatiblity check */ + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + pVars->mc_info.sbrPresentFlag = 1; + + if (audioObjectType == MP4AUDIO_PS) + { + pVars->mc_info.psPresentFlag = 1; + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS; + } + + extensionSamplingFrequencyIndex = /* extensionSamplingFrequencyIndex */ + get9_n_lessbits(LEN_SAMP_RATE_IDX, + pInputStream); + if (extensionSamplingFrequencyIndex == 0x0f) + { + /* + * sampling rate not listed in Table 1.6.2, + * this release does not support this + */ + /*sampling_rate = getbits( LEN_SAMP_RATE, + pInputStream);*/ + getbits(LEN_SAMP_RATE, pInputStream); + } + + audioObjectType = (tMP4AudioObjectType) get9_n_lessbits(LEN_OBJ_TYPE , + pInputStream); + } + + + if ((/*(audioObjectType == MP4AUDIO_AAC_MAIN) ||*/ + (audioObjectType == MP4AUDIO_AAC_LC) || + /*(audioObjectType == MP4AUDIO_AAC_SSR) ||*/ + (audioObjectType == MP4AUDIO_LTP) /*||*/ + /*(audioObjectType == MP4AUDIO_AAC_SCALABLE) ||*/ + /*(audioObjectType == MP4AUDIO_TWINVQ)*/) && (status == SUCCESS)) + { + status = get_GA_specific_config(pVars, + pInputStream, + channel_config, + audioObjectType); + + /* + * verify that Program config returned a supported audio object type + */ + + if ((pVars->mc_info.audioObjectType != MP4AUDIO_AAC_LC) && + (pVars->mc_info.audioObjectType != MP4AUDIO_LTP)) + { + return 1; /* status != SUCCESS invalid aot */ + } + } + else + { + return 1; /* status != SUCCESS invalid aot or invalid parameter */ + } + + /* + * SBR tool explicit signaling ( backward compatible ) + */ + if (extensionAudioObjectType != MP4AUDIO_SBR) + { + syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE, + pInputStream); + + if (syncExtensionType == 0x2b7) + { + extensionAudioObjectType = get9_n_lessbits( /* extensionAudioObjectType */ + LEN_OBJ_TYPE, + pInputStream); + + if (extensionAudioObjectType == MP4AUDIO_SBR) + { + pVars->mc_info.sbrPresentFlag = get1bits(pInputStream); /* sbrPresentFlag */ + if (pVars->mc_info.sbrPresentFlag == 1) + { + extensionSamplingFrequencyIndex = + get9_n_lessbits( /* extensionSamplingFrequencyIndex */ + LEN_SAMP_RATE_IDX, + pInputStream); + if (pVars->aacPlusEnabled == true) + { +#ifdef AAC_PLUS + if (extensionSamplingFrequencyIndex < 3) + { + /* + * Disable SBR/PS for any sampling freq. > 48 KHz + * 3GPP request support up to Level 2, == max AAC/SBR present + * 24/48 KHz + */ + pVars->aacPlusEnabled = false; + } + else + { + pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) == + samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1; + + if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx) + { + /* + * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz + */ + if (pVars->prog_config.sampling_rate_idx < 6) + { + pVars->aacPlusEnabled = false; + } + + pVars->mc_info.bDownSampledSbr = true; + } + + pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex; + } + +#endif + } + + if (extensionSamplingFrequencyIndex == 0x0f) + { + /* + * sampling rate not listed in Table 1.6.2, + * this release does not support this + */ + /*sampling_rate = getbits( LEN_SAMP_RATE, + pInputStream);*/ + getbits(LEN_SAMP_RATE, pInputStream); + } + /* syncExtensionType */ + syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE, + pInputStream); + if (syncExtensionType == 0x548) + { + pVars->mc_info.psPresentFlag = get1bits(pInputStream); /* psPresentFlag */ + if (pVars->mc_info.psPresentFlag) + { + extensionAudioObjectType = MP4AUDIO_PS; + } + } + else + { + /* + * Rewind bitstream pointer so that the syncExtensionType reading has no + * effect when decoding raw bitstream + */ + pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE; + } + + pVars->mc_info.ExtendedAudioObjectType = (eMP4AudioObjectType)extensionAudioObjectType; + } + } + } + else if (!status) + { + /* + * Rewind bitstream pointer so that the syncExtensionType reading has no + * effect when decoding raw bitstream + */ + pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE; + +#ifdef AAC_PLUS + + /* + * For implicit signalling, no hint that sbr or ps is used, so we need to + * check the sampling frequency of the aac content, if lesser or equal to + * 24 KHz, by defualt upsample, otherwise, do nothing + */ + if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == true) && + audioObjectType == MP4AUDIO_AAC_LC) + { + pVars->mc_info.upsamplingFactor = 2; + pVars->prog_config.sampling_rate_idx -= 3; + pVars->mc_info.sbrPresentFlag = 1; + pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED; + pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED; + + } + else + { + /* + * Disable SBR decoding for any implicit-signalig clip whose SF is > 24 KHz + * sbr-downsampling has to be implicit + */ + pVars->aacPlusEnabled = false; + } +#endif + + } + } + else /* MP4AUDIO_SBR was detected */ + { + /* + * Set the real output frequency use by the SBR tool, define tentative upsample ratio + */ + if (pVars->aacPlusEnabled == true) + { +#ifdef AAC_PLUS + pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) == + samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1; + + if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx) + { + /* + * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz + */ + if (pVars->prog_config.sampling_rate_idx < 6) + { + pVars->aacPlusEnabled = false; + } + pVars->mc_info.bDownSampledSbr = true; + } + pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex; + + + +#endif + + } + + } /* if ( extensionAudioObjectType != MP4AUDIO_SBR ) */ + + + + if (channel_config > 2) + { + pVars->multichannel_numChannels = channel_config << 1; /* to go along with own multichannel format */ + pVars->multichannel_detected = true; + } + + /* + * The following object types are not supported in this release, + * however, keep these interfaces for future implementation + */ + + /* + *if (audioObjectType == MP4AUDIO_CELP) + *{ + * status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_HVXC) + *{ + * status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_TTSI) + *{ + * status = 1; + *} + */ + + /* + *if ((audioObjectType == 13) || (audioObjectType == 14) || + * (audioObjectType == 15) || (audioObjectType == 16)) + *{ + * status = 1; + *} + */ + + /* The following objects are Amendment 1 objects */ + /* + *if (((audioObjectType == MP4AUDIO_ER_AAC_LC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LTP) || + * (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) || + * (audioObjectType == MP4AUDIO_ER_TWINVQ) || + * (audioObjectType == MP4AUDIO_ER_BSAC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LD)) && (status == -1)) + *{ + */ + /* + * should call get_GA_specific_config + * for this release, do not support Error Resilience + * temporary solution is set status flag and exit decoding + */ + /* status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_ER_CELP) + * { + * status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_ER_HVXC) + *{ + * status = 1; + *} + */ + + /* + *if ((audioObjectType == MP4AUDIO_ER_HILN) || + * (audioObjectType == MP4AUDIO_PARAMETRIC)) + *{ + * status = 1; + *} + */ + + /* + *if ((audioObjectType == MP4AUDIO_ER_AAC_LC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LTP) || + * (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) || + * (audioObjectType == MP4AUDIO_ER_TWINVQ) || + * (audioObjectType == MP4AUDIO_ER_BSAC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LD) || + * (audioObjectType == MP4AUDIO_ER_CELP) || + * (audioObjectType == MP4AUDIO_ER_HVXC) || + * (audioObjectType == MP4AUDIO_ER_HILN) || + * (audioObjectType == MP4AUDIO_PARAMETRIC)) + *{ + */ + /* error protection config */ + /* + * epConfig = + * getbits( + * LEN_EP_CONFIG, + * pInputStream); + * + * if (epConfig == 2) + * { + */ + /* should call ErrorProtectionSpecificConfig() */ + /* + * status = 1; + * } + * + *} + */ + + return status; + +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ele_list.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ele_list.cpp new file mode 100644 index 0000000..20778bf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ele_list.cpp @@ -0,0 +1,194 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ele_list.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pElementList = pointer to an EleList structure - only the field num_ele + needs to be set. Data type pointer to EleList. + + pInputStream = pointer to a BITS structure, used by the function getbits + to provide data. Data type pointer to BITS + + enableCPE = boolean value indicating the area to be read contains + a channel pair element field. Data type Bool + + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: None + + Pointers and Buffers Modified: + pElementList contents are updated with information pertaining to channel + configuration. + + pInputBuffer contents are updated to the next location to be read from + the input stream. + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function is called several times by get_prog_config() to read in part of + the program configuration data related to channel setup. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not have static or global variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(), + page 16, and section 8.5 "Program Config Element (PCE)", page 30. + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + +------------------------------------------------------------------------------ + PSEUDO-CODE + + elementCount = pElementList->num_ele; + + FOR (index = 0; index < elementCount; index++) + IF (enableCPE != FALSE) THEN + pElementList->ele_is_cpe[index] = + getbits(LEN_ELE_IS_CPE, pInputStream); + ELSE + pElementList->ele_is_cpe[index] = 0; + END IF + + pElementList->ele_tag[index] = getbits(LEN_TAG, pInputStream); + + END FOR + + RETURNS nothing + +------------------------------------------------------------------------------ +*/ + + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_elelist.h" +#include "s_bits.h" +#include "e_progconfigconst.h" +#include "ibstream.h" +#include "get_ele_list.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void get_ele_list( + EleList *pElementList, + BITS *pInputStream, + const Bool enableCPE) +{ + Int index; + Int *pEleIsCPE; + Int *pEleTag; + + pEleIsCPE = &pElementList->ele_is_cpe[0]; + pEleTag = &pElementList->ele_tag[0]; + + for (index = pElementList->num_ele; index > 0; index--) + { + if (enableCPE != FALSE) + { + *pEleIsCPE++ = get1bits(/*LEN_ELE_IS_CPE, */pInputStream); + } + else + { + *pEleIsCPE++ = FALSE; + } + + *pEleTag++ = get9_n_lessbits(LEN_TAG, pInputStream); + + } /* end for (index) */ + + return; + +} /* end get_ele_list */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ga_specific_config.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ga_specific_config.cpp new file mode 100644 index 0000000..f408c78 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ga_specific_config.cpp @@ -0,0 +1,441 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ga_specific_config.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that holds all information for + this instance of the library. pVars->prog_config + pVars->mc_info, pVars->pWinSeqInfo, pVars->SFBWidth128 + are needed for calling set_mc_info. + Data type pointer to tDec_Int_File + + channel_config = variable that indicates the channel configuration + information, in this decoder library, only values + 0, 1, and 2 are allowed. + Data type UInt + + audioObjectType = variable that indicates the Audio Object Type. + Data type UInt. + + pInputStream = pointer to a BITS structure that holds information + regarding the input stream. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + status = 0 if success + 1 otherwise + + Pointers and Buffers Modified: + pVars->mc_info contents are updated with channel information. + if infoinit is called within set_mc_info, then + pVars->pWinSeqInfo contents are updated with window information. + pVars->SFBWidth128 contents are updated with scale factor band width data. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function takes the sampling_rate_idx, channel_config, and + audioObjectType from AudioSpecificConfig() and set the decoder configuration + necessary for the decoder to decode properly. + It also reads the bitstream for frame length, scalable bitstream information + and extension information to General Audio defined in MPEG-4 phase 1 + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global variables + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + Part 3 + Subpart 1 p18 1.6 Interface to MPEG-4 Systems + Subpart 4 p13 4.4.1 GA Specific Configuration + Amendment p10 6.2.1 AudioSpecificInfo + Amendment p78 8.2 Decoder configuration (GASpecificConfig) + + (2) AAC DecoderSpecificInfo Information + PacketVideo descriptions - San Diego + +------------------------------------------------------------------------------ + PSEUDO-CODE + + frameLenFlag = CALL getbits( + neededBits = LEN_FRAME_LEN_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (frameLenFlag) + + dependsOnCoreCoder = CALL getbits( + neededBits = LEN_DEPEND_ON_CORE, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (dependsOnCoreCoder) + + IF (dependsOnCoreCoder != FALSE) + THEN + coreCoderDelay = CALL getbits( + neededBits = LEN_CORE_DELAY, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (coreCoderDelay) + ENDIF + + extFlag = CALL getbits( + neededBits = LEN_EXT_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (extFlag) + + IF (channel_config == 0) + THEN + status = CALL get_prog_config( + pVars = pVars, + pScratchPCE = &pVars->scratch_prog_config); + MODIFYING (pVars, pScratchPCE) + RETURNING (status) + + ELSE + channel_config--; + pVars->prog_config.front.ele_is_cpe[0] = channel_config; + pVars->prog_config.front.ele_tag[0] = 0; + + status = CALL set_mc_info( + pMC_Info = &(pVars->mc_info), + audioObjectType = audioObjectType, + sampling_rate_idx = pVars->prog_config.sampling_rate_idx, + tag = pVars->prog_config.front.ele_tag[0], + is_cpe = pVars->prog_config.front.ele_is_cpe[0], + pWinSeqInfo = pVars->pWinSeqInfo, + sfbwidth128 = pVars->SFBWidth128); + MODIFYING (pMC_Info, pWinSeqInfo, sfbwidth128) + RETURNING (SUCCESS) + ENDIF + + IF ((audioObjectType == MP4AUDIO_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE)) + THEN + layer_num = CALL getbits( + neededBits = LEN_LAYER_NUM, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (layer_num) + + status = 1; + ENDIF + + IF (extFlag != FALSE) + THEN + IF (audioObjectType == MP4AUDIO_ER_BSAC) + THEN + numOfSubFrame = CALL getbits( + neededBits = LEN_SUB_FRAME, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (numOfSubFrame) + + layer_len = CALL getbits( + neededBits = LEN_LAYER_LEN, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (layer_len) + + ENDIF + + IF (((audioObjectType > 16) AND (audioObjectType < 22)) OR + (audioObjectType == 23)) + THEN + aacSectionDataResilienceFlag = + CALL getbits( + neededBits = LEN_SECT_RES_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (aacSectionDataResilienceFlag) + + aacScalefactorDataResilienceFlag = + CALL getbits( + neededBits = LEN_SFB_RES_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (aacScalefactorDataResilienceFlag) + + aacSpectralDataResilienceFlag = + CALL getbits( + neededBits = LEN_SPEC_RES_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (aacSpectralDataResilienceFlag) + ENDIF + + status = 1; + + ENDIF + + RETURN status; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_mp4ff_const.h" +#include "e_tmp4audioobjecttype.h" +#include "s_tdec_int_file.h" +#include "get_ga_specific_config.h" +#include "set_mc_info.h" +#include "get_prog_config.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int get_GA_specific_config( + tDec_Int_File * const pVars, + BITS *pInputStream, + UInt channel_config, + const tMP4AudioObjectType audioObjectType +) +{ + + Int status = SUCCESS; + UInt dependsOnCoreCoder; + /* Int coreCoderDelay; */ + UInt extFlag; + + /* These variables are left for future implementation */ + /* UInt layer_num; */ + /* UInt numOfSubFrame; */ + /* UInt layer_len; */ + /* UInt aacSectionDataResilienceFlag; */ + /* UInt aacScalefactorDataResilienceFlag; */ + /* UInt aacSpectralDataResilienceFlag; */ + Int extFlag3; + + /* + * frame length flag == 0, 1024 samples/frame + * frame length flag == 1, 960 samples/frame + */ + get1bits(/* LEN_FRAME_LEN_FLAG,*/ + pInputStream); + + /* + * dependsOnCoreCoder == 1, core coder has different sampling rate + * in a scalable bitstream + */ + dependsOnCoreCoder = + get1bits(/* LEN_DEPEND_ON_CORE,*/ + pInputStream); + + if (dependsOnCoreCoder != FALSE) + { + /*coreCoderDelay = + * getbits( + * LEN_CORE_DELAY, + * pInputStream); + */ + + status = 1; /* do not support scalable coding in this release */ + } + + /* + * extension flag indicates if Amendment 1 objects are used or not + * extension flag == 0 objects = 1, 2, 3, 4, 6, 7 + * extension flag == 1 objects = 17, 19, 20, 21, 22, 23 + */ + extFlag = get1bits(pInputStream); /* LEN_EXT_FLAG,*/ + + + /* Force checks for implicit channel configuration */ + pVars->mc_info.implicit_channeling = 1; + + if (status == SUCCESS) + { + + if (channel_config == 0) + { + status = get_prog_config(pVars, + &pVars->scratch.scratch_prog_config); + + if (status != SUCCESS) + { + pVars->prog_config.front.ele_is_cpe[0] = 0; /* default to mono */ + pVars->mc_info.nch = 1; + pVars->prog_config.front.ele_tag[0] = 0; + pVars->mc_info.audioObjectType = audioObjectType; + + status = SUCCESS; + } + } + else + { + /* + * dummy tag = 0 and + * set up decoding configurations + */ + + if (pVars->multichannel_detected) /* more than 2 channels */ + { + pVars->prog_config.front.ele_is_cpe[0] = 1; /* In this case always default to play the stereo channel */ + pVars->prog_config.front.ele_tag[0] = 0; + } + else + { + channel_config--; + pVars->prog_config.front.ele_is_cpe[0] = channel_config; + pVars->prog_config.front.ele_tag[0] = 0; + } + + status = + set_mc_info( + &(pVars->mc_info), + audioObjectType, /* previously profile */ + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[0], + pVars->prog_config.front.ele_is_cpe[0], + pVars->winmap, /*pVars->pWinSeqInfo,*/ + pVars->SFBWidth128); + + } /* if (channel_config) */ + + } /* if(status) */ + + /* + * This layer_num is not found in ISO/IEC specs, + * but it is defined in San Diego spec for scalable bitstream + */ + if ((audioObjectType == MP4AUDIO_AAC_SCALABLE) || + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE)) + { + /*layer_num = + * getbits( + * LEN_LAYER_NUM, + * pInputStream); + */ + + status = 1; /* for this release only */ + } + + if (extFlag) + { + /* + * currently do not implement these functionalities + * defined in Amendment 1 + * keep it here for future release + */ + if (audioObjectType == MP4AUDIO_ER_BSAC) + { + status = 1; /* NOT SUPPORTED */ + /* + numOfSubFrame = getbits( LEN_SUB_FRAME, pInputStream); + + layer_len = getbits( LEN_LAYER_LEN, pInputStream); + */ + } + + /* + * The following code is equivalent to + * if ((audioObjectType == 17) || (audioObjectType == 18) || + * (audioObjectType == 19) || (audioObjectType == 20) || + * (audioObjectType == 21) || (audioObjectType == 23)) + */ + + if (((audioObjectType > 16) && (audioObjectType < 22)) || + (audioObjectType == 23)) + { + status = 1; /* NOT SUPPORTED */ + /* + aacSectionDataResilienceFlag = getbits( LEN_SECT_RES_FLAG, + pInputStream); + + aacScalefactorDataResilienceFlag = getbits( LEN_SCF_RES_FLAG, + pInputStream); + + aacSpectralDataResilienceFlag = getbits( LEN_SPEC_RES_FLAG, + pInputStream); + */ + } + /* + * this flag is tbd in version 3 of ISO/IEC spec + * if the encoder generates this bit, then it has to be read + * current adif2mp4ff does not write this bit. If this bit is to + * be read, it can be done by the following code: + */ + + extFlag3 = get1bits(pInputStream); /* LEN_EXT_FLAG3 */ + + if (extFlag3) + { + status = 1; /* NOT SUPPORTED */ + } + + } + + return status; +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ics_info.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ics_info.cpp new file mode 100644 index 0000000..d2de5d4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ics_info.cpp @@ -0,0 +1,561 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ics_info.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + audioObjectType = MP4 Audio Object Type for the current song. Only if + this is set to LTP (MP4AUDIO_LTP) will long term + prediction bits be retrieved. Data type + tMP4AudioObjectType, which is an enumeration, which in + turn is an Int. + + pInputStream = pointer to a BITS structure, used by the function getbits + to provide data. This is the second parameter to this + function to match its position in getbits(). + Data type pointer to BITS structure + + common_window = field read in huffdecode, which tells whether information + is shared between the left and right channel. Long term + prediction (LTP) data is NOT shared even if its a common + window, so this flag is needed to see if another set of + LTP possibly needs to be read. If this flag is false, + pSecondLTPStatus is not touched, it could be NULL if + need be. Data type Bool, which is Int. + + pWindowSequence = pointer to where the the window type of the current + frame and channel should be placed, of data type + WINDOW_SEQUENCE, which is Int. It can take on one + of four values: ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE, + EIGHT_SHORT_SEQUENCE, LONG_STOP_SEQUENCE, + + pWindowShape = pointer to where the window shape for the current frame + and channel should be placed, of data type WINDOW_SHAPE, + which is Int. It can take on the one of these two values: + SINE_WINDOW, KAISER_BESSEL_WINDOW. It is used in the + "filterbank" section of decoding. + + group = array that holds the index of the first window in each + group. Data type array of Int, eight elements. + + p_max_sfb = pointer to where the maximum number of scale factor bands + for the current frame and channel will be placed. Data + type of pointer to Int. + + p_winmap = array of pointers to all of the possible four window + configurations. This parameter did not need to be pointers, + and could be changed in the future. Data type array of pointers + to FrameInfo structures, length 4. + + pFirstLTPStatus = pointer to a structure where the first LTP + information will be stored. It would be confusing and wrong + to call this left LTP status since if common_window = FALSE, + this function will be called twice - once for the left, once + for the right. It could be done, but extra conditional code + would need to be done. + Data type pointer to LT_PRED_STATUS structure. + + pSecondLTPStatus = pointer to where the right channel of LTP + information will be stored only if common_window is non-zero. + Data type pointer to LT_PRED_STATUS structure. + + Local Stores/Buffers/Pointers Needed: None. + + Global Stores/Buffers/Pointers Needed: None. + + Outputs: + status = 0 implies no error occurred, non-zero otherwise. + + Pointers and Buffers Modified: + pInputStream contents are modified in such a way that the number of bits + read increases. + pWindowSequence contents are updated with the current window for this + frame and channel + group[] contents will be modified to grouping information. See getgroup + source code for a better description of what this is. + p_max_sfb contents will be updated with the maximum scale factor bands + for this frame and channel. + pFirstLTPStatus contents may be updated if the stream has long term + prediction information. + pSecondLTPStatus contents may be updated if common_window != 0 and LTP data + is present. + + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function retrieves the individual channel stream (ICS) information + from the bitstream. The information read for the current + frame and channel is: + - window sequence + - window shape for use in the filter bank + - number of scale factor bands + - long term predication (LTP) information + - grouping information + + This function does NOT support MPEG2 style AAC Frequency Domain Predictor, + not to be confused with LTP (Long Term Prediction). If such data is found + to be on the file an error is generated. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function is not to use static or global data. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) Titled "Information technology - Coding + of audio-visual objects Part 3: Audio Subpart 4:" + Table 4.4.6 - Syntax of ics_info(), page 16. + + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = 0; + first_ltp_data_present = FALSE; + second_ltp_data_present = FALSE; + + + CALL getbits( + neededBits = LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + windowSequence = (temp >> LEN_WIN_SH) & ((0x1<> LEN_PREDICTOR_DATA_PRESENT); + + predictor_data_present = + (Bool) (temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT)-1)); + + IF (local_max_sfb > allowed_max_sfb) + THEN + status = 1 + ELSEIF (audioObjectType == MP4AUDIO_LTP) + THEN + IF (predictor_data_present != FALSE) + THEN + CALL getbits( + neededBits = LEN_LTP_DATA_PRESENT, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(first_ltp_data_present = returnValue) + + IF (ltp_data_present != FALSE) + THEN + + CALL lt_decode( + win_type = windowSequence, + pInputStream = pInputStream, + max_sfb = local_max_sfb, + pLt_pred = pFirstLTPStatus) + MODIFYING(pInputStream) + MODIFYING(pFirstLTPStatus) + RETURNING(nothing) + + ENDIF + + IF (common_window != FALSE) + THEN + CALL getbits( + neededBits = LEN_LTP_DATA_PRESENT, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(second_ltp_data_present = returnValue) + + IF (second_ltp_data_present != FALSE) + THEN + + CALL lt_decode( + win_type = windowSequence, + pInputStream = pInputStream, + max_sfb = local_max_sfb, + pLt_pred = pSecondLTPStatus) + MODIFYING(pInputStream) + MODIFYING(pSecondLTPStatus) + RETURNING(nothing) + ENDIF + ENDIF + ENDIF + ELSE + IF (predictor_data_present != FALSE) + THEN + status = 1 + ENDIF + END IF + ENDIF + + pFirstLTPStatus->ltp_data_present = first_ltp_data_present; + + IF (common_window != FALSE) + THEN + pSecondLTPStatus->ltp_data_present = second_ltp_data_present; + ENDIF + + pFrameInfo = p_winmap[*p_wnd]; + IF (local_max_sfb > pFrameInfo->sfb_per_frame) + THEN + status = 1; + ENDIF + + *(p_max_sfb) = local_max_sfb; + + MODIFY(*(pWindowSequence)) + MODIFY(*(pWinShape)) + MODIFY(*(p_max_sfb)) + MODIFY(group[]) + MODIFY(*pInputStream) + MODIFY(*pFirstLTPStatus) + MODIFY(*pSecondLTPStatus) + RETURN (status); + + + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +#include "e_rawbitstreamconst.h" +#include "e_tmp4audioobjecttype.h" + +#include "s_bits.h" +#include "s_frameinfo.h" +#include "s_lt_pred_status.h" + +#include "ibstream.h" +#include "lt_decode.h" +#include "ltp_common_internal.h" /* For LEN_LTP_DATA_PRESENT constant */ + +#include "get_ics_info.h" +#include "huffman.h" /* For the declaration of getgroup */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define LEN_PREDICTOR_DATA_PRESENT (1) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int get_ics_info( + const tMP4AudioObjectType audioObjectType, + BITS *pInputStream, + const Bool common_window, + WINDOW_SEQUENCE *pWindowSequence, + WINDOW_SHAPE *pWindowShape, + Int group[], + Int *p_max_sfb, + FrameInfo *p_winmap[], + LT_PRED_STATUS *pFirstLTPStatus, + LT_PRED_STATUS *pSecondLTPStatus) +{ + WINDOW_SEQUENCE windowSequence; + UInt temp; + Bool predictor_data_present; + UInt local_max_sfb; + UInt allowed_max_sfb; + Int status = SUCCESS; + Bool first_ltp_data_present = FALSE; + Bool second_ltp_data_present = FALSE; + + /* + * The following three calls to getbits have been replaced with one + * call for speed: + * + * getbits(LEN_ICS_RESERV, pInputStream); + * windowSequence = getbits(LEN_WIN_SEQ, pInputStream); + * *pWindowShape = getbits(LEN_WIN_SH, pInputStream); + * + */ + + temp = + get9_n_lessbits( + LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH, + pInputStream); + + + windowSequence = (WINDOW_SEQUENCE)((temp >> LEN_WIN_SH) & ((0x1 << LEN_WIN_SEQ) - 1)); + + *pWindowShape = (WINDOW_SHAPE)((temp) & ((0x1 << LEN_WIN_SH) - 1)); + + /* + * This pointer should not be NULL as long as the initialization code + * has been run, so the test for NULL has been removed. + */ + allowed_max_sfb = p_winmap[windowSequence]->sfb_per_win[0]; + + if (windowSequence == EIGHT_SHORT_SEQUENCE) + { + local_max_sfb = get9_n_lessbits(LEN_MAX_SFBS, + pInputStream); + + getgroup( + group, + pInputStream); + + if (local_max_sfb > allowed_max_sfb) + { + status = 1; /* ERROR CODE - needs to be updated */ + } + + } /* end of TRUE of if (windowSequence == EIGHT_SHORT_SEQUENCE) */ + else + { + /* There is only one group for long windows. */ + group[0] = 1; + + /* + * The window is long, get the maximum scale factor bands, + * and get long term prediction info. + * + * Reference [1] states that the audioObjectType is first tested, + * then the predictor_data_present is read on either branch of the + * if (audioObjectType == MP4AUDIO_LTP). Instead, this code combines + * the two calls on both branches into one before the + * if, and then in turn combines with another call to getbits, all + * in the name of speed. + * + * This would be the individual calls, without checking the number + * of scale factor bands: + * + * local_max_sfb = + * (Int) getbits( + * LEN_MAX_SFBL, + * pInputStream); + * + * if (audioObjectType == MP4AUDIO_LTP) + * { + * predictor_data_present = + * (Bool) getbits( + * LEN_PREDICTOR_DATA_PRESENT, + * pInputStream); + * + * ..... (read LTP data) + * + * } + * else + * { + * + * predictor_data_present = + * (Bool) getbits( + * LEN_PREDICTOR_DATA_PRESENT, + * pInputStream); + * + * ..... (its an error for this library) + * } + */ + temp = + get9_n_lessbits( + LEN_MAX_SFBL + LEN_PREDICTOR_DATA_PRESENT, + pInputStream); + + local_max_sfb = (Int)(temp >> LEN_PREDICTOR_DATA_PRESENT); + + predictor_data_present = + (Bool)(temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT) - 1)); + + if (local_max_sfb > allowed_max_sfb) + { + status = 1; /* ERROR CODE - needs to be updated */ + } + else if (audioObjectType == MP4AUDIO_LTP) + { + /* + * Note that the predictor data bit has already been + * read. + */ + + /* + * If the object type is LTP, the predictor data is + * LTP. If the object type is not LTP, the predictor data + * is so called "frequency predictor data", which is not + * supported by this implementation. Refer to (1) + */ + if (predictor_data_present != FALSE) + { + first_ltp_data_present = + (Bool) get1bits(/* LEN_LTP_DATA_PRESENT,*/ + pInputStream); + + if (first_ltp_data_present != FALSE) + { + lt_decode( + windowSequence, + pInputStream, + local_max_sfb, + pFirstLTPStatus); + } + if (common_window != FALSE) + { + second_ltp_data_present = + (Bool) get1bits(/* LEN_LTP_DATA_PRESENT,*/ + pInputStream); + + if (second_ltp_data_present != FALSE) + { + lt_decode( + windowSequence, + pInputStream, + local_max_sfb, + pSecondLTPStatus); + } + } /* if (common_window != FALSE) */ + + } /* if (predictor_data_present != FALSE) */ + + } /* else if (audioObjectType == MP4AUDIO_LTP) */ + else + { + /* + * Note that the predictor data bit has already been + * read. + */ + + /* + * The object type is not LTP. If there is data, its + * frequency predictor data, not supported by this + * implementation. + */ + if (predictor_data_present != FALSE) + { + status = 1; /* ERROR CODE UPDATE LATER */ + } /* if (predictor_data_present != FALSE) */ + + } /* end of "else" clause of if (audioObjectType == MP4AUDIO_LTP) */ + + } /* if (windowSequence == EIGHT_SHORT_SEQUENCE) [FALSE branch] */ + + + /* + * Save all local copies. + */ + pFirstLTPStatus->ltp_data_present = first_ltp_data_present; + if (common_window != FALSE) + { + pSecondLTPStatus->ltp_data_present = second_ltp_data_present; + } + + *p_max_sfb = local_max_sfb; + + *pWindowSequence = windowSequence; + + return (status); + +} /* get_ics_info */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_prog_config.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_prog_config.cpp new file mode 100644 index 0000000..279740f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_prog_config.cpp @@ -0,0 +1,692 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_prog_config.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that holds all information for + this instance of the library. pVars->prog_config is directly + used, and pVars->mc_info, pVars->prog_config, pVars->winmap, + pVars->SFBWidth128 are needed indirectly for calling + set_mc_info. Data type pointer to tDec_Int_File structure. + + pScratchPCE = pointer to a temporary ProgConfig structure to be used + to read in the program configuration element. + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = zero if no error was found, non-zero otherwise. + + Pointers and Buffers Modified: + pVars->prog_config contents are updated with the PCE read in. + pVars->mc_info contents are updated with channel information. + pVars->winmap contents are updated with window information. + pVars->SFBWidth128 contents are updated with scale factor band width data. + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads from the input stream to memory for a temporary + program configuration element (PCE). If the PCE read is the first + encountered it is saved. Or, if the tag of the PCE read matches the tag of + the first PCE encounted, it is saved as well. This is a mechanism for + changing the sampling rate. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use static or global variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(), + page 16, and section 8.5 "Program Config Element (PCE)", page 30. + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = SUCCESS; + pInputStream = &(pVars->inputStream); + + + CALL getbits( + neededBits = LEN_TAG, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( tag = returnValue ) + + CALL getbits( + neededBits = LEN_PROFILE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( pScratchPCE->profile = returnValue ) + + CALL getbits( + neededBits = LEN_PROFILE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( pScratchPCE->sampling_rate_idx = returnValue ) + + CALL getbits( + neededBits = LEN_NUM_ELE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->front.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_ELE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->side.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_ELE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->back.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_LFE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->lfe.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_DAT, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->data.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_CCE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->coupling.num_ele = temp; + + CALL getbits( + neededBits = LEN_MIX_PRES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( flag = returnValue ) + + pScratchPCE->mono_mix.present = flag; + + IF (flag != FALSE) + THEN + CALL getbits( + neededBits = LEN_TAG, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->mono_mix.ele_tag = temp; + + ENDIF + + CALL getbits( + neededBits = LEN_MIX_PRES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( flag = returnValue ) + + pScratchPCE->stereo_mix.present = flag; + + IF (flag != FALSE) + THEN + + CALL getbits( + neededBits = LEN_TAG, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->stereo_mix.ele_tag = temp; + + ENDIF + + CALL getbits( + neededBits = LEN_MIX_PRES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( flag = returnValue ) + + flag = + getbits( + LEN_MIX_PRES, + pInputStream); + + pScratchPCE->matrix_mix.present = flag; + + IF (flag != FALSE) + THEN + CALL getbits( + neededBits = LEN_MMIX_IDX, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->matrix_mix.ele_tag = temp; + + CALL getbits( + neededBits = LEN_PSUR_ENAB, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->matrix_mix.pseudo_enab = temp; + + ENDIF + + + CALL get_ele_list( + pElementList = &pScratchPCE->front, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->front ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->side, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->side ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->back, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->back ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->lfe, + pInputStream = pInputStream, + enableCPE = FALSE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->lfe ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->data, + pInputStream = pInputStream, + enableCPE = FALSE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->data ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->coupling, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->coupling ) + RETURNING( nothing ) + + + CALL byte_align( + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( nothing ) + + CALL getbits( + neededBits = LEN_COMMENT_BYTES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( numChars = returnValue ) + + FOR (i = numChars; i > 0; i--) + + CALL getbits( + neededBits = LEN_COMMENT_BYTES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( nothing ) + + ENDFOR + + IF (pVars->current_program < 0) + THEN + pVars->current_program = tag; + ENDIF + + + IF (tag == pVars->current_program) + THEN + + CALL pv_memcpy( + to = &pVars->prog_config, + from = pScratchPCE, + n = sizeof(ProgConfig)) + MODIFYING( pVars->prog_config ) + RETURNING( nothing ) + + CALL set_mc_info( + pMC_Info = &pVars->mc_info, + objectType = pVars->prog_config.profile + 1, + samplin_rate_idx = pVars->prog_config.sampling_rate_idx, + tag = pVars->prog_config.front.ele_tag[0], + is_cpe = pVars->prog_config.front.ele_is_cpe[0], + pWinSeqInfo = pVars->winmap, + pSfbwidth128 = pVars->SFBWidth128) + MODIFYING( pVars->mc_info ) + MODIFYING( pVars->winmap ) + MODIFYING( pVars->SFBWidth128 ) + RETURN( status = return_value ) + + ENDIF + + MODIFY( pVars->mc_info ) + MODIFY( pVars->winmap ) + MODIFY( pVars->SFBWidth128 ) + RETURN (status) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "s_elelist.h" +#include "s_tdec_int_file.h" +#include "s_tdec_int_chan.h" +#include "e_progconfigconst.h" +#include "ibstream.h" +#include "get_ele_list.h" +#include "aac_mem_funcs.h" +#include "set_mc_info.h" +#include "get_prog_config.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +Int get_prog_config( + tDec_Int_File *pVars, + ProgConfig *pScratchPCE) +{ + Int i; + UInt tag; + Int numChars; + UInt temp; + Bool flag; + Int status = SUCCESS; + BITS *pInputStream = &(pVars->inputStream); + + + /* + * The tag is used at the very end to see if this PCE is + * the one to be used. Otherwise it does not need to be saved for the + * the simple configurations to be used in this version of an AAC + * decoder. + * + * All of the bits of this PCE must be read even if this PCE will not + * be used. They are read into a temporary PCE, then later it is decided + * whether to keep this PCE. + * + * To allow quick removal of the fields from the ProgConfig structure + * that will probably not be used at a later date, + * while still advancing the bitstream pointer,the return value of + * getbits is saved into a temporary variable, then transfered to + * the structure item. + */ + tag = get9_n_lessbits(LEN_TAG, pInputStream); + + pScratchPCE->profile = get9_n_lessbits(LEN_PROFILE, pInputStream); + + pScratchPCE->sampling_rate_idx = get9_n_lessbits(LEN_SAMP_IDX, pInputStream); + + if (!pVars->adif_test && (pScratchPCE->sampling_rate_idx != pVars->prog_config.sampling_rate_idx)) + { +#ifdef AAC_PLUS + /* + * PCE carries the baseline frequency, if SBR or PS are used, the frequencies will not match + * so check for this unique case, and let decoding continue if this is a redundant PCE + */ + if ((pScratchPCE->sampling_rate_idx != (pVars->prog_config.sampling_rate_idx + 3)) || + (pVars->mc_info.upsamplingFactor != 2)) +#endif + { + /* rewind the pointer as implicit channel configuration maybe the case */ + pInputStream->usedBits -= (LEN_TAG + LEN_PROFILE + LEN_SAMP_IDX); + + return (1); /* mismatch cannot happen */ + } + } + + + /* + * Retrieve the number of element lists for each of + * front, side, back, lfe, data, and coupling. + * + * For two-channel stereo or mono, only the data in the front needs + * to be saved. However, ALL fields need to be skipped over in some + * fashion. Also, the number of elements needs to be temporarily saved + * to call get_ele_list(). If that function was changed to pass in + * the number of points to be read, the memory set aside inside the + * ProgConfig structure could be removed. + */ + + /* + * The next six function calls could be combined into one, then use + * shifts and masks to retrieve the individual fields. + */ + temp = get9_n_lessbits(LEN_NUM_ELE, pInputStream); + + pScratchPCE->front.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = get9_n_lessbits(LEN_NUM_ELE, pInputStream); + + pScratchPCE->side.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = get9_n_lessbits(LEN_NUM_ELE, pInputStream); + + pScratchPCE->back.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = get9_n_lessbits(LEN_NUM_LFE, pInputStream); + + pScratchPCE->lfe.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = get9_n_lessbits(LEN_NUM_DAT, pInputStream); + pScratchPCE->data.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = get9_n_lessbits(LEN_NUM_CCE, pInputStream); + + pScratchPCE->coupling.num_ele = temp; + + /* + * Read in mix down data. + * + * Whether these fields can be removed and have proper operation + * will be determined at a later date. + */ + + /* Read presence of mono_mix */ + flag = get1bits(pInputStream);/* LEN_MIX_PRES,*/ + + pScratchPCE->mono_mix.present = flag; + + if (flag != FALSE) + { + temp = get9_n_lessbits(LEN_TAG, pInputStream); + + pScratchPCE->mono_mix.ele_tag = temp; + + } /* end if (flag != FALSE) */ + + /* Read presence of stereo mix */ + flag = get1bits(pInputStream); /* LEN_MIX_PRES,*/ + + pScratchPCE->stereo_mix.present = flag; + + if (flag != FALSE) + { + temp = get9_n_lessbits(LEN_TAG, pInputStream); + + pScratchPCE->stereo_mix.ele_tag = temp; + + } /* end if (flag != FALSE) */ + + /* Read presence of matrix mix */ + flag = get1bits(pInputStream); /* LEN_MIX_PRES,*/ + + pScratchPCE->matrix_mix.present = flag; + + if (flag != FALSE) + { + temp = get9_n_lessbits(LEN_MMIX_IDX, pInputStream); + + pScratchPCE->matrix_mix.ele_tag = temp; + + temp = get1bits(pInputStream); /* LEN_PSUR_ENAB,*/ + + pScratchPCE->matrix_mix.pseudo_enab = temp; + + } /* end if (flag != FALSE) */ + + /* + * Get each of the element lists. Only the front information will be + * used for the PV decoder, but the usedBits field of pInputStream must + * be advanced appropriately. + * + * This could be optimized by advancing the bit stream for the + * elements that do not need to be read. + */ + get_ele_list(&pScratchPCE->front, + pInputStream, + TRUE); + + get_ele_list(&pScratchPCE->side, + pInputStream, + TRUE); + + get_ele_list(&pScratchPCE->back, + pInputStream, + TRUE); + + get_ele_list(&pScratchPCE->lfe, + pInputStream, + FALSE); + + get_ele_list(&pScratchPCE->data, + pInputStream, + FALSE); + + get_ele_list(&pScratchPCE->coupling, + pInputStream, + TRUE); + + /* + * The standard requests a byte alignment before reading in the + * comment. This can be done because LEN_COMMENT_BYTES == 8. + */ + byte_align(pInputStream); + + numChars = get9_n_lessbits(LEN_COMMENT_BYTES, pInputStream); + + /* + * Ignore the comment - it requires 65 bytes to store (or worse on DSP). + * If this field is restored, make sure to append a trailing '\0' + */ + for (i = numChars; i > 0; i--) + { + pScratchPCE->comments[i] = (Char) get9_n_lessbits(LEN_BYTE, + pInputStream); + + } /* end for */ + + + if (pVars->current_program < 0) + { + /* + * If this is the first PCE, it becomes the current, regardless of + * its tag number. + */ + pVars->current_program = tag; + + pVars->mc_info.ch_info[0].tag = 0; + + } /* end if (pVars->current_program < 0) */ + + + if (tag == (UInt)pVars->current_program) + { + /* + * This branch is reached under two conditions: + * 1) This is the first PCE found, it was selected in the above if + * block. In all encoders found thus far, the tag value has been + * zero. + * 2) A PCE has been sent by the encoder with a tag that matches the + * the first one sent. It will then be re-read. No encoder found + * + * Regardless, the temporary PCE will now be copied into the + * the one official program configuration. + */ + + /* + * Keep adts setting in case of a redundant PCE (only applicable when + * using aac-lib own adts parser) + */ + pScratchPCE->file_is_adts = pVars->prog_config.file_is_adts; + pScratchPCE->headerless_frames = pVars->prog_config.headerless_frames; + + pv_memcpy(&pVars->prog_config, + pScratchPCE, + sizeof(ProgConfig)); + + + tag = 0; + + /* + * Check that dual-mono does not carry more than 2 tracks, otherwise flag an non-supported error + */ + if ((pVars->prog_config.front.num_ele > 2) && !(pVars->prog_config.front.ele_is_cpe[tag])) + { + status = 1; + } + + /* + * Check that stereo does not carry more than 1 track, otherwise flag an non-supported error + */ + if ((pVars->prog_config.front.num_ele > 1) && (pVars->prog_config.front.ele_is_cpe[tag])) + { + status = 1; + } + + + + if (!status) + { + + /* enter configuration into MC_Info structure */ + status = set_mc_info(&pVars->mc_info, + (tMP4AudioObjectType)(pVars->prog_config.profile + 1), + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[tag], + pVars->prog_config.front.ele_is_cpe[tag], + pVars->winmap, + pVars->SFBWidth128); + + if (pVars->mc_info.upsamplingFactor == 2) + { + /* + * prog_config.sampling_rate_idx corresponds to the aac base layer, + * if the upsampling factor is active, then the output frequency needs + * to be adjusted accordingly + */ + pVars->prog_config.sampling_rate_idx -= 3; + } + + } + + + } /* end if (tag == pVars->current_program) */ + + + + return (status); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getactualaacconfig.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getactualaacconfig.cpp new file mode 100644 index 0000000..9ff56cd --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getactualaacconfig.cpp @@ -0,0 +1,314 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getactualaacconfig.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external interface structure. See the file + PVMP4AudioDecoder_API.h for a description of each field. + Data type of pointer to a tPVMP4AudioDecoderExternal + structure. + + pExt->pInputBuffer: pointer to input buffer containing input + bitstream + + pExt->inputBufferCurrentLength: number of bytes in the input buffer + + pExt->inputBufferUsedLength: number of bytes already consumed in + input buffer + + pExt->remainderBits: number of bits consumed in addition to + pExt->inputBufferUsedLength + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tDec_Int_File structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tDec_Int_File + structure. + + aStream = pointer to a UChar* stream that holds the input stream. + + aProperty = pointer to a structure DecodeProperties (define in include file) + + Local Stores/Buffers/Pointers Needed: None + (The memory set aside in pMem performs this task) + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 if no error occurred + MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred + MP4AUDEC_RECOVERABLE if a recoverable error occurred. + Presently a recoverable error does not exist, but this + was a requirement. + + + Pointers and Buffers Modified: + pMem contents are modified. + pExt: (more detail in the file PVMP4AudioDecoder_API.h) + inputBufferUsedLength - number of array elements used up by the stream. + remainderBits - remaining bits in the next UInt32 buffer + samplingRate - sampling rate in samples per sec + encodedChannels - channels found on the file (informative) + frameLength - length of the frame + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "getactualaacconfig.h" +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "ibstream.h" /* where #define INBUF_ARRAY_INDEX_SHIFT */ +#include "sfb.h" /* Where samp_rate_info[] is declared */ + +#include "get_audio_specific_config.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ + +#include "oscl_error_codes.h" +#include "oscl_exception.h" +#include "oscl_mem.h" +#include "e_elementid.h" +#include "e_sbr_element_id.h" +#include "get_dse.h" +#include "get_sbr_bitstream.h" +#include "get_prog_config.h" +#include "huffman.h" /* where huffdecode is declared */ +#include "e_sbr_error.h" +#include "sbr_read_data.h" +#include "sbr_open.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define ERROR_BUFFER_OVERRUN (-2) +#define KCODEC_INIT_FAILURE (-1) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +#include "oscl_dll.h" +OSCL_DLL_ENTRY_POINT_DEFAULT() + + +OSCL_EXPORT_REF int32 GetActualAacConfig(uint8* aConfigHeader, + uint8* aAudioObjectType, + int32* aConfigHeaderSize, + uint8* SamplingRateIndex, + uint32* NumChannels, + uint32* aSamplesPerFrame) +{ + + tPVMP4AudioDecoderExternal * iAACDecExt = NULL; + UInt initialUsedBits; /* Unsigned for C55x */ + tDec_Int_File *pVars; /* Helper pointer */ + MC_Info *pMC_Info; /* Helper pointer */ + + Int status = ERROR_BUFFER_OVERRUN; + + /* + * Allocate memory to decode one AAC frame + */ + + + iAACDecExt = new tPVMP4AudioDecoderExternal; + if (!iAACDecExt) + { + return 1; + } + iAACDecExt->inputBufferCurrentLength = 0; + + + iAACDecExt->pInputBuffer = aConfigHeader; + iAACDecExt->inputBufferMaxLength = PVMP4AUDIODECODER_INBUFSIZE; + + + iAACDecExt->inputBufferUsedLength = 0; + iAACDecExt->remainderBits = 0; + + int32 memreq = PVMP4AudioDecoderGetMemRequirements(); + + uint8 *pMem = OSCL_ARRAY_NEW(uint8 , memreq); + + if (pMem == 0) + { + return KCODEC_INIT_FAILURE; + } + + if (PVMP4AudioDecoderInitLibrary(iAACDecExt, pMem) != 0) + { + return KCODEC_INIT_FAILURE; + } + + iAACDecExt->inputBufferCurrentLength = *aConfigHeaderSize; + + + /* + * Initialize "helper" pointers to existing memory. + */ + + pVars = (tDec_Int_File *)pMem; + + + pMC_Info = &pVars->mc_info; + + + + /* + * Translate input buffer variables. + */ + pVars->inputStream.pBuffer = iAACDecExt->pInputBuffer; + + pVars->inputStream.availableBits = + (UInt)(iAACDecExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT); + + initialUsedBits = + (UInt)((iAACDecExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) + + iAACDecExt->remainderBits); + + pVars->inputStream.inputBufferCurrentLength = + (UInt)iAACDecExt->inputBufferCurrentLength; + + pVars->inputStream.usedBits = initialUsedBits; + + pVars->aacPlusEnabled = true; /* Always enable aacplus decoding */ + + + if (initialUsedBits <= pVars->inputStream.availableBits) + { + /* + * Buffer is not overrun, then + * decode the AudioSpecificConfig() structure + */ + pVars->aacConfigUtilityEnabled = true; /* set aac utility mode */ + + int tmp = pVars->inputStream.usedBits; /* store initial offset */ + + status = get_audio_specific_config(pVars); + + if (status != SUCCESS) /* on error, check if streamMuxConfig was sent */ + { + pVars->inputStream.usedBits = tmp + 15; /* jump over streamMuxConfig bits */ + status = get_audio_specific_config(pVars); + } + + } + + + byte_align(&pVars->inputStream); + + *aConfigHeaderSize = (Int32)((pVars->inputStream.usedBits) >> 3); + + + *SamplingRateIndex = pVars->prog_config.sampling_rate_idx; + + *NumChannels = pVars->mc_info.nch; + + /* + * Set the audio object type to the extended type, only if this is different + * from the baseline object type (this only applies to explicit signaling) + */ + if (pVars->mc_info.audioObjectType != pVars->mc_info.ExtendedAudioObjectType) + { + *aAudioObjectType = pVars->mc_info.ExtendedAudioObjectType; + } + else + { + *aAudioObjectType = pVars->mc_info.audioObjectType; + } + + *aSamplesPerFrame = LONG_WINDOW << (pVars->mc_info.upsamplingFactor - 1); + + /* + * Set parameters based on the explicit information from the + * audio specific config + */ + + if (pVars->mc_info.sbrPresentFlag) + { + if (pVars->mc_info.psPresentFlag) + { + *NumChannels += 1; + } + } + + pVars->status = status; + + /* + * Clear allocated memory + */ + if (pMem != NULL) + { + OSCL_ARRAY_DELETE(pMem); + pMem = NULL; + } + + + OSCL_DELETE(iAACDecExt); + iAACDecExt = NULL; + + return status; +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getgroup.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getgroup.cpp new file mode 100644 index 0000000..51fab4f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getgroup.cpp @@ -0,0 +1,214 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getgroup.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to structure that holds input bitstream + information. Type BITS + + group[] = array that holds the index of the first window in each + group. Type Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + group contains the index of first windows in each group + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads the window grouping information associated with an + Individual Channel Stream (ICS). If the window sequence is + EIGHT_SHORT_SEQUENCE, scalefactor grouping information is transmitted. If a + set of short windows form a group then they share scalefactors, intensity + positions and PNS information. The first short window is always a new group + so no grouping bit is transmitted. Subsequent short windows are in the same + group if the associated grouping bit is 1. A new group is started if the + associated grouping bit is 0. + The pointer pGroup points to an array that stores the first window index + of next group. For example, if the window grouping is: + + window index: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | + grouping : |<- 0 ->| 1 |<- 2 ->|<- 3 ->| + + Then: + + group[] : | 2 | 3 | 6 | 8 | + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should replace the contents of the array pointed to by pGroup + with the first window indexes of groups starting from the second group. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 + p16 (Table 4.4.6) + p55 (Recovering ics_info) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF (pFrameInfo->coef_per_win[0] > SN2) + + *pGroup++ = 1; + *pGroup = 1; + + ELSE + + FOR (win = 1; win < pFrameInfo->num_win; win++) + + IF (getbits(1,pInputStream) == 0) + + *pGroup++ = win; + + ENDIF + + ENDFOR (win) + + *pGroup = win; + + ENDIF(pFrameInfo) + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define SEVEN 7 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void getgroup( + Int group[], + BITS *pInputStream) +{ + Int win; + Int *pGroup; + UInt mask; + UInt groupBits; + + pGroup = group; + + mask = 0x40; + + /* only short-window sequences are grouped! + * first short window is always a new group, + * start reading bitstream from the second + * window, a new group is indicated by an + * "0" bit in the input stream + */ + groupBits = + get9_n_lessbits( + SEVEN, + pInputStream); + + for (win = 1; win < NUM_SHORT_WINDOWS; win++) + { + if ((groupBits & mask) == 0) + { + *pGroup++ = win; + + } /* if (groupBits) */ + + mask >>= 1; + + } /* for (win) */ + + *pGroup = win; + +} /* getgroup */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/infoinit.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/infoinit.cpp new file mode 100644 index 0000000..d578a32 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/infoinit.cpp @@ -0,0 +1,312 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: infoinit.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pSi = pointer to sampling rate info + ppWin_seq_info = pointer array to window sequence Info struct + pSfbwidth128 = pointer to sfb bandwidth array of short window + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + + ppWin_seq_info[ONLY_LONG_WINDOW]{all structure members} = setup values + ppWin_seq_info[EIGHT_SHORT_WINDOW]{all structure members} = setup values + + Local Stores Modified: + + Global Stores Modified: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function sets the values of 'Info' structure for blocks containing long + and short window sequences, the following structures are being set: + + win_seq_info[ONLY_LONG_WINDOW], win_seq_info[EIGHT_SHORT_WINDOW], + only_long_info and eight_short_info + +------------------------------------------------------------------------------ + REQUIREMENTS + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p66 (sfb tables) + p111 (4.6.10) + p200 (Annex 4.B.5) +------------------------------------------------------------------------------ + PSEUDO-CODE + + pFrameInfo = pointer to only_long_info; + win_seq_info[ONLY_LONG_WINDOW] = pFrameInfo; + pFrameInfo{all structure members} = setup values; + + + pFrameInfo = pointer to eight_short_info; + win_seq_info[EIGHT_SHORT_WINDOW] = pFrameInfo; + pFrameInfo{all structure.members} = setup values; + + + FOR (window_seq = 0; window_seq < NUM_WIN_SEQ; win_seq++) + + win_seq_info[window_seq].members = setup values; + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sr_info.h" +#include "s_frameinfo.h" +#include "e_blockswitching.h" +#include "e_huffmanconst.h" +#include "sfb.h" +#include "huffman.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int infoinit( + const Int samp_rate_idx, + FrameInfo **ppWin_seq_info, + Int *pSfbwidth128) + +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + + Int i; + Int sfb_idx, sfb_sbk; + Int bins_sbk; + Int win_seq; + Int start_idx, end_idx; + Int nsfb_short; + Int16 *sfbands; + FrameInfo *pFrameInfo; + + const SR_Info *pSi = &(samp_rate_info[samp_rate_idx]); + + const Int16 * pt_SFbands1024 = NULL; + const Int16 * pt_SFbands128 = NULL; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + switch (pSi->samp_rate) + { + case 96000: + case 88200: + pt_SFbands1024 = sfb_96_1024; + pt_SFbands128 = sfb_64_128; /* equal to table sfb_96_128, (eliminated) */ + break; + case 64000: + pt_SFbands1024 = sfb_64_1024; + pt_SFbands128 = sfb_64_128; + break; + case 48000: + case 44100: + pt_SFbands1024 = sfb_48_1024; + pt_SFbands128 = sfb_48_128; + break; + case 32000: + pt_SFbands1024 = sfb_32_1024; + pt_SFbands128 = sfb_48_128; + break; + case 24000: + case 22050: + pt_SFbands1024 = sfb_24_1024; + pt_SFbands128 = sfb_24_128; + break; + case 16000: + case 12000: + case 11025: + pt_SFbands1024 = sfb_16_1024; + pt_SFbands128 = sfb_16_128; + break; + case 8000: + pt_SFbands1024 = sfb_8_1024; + pt_SFbands128 = sfb_8_128; + break; + default: + // sampling rate not supported + return -1; + } + + /* long block info */ + + pFrameInfo = ppWin_seq_info[ONLY_LONG_WINDOW]; + pFrameInfo->islong = 1; + pFrameInfo->num_win = 1; + pFrameInfo->coef_per_frame = LN2; /* = 1024 */ + + pFrameInfo->sfb_per_win[0] = pSi->nsfb1024; + pFrameInfo->sectbits[0] = LONG_SECT_BITS; + pFrameInfo->win_sfb_top[0] = (Int16 *)pt_SFbands1024; + + pFrameInfo->sfb_width_128 = NULL; /* no short block sfb */ + pFrameInfo->num_groups = 1; /* long block, one group */ + pFrameInfo->group_len[0] = 1; /* only one window */ + + /* short block info */ + pFrameInfo = ppWin_seq_info[EIGHT_SHORT_WINDOW]; + pFrameInfo->islong = 0; + pFrameInfo->num_win = NSHORT; + pFrameInfo->coef_per_frame = LN2; + + for (i = 0; i < pFrameInfo->num_win; i++) + { + pFrameInfo->sfb_per_win[i] = pSi->nsfb128; + pFrameInfo->sectbits[i] = SHORT_SECT_BITS; + pFrameInfo->win_sfb_top[i] = (Int16 *)pt_SFbands128; + } + + /* construct sfb width table */ + pFrameInfo->sfb_width_128 = pSfbwidth128; + for (i = 0, start_idx = 0, nsfb_short = pSi->nsfb128; i < nsfb_short; i++) + { + end_idx = pt_SFbands128[i]; + pSfbwidth128[i] = end_idx - start_idx; + start_idx = end_idx; + } + + + /* common to long and short */ + for (win_seq = 0; win_seq < NUM_WIN_SEQ; win_seq++) + { + + if (ppWin_seq_info[win_seq] != NULL) + { + pFrameInfo = ppWin_seq_info[win_seq]; + pFrameInfo->sfb_per_frame = 0; + sfb_sbk = 0; + bins_sbk = 0; + + for (i = 0; i < pFrameInfo->num_win; i++) + { + + /* compute coef_per_win */ + pFrameInfo->coef_per_win[i] = + pFrameInfo->coef_per_frame / pFrameInfo->num_win; + + /* compute sfb_per_frame */ + pFrameInfo->sfb_per_frame += pFrameInfo->sfb_per_win[i]; + + /* construct default (non-interleaved) bk_sfb_top[] */ + sfbands = pFrameInfo->win_sfb_top[i]; + for (sfb_idx = 0; sfb_idx < pFrameInfo->sfb_per_win[i]; + sfb_idx++) + { + pFrameInfo->frame_sfb_top[sfb_idx+sfb_sbk] = + sfbands[sfb_idx] + bins_sbk; + } + + bins_sbk += pFrameInfo->coef_per_win[i]; + sfb_sbk += pFrameInfo->sfb_per_win[i]; + } /* for i = sbk ends */ + } + + } /* for win_seq ends */ + + return SUCCESS; + +} /* infoinit */ + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/lt_decode.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/lt_decode.cpp new file mode 100644 index 0000000..b6c3c4b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/lt_decode.cpp @@ -0,0 +1,461 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: lt_decode.cpp + + +------------------------------------------------------------------------------ + + INPUT AND OUTPUT DEFINITIONS + + Inputs: + win_type Type of window (SHORT or LONG) + [WINDOW_TYPE] + + max_sfb Maximum number of active scalefactor bands + [Int] + + pLt_pred Pointer to structure containing information for + long-term prediction. + [LT_PRED_STATUS *] + + pInputStream Pointer to structure containing bitstream + information. + [BITS *] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pLt_pred->weight_index - updated with index into weight table for LTP. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function decodes the bitstream elements for long term prediction + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by Nokia + in the course of development of the MPEG-2 AAC/MPEG-4 Audio standard + ISO/IEC13818-7, 14496-1, 2 and 3. This software module is an implementation + of a part of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the + MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC gives users of the + MPEG-2aac/MPEG-4 Audio standards free license to this software module or + modifications thereof for use in hardware or software products claiming + conformance to the MPEG-2 aac/MPEG-4 Audio standards. Those intending to + use this software module in hardware or software products are advised that + this use may infringe existing patents. The original developer of this + software module, the subsequent editors and their companies, and ISO/IEC + have no liability for use of this software module or modifications thereof + in an implementation. Copyright is not released for non MPEG-2 aac/MPEG-4 + Audio conforming products. The original developer retains full right to use + the code for the developer's own purpose, assign or donate the code to a + third party and to inhibit third party from using the code for non + MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice + must be included in all copies or derivative works." + Copyright (c)1997. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pDelay[0] = (Int) getbits( + LEN_LTP_LAG, + pInputStream); + + temp_reg = (Int) getbits( + LEN_LTP_COEF, + pInputStream); + + pLt_pred->weight = codebook[temp_reg]; + + last_band = max_sfb; + + IF (win_type != EIGHT_SHORT_SEQUENCE) + + IF (last_band > MAX_LT_PRED_LONG_SFB) + + last_band = MAX_LT_PRED_LONG_SFB; + + ENDIF + + FOR (m = last_band; m > 0; m--) + + *(pSfbPredictionUsed++) = (Int) getbits( + LEN_LTP_LONG_USED, + pInputStream); + ENDFOR + + FOR (m = (max_sfb - last_band); m > 0; m--) + + *(pSfbPredictionUsed++) = 0; + + ENDFOR + + ELSE + + IF (last_band > MAX_LT_PRED_SHORT_SFB) + + last_band = MAX_LT_PRED_SHORT_SFB; + + ENDIF + + prev_subblock = pDelay[0]; + + pWinPredictionUsed++; + + pTempPtr = &pSfbPredictionUsed[0]; + + FOR (m = NUM_SHORT_WINDOWS; m > 0;) + + m--; + temp_reg = (Int) getbits( + LEN_LTP_SHORT_USED, + pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + IF (temp_reg != FALSE) + { + *(pDelay++) = prev_subblock; + + FOR (k = last_band; k > 0; k--) + { + *(pTempPtr++) = 1; + } + break; + ELSE + { + pDelay++; + pTempPtr += last_band; + } + + ENDFOR (m = NUM_SHORT_WINDOWS; m > 0;) + + prev_subblock += LTP_LAG_OFFSET; + + FOR (; m > 0; m--) + + temp_reg = (Int) getbits ( + LEN_LTP_SHORT_USED, + pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + IF (temp_reg != FALSE) + + temp_reg = (Int) getbits( + LEN_LTP_SHORT_LAG_PRESENT, + pInputStream); + IF (temp_reg != 0) + + temp_reg = (Int) getbits( + LEN_LTP_SHORT_LAG, + pInputStream); + + *(pDelay++) = prev_subblock - temp_reg; + + ELSE + + *(pDelay++) = prev_subblock - LTP_LAG_OFFSET; + + ENDIF + + FOR (k = last_band; k > 0; k--) + *(pTempPtr++) = 1; + ENDFOR + + ELSE + + pDelay++; + pTempPtr += last_band; + + ENDIF + + ENDFOR (; m > 0; m--) + + ENDIF (win_type != EIGHT_SHORT_SEQUENCE) + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "lt_decode.h" +#include "ltp_common_internal.h" +#include "window_block_fxp.h" +#include "e_window_sequence.h" +#include "s_lt_pred_status.h" +#include "s_bits.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void lt_decode( + const WINDOW_SEQUENCE win_type, + BITS *pInputStream, + const Int max_sfb, + LT_PRED_STATUS *pLt_pred) +{ + Int wnd_num; + Int k; + Int last_band; + Int prev_subblock; + Int prev_subblock_nonzero; + Int temp_reg; + + Bool *pWinPredictionUsed = pLt_pred->win_prediction_used; + Bool *pSfbPredictionUsed = pLt_pred->sfb_prediction_used; + Int *pTempPtr; + Int *pDelay = pLt_pred->delay; + + pDelay[0] = (Int) get17_n_lessbits( + LEN_LTP_LAG, /* 11 bits */ + pInputStream); + + pLt_pred->weight_index = (Int) get9_n_lessbits( + LEN_LTP_COEF, /* 3 bits */ + pInputStream); + + last_band = max_sfb; + + if (win_type != EIGHT_SHORT_SEQUENCE) + { + + /* last_band = min(MAX_LT_PRED_LONG_SFB, max_sfb) MAX_SCFAC_BANDS */ + if (last_band > MAX_LT_PRED_LONG_SFB) + { + last_band = MAX_LT_PRED_LONG_SFB; + } + + for (k = last_band; k > 0; k--) + { + *(pSfbPredictionUsed++) = (Int) get1bits(pInputStream); + } + + /* + * This is not a call to memset, because + * (max_sfb - last_band) should typically be a small value. + */ + for (k = (max_sfb - last_band); k > 0; k--) + { + *(pSfbPredictionUsed++) = FALSE; + } + } + else /* (win_type == EIGHT_SHORT_SEQUENCE) */ + { + /* last_band = min(MAX_LT_PRED_SHORT_SFB, max_sfb) */ + + if (last_band > MAX_LT_PRED_SHORT_SFB) + { + last_band = MAX_LT_PRED_SHORT_SFB; + } + + /* + * The following two coding constructs are equivalent... + * + * first_time == 1 + * for (wnd_num=NUM_SHORT_WINDOWS; wnd_num > 0; wnd_num--) + * { + * if (condition) + * { + * if (first_time == 1) + * { + * CODE SECTION A + * first_time = 0; + * } + * else + * { + * CODE SECTION B + * } + * } + * } + * + * -----------------------------------EQUIVALENT TO------------ + * + * wnd_num=NUM_SHORT_WINDOWS; + * + * do + * { + * wnd_num--; + * if (condition) + * { + * CODE SECTION A + * break; + * } + * } while( wnd_num > 0) + * + * while (wnd_num > 0) + * { + * if (condition) + * { + * CODE SECTION B + * } + * wnd_num--; + * } + * + */ + + prev_subblock = pDelay[0]; + + pTempPtr = &pSfbPredictionUsed[0]; + + wnd_num = NUM_SHORT_WINDOWS; + + prev_subblock_nonzero = prev_subblock; + prev_subblock += LTP_LAG_OFFSET; + + do + { + /* + * Place decrement of wnd_num here, to insure + * that the decrement occurs before the + * break out of the do-while loop. + */ + wnd_num--; + + temp_reg = (Int) get1bits(pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + if (temp_reg != FALSE) + { + *(pDelay++) = prev_subblock_nonzero; + + for (k = last_band; k > 0; k--) + { + *(pTempPtr++) = TRUE; + } + for (k = (max_sfb - last_band); k > 0; k--) + { + *(pTempPtr++) = FALSE; + } + break; + + } /* if(pWinPredictionUsed) */ + else + { + pDelay++; + pTempPtr += max_sfb; + } + + } + while (wnd_num > 0); + + /* + * This while loop picks up where the previous one left off. + * Notice that the code functions differently inside the loop + */ + + while (wnd_num > 0) + { + temp_reg = (Int) get1bits(pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + if (temp_reg != FALSE) + { + temp_reg = (Int) get1bits(pInputStream); + if (temp_reg != 0) + { + temp_reg = (Int) get9_n_lessbits( + LEN_LTP_SHORT_LAG, + pInputStream); + + *(pDelay++) = prev_subblock - temp_reg; + } + else + { + *(pDelay++) = prev_subblock_nonzero; + } + for (k = last_band; k > 0; k--) + { + *(pTempPtr++) = TRUE; + } + for (k = (max_sfb - last_band); k > 0; k--) + { + *(pTempPtr++) = FALSE; + } + + } /* if (temp_reg) */ + else + { + pDelay++; + pTempPtr += max_sfb; + } + + wnd_num--; + + } /* while(wnd_num) */ + + } /* else (win_type == EIGHT_SHORT_SEQUENCE) */ + +} /* lt_decode */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecodergetmemrequirements.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecodergetmemrequirements.cpp new file mode 100644 index 0000000..340aca7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecodergetmemrequirements.cpp @@ -0,0 +1,119 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecodergetmemrequirements.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: None + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + size = amount of memory needed to be allocated by the calling + environment. + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function returns the amount of internal memory needed by the library. + Presently this is a constant value, but could later be more sophisticated + by taking into account mono or stereo, and whether LTP is to be used. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + +------------------------------------------------------------------------------ + PSEUDO-CODE + + size = sizeof(tDec_Int_File); + + RETURN (size) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +OSCL_EXPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void) +{ + UInt32 size; + + size = (UInt32) sizeof(tDec_Int_File); + + + return (size); + +} /* PVMP4AudioDecoderGetMemRequirements() */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecoderinitlibrary.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecoderinitlibrary.cpp new file mode 100644 index 0000000..6cf770b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecoderinitlibrary.cpp @@ -0,0 +1,369 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecoderinitlibrary.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external application-program interface (API) + structure that a client program uses to communicate information + with this library. Among the items in this structure is a pointer + to the input and output buffers, data for handling the input buffer + and output information. Look in PVMP4AudioDecoder_API.h for all the + fields to this structure. Data type pointer to a + tPVMP4AudioDecoderExternal structure. + + pMem = pointer to allocated memory, of the size returned by the function + PVMP4AudioDecoderGetMemRequirements. This is a void pointer for + two reasons: + 1) So the external program does not need all of the header files + for all of the fields in the structure tDec_Int_File + 2) To hide data and the implementation of the program. Even knowing + how data is stored can help in reverse engineering software. + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 (SUCCESS). Presently there is no error checking in this + function. + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Initializes the internal memory for the MP4 Audio Decoder library. + Also sets relevant values for the external interface structure, clears + the bit rate, channel count, sampling rate, and number of used buffer + elements. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. +------------------------------------------------------------------------------ + PSEUDO-CODE + + pVars = pMem; + + CALL pv_memset( + to = pVars, + c = 0, + n = sizeof(tDec_Int_File)) + MODIFYING(*pVars = 0) + RETURNING(nothing) + + pVars->current_program = -1 + pVars->mc_info.sampling_rate_idx = Fs_44 + pVars->frameLength = LONG_WINDOW + + + pVars->winmap[ONLY_LONG_SEQUENCE] = &pVars->longFrameInfo; + pVars->winmap[LONG_START_SEQUENCE] = &pVars->longFrameInfo; + pVars->winmap[EIGHT_SHORT_SEQUENCE] = &pVars->shortFrameInfo; + pVars->winmap[LONG_STOP_SEQUENCE] = &pVars->longFrameInfo; + + CALL infoinit( + samp_rate_indx = pVars->mc_info.sampling_rate_idx, + ppWin_seq_info = pVars->winmap, + pSfbwidth128 = pVars->SFBWidth128) + MODIFYING(ppWinSeq_info) + MODIFYING(pSfbwidth128) + RETURNING(nothing) + + pExt->bitRate = 0; + pExt->encodedChannels = 0; + pExt->samplingRate = 0; + pExt->inputBufferUsedLength = 0; + + MODIFY(pExt) + MODIFY(pMem) + RETURN(SUCCESS) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "e_progconfigconst.h" + +#include "huffman.h" /* For the definition of infoinit */ +#include "aac_mem_funcs.h" /* For pv_memset */ +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ +#include "s_tdec_int_chan.h" +#include "sfb.h" /* samp_rate_info[] is declared here */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +OSCL_EXPORT_REF Int PVMP4AudioDecoderInitLibrary( + tPVMP4AudioDecoderExternal *pExt, + void *pMem) +{ + tDec_Int_File *pVars; + + pVars = (tDec_Int_File *)pMem; + + /* + * Initialize all memory. The pointers to channel memory will be + * set to zero also. + */ + pv_memset( + pVars, + 0, + sizeof(tDec_Int_File)); + + /* + * Pick default values for the library. + */ + pVars->perChan[0].fxpCoef = pVars->fxpCoef[0]; + pVars->perChan[1].fxpCoef = pVars->fxpCoef[1]; + + /* Here, the "shared memory" pointer is set to point + * at the 1024th element of fxpCoef, because those spaces + * in memory are not used until the filterbank is called. + * + * Therefore, any variables that are only used before + * the filterbank can occupy this same space in memory. + */ + + pVars->perChan[0].pShareWfxpCoef = (per_chan_share_w_fxpCoef *) + & (pVars->perChan[0].fxpCoef[1024]); + + pVars->perChan[1].pShareWfxpCoef = (per_chan_share_w_fxpCoef *) + & (pVars->perChan[1].fxpCoef[1024]); + + /* + * This next line informs the function get_prog_config that no + * configuration has been found thus far, so it is a default + * configuration. + */ + + pVars->current_program = -1; + pVars->mc_info.sampling_rate_idx = Fs_44; /* Fs_44 = 4, 44.1kHz */ + + pVars->mc_info.ch_info[0].tag = 0; + + pVars->parameters_acquired = false; + + + /* + * In the future, the frame length will change with MP4 file format. + * Presently this variable is used to simply the unit test for + * the function PVMP4AudioDecodeFrame() .. otherwise the test would + * have to pass around 1024 length arrays. + */ + pVars->frameLength = LONG_WINDOW; /* 1024*/ + + /* + * The window types ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE, and + * LONG_STOP_SEQUENCE share the same information. The only difference + * between the windows is accounted for in the "filterbank", in + * the function trans4m_freq_2_time_fxp() + */ + + pVars->winmap[ONLY_LONG_SEQUENCE] /* 0 */ = &pVars->longFrameInfo; + pVars->winmap[LONG_START_SEQUENCE] /* 1 */ = &pVars->longFrameInfo; + pVars->winmap[EIGHT_SHORT_SEQUENCE] /* 2 */ = &pVars->shortFrameInfo; + pVars->winmap[LONG_STOP_SEQUENCE] /* 3 */ = &pVars->longFrameInfo; + + infoinit( + pVars->mc_info.sampling_rate_idx, + (FrameInfo **)pVars->winmap, + pVars->SFBWidth128); + + + /* + * Clear out external output values. These values are set later at the end + * of PVMP4AudioDecodeFrames() + */ + pExt->bitRate = 0; + pExt->encodedChannels = 0; + pExt->samplingRate = 0; + pExt->aacPlusUpsamplingFactor = 1; /* Default for regular AAC */ + pVars->aacPlusEnabled = pExt->aacPlusEnabled; + + + pVars->multichannel_detected = false; + +#if defined(AAC_PLUS) + pVars->sbrDecoderData.setStreamType = 1; /* Enable Lock for AAC stream type setting */ +#endif + + /* + * Initialize input buffer variable. + */ + + pExt->inputBufferUsedLength = 0; + + + return (MP4AUDEC_SUCCESS); + +} /* PVMP4AudioDecoderInitLibrary */ + + +/* +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external application-program interface (API) + structure that a client program uses to communicate information + with this library. Among the items in this structure is a pointer + to the input and output buffers, data for handling the input buffer + and output information. Look in PVMP4AudioDecoder_API.h for all the + fields to this structure. Data type pointer to a + tPVMP4AudioDecoderExternal structure. + + pMem = pointer to allocated memory, of the size returned by the function + PVMP4AudioDecoderGetMemRequirements. This is a void pointer for + two reasons: + 1) So the external program does not need all of the header files + for all of the fields in the structure tDec_Int_File + 2) To hide data and the implementation of the program. Even knowing + how data is stored can help in reverse engineering software. + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 (SUCCESS). Presently there is no error checking in this + function. + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Disable SBR decoding functionality and set parameters accordingly + +------------------------------------------------------------------------------ + REQUIREMENTS + + +---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +OSCL_EXPORT_REF void PVMP4AudioDecoderDisableAacPlus( + tPVMP4AudioDecoderExternal *pExt, + void *pMem) +{ + tDec_Int_File *pVars; + + pVars = (tDec_Int_File *)pMem; + + if ((pVars->aacPlusEnabled == true) && (pExt->aacPlusEnabled == true)) + { + // disable only when makes sense + pVars->aacPlusEnabled = false; + pExt->aacPlusEnabled = false; + +#if defined(AAC_PLUS) + pVars->mc_info.upsamplingFactor = 1; + pVars->mc_info.psPresentFlag = 0; + pVars->mc_info.sbrPresentFlag = 0; + pVars->prog_config.sampling_rate_idx += 3; + pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED; + pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED; + + + pExt->samplingRate = samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate; + pExt->aacPlusUpsamplingFactor = 1; +#endif + } +} /* PVMP4AudioDecoderDisableAacPlus */ + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/set_mc_info.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/set_mc_info.cpp new file mode 100644 index 0000000..af08d3f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/set_mc_info.cpp @@ -0,0 +1,278 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: set_mc_info.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pMC_Info = pointer to structure MC_Info that holds information of + multiple channels' configurations + Data type pointer to MC_Info + + objectType = variable that holds the Audio Object Type of current + file/bitstream. + Data type Int + + sampling_rate_idx = variable that indicates the sampling rate of the + source file being encoded + Data Type Int + + tag = variable that stores the element instance tag of the + first (front) channel element. + Data type Int + + is_cpe = variable that indicates if a Channel Pair Element (CPE) + or a Single Channel Element (SCE) is used. + Data type Int (maybe Boolean) + + pWinSeqInfo = array of pointers that points to structures holding + frame information of long and short window sequences. + Data type FrameInfo + + pSfbwidth128 = array that will store the scalefactor bandwidth of + short window sequence frame. + Data type Int array + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + return SUCCESS + + Pointers and Buffers Modified: + pMC_Info->nch contains the number of channels depending + upon if CPE or SCE is used + pMC_Info->objectType contents updated with the decoded Audio + Object Type + + pMC_Info->ch_info.tag contents updated with the value of decoded + channel element tag + + PMC_Info->ch_info.cpe contents updated depending upon if CPE or + SCE is used + + pWinSeqInfo contents updated by calling infoinit if + sampling_rate_idx is different from + previous value + + pSfbWidth128 contents updated by calling infoinit if + sampling_rate_idx is different from + previous value + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function initializes the channel configuration information. The + structure MC_Info stores the number of channels, channel element tag. + If sampling rate index is different from the previous value, + The frame information will be updated by calling infoinit.c + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall update the relevant information on channel configs + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 1 p20 Table 1.6.3 + Subpart 4 p30 5.1.2.1 + Subpart 4 p31 4.5.2.1.1 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pMC_Info->nch = 0; + + pMC_Info->profile = objectType; + + IF (pMC_Info->sampling_rate_idx != sampling_rate_idx) + THEN + pMC_Info->sampling_rate_idx = sampling_rate_idx; + + CALL infoinit( + samp_rate_idx = sampling_rate_idx + ppWin_seq_info= pWinSeqInfo + pSfbwidth128 = pSfbwidth128) + MODIFYING(pWinSeqInfo, pSfbwidth128) + RETURNING(None) + ENDIF + + pCh_Info = &pMC_Info->ch_info[0]; + pCh_Info->tag = tag; + + IF (is_cpe == FALSE) + THEN + pCh_Info->cpe = FALSE; + + pMC_Info->nch = 1; + + ELSE + pCh_Info->cpe = TRUE; + pCh_Info = &pMC_Info->ch_info[1]; + pCh_Info->tag = tag; + pCh_Info->cpe = TRUE; + + pMC_Info->nch = 2; + + ENDIF + + RETURN(SUCCESS) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "set_mc_info.h" +#include "huffman.h" +#include "s_ch_info.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int set_mc_info( + MC_Info *pMC_Info, + const tMP4AudioObjectType audioObjectType, /* used to be profile */ + const Int sampling_rate_idx, + const Int tag, /* always pass-in last element's value */ + const Int is_cpe, + FrameInfo *pWinSeqInfo[], + Int sfbwidth128[] +) +{ + Ch_Info *pCh_Info; /*optional task: eliminate this structure */ + + /* + * audioObjectType and sampling rate + * re-configure if new sampling rate + * + */ + pMC_Info->audioObjectType = audioObjectType; + + if (pMC_Info->sampling_rate_idx != sampling_rate_idx) + { + pMC_Info->sampling_rate_idx = sampling_rate_idx; + + Int status; + status = infoinit(sampling_rate_idx, + pWinSeqInfo, + sfbwidth128); + if (SUCCESS != status) + { + return 1; + } + } + + /* + * first setup values for mono config, Single Channel Element (SCE) + * then if stereo, go inside if(is_cpe != FALSE) branch to setup + * values for stereo. + * set the channel counts + * save tag for left channel + */ + pMC_Info->nch = 1 + is_cpe; + + pCh_Info = &pMC_Info->ch_info[0]; + pCh_Info->tag = tag; + pCh_Info->cpe = is_cpe; + + /* This if branch maybe deleted in the future */ + if (is_cpe != FALSE) + { + /* Channel Pair Element (CPE) */ + /* right channel*/ + pCh_Info = &pMC_Info->ch_info[1]; + pCh_Info->cpe = TRUE; + + } + + + return(SUCCESS); /* possible future error checkings */ +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/sfb.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/sfb.cpp new file mode 100644 index 0000000..6a0cff0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/sfb.cpp @@ -0,0 +1,234 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sfb.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function defines the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + Subpart 4 p66 (sfb tables) + p111 (4.6.10) + p200 (Annex 4.B.5) + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "sfb.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const Int16 sfb_96_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 96, 108, 120, + 132, 144, 156, 172, 188, 212, 240, + 276, 320, 384, 448, 512, 576, 640, + 704, 768, 832, 896, 960, 1024 +}; /* 41 scfbands */ + +const Int16 sfb_64_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 100, 112, 124, + 140, 156, 172, 192, 216, 240, 268, + 304, 344, 384, 424, 464, 504, 544, + 584, 624, 664, 704, 744, 784, 824, + 864, 904, 944, 984, 1024 +}; /* 41 scfbands 47 */ + +const Int16 sfb_64_128[] = +{ + 4, 8, 12, 16, 20, 24, 32, + 40, 48, 64, 92, 128 +}; /* 12 scfbands */ + + +const Int16 sfb_48_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 48, 56, 64, 72, + 80, 88, 96, 108, 120, 132, 144, + 160, 176, 196, 216, 240, 264, 292, + 320, 352, 384, 416, 448, 480, 512, + 544, 576, 608, 640, 672, 704, 736, + 768, 800, 832, 864, 896, 928, 1024 +}; +/* 49 scfbands*/ + +const Int16 sfb_48_128[] = +{ + 4, 8, 12, 16, 20, 28, 36, + 44, 56, 68, 80, 96, 112, 128 +}; /* 14 scfbands */ + +const Int16 sfb_32_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 48, 56, 64, 72, + 80, 88, 96, 108, 120, 132, 144, + 160, 176, 196, 216, 240, 264, 292, + 320, 352, 384, 416, 448, 480, 512, + 544, 576, 608, 640, 672, 704, 736, + 768, 800, 832, 864, 896, 928, 960, + 992, 1024 +}; /* 51 scfbands */ + +const Int16 sfb_24_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 52, 60, 68, + 76, 84, 92, 100, 108, 116, 124, + 136, 148, 160, 172, 188, 204, 220, + 240, 260, 284, 308, 336, 364, 396, + 432, 468, 508, 552, 600, 652, 704, + 768, 832, 896, 960, 1024 +}; /* 47 scfbands */ + +const Int16 sfb_24_128[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 36, 44, 52, 64, 76, 92, 108, + 128 +}; /* 15 scfbands */ + +const Int16 sfb_16_1024[] = +{ + 8, 16, 24, 32, 40, 48, 56, + 64, 72, 80, 88, 100, 112, 124, + 136, 148, 160, 172, 184, 196, 212, + 228, 244, 260, 280, 300, 320, 344, + 368, 396, 424, 456, 492, 532, 572, + 616, 664, 716, 772, 832, 896, 960, + 1024 +}; /* 43 scfbands */ + +const Int16 sfb_16_128[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 40, 48, 60, 72, 88, 108, + 128 +}; /* 15 scfbands */ + +const Int16 sfb_8_1024[] = +{ + 12, 24, 36, 48, 60, 72, 84, + 96, 108, 120, 132, 144, 156, 172, + 188, 204, 220, 236, 252, 268, 288, + 308, 328, 348, 372, 396, 420, 448, + 476, 508, 544, 580, 620, 664, 712, + 764, 820, 880, 944, 1024 +}; /* 40 scfbands */ + +const Int16 sfb_8_128[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 36, 44, 52, 60, 72, 88, 108, + 128 +}; /* 15 scfbands */ + +const SR_Info samp_rate_info[12] = +{ + /* sampling_frequency, #long sfb, #short sfb */ + /* samp_rate, nsfb1024, nsfb128 */ + {96000, 41, 12}, /* 96000 */ + {88200, 41, 12}, /* 88200 */ + {64000, 47, 12}, /* 64000 */ + {48000, 49, 14}, /* 48000 */ + {44100, 49, 14}, /* 44100 */ + {32000, 51, 14}, /* 32000 */ + {24000, 47, 15}, /* 24000 */ + {22050, 47, 15}, /* 22050 */ + {16000, 43, 15}, /* 16000 */ + {12000, 43, 15}, /* 12000 */ + {11025, 43, 15}, /* 11025 */ + { 8000, 40, 15}, /* 8000 */ +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/patent_disclaimer.txt b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/patent_disclaimer.txt new file mode 100644 index 0000000..b4bf11d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/aac/patent_disclaimer.txt @@ -0,0 +1,9 @@ + +THIS IS NOT A GRANT OF PATENT RIGHTS. + +Google makes no representation or warranty that the codecs for which +source code is made available hereunder are unencumbered by +third-party patents. Those intending to use this source code in +hardware or software products are advised that implementations of +these codecs, including in open source software or shareware, may +require patent licenses from the relevant patent holders. diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/Android.mk new file mode 100644 index 0000000..f618e40 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/Android.mk @@ -0,0 +1,66 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/pvmp3_normalize.cpp \ + src/pvmp3_alias_reduction.cpp \ + src/pvmp3_crc.cpp \ + src/pvmp3_decode_header.cpp \ + src/pvmp3_decode_huff_cw.cpp \ + src/pvmp3_decoder.cpp \ + src/pvmp3_getbits.cpp \ + src/pvmp3_dequantize_sample.cpp \ + src/pvmp3_framedecoder.cpp \ + src/pvmp3_get_main_data_size.cpp \ + src/pvmp3_get_side_info.cpp \ + src/pvmp3_get_scale_factors.cpp \ + src/pvmp3_mpeg2_get_scale_data.cpp \ + src/pvmp3_mpeg2_get_scale_factors.cpp \ + src/pvmp3_mpeg2_stereo_proc.cpp \ + src/pvmp3_huffman_decoding.cpp \ + src/pvmp3_huffman_parsing.cpp \ + src/pvmp3_tables.cpp \ + src/pvmp3_imdct_synth.cpp \ + src/pvmp3_mdct_6.cpp \ + src/pvmp3_dct_6.cpp \ + src/pvmp3_poly_phase_synthesis.cpp \ + src/pvmp3_equalizer.cpp \ + src/pvmp3_seek_synch.cpp \ + src/pvmp3_stereo_proc.cpp \ + src/pvmp3_reorder.cpp \ + src/pvmp3_polyphase_filter_window.cpp \ + src/pvmp3_mdct_18.cpp \ + src/pvmp3_dct_9.cpp \ + src/pvmp3_dct_16.cpp + +ifeq ($(TARGET_ARCH),arm) +LOCAL_SRC_FILES += \ + src/asm/pvmp3_polyphase_filter_window_gcc.s \ + src/asm/pvmp3_mdct_18_gcc.s \ + src/asm/pvmp3_dct_9_gcc.s \ + src/asm/pvmp3_dct_16_gcc.s +endif + + +LOCAL_MODULE := libpvmp3 + +LOCAL_CFLAGS := $(PV_CFLAGS) +LOCAL_ARM_MODE := arm + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/codecs_v2/audio/mp3/dec/src \ + $(PV_TOP)/codecs_v2/audio/mp3/dec/include \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + include/pvmp3_decoder.h \ + include/pvmp3decoder_api.h \ + include/pvmp3_audio_type_defs.h + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/build/make/local.mk new file mode 100644 index 0000000..e93ea54 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/build/make/local.mk @@ -0,0 +1,52 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + +TARGET := pvmp3 + + +OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true + +SRCDIR := ../../src +INCSRCDIR := ../../include + + +SRCS := pvmp3_normalize.cpp \ + pvmp3_alias_reduction.cpp \ + pvmp3_crc.cpp \ + pvmp3_decode_header.cpp \ + pvmp3_decode_huff_cw.cpp \ + pvmp3_decoder.cpp \ + pvmp3_getbits.cpp \ + pvmp3_dequantize_sample.cpp \ + pvmp3_framedecoder.cpp \ + pvmp3_get_main_data_size.cpp \ + pvmp3_get_side_info.cpp \ + pvmp3_get_scale_factors.cpp \ + pvmp3_mpeg2_get_scale_data.cpp \ + pvmp3_mpeg2_get_scale_factors.cpp \ + pvmp3_mpeg2_stereo_proc.cpp \ + pvmp3_huffman_decoding.cpp \ + pvmp3_huffman_parsing.cpp \ + pvmp3_tables.cpp \ + pvmp3_imdct_synth.cpp \ + pvmp3_mdct_6.cpp \ + pvmp3_dct_6.cpp \ + pvmp3_poly_phase_synthesis.cpp \ + pvmp3_equalizer.cpp \ + pvmp3_seek_synch.cpp \ + pvmp3_stereo_proc.cpp \ + pvmp3_reorder.cpp \ + pvmp3_polyphase_filter_window.cpp \ + pvmp3_mdct_18.cpp \ + pvmp3_dct_9.cpp \ + pvmp3_dct_16.cpp + + +HDRS := pvmp3_decoder.h pvmp3decoder_api.h pvmp3_audio_type_defs.h + +include $(MK)/library.mk + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/build/make/make_g++_arm.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/build/make/make_g++_arm.mk new file mode 100644 index 0000000..9c36100 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/build/make/make_g++_arm.mk @@ -0,0 +1,19 @@ +# Additional assembly files for linux-arm +ifeq ($(GLOBAL_CPU_ARCH_VERSION),0) + ASM_INCLUSION:=0 +else ifeq ($(GLOBAL_CPU_ARCH_VERSION),1) + ASM_INCLUSION:=0 +else ifeq ($(GLOBAL_CPU_ARCH_VERSION),2) + ASM_INCLUSION:=0 +else ifeq ($(GLOBAL_CPU_ARCH_VERSION),3) + ASM_INCLUSION:=0 +else + ASM_INCLUSION:=1 +endif + +ifneq ($(ASM_INCLUSION),0) +SRCS+= asm/pvmp3_polyphase_filter_window_gcc.s \ + asm/pvmp3_mdct_18_gcc.s \ + asm/pvmp3_dct_9_gcc.s \ + asm/pvmp3_dct_16_gcc.s +endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/mp3_decoder_selection.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/mp3_decoder_selection.h new file mode 100644 index 0000000..e287433 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/mp3_decoder_selection.h @@ -0,0 +1,30 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \file mp3_decoder_selection.h + * \brief select mp3 decoder + * + */ + +#ifndef MP3_DECODER_SELECTION_H +#define MP3_DECODER_SELECTION_H + + +#define NEW_PV_MP3_DECODER 1 // 1 == PV mp3 decoder + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/pvmp3_audio_type_defs.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/pvmp3_audio_type_defs.h new file mode 100644 index 0000000..8414a93 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/pvmp3_audio_type_defs.h @@ -0,0 +1,181 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_audio_type_defs.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file was derived from a number of standards bodies. The type + definitions below were created from some of the best practices observed + in the standards bodies. + + This file is dependent on limits.h for defining the bit widths. In an + ANSI C environment limits.h is expected to always be present and contain + the following definitions: + + SCHAR_MIN + SCHAR_MAX + UCHAR_MAX + + INT_MAX + INT_MIN + UINT_MAX + + SHRT_MIN + SHRT_MAX + USHRT_MAX + + LONG_MIN + LONG_MAX + ULONG_MAX + +------------------------------------------------------------------------------ +*/ + +#ifndef PVMP3_AUDIO_TYPE_DEFS_H +#define PVMP3_AUDIO_TYPE_DEFS_H + +#include "oscl_base.h" + + +#ifndef Char +typedef int8 Char; +#endif + +#ifndef UChar +typedef uint8 UChar; +#endif + + + +/*---------------------------------------------------------------------------- +; Define generic signed and unsigned int +----------------------------------------------------------------------------*/ +#ifndef Int +typedef signed int Int; +#endif + +#ifndef UInt +typedef unsigned int UInt; +#endif + + +/*---------------------------------------------------------------------------- +; Define 16 bit signed and unsigned words +----------------------------------------------------------------------------*/ + + +#ifndef Int16 +typedef int16 Int16; +#endif + +#ifndef INT16_MIN +#define INT16_MIN (-32768) +#endif + +#ifndef INT16_MAX +#define INT16_MAX 32767 +#endif + +#ifndef UInt16 +typedef uint16 UInt16; + +#endif + + +/*---------------------------------------------------------------------------- +; Define 32 bit signed and unsigned words +----------------------------------------------------------------------------*/ + + +#ifndef Int32 +typedef int32 Int32; +#endif + +#ifndef INT32_MIN +#define INT32_MIN (-2147483647 - 1) +#endif +#ifndef INT32_MAX +#define INT32_MAX 2147483647 +#endif + +#ifndef UInt32 +typedef uint32 UInt32; +#endif + +#ifndef UINT32_MIN +#define UINT32_MIN 0 +#endif +#ifndef UINT32_MAX +#define UINT32_MAX 0xffffffff +#endif + + +#ifndef INT_MAX +#define INT_MAX INT32_MAX /* for 32 bit */ +#endif + +/*---------------------------------------------------------------------------- +; Define 64 bit signed and unsigned words +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; Define boolean type +----------------------------------------------------------------------------*/ +#ifndef Bool +typedef int Bool; +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef OFF +#define OFF 0 +#endif +#ifndef ON +#define ON 1 +#endif + +#ifndef NO +#define NO 0 +#endif +#ifndef YES +#define YES 1 +#endif + +#ifndef SUCCESS +#define SUCCESS 0 +#endif + + +#ifndef NULL +#define NULL 0 +#endif + + +#endif /* PVMP3_AUDIO_TYPE_DEFS_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/pvmp3_decoder.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/pvmp3_decoder.h new file mode 100644 index 0000000..34ae399 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/pvmp3_decoder.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \file pvmp3_decoder.h + * \brief Header file for the MP3 decoder library + * + */ + +#ifndef PVMP3_DECODER_H +#define PVMP3_DECODER_H + + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#include "pvmp3decoder_api.h" +#include "oscl_base.h" + + +/*! + * \brief number of samples per frame (decoded frames) + */ + + +#define KMP3_MAX_OUTPUT_SIZE 4608 + +/*! + * \class CPvMP3_Decoder "include/pvmp3_decoder.h" + * \brief MP3 Decoder class + */ + + +// CPvMP3_Decoder + +/*! + * \class CPvMP3_Decoder + * \brief MP3 Decoder class + */ + + +// CPvMP3_Decoder +class CPvMP3_Decoder +{ + public: + OSCL_IMPORT_REF void ConstructL(); + OSCL_IMPORT_REF static CPvMP3_Decoder *NewL(); + OSCL_IMPORT_REF ~CPvMP3_Decoder(); + + OSCL_IMPORT_REF int32 StartL(tPVMP3DecoderExternal * pExt, + bool aAllocateInputBuffer = false, + bool aAllocateOutputBuffer = false, + bool crcEnabler = false, + e_equalization equalizType = flat + ); + OSCL_IMPORT_REF int32 ExecuteL(tPVMP3DecoderExternal * pExt); + OSCL_IMPORT_REF void ResetDecoderL(); + OSCL_IMPORT_REF void StopL(); + + OSCL_IMPORT_REF void TerminateDecoderL(); + OSCL_IMPORT_REF int32 SeekMp3Synchronization(tPVMP3DecoderExternal * pExt); + + + + private: + bool iAllocateInputBuffer; + bool iAllocateOutputBuffer; + + uint8 *pMem; + + uint8* iInputBuf; + int16* iOutputBuf; +}; + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/pvmp3decoder_api.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/pvmp3decoder_api.h new file mode 100644 index 0000000..6c4c09a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/include/pvmp3decoder_api.h @@ -0,0 +1,234 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3decoder_api.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure tPVMP3DecoderExternal + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3DECODER_API_H +#define PVMP3DECODER_API_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + typedef enum + { + flat = 0, + bass_boost = 1, + rock = 2, + pop = 3, + jazz = 4, + classical = 5, + talk = 6, + flat_ = 7 + + } e_equalization; + + + + typedef enum + { + MP3DEC_SUCCESS = 0, + MP3DEC_INVALID_FRAME = 1, + MP3DEC_INCOMPLETE_FRAME = 2, + MP3DEC_LOST_FRAME_SYNC = 4, + MP3DEC_OUTPUT_BUFFER_TOO_SMALL = 8 + } tPVMP3DecoderErrorCode; + + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + typedef struct +#ifdef __cplusplus + tPVMP3DecoderExternal +#endif + { + + /* + * INPUT: + * Pointer to the input buffer that contains the encoded bistream data. + * The data is filled in such that the first bit transmitted is + * the most-significant bit (MSB) of the first array element. + * The buffer is accessed in a linear fashion for speed, and the number of + * bytes consumed varies frame to frame. + * The calling environment can change what is pointed to between calls to + * the decode function, library, as long as the inputBufferCurrentLength, + * and inputBufferUsedLength are updated too. Also, any remaining bits in + * the old buffer must be put at the beginning of the new buffer. + */ + uint8 *pInputBuffer; + + /* + * INPUT: + * Number of valid bytes in the input buffer, set by the calling + * function. After decoding the bitstream the library checks to + * see if it when past this value; it would be to prohibitive to + * check after every read operation. This value is not modified by + * the MP3 library. + */ + int32 inputBufferCurrentLength; + + /* + * INPUT/OUTPUT: + * Number of elements used by the library, initially set to zero by + * the function pvmp3_resetDecoder(), and modified by each + * call to pvmp3_framedecoder(). + */ + int32 inputBufferUsedLength; + + /* + * OUTPUT: + * holds the predicted frame size. It used on the test console, for parsing + * purposes. + */ + uint32 CurrentFrameLength; + + /* + * INPUT: + * This variable holds the type of equalization used + * + * + */ + e_equalization equalizerType; + + + /* + * INPUT: + * The actual size of the buffer. + * This variable is not used by the library, but is used by the + * console test application. This parameter could be deleted + * if this value was passed into these function. + */ + int32 inputBufferMaxLength; + + /* + * OUTPUT: + * The number of channels decoded from the bitstream. + */ + int16 num_channels; + + /* + * OUTPUT: + * The number of channels decoded from the bitstream. + */ + int16 version; + + /* + * OUTPUT: + * The sampling rate decoded from the bitstream, in units of + * samples/second. + */ + int32 samplingRate; + + /* + * OUTPUT: + * This value is the bitrate in units of bits/second. IT + * is calculated using the number of bits consumed for the current frame, + * and then multiplying by the sampling_rate, divided by points in a frame. + * This value can changes frame to frame. + */ + int32 bitRate; + + /* + * INPUT/OUTPUT: + * In: Inform decoder how much more room is available in the output buffer in int16 samples + * Out: Size of the output frame in 16-bit words, This value depends on the mp3 version + */ + int32 outputFrameSize; + + /* + * INPUT: + * Flag to enable/disable crc error checking + */ + int32 crcEnabled; + + /* + * OUTPUT: + * This value is used to accumulate bit processed and compute an estimate of the + * bitrate. For debugging purposes only, as it will overflow for very long clips + */ + uint32 totalNumberOfBitsUsed; + + + /* + * INPUT: (but what is pointed to is an output) + * Pointer to the output buffer to hold the 16-bit PCM audio samples. + * If the output is stereo, both left and right channels will be stored + * in this one buffer. + */ + + int16 *pOutputBuffer; + + } tPVMP3DecoderExternal; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_16_gcc.s b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_16_gcc.s new file mode 100644 index 0000000..e61c8d3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_16_gcc.s @@ -0,0 +1,476 @@ +@ ------------------------------------------------------------------ +@ Copyright (C) 1998-2009 PacketVideo +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ http://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +@ express or implied. +@ See the License for the specific language governing permissions +@ and limitations under the License. +@ ------------------------------------------------------------------- + +@ +@ +@ Filename: pvmp3_dct_16_gcc.s +@ +@ +@------------------------------------------------------------------------------ +@ REVISION HISTORY +@ +@ +@ Who: Date: MM/DD/YYYY +@ Description: +@ +@------------------------------------------------------------------------------ + +.arm + +.align 4 + +.text + +.extern pvmp3_dct_16 +.extern pvmp3_merge_in_place_N32 +.extern pvmp3_split + + + +@------------------------------------------------------------------------------ + +.global pvmp3_dct_16 + +pvmp3_dct_16: + stmfd sp!,{r0,r1,r4-r11,lr} + ldr r1,[r0] + ldr r3,[r0,#0x3c] + ldr r12,constant1 + sub r2,r1,r3 + smull lr,r2,r12,r2 + sub sp,sp,#0x1c + str r2,[sp,#0x14] + ldr r2,[r0,#0x1c] + ldr r12,[r0,#0x20] + add r1,r1,r3 + sub r3,r2,r12 + ldr lr,constant2 + mov r3,r3,lsl #3 + smull r4,r3,lr,r3 + ldr r6,constant5 + str r3,[sp] + add r3,r2,r12 + sub r2,r1,r3 + ldr r12,constant3 + add r3,r1,r3 + smull lr,r2,r12,r2 + ldr r12,[r0,#0x38] + ldr r1,[r0,#4] + ldr lr,constant4 + sub r4,r1,r12 + add r1,r1,r12 + ldr r12,[r0,#0x18] + smull r4,r5,lr,r4 + ldr lr,[r0,#0x24] + ldr r10,constant10 + sub r4,r12,lr + mov r4,r4,lsl #1 + smull r7,r4,r6,r4 + add r12,r12,lr + add r7,r1,r12 + sub r12,r1,r12 + ldr r1,constant6 + str r4,[sp,#4] + smull r12,r4,r1,r12 + ldr r1,[r0,#8] + ldr r12,[r0,#0x34] + ldr r6,constant7 + sub lr,r1,r12 + smull r8,lr,r6,lr + add r1,r1,r12 + str lr,[sp,#0x10] + ldr r12,[r0,#0x14] + ldr lr,[r0,#0x28] + ldr r8,constant8 + sub r6,r12,lr + mov r6,r6,lsl #1 + smull r9,r6,r8,r6 + add r12,r12,lr + ldr r9,constant9 + add r8,r1,r12 + sub r12,r1,r12 + smull r12,lr,r9,r12 + ldr r12,[r0,#0x30] + ldr r1,[r0,#0xc] + sub r9,r1,r12 + smull r11,r9,r10,r9 + add r12,r1,r12 + str r9,[sp,#0xc] + ldr r9,[r0,#0x10] + ldr r10,constant11 + str r9,[sp,#0x18] + ldr r1,[r0,#0x2c] + sub r9,r9,r1 + smull r11,r9,r10,r9 + ldr r10,constant12 + str r9,[sp,#8] + ldr r9,[sp,#0x18] + ldr r11,constant14 + add r9,r9,r1 + add r1,r12,r9 + sub r12,r12,r9 + mov r12,r12,lsl #2 + smull r9,r12,r10,r12 + ldr r10,constant13 + add r9,r3,r1 + sub r1,r3,r1 + smull r1,r3,r10,r1 + sub r1,r7,r8 + mov r1,r1,lsl #1 + smull r1,r10,r11,r1 + add r1,r7,r8 + add r8,r9,r1 + sub r7,r9,r1 + mov r8,r8,asr #1 + ldr r1,constant15 + str r8,[r0] + smull r7,r8,r1,r7 + sub r7,r3,r10 + str r8,[r0,#0x20] + mov r7,r7,lsl #1 + smull r8,r7,r1,r7 + add r3,r3,r10 + add r3,r3,r7 + str r3,[r0,#0x10] + sub r3,r2,r12 + str r7,[r0,#0x30] + add r2,r2,r12 + ldr r7,constant13 + sub r12,r4,lr + mov r3,r3,lsl #1 + smull r8,r3,r7,r3 + add lr,r4,lr + sub r4,r2,lr + mov r12,r12,lsl #2 + smull r7,r12,r11,r12 + add lr,lr,r2 + sub r2,r3,r12 + mov r2,r2,lsl #1 + smull r7,r2,r1,r2 + mov r4,r4,lsl #1 + add r12,r12,r2 + add r3,r12,r3 + smull r7,r4,r1,r4 + add r12,r3,lr + add r3,r3,r4 + str r3,[r0,#0x18] + add r3,r2,r4 + str r2,[r0,#0x38] + str r3,[r0,#0x28] + str r12,[r0,#8] + ldr r2,[sp,#0x14] + ldr r3,[sp,#0] + ldr lr,[sp,#4] + sub r2,r2,r3 + ldr r3,constant3 + mov r2,r2,lsl #1 + smull r12,r2,r3,r2 + ldr r3,[sp,#0x14] + ldr r12,[sp,#0] + ldr r4,constant6 + add r12,r3,r12 + ldr r3,[sp,#4] + sub lr,r5,lr + mov lr,lr,lsl #1 + add r3,r5,r3 + smull r5,lr,r4,lr + ldr r4,[sp,#0x10] + ldr r5,[sp,#0x10] + add r4,r4,r6 + sub r5,r5,r6 + ldr r6,constant9 + mov r5,r5,lsl #1 + smull r7,r5,r6,r5 + ldr r6,[sp,#8] + ldr r9,[sp,#0xc] + ldr r10,constant12 + sub r6,r9,r6 + mov r6,r6,lsl #3 + smull r7,r6,r10,r6 + ldr r8,[sp,#0x20] + ldr r7,[sp,#8] + cmp r8,#0 + add r7,r9,r7 + + bne no_flag_proc + rsb r12,r12,#0 + rsb r2,r2,#0 + rsb r3,r3,#0 + rsb lr,lr,#0 + rsb r4,r4,#0 + rsb r5,r5,#0 + rsb r7,r7,#0 + rsb r6,r6,#0 +no_flag_proc: + + sub r8,r2,r6 + add r2,r6,r2 + sub r6,r12,r7 + ldr r9,constant13 + add r12,r12,r7 + sub r7,r3,r4 + mov r6,r6,lsl #1 + mov r8,r8,lsl #1 + smull r10,r8,r9,r8 + add r3,r3,r4 + smull r10,r6,r9,r6 + sub r4,lr,r5 + mov r7,r7,lsl #2 + smull r9,r7,r11,r7 + add lr,lr,r5 + sub r5,r6,r7 + add r6,r6,r7 + sub r7,r12,r3 + add r3,r12,r3 + sub r12,r2,lr + mov r4,r4,lsl #2 + smull r9,r4,r11,r4 + add lr,r2,lr + sub r2,r8,r4 + mov r2,r2,lsl #1 + mov r5,r5,lsl #1 + mov r12,r12,lsl #1 + mov r7,r7,lsl #1 + smull r9,r5,r1,r5 + smull r9,r2,r1,r2 + add r6,r6,r5 + smull r9,r7,r1,r7 + smull r9,r12,r1,r12 + add r1,r4,r2 + add r1,r1,r8 + add lr,lr,r1 + add r3,r3,lr + str r3,[r0,#4] + add r3,r6,lr + str r3,[r0,#0xc] + add r1,r1,r12 + add r3,r6,r1 + add r1,r7,r1 + str r1,[r0,#0x1c] + str r3,[r0,#0x14] + add r1,r12,r2 + add r3,r7,r1 + add r1,r5,r1 + str r1,[r0,#0x2c] + str r3,[r0,#0x24]! + add r1,r5,r2 + str r1,[r0,#0x10] + str r2,[r0,#0x18] + add sp,sp,#0x24 + ldmfd sp!,{r4-r11,pc} + + + +@------------------------------------------------------------------------------ + +.global pvmp3_merge_in_place_N32 + + + +pvmp3_merge_in_place_N32: + stmfd sp!,{r4,lr} + ldr r1,[r0,#0x1c] + ldr r2,[r0,#0x38] + str r1,[r0,#0x38] + ldr r1,[r0,#0x18] + ldr r3,[r0,#0x30] + str r1,[r0,#0x30] + ldr r12,[r0,#0x14] + ldr r1,[r0,#0x28] + str r12,[r0,#0x28] + ldr r12,[r0,#0x10] + ldr lr,[r0,#0x20] + str r12,[r0,#0x20] + ldr r12,[r0,#0xc] + str r12,[r0,#0x18] + ldr r12,[r0,#8] + str r12,[r0,#0x10] + ldr r12,[r0,#4] + str r12,[r0,#8] + ldr r4,[r0,#0x40] + ldr r12,[r0,#0x44] + add r4,r4,r12 + str r4,[r0,#4] + str lr,[r0,#0x40] + ldr lr,[r0,#0x48] + add r12,lr,r12 + str r12,[r0,#0xc] + ldr r12,[r0,#0x4c] + add lr,r12,lr + str lr,[r0,#0x14] + ldr lr,[r0,#0x24] + str lr,[r0,#0x48] + ldr lr,[r0,#0x50] + add r12,lr,r12 + str r12,[r0,#0x1c] + ldr r12,[r0,#0x54] + str r1,[r0,#0x50] + add lr,r12,lr + str lr,[r0,#0x24] + ldr r1,[r0,#0x58] + ldr r4,[r0,#0x2c] + ldr lr,[r0,#0x34] + add r12,r1,r12 + str r12,[r0,#0x2c] + ldr r12,[r0,#0x5c] + add r1,r12,r1 + str r1,[r0,#0x34] + str r4,[r0,#0x58] + ldr r1,[r0,#0x60] + ldr r4,[r0,#0x3c] + add r12,r1,r12 + str r12,[r0,#0x3c] + ldr r12,[r0,#0x64] + add r1,r12,r1 + str r1,[r0,#0x44] + ldr r1,[r0,#0x68] + add r12,r1,r12 + str r12,[r0,#0x4c] + ldr r12,[r0,#0x6c] + add r1,r12,r1 + str r1,[r0,#0x54] + ldr r1,[r0,#0x70] + str r3,[r0,#0x60] + add r12,r1,r12 + str r12,[r0,#0x5c] + ldr r3,[r0,#0x74] + add r1,r3,r1 + str r1,[r0,#0x64] + str lr,[r0,#0x68] + ldr r1,[r0,#0x78] + str r2,[r0,#0x70] + add r3,r1,r3 + str r3,[r0,#0x6c] + ldr r2,[r0,#0x7c] + add r1,r1,r2 + str r1,[r0,#0x74] + str r4,[r0,#0x78] + ldmfd sp!,{r4,pc} + + +@------------------------------------------------------------------------------ + +.global pvmp3_split + + +pvmp3_split: + stmfd sp!,{r4,r5,lr} + adr r1,constant16 + ldr r2,[r1] + add r2,r1 + sub r1,r0,#4 + mov r3,#3 +loop1: + ldr r12,[r0] + ldr lr,[r1] + ldr r4,[r2],#-4 + add r5,lr,r12 + sub r12,lr,r12 + smull r12,lr,r4,r12 + str r5,[r1],#-4 + mov r12,r12,lsr #27 + add r12,r12,lr,lsl #5 + str r12,[r0],#4 + ldr r12,[r0] + ldr lr,[r1] + ldr r4,[r2],#-4 + add r5,lr,r12 + sub r12,lr,r12 + smull r12,lr,r4,r12 + str r5,[r1],#-4 + mov r12,r12,lsr #27 + add r12,r12,lr,lsl #5 + str r12,[r0],#4 + subs r3,r3,#1 + bne loop1 + mov r3,#5 +loop2: + ldr r12,[r0] + ldr lr,[r1] + ldr r4,[r2],#-4 + add r5,lr,r12 + sub r12,lr,r12 + mov r12,r12,lsl #1 + smull lr,r12,r4,r12 + str r5,[r1],#-4 + str r12,[r0],#4 + ldr r12,[r0] + ldr lr,[r1] + ldr r4,[r2],#-4 + add r5,lr,r12 + sub r12,lr,r12 + mov r12,r12,lsl #1 + smull lr,r12,r4,r12 + str r5,[r1],#-4 + str r12,[r0],#4 + subs r3,r3,#1 + bne loop2 + ldmfd sp!,{r4,r5,pc} +constant1: + .word 0x404f4680 +constant2: + .word 0x519e4e00 +constant3: + .word 0x4140fb80 +constant4: + .word 0x42e13c00 +constant5: + .word 0x6e3c9300 +constant6: + .word 0x4cf8de80 +constant7: + .word 0x48919f80 +constant8: + .word 0x43e22480 +constant9: + .word 0x73326b80 +constant10: + .word 0x52cb0e80 +constant11: + .word 0x64e24000 +constant12: + .word 0x52036780 +constant13: + .word 0x4545ea00 +constant14: + .word 0x539eba80 +constant15: + .word 0x5a827980 +constant16: + .word (CosTable_dct32 + 60)-constant16 + + + +CosTable_dct32: + .word 0x4013c280 + .word 0x40b34580 + .word 0x41fa2d80 + .word 0x43f93400 + .word 0x46cc1c00 + .word 0x4a9d9d00 + .word 0x4fae3700 + .word 0x56601e80 + .word 0x5f4cf700 + .word 0x6b6fcf00 + .word 0x07c7d1d8 + .word 0x095b0350 + .word 0x0bdf91b0 + .word 0x107655e0 + .word 0x1b42c840 + .word 0x51852300 + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_gcc.s b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_gcc.s new file mode 100644 index 0000000..618c50e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_gcc.s @@ -0,0 +1,193 @@ +@ ------------------------------------------------------------------ +@ Copyright (C) 1998-2009 PacketVideo +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ http://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +@ express or implied. +@ See the License for the specific language governing permissions +@ and limitations under the License. +@ ------------------------------------------------------------------- + +@ +@ +@ Filename: pvmp3_dct_9_gcc.s +@ +@------------------------------------------------------------------------------ +@ REVISION HISTORY +@ +@ +@ Who: Date: MM/DD/YYYY +@ Description: +@ +@------------------------------------------------------------------------------ + +.arm + +.align 4 + +.text + + +@------------------------------------------------------------------------------ + +.global pvmp3_dct_9 + +pvmp3_dct_9: + stmfd sp!,{r4-r11,lr} + ldr r2, [r0, #0x20] + ldr r3, [r0, #0] + ldr r12,[r0, #4] + add r1,r2,r3 + sub lr,r2,r3 + ldr r3,[r0, #0x1c] + ldr r4,[r0, #0x18] + add r2,r3,r12 + ldr r5,[r0,#8] + sub r3,r3,r12 + add r12,r4,r5 + sub r4,r4,r5 + ldr r5,[r0, #0x14] + ldr r7,[r0, #0xc] + ldr r9,[r0, #0x10] + add r6,r5,r7 + sub r5,r5,r7 + add r7,r1,r12 + add r8,r9,r2 + add r7,r7,r6 + add r10,r7,r8 + rsb r7,r8,r7,asr #1 + str r7,[r0, #0x18] + rsb r2,r9,r2,asr #1 + str r10,[r0,#0] + ldr r11,cos_2pi_9 + rsb r7,r2,#0 + + ldr r10,cos_4pi_9 + mov r9,r1,lsl #1 + mov r8,r7 + +@ vec[4] = fxp_mac32_Q32( vec[4], tmp0<<1, cos_2pi_9)@ + + smlal r1,r8,r11,r9 + ldr r11,cos_pi_9 + mov r1,r9 @@@@@@ !!!!!! + +@ vec[8] = fxp_mac32_Q32( vec[8], tmp0<<1, cos_4pi_9)@ + + smlal r1,r7,r10,r9 + + mov r1,r12,lsl #1 + + +@ vec[2] = fxp_mac32_Q32( vec[2], tmp0<<1, cos_pi_9)@ + + smlal r9,r2,r11,r9 + rsb r9,r10,#0 + ldr r11,cos_5pi_9 + + smlal r12,r2,r9,r1 + + + +@ vec[2] = fxp_mac32_Q32( vec[2], tmp2<<1, cos_5pi_9)@ + + ldr r9,cos_2pi_9 + mov r12,r1 @@@@@@ !!!!!! + smlal r12,r8,r11,r1 + + +@ vec[8] = fxp_mac32_Q32( vec[8], tmp2<<1, cos_2pi_9)@ + + smlal r1,r7,r9,r1 + mov r1,r6,lsl #1 + smlal r12,r7,r11,r1 + and r6,r10,r11,asr #14 + smlal r12,r8,r6,r1 + ldr r10,cos_11pi_18 + add r12,r11,r6 + smlal r1,r2,r12,r1 + ldr r9,cos_8pi_9 + str r2,[r0,#8] + mov r1,r5,lsl #1 + +@ vec[8] = fxp_mac32_Q32( vec[8], tmp3<<1, cos_8pi_9)@ + + smull r2,r6,r9,r1 + str r7,[r0,#0x20] + mov r2,r4,lsl #1 + ldr r7,cos_13pi_18 + smlal r12,r6,r10,r2 + + mov r3,r3,lsl #1 + +@ vec[5] = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18)@ + + smlal r12,r6,r7,r3 + add r4,r5,r4 + mov r12,lr,lsl #1 + sub lr,r4,lr + ldr r7,cos_17pi_18 + str r8,[r0, #0x10] + ldr r4,cos_pi_6 + + mov lr,lr,lsl #1 + +@ vec[1] = fxp_mac32_Q32( vec[1], tmp8<<1, cos_17pi_18)@ + + smlal r8,r6,r7,r12 + +@ vec[3] = fxp_mul32_Q32((tmp5 + tmp6 - tmp8)<<1, cos_pi_6)@ + + smull r5,lr,r4,lr + str r6,[r0, #4] + str lr,[r0, #0xc] + + +@ vec[5] = fxp_mul32_Q32(tmp5<<1, cos_17pi_18)@ + smull r5,lr,r7,r1 + rsb r6,r9,#0 +@ vec[5] = fxp_mac32_Q32( vec[5], tmp6<<1, cos_7pi_18)@ + smlal r5,lr,r6,r2 +@ vec[5] = fxp_mac32_Q32( vec[5], tmp7<<1, cos_pi_6)@ + smlal r5,lr,r4,r3 +@ vec[5] = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18)@ + smlal r5,lr,r10,r12 + str lr,[r0, #0x14] + rsb lr,r10,#0 + +@ vec[7] = fxp_mul32_Q32(tmp5<<1, cos_5pi_18)@ + smull r5,r1,lr,r1 +@ vec[7] = fxp_mac32_Q32( vec[7], tmp6<<1, cos_17pi_18)@ + smlal r2,r1,r7,r2 +@ vec[7] = fxp_mac32_Q32( vec[7], tmp7<<1, cos_pi_6)@ + smlal r3,r1,r4,r3 +@ vec[7] = fxp_mac32_Q32( vec[7], tmp8<<1, cos_11pi_18)@ + smlal r12,r1,r9,r12 + str r1,[r0, #0x1c] + ldmfd sp!,{r4-r11,pc} +cos_2pi_9: + .word 0x620dbe80 +cos_4pi_9: + .word 0x163a1a80 +cos_pi_9: + .word 0x7847d900 +cos_5pi_9: + .word 0x87b82700 +cos_8pi_9: + .word 0xd438af00 +cos_11pi_18: + .word 0xadb92280 +cos_13pi_18: + .word 0x91261480 +cos_17pi_18: + .word 0x81f1d200 +cos_pi_6: + .word 0x6ed9eb80 + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_gcc.s b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_gcc.s new file mode 100644 index 0000000..575acd6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_gcc.s @@ -0,0 +1,357 @@ +@ ------------------------------------------------------------------ +@ Copyright (C) 1998-2009 PacketVideo +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ http://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +@ express or implied. +@ See the License for the specific language governing permissions +@ and limitations under the License. +@ ------------------------------------------------------------------- + +@ +@ +@ Filename: pvmp3_dct_18_gcc.s +@ +@------------------------------------------------------------------------------ +@ REVISION HISTORY +@ +@ +@ Who: Date: MM/DD/YYYY +@ Description: +@ +@------------------------------------------------------------------------------ + +.arm + +.align 4 + +.text + +.extern pvmp3_dct_9 + +@------------------------------------------------------------------------------ + +.global pvmp3_mdct_18 + +pvmp3_mdct_18: + stmfd sp!,{r4-r11,lr} + mov r7,r2 + adr r2,constdata$1 + mov r6,r1 + add r3,r2,#0x24 + add r12,r3,#0x44 + add r1,r0,#0x44 + mov r5,r0 + +@ for ( i=9@ i!=0@ i--) +@ { + + mov r4,#9 +Loop_1: + +@ tmp = *(pt_vec) +@ tmp1 = *(pt_vec_o) + + ldr lr,[r0] @@ tmp == lr + ldr r8,[r3],#4 @@ tmp1 == r8 + +@ tmp = fxp_mul32_Q32( tmp<<1, *(pt_cos++ )) +@ tmp1 = fxp_mul32_Q27( tmp1, *(pt_cos_x--)) + + mov lr,lr,lsl #1 + smull r10,lr,r8,lr + ldr r8,[r12],#-4 + ldr r9,[r1] + subs r4,r4,#1 + smull r9,r10,r8,r9 + mov r8,r9,lsr #27 + add r8,r8,r10,lsl #5 + +@ *(pt_vec++) = tmp + tmp1 +@ *(pt_vec_o--) = fxp_mul32_Q28( (tmp - tmp1), *(pt_cos_split++)) + + add r9,lr,r8 + sub r8,lr,r8 + ldr lr,[r2],#4 + str r9,[r0],#4 + smull r8,r9,lr,r8 + mov lr,r8,lsr #28 + add lr,lr,r9,lsl #4 + str lr,[r1],#-4 + bne Loop_1 + +@ } + + mov r0,r5 @@ r0 = vec + bl pvmp3_dct_9 + add r0,r5,#0x24 @@ r0 = &vec[9] + bl pvmp3_dct_9 + + ldr r0,[r5,#0x20] + ldr r2,[r5,#0x40] + str r0,[r5,#0x40] + ldr r0,[r5,#0x1c] + ldr r3,[r5,#0x38] + str r0,[r5,#0x38] + ldr r1,[r5,#0x18] + ldr r0,[r5,#0x30] + str r1,[r5,#0x30] + ldr r12,[r5,#0x14] + ldr r1,[r5,#0x28] + str r12,[r5,#0x28] + ldr r12,[r5,#0x10] + str r12,[r5,#0x20] + ldr r12,[r5,#0xc] + str r12,[r5,#0x18] + ldr r12,[r5,#8] + str r12,[r5,#0x10] + ldr r12,[r5,#4] + str r12,[r5,#8] + ldr r12,[r5,#0x24] + sub r12,r12,r1 + str r12,[r5,#4] + ldr r12,[r5,#0x2c] + sub r1,r12,r1 + str r1,[r5,#0xc] + sub r1,r12,r0 + str r1,[r5,#0x14] + ldr r1,[r5,#0x34] + sub r0,r1,r0 + str r0,[r5,#0x1c] + sub r0,r1,r3 + str r0,[r5,#0x24] + ldr r1,[r5,#0x3c] + sub r3,r1,r3 + sub r1,r1,r2 + str r1,[r5,#0x34] + str r3,[r5,#0x2c] + ldr r1,[r5,#0x44] + sub r1,r1,r2 + str r1,[r5,#0x3c] + ldr r12,[r5,#0] + +Loop_2: + add r1,r5,r4,lsl #2 + ldr r2,[r1,#0x28] + ldr r3,[r6,r4,lsl #2] + add r0,r0,r2 + str r0,[r1,#0x28] + ldr lr,[r7,r4,lsl #2] + ldr r1,[r1,#4] + smlal r0,r3,lr,r0 + mov r0,r2 + add r2,r12,r1 + rsb r2,r2,#0 + str r3,[r5,r4,lsl #2] + str r2,[r6,r4,lsl #2] + add r4,r4,#1 + cmp r4,#6 + mov r12,r1 + + blt Loop_2 + + ldr r1,[r5,#0x40] + ldr r2,[r6,#0x18] + add r3,r0,r1 + str r3,[r5,#0x40] + ldr lr,[r7,r4,lsl #2] + mov r3,r3,lsl #1 + ldr r0,[r5,#0x1c] + smlal r3,r2,lr,r3 + add r3,r12,r0 + str r2,[r5,#0x18] + ldr r2,[r6,#0x1c] + rsb r3,r3,#0 + str r3,[r6,#0x18] + ldr r3,[r5,#0x20] + add r0,r3,r0 + rsb r0,r0,#0 + str r0,[r6,#0x1c] + ldr r3,[r5,#0x44] + ldr r0,[r6,#0x20] + add r3,r3,r1 + mov r1,r2 + ldr r10,[r7,#0x1c] + mov r2,r3,lsl #1 + smlal r12,r1,r10,r2 + str r1,[r5,#0x1c] + ldr r1,[r5,#0x20] + ldr r3,[r5,#0x24] + add r1,r1,r3 + rsb r1,r1,#0 + str r1,[r6,#0x20] + ldr r1,[r5,#0x44] + ldr r3,[r7,#0x20] + mov r1,r1,lsl #1 + smlal r12,r0,r3,r1 + ldr lr,[r7,#0x24] + ldr r3,[r6,#0x24] + str r0,[r5,#0x20] + smlal r1,r3,lr,r1 + ldr r0,[r6,#0x40] + ldr r12,[r6,#0x44] + str r3,[r5,#0x24] + ldr r1,[r5,#0x28] + ldr r3,[r7,#0x44] + mov r1,r1,lsl #1 + smlal r1,r12,r3,r1 + ldr r1,[r5,#0x40] + str r12,[r5,#0x44] + rsb r8,r1,#0 + str r8,[r5,#0x28] + ldr r1,[r5,#0x2c] + ldr r3,[r7,#0x40] + mov r1,r1,lsl #1 + smlal r1,r0,r3,r1 + str r0,[r5,#0x40] + ldr r0,[r5,#0x3c] + ldr r1,[r6,#0x38] + ldr r3,[r6,#0x3c] + rsb r9,r0,#0 + str r9,[r5,#0x2c] + ldr r0,[r5,#0x30] + ldr r12,[r7,#0x3c] + mov r0,r0,lsl #1 + smlal r0,r3,r12,r0 + str r3,[r5,#0x3c] + ldr r0,[r5,#0x38] + rsb r0,r0,#0 + str r0,[r5,#0x30] + ldr r3,[r5,#0x34] + ldr r12,[r7,#0x38] + mov r3,r3,lsl #1 + smlal r3,r1,r12,r3 + mov r0,r0,lsl #1 + str r1,[r5,#0x38] + ldr r4,[r7,#0x34] + ldr r1,[r6,#0x34] + ldr r3,[r6,#0x30] + smlal r0,r1,r4,r0 + ldr r12,[r6,#0x2c] + ldr lr,[r6,#0x28] + str r1,[r5,#0x34] + ldr r1,[r7,#0x30] + mov r0,r9,lsl #1 + smlal r0,r3,r1,r0 + mov r0,r8,lsl #1 + ldr r1,[r7,#0x2c] + str r3,[r5,#0x30] + smlal r0,r12,r1,r0 + ldr r0,[r7,#0x28] + str r12,[r5,#0x2c] + smlal r2,lr,r0,r2 + str lr,[r5,#0x28] + ldr r1,[r6,#4] + ldr r12,[r7,#0x48] + mov r2,r1,lsl #1 + ldr r1,[r6,#0x20] + ldr r0,[r6,#0] + mov r1,r1,lsl #1 + smull r4,lr,r12,r1 + ldr r3,[r6,#0x1c] + str lr,[r6,#0] + ldr r12,[r7,#0x4c] + mov r3,r3,lsl #1 + smull r4,lr,r12,r3 + mov r0,r0,lsl #1 + ldr r12,[r7,#0x64] + str lr,[r6,#4] + smull r4,lr,r12,r2 + ldr r12,[r7,#0x68] + str lr,[r6,#0x1c] + smull r4,lr,r12,r0 + ldr r12,[r7,#0x6c] + str lr,[r6,#0x20] + smull lr,r0,r12,r0 + ldr r12,[r7,#0x70] + str r0,[r6,#0x24] + smull r0,r2,r12,r2 + ldr r0,[r7,#0x88] + str r2,[r6,#0x28] + smull r3,r2,r0,r3 + ldr r0,[r7,#0x8c] + str r2,[r6,#0x40] + smull r2,r1,r0,r1 + str r1,[r6,#0x44] + ldr r0,[r6,#0x18] + ldr lr,[r7,#0x50] + mov r1,r0,lsl #1 + ldr r0,[r6,#0x14] + smull r5,r4,lr,r1 + mov r3,r0,lsl #1 + ldr r0,[r6,#0x10] + mov r12,r0,lsl #1 + ldr r0,[r6,#0xc] + mov r2,r0,lsl #1 + ldr r0,[r6,#8] + str r4,[r6,#8] + ldr lr,[r7,#0x54] + mov r0,r0,lsl #1 + smull r5,r4,lr,r3 + ldr lr,[r7,#0x58] + str r4,[r6,#0xc] + smull r5,r4,lr,r12 + ldr lr,[r7,#0x5c] + str r4,[r6,#0x10] + smull r5,r4,lr,r2 + ldr lr,[r7,#0x60] + str r4,[r6,#0x14] + smull r5,r4,lr,r0 + ldr lr,[r7,#0x74] + str r4,[r6,#0x18] + smull r4,r0,lr,r0 + ldr lr,[r7,#0x78] + str r0,[r6,#0x2c] + smull r0,r2,lr,r2 + ldr r0,[r7,#0x7c] + str r2,[r6,#0x30] + smull r12,r2,r0,r12 + ldr r0,[r7,#0x80] + str r2,[r6,#0x34] + smull r3,r2,r0,r3 + ldr r0,[r7,#0x84] + str r2,[r6,#0x38] + smull r2,r1,r0,r1 + str r1,[r6,#0x3c] + ldmfd sp!,{r4-r11,pc} + +@------------------------------------------------------------------------------ + +constdata$1: +cosTerms_dct18: + .word 0x0807d2b0 + .word 0x08483ee0 + .word 0x08d3b7d0 + .word 0x09c42570 + .word 0x0b504f30 + .word 0x0df29440 + .word 0x12edfb20 + .word 0x1ee8dd40 + .word 0x5bca2a00 +cosTerms_1_ov_cos_phi: + .word 0x400f9c00 + .word 0x408d6080 + .word 0x418dcb80 + .word 0x431b1a00 + .word 0x4545ea00 + .word 0x48270680 + .word 0x4be25480 + .word 0x50ab9480 + .word 0x56ce4d80 + .word 0x05ebb630 + .word 0x06921a98 + .word 0x0771d3a8 + .word 0x08a9a830 + .word 0x0a73d750 + .word 0x0d4d5260 + .word 0x127b1ca0 + .word 0x1ea52b40 + .word 0x5bb3cc80 + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_gcc.s b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_gcc.s new file mode 100644 index 0000000..1140ed7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_gcc.s @@ -0,0 +1,233 @@ +@ ------------------------------------------------------------------ +@ Copyright (C) 1998-2009 PacketVideo +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ http://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +@ express or implied. +@ See the License for the specific language governing permissions +@ and limitations under the License. +@ ------------------------------------------------------------------- + +@ +@ +@ Filename: pvmp3_polyphase_filter_window.s +@ +@------------------------------------------------------------------------------ +@ REVISION HISTORY +@ +@ +@ Who: Date: MM/DD/YYYY +@ Description: +@ +@------------------------------------------------------------------------------ + +.arm + +.align 4 + +.text + +.extern pqmfSynthWin +.hidden pqmfSynthWin + + + +@------------------------------------------------------------------------------ + +.global pvmp3_polyphase_filter_window + +pvmp3_polyphase_filter_window: + stmfd sp!,{r0-r2,r4-r11,lr} + + sub sp,sp,#4 + adr r2,PolyPh_filter_coeff + ldr r1,[r2] + add r1,r2 + ldr r2,[sp,#0xc] + + sub r2,r2,#1 + mov r10,#1 + str r2,[sp] + +@ Accumulators r9, r11::> Initialization + +Loop_j: + mov r9, #0x20 + mov r11, #0x20 + mov r4, #0x10 +Loop_i: + add r2,r4,r10 + add r3,r0,r2,lsl #2 + sub r2,r4,r10 + ldr r5,[r3] + ldr lr,[r1] + add r12,r0,r2,lsl #2 + ldr r6,[r12,#0x780] + smlal r2,r9,lr,r5 + smlal r2,r11,lr,r6 + ldr r2,[r1,#4] + ldr r7,[r12,#0x80] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + sub r9,r9,r5 + ldr r5,[r1,#8] + ldr r8,[r3,#0x700] + add r4,r4,#0x200 + smlal r6,r9,r5,r7 + smull r6,r2,r5,r8 + ldr r5,[r1,#0xc] + sub r11,r11,r2 + smlal r8,r9,r5,r8 + smlal r7,r11,r5,r7 + ldr r5,[r3,#0x100] + ldr r2,[r1,#0x10] + ldr r6,[r12,#0x680] + smlal lr,r9,r2,r5 + smlal lr,r11,r2,r6 + ldr r2,[r1,#0x14] + ldr r7,[r12,#0x180] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + ldr r6,[r1,#0x18] + ldr r8,[r3,#0x600] + sub r9,r9,r5 + smlal r5,r9,r6,r7 + smull r2,r5,r6,r8 + ldr r6,[r1,#0x1c] + sub r11,r11,r5 + smlal r8,r9,r6,r8 + ldr r2,[r1,#0x20] + ldr r5,[r3,#0x200] + smlal r7,r11,r6,r7 + ldr r6,[r12,#0x580] + smlal lr,r9,r2,r5 + smlal lr,r11,r2,r6 + ldr r2,[r1,#0x24] + ldr r7,[r12,#0x280] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + ldr r6,[r1,#0x28] + ldr r8,[r3,#0x500] + sub r9,r9,r5 + smlal r5,r9,r6,r7 + smull r2,r5,r6,r8 + ldr r6,[r1,#0x2c] + sub r11,r11,r5 + + smlal r8,r9,r6,r8 + smlal r7,r11,r6,r7 + ldr r5,[r3,#0x300] + ldr r8,[r1,#0x30] + ldr r6,[r12,#0x480] + smlal r7,r9,r8,r5 + smlal r7,r11,r8,r6 + ldr r8,[r1,#0x34] + ldr r12,[r12,#0x380] + smlal r5,r11,r8,r5 + smull r6,r5,r8,r6 + ldr r6,[r1,#0x38] + + + ldr r3,[r3,#0x400] + sub r9,r9,r5 + smlal r7,r9,r6,r12 + smull r8,r7,r6,r3 + cmp r4,#0x210 + sub r11,r11,r7 + + ldr r2,[r1,#0x3c] + add r1,r1,#0x40 + smlal r3,r9,r2,r3 + smlal r12,r11,r2,r12 + + blt Loop_i + + mov r3,r9, asr #6 + mov r4,r3, asr #15 + teq r4,r3, asr #31 + ldr r12,LOW_16BITS + ldr r2,[sp] + eorne r3,r12,r3,asr #31 + ldr r4,[sp,#8] + mov r2,r10,lsl r2 + add r4,r4,r2,lsl #1 + strh r3,[r4] + + mov r3,r11,asr #6 + mov r4,r3,asr #15 + teq r4,r3,asr #31 + eorne r3,r12,r3,asr #31 + ldr r12,[sp,#0xc] + ldr r11,[sp,#8] + rsb r2,r2,r12,lsl #5 + add r2,r11,r2,lsl #1 + strh r3,[r2] + + add r10,r10,#1 + cmp r10,#0x10 + blt Loop_j + +@ Accumulators r4, r5 Initialization + + mov r4,#0x20 + mov r5,#0x20 + mov r3,#0x10 +PolyPh_filter_loop2: + add r2,r0,r3,lsl #2 + ldr r12,[r2] + ldr r8,[r1] + ldr r6,[r2,#0x80] + smlal r12,r4,r8,r12 + ldr r12,[r1,#4] + ldr r7,[r2,#0x40] + smlal r6,r4,r12,r6 + + ldr r12,[r1,#8] + ldr r6,[r2,#0x180] + smlal r7,r5,r12,r7 + ldr r12,[r2,#0x100] + ldr r7,[r1,#0xc] + ldr r2,[r2,#0x140] + smlal r12,r4,r7,r12 + ldr r12,[r1,#0x10] + add r3,r3,#0x80 + smlal r6,r4,r12,r6 + ldr r6,[r1,#0x14] + cmp r3,#0x210 + smlal r2,r5,r6,r2 + add r1,r1,#0x18 + + blt PolyPh_filter_loop2 + mov r0,r4,asr #6 + mov r2,r0,asr #15 + teq r2,r0,asr #31 + ldrne r12,LOW_16BITS + ldr r1,[sp,#8] + eorne r0,r12,r0,asr #31 + strh r0,[r1,#0] + mov r0,r5,asr #6 + mov r2,r0,asr #15 + teq r2,r0,asr #31 + ldrne r12,LOW_16BITS + ldr r2,[sp] + mov r1,#0x10 + eorne r0,r12,r0,asr #31 + ldr r12,[sp,#8] + mov r1,r1,lsl r2 + add r1,r12,r1,lsl #1 + strh r0,[r1] + add sp,sp,#0x10 + ldmfd sp!,{r4-r11,pc} + +PolyPh_filter_coeff: + .word pqmfSynthWin-PolyPh_filter_coeff +LOW_16BITS: + .word 0x00007fff + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/mp3_mem_funcs.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/mp3_mem_funcs.h new file mode 100644 index 0000000..2b12d7a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/mp3_mem_funcs.h @@ -0,0 +1,70 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: mp3_mem_funcs.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ + +#ifndef MP3_MEM_FUNCS_H +#define MP3_MEM_FUNCS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "oscl_mem.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + + +#define pv_memset(to, c, n) oscl_memset(to, c, n) + + +#define pv_memcpy(to, from, n) oscl_memcpy(to, from, n) +#define pv_memmove(to, from, n) oscl_memmove(to, from, n) +#define pv_memcmp(p, q, n) oscl_memcmp(p, q, n) + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3_huffman.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3_huffman.h new file mode 100644 index 0000000..b894ad3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3_huffman.h @@ -0,0 +1,109 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pv_mp3_huffman.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ + +#ifndef PV_MP3_HUFFMAN_H +#define PV_MP3_HUFFMAN_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" +#include "s_tmp3dec_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + int32 pvmp3_huffman_parsing(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], + granuleInfo *grInfo, + tmp3dec_file *pVars, + int32 part2_start, + mp3Header *info); + + + void pvmp3_huffman_quad_decoding(struct huffcodetab *h, + int32 *is, + tmp3Bits *pMainData); + + void pvmp3_huffman_pair_decoding(struct huffcodetab *h, + int32 *is, + tmp3Bits *pMainData); + + + void pvmp3_huffman_pair_decoding_linbits(struct huffcodetab *h, + int32 *is, + tmp3Bits *pMainData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op.h new file mode 100644 index 0000000..227e05a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op.h @@ -0,0 +1,68 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pv_mp3dec_fxd_op.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file select the associated fixed point functions with the OS/ARCH. + + + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_MP3DEC_FXD_OP_H +#define PV_MP3DEC_FXD_OP_H + +#include "pvmp3_audio_type_defs.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#if ((PV_CPU_ARCH_VERSION >=4) && (PV_COMPILER == EPV_ARM_GNUC)) + +#include "pv_mp3dec_fxd_op_arm_gcc.h" + +#else + +#ifndef C_EQUIVALENT +#define C_EQUIVALENT +#endif + +#include "pv_mp3dec_fxd_op_c_equivalent.h" + +#endif + + +#ifdef __cplusplus +} +#endif + + + +#endif /* PV_MP3DEC_FXD_OP_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm_gcc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm_gcc.h new file mode 100644 index 0000000..d0fe06a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm_gcc.h @@ -0,0 +1,244 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Pathname: ./cpp/include/pv_mp3dec_fxd_op_arm_gcc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file select the associated fixed point functions with the OS/ARCH. + + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_MP3DEC_FXD_OP_ARM_GCC_H +#define PV_MP3DEC_FXD_OP_ARM_GCC_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "pvmp3_audio_type_defs.h" + + + +#define Qfmt_31(a) (int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) + +#define Qfmt15(x) (Int16)(x*((int32)1<<15) + (x>=0?0.5F:-0.5F)) + + static inline int32 fxp_mul32_Q30(const int32 a, const int32 b) + { + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %1, %1, lsr #30\n\t" + "add %0, %1, %0, asl #2" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + + static inline int32 fxp_mac32_Q30(const int32 a, const int32 b, int32 L_add) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + register int32 rc = (int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %4, %4, %0, asl #2\n\t" + "add %0, %4, %1, lsr #30" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + + static inline int32 fxp_mul32_Q32(const int32 a, const int32 b) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile( + "smull %1, %0, %2, %3" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline int32 fxp_mul32_Q29(const int32 a, const int32 b) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %1, %1, lsr #29\n\t" + "add %0, %1, %0, asl #3" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + + } + + static inline int32 fxp_mul32_Q28(const int32 a, const int32 b) +{ + + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %1, %1, lsr #28\n\t" + "add %0, %1, %0, asl #4" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + + } + + + static inline int32 fxp_mul32_Q27(const int32 a, const int32 b) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %1, %1, lsr #27\n\t" + "add %0, %1, %0, asl #5" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + + } + + + static inline int32 fxp_mul32_Q26(const int32 a, const int32 b) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %1, %1, lsr #26\n\t" + "add %0, %1, %0, asl #6" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + + } + + + + static inline int32 fxp_mac32_Q32(int32 L_add, const int32 a, const int32 b) +{ + + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + register int32 rc = (int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %0, %0, %4" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + static inline int32 fxp_msb32_Q32(int32 L_sub, const int32 a, const int32 b) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + register int32 rc = (int32)L_sub; + + asm volatile("smull %1, %0, %2, %3\n\t" + "sub %0, %4, %0" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + + return (result64_hi); + } + + + __inline int32 pv_abs(int32 x) +{ + register int32 z; + register int32 y; + register int32 ra = x; + asm volatile( + "sub %0, %2, %2, lsr #31\n\t" + "eor %1, %0, %0, asr #31" + : "=&r*i"(z), + "=&r*i"(y) + : "r"(ra)); + + return (y); + } + + + +#ifdef __cplusplus +} +#endif + + +#endif /* PV_MP3DEC_FXD_OP_ARM_GCC_H */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_c_equivalent.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_c_equivalent.h new file mode 100644 index 0000000..4542303 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_c_equivalent.h @@ -0,0 +1,109 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Pathname: ./cpp/include/pv_mp3dec_fxd_op_c_equivalent.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_MP3DEC_FXD_OP_C_EQUIVALENT +#define PV_MP3DEC_FXD_OP_C_EQUIVALENT + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "pvmp3_audio_type_defs.h" +#define Qfmt_31(a) (Int32)((float)a*0x7FFFFFFF) + +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + + + + __inline int32 pv_abs(int32 a) + { + int32 b = (a < 0) ? -a : a; + return b; + } + + __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 30); + } + + __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) + { + return (L_add + (Int32)(((int64)(a) * b) >> 30)); + } + + __inline Int32 fxp_mul32_Q32(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 32); + } + + + __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 28); + } + + __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 27); + } + + __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 26); + } + + + __inline Int32 fxp_mac32_Q32(Int32 L_add, const Int32 a, const Int32 b) + { + return (L_add + (Int32)(((int64)(a) * b) >> 32)); + } + + __inline Int32 fxp_msb32_Q32(Int32 L_sub, const Int32 a, const Int32 b) + { + return (L_sub - ((Int32)(((int64)(a) * b) >> 32))); + } + + + __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 29); + } + +#ifdef __cplusplus +} +#endif + + +#endif /* PV_MP3DEC_FXD_OP_C_EQUIVALENT */ + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.cpp new file mode 100644 index 0000000..5e96bab --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.cpp @@ -0,0 +1,253 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_alias_reduction.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + int32 *input_buffer, Ptr to fequency lines of current channel + struct gr_info_s *gr_info, structure with granuke information for the + input + mp3Header *info mp3 header information + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Alias Reduction + + + + Alias reduction before processing by the IMDCT + + Csi + + >---------0---------0--------> + \ / - + Cai \ / + \ / + \ / + \ + / \ + Cai / \ + / \ + + >--------0---------0----------> + Csi + + + Aliasing Butterfly + Alias reduction is not applied to short blocks + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + 1 ci + csi = ---------------- csi = ---------------- + sqrt( 1 + (ci^2)) sqrt( 1 + (ci^2)) + + + ci = -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037 + + ------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_alias_reduction.h" +#include "pv_mp3dec_fxd_op.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define NUM_BUTTERFLIES 8 + +#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*a)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 c_signal [ NUM_BUTTERFLIES ] = +{ + + Q31_fmt(0.85749292571254f), Q31_fmt(0.88174199731771f), + Q31_fmt(0.94962864910273f), Q31_fmt(0.98331459249179f), + Q31_fmt(0.99551781606759f), Q31_fmt(0.99916055817815f), + Q31_fmt(0.99989919524445f), Q31_fmt(0.99999315507028f) + +}; + + +const int32 c_alias [ NUM_BUTTERFLIES ] = +{ + + Q31_fmt(-0.51449575542753f), Q31_fmt(-0.47173196856497f), + Q31_fmt(-0.31337745420390f), Q31_fmt(-0.18191319961098f), + Q31_fmt(-0.09457419252642f), Q31_fmt(-0.04096558288530f), + Q31_fmt(-0.01419856857247f), Q31_fmt(-0.00369997467376f) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_alias_reduction(int32 *input_buffer, /* Ptr to spec values of current channel */ + granuleInfo *gr_info, + int32 *used_freq_lines, + mp3Header *info) +{ + int32 *ptr1; + int32 *ptr2; + int32 *ptr3; + int32 *ptr4; + const int32 *ptr_csi; + const int32 *ptr_csa; + int32 sblim; + + int32 i, j; + + *used_freq_lines = fxp_mul32_Q32(*used_freq_lines << 16, (int32)(0x7FFFFFFF / (float)18 - 1.0f)) >> 15; + + + if (gr_info->window_switching_flag && gr_info->block_type == 2) + { + if (gr_info->mixed_block_flag) + { + sblim = ((info->version_x == MPEG_2_5) && (info->sampling_frequency == 2)) ? 3 : 1; + } + else + { + return; /* illegal parameter */ + } + } + else + { + sblim = *used_freq_lines + 1; + + if (sblim > SUBBANDS_NUMBER - 1) + { + sblim = SUBBANDS_NUMBER - 1; /* default */ + } + + } + + + ptr3 = &input_buffer[17]; + ptr4 = &input_buffer[18]; + ptr_csi = c_signal; + ptr_csa = c_alias; + + /* NUM_BUTTERFLIES (=8) butterflies between each pair of sub-bands*/ + + for (i = NUM_BUTTERFLIES >> 1; i != 0; i--) + { + int32 csi1 = *ptr_csi++; + int32 csi2 = *ptr_csi++; + int32 csa1 = *ptr_csa++; + int32 csa2 = *ptr_csa++; + + ptr1 = ptr3; + ptr3 -= 2; + ptr2 = ptr4; + ptr4 += 2; + + /* + * "sblim" alias-reduction operations between each + * pair of sub-bands + */ + + for (j = sblim >> 1; j != 0; j--) + { + int32 y = *ptr2; + int32 x = *ptr1 << 1; + *ptr1-- = fxp_msb32_Q32(fxp_mul32_Q32(x, csi1), y << 1, csa1); + *ptr2++ = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi1), x, csa1); + y = *ptr2; + x = *ptr1 << 1; + *ptr1 = fxp_msb32_Q32(fxp_mul32_Q32(x, csi2), y << 1, csa2); + *ptr2 = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi2), x, csa2); + ptr1 += 19; + ptr2 += 17; + y = *ptr2; + x = *ptr1 << 1; + *ptr1-- = fxp_msb32_Q32(fxp_mul32_Q32(x, csi1), y << 1, csa1); + *ptr2++ = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi1), x, csa1); + y = *ptr2; + x = *ptr1 << 1; + *ptr1 = fxp_msb32_Q32(fxp_mul32_Q32(x, csi2), y << 1, csa2); + *ptr2 = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi2), x, csa2); + ptr1 += 19; + ptr2 += 17; + + } + + if (sblim & 1) + { + int32 x = *ptr1 << 1; + int32 y = *ptr2; + *ptr1-- = fxp_msb32_Q32(fxp_mul32_Q32(x, csi1), y << 1, csa1); + *ptr2++ = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi1), x, csa1); + + x = *ptr1 << 1; + y = *ptr2; + *ptr1 = fxp_msb32_Q32(fxp_mul32_Q32(x, csi2), y << 1, csa2); + *ptr2 = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi2), x, csa2); + } + } + +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.h new file mode 100644 index 0000000..38603ee --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_alias_reduction.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_ALIAS_REDUCTION_H +#define PVMP3_ALIAS_REDUCTION_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_alias_reduction(int32 *input_buffer, + granuleInfo *gr_info, + int32 *used_freq_lines, + mp3Header *info); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_crc.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_crc.cpp new file mode 100644 index 0000000..bc3900f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_crc.cpp @@ -0,0 +1,153 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_crc.cpp + + Functions: + getbits_crc + calculate_crc + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +getbits_crc + +Input + tbits *inputStream, bit stream structure + int32 neededBits, number of bits to read from the bit stream + uint32 *crc, memory location holding calculated crc value + uint32 crc_enabled flag to enable/disable crc checking + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +calculate_crc + +Input + uint32 data, data vector + uint32 length, number of element upon the crc will be calculated + uint32 *crc, memory location holding calculated crc value + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + + ------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_getbits.h" +#include "pvmp3_crc.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint32 getbits_crc(tmp3Bits *inputStream, /* bit stream structure */ + int32 neededBits, /* number of bits to read from the bit stream */ + uint32 *crc, + uint32 crc_enabled) +{ + uint32 bits = getNbits(inputStream, neededBits); + + if (crc_enabled) + { + calculate_crc(bits, neededBits, crc); + } + return(bits); +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void calculate_crc(uint32 data, + uint32 length, + uint32 *crc) +{ + uint32 carry; + uint32 masking = 1 << length; + + while ((masking >>= 1)) + { + carry = *crc & 0x8000; + *crc <<= 1; + if (!carry ^ !(data & masking)) + { + *crc ^= CRC16_POLYNOMIAL; + } + } + *crc &= 0xffff; +} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_crc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_crc.h new file mode 100644 index 0000000..398756e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_crc.h @@ -0,0 +1,103 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_crc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_CRC_H +#define PVMP3_CRC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" +#include "pvmp3decoder_api.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define CRC16_POLYNOMIAL 0x8005 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + uint32 getbits_crc(tmp3Bits *inputStream, + int32 neededBits, + uint32 *crc, + uint32 crc_enabled); + + + void calculate_crc(uint32 data, + uint32 length, + uint32 *crc); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.cpp new file mode 100644 index 0000000..a6e6525 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.cpp @@ -0,0 +1,403 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dct_16.cpp + + Functions: + dct_16 + pv_merge_in_place_N32 + pv_split + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + dct_16 + +Input + int32 vec[], input vector length 16 + Int flag processing direction: forward (1), backward ( 0) + Returns + + int32 vec[], dct length 16 + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + pv_merge_in_place_N32 + +Input + int32 vec[], input vector length 16 + + Returns + + int32 vec[], merged output of two dct 16 to create a dct 32 + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + pv_split + +Input + int32 vec[], input vector length 16 + + Returns + + int32 vec[], splitted even/odd and pre processing rotation + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + dct 16 and tools to assemble a dct32 output + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ +#include "oscl_base_macros.h"// has integer values of PV_COMPILER + +#if !((PV_CPU_ARCH_VERSION >=4) && (PV_COMPILER == EPV_ARM_GNUC)) +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dct_16.h" +#include "pv_mp3dec_fxd_op.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define Qfmt(a) (int32)(a*((int32)1<<27)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 CosTable_dct32[16] = +{ + Qfmt_31(0.50060299823520F) , Qfmt_31(0.50547095989754F) , + Qfmt_31(0.51544730992262F) , Qfmt_31(0.53104259108978F) , + Qfmt_31(0.55310389603444F) , Qfmt_31(0.58293496820613F) , + Qfmt_31(0.62250412303566F) , Qfmt_31(0.67480834145501F) , + Qfmt_31(0.74453627100230F) , Qfmt_31(0.83934964541553F) , + + Qfmt(0.97256823786196F) , Qfmt(1.16943993343288F) , + Qfmt(1.48416461631417F) , Qfmt(2.05778100995341F) , + Qfmt(3.40760841846872F) , Qfmt(10.19000812354803F) +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_dct_16(int32 vec[], int32 flag) +{ + int32 tmp0; + int32 tmp1; + int32 tmp2; + int32 tmp3; + int32 tmp4; + int32 tmp5; + int32 tmp6; + int32 tmp7; + int32 tmp_o0; + int32 tmp_o1; + int32 tmp_o2; + int32 tmp_o3; + int32 tmp_o4; + int32 tmp_o5; + int32 tmp_o6; + int32 tmp_o7; + int32 itmp_e0; + int32 itmp_e1; + int32 itmp_e2; + + /* split input vector */ + + tmp_o0 = fxp_mul32_Q32((vec[ 0] - vec[15]), Qfmt_31(0.50241928618816F)); + tmp0 = vec[ 0] + vec[15]; + + tmp_o7 = fxp_mul32_Q32((vec[ 7] - vec[ 8]) << 3, Qfmt_31(0.63764357733614F)); + tmp7 = vec[ 7] + vec[ 8]; + + itmp_e0 = fxp_mul32_Q32((tmp0 - tmp7), Qfmt_31(0.50979557910416F)); + tmp7 = (tmp0 + tmp7); + + tmp_o1 = fxp_mul32_Q32((vec[ 1] - vec[14]), Qfmt_31(0.52249861493969F)); + tmp1 = vec[ 1] + vec[14]; + + tmp_o6 = fxp_mul32_Q32((vec[ 6] - vec[ 9]) << 1, Qfmt_31(0.86122354911916F)); + tmp6 = vec[ 6] + vec[ 9]; + + + + itmp_e1 = (tmp1 + tmp6); + tmp6 = fxp_mul32_Q32((tmp1 - tmp6), Qfmt_31(0.60134488693505F)); + + + + tmp_o2 = fxp_mul32_Q32((vec[ 2] - vec[13]), Qfmt_31(0.56694403481636F)); + tmp2 = vec[ 2] + vec[13]; + tmp_o5 = fxp_mul32_Q32((vec[ 5] - vec[10]) << 1, Qfmt_31(0.53033884299517F)); + tmp5 = vec[ 5] + vec[10]; + + itmp_e2 = (tmp2 + tmp5); + tmp5 = fxp_mul32_Q32((tmp2 - tmp5), Qfmt_31(0.89997622313642F)); + + tmp_o3 = fxp_mul32_Q32((vec[ 3] - vec[12]), Qfmt_31(0.64682178335999F)); + tmp3 = vec[ 3] + vec[12]; + tmp_o4 = fxp_mul32_Q32((vec[ 4] - vec[11]), Qfmt_31(0.78815462345125F)); + tmp4 = vec[ 4] + vec[11]; + + tmp1 = (tmp3 + tmp4); + tmp4 = fxp_mul32_Q32((tmp3 - tmp4) << 2, Qfmt_31(0.64072886193538F)); + + /* split even part of tmp_e */ + + tmp0 = (tmp7 + tmp1); + tmp1 = fxp_mul32_Q32((tmp7 - tmp1), Qfmt_31(0.54119610014620F)); + + tmp3 = fxp_mul32_Q32((itmp_e1 - itmp_e2) << 1, Qfmt_31(0.65328148243819F)); + tmp7 = (itmp_e1 + itmp_e2); + + vec[ 0] = (tmp0 + tmp7) >> 1; + vec[ 8] = fxp_mul32_Q32((tmp0 - tmp7), Qfmt_31(0.70710678118655F)); + tmp0 = fxp_mul32_Q32((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F)); + vec[ 4] = tmp1 + tmp3 + tmp0; + vec[12] = tmp0; + + /* split odd part of tmp_e */ + + tmp1 = fxp_mul32_Q32((itmp_e0 - tmp4) << 1, Qfmt_31(0.54119610014620F)); + tmp7 = itmp_e0 + tmp4; + + tmp3 = fxp_mul32_Q32((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F)); + tmp6 += tmp5; + + tmp4 = fxp_mul32_Q32((tmp7 - tmp6) << 1, Qfmt_31(0.70710678118655F)); + tmp6 += tmp7; + tmp7 = fxp_mul32_Q32((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F)); + + tmp1 += tmp3 + tmp7; + vec[ 2] = tmp1 + tmp6; + vec[ 6] = tmp1 + tmp4; + vec[10] = tmp7 + tmp4; + vec[14] = tmp7; + + + // dct8; + + tmp1 = fxp_mul32_Q32((tmp_o0 - tmp_o7) << 1, Qfmt_31(0.50979557910416F)); + tmp7 = tmp_o0 + tmp_o7; + + tmp6 = tmp_o1 + tmp_o6; + tmp_o1 = fxp_mul32_Q32((tmp_o1 - tmp_o6) << 1, Qfmt_31(0.60134488693505F)); + + tmp5 = tmp_o2 + tmp_o5; + tmp_o5 = fxp_mul32_Q32((tmp_o2 - tmp_o5) << 1, Qfmt_31(0.89997622313642F)); + + tmp0 = fxp_mul32_Q32((tmp_o3 - tmp_o4) << 3, Qfmt_31(0.6407288619354F)); + tmp4 = tmp_o3 + tmp_o4; + + if (!flag) + { + tmp7 = -tmp7; + tmp1 = -tmp1; + tmp6 = -tmp6; + tmp_o1 = -tmp_o1; + tmp5 = -tmp5; + tmp_o5 = -tmp_o5; + tmp4 = -tmp4; + tmp0 = -tmp0; + } + + + tmp2 = fxp_mul32_Q32((tmp1 - tmp0) << 1, Qfmt_31(0.54119610014620F)); + tmp0 += tmp1; + tmp1 = fxp_mul32_Q32((tmp7 - tmp4) << 1, Qfmt_31(0.54119610014620F)); + tmp7 += tmp4; + tmp4 = fxp_mul32_Q32((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F)); + tmp6 += tmp5; + tmp5 = fxp_mul32_Q32((tmp_o1 - tmp_o5) << 2, Qfmt_31(0.65328148243819F)); + tmp_o1 += tmp_o5; + + + vec[13] = fxp_mul32_Q32((tmp1 - tmp4) << 1, Qfmt_31(0.70710678118655F)); + vec[ 5] = tmp1 + tmp4 + vec[13]; + + vec[ 9] = fxp_mul32_Q32((tmp7 - tmp6) << 1, Qfmt_31(0.70710678118655F)); + vec[ 1] = tmp7 + tmp6; + + tmp4 = fxp_mul32_Q32((tmp0 - tmp_o1) << 1, Qfmt_31(0.70710678118655F)); + tmp0 += tmp_o1; + tmp6 = fxp_mul32_Q32((tmp2 - tmp5) << 1, Qfmt_31(0.70710678118655F)); + tmp2 += tmp5 + tmp6; + tmp0 += tmp2; + + vec[ 1] += tmp0; + vec[ 3] = tmp0 + vec[ 5]; + tmp2 += tmp4; + vec[ 5] = tmp2 + vec[ 5]; + vec[ 7] = tmp2 + vec[ 9]; + tmp4 += tmp6; + vec[ 9] = tmp4 + vec[ 9]; + vec[11] = tmp4 + vec[13]; + vec[13] = tmp6 + vec[13]; + vec[15] = tmp6; + +} +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void pvmp3_merge_in_place_N32(int32 vec[]) +{ + + + int32 temp0; + int32 temp1; + int32 temp2; + int32 temp3; + + temp0 = vec[14]; + vec[14] = vec[ 7]; + temp1 = vec[12]; + vec[12] = vec[ 6]; + temp2 = vec[10]; + vec[10] = vec[ 5]; + temp3 = vec[ 8]; + vec[ 8] = vec[ 4]; + vec[ 6] = vec[ 3]; + vec[ 4] = vec[ 2]; + vec[ 2] = vec[ 1]; + + vec[ 1] = (vec[16] + vec[17]); + vec[16] = temp3; + vec[ 3] = (vec[18] + vec[17]); + vec[ 5] = (vec[19] + vec[18]); + vec[18] = vec[9]; + + vec[ 7] = (vec[20] + vec[19]); + vec[ 9] = (vec[21] + vec[20]); + vec[20] = temp2; + temp2 = vec[13]; + temp3 = vec[11]; + vec[11] = (vec[22] + vec[21]); + vec[13] = (vec[23] + vec[22]); + vec[22] = temp3; + temp3 = vec[15]; + + vec[15] = (vec[24] + vec[23]); + vec[17] = (vec[25] + vec[24]); + vec[19] = (vec[26] + vec[25]); + vec[21] = (vec[27] + vec[26]); + vec[23] = (vec[28] + vec[27]); + vec[24] = temp1; + vec[25] = (vec[29] + vec[28]); + vec[26] = temp2; + vec[27] = (vec[30] + vec[29]); + vec[28] = temp0; + vec[29] = (vec[30] + vec[31]); + vec[30] = temp3; +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void pvmp3_split(int32 *vect) +{ + + int32 i; + const int32 *pt_cosTerms = &CosTable_dct32[15]; + int32 *pt_vect = vect; + int32 *pt_vect_2 = pt_vect - 1; + + for (i = 3; i != 0; i--) + { + int32 tmp2 = *(pt_vect); + int32 tmp1 = *(pt_vect_2); + int32 cosx = *(pt_cosTerms--); + *(pt_vect_2--) = (tmp1 + tmp2); + *(pt_vect++) = fxp_mul32_Q27((tmp1 - tmp2), cosx); + + tmp2 = *(pt_vect); + tmp1 = *(pt_vect_2); + cosx = *(pt_cosTerms--); + *(pt_vect_2--) = (tmp1 + tmp2); + *(pt_vect++) = fxp_mul32_Q27((tmp1 - tmp2), cosx); + + } + + for (i = 5; i != 0; i--) + { + int32 tmp2 = *(pt_vect); + int32 tmp1 = *(pt_vect_2); + int32 cosx = *(pt_cosTerms--); + *(pt_vect_2--) = (tmp1 + tmp2); + *(pt_vect++) = fxp_mul32_Q32((tmp1 - tmp2) << 1, cosx); + + tmp2 = *(pt_vect); + tmp1 = *(pt_vect_2); + cosx = *(pt_cosTerms--); + *(pt_vect_2--) = (tmp1 + tmp2); + *(pt_vect++) = fxp_mul32_Q32((tmp1 - tmp2) << 1, cosx); + } + +} + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.h new file mode 100644 index 0000000..85464b9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dct_16.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_DCT_16_H +#define PVMP3_DCT_16_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_dct_16(int32 vec[], int32 flag); + + void pvmp3_merge_in_place_N32(int32 vec[]); + + void pvmp3_split(int32 *vect); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_6.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_6.cpp new file mode 100644 index 0000000..f1110df --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_6.cpp @@ -0,0 +1,144 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dct6.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + Int32 vec[] vector of 6 32-bit integers +Returns + Int32 vec[] dct computation in-place + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Returns the dct of length 6 of the input vector + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_mdct_6.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define Qfmt30(a) (Int32)(a*((Int32)1<<30) + (a>=0?0.5F:-0.5F)) + +#define cos_pi_6 Qfmt30( 0.86602540378444f) +#define cos_2_pi_6 Qfmt30( 0.5f) +#define cos_7_pi_12 Qfmt30( -0.25881904510252f) +#define cos_3_pi_12 Qfmt30( 0.70710678118655f) +#define cos_11_pi_12 Qfmt30( -0.96592582628907f) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_dct_6(int32 vec[]) +{ + + Int32 tmp0; + Int32 tmp1; + Int32 tmp2; + Int32 tmp3; + Int32 tmp4; + Int32 tmp5; + + + /* split input vector */ + + tmp0 = vec[5] + vec[0]; + tmp5 = vec[5] - vec[0]; + tmp1 = vec[4] + vec[1]; + tmp4 = vec[4] - vec[1]; + tmp2 = vec[3] + vec[2]; + tmp3 = vec[3] - vec[2]; + + vec[0] = tmp0 + tmp2 ; + vec[2] = fxp_mul32_Q30(tmp0 - tmp2, cos_pi_6); + vec[4] = (vec[0] >> 1) - tmp1; + vec[0] += tmp1; + + tmp0 = fxp_mul32_Q30(tmp3, cos_7_pi_12); + tmp0 = fxp_mac32_Q30(tmp4, -cos_3_pi_12, tmp0); + vec[1] = fxp_mac32_Q30(tmp5, cos_11_pi_12, tmp0); + + vec[3] = fxp_mul32_Q30((tmp3 + tmp4 - tmp5), cos_3_pi_12); + tmp0 = fxp_mul32_Q30(tmp3, cos_11_pi_12); + tmp0 = fxp_mac32_Q30(tmp4, cos_3_pi_12, tmp0); + vec[5] = fxp_mac32_Q30(tmp5, cos_7_pi_12, tmp0); + +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_9.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_9.cpp new file mode 100644 index 0000000..dff8ffe --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dct_9.cpp @@ -0,0 +1,160 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dct_9.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + int32 vec[] vector of 9 32-bit integers +Returns + int32 vec[] dct computation in-place + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Returns the dct of length 9 of the input vector + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ +#include "oscl_base_macros.h"// has integer values of PV_COMPILER + +#if !((PV_CPU_ARCH_VERSION >=4) && ((PV_COMPILER == EPV_ARM_GNUC)|| (PV_COMPILER == EPV_ARM_RVCT))) +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_mdct_18.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define Qfmt31(a) (int32)(a*(0x7FFFFFFF)) + +#define cos_pi_9 Qfmt31( 0.93969262078591f) +#define cos_2pi_9 Qfmt31( 0.76604444311898f) +#define cos_4pi_9 Qfmt31( 0.17364817766693f) +#define cos_5pi_9 Qfmt31(-0.17364817766693f) +#define cos_7pi_9 Qfmt31(-0.76604444311898f) +#define cos_8pi_9 Qfmt31(-0.93969262078591f) +#define cos_pi_6 Qfmt31( 0.86602540378444f) +#define cos_5pi_6 Qfmt31(-0.86602540378444f) +#define cos_5pi_18 Qfmt31( 0.64278760968654f) +#define cos_7pi_18 Qfmt31( 0.34202014332567f) +#define cos_11pi_18 Qfmt31(-0.34202014332567f) +#define cos_13pi_18 Qfmt31(-0.64278760968654f) +#define cos_17pi_18 Qfmt31(-0.98480775301221f) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_dct_9(int32 vec[]) +{ + + /* split input vector */ + + int32 tmp0 = vec[8] + vec[0]; + int32 tmp8 = vec[8] - vec[0]; + int32 tmp1 = vec[7] + vec[1]; + int32 tmp7 = vec[7] - vec[1]; + int32 tmp2 = vec[6] + vec[2]; + int32 tmp6 = vec[6] - vec[2]; + int32 tmp3 = vec[5] + vec[3]; + int32 tmp5 = vec[5] - vec[3]; + + vec[0] = (tmp0 + tmp2 + tmp3) + (tmp1 + vec[4]); + vec[6] = ((tmp0 + tmp2 + tmp3) >> 1) - (tmp1 + vec[4]); + vec[2] = (tmp1 >> 1) - vec[4]; + vec[4] = -vec[2]; + vec[8] = -vec[2]; + vec[4] = fxp_mac32_Q32(vec[4], tmp0 << 1, cos_2pi_9); + vec[8] = fxp_mac32_Q32(vec[8], tmp0 << 1, cos_4pi_9); + vec[2] = fxp_mac32_Q32(vec[2], tmp0 << 1, cos_pi_9); + vec[2] = fxp_mac32_Q32(vec[2], tmp2 << 1, cos_5pi_9); + vec[4] = fxp_mac32_Q32(vec[4], tmp2 << 1, cos_8pi_9); + vec[8] = fxp_mac32_Q32(vec[8], tmp2 << 1, cos_2pi_9); + vec[8] = fxp_mac32_Q32(vec[8], tmp3 << 1, cos_8pi_9); + vec[4] = fxp_mac32_Q32(vec[4], tmp3 << 1, cos_4pi_9); + vec[2] = fxp_mac32_Q32(vec[2], tmp3 << 1, cos_7pi_9); + + vec[1] = fxp_mul32_Q32(tmp5 << 1, cos_11pi_18); + vec[1] = fxp_mac32_Q32(vec[1], tmp6 << 1, cos_13pi_18); + vec[1] = fxp_mac32_Q32(vec[1], tmp7 << 1, cos_5pi_6); + vec[1] = fxp_mac32_Q32(vec[1], tmp8 << 1, cos_17pi_18); + vec[3] = fxp_mul32_Q32((tmp5 + tmp6 - tmp8) << 1, cos_pi_6); + vec[5] = fxp_mul32_Q32(tmp5 << 1, cos_17pi_18); + vec[5] = fxp_mac32_Q32(vec[5], tmp6 << 1, cos_7pi_18); + vec[5] = fxp_mac32_Q32(vec[5], tmp7 << 1, cos_pi_6); + vec[5] = fxp_mac32_Q32(vec[5], tmp8 << 1, cos_13pi_18); + vec[7] = fxp_mul32_Q32(tmp5 << 1, cos_5pi_18); + vec[7] = fxp_mac32_Q32(vec[7], tmp6 << 1, cos_17pi_18); + vec[7] = fxp_mac32_Q32(vec[7], tmp7 << 1, cos_pi_6); + vec[7] = fxp_mac32_Q32(vec[7], tmp8 << 1, cos_11pi_18); + +} + + + +#endif // If not assembly diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dec_defs.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dec_defs.h new file mode 100644 index 0000000..c55f4bf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dec_defs.h @@ -0,0 +1,210 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dec_defs.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file has the mp3 decoder common defines. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_DEC_DEFS_H +#define PVMP3_DEC_DEFS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" +#include "pvmp3decoder_api.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#define module(x, POW2) ((x)&(POW2-1)) + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define BUFSIZE 8192 // big enough to hold 4608 bytes == biggest mp3 frame + +#define CHAN 2 +#define GRAN 2 + + +#define SUBBANDS_NUMBER 32 +#define FILTERBANK_BANDS 18 +#define HAN_SIZE 512 + + +/* MPEG Header Definitions - ID Bit Values */ + +#define MPEG_1 0 +#define MPEG_2 1 +#define MPEG_2_5 2 +#define INVALID_VERSION -1 + +/* MPEG Header Definitions - Mode Values */ + +#define MPG_MD_STEREO 0 +#define MPG_MD_JOINT_STEREO 1 +#define MPG_MD_DUAL_CHANNEL 2 +#define MPG_MD_MONO 3 + + + +#define LEFT 0 +#define RIGHT 1 + + +#define SYNC_WORD (int32)0x7ff +#define SYNC_WORD_LNGTH 11 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef enum ERROR_CODE + { + NO_DECODING_ERROR = 0, + UNSUPPORTED_LAYER = 1, + UNSUPPORTED_FREE_BITRATE = 2, + FILE_OPEN_ERROR = 3, /* error opening file */ + CHANNEL_CONFIG_ERROR = 4, /* error in channel configuration */ + SYNTHESIS_WINDOW_ERROR = 5, /* error in synthesis window table */ + READ_FILE_ERROR = 6, /* error reading input file */ + SIDE_INFO_ERROR = 7, /* error in side info */ + HUFFMAN_TABLE_ERROR = 8, /* error in Huffman table */ + COMMAND_LINE_ERROR = 9, /* error in command line */ + MEMORY_ALLOCATION_ERROR = 10, /* error allocating memory */ + NO_ENOUGH_MAIN_DATA_ERROR = 11, + SYNCH_LOST_ERROR = 12, + OUTPUT_BUFFER_TOO_SMALL = 13 /* output buffer can't hold output */ + } ERROR_CODE; + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /* Header Information Structure */ + + typedef struct + { + int32 version_x; + int32 layer_description; + int32 error_protection; + int32 bitrate_index; + int32 sampling_frequency; + int32 padding; + int32 extension; + int32 mode; + int32 mode_ext; + int32 copyright; + int32 original; + int32 emphasis; + } mp3Header; + + + /* Layer III side information. */ + + typedef struct + { + uint32 part2_3_length; + uint32 big_values; + int32 global_gain; + uint32 scalefac_compress; + uint32 window_switching_flag; + uint32 block_type; + uint32 mixed_block_flag; + uint32 table_select[3]; + uint32 subblock_gain[3]; + uint32 region0_count; + uint32 region1_count; + uint32 preflag; + uint32 scalefac_scale; + uint32 count1table_select; + + } granuleInfo; + + typedef struct + { + uint32 scfsi[4]; + granuleInfo gran[2]; + + } channelInfo; + + /* Layer III side info. */ + + typedef struct + { + uint32 main_data_begin; + uint32 private_bits; + channelInfo ch[2]; + + } mp3SideInfo; + + /* Layer III scale factors. */ + typedef struct + { + int32 l[23]; /* [cb] */ + int32 s[3][13]; /* [window][cb] */ + + } mp3ScaleFactors; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.cpp new file mode 100644 index 0000000..f433263 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.cpp @@ -0,0 +1,184 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decode_header.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + tbits *inputStream, bit stream + mp3Header *info, + uint32 *crc + Returns + + mp3Header *info, structure holding the parsed mp3 header info + uint32 *crc initialized crc computation + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + gets mp3 header information + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_decode_header.h" +#include "pvmp3_crc.h" +#include "pvmp3_getbits.h" +#include "pvmp3_seek_synch.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +ERROR_CODE pvmp3_decode_header(tmp3Bits *inputStream, + mp3Header *info, + uint32 *crc) +{ + + ERROR_CODE err = NO_DECODING_ERROR; + uint32 temp; + + /* + * Verify that at least the header is complete + */ + if (inputStream->inputBufferCurrentLength < (SYNC_WORD_LNGTH + 21)) + { + return NO_ENOUGH_MAIN_DATA_ERROR; + } + + /* + * MPEG Audio Version ID + */ + temp = getUpTo17bits(inputStream, SYNC_WORD_LNGTH); + if ((temp & SYNC_WORD) != SYNC_WORD) + { + err = pvmp3_header_sync(inputStream); + + if (err != NO_DECODING_ERROR) + { + return err; + } + } + + temp = getNbits(inputStream, 21); // to avoid multiple bitstream accesses + + + switch (temp >> 19) /* 2 */ + { + case 0: + info->version_x = MPEG_2_5; + break; + case 2: + info->version_x = MPEG_2; + break; + case 3: + info->version_x = MPEG_1; + break; + default: + info->version_x = INVALID_VERSION; + err = UNSUPPORTED_LAYER; + break; + } + + info->layer_description = 4 - ((temp << 13) >> 30); /* 2 */ + info->error_protection = !((temp << 15) >> 31); /* 1 */ + + if (info->error_protection) + { + *crc = 0xffff; /* CRC start value */ + calculate_crc((temp << 16) >> 16, 16, crc); + } + + info->bitrate_index = (temp << 16) >> 28; /* 4 */ + info->sampling_frequency = (temp << 20) >> 30; /* 2 */ + info->padding = (temp << 22) >> 31; /* 1 */ + info->extension = (temp << 23) >> 31; /* 1 */ + info->mode = (temp << 24) >> 30; /* 2 */ + info->mode_ext = (temp << 26) >> 30; /* 2 */ + info->copyright = (temp << 27) >> 31; /* 1 */ + info->original = (temp << 28) >> 31; /* 1 */ + info->emphasis = (temp << 30) >> 30; /* 2 */ + + + if (!info->bitrate_index || info->sampling_frequency == 3) + { + err = UNSUPPORTED_FREE_BITRATE; + } + + return(err); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.h new file mode 100644 index 0000000..03a615b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.h @@ -0,0 +1,96 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decode_header.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_DECODE_HEADER_H +#define PVMP3_DECODE_HEADER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "pvmp3_dec_defs.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + ERROR_CODE pvmp3_decode_header(tmp3Bits *inputStream, + mp3Header *info, + uint32 *crc); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.cpp new file mode 100644 index 0000000..d506ba3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.cpp @@ -0,0 +1,750 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decode_huff_cw.cpp + + Funtions: + pvmp3_decode_huff_cw_tab0 + pvmp3_decode_huff_cw_tab1 + pvmp3_decode_huff_cw_tab2 + pvmp3_decode_huff_cw_tab3 + pvmp3_decode_huff_cw_tab5 + pvmp3_decode_huff_cw_tab6 + pvmp3_decode_huff_cw_tab7 + pvmp3_decode_huff_cw_tab8 + pvmp3_decode_huff_cw_tab9 + pvmp3_decode_huff_cw_tab10 + pvmp3_decode_huff_cw_tab11 + pvmp3_decode_huff_cw_tab12 + pvmp3_decode_huff_cw_tab13 + pvmp3_decode_huff_cw_tab15 + pvmp3_decode_huff_cw_tab16 + pvmp3_decode_huff_cw_tab24 + pvmp3_decode_huff_cw_tab32 + pvmp3_decode_huff_cw_tab33 + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + BITS *pMainData = pointer to input mp3 Main data bit stream + + + Outputs: + cw = bit field extracted from a leaf entry of packed mp3 Huffman Tables + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + These functions are used to decode huffman codewords from the input + bitstream using combined binary search and look-up table approach. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + + [2] Introduction to Algorithms, + Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest. + The MIT press, 1990 + + [3] "Selecting an Optimal Huffman Decoder for AAC", + Vladimir Z. Mesarovic, et al. + AES 111th Convention, September 21-24, 2001, New York, USA + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_tables.h" +#include "pvmp3_getbits.h" +#include "pvmp3_decode_huff_cw.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint16 pvmp3_decode_huff_cw_tab0(tmp3Bits *pMainData) +{ + OSCL_UNUSED_ARG(pMainData); + return(0); + +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab1(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 3); /* hufftable1 */ + + cw = *(huffTable_1 + tmp); + pMainData->usedBits -= (3 - (cw & 0xFF)); + return(cw >> 8); + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab2(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 6); /* huffTable_2,3 */ + + if (tmp >> 3) + { + tmp = (tmp >> 3) - 1; + } + else + { + tmp = tmp + 7; + } + + cw = *(huffTable_2 + tmp); + pMainData->usedBits -= (6 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab3(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 6); /* huffTable_2,3 */ + + if (tmp >> 3) + { + tmp = (tmp >> 3) - 1; + } + else + { + tmp = tmp + 7; + } + + cw = *(huffTable_3 + tmp); + pMainData->usedBits -= (6 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab5(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 8); /* huffTable_5 */ + + if ((tmp >> 5)) + { + tmp = (tmp >> 5) - 1; + } + else if ((tmp >> 1) >= 2) + { + tmp = (tmp >> 1) - 2 + 7; + } + else + { + tmp = (tmp & 3) + 21; + } + + cw = *(huffTable_5 + tmp); + pMainData->usedBits -= (8 - (cw & 0xFF)); + + return(cw >> 8); +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab6(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 7); /* huffTable_6 */ + if ((tmp >> 3) >= 3) + { + tmp = (tmp >> 3) - 3; + } + else if (tmp >> 1) + { + tmp = (tmp >> 1) - 1 + 13; + } + else + { + tmp = tmp + 24; + } + + cw = *(huffTable_6 + tmp); + pMainData->usedBits -= (7 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab7(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 10); /* huffTable_7 */ + if ((tmp >> 7) >= 2) + { + tmp = (tmp >> 7) - 2; + } + else if ((tmp >> 4) >= 7) + { + tmp = (tmp >> 4) - 7 + 6; + } + else if ((tmp >> 1) >= 2) + { + tmp = (tmp >> 1) - 2 + 15; + } + else + { + tmp = (tmp & 3) + 69; + } + + cw = *(huffTable_7 + tmp); + pMainData->usedBits -= (10 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab8(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 11); /* huffTable_8 */ + if ((tmp >> 7) >= 2) + { + tmp = (tmp >> 7) - 2; + } + else if ((tmp >> 5) >= 5) + { + tmp = (tmp >> 5) - 5 + 14; + } + else if ((tmp >> 2) >= 3) + { + tmp = (tmp >> 2) - 3 + 17; + } + else + { + tmp = (tmp) + 54; + } + + cw = *(huffTable_8 + tmp); + pMainData->usedBits -= (11 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab9(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 9); /* huffTable_9 */ + if ((tmp >> 5) >= 5) + { + tmp = (tmp >> 5) - 5; + } + else if ((tmp >> 3) >= 6) + { + tmp = (tmp >> 3) - 6 + 11; + } + else if ((tmp >> 1) >= 4) + { + tmp = (tmp >> 1) - 4 + 25; + } + else + { + tmp = tmp + 45; + } + + cw = *(huffTable_9 + tmp); + pMainData->usedBits -= (9 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab10(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 11); /* huffTable_10 */ + if (tmp >> 10) + { + tmp = (tmp >> 10) - 1; + } + else if ((tmp >> 7) >= 3) + { + tmp = (tmp >> 7) - 3 + 1; + } + else if ((tmp >> 5) >= 8) + { + tmp = (tmp >> 5) - 8 + 6; + } + else if ((tmp >> 3) >= 18) + { + tmp = (tmp >> 3) - 18 + 10; + } + else if ((tmp >> 2) >= 24) + { + tmp = (tmp >> 2) - 24 + 24; + } + else if ((tmp >> 1) >= 12) + { + tmp = (tmp >> 1) - 12 + 36; + } + else + { + tmp = (tmp) + 72; + } + + cw = *(huffTable_10 + tmp); + pMainData->usedBits -= (11 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab11(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 11); /* huffTable_11 */ + if ((tmp >> 8) >= 3) + { + tmp = (tmp >> 8) - 3; + } + else if ((tmp >> 6) >= 7) + { + tmp = (tmp >> 6) - 7 + 5; + } + else if ((tmp >> 3) >= 32) + { + tmp = (tmp >> 3) - 32 + 10; + } + else if ((tmp >> 2) >= 10) + { + tmp = (tmp >> 2) - 10 + 34; + } + else if ((tmp >> 1) >= 8) + { + tmp = (tmp >> 1) - 8 + 88; + } + else + { + tmp = (tmp & 0xFF) + 100; + } + cw = *(huffTable_11 + tmp); + pMainData->usedBits -= (11 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab12(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 10); /* huffTable_12 */ + if ((tmp >> 7) >= 5) + { + tmp = (tmp >> 7) - 5; + } + else if ((tmp >> 5) >= 12) + { + tmp = (tmp >> 5) - 12 + 3; + } + else if ((tmp >> 4) >= 17) + { + tmp = (tmp >> 4) - 17 + 11; + } + else if ((tmp >> 2) >= 32) + { + tmp = (tmp >> 2) - 32 + 18; + } + else if ((tmp >> 1) >= 16) + { + tmp = (tmp >> 1) - 16 + 54; + } + else + { + tmp = (tmp & 0x1F) + 102; + + } + cw = *(huffTable_12 + tmp); + pMainData->usedBits -= (10 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab13(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getNbits(pMainData, 19); /* huffTable_13 */ + if (tmp >> 18) + { + tmp = 0; + } + else if ((tmp >> 15) >= 4) + { + tmp = (tmp >> 15) - 4 + 1; + } + else if ((tmp >> 11) >= 32) + { + tmp = (tmp >> 11) - 32 + 5; + } + else if ((tmp >> 9) >= 64) + { + tmp = (tmp >> 9) - 64 + 37; + } + else if ((tmp >> 8) >= 64) + { + tmp = (tmp >> 8) - 64 + 101; + } + else if ((tmp >> 7) >= 64) + { + tmp = (tmp >> 7) - 64 + 165; + } + else if ((tmp >> 6) >= 32) + { + tmp = (tmp >> 6) - 32 + 229; + } + else if ((tmp >> 5) >= 32) + { + tmp = (tmp >> 5) - 32 + 325; + } + else if ((tmp >> 4) >= 32) + { + tmp = (tmp >> 4) - 32 + 357; + } + else if ((tmp >> 3) >= 32) + { + tmp = (tmp >> 3) - 32 + 389; + } + else if ((tmp >> 2) >= 2) + { + tmp = (tmp >> 2) - 2 + 421; + } + else + { + tmp = (tmp & 0x7) + 483; + } + + cw = *(huffTable_13 + tmp); + pMainData->usedBits -= (19 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab15(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 13); /* huffTable_15 */ + if ((tmp >> 9) >= 10) + { + tmp = (tmp >> 9) - 10; + } + else if ((tmp >> 6) >= 39) + { + tmp = (tmp >> 6) - 39 + 6; + } + else if ((tmp >> 4) >= 62) + { + tmp = (tmp >> 4) - 62 + 47; + } + else if ((tmp >> 3) >= 60) + { + tmp = (tmp >> 3) - 60 + 141; + } + else if ((tmp >> 2) >= 64) + { + tmp = (tmp >> 2) - 64 + 205; + } + else if ((tmp >> 1) >= 32) + { + tmp = (tmp >> 1) - 32 + 261; + } + else + { + tmp = (tmp & 0x3f) + 357; + } + + cw = *(huffTable_15 + tmp); + pMainData->usedBits -= (13 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab16(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 17); /* huffTable_16 */ + if (tmp >> 16) + { + tmp = 0; + } + else if ((tmp >> 13) >= 4) + { + tmp = (tmp >> 13) - 4 + 1; + } + else if ((tmp >> 9) >= 38) + { + tmp = (tmp >> 9) - 38 + 5; + } + else if ((tmp >> 7) >= 94) + { + tmp = (tmp >> 7) - 94 + 31; + } + else if ((tmp >> 5) >= 214) + { + tmp = (tmp >> 5) - 214 + 89; + } + else if ((tmp >> 3) >= 704) + { + if ((tmp >> 4) >= 384) + { + tmp = (tmp >> 4) - 384 + 315; + } + else + { + tmp = (tmp >> 3) - 704 + 251; + } + } + else if ((tmp >> 8) >= 14) + { + tmp = (tmp >> 8) - 14 + 359; + } + else if ((tmp) >= 3456) + { + if ((tmp >> 2) >= 868) + { + tmp = (tmp >> 2) - 868 + 383; + } + else + { + tmp = (tmp) - 3456 + 367; + } + } + else + { + tmp = ((tmp >> 6) & 0x3f) + 411; + } + + cw = *(huffTable_16 + tmp); + pMainData->usedBits -= (17 - (cw & 0xFF)); + + return(cw >> 8); +} + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab24(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 12); /* huffTable_24 */ + if ((tmp >> 6) >= 41) + { + tmp = (tmp >> 6) - 41; + } + else if ((tmp >> 3) >= 218) + { + tmp = (tmp >> 3) - 218 + 23; + } + else if ((tmp >> 2) >= 336) + { + tmp = (tmp >> 2) - 336 + 133; + } + else if ((tmp >> 1) >= 520) + { + tmp = (tmp >> 1) - 520 + 233; + } + else if ((tmp) >= 1024) + { + tmp = (tmp) - 1024 + 385; + } + else if ((tmp >> 1) >= 352) + { + if ((tmp >> 8) == 3) + { + tmp = (tmp >> 8) - 3 + 433; + } + else + { + tmp = (tmp >> 1) - 352 + 401; + } + } + else + { + tmp = ((tmp >> 4) & 0x3f) + 434; + } + + cw = *(huffTable_24 + tmp); + pMainData->usedBits -= (12 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab32(tmp3Bits *pMainData) +{ + uint32 tmp = getUpTo9bits(pMainData, 6); /* huffTable_32 */ + if ((tmp >> 5)) + { + pMainData->usedBits -= 5; + return(0); + } + else + { + uint16 cw = *(huffTable_32 + (tmp & 0x1f)); + pMainData->usedBits -= (6 - (cw & 0xFF)); + + return(cw >> 8); + } + +} + + +uint16 pvmp3_decode_huff_cw_tab33(tmp3Bits *pMainData) +{ + + uint16 tmp = getUpTo9bits(pMainData, 4); /* huffTable_33 */ + + return((0x0f - tmp)); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.h new file mode 100644 index 0000000..52c51eb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.h @@ -0,0 +1,107 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decode_huff_cw.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_DECODE_HUFF_CW_H +#define PVMP3_DECODE_HUFF_CW_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "pvmp3_dec_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + uint16 pvmp3_decode_huff_cw_tab0(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab1(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab2(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab3(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab5(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab6(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab7(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab8(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab9(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab10(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab11(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab12(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab13(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab15(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab16(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab24(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab32(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab33(tmp3Bits *); +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decoder.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decoder.cpp new file mode 100644 index 0000000..1dae314 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_decoder.cpp @@ -0,0 +1,427 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decoder.cpp + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Entry point to the mp3 library + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_decoder.h" +#include "oscl_error_codes.h" +#include "oscl_exception.h" +#include "pvmp3_framedecoder.h" +#include "pvmp3_seek_synch.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +#define KMP3_MAX_STREAMING_BUFFER_SIZE BUFSIZE + +#define KCAI_CODEC_INIT_FAILURE -1 + +// Use default DLL entry point +#include "oscl_dll.h" +OSCL_DLL_ENTRY_POINT_DEFAULT() + + +OSCL_EXPORT_REF CPvMP3_Decoder *CPvMP3_Decoder::NewL() +{ + CPvMP3_Decoder *dec = new CPvMP3_Decoder; + + if (dec == NULL) + { + OSCL_LEAVE(OsclErrNoMemory); + } + else + { + dec->ConstructL(); + } + + return dec; +} + + +OSCL_EXPORT_REF void CPvMP3_Decoder::ConstructL() +{ + // Initialize member variables + pMem = NULL; + iInputBuf = NULL; + iOutputBuf = NULL; +} + + +/* +----------------------------------------------------------------------------- + + CPvMP3_Decoder + + ~CPvMP3_Decoder + + Empty decoder destructor. + + Parameters: none + + Return Values: none + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF CPvMP3_Decoder::~CPvMP3_Decoder() +{ + if (pMem != NULL) + { + OSCL_ARRAY_DELETE(pMem); + pMem = NULL; + } + + if (iAllocateInputBuffer && iInputBuf) + { + OSCL_ARRAY_DELETE(iInputBuf); + iInputBuf = NULL; + } + + if (iAllocateOutputBuffer && iOutputBuf) + { + OSCL_ARRAY_DELETE(iOutputBuf); + iOutputBuf = NULL; + } +} + + +/* +----------------------------------------------------------------------------- + + CPvMP3_Decoder + + StartL + + Start decoder object. Initialize codec status. + + Parameters: none + + Return Values: status + +----------------------------------------------------------------------------- +*/ + +OSCL_EXPORT_REF int32 CPvMP3_Decoder::StartL(tPVMP3DecoderExternal * pExt, + bool aAllocateInputBuffer, + bool aAllocateOutputBuffer, + bool crcEnabler, + e_equalization equalizType) +{ + + iAllocateInputBuffer = aAllocateInputBuffer; + iAllocateOutputBuffer = aAllocateOutputBuffer; + + if (iAllocateInputBuffer) + { + iInputBuf = OSCL_ARRAY_NEW(uint8, KMP3_MAX_STREAMING_BUFFER_SIZE); + if (iInputBuf == NULL) + { + return KCAI_CODEC_INIT_FAILURE; + } +// pExt->inputBufferMaxLength = KMP3_MAX_STREAMING_BUFFER_SIZE; + pExt->inputBufferMaxLength = 512; + } + else + { + iInputBuf = NULL; + pExt->inputBufferMaxLength = 0; + } + pExt->pInputBuffer = iInputBuf; + + if (iAllocateOutputBuffer) + { + iOutputBuf = OSCL_ARRAY_NEW(int16, (KMP3_MAX_OUTPUT_SIZE >> 1)); + + if (iOutputBuf == NULL) + { + return KCAI_CODEC_INIT_FAILURE; + } + + pExt->outputFrameSize = (KMP3_MAX_OUTPUT_SIZE >> 1); + } + else + { + iOutputBuf = NULL; + pExt->outputFrameSize = 0; + + } + pExt->pOutputBuffer = iOutputBuf; + + pExt->crcEnabled = crcEnabler; + pExt->equalizerType = equalizType; /* Dynamically enable equalizing type */ + + int32 memreq = pvmp3_decoderMemRequirements(); + + pMem = OSCL_ARRAY_NEW(uint8 , memreq); + + if (pMem == 0) + { + return KCAI_CODEC_INIT_FAILURE; + } + + pvmp3_InitDecoder(pExt, pMem); + + + return SUCCESS; +} + + +/* +----------------------------------------------------------------------------- + + CPvMP3_Decoder + + ExecuteL + + Execute decoder object. Read one encoded mp3 frame from the input + stream, decode it and write the decoded frame to output stream. + + Parameters: + tPVMP3DecoderExternal * pExt, pointer to decoder external state variables + + Return Values: status + + +----------------------------------------------------------------------------- +*/ + +OSCL_EXPORT_REF int32 CPvMP3_Decoder::ExecuteL(tPVMP3DecoderExternal * pExt) +{ + ERROR_CODE errorCode = NO_DECODING_ERROR; + int32 status; + + errorCode = pvmp3_framedecoder(pExt, pMem); + + + switch (errorCode) + { + case NO_DECODING_ERROR: + + status = MP3DEC_SUCCESS; + break; + + case NO_ENOUGH_MAIN_DATA_ERROR: + + status = MP3DEC_INCOMPLETE_FRAME; + break; + + case OUTPUT_BUFFER_TOO_SMALL: + + status = MP3DEC_OUTPUT_BUFFER_TOO_SMALL; + break; + + case UNSUPPORTED_LAYER: + case UNSUPPORTED_FREE_BITRATE: + case CHANNEL_CONFIG_ERROR: + case SYNTHESIS_WINDOW_ERROR: + case SIDE_INFO_ERROR: + case HUFFMAN_TABLE_ERROR: + case SYNCH_LOST_ERROR: + default: + + status = MP3DEC_INVALID_FRAME; + break; + + } + + + return status; +} + +/* +----------------------------------------------------------------------------- + + CPvMP3_Decoder + + StopL + + Stop decoder object. Flush out last frame + + Parameters: + tPVMP3DecoderExternal * pExt, pointer to decoder external state variables + + + Return Values: none + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF void CPvMP3_Decoder::StopL() +{ + pvmp3_resetDecoder(pMem); +} + +/* +----------------------------------------------------------------------------- + + CPvMP3_Decoder + + ResetDecoderL + + Stop decoder object. Reset decoder. + + Parameters: + tPVMP3DecoderExternal * pExt, pointer to decoder external state variables + + + Return Values: status + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF void CPvMP3_Decoder::ResetDecoderL() +{ + + pvmp3_resetDecoder(pMem); +} + + +/* +----------------------------------------------------------------------------- + + CPvMP3_Decoder + + TerminateDecoderL + + Stop decoder object. close decoder. + + Parameters: none + + Return Values: none + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF void CPvMP3_Decoder::TerminateDecoderL() +{ + if (pMem != NULL) + { + OSCL_ARRAY_DELETE(pMem); + pMem = NULL; + } + + if (iAllocateInputBuffer && iInputBuf) + { + OSCL_ARRAY_DELETE(iInputBuf); + iInputBuf = NULL; + } + + if (iAllocateOutputBuffer && iOutputBuf) + { + OSCL_ARRAY_DELETE(iOutputBuf); + iOutputBuf = NULL; + } +} + + + +/* +----------------------------------------------------------------------------- + + CPvMP3_Decoder + + SeekMp3Synchronization + + Utility to seek for the mp3 frames boundaries. + + Parameters: + tPVMP3DecoderExternal * pExt, pointer to decoder external state variables + + Return Values: status + +----------------------------------------------------------------------------- +*/ +OSCL_EXPORT_REF int32 CPvMP3_Decoder::SeekMp3Synchronization( + tPVMP3DecoderExternal * pExt) +{ + ERROR_CODE errorCode = NO_DECODING_ERROR; + + errorCode = pvmp3_frame_synch(pExt, pMem); + + if (errorCode != NO_DECODING_ERROR) + { + return 1; + } + else + { + return 0; + } +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.cpp new file mode 100644 index 0000000..b55b48e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.cpp @@ -0,0 +1,444 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dequantize_sample.cpp + + Functions: + power_1_third + pvmp3_dequantize_sample + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +power_1_third +int32 power_1_third( int32 xx) + +Input + int32 xx, int32 in the [0, 8192] range + + Returns + + int32 xx^(1/3) int32 Q26 number representing + the 1/3 power of the input + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +pvmp3_dequantize_sample + +Input + int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, scale factor structure + struct gr_info_s *gr_info, granule structure informatiom + mp3Header *info mp3 header info + + Returns + + int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], dequantize output as (.)^(4/3) + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + dequantize sample + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_dequantize_sample.h" +#include "pvmp3_normalize.h" +#include "mp3_mem_funcs.h" +#include "pvmp3_tables.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define Q30_fmt(a)(int32(double(0x40000000)*a)) +#define Q29_fmt(a)(int32(double(0x20000000)*a)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 pretab[22] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0}; + +const int32 pow_2_1_fourth[4] = +{ + Q30_fmt(1.0), Q30_fmt(1.18920711500272), + Q30_fmt(1.41421356237310), Q30_fmt(1.68179283050743) +}; + +const int32 two_cubic_roots[7] = +{ + Q29_fmt(0), Q29_fmt(1.25992104989487), + Q29_fmt(1.58740105196820), Q29_fmt(2.00000000000000), + Q29_fmt(2.51984209978975), Q29_fmt(3.17480210393640), + Q29_fmt(3.99999999999999) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +int32 power_1_third(int32 xx) +{ + + if (xx <= 512) + { + return (power_one_third[xx] >> 1); + } + else + { + if (xx >> 15) + { + return 0x7FFFFFFF; /* saturate any value over 32767 */ + } + else + { + int32 x = xx; + int32 m = 22 - pvmp3_normalize(xx); + + xx >>= m; + xx = (power_one_third[xx]) + (((power_one_third[xx+1] - power_one_third[xx]) >> m) * (x & ((1 << m) - 1))); + return (fxp_mul32_Q30(xx, two_cubic_roots[m])); + } + + } +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void pvmp3_dequantize_sample(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, + granuleInfo *gr_info, + int32 used_freq_lines, + mp3Header *info) +{ + int32 ss; + int32 cb = 0; + int32 global_gain; + int32 sfreq = info->sampling_frequency + info->version_x + (info->version_x << 1); + + /* apply formula per block type */ + + if (gr_info->window_switching_flag && (gr_info->block_type == 2)) + { + int32 next_cb_boundary; + int32 cb_begin = 0; + int32 cb_width = 0; + int32 mixstart = 8; /* added 2003/08/21 efs */ + + if (info->version_x != MPEG_1) + { + mixstart = 6; /* different value in MPEG2 LSF */ + } + + if (gr_info->mixed_block_flag) + { + next_cb_boundary = mp3_sfBandIndex[sfreq].l[1]; /* LONG blocks: 0,1,3 */ + } + else + { + next_cb_boundary = mp3_sfBandIndex[sfreq].s[1] * 3; /* pure SHORT block */ + cb_width = 0; + } + + global_gain = gr_info->global_gain; + int32 two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3]; + global_gain = 12 + (global_gain >> 2); + + for (ss = 0 ; ss < used_freq_lines ; ss++) + { + if (ss == next_cb_boundary) + { + cb++; /* critical band counter */ + if (gr_info->mixed_block_flag) + { + if (next_cb_boundary == mp3_sfBandIndex[sfreq].l[mixstart]) + { + next_cb_boundary = mp3_sfBandIndex[sfreq].s[4] * 3; + + cb_begin = mp3_sfBandIndex[sfreq].s[3] * 3; + cb_width = 3; + cb = 3; + } + else if (ss < mp3_sfBandIndex[sfreq].l[mixstart]) + { + next_cb_boundary = mp3_sfBandIndex[sfreq].l[cb+1]; + } + else + { + next_cb_boundary = mp3_sfBandIndex[sfreq].s[cb+1] * 3; + + cb_width = cb; + cb_begin = mp3_sfBandIndex[sfreq].s[cb] * 3; + } + + if (ss < 2*FILTERBANK_BANDS) + { /* 1st 2 subbands of switched blocks */ + global_gain = (gr_info->global_gain); + global_gain -= (1 + gr_info->scalefac_scale) * + (scalefac->l[cb] + gr_info->preflag * pretab[cb]) << 1; + + two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3]; + global_gain = 12 + (global_gain >> 2); + } + } + else + { + next_cb_boundary = mp3_sfBandIndex[sfreq].s[cb+1] * 3; + cb_width = cb; + cb_begin = mp3_sfBandIndex[sfreq].s[cb] * 3; + } + + } /* end-if ( ss == next_cb_boundary) */ + + /* Do long/short dependent scaling operations. */ + if ((gr_info->mixed_block_flag == 0) || (gr_info->mixed_block_flag && (ss >= 2*FILTERBANK_BANDS))) + { + int32 temp2 = fxp_mul32_Q32((ss - cb_begin) << 16, mp3_shortwindBandWidths[sfreq][cb_width]); + temp2 = (temp2 + 1) >> 15; + + global_gain = (gr_info->global_gain); + global_gain -= gr_info->subblock_gain[temp2] << 3; + global_gain -= (1 + gr_info->scalefac_scale) * (scalefac->s[temp2][cb] << 1); + + two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3]; + global_gain = 12 + (global_gain >> 2); + + } + + + /* + * xr[sb][ss] = 2^(global_gain/4) + */ + + /* Scale quantized value. */ + + /* 0 < abs(is[ss]) < 8192 */ + + int32 tmp = fxp_mul32_Q30((is[ss] << 16), power_1_third(pv_abs(is[ ss]))); + + tmp = fxp_mul32_Q30(tmp, two_raise_one_fourth); + + if (global_gain < 0) + { + int32 temp = - global_gain; + if (temp < 32) + { + is[ss] = (tmp >> temp); + } + else + { + is[ss] = 0; + } + } + else + { + is[ss] = (tmp << global_gain); + } + + } /* for (ss=0 ; ss < used_freq_lines ; ss++) */ + + } + else + { + + for (cb = 0 ; cb < 22 ; cb++) + { + + /* Compute overall (global) scaling. */ + + global_gain = (gr_info->global_gain); + + global_gain -= (1 + gr_info->scalefac_scale) * + (scalefac->l[cb] + gr_info->preflag * pretab[cb]) << 1; + + + int32 two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3]; + global_gain = 12 + (global_gain >> 2); + + /* + * xr[sb][ss] = 2^(global_gain/4) + */ + + /* Scale quantized value. */ + + if (used_freq_lines >= mp3_sfBandIndex[sfreq].l[cb+1]) + { + if (global_gain <= 0) + { + global_gain = - global_gain; + if (global_gain < 32) + { + for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < mp3_sfBandIndex[sfreq].l[cb+1]; ss += 2) + { + int32 tmp = is[ss]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain; + } + tmp = is[ss+1]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss+1] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain; + } + } + } + else + { + pv_memset(&is[ mp3_sfBandIndex[sfreq].l[cb]], + 0, + (mp3_sfBandIndex[sfreq].l[cb+1] - mp3_sfBandIndex[sfreq].l[cb])*sizeof(*is)); + } + } + else + { + for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < mp3_sfBandIndex[sfreq].l[cb+1]; ss += 2) + { + int32 tmp = is[ss]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) << global_gain; + } + + tmp = is[ss+1]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss+1] = fxp_mul32_Q30(tmp, two_raise_one_fourth) << global_gain; + } + } + } + } + else + { + if (global_gain <= 0) + { + global_gain = - global_gain; + if (global_gain < 32) + { + for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < used_freq_lines; ss += 2) + { + int32 tmp = is[ss]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain; + } + tmp = is[ss+1]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss+1] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain; + } + } + + } + else + { + pv_memset(&is[ mp3_sfBandIndex[sfreq].l[cb]], + 0, + (mp3_sfBandIndex[sfreq].l[cb+1] - mp3_sfBandIndex[sfreq].l[cb])*sizeof(*is)); + } + } + else + { + for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < used_freq_lines; ss++) + { + int32 tmp = is[ss]; + + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) << global_gain; + } + } + } + + cb = 22; // force breaking out of the loop + + } /* if ( used_freq_lines >= mp3_sfBandIndex[sfreq].l[cb+1]) */ + + } /* for (cb=0 ; cb < 22 ; cb++) */ + + } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */ + + + pv_memset(&is[used_freq_lines], + 0, + (FILTERBANK_BANDS*SUBBANDS_NUMBER - used_freq_lines)*sizeof(*is)); + +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.h new file mode 100644 index 0000000..5e9193a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dequantize_sample.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_DEQUANTIZE_SAMPLE_H +#define PVMP3_DEQUANTIZE_SAMPLE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + int32 power_1_third(int32 xx); + + void pvmp3_dequantize_sample(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, + granuleInfo *gr_info, + int32 num_lines, + mp3Header *info); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.cpp new file mode 100644 index 0000000..e55b220 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.cpp @@ -0,0 +1,406 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_equalizer.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Input + int32 *inData, pointer to the spectrum frequency-line + e_equalization equalizerType, equalization mode + int32 *pt_work_buff + + Output + int32 *pt_work_buff pointer to the equalized frequency-line + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Equalizer + Each subband sample is scaled according to a spectrum shape setting + defined by "equalizerType" + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_equalizer.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define LEVEL__0__dB 0.999999970f +#define LEVEL__1_5dB 0.841395142f +#define LEVEL__3__dB 0.707106781f +#define LEVEL__4_5dB 0.595662143f +#define LEVEL__6__dB 0.500000000f +#define LEVEL__7_5dB 0.421696503f +#define LEVEL__9__dB 0.353553393f +#define LEVEL_12__dB 0.250000000f +#define LEVEL_15__dB 0.176776695f +#define LEVEL_18__dB 0.125000000f +#define LEVEL_21__dB 0.088388347f +#define LEVEL_30__dB 0.031250000f +#define LEVEL_45__dB 0.005524271f +#define LEVEL_60__dB 0.000976562f + +#define Qmf31( x) (int32)(x*(float)0x7FFFFFFF) + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const int32 equalizerTbl[8][SUBBANDS_NUMBER] = +{ + /* FLAT */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB) + }, + /* BASS BOOST */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__1_5dB), Qmf31(LEVEL__3__dB), + + Qmf31(LEVEL__4_5dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB) + }, + /* ROCK */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__1_5dB), Qmf31(LEVEL__3__dB), + + Qmf31(LEVEL__4_5dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__1_5dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB) + }, + /* POP */ + { + Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + + Qmf31(LEVEL__1_5dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB) + }, + /* JAZZ */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__1_5dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB) + }, + /* CLASSICAL */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__1_5dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB) + }, + /* TALK */ + { + Qmf31(LEVEL__9__dB), + + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__1_5dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB) + }, + /* FLAT */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB) + } +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_equalizer(int32 *circ_buffer, + e_equalization equalizerType, + int32 *work_buff) +{ + + if (equalizerType == flat) + { + for (int32 band = 0; band < FILTERBANK_BANDS; band += 2) + { + + int32 *pt_work_buff = &work_buff[band]; + int32 *inData = &circ_buffer[544 - (band<<5)]; + + int32 i; + for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2) + { + int32 temp1 = (pt_work_buff[ i ]); + int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]); + int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]); + int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]); + *(inData++) = temp1; + *(inData++) = temp2; + *(inData++) = temp3; + *(inData++) = temp4; + } + + inData -= SUBBANDS_NUMBER << 1; + pt_work_buff++; + + for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2) + { + int32 temp1 = (pt_work_buff[ i ]); + int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]); + int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]); + int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]); + *(inData++) = temp1; + *(inData++) = temp2; + *(inData++) = temp3; + *(inData++) = temp4; + } + } + } + else + { + const int32 *pt_equalizer = equalizerTbl[equalizerType&7]; + + + for (int32 band = 0; band < FILTERBANK_BANDS; band += 3) + { + int32 *inData = &circ_buffer[544 - (band<<5)]; + + int32 *pt_work_buff = &work_buff[band]; + int32 i; + + for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2) + { + int32 temp1 = (pt_work_buff[ i ]); + int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]); + int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]); + int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]); + *(inData++) = fxp_mul32_Q32(temp1 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp2 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp3 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp4 << 1, *(pt_equalizer++)); + } + + pt_equalizer -= SUBBANDS_NUMBER; + + inData -= SUBBANDS_NUMBER << 1; + pt_work_buff++; + + for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2) + { + int32 temp1 = (pt_work_buff[ i ]); + int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]); + int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]); + int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]); + *(inData++) = fxp_mul32_Q32(temp1 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp2 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp3 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp4 << 1, *(pt_equalizer++)); + } + pt_equalizer -= SUBBANDS_NUMBER; + + } + } +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.h new file mode 100644 index 0000000..1baa285 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_EQUALIZER_H +#define PVMP3_EQUALIZER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "pvmp3decoder_api.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_equalizer(int32 *inData, + e_equalization equalizerType, + int32 *pt_work_buff); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.cpp new file mode 100644 index 0000000..50c052a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.cpp @@ -0,0 +1,826 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_framedecoder.cpp + + Functions: + pvmp3_framedecoder + pvmp3_InitDecoder + pvmp3_resetDecoder + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + pExt = pointer to the external interface structure. See the file + pvmp3decoder_api.h for a description of each field. + Data type of pointer to a tPVMP3DecoderExternal + structure. + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tmp3dec_file structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tmp3dec_file + structure. + + + Outputs: + status = ERROR condition. see structure ERROR_CODE + + Pointers and Buffers Modified: + pMem contents are modified. + pExt: (more detail in the file pvmp3decoder_api.h) + inputBufferUsedLength - number of array elements used up by the stream. + samplingRate - sampling rate in samples per sec + bitRate - bit rate in bits per second, varies frame to frame. + + + +------------------------------------------------------------------------------ + FUNCTIONS DESCRIPTION + + pvmp3_framedecoder + frame decoder library driver + pvmp3_InitDecoder + Decoder Initialization + pvmp3_resetDecoder + Reset Decoder + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + + +#include "pvmp3_framedecoder.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_poly_phase_synthesis.h" +#include "pvmp3_tables.h" +#include "pvmp3_imdct_synth.h" +#include "pvmp3_alias_reduction.h" +#include "pvmp3_reorder.h" +#include "pvmp3_dequantize_sample.h" +#include "pvmp3_stereo_proc.h" +#include "pvmp3_mpeg2_stereo_proc.h" +#include "pvmp3_get_side_info.h" +#include "pvmp3_get_scale_factors.h" +#include "pvmp3_mpeg2_get_scale_factors.h" +#include "pvmp3_decode_header.h" +#include "pvmp3_get_main_data_size.h" +#include "s_tmp3dec_file.h" +#include "pvmp3_getbits.h" +#include "mp3_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +ERROR_CODE pvmp3_framedecoder(tPVMP3DecoderExternal *pExt, + void *pMem) +{ + + ERROR_CODE errorCode = NO_DECODING_ERROR; + + int32 crc_error_count = 0; + uint32 sent_crc = 0; + uint32 computed_crc = 0; + + tmp3dec_chan *pChVars[CHAN]; + tmp3dec_file *pVars = (tmp3dec_file *)pMem; + + mp3Header info_data; + mp3Header *info = &info_data; + + pVars->inputStream.pBuffer = pExt->pInputBuffer; + + + pVars->inputStream.usedBits = pExt->inputBufferUsedLength << 3; + pVars->inputStream.inputBufferCurrentLength = pExt->inputBufferCurrentLength; + + + errorCode = pvmp3_decode_header(&pVars->inputStream, + info, + &computed_crc); + + if (errorCode != NO_DECODING_ERROR) + { + pExt->outputFrameSize = 0; + return errorCode; + } + + pVars->num_channels = (info->mode == MPG_MD_MONO) ? 1 : 2; + pExt->num_channels = pVars->num_channels; + + int32 outputFrameSize = (info->version_x == MPEG_1) ? + 2 * SUBBANDS_NUMBER * FILTERBANK_BANDS : + SUBBANDS_NUMBER * FILTERBANK_BANDS; + + outputFrameSize = (info->mode == MPG_MD_MONO) ? outputFrameSize : outputFrameSize << 1; + + + /* + * Check if output buffer has enough room to hold output PCM + */ + if (pExt->outputFrameSize >= outputFrameSize) + { + pExt->outputFrameSize = outputFrameSize; + } + else + { + pExt->outputFrameSize = 0; + return OUTPUT_BUFFER_TOO_SMALL; + } + + + pChVars[ LEFT] = &pVars->perChan[ LEFT]; + pChVars[RIGHT] = &pVars->perChan[RIGHT]; + + + + + if (info->error_protection) + { + /* + * Get crc content + */ + sent_crc = getUpTo17bits(&pVars->inputStream, 16); + } + + + if (info->layer_description == 3) + { + int32 gr; + int32 ch; + uint32 main_data_end; + int32 bytes_to_discard; + int16 *ptrOutBuffer = pExt->pOutputBuffer; + + /* + * Side Information must be extracted from the bitstream and store for use + * during the decoded of the associated frame + */ + + errorCode = pvmp3_get_side_info(&pVars->inputStream, + &pVars->sideInfo, + info, + &computed_crc); + + if (errorCode != NO_DECODING_ERROR) + { + pExt->outputFrameSize = 0; + return errorCode; + } + + /* + * If CRC was sent, check that matches the one got while parsing data + * disable crc if this is the desired mode + */ + if (info->error_protection) + { + if ((computed_crc != sent_crc) && pExt->crcEnabled) + { + crc_error_count++; + } + } + + /* + * main data (scalefactors, Huffman coded, etc,) are not necessarily located + * adjacent to the side-info. Beginning of main data is located using + * field "main_data_begin" of the current frame. The length does not include + * header and side info. + * "main_data_begin" points to the first bit of main data of a frame. It is a negative + * offset in bytes from the first byte of the sync word + * main_data_begin = 0 <===> main data start rigth after side info. + */ + + int32 temp = pvmp3_get_main_data_size(info, pVars); + + + /* + * Check if available data holds a full frame, if not flag an error + */ + + if ((uint32)pVars->predicted_frame_size > pVars->inputStream.inputBufferCurrentLength) + { + pExt->outputFrameSize = 0; + return NO_ENOUGH_MAIN_DATA_ERROR; + } + + /* + * Fill in internal circular buffer + */ + fillMainDataBuf(pVars, temp); + + + main_data_end = pVars->mainDataStream.usedBits >> 3; /* in bytes */ + if ((main_data_end << 3) < pVars->mainDataStream.usedBits) + { + main_data_end++; + pVars->mainDataStream.usedBits = main_data_end << 3; + } + + + bytes_to_discard = pVars->frame_start - pVars->sideInfo.main_data_begin - main_data_end; + + + if (main_data_end > BUFSIZE) /* check overflow on the buffer */ + { + pVars->frame_start -= BUFSIZE; + + pVars->mainDataStream.usedBits -= (BUFSIZE << 3); + } + + pVars->frame_start += temp; + + + if (bytes_to_discard < 0 || crc_error_count) + { + /* + * Not enough data to decode, then we should avoid reading this + * data ( getting/ignoring sido info and scale data) + * Main data could be located in the previous frame, so an unaccounted + * frame can cause incorrect processing + * Just run the polyphase filter to "clean" the history buffer + */ + errorCode = NO_ENOUGH_MAIN_DATA_ERROR; + + /* + * Clear the input to these filters + */ + + pv_memset((void*)pChVars[RIGHT]->work_buf_int32, + 0, + SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[RIGHT]->work_buf_int32[0])); + + pv_memset((void*)pChVars[LEFT]->work_buf_int32, + 0, + SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[LEFT]->work_buf_int32[0])); + + /* clear circular buffers, to avoid any glitch */ + pv_memset((void*)&pChVars[ LEFT]->circ_buffer[576], + 0, + 480*sizeof(pChVars[ LEFT]->circ_buffer[0])); + pv_memset((void*)&pChVars[RIGHT]->circ_buffer[576], + 0, + 480*sizeof(pChVars[RIGHT]->circ_buffer[0])); + + pChVars[ LEFT]->used_freq_lines = 575; + pChVars[RIGHT]->used_freq_lines = 575; + + } + else + { + pVars->mainDataStream.usedBits += (bytes_to_discard << 3); + } + + /* + * if (fr_ps->header->version_x == MPEG_1), use 2 granules, otherwise just 1 + */ + for (gr = 0; gr < (1 + !(info->version_x)); gr++) + { + if (errorCode != NO_ENOUGH_MAIN_DATA_ERROR) + { + for (ch = 0; ch < pVars->num_channels; ch++) + { + int32 part2_start = pVars->mainDataStream.usedBits; + + if (info->version_x == MPEG_1) + { + + pvmp3_get_scale_factors(&pVars->scaleFactors[ch], + &pVars->sideInfo, + gr, + ch, + &pVars->mainDataStream); + } + else + { + int32 * tmp = pVars->Scratch_mem; + pvmp3_mpeg2_get_scale_factors(&pVars->scaleFactors[ch], + &pVars->sideInfo, + gr, + ch, + info, + (uint32 *)tmp, + &pVars->mainDataStream); + } + + pChVars[ch]->used_freq_lines = pvmp3_huffman_parsing(pChVars[ch]->work_buf_int32, + &pVars->sideInfo.ch[ch].gran[gr], + pVars, + part2_start, + info); + + + pvmp3_dequantize_sample(pChVars[ch]->work_buf_int32, + &pVars->scaleFactors[ch], + &pVars->sideInfo.ch[ch].gran[gr], + pChVars[ch]->used_freq_lines, + info); + + + + + } /* for (ch=0; chnum_channels == 2) + { + + int32 used_freq_lines = (pChVars[ LEFT]->used_freq_lines > + pChVars[RIGHT]->used_freq_lines) ? + pChVars[ LEFT]->used_freq_lines : + pChVars[RIGHT]->used_freq_lines; + + pChVars[ LEFT]->used_freq_lines = used_freq_lines; + pChVars[RIGHT]->used_freq_lines = used_freq_lines; + + if (info->version_x == MPEG_1) + { + pvmp3_stereo_proc(pChVars[ LEFT]->work_buf_int32, + pChVars[RIGHT]->work_buf_int32, + &pVars->scaleFactors[RIGHT], + &pVars->sideInfo.ch[LEFT].gran[gr], + used_freq_lines, + info); + } + else + { + int32 * tmp = pVars->Scratch_mem; + pvmp3_mpeg2_stereo_proc(pChVars[ LEFT]->work_buf_int32, + pChVars[RIGHT]->work_buf_int32, + &pVars->scaleFactors[RIGHT], + &pVars->sideInfo.ch[ LEFT].gran[gr], + &pVars->sideInfo.ch[RIGHT].gran[gr], + (uint32 *)tmp, + used_freq_lines, + info); + } + } + + } /* if ( errorCode != NO_ENOUGH_MAIN_DATA_ERROR) */ + + for (ch = 0; ch < pVars->num_channels; ch++) + { + + pvmp3_reorder(pChVars[ch]->work_buf_int32, + &pVars->sideInfo.ch[ch].gran[gr], + &pChVars[ ch]->used_freq_lines, + info, + pVars->Scratch_mem); + + pvmp3_alias_reduction(pChVars[ch]->work_buf_int32, + &pVars->sideInfo.ch[ch].gran[gr], + &pChVars[ ch]->used_freq_lines, + info); + + + /* + * IMDCT + */ + /* set mxposition + * In case of mixed blocks, # of bands with long + * blocks (2 or 4) else 0 + */ + uint16 mixedBlocksLongBlocks = 0; /* 0 = long or short, 2=mixed, 4=mixed 2.5@8000 */ + if (pVars->sideInfo.ch[ch].gran[gr].mixed_block_flag && + pVars->sideInfo.ch[ch].gran[gr].window_switching_flag) + { + if ((info->version_x == MPEG_2_5) && (info->sampling_frequency == 2)) + { + mixedBlocksLongBlocks = 4; /* mpeg2.5 @ 8 KHz */ + } + else + { + mixedBlocksLongBlocks = 2; + } + } + + pvmp3_imdct_synth(pChVars[ch]->work_buf_int32, + pChVars[ch]->overlap, + pVars->sideInfo.ch[ch].gran[gr].block_type, + mixedBlocksLongBlocks, + pChVars[ ch]->used_freq_lines, + pVars->Scratch_mem); + + + /* + * Polyphase synthesis + */ + + pvmp3_poly_phase_synthesis(pChVars[ch], + pVars->num_channels, + pExt->equalizerType, + &ptrOutBuffer[ch]); + + + }/* end ch loop */ + + ptrOutBuffer += pVars->num_channels * SUBBANDS_NUMBER * FILTERBANK_BANDS; + } /* for (gr=0;grbitrate_index > 0) + { /* if not free-format */ + + int32 ancillary_data_lenght = pVars->predicted_frame_size << 3; + + ancillary_data_lenght -= pVars->inputStream.usedBits; + + /* skip ancillary data */ + if (ancillary_data_lenght > 0) + { + pVars->inputStream.usedBits += ancillary_data_lenght; + } + + } + + /* + * This overrides a possible NO_ENOUGH_MAIN_DATA_ERROR + */ + errorCode = NO_DECODING_ERROR; + + } + else + { + /* + * The info on the header leads to an unsupported layer, more data + * will not fix this, so this is a bad frame, + */ + + pExt->outputFrameSize = 0; + return UNSUPPORTED_LAYER; + } + + pExt->inputBufferUsedLength = pVars->inputStream.usedBits >> 3; + pExt->totalNumberOfBitsUsed += pVars->inputStream.usedBits; + pExt->version = info->version_x; + pExt->samplingRate = mp3_s_freq[info->version_x][info->sampling_frequency]; + pExt->bitRate = mp3_bitrate[pExt->version][info->bitrate_index]; + + + /* + * Always verify buffer overrun condition + */ + + if (pExt->inputBufferUsedLength > pExt->inputBufferCurrentLength) + { + pExt->outputFrameSize = 0; + errorCode = NO_ENOUGH_MAIN_DATA_ERROR; + } + + return errorCode; + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +__inline void fillDataBuf(tmp3Bits *pMainData, + uint32 val) /* val to write into the buffer */ +{ + pMainData->pBuffer[module(pMainData->offset++, BUFSIZE)] = (uint8)val; +} + + +void fillMainDataBuf(void *pMem, int32 temp) +{ + tmp3dec_file *pVars = (tmp3dec_file *)pMem; + + + int32 offset = (pVars->inputStream.usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + /* + * Check if input circular buffer boundaries need to be enforced + */ + if ((offset + temp) < BUFSIZE) + { + uint8 * ptr = pVars->inputStream.pBuffer + offset; + + offset = pVars->mainDataStream.offset; + + /* + * Check if main data circular buffer boundaries need to be enforced + */ + if ((offset + temp) < BUFSIZE) + { + pv_memcpy((pVars->mainDataStream.pBuffer + offset), ptr, temp*sizeof(uint8)); + pVars->mainDataStream.offset += temp; + } + else + { + int32 tmp1 = *(ptr++); + for (int32 nBytes = temp >> 1; nBytes != 0; nBytes--) /* read main data. */ + { + int32 tmp2 = *(ptr++); + fillDataBuf(&pVars->mainDataStream, tmp1); + fillDataBuf(&pVars->mainDataStream, tmp2); + tmp1 = *(ptr++); + } + + if (temp&1) + { + fillDataBuf(&pVars->mainDataStream, tmp1); + } + + /* adjust circular buffer counter */ + pVars->mainDataStream.offset = module(pVars->mainDataStream.offset, BUFSIZE); + } + } + else + { + for (int32 nBytes = temp >> 1; nBytes != 0; nBytes--) /* read main data. */ + { + fillDataBuf(&pVars->mainDataStream, *(pVars->inputStream.pBuffer + module(offset++ , BUFSIZE))); + fillDataBuf(&pVars->mainDataStream, *(pVars->inputStream.pBuffer + module(offset++ , BUFSIZE))); + } + if (temp&1) + { + fillDataBuf(&pVars->mainDataStream, *(pVars->inputStream.pBuffer + module(offset , BUFSIZE))); + } + } + + + pVars->inputStream.usedBits += (temp) << INBUF_ARRAY_INDEX_SHIFT; +} + + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint32 pvmp3_decoderMemRequirements(void) +{ + uint32 size; + + size = (uint32) sizeof(tmp3dec_file); + return (size); +} + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +#include "pvmp3_decode_huff_cw.h" + +void pvmp3_InitDecoder(tPVMP3DecoderExternal *pExt, + void *pMem) +{ + + tmp3dec_file *pVars; + huffcodetab *pHuff; + + pVars = (tmp3dec_file *)pMem; + + pVars->num_channels = 0; + + pExt->totalNumberOfBitsUsed = 0; + pExt->inputBufferCurrentLength = 0; + pExt->inputBufferUsedLength = 0; + + pVars->mainDataStream.offset = 0; + + pv_memset((void*)pVars->mainDataBuffer, + 0, + BUFSIZE*sizeof(*pVars->mainDataBuffer)); + + + pVars->inputStream.pBuffer = pExt->pInputBuffer; + + /* + * Initialize huffman decoding table + */ + + pHuff = pVars->ht; + pHuff[0].linbits = 0; + pHuff[0].pdec_huff_tab = pvmp3_decode_huff_cw_tab0; + pHuff[1].linbits = 0; + pHuff[1].pdec_huff_tab = pvmp3_decode_huff_cw_tab1; + pHuff[2].linbits = 0; + pHuff[2].pdec_huff_tab = pvmp3_decode_huff_cw_tab2; + pHuff[3].linbits = 0; + pHuff[3].pdec_huff_tab = pvmp3_decode_huff_cw_tab3; + pHuff[4].linbits = 0; + pHuff[4].pdec_huff_tab = pvmp3_decode_huff_cw_tab0; /* tbl 4 is not used */ + pHuff[5].linbits = 4; + pHuff[5].pdec_huff_tab = pvmp3_decode_huff_cw_tab5; + pHuff[6].linbits = 0; + pHuff[6].pdec_huff_tab = pvmp3_decode_huff_cw_tab6; + pHuff[7].linbits = 0; + pHuff[7].pdec_huff_tab = pvmp3_decode_huff_cw_tab7; + pHuff[8].linbits = 0; + pHuff[8].pdec_huff_tab = pvmp3_decode_huff_cw_tab8; + pHuff[9].linbits = 0; + pHuff[9].pdec_huff_tab = pvmp3_decode_huff_cw_tab9; + pHuff[10].linbits = 0; + pHuff[10].pdec_huff_tab = pvmp3_decode_huff_cw_tab10; + pHuff[11].linbits = 0; + pHuff[11].pdec_huff_tab = pvmp3_decode_huff_cw_tab11; + pHuff[12].linbits = 0; + pHuff[12].pdec_huff_tab = pvmp3_decode_huff_cw_tab12; + pHuff[13].linbits = 0; + pHuff[13].pdec_huff_tab = pvmp3_decode_huff_cw_tab13; + pHuff[14].linbits = 0; + pHuff[14].pdec_huff_tab = pvmp3_decode_huff_cw_tab0; /* tbl 14 is not used */ + pHuff[15].linbits = 0; + pHuff[15].pdec_huff_tab = pvmp3_decode_huff_cw_tab15; + pHuff[16].linbits = 1; + pHuff[16].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[17].linbits = 2; + pHuff[17].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[18].linbits = 3; + pHuff[18].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[19].linbits = 4; + pHuff[19].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[20].linbits = 6; + pHuff[20].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[21].linbits = 8; + pHuff[21].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[22].linbits = 10; + pHuff[22].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[23].linbits = 13; + pHuff[23].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[24].linbits = 4; + pHuff[24].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[25].linbits = 5; + pHuff[25].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[26].linbits = 6; + pHuff[26].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[27].linbits = 7; + pHuff[27].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[28].linbits = 8; + pHuff[28].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[29].linbits = 9; + pHuff[29].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[30].linbits = 11; + pHuff[30].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[31].linbits = 13; + pHuff[31].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[32].linbits = 0; + pHuff[32].pdec_huff_tab = pvmp3_decode_huff_cw_tab32; + pHuff[33].linbits = 0; + pHuff[33].pdec_huff_tab = pvmp3_decode_huff_cw_tab33; + + /* + * Initialize polysynthesis circular buffer mechanism + */ + /* clear buffers */ + + pvmp3_resetDecoder(pMem); + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void pvmp3_resetDecoder(void *pMem) +{ + + tmp3dec_file *pVars; + tmp3dec_chan *pChVars[CHAN]; + + pVars = (tmp3dec_file *)pMem; + pChVars[ LEFT] = &pVars->perChan[ LEFT]; + pChVars[RIGHT] = &pVars->perChan[RIGHT]; + + pVars->frame_start = 0; + + pVars->mainDataStream.offset = 0; + + pVars->mainDataStream.pBuffer = pVars->mainDataBuffer; + pVars->mainDataStream.usedBits = 0; + + + pVars->inputStream.usedBits = 0; // in bits + + + pChVars[ LEFT]->used_freq_lines = 575; + pChVars[RIGHT]->used_freq_lines = 575; + + + /* + * Initialize polysynthesis circular buffer mechanism + */ + + pv_memset((void*)&pChVars[ LEFT]->circ_buffer[576], + 0, + 480*sizeof(pChVars[ LEFT]->circ_buffer[0])); + pv_memset((void*)&pChVars[RIGHT]->circ_buffer[576], + 0, + 480*sizeof(pChVars[RIGHT]->circ_buffer[0])); + + + pv_memset((void*)pChVars[ LEFT]->overlap, + 0, + SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[ LEFT]->overlap[0])); + + + pv_memset((void*)pChVars[ RIGHT]->overlap, + 0, + SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[ RIGHT]->overlap[0])); + + + + + + /* + * Clear all the structures + */ + + + pv_memset((void*)&pVars->scaleFactors[RIGHT], + 0, + sizeof(mp3ScaleFactors)); + + pv_memset((void*)&pVars->scaleFactors[LEFT], + 0, + sizeof(mp3ScaleFactors)); + + pv_memset((void*)&pVars->sideInfo, + 0, + sizeof(mp3SideInfo)); + + pv_memset((void*)&pVars->sideInfo, + 0, + sizeof(mp3SideInfo)); + +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.h new file mode 100644 index 0000000..9c51586 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.h @@ -0,0 +1,108 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_framedecoder.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_FRAMEDECODER_H +#define PVMP3_FRAMEDECODER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "pvmp3decoder_api.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + + ERROR_CODE pvmp3_framedecoder(tPVMP3DecoderExternal *pExt, + void *pMem); + + + + uint32 pvmp3_decoderMemRequirements(void); + + void pvmp3_InitDecoder(tPVMP3DecoderExternal *pExt, + void *pMem); + + + void pvmp3_resetDecoder(void *pMem); + + + void fillMainDataBuf(void *pMem, int32 temp); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.cpp new file mode 100644 index 0000000..928b741 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.cpp @@ -0,0 +1,172 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_main_data_size.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Input + mp3Header *info, pointer to mp3 header info structure + tmp3dec_file *pVars + contains information that needs to persist + between calls to this function, or is too big to + be placed on the stack, even though the data is + only needed during execution of this function + + Returns + + main data frame size + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + get main data frame size + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_tables.h" +#include "pvmp3_get_main_data_size.h" +#include "pv_mp3dec_fxd_op.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +int32 pvmp3_get_main_data_size(mp3Header *info, + tmp3dec_file *pVars) +{ + + + int32 numBytes = fxp_mul32_Q28(mp3_bitrate[info->version_x][info->bitrate_index] << 20, + inv_sfreq[info->sampling_frequency]); + + + numBytes >>= (20 - info->version_x); + + /* + * Remove the size of the side information from the main data total + */ + if (info->version_x == MPEG_1) + { + pVars->predicted_frame_size = numBytes; + if (info->mode == MPG_MD_MONO) + { + numBytes -= 17; + } + else + { + numBytes -= 32; + } + } + else + { + numBytes >>= 1; + pVars->predicted_frame_size = numBytes; + + if (info->mode == MPG_MD_MONO) + { + numBytes -= 9; + } + else + { + numBytes -= 17; + } + } + + if (info->padding) + { + numBytes++; + pVars->predicted_frame_size++; + } + + if (info->error_protection) + { + numBytes -= 6; + } + else + { + numBytes -= 4; + } + + + if (numBytes < 0) + { + numBytes = 0; + } + + return(numBytes); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.h new file mode 100644 index 0000000..a4f3818 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.h @@ -0,0 +1,94 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_main_data_size.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_GET_MAIN_DATA_SIZE_H +#define PVMP3_GET_MAIN_DATA_SIZE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "s_tmp3dec_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + int32 pvmp3_get_main_data_size(mp3Header *info, + tmp3dec_file *pVars); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.cpp new file mode 100644 index 0000000..cc8223f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.cpp @@ -0,0 +1,218 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_scale_factors.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Input + mp3ScaleFactors *scalefac, + mp3SideInfo *si, side info + int32 gr, granule + int32 ch, channel + tbits *pMainData bit stream + + Returns + + mp3ScaleFactors *scalefac, scale factors + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + get scale factors + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_get_scale_factors.h" +#include "pvmp3_getbits.h" +#include "mp3_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define Qfmt_28(a)(int32(double(0x10000000)*a)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 slen[2][16] = +{ + {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4}, + {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3} +}; + +const struct +{ + int32 l[5]; + int32 s[3]; +} sfbtable = +{ + {0, 6, 11, 16, 21}, + {0, 6, 12} +}; + +const int32 long_sfbtable[4] = { 6, 5, 5, 5}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_get_scale_factors(mp3ScaleFactors *scalefac, + mp3SideInfo *si, + int32 gr, + int32 ch, + tmp3Bits *pMainData) +{ + int32 sfb; + int32 i; + int32 window; + granuleInfo *gr_info = &(si->ch[ch].gran[gr]); + + if (gr_info->window_switching_flag && (gr_info->block_type == 2)) + { + if (gr_info->mixed_block_flag) + { /* MIXED */ + for (sfb = 0; sfb < 8; sfb++) + { + scalefac->l[sfb] = getNbits(pMainData, slen[0][gr_info->scalefac_compress]); + } + + for (sfb = 3; sfb < 6; sfb++) + { + for (window = 0; window < 3; window++) + { + scalefac->s[window][sfb] = getNbits(pMainData, slen[0][gr_info->scalefac_compress]); + } + } + for (sfb = 6; sfb < 12; sfb++) + { + for (window = 0; window < 3; window++) + { + scalefac->s[window][sfb] = getNbits(pMainData, slen[1][gr_info->scalefac_compress]); + } + } + } + else + { /* SHORT*/ + for (i = 0; i < 2; i++) + { + for (sfb = sfbtable.s[i]; sfb < sfbtable.s[i+1]; sfb++) + { + for (window = 0; window < 3; window++) + { + scalefac->s[window][sfb] = getNbits(pMainData, slen[i][gr_info->scalefac_compress]); + } + } + } + } + + scalefac->s[0][12] = 0; /* sfb = 12 win= 0 */ + scalefac->s[1][12] = 0; /* sfb = 12 win= 1 */ + scalefac->s[2][12] = 0; /* sfb = 12 win= 2 */ + } + else + { /* LONG types 0,1,3 */ + + int32 *ptr = &scalefac->l[0]; + + for (i = 0; i < 4; i++) + { + int32 tmp4 = long_sfbtable[i]; + + if ((si->ch[ch].scfsi[i] == 0) || (gr == 0)) + { + int32 tmp1 = slen[(i>>1)][gr_info->scalefac_compress]; + + if (tmp1) + { + int32 tmp2 = tmp1 * tmp4; + uint32 tmp3 = getNbits(pMainData, tmp2); + tmp4 = 32 - tmp1; + for (; tmp2 > 0; tmp2 -= tmp1) + { + *(ptr++) = (tmp3 << (32 - tmp2)) >> tmp4; + } + } + else + { + for (sfb = tmp4; sfb != 0; sfb--) + { + *(ptr++) = 0; + } + + } + } + else + { + ptr += tmp4; + } + } + scalefac->l[21] = 0; + scalefac->l[22] = 0; + } +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.h new file mode 100644 index 0000000..85045a7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.h @@ -0,0 +1,97 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_scale_factors.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_GET_SCALE_FACTORS_H +#define PVMP3_GET_SCALE_FACTORS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_get_scale_factors(mp3ScaleFactors *scalefac, + mp3SideInfo *si, + int32 gr, + int32 ch, + tmp3Bits *pMainData); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.cpp new file mode 100644 index 0000000..78e230f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.cpp @@ -0,0 +1,277 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_side_info.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + mp3SideInfo *si, + mp3Header *info, mp3 header information + uint32 *crc initialized crc value (if enabled) + + + Returns + + mp3SideInfo *si, side information + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + acquires side information + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_get_side_info.h" +#include "pvmp3_crc.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +ERROR_CODE pvmp3_get_side_info(tmp3Bits *inputStream, + mp3SideInfo *si, + mp3Header *info, + uint32 *crc) +{ + int32 ch, gr; + uint32 tmp; + + int stereo = (info->mode == MPG_MD_MONO) ? 1 : 2; + + if (info->version_x == MPEG_1) + { + if (stereo == 1) + { + tmp = getbits_crc(inputStream, 14, crc, info->error_protection); + si->main_data_begin = (tmp << 18) >> 23; /* 9 */ + si->private_bits = (tmp << 23) >> 27; /* 5 */ + } + else + { + tmp = getbits_crc(inputStream, 12, crc, info->error_protection); + si->main_data_begin = (tmp << 20) >> 23; /* 9 */ + si->private_bits = (tmp << 23) >> 29; /* 3 */ + + } + + for (ch = 0; ch < stereo; ch++) + { + tmp = getbits_crc(inputStream, 4, crc, info->error_protection); + si->ch[ch].scfsi[0] = (tmp << 28) >> 31; /* 1 */ + si->ch[ch].scfsi[1] = (tmp << 29) >> 31; /* 1 */ + si->ch[ch].scfsi[2] = (tmp << 30) >> 31; /* 1 */ + si->ch[ch].scfsi[3] = tmp & 1; /* 1 */ + } + + for (gr = 0; gr < 2 ; gr++) + { + for (ch = 0; ch < stereo; ch++) + { + si->ch[ch].gran[gr].part2_3_length = getbits_crc(inputStream, 12, crc, info->error_protection); + tmp = getbits_crc(inputStream, 22, crc, info->error_protection); + + si->ch[ch].gran[gr].big_values = (tmp << 10) >> 23; /* 9 */ + si->ch[ch].gran[gr].global_gain = ((tmp << 19) >> 24) - 210; /* 8 */ + si->ch[ch].gran[gr].scalefac_compress = (tmp << 27) >> 28; /* 4 */ + si->ch[ch].gran[gr].window_switching_flag = tmp & 1; /* 1 */ + + if (si->ch[ch].gran[gr].window_switching_flag) + { + tmp = getbits_crc(inputStream, 22, crc, info->error_protection); + + si->ch[ch].gran[gr].block_type = (tmp << 10) >> 30; /* 2 */; + si->ch[ch].gran[gr].mixed_block_flag = (tmp << 12) >> 31; /* 1 */; + + si->ch[ch].gran[gr].table_select[0] = (tmp << 13) >> 27; /* 5 */; + si->ch[ch].gran[gr].table_select[1] = (tmp << 18) >> 27; /* 5 */; + + si->ch[ch].gran[gr].subblock_gain[0] = (tmp << 23) >> 29; /* 3 */; + si->ch[ch].gran[gr].subblock_gain[1] = (tmp << 26) >> 29; /* 3 */; + si->ch[ch].gran[gr].subblock_gain[2] = (tmp << 29) >> 29; /* 3 */; + + /* Set region_count parameters since they are implicit in this case. */ + + if (si->ch[ch].gran[gr].block_type == 0) + { + return(SIDE_INFO_ERROR); + } + else if ((si->ch[ch].gran[gr].block_type == 2) + && (si->ch[ch].gran[gr].mixed_block_flag == 0)) + { + si->ch[ch].gran[gr].region0_count = 8; /* MI 9; */ + si->ch[ch].gran[gr].region1_count = 12; + } + else + { + si->ch[ch].gran[gr].region0_count = 7; /* MI 8; */ + si->ch[ch].gran[gr].region1_count = 13; + } + } + else + { + tmp = getbits_crc(inputStream, 22, crc, info->error_protection); + + si->ch[ch].gran[gr].table_select[0] = (tmp << 10) >> 27; /* 5 */; + si->ch[ch].gran[gr].table_select[1] = (tmp << 15) >> 27; /* 5 */; + si->ch[ch].gran[gr].table_select[2] = (tmp << 20) >> 27; /* 5 */; + + si->ch[ch].gran[gr].region0_count = (tmp << 25) >> 28; /* 4 */; + si->ch[ch].gran[gr].region1_count = (tmp << 29) >> 29; /* 3 */; + + si->ch[ch].gran[gr].block_type = 0; + } + + tmp = getbits_crc(inputStream, 3, crc, info->error_protection); + si->ch[ch].gran[gr].preflag = (tmp << 29) >> 31; /* 1 */ + si->ch[ch].gran[gr].scalefac_scale = (tmp << 30) >> 31; /* 1 */ + si->ch[ch].gran[gr].count1table_select = tmp & 1; /* 1 */ + } + } + } + else /* Layer 3 LSF */ + { + si->main_data_begin = getbits_crc(inputStream, 8, crc, info->error_protection); + si->private_bits = getbits_crc(inputStream, stereo, crc, info->error_protection); + + for (ch = 0; ch < stereo; ch++) + { + tmp = getbits_crc(inputStream, 21, crc, info->error_protection); + si->ch[ch].gran[0].part2_3_length = (tmp << 11) >> 20; /* 12 */ + si->ch[ch].gran[0].big_values = (tmp << 23) >> 23; /* 9 */ + + tmp = getbits_crc(inputStream, 18, crc, info->error_protection); + si->ch[ch].gran[0].global_gain = ((tmp << 14) >> 24) - 210; /* 8 */ + si->ch[ch].gran[0].scalefac_compress = (tmp << 22) >> 23; /* 9 */ + si->ch[ch].gran[0].window_switching_flag = tmp & 1; /* 1 */ + + if (si->ch[ch].gran[0].window_switching_flag) + { + + tmp = getbits_crc(inputStream, 22, crc, info->error_protection); + + si->ch[ch].gran[0].block_type = (tmp << 10) >> 30; /* 2 */; + si->ch[ch].gran[0].mixed_block_flag = (tmp << 12) >> 31; /* 1 */; + + si->ch[ch].gran[0].table_select[0] = (tmp << 13) >> 27; /* 5 */; + si->ch[ch].gran[0].table_select[1] = (tmp << 18) >> 27; /* 5 */; + + si->ch[ch].gran[0].subblock_gain[0] = (tmp << 23) >> 29; /* 3 */; + si->ch[ch].gran[0].subblock_gain[1] = (tmp << 26) >> 29; /* 3 */; + si->ch[ch].gran[0].subblock_gain[2] = (tmp << 29) >> 29; /* 3 */; + + /* Set region_count parameters since they are implicit in this case. */ + + if (si->ch[ch].gran[0].block_type == 0) + { + return(SIDE_INFO_ERROR); + } + else if ((si->ch[ch].gran[0].block_type == 2) + && (si->ch[ch].gran[0].mixed_block_flag == 0)) + { + si->ch[ch].gran[0].region0_count = 8; /* MI 9; */ + si->ch[ch].gran[0].region1_count = 12; + } + else + { + si->ch[ch].gran[0].region0_count = 7; /* MI 8; */ + si->ch[ch].gran[0].region1_count = 13; + } + } + else + { + tmp = getbits_crc(inputStream, 22, crc, info->error_protection); + + si->ch[ch].gran[0].table_select[0] = (tmp << 10) >> 27; /* 5 */; + si->ch[ch].gran[0].table_select[1] = (tmp << 15) >> 27; /* 5 */; + si->ch[ch].gran[0].table_select[2] = (tmp << 20) >> 27; /* 5 */; + + si->ch[ch].gran[0].region0_count = (tmp << 25) >> 28; /* 4 */; + si->ch[ch].gran[0].region1_count = (tmp << 29) >> 29; /* 3 */; + + si->ch[ch].gran[0].block_type = 0; + } + + tmp = getbits_crc(inputStream, 2, crc, info->error_protection); + si->ch[ch].gran[0].scalefac_scale = tmp >> 1; /* 1 */ + si->ch[ch].gran[0].count1table_select = tmp & 1; /* 1 */ + + } + } + return (NO_DECODING_ERROR); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.h new file mode 100644 index 0000000..c8e5973 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_side_info.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_GET_SIDE_INFO_H +#define PVMP3_GET_SIDE_INFO_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + ERROR_CODE pvmp3_get_side_info(tmp3Bits *inputStream, + mp3SideInfo *si, + mp3Header *info, + uint32 *crc); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.cpp new file mode 100644 index 0000000..7969bfc --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.cpp @@ -0,0 +1,248 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_getbits.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + tmp3Bits *inputStream, structure holding the input stream parameters + int32 neededBits number of bits to read from the bit stream + + Outputs: + + word parsed from teh bitstream, with size neededBits-bits, + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint32 getNbits(tmp3Bits *ptBitStream, + int32 neededBits) /* number of bits to read from the bitstream (up to 25) */ +{ + + uint32 offset; + uint32 bitIndex; + uint8 Elem; /* Needs to be same type as pInput->pBuffer */ + uint8 Elem1; + uint8 Elem2; + uint8 Elem3; + uint32 returnValue = 0; + + if (!neededBits) + { + return (returnValue); + } + + offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + Elem = *(ptBitStream->pBuffer + module(offset , BUFSIZE)); + Elem1 = *(ptBitStream->pBuffer + module(offset + 1, BUFSIZE)); + Elem2 = *(ptBitStream->pBuffer + module(offset + 2, BUFSIZE)); + Elem3 = *(ptBitStream->pBuffer + module(offset + 3, BUFSIZE)); + + + returnValue = (((uint32)(Elem)) << 24) | + (((uint32)(Elem1)) << 16) | + (((uint32)(Elem2)) << 8) | + ((uint32)(Elem3)); + + /* Remove extra high bits by shifting up */ + bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH); + + /* This line is faster than to mask off the high bits. */ + returnValue <<= bitIndex; + + /* Move the field down. */ + returnValue >>= (32 - neededBits); + + ptBitStream->usedBits += neededBits; + + return (returnValue); +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint16 getUpTo9bits(tmp3Bits *ptBitStream, + int32 neededBits) /* number of bits to read from the bit stream 2 to 9 */ +{ + + uint32 offset; + uint32 bitIndex; + uint8 Elem; /* Needs to be same type as pInput->pBuffer */ + uint8 Elem1; + uint16 returnValue; + + offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + Elem = *(ptBitStream->pBuffer + module(offset , BUFSIZE)); + Elem1 = *(ptBitStream->pBuffer + module(offset + 1, BUFSIZE)); + + + returnValue = (((uint16)(Elem)) << 8) | + ((uint16)(Elem1)); + + /* Remove extra high bits by shifting up */ + bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH); + + ptBitStream->usedBits += neededBits; + /* This line is faster than to mask off the high bits. */ + returnValue = (returnValue << (bitIndex)); + + /* Move the field down. */ + + return (uint16)(returnValue >> (16 - neededBits)); + +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint32 getUpTo17bits(tmp3Bits *ptBitStream, + int32 neededBits) /* number of bits to read from the bit stream 2 to 8 */ +{ + + uint32 offset; + uint32 bitIndex; + uint8 Elem; /* Needs to be same type as pInput->pBuffer */ + uint8 Elem1; + uint8 Elem2; + uint32 returnValue; + + offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + Elem = *(ptBitStream->pBuffer + module(offset , BUFSIZE)); + Elem1 = *(ptBitStream->pBuffer + module(offset + 1, BUFSIZE)); + Elem2 = *(ptBitStream->pBuffer + module(offset + 2, BUFSIZE)); + + + returnValue = (((uint32)(Elem)) << 16) | + (((uint32)(Elem1)) << 8) | + ((uint32)(Elem2)); + + /* Remove extra high bits by shifting up */ + bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH); + + ptBitStream->usedBits += neededBits; + /* This line is faster than to mask off the high bits. */ + returnValue = 0xFFFFFF & (returnValue << (bitIndex)); + + /* Move the field down. */ + + return (uint32)(returnValue >> (24 - neededBits)); + +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint8 get1bit(tmp3Bits *ptBitStream) /* number of bits to read from the bit stream */ +{ + + uint32 offset; + uint32 bitIndex; + uint8 returnValue; + + offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + returnValue = *(ptBitStream->pBuffer + module(offset , BUFSIZE)); + + /* Remove extra high bits by shifting up */ + bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH); + ptBitStream->usedBits++; + + /* This line is faster than to mask off the high bits. */ + returnValue = (returnValue << (bitIndex)); + + return (uint8)(returnValue >> 7); + +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.h new file mode 100644 index 0000000..0c5a670 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.h @@ -0,0 +1,105 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_getbits.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_GETBITS_H +#define PVMP3_GETBITS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_dec_defs.h" +#include "s_mp3bits.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define INBUF_ARRAY_INDEX_SHIFT (3) +#define INBUF_BIT_WIDTH (1<<(INBUF_ARRAY_INDEX_SHIFT)) +#define INBUF_BIT_MODULO_MASK ((INBUF_BIT_WIDTH)-1) + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + uint32 getNbits(tmp3Bits *pMainData, + int32 neededBits); + + uint16 getUpTo9bits(tmp3Bits *pMainData, + int32 neededBits); + + uint32 getUpTo17bits(tmp3Bits *pMainData, + int32 neededBits); + + uint8 get1bit(tmp3Bits *pMainData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_decoding.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_decoding.cpp new file mode 100644 index 0000000..efc10f2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_decoding.cpp @@ -0,0 +1,296 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_huffman_decoding.cpp + + Functions: + pvmp3_huffman_quad_decoding + pvmp3_huffman_pair_decoding + pvmp3_huffman_pair_decoding_linbits + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + struct huffcodetab *h, pointer to huffman code record + int32 *x, returns decoded x value + int32 *y, returns decoded y value + int32 *v, returns decoded v value (only in quad function) + int32 *w, returns decoded w value (only in quad function) + tbits *pMainData bit stream + + Outputs: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + These functions are used to decode huffman codewords from the input + bitstream using combined binary search and look-up table approach. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_dec_defs.h" +#include "pv_mp3_huffman.h" +#include "pvmp3_getbits.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void pvmp3_huffman_quad_decoding(struct huffcodetab *h, + int32 *is, + tmp3Bits *pMainData) +{ + + int32 x; + int32 y; + int32 v; + int32 w; + + y = (*h->pdec_huff_tab)(pMainData); + + + if (y) + { + v = (y >> 3); + + if (v) + { + if (get1bit(pMainData)) + { + v = -v; + } + } + w = (y >> 2) & 1; + if (w) + { + if (get1bit(pMainData)) + { + w = -w; + } + } + x = (y >> 1) & 1; + if (x) + { + if (get1bit(pMainData)) + { + x = -x; + } + } + y = y & 1; + if (y) + { + if (get1bit(pMainData)) + { + y = -y; + } + } + + } + else + { + v = 0; + w = 0; + x = 0; + + } + + *is = v; + *(is + 1) = w; + *(is + 2) = x; + *(is + 3) = y; + +} + + + +void pvmp3_huffman_pair_decoding(struct huffcodetab *h, /* pointer to huffman code record */ + int32 *is, + tmp3Bits *pMainData) +{ + /* Lookup in Huffman table. */ + int32 x; + int32 y; + + uint16 cw = (*h->pdec_huff_tab)(pMainData); + + /* Process sign and escape encodings for dual tables. */ + + + if (cw) + { + x = cw >> 4; + + if (x) + { + if (get1bit(pMainData)) + { + x = -x; + } + y = cw & 0xf; + if (y && get1bit(pMainData)) + { + y = -y; + } + + } + else + { + y = cw & 0xf; + if (get1bit(pMainData)) + { + y = -y; + } + } + + *is = x; + *(is + 1) = y; + } + else + { + *is = 0; + *(is + 1) = 0; + } + + + +} + + + + +void pvmp3_huffman_pair_decoding_linbits(struct huffcodetab *h, /* pointer to huffman code record */ + int32 *is, + tmp3Bits *pMainData) +{ + int32 x; + int32 y; + + uint16 cw; + /* Lookup in Huffman table. */ + + + cw = (*h->pdec_huff_tab)(pMainData); + x = cw >> 4; + + /* Process sign and escape encodings for dual tables. */ + + + if (15 == (uint32)x) + { + int32 tmp = getUpTo17bits(pMainData, (h->linbits + 1)); + x += tmp >> 1; + if (tmp&1) + { + x = -x; + } + } + else if (x) + { + if (get1bit(pMainData)) + { + x = -x; + } + } + + y = cw & 0xf; + if (15 == (uint32)y) + { + int32 tmp = getUpTo17bits(pMainData, (h->linbits + 1)); + y += tmp >> 1; + if (tmp&1) + { + y = -y; + } + } + else if (y) + { + if (get1bit(pMainData)) + { + y = -y; + } + } + + *is = x; + *(is + 1) = y; + +} + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_parsing.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_parsing.cpp new file mode 100644 index 0000000..a6e14d3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_parsing.cpp @@ -0,0 +1,320 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_huffman_decoding.cpp + + Functions: + pvmp3_huffman_quad_decoding + pvmp3_huffman_pair_decoding + pvmp3_huffman_pair_decoding_linbits + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + int32 is[], + granuleInfo *grInfo, information for the given channel and granule + tmp3dec_file *pVars, decoder state structure + int32 part2_start, index to beginning of part 2 data + mp3Header *info mp3 header info + + Outputs: + int32 is[], uncompressed data + + Return: + non zero frequency lines + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + These functions are used to decode huffman codewords from the input + bitstream using combined binary search and look-up table approach. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_mp3_huffman.h" +#include "s_mp3bits.h" +#include "mp3_mem_funcs.h" +#include "pvmp3_tables.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +int32 pvmp3_huffman_parsing(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], + granuleInfo *grInfo, + tmp3dec_file *pVars, + int32 part2_start, + mp3Header *info) + + +{ + int32 i; + int32 region1Start; + int32 region2Start; + int32 sfreq; + uint32 grBits; + void(*pt_huff)(struct huffcodetab *, int32 *, tmp3Bits *); + struct huffcodetab *h; + + tmp3Bits *pMainData = &pVars->mainDataStream; + + + /*int32 bt = (*si).ch[ch].gr[gr].window_switching_flag && ((*si).ch[ch].gr[gr].block_type == 2);*/ + + sfreq = info->sampling_frequency + info->version_x + (info->version_x << 1); + + /* Find region boundary for short block case. */ + + + if ((grInfo->window_switching_flag) && (grInfo->block_type == 2)) + { + if (info->version_x == MPEG_1) + { + /* Region2. */ + region1Start = 12; + } + else + { + /* Region2. */ + i = grInfo->region0_count + 1; + region1Start = mp3_sfBandIndex[sfreq].s[i/3]; + } + + region1Start += region1Start << 1; + region2Start = 576; /* No Region2 for short block case. */ + } + else + { /* Find region boundary for long block case. */ + i = grInfo->region0_count + 1; + region1Start = mp3_sfBandIndex[sfreq].l[i]; + region2Start = mp3_sfBandIndex[sfreq].l[i + grInfo->region1_count + 1]; + } + + /* Read bigvalues area. */ + + + if (grInfo->big_values > (FILTERBANK_BANDS*SUBBANDS_NUMBER >> 1)) + { + grInfo->big_values = (FILTERBANK_BANDS * SUBBANDS_NUMBER >> 1); + } + + if ((grInfo->big_values << 1) > (uint32)region2Start) + { + h = &(pVars->ht[grInfo->table_select[0]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + + for (i = 0; i < region1Start; i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + + h = &(pVars->ht[grInfo->table_select[1]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + + for (; i < region2Start; i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + + h = &(pVars->ht[grInfo->table_select[2]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + + for (; (uint32)i < (grInfo->big_values << 1); i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + } + else if ((grInfo->big_values << 1) > (uint32)region1Start) + { + h = &(pVars->ht[grInfo->table_select[0]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + for (i = 0; i < region1Start; i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + + h = &(pVars->ht[grInfo->table_select[1]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + for (; (uint32)i < (grInfo->big_values << 1); i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + } + else + { + h = &(pVars->ht[grInfo->table_select[0]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + + for (i = 0; (uint32)i < (grInfo->big_values << 1); i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + } + + + + /* Read count1 area. */ + h = &(pVars->ht[grInfo->count1table_select+32]); + + grBits = part2_start + grInfo->part2_3_length; + + while ((pMainData->usedBits < grBits) && + (i < FILTERBANK_BANDS*SUBBANDS_NUMBER - 4)) + { + pvmp3_huffman_quad_decoding(h, &is[i], pMainData); + i += 4; + } + + if ((pMainData->usedBits < grBits) && + (i < FILTERBANK_BANDS*SUBBANDS_NUMBER)) + { + pvmp3_huffman_quad_decoding(h, &is[i], pMainData); + i += 4; + + if ((i - 2) >= FILTERBANK_BANDS*SUBBANDS_NUMBER) + { + i -= 2; + is[i] = 0; + is[(i+1)] = 0; + } + } + + if (pMainData->usedBits > grBits) + { + i -= 4; + + if (i < 0 || i > FILTERBANK_BANDS*SUBBANDS_NUMBER - 4) + { + /* illegal parameters may cause invalid access, set i to 0 */ + i = 0; + } + + is[i] = 0; + is[(i+1)] = 0; + is[(i+2)] = 0; + is[(i+3)] = 0; + + } + + pMainData->usedBits = grBits; + + return (i); + +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.cpp new file mode 100644 index 0000000..a52fd0e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.cpp @@ -0,0 +1,368 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_imdct_synth.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Input + int32 in[], Pointer to spec values of current channel + int32 overlap[], Pointer to overlap values of current channel + uint32 blk_type, Block type + int16 mx_band, In case of mixed blocks, # of bands with long + blocks (2 or 4) else 0 + int32 *Scratch_mem + Returns + + int32 in[], + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + The frequency lines are preprocessed by the "alias reduction" scheme + and fed into the IMDCT matrix, each 18 into one transform block. + The first half of the output values are added to the stored overlap + values from the last block. These values are new output values and + are input values for the polyphase filterbank. The second half of the + output values is stored for overlap with the next data granule. + The number of windowed samples is 12 for short blocks, and 36 for long + blocks + +Windowing + + Depending on window_switching_flag[gr][ch], block_type[gr][ch] and + mixed_block_flag[gr][ch] different shapes of windows are used. + normal window + start window + stop window + short windows + Each of the three short blocks is windowed separately. + The windowed short blocks must be overlapped and concatenated. + +Overlapping and adding with previous block + + The first half (18 values) of the current block (36 values) has to be + overlapped with the second half of the previous block. The second half + of the current block has to be stored for overlapping with the next block + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_imdct_synth.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_mdct_18.h" +#include "pvmp3_mdct_6.h" +#include "mp3_mem_funcs.h" + + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define LONG 0 +#define START 1 +#define SHORT 2 +#define STOP 3 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/* + * sin(pi/36*(k+0.5)),k=0..35 + */ + +const int32 normal_win[36] = +{ + Qfmt_31(0.08723877473068f), Qfmt_31(0.26105238444010f), Qfmt_31(0.43287922787620f), + Qfmt_31(0.60141159900854f), Qfmt_31(0.76536686473018f), Qfmt_31(0.92349722647006f), + Qfmt_31(0.53729960834682f), Qfmt_31(0.60876142900872f), Qfmt_31(0.67559020761566f), + Qfmt_31(-0.73727733681012f), Qfmt_31(-0.79335334029124f), Qfmt_31(0.84339144581289f), + Qfmt_31(0.88701083317822f), Qfmt_31(0.92387953251129f), Qfmt_31(-0.95371695074823f), + Qfmt_31(-0.97629600711993f), Qfmt_31(-0.99144486137381f), Qfmt_31(-0.99904822158186f), + Qfmt_31(0.99904822158186f), Qfmt_31(0.99144486137381f), Qfmt_31(0.97629600711993f), + Qfmt_31(0.95371695074823f), Qfmt_31(0.92387953251129f), Qfmt_31(0.88701083317822f), + Qfmt_31(0.84339144581289f), Qfmt_31(0.79335334029124f), Qfmt_31(0.73727733681012f), + Qfmt_31(0.67559020761566f), Qfmt_31(0.60876142900872f), Qfmt_31(0.53729960834682f), + Qfmt_31(0.46174861323503f), Qfmt_31(0.38268343236509f), Qfmt_31(0.30070579950427f), + Qfmt_31(0.21643961393810f), Qfmt_31(0.13052619222005f), Qfmt_31(0.04361938736534f) +}; + + +const int32 start_win[36] = +{ + /* k=0..17 sin(pi/36*(k+0.5)), */ + Qfmt_31(0.08723877473068f), Qfmt_31(0.26105238444010f), Qfmt_31(0.43287922787620f), + Qfmt_31(0.60141159900854f), Qfmt_31(0.76536686473018f), Qfmt_31(0.92349722647006f), + Qfmt_31(0.53729960834682f), Qfmt_31(0.60876142900872f), Qfmt_31(0.67559020761566f), + Qfmt_31(-0.73727733681012f), Qfmt_31(-0.79335334029124f), Qfmt_31(0.84339144581289f), + Qfmt_31(0.88701083317822f), Qfmt_31(0.92387953251129f), Qfmt_31(-0.95371695074823f), + Qfmt_31(-0.97629600711993f), Qfmt_31(-0.99144486137381f), Qfmt_31(-0.99904822158186f), + + Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), + Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), + /* k=24..29; sin(pi/12*(k-18+0.5)) */ + Qfmt_31(0.99144486137381f), Qfmt_31(0.92387953251129f), Qfmt_31(0.79335334029124f), + Qfmt_31(0.60876142900872f), Qfmt_31(0.38268343236509f), Qfmt_31(0.13052619222005f), + + Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), + Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f) +}; + + +const int32 stop_win[36] = +{ + Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), + Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), + /* k=6..11; sin(pi/12*(k-6+0.5)) */ + Qfmt_31(0.13052619222005f), Qfmt_31(0.38268343236509f), Qfmt_31(0.60876142900872f), + Qfmt_31(-0.79335334029124f), Qfmt_31(-0.92387953251129f), Qfmt_31(0.99144486137381f), + + Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), Qfmt_31(-0.99999990000000f), + Qfmt_31(-0.99999990000000f), Qfmt_31(-0.99999990000000f), Qfmt_31(-0.99999990000000f), + /* k=18..35 sin(pi/36*(k+0.5)), */ + Qfmt_31(0.99904822158186f), Qfmt_31(0.99144486137381f), Qfmt_31(0.97629600711993f), + Qfmt_31(0.95371695074823f), Qfmt_31(0.92387953251129f), Qfmt_31(0.88701083317822f), + Qfmt_31(0.84339144581289f), Qfmt_31(0.79335334029124f), Qfmt_31(0.73727733681012f), + Qfmt_31(0.67559020761566f), Qfmt_31(0.60876142900872f), Qfmt_31(0.53729960834682f), + Qfmt_31(0.46174861323503f), Qfmt_31(0.38268343236509f), Qfmt_31(0.30070579950427f), + Qfmt_31(0.21643961393810f), Qfmt_31(0.13052619222005f), Qfmt_31(0.04361938736534f) +}; + + +const int32 short_win[12] = +{ + /* k=0..11; sin(pi/12*(k+0.5)) */ + Qfmt_31(0.13052619222005f), Qfmt_31(0.38268343236509f), Qfmt_31(0.60876142900872f), + Qfmt_31(0.79335334029124f), Qfmt_31(0.92387953251129f), Qfmt_31(0.99144486137381f), + Qfmt_31(0.99144486137381f), Qfmt_31(0.92387953251129f), Qfmt_31(0.79335334029124f), + Qfmt_31(0.60876142900872f), Qfmt_31(0.38268343236509f), Qfmt_31(0.13052619222005f), +}; +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_imdct_synth(int32 in[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 overlap[SUBBANDS_NUMBER*FILTERBANK_BANDS], + uint32 blk_type, + int16 mx_band, + int32 used_freq_lines, + int32 *Scratch_mem) +{ + + int32 band; + int32 bands2process = used_freq_lines + 2; + + if (bands2process > SUBBANDS_NUMBER) + { + bands2process = SUBBANDS_NUMBER; /* default */ + } + + + /* + * in case of mx_poly_band> 0, do + * long transforms + */ + + + for (band = 0; band < bands2process; band++) + { + uint32 current_blk_type = (band < mx_band) ? LONG : blk_type; + + int32 * out = in + (band * FILTERBANK_BANDS); + int32 * history = overlap + (band * FILTERBANK_BANDS); + + switch (current_blk_type) + { + case LONG: + + pvmp3_mdct_18(out, history, normal_win); + + break; + + case START: + + pvmp3_mdct_18(out, history, start_win); + + break; + + case STOP: + + pvmp3_mdct_18(out, history, stop_win); + + break; + + case SHORT: + { + int32 *tmp_prev_ovr = &Scratch_mem[FILTERBANK_BANDS]; + int32 i; + + for (i = 0; i < 6; i++) + { + Scratch_mem[i ] = out[(i*3)]; + Scratch_mem[6 +i] = out[(i*3) + 1]; + Scratch_mem[12 +i] = out[(i*3) + 2]; + } + + pvmp3_mdct_6(&Scratch_mem[ 0], &tmp_prev_ovr[ 0]); + pvmp3_mdct_6(&Scratch_mem[ 6], &tmp_prev_ovr[ 6]); + pvmp3_mdct_6(&Scratch_mem[12], &tmp_prev_ovr[12]); + + for (i = 0; i < 6; i++) + { + int32 temp = history[i]; + /* next iteration overlap */ + history[i] = fxp_mul32_Q32(tmp_prev_ovr[ 6+i] << 1, short_win[6+i]); + history[i] += fxp_mul32_Q32(Scratch_mem[12+i] << 1, short_win[ i]); + out[i] = temp; + } + + for (i = 0; i < 6; i++) + { + out[i+6] = fxp_mul32_Q32(Scratch_mem[i] << 1, short_win[i]); + out[i+6] += history[i+6]; + /* next iteration overlap */ + history[i+6] = fxp_mul32_Q32(tmp_prev_ovr[12+i] << 1, short_win[6+i]); + + } + for (i = 0; i < 6; i++) + { + out[i+12] = fxp_mul32_Q32(tmp_prev_ovr[ i] << 1, short_win[6+i]); + out[i+12] += fxp_mul32_Q32(Scratch_mem[6+i] << 1, short_win[ i]); + out[i+12] += history[i+12]; + history[12+i] = 0; + } + } + + break; + } + + /* + * Compensation for frequency inversion of polyphase filterbank + * every odd time sample of every odd odd subband is mulitplied by -1 before + * processing by the polyphase filter + */ + + if (band & 1) + { + for (int32 slot = 1; slot < FILTERBANK_BANDS; slot += 6) + { + int32 temp1 = out[slot ]; + int32 temp2 = out[slot+2]; + int32 temp3 = out[slot+4]; + out[slot ] = -temp1; + out[slot+2] = -temp2; + out[slot+4] = -temp3; + } + } + } + + + for (band = bands2process; band < SUBBANDS_NUMBER; band++) + { + int32 * out = in + (band * FILTERBANK_BANDS); + int32 * history = overlap + (band * FILTERBANK_BANDS); + int32 slot; + + if (band & 1) + { + for (slot = 0; slot < FILTERBANK_BANDS; slot += 6) + { + int32 temp1 = history[slot ]; + int32 temp2 = history[slot+1]; + int32 temp3 = history[slot+2]; + out[slot ] = temp1; + out[slot+1] = -temp2; + out[slot+2] = temp3; + + temp1 = history[slot+3]; + temp2 = history[slot+4]; + temp3 = history[slot+5]; + out[slot+3] = -temp1; + out[slot+4] = temp2; + out[slot+5] = -temp3; + } + } + else + { + for (slot = 0; slot < FILTERBANK_BANDS; slot += 3) + { + int32 temp1 = history[slot ]; + int32 temp2 = history[slot+1]; + int32 temp3 = history[slot+2]; + out[slot ] = temp1; + out[slot+1] = temp2; + out[slot+2] = temp3; + } + } + + pv_memset(history, 0, FILTERBANK_BANDS*sizeof(*overlap)); + } +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.h new file mode 100644 index 0000000..e9ac514 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.h @@ -0,0 +1,96 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_imdct_synth.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ + +#ifndef PVMP3_IMDCT_SYNTH_H +#define PVMP3_IMDCT_SYNTH_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_imdct_synth(int32 in[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 overlap[SUBBANDS_NUMBER*FILTERBANK_BANDS], + uint32 blk_type, + int16 mx_band, + int32 used_freq_lines, + int32 *Scratch_mem); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.cpp new file mode 100644 index 0000000..31e7a57 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.cpp @@ -0,0 +1,282 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: mdct_18.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + int32 vec[], input vector of length 18 + int32 *history input for overlap and add, vector updated with + next overlap and add values + const int32 *window sine window used in the mdct, three types are allowed + noraml, start and stop +Returns + none mdct computation in-place + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Returns the mdct of length 18 of the input vector, as well as the overlap + vector for next iteration ( on history[]) + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ +#include "oscl_base_macros.h"// has integer values of PV_COMPILER + +#if !((PV_CPU_ARCH_VERSION >=4) && ((PV_COMPILER == EPV_ARM_GNUC)|| (PV_COMPILER == EPV_ARM_RVCT))) +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_mdct_18.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 cosTerms_dct18[9] = +{ + Qfmt(0.50190991877167f), Qfmt(0.51763809020504f), Qfmt(0.55168895948125f), + Qfmt(0.61038729438073f), Qfmt(0.70710678118655f), Qfmt(0.87172339781055f), + Qfmt(1.18310079157625f), Qfmt(1.93185165257814f), Qfmt(5.73685662283493f) +}; + + +const int32 cosTerms_1_ov_cos_phi[18] = +{ + + Qfmt1(0.50047634258166f), Qfmt1(0.50431448029008f), Qfmt1(0.51213975715725f), + Qfmt1(0.52426456257041f), Qfmt1(0.54119610014620f), Qfmt1(0.56369097343317f), + Qfmt1(0.59284452371708f), Qfmt1(0.63023620700513f), Qfmt1(0.67817085245463f), + + Qfmt2(0.74009361646113f), Qfmt2(0.82133981585229f), Qfmt2(0.93057949835179f), + Qfmt2(1.08284028510010f), Qfmt2(1.30656296487638f), Qfmt2(1.66275476171152f), + Qfmt2(2.31011315767265f), Qfmt2(3.83064878777019f), Qfmt2(11.46279281302667f) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void pvmp3_mdct_18(int32 vec[], int32 *history, const int32 *window) +{ + int32 i; + int32 tmp; + int32 tmp1; + int32 tmp2; + int32 tmp3; + int32 tmp4; + + + + const int32 *pt_cos_split = cosTerms_dct18; + const int32 *pt_cos = cosTerms_1_ov_cos_phi; + const int32 *pt_cos_x = &cosTerms_1_ov_cos_phi[17]; + int32 *pt_vec = vec; + int32 *pt_vec_o = &vec[17]; + + + for (i = 9; i != 0; i--) + { + tmp = *(pt_vec); + tmp1 = *(pt_vec_o); + tmp = fxp_mul32_Q32(tmp << 1, *(pt_cos++)); + tmp1 = fxp_mul32_Q27(tmp1, *(pt_cos_x--)); + *(pt_vec++) = tmp + tmp1 ; + *(pt_vec_o--) = fxp_mul32_Q28((tmp - tmp1), *(pt_cos_split++)); + } + + + pvmp3_dct_9(vec); // Even terms + pvmp3_dct_9(&vec[9]); // Odd terms + + + tmp3 = vec[16]; // + vec[16] = vec[ 8]; + tmp4 = vec[14]; // + vec[14] = vec[ 7]; + tmp = vec[12]; + vec[12] = vec[ 6]; + tmp2 = vec[10]; // vec[10] + vec[10] = vec[ 5]; + vec[ 8] = vec[ 4]; + vec[ 6] = vec[ 3]; + vec[ 4] = vec[ 2]; + vec[ 2] = vec[ 1]; + vec[ 1] = vec[ 9] - tmp2; // vec[9] + vec[10] + vec[ 3] = vec[11] - tmp2; + vec[ 5] = vec[11] - tmp; + vec[ 7] = vec[13] - tmp; + vec[ 9] = vec[13] - tmp4; + vec[11] = vec[15] - tmp4; + vec[13] = vec[15] - tmp3; + vec[15] = vec[17] - tmp3; + + + /* overlap and add */ + + tmp2 = vec[0]; + tmp3 = vec[9]; + + for (i = 0; i < 6; i++) + { + tmp = history[ i]; + tmp4 = vec[i+10]; + vec[i+10] = tmp3 + tmp4; + tmp1 = vec[i+1]; + vec[ i] = fxp_mac32_Q32(tmp, (vec[i+10]), window[ i]); + tmp3 = tmp4; + history[i ] = -(tmp2 + tmp1); + tmp2 = tmp1; + } + + tmp = history[ 6]; + tmp4 = vec[16]; + vec[16] = tmp3 + tmp4; + tmp1 = vec[7]; + vec[ 6] = fxp_mac32_Q32(tmp, vec[16] << 1, window[ i]); + tmp = history[ 7]; + history[6] = -(tmp2 + tmp1); + history[7] = -(tmp1 + vec[8]); + + tmp1 = history[ 8]; + tmp4 = vec[17] + tmp4; + vec[ 7] = fxp_mac32_Q32(tmp, tmp4 << 1, window[ 7]); + history[8] = -(vec[8] + vec[9]); + vec[ 8] = fxp_mac32_Q32(tmp1, vec[17] << 1, window[ 8]); + + tmp = history[9]; + tmp1 = history[17]; + tmp2 = history[16]; + vec[ 9] = fxp_mac32_Q32(tmp, vec[17] << 1, window[ 9]); + + vec[17] = fxp_mac32_Q32(tmp1, vec[10] << 1, window[17]); + vec[10] = -vec[ 16]; + vec[16] = fxp_mac32_Q32(tmp2, vec[11] << 1, window[16]); + tmp1 = history[15]; + tmp2 = history[14]; + vec[11] = -vec[ 15]; + vec[15] = fxp_mac32_Q32(tmp1, vec[12] << 1, window[15]); + vec[12] = -vec[ 14]; + vec[14] = fxp_mac32_Q32(tmp2, vec[13] << 1, window[14]); + + tmp = history[13]; + tmp1 = history[12]; + tmp2 = history[11]; + tmp3 = history[10]; + vec[13] = fxp_mac32_Q32(tmp, vec[12] << 1, window[13]); + vec[12] = fxp_mac32_Q32(tmp1, vec[11] << 1, window[12]); + vec[11] = fxp_mac32_Q32(tmp2, vec[10] << 1, window[11]); + vec[10] = fxp_mac32_Q32(tmp3, tmp4 << 1, window[10]); + + + /* next iteration overlap */ + + tmp1 = history[ 8]; + tmp3 = history[ 7]; + tmp2 = history[ 1]; + tmp = history[ 0]; + tmp1 <<= 1; + tmp3 <<= 1; + + history[ 0] = fxp_mul32_Q32(tmp1, window[18]); + history[17] = fxp_mul32_Q32(tmp1, window[35]); + history[ 1] = fxp_mul32_Q32(tmp3, window[19]); + history[16] = fxp_mul32_Q32(tmp3, window[34]); + + tmp2 <<= 1; + tmp <<= 1; + history[ 7] = fxp_mul32_Q32(tmp2, window[25]); + history[10] = fxp_mul32_Q32(tmp2, window[28]); + history[ 8] = fxp_mul32_Q32(tmp, window[26]); + history[ 9] = fxp_mul32_Q32(tmp, window[27]); + + tmp1 = history[ 6]; + tmp3 = history[ 5]; + tmp4 = history[ 4]; + tmp2 = history[ 3]; + tmp = history[ 2]; + + tmp1 <<= 1; + tmp3 <<= 1; + tmp4 <<= 1; + + history[ 2] = fxp_mul32_Q32(tmp1, window[20]); + history[15] = fxp_mul32_Q32(tmp1, window[33]); + history[ 3] = fxp_mul32_Q32(tmp3, window[21]); + history[14] = fxp_mul32_Q32(tmp3, window[32]); + history[ 4] = fxp_mul32_Q32(tmp4, window[22]); + history[13] = fxp_mul32_Q32(tmp4, window[31]); + tmp2 <<= 1; + tmp <<= 1; + history[ 5] = fxp_mul32_Q32(tmp2, window[23]); + history[12] = fxp_mul32_Q32(tmp2, window[30]); + history[ 6] = fxp_mul32_Q32(tmp, window[24]); + history[11] = fxp_mul32_Q32(tmp, window[29]); +} + +#endif // If not assembly diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.h new file mode 100644 index 0000000..243099e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.h @@ -0,0 +1,101 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Pathname: ./include/pvmp3_mdct_18.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines function mdct_18, dct9, mdct_6 and dct_6 + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef MDCT_18_H +#define MDCT_18_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define Qfmt(a) (Int32)(a*((Int32)1<<28) ) +#define Qfmt1(a) (Int32)(a*((Int32)0x7FFFFFFF)) +#define Qfmt2(a) (Int32)(a*((Int32)1<<27)) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_mdct_18(int32 vec[], int32 *history, const int32 *window); + + void pvmp3_dct_9(int32 vec[]); + + void pvmp3_mdct_6(int32 vec[], int32 *overlap); + + void pvmp3_dct_6(int32 vec[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.cpp new file mode 100644 index 0000000..d30e4aa --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.cpp @@ -0,0 +1,157 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + Filename: mdct_18.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + int32 vec[], input vector of length 6 + int32 *history input for overlap and add, vector updated with + next overlap and add values +Returns + none mdct computation in-place + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Returns the mdct of length 6 of the input vector, as well as the overlap + vector for next iteration ( on history[]) + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_mdct_6.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define QFORMAT 29 +#define Qfmt29(a) (int32)(a*((int32)1<=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/* + * (1./(2*cos((pi/(2*N))*(2*i+1)))), N = 12, i = [0:N/2-1] + */ + +const int32 cosTerms_1_ov_cos_phi_N6[6] = +{ + + Qfmt29(0.50431448029008f), Qfmt29(0.54119610014620f), + Qfmt29(0.63023620700513f), Qfmt29(0.82133981585229f), + Qfmt29(1.30656296487638f), Qfmt29(3.83064878777019f) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void pvmp3_mdct_6(int32 vec[], int32 *history) +{ + int32 i; + int32 tmp; + int32 tmp1; + int32 tmp2; + + int32 *pt_vec = vec; + int32 *pt_vec_o = vec; + const int32 *pt_cos = cosTerms_1_ov_cos_phi_N6; + + for (i = 2; i != 0; i--) + { + tmp = *(pt_vec++); + tmp1 = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_vec_o++) = fxp_mul32_Q29(tmp, *(pt_cos++)); + *(pt_vec_o++) = fxp_mul32_Q29(tmp1, *(pt_cos++)); + *(pt_vec_o++) = fxp_mul32_Q29(tmp2, *(pt_cos++)); + } + + + pvmp3_dct_6(vec); // Even terms + + + tmp = -(vec[0] + vec[1]); + history[3] = tmp; + history[2] = tmp; + tmp = -(vec[1] + vec[2]); + vec[0] = vec[3] + vec[4]; + vec[1] = vec[4] + vec[5]; + history[4] = tmp; + history[1] = tmp; + tmp = -(vec[2] + vec[3]); + vec[4] = -vec[1]; + history[5] = tmp; + history[0] = tmp; + + vec[2] = vec[5]; + vec[3] = -vec[5]; + vec[5] = -vec[0]; + +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.h new file mode 100644 index 0000000..ebfceac --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.h @@ -0,0 +1,98 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Pathname: ./include/pvmp3_mdct_6.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines function mdct_18, dct9, mdct_6 and dct_6 + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_MDCT_6_H +#define PVMP3_MDCT_6_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define Qfmt(a) (Int32)(a*((Int32)1<<28) ) +#define Qfmt1(a) (Int32)(a*((Int32)0x7FFFFFFF)) +#define Qfmt2(a) (Int32)(a*((Int32)1<<27)) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + void pvmp3_mdct_6(int32 vec[], int32 *overlap); + + void pvmp3_dct_6(int32 vec[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.cpp new file mode 100644 index 0000000..1f24227 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.cpp @@ -0,0 +1,239 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_get_scale_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + mp3SideInfo *si, side information + int32 gr, granule + int32 ch, channel + mp3Header *info, mp3 header information + uint32 *scalefac_buffer, + uint32 *scalefac_IIP_buffer, + tbits *pMainData bit stream Data + + Returns + + uint32 *scalefac_buffer, acquired scale band data + uint32 *scalefac_IIP_buffer, auxiliary scale data + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + get scale data for mpeg2 layer III LSF extension + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_mpeg2_get_scale_data.h" +#include "pvmp3_getbits.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const uint32 nr_of_sfb_block[6][3][4] = +{ {{ 6, 5, 5, 5}, { 9, 9, 9, 9}, { 6, 9, 9, 9}}, + {{ 6, 5, 7, 3}, { 9, 9, 12, 6}, { 6, 9, 12, 6}}, + {{11, 10, 0, 0}, { 18, 18, 0, 0}, {15, 18, 0, 0}}, + {{ 7, 7, 7, 0}, { 12, 12, 12, 0}, { 6, 15, 12, 0}}, + {{ 6, 6, 6, 3}, { 12, 9, 9, 6}, { 6, 12, 9, 6}}, + {{ 8, 8, 5, 0}, { 15, 12, 9, 0}, { 6, 18, 9, 0}} +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_mpeg2_get_scale_data(mp3SideInfo *si, + int32 gr, + int32 ch, + mp3Header *info, + uint32 *scalefac_buffer, + uint32 *scalefac_IIP_buffer, + tmp3Bits *pMainData) +{ + int16 i; + int16 j; + int16 k; + int16 blocktypenumber = 0; + int16 blocknumber = 0; + + granuleInfo *gr_info = &(si->ch[ch].gran[gr]); + uint32 scalefac_comp, int_scalefac_comp; + uint32 new_slen[4] = { 0, 0, 0, 0 }; + + scalefac_comp = gr_info->scalefac_compress; + + + if ((((info->mode_ext &1)) && (ch == 1))) + { + /* intensity_scale = scalefac_comp %2; */ + int_scalefac_comp = scalefac_comp >> 1; + + if (int_scalefac_comp < 180) + { + new_slen[0] = int_scalefac_comp / 36; + new_slen[1] = (int_scalefac_comp % 36) / 6; + new_slen[2] = int_scalefac_comp % 6; + blocknumber = 3; + } + else if (int_scalefac_comp < 244) + { + int_scalefac_comp -= 180; + new_slen[0] = (int_scalefac_comp & 63) >> 4; + new_slen[1] = (int_scalefac_comp & 15) >> 2; + new_slen[2] = int_scalefac_comp & 3; + blocknumber = 4; + } + else if (int_scalefac_comp <= 255) + { + int_scalefac_comp -= 244; + new_slen[0] = (int_scalefac_comp) / 3; + new_slen[1] = (int_scalefac_comp) % 3; + new_slen[2] = 0; + blocknumber = 5; + } + new_slen[3] = 0; + si->ch[ch].gran[gr].preflag = 0; + } + else + { + if (scalefac_comp < 400) + { + new_slen[0] = (scalefac_comp >> 4) / 5; + new_slen[1] = (scalefac_comp >> 4) % 5; + new_slen[2] = (scalefac_comp & 15) >> 2 ; + new_slen[3] = (scalefac_comp & 3); + si->ch[ch].gran[gr].preflag = 0; + + blocknumber = 0; + } + else if (scalefac_comp < 500) + { + scalefac_comp -= 400; + new_slen[0] = (scalefac_comp >> 2) / 5; + new_slen[1] = (scalefac_comp >> 2) % 5; + new_slen[2] = scalefac_comp & 3; + new_slen[3] = 0; + si->ch[ch].gran[gr].preflag = 0; + blocknumber = 1; + } + else if (scalefac_comp < 512) + { + scalefac_comp -= 500; + new_slen[0] = scalefac_comp / 3; + new_slen[1] = scalefac_comp % 3; + new_slen[2] = 0 ; + new_slen[3] = 0; + si->ch[ch].gran[gr].preflag = 1; + blocknumber = 2; + } + } + + if (gr_info->block_type == 2) + { + if (gr_info->mixed_block_flag) + { + blocktypenumber = 2; + } + else + { + blocktypenumber = 1; + } + } + + k = 0; + for (i = 0; i < 4; i++) + { + if (new_slen[i]) + { + for (j = 0; j < (int16)nr_of_sfb_block[blocknumber][blocktypenumber][i]; j++) + { + scalefac_buffer[k] = getNbits(pMainData, new_slen[i]); + scalefac_IIP_buffer[k] = (1L << new_slen[i]) - 1; + k++; + } + } + else + { + for (j = 0; j < (int16)nr_of_sfb_block[blocknumber][blocktypenumber][i]; j++) + { + scalefac_buffer[k] = 0; + scalefac_IIP_buffer[k] = 0; + k++; + } + } + } +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.h new file mode 100644 index 0000000..a7911f9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.h @@ -0,0 +1,98 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_get_scale_data.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_MPEG2_GET_SCALE_DATA_H +#define PVMP3_MPEG2_GET_SCALE_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_mpeg2_get_scale_data(mp3SideInfo *si, + int32 gr, + int32 ch, + mp3Header *info, + uint32 *scalefac_buffer, + uint32 *scalefac_IIP_buffer, + tmp3Bits *pMainData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.cpp new file mode 100644 index 0000000..ff09df3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.cpp @@ -0,0 +1,194 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_get_scale_factors.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + + mp3ScaleFactors *scalefac, + mp3SideInfo *si, side information + int32 gr, granule + int32 ch, channel + mp3Header *info, mp3 header information + uint32 *scalefac_IIP_buffer, auxiliary scale data + tbits *pMainData bit stream Data + + Returns + + III_scalefac_t *scalefac, scale factor + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + get scale factor for mpe2 layer III LSF extension + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_mpeg2_get_scale_factors.h" +#include "pvmp3_mpeg2_get_scale_data.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_mpeg2_get_scale_factors(mp3ScaleFactors *scalefac, + mp3SideInfo *si, + int32 gr, + int32 ch, + mp3Header *info, + uint32 *scalefac_IIP_buffer, + tmp3Bits *pMainData) +{ + + int32 sfb; + int32 k = 0; + int32 window; + uint32 *scalefac_buffer = &scalefac_IIP_buffer[56]; + + granuleInfo *gr_info = &(si->ch[ch].gran[gr]); + + pvmp3_mpeg2_get_scale_data(si, + gr, + ch, + info, + (uint32 *)scalefac_buffer, + (uint32 *)scalefac_IIP_buffer, + pMainData); + + + if (gr_info->window_switching_flag && (gr_info->block_type == 2)) + { + if (gr_info->mixed_block_flag) + { + for (sfb = 0; sfb < 6; sfb++) + { + scalefac->l[sfb] = scalefac_buffer[sfb]; + } + + + k = 6; + for (sfb = 3; sfb < 12; sfb++) + { + for (window = 0; window < 3; window++) + { + scalefac->s[window][sfb] = scalefac_buffer[k]; + k++; + } + } + + + /* adjust position of "illegal position" information in scalefac_IIP_buffer[] */ + /* in mixed blocks mode for short sfb, move them 3 places up. efs 3002-07-04 */ + for (sfb = 11; sfb >= 3; sfb--) + { + scalefac_IIP_buffer[3*sfb + 2] = scalefac_IIP_buffer[3*sfb - 1]; + scalefac_IIP_buffer[3*sfb + 1] = scalefac_IIP_buffer[3*sfb - 2]; + scalefac_IIP_buffer[3*sfb ] = scalefac_IIP_buffer[3*sfb - 3]; + + } + } + else + { /* SHORT*/ + for (sfb = 0; sfb < 12; sfb++) + { + for (window = 0; window < 3; window++) + { + scalefac->s[window][sfb] = scalefac_buffer[k]; + k++; + } + } + } + + scalefac->s[0][12] = 0; + scalefac->s[1][12] = 0; + scalefac->s[2][12] = 0; + + } + else + { /* LONG types 0,1,3 */ + for (sfb = 0; sfb < 21; sfb++) + { + scalefac->l[sfb] = scalefac_buffer[sfb]; + } + scalefac->l[21] = 0; + scalefac->l[22] = 0; + + } +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.h new file mode 100644 index 0000000..a4dd2a0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.h @@ -0,0 +1,100 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_get_scale_factors.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_MPEG2_GET_SCALE_FACTORS_H +#define PVMP3_MPEG2_GET_SCALE_FACTORS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_mpeg2_get_scale_factors(mp3ScaleFactors *scalefac, + mp3SideInfo *si, + int32 gr, + int32 ch, + mp3Header *info, + uint32 *scalefac_IIP_buffer, + tmp3Bits *pMainData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.cpp new file mode 100644 index 0000000..ff5fb62 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.cpp @@ -0,0 +1,691 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_stereo_proc.cpp + + Functions: + + pvmp3_st_intensity_ver2 + pvmp3_mpeg2_stereo_proc + +------------------------------------------------------------------------------ + +pvmp3_st_intensity_ver2 + + INPUT AND OUTPUT DEFINITIONS + +Input + + int32 xr[], input channel + int32 xl[], + int32 m, selecting index: io = 2(1/4) (m=0), io = 2(1/8) (m=1) + int32 is_pos, index on table is_pos_pow_eitgh_root_of_2 + int32 Start, Location of first element where stereo intensity is applied + int32 Number number of elements affected + + Returns + + int32 xl[], generated stereo channel + + + + +------------------------------------------------------------------------------ + +pvmp3_mpeg2_stereo_proc + + INPUT AND OUTPUT DEFINITIONS + +Input + + int32 xr[], input channel + int32 xl[], + mp3ScaleFactors *scalefac, scale factors structure for Right channel + granuleInfo *gr_info_l, granule structure for the left channel + granuleInfo *gr_info_r, granule structure for the rigth channel + uint32 *scalefac_IIP_buffer, auxiliary scale factor vector + mp3Header *info mp3 header info + Returns + + int32 xl[], generated stereo channel + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + stereo processing for mpeg2 layer III LSF extension + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_mpeg2_stereo_proc.h" +#include "pvmp3_stereo_proc.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_tables.h" +#include "mp3_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*a)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 is_pos_pow_eitgh_root_of_2[8] = +{ + /* --- 2^(1/8) ----- */ + Q31_fmt(1.00000000000000), Q31_fmt(0.91700404320467), Q31_fmt(0.84089641525371), + Q31_fmt(0.77110541270397), Q31_fmt(0.70710678118655), Q31_fmt(0.64841977732550), + Q31_fmt(0.59460355750136), Q31_fmt(0.54525386633263) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_st_intensity_ver2(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 m, + int32 is_pos, + int32 Start, + int32 Number) +{ + int32 k[2]; + + /* pow(io, ((is_pos + 1)>>1)); io = 2(1/4) (m=0), io = 2(1/8) (m=1) */ + k[0] = is_pos_pow_eitgh_root_of_2[((is_pos+1)&(3+(m<<2)))<<(1-m)] >> ((is_pos + 1) >> (2 + m)); + /* pow(io, (is_pos>>1)); io = 2(1/4) (m=0), io = 2(1/8) (m=1) */ + k[1] = is_pos_pow_eitgh_root_of_2[(is_pos&(3+(m<<2)))<<(1-m)] >> (is_pos >> (2 + m)); + + + int32 *pt_xr = &xr[Start]; + int32 *pt_xl = &xl[Start]; + + if (is_pos == 0) /* 0 < is_pos < 31 */ + { + pv_memcpy(pt_xl, pt_xr, Number*sizeof(*pt_xr)); + } + else if (is_pos & 1) + { + for (int32 i = Number >> 1; i != 0; i--) + { + *(pt_xl++) = (*pt_xr); + *(pt_xr) = fxp_mul32_Q32((*pt_xr) << 1, k[0]); + pt_xr++; + *(pt_xl++) = (*pt_xr); + *(pt_xr) = fxp_mul32_Q32((*pt_xr) << 1, k[0]); + pt_xr++; + } + if (Number&1) + { + *(pt_xl) = (*pt_xr); + *(pt_xr) = fxp_mul32_Q32((*pt_xr) << 1, k[0]); + } + } + else + { + for (int32 i = Number >> 1; i != 0; i--) + { + *(pt_xl++) = fxp_mul32_Q32((*(pt_xr++)) << 1, k[1]); + *(pt_xl++) = fxp_mul32_Q32((*(pt_xr++)) << 1, k[1]); + } + if (Number&1) + { + *(pt_xl) = fxp_mul32_Q32((*pt_xr) << 1, k[1]); + } + } + +} + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void pvmp3_mpeg2_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac_R, + granuleInfo *gr_info_l, + granuleInfo *gr_info_r, + uint32 *scalefac_IIP_buffer, + int32 used_freq_lines, + mp3Header *info) +{ + + int32 sfreq; + int32 sb; + int32 ss; + int32 sfbNo; + int32 sfbStart; + int32 sfb; + int32 sfbTemp; + int32 i; + int32 j; + int32 io; + + + int32 i_stereo = (info->mode == MPG_MD_JOINT_STEREO) && + (info->mode_ext & 0x1); + + int32 ms_stereo = (info->mode == MPG_MD_JOINT_STEREO) && + (info->mode_ext & 0x2); + + + if (i_stereo) + { + if (gr_info_r->scalefac_compress & 1) + { + io = 0; /* 2^(-1/4) */ + } + else + { + io = 1; /* 2^(-1/8) */ + } + + sfreq = info->version_x + (info->version_x << 1); + sfreq += info->sampling_frequency; + + if (gr_info_l->window_switching_flag && (gr_info_l->block_type == 2)) + { + if (gr_info_l->mixed_block_flag) + { + /* + * mixed blocks processing + */ + i = 31; + ss = 17; + sb = -1; + + while (i >= 0) + { + if (xl[(i*FILTERBANK_BANDS) + ss]) + { + sb = (i << 4) + (i << 1) + ss; + i = -1; + } + else + { + ss--; + if (ss < 0) + { + i--; + ss = 17; + } + } + } /* now sb is the number of highest line with value != 0 */ + /* can be between -1 (all lines zero) and 575 (no line zero) */ + + if (sb < 36) /* was (sb <= 36) */ + { + /* + * mixed blocks processing: intensity bound inside long blocks + */ + /* 1. long blocks up to intensity border: Stereo or M/S */ + if (mp3_sfBandIndex[sfreq].l[4] <= sb) + { + i = 4; + } + else + { + i = 0; + } + + while (mp3_sfBandIndex[sfreq].l[i] <= sb) + { + i++; + } + sfbTemp = i; /* from that (long) sfb on we have intensity stereo */ + + sfbNo = mp3_sfBandIndex[sfreq].l[sfbTemp]; /* number of lines to process */ + + /* from sfbStart up sfbNo lines do ms_stereo or normal stereo */ + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, sfbNo); + } + + /* 2. long blocks from intensity border up to sfb band 6: intensity */ + /* calc. MPEG_1_2_Factor[0], MPEG_1_2_Factor[1] */ + + for (sfb = sfbTemp; sfb < 6; sfb++) + { + sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; /* = Start in 0 ... 575 */ + sfbNo = mp3_sfBandIndex[sfreq].l[sfb+1] - mp3_sfBandIndex[sfreq].l[sfb]; /* No of lines to process */ + + if ((uint32)(scalefac_R->l[sfb]) != scalefac_IIP_buffer[sfb]) + { + pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->l[sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + + /* 3. now process all sfb with short blocks (3...12), all in intensity mode */ + + for (j = 0; j < 3; j++) + { + /* first calculate directional factors for intensity stereo, + * for all sfb in intensity mode, but only + * if they do not have "illegal" position: + */ + /* to do this for all sfb we have to get information for last scale factor band: + * here we clearly have more than one sfb in intensity mode, + * so copy factors and legal/illegal information from sfb11 to sfb12 + */ + (scalefac_R->s[j][12]) = (scalefac_R->s[j][11]); + scalefac_IIP_buffer[36 + j] = scalefac_IIP_buffer[33 + j]; /* legal/illegal in sfb 12 same as in sfb 11 */ + + for (sfb = 3; sfb < 13; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo; + + if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j]) + { + pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + } /* for (j = 0; j < 3; j++) */ + } + else /* else then (sb >= 36) */ + { + /* + * mixed blocks processing: intensity bound outside long blocks + */ + + /* 2. short blocks, do for all 3 */ + /* ------------------------------ */ + for (j = 0; j < 3; j++) + { + int32 sfbcnt = -1; + + for (sfb = 12; sfb >= 3; sfb--) + { + int32 lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + + i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1; + + while (lines > 0) + { + if (xl[i]) + { + sfbcnt = sfb; + sfb = -10; + lines = -10; + } + lines--; + i--; + } + } + + sfbcnt += 1; + if (sfbcnt < 3) + { + sfbcnt = 3; /* should not be necessary */ + } + + sfbTemp = sfbcnt; /* from this (short) sfb on we have intensity mode */ + /* can have values between 3 (all short sfb in intensity) */ + /* and 13 (no short sfb in intensity mode) */ + + /* 3. from sfbTemp to last sfb calculate is_ratio values: */ + /* first calculate directional factors for intensity stereo, */ + /* for all sfb in intensity mode, but only */ + /* if they do not have "illegal" position: */ + + /* to do this for all sfb we have to get information for last scale factor band: */ + /* get factors for last scale factor band: */ + /* more than one sfb in intensity mode, + copy factors and legal/illegal information from sfb11 to sfb12 */ + if (sfbTemp < 12) + { + (scalefac_R->s[j][12]) = (scalefac_R->s[j][11]); + scalefac_IIP_buffer[36 + j] = scalefac_IIP_buffer[33 + j]; /* legal/illegal in sfb 12 same as in sfb 11 */ + } + else if (sfbTemp == sfb) + /* only sfb 12 in intensity mode, use factors corresponding to is_pos[12] == 0 */ + { + (scalefac_R->s[j][12]) = 0; + scalefac_IIP_buffer[36 + j] = 1; /* the scf value 0 in sfb12 is "legal" */ + } + /* if sfbTemp > sfb (no sfb in intensity mode): do nothing */ + + + /* 4. do normal stereo or MS stereo from sfb 3 to < sfbTemp: */ + for (sfb = 3; sfb < sfbTemp; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + + /* 5. now intensity stereo processing of the remaining sfb's: */ + + for (sfb = sfbTemp; sfb < 13; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo; + if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j]) + { + pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + /* end of correction by efs 2003-07-04 */ + } /* for (j = 0; j < 3; j++) */ + + + /* long blocks 0 up to sfb band 6: no intensity */ + + sfbNo = mp3_sfBandIndex[sfreq].l[6]; /* number of lines to process */ + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, sfbNo); + } + + } /* if intensity bound inside or outside long blocks */ + } /* if (gr_info->mixed_block_flag) */ + else + { + /* + * short block processing + */ + for (j = 0; j < 3; j++) + { + int32 sfbcnt = -1; + + for (sfb = 12; sfb >= 0; sfb--) + { + int32 lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1; + + while (lines > 0) + { + if (xl[i]) + { + sfbcnt = sfb; + sfb = -10; + lines = -10; + } + lines--; + i--; + } + } + + sfbcnt += 1; + + /* start of corrected version by efs 2003-07-04 */ + sfbTemp = sfbcnt; /* from this (short) sfb on we have intensity mode */ + /* can have values between 3 (all short sfb in intensity) */ + /* and 13 (no short sfb in intensity mode) */ + + /* first calculate directional factors for intensity stereo, + for all sfb in intensity mode, but only + if they do not have "illegal" position: */ + + /* to do this for all sfb we have to get information for last scale factor band: */ + /* get factors for last scale factor band: */ + /* more than one sfb in intensity mode, + copy factors and legal/illegal information from sfb11 to sfb12 */ + if (sfbTemp < 12) + { + (scalefac_R->s[j][12]) = (scalefac_R->s[j][11]); + scalefac_IIP_buffer[36 + j] = scalefac_IIP_buffer[33 + j]; /* legal/illegal in sfb 12 same as in sfb 11 */ + } + else if (sfbTemp == 12) + /* only sfb 12 in intensity mode, use factors corresponding to is_pos[12] == 0 */ + { + (scalefac_R->s[j][12]) = 0; + scalefac_IIP_buffer[36 + j] = 1; /* the scf value 0 in sfb12 is "legal" */ + } + /* if sfbTemp > sfb (no sfb in intensity mode): do nothing */ + + + /* Now process audio samples */ + /* first process lower sfb's not in intensity mode */ + for (sfb = 0; sfb < sfbTemp; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + + /* now intensity stereo processing of the remaining sfb's: */ + for (sfb = sfbTemp; sfb < 13; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo; + + if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j]) + { + pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + + } /* for (j = 0; j < 3; j++) */ + + } /* end of else ( gr_info->mixed_block_flag) */ + + } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */ + else + { + /* + * long block processing + */ + i = 31; + ss = 17; + sb = 0; + + while (i >= 0) + { + if (xl[(i*FILTERBANK_BANDS) + ss]) + { + sb = (i << 4) + (i << 1) + ss; + /* i = -1 patched RF 24-09-2002 */ + i = -2; + } + else + { + ss--; + if (ss < 0) + { + i--; + ss = 17; + } + } + } + + /* patched RF 24-09-2002 */ + if (sb) + { + if (mp3_sfBandIndex[sfreq].l[14] <= sb) + { + i = 14; + } + else if (mp3_sfBandIndex[sfreq].l[7] <= sb) + { + i = 7; + } + else + { + i = 0; + } + + while (mp3_sfBandIndex[sfreq].l[i] <= sb) + { + i++; + } + } + + else + { + if (i == -1) + { + /* all xr[1][][] are 0: set IS bound sfb to 0 */ + i = 0; + } + else + { + /* xr[1][0][0] is unequal 0 and all others are 0: set IS bound sfb to 1 */ + i = 1; + } + } + /* corrected version by efs 2003-07-04 */ + sfbTemp = i; /* from this (long) sfb on we have intensity mode */ + /* can have values between 0 (all long sfb in intensity) */ + /* and 22 (no long sfb in intensity mode) */ + + /* first calculate directional factors for intensity stereo, + for all sfb in intensity mode, but only if they + do not have "illegal" position: */ + + /* to do this for all sfb we have to get information for last scale factor band: */ + if (sfbTemp < 21) + /* more than one sfb in intensity mode, */ + /* copy factors and legal/illegal information from sfb20 to sfb21 */ + { + (scalefac_R->l[21]) = (scalefac_R->l[20]); + scalefac_IIP_buffer[21] = scalefac_IIP_buffer[20]; /* legal/illegal in sfb 21 same as in sfb 20 */ + } + else if (sfbTemp == 21) + /* only sfb 21 in intensity mode, is_pos[21] = 0 */ + { + (scalefac_R->l[21]) = 0; + scalefac_IIP_buffer[21] = 1; /* the scf value 0 in sfb21 is "legal" */ + } + /* if sfbTemp > 21 (no sfb in intensity mode): do nothing */ + + + /* Now process audio samples */ + /* first process lower sfb's not in intensity mode */ + + sfbNo = mp3_sfBandIndex[sfreq].l[sfbTemp] - mp3_sfBandIndex[sfreq].l[0]; + sfbStart = mp3_sfBandIndex[sfreq].l[0]; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + /* now intensity stereo processing of the remaining sfb's: */ + for (sfb = sfbTemp; sfb < 22; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].l[sfb+1] - mp3_sfBandIndex[sfreq].l[sfb]; /* number of lines to process */ + sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; /* start of sfb */ + + if ((uint32)(scalefac_R->l[sfb]) != scalefac_IIP_buffer[sfb]) /* "legal" position ? */ + { + pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->l[sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (sfb = sfbTemp; sfb < 22; sfb++) */ + + } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */ + + } /* if (i_stereo) */ + else + { + /* + * normal or ms stereo processing + */ + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, used_freq_lines); + } + + } /* if (i_stereo) */ + +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.h new file mode 100644 index 0000000..a9aa0f0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.h @@ -0,0 +1,105 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_stereo_proc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_MPEG2_STEREO_PROC_H +#define PVMP3_MPEG2_STEREO_PROC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_mpeg2_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, + granuleInfo *gr_info_l, + granuleInfo *gr_info_r, + uint32 *scalefac_IIP_buffer, + int32 used_freq_lines, + mp3Header *info); + + + void pvmp3_st_intensity_ver2(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 m, + int32 is_pos, + int32 Start, + int32 Number); +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.cpp new file mode 100644 index 0000000..fdf1427 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.cpp @@ -0,0 +1,166 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_normalize.cpp + + Date: 10/02/2007 + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + Int32 x 32-bit integer non-zero input +Returns + Int32 i number of leading zeros on x + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Returns number of leading zeros on the non-zero input + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "pvmp3_normalize.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +#if ((PV_CPU_ARCH_VERSION >=5) && ((PV_COMPILER == EPV_ARM_RVCT) || (PV_COMPILER == EPV_ARM_GNUC))) + + +/* function is inlined in header file */ + + +#else + +int32 pvmp3_normalize(int32 x) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + int32 i; + + + if (x > 0x0FFFFFFF) + { + i = 0; /* most likely case */ + } + else if (x > 0x00FFFFFF) + { + i = 3; /* second most likely case */ + } + else if (x > 0x0000FFFF) + { + i = x > 0x000FFFFF ? 7 : 11; + } + else + { + if (x > 0x000000FF) + { + i = x > 0x00000FFF ? 15 : 19; + } + else + { + i = x > 0x0000000F ? 23 : 27; + } + } + + + x <<= i; + + switch (x & 0x78000000) + { + case 0x08000000: + i += 3; + break; + + case 0x18000000: + case 0x10000000: + i += 2; + break; + case 0x28000000: + case 0x20000000: + case 0x38000000: + case 0x30000000: + i++; + + default: + ; + } + + return i; + +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.h new file mode 100644 index 0000000..b19634e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_normalize.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PVMP3_NORMALIZE_H +#define PVMP3_NORMALIZE_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ +#if ((PV_CPU_ARCH_VERSION >=5) && (PV_COMPILER == EPV_ARM_GNUC)) + +__inline int32 pvmp3_normalize(int32 x) +{ + register int32 y; + register int32 ra = x; + + + asm volatile( + "clz %0, %1\n\t" + "sub %0, %0, #1" + : "=&r*i"(y) + : "r"(ra)); + return (y); + +} + +#else + +#ifdef __cplusplus +extern "C" +{ +#endif + + int32 pvmp3_normalize(int32 x); + +#ifdef __cplusplus +} +#endif + +#endif + + + +#endif /* PV_NORMALIZE_H */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.cpp new file mode 100644 index 0000000..df83dc9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.cpp @@ -0,0 +1,178 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_poly_phase_synthesis.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Input + tmp3dec_chan *pChVars, decoder state structure per channel + int32 numChannels, number of channels + e_equalization equalizerType, equalization mode + int16 *outPcm pointer to the PCM output data + + Output + int16 *outPcm pointer to the PCM output data + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + polyphase synthesis + Each time the subband samples for all 32 polyphase subbands of one + channel have been calculated, they can be applied to the synthesis + subband filter and 32 consecutive audio samples can be calculated + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_poly_phase_synthesis.h" +#include "pvmp3_polyphase_filter_window.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_dct_16.h" +#include "pvmp3_equalizer.h" +#include "mp3_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_poly_phase_synthesis(tmp3dec_chan *pChVars, + int32 numChannels, + e_equalization equalizerType, + int16 *outPcm) +{ + /* + * Equalizer + */ + pvmp3_equalizer(pChVars->circ_buffer, + equalizerType, + pChVars->work_buf_int32); + + + int16 * ptr_out = outPcm; + + + for (int32 band = 0; band < FILTERBANK_BANDS; band += 2) + { + int32 *inData = &pChVars->circ_buffer[544 - (band<<5)]; + + /* + * DCT 32 + */ + + pvmp3_split(&inData[16]); + + pvmp3_dct_16(&inData[16], 0); + pvmp3_dct_16(inData, 1); // Even terms + + pvmp3_merge_in_place_N32(inData); + + pvmp3_polyphase_filter_window(inData, + ptr_out, + numChannels); + + inData -= SUBBANDS_NUMBER; + + /* + * DCT 32 + */ + + pvmp3_split(&inData[16]); + + pvmp3_dct_16(&inData[16], 0); + pvmp3_dct_16(inData, 1); // Even terms + + pvmp3_merge_in_place_N32(inData); + + pvmp3_polyphase_filter_window(inData, + ptr_out + (numChannels << 5), + numChannels); + + ptr_out += (numChannels << 6); + + inData -= SUBBANDS_NUMBER; + + }/* end band loop */ + + pv_memmove(&pChVars->circ_buffer[576], + pChVars->circ_buffer, + 480*sizeof(*pChVars->circ_buffer)); + +} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.h new file mode 100644 index 0000000..2e63b62 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_poly_phase_synthesis.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_POLY_PHASE_SYNTHESIS_H +#define PVMP3_POLY_PHASE_SYNTHESIS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "s_tmp3dec_chan.h" +#include "pvmp3decoder_api.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_poly_phase_synthesis(tmp3dec_chan *pChVars, + int32 numChannels, + e_equalization equalizerType, + int16 *outPcm); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.cpp new file mode 100644 index 0000000..a9f3ce3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.cpp @@ -0,0 +1,232 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_polyphase_filter_window.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + +Input + int32 *synth_buffer, synthesis input buffer + int16 *outPcm, generated output ( 32 values) + int32 numChannels number of channels + Returns + + int16 *outPcm + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + apply polyphase filter window + Input 32 subband samples + Calculate 64 values +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ +#include "oscl_base_macros.h"// has integer values of PV_COMPILER + +#if !((PV_CPU_ARCH_VERSION >=4) && ((PV_COMPILER == EPV_ARM_GNUC)|| (PV_COMPILER == EPV_ARM_RVCT))) +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_polyphase_filter_window.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_tables.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module1 specific macros here +----------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module1 +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module_x +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module_x but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_polyphase_filter_window(int32 *synth_buffer, + int16 *outPcm, + int32 numChannels) +{ + int32 sum1; + int32 sum2; + const int32 *winPtr = pqmfSynthWin; + int32 i; + + + for (int16 j = 1; j < SUBBANDS_NUMBER / 2; j++) + { + sum1 = 0x00000020; + sum2 = 0x00000020; + + + for (i = (SUBBANDS_NUMBER >> 1); + i < HAN_SIZE + (SUBBANDS_NUMBER >> 1); + i += SUBBANDS_NUMBER << 4) + { + int32 *pt_1 = &synth_buffer[ i+j]; + int32 *pt_2 = &synth_buffer[ i-j]; + int32 temp1 = pt_1[ 0]; + int32 temp3 = pt_2[ SUBBANDS_NUMBER*15 ]; + int32 temp2 = pt_2[ SUBBANDS_NUMBER* 1 ]; + int32 temp4 = pt_1[ SUBBANDS_NUMBER*14 ]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[ 0]); + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[ 0]); + sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[ 1]); + sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[ 1]); + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[ 2]); + sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[ 2]); + sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[ 3]); + sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[ 3]); + + temp1 = pt_1[ SUBBANDS_NUMBER* 2]; + temp3 = pt_2[ SUBBANDS_NUMBER*13]; + temp2 = pt_2[ SUBBANDS_NUMBER* 3]; + temp4 = pt_1[ SUBBANDS_NUMBER*12]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[ 4]); + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[ 4]); + sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[ 5]); + sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[ 5]); + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[ 6]); + sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[ 6]); + sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[ 7]); + sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[ 7]); + + temp1 = pt_1[ SUBBANDS_NUMBER* 4 ]; + temp3 = pt_2[ SUBBANDS_NUMBER*11 ]; + temp2 = pt_2[ SUBBANDS_NUMBER* 5 ]; + temp4 = pt_1[ SUBBANDS_NUMBER*10 ]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[ 8]); + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[ 8]); + sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[ 9]); + sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[ 9]); + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[10]); + sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[10]); + sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[11]); + sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[11]); + + temp1 = pt_1[ SUBBANDS_NUMBER*6 ]; + temp3 = pt_2[ SUBBANDS_NUMBER*9 ]; + temp2 = pt_2[ SUBBANDS_NUMBER*7 ]; + temp4 = pt_1[ SUBBANDS_NUMBER*8 ]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[12]); + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[12]); + sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[13]); + sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[13]); + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[14]); + sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[14]); + sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[15]); + sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[15]); + + winPtr += 16; + } + + + + int32 k = j << (numChannels - 1); + outPcm[k] = saturate16(sum1 >> 6); + outPcm[(numChannels<<5) - k] = saturate16(sum2 >> 6); + } + + + + sum1 = 0x00000020; + sum2 = 0x00000020; + + + for (i = 16; i < HAN_SIZE + 16; i += (SUBBANDS_NUMBER << 2)) + { + int32 *pt_synth = &synth_buffer[i]; + int32 temp1 = pt_synth[ 0 ]; + int32 temp2 = pt_synth[ SUBBANDS_NUMBER ]; + int32 temp3 = pt_synth[ SUBBANDS_NUMBER/2]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[0]) ; + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[1]) ; + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[2]) ; + + temp1 = pt_synth[ SUBBANDS_NUMBER<<1 ]; + temp2 = pt_synth[ 3*SUBBANDS_NUMBER ]; + temp3 = pt_synth[ SUBBANDS_NUMBER*5/2]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[3]) ; + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[4]) ; + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[5]) ; + + winPtr += 6; + } + + + outPcm[0] = saturate16(sum1 >> 6); + outPcm[(SUBBANDS_NUMBER/2)<<(numChannels-1)] = saturate16(sum2 >> 6); + + +} + +#endif // If not assembly + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.h new file mode 100644 index 0000000..3e68746 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.h @@ -0,0 +1,114 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decode_header.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_POLYPHASE_FILTER_WINDOW_H +#define PVMP3_POLYPHASE_FILTER_WINDOW_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "s_tmp3dec_chan.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define MAX_16BITS_INT 0x7FFF + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + + + inline int16 saturate16(int32 sample) + { + + if ((sample >> 15) ^(sample >> 31)) + { + sample = MAX_16BITS_INT ^(sample >> 31); + } + return sample; + + } + + + void pvmp3_polyphase_filter_window(int32 *synth_buffer, + int16 *outPcm, + int32 numChannels); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.cpp new file mode 100644 index 0000000..3fa0687 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.cpp @@ -0,0 +1,188 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_reorder.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + int32 xr[ ], rescaled data + struct gr_info_s *gr_info, granule structure + mp3Header *info, mp3 header info + int32 Scratch_mem[168] for temporary usage + + Outputs: + + int32 xr[ ], reordered data + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + If short blocks are used (block_type[gr][ch]=='10'), the rescaled data + xr[scf_band][window][freq_line] shall be reordered in polyphase subband + order, xr[subband][window][freq_line], prior to the IMDCT operation. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_reorder.h" +#include "pvmp3_tables.h" +#include "mp3_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_reorder(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + granuleInfo *gr_info, + int32 *used_freq_lines, + mp3Header *info, + int32 Scratch_mem[168]) +{ + int32 sfreq = info->version_x + (info->version_x << 1); + sfreq += info->sampling_frequency; + + if (gr_info->window_switching_flag && (gr_info->block_type == 2)) + { + int32 sfb_lines; + int32 freq; + int32 src_line; + int32 sfb; + if (gr_info->mixed_block_flag) + { + /* REORDERING FOR REST SWITCHED SHORT */ + sfb = 3; /* no reorder for low 2 subbands */ + src_line = 36; + } + else + { /* pure short */ + sfb = 0; + src_line = 0; + } + int16 ct = src_line; + + for (; sfb < 13; sfb++) + { + if (*used_freq_lines > 3*mp3_sfBandIndex[sfreq].s[sfb+1]) + { + sfb_lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + + for (freq = 0; freq < 3*sfb_lines; freq += 3) + { + int32 tmp1 = xr[src_line]; + int32 tmp2 = xr[src_line+(sfb_lines)]; + int32 tmp3 = xr[src_line+(sfb_lines<<1)]; + src_line++; + Scratch_mem[freq ] = tmp1; + Scratch_mem[freq+1] = tmp2; + Scratch_mem[freq+2] = tmp3; + } + src_line += (sfb_lines << 1); + + pv_memcpy(&xr[ct], Scratch_mem, sfb_lines*3*sizeof(int32)); + ct += sfb_lines + (sfb_lines << 1); + + } + else + { + + sfb_lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + + for (freq = 0; freq < 3*sfb_lines; freq += 3) + { + int32 tmp1 = xr[src_line]; + int32 tmp2 = xr[src_line+(sfb_lines)]; + int32 tmp3 = xr[src_line+(sfb_lines<<1)]; + src_line++; + Scratch_mem[freq ] = tmp1; + Scratch_mem[freq+1] = tmp2; + Scratch_mem[freq+2] = tmp3; + } + + pv_memcpy(&xr[ct], Scratch_mem, sfb_lines*3*sizeof(int32)); + + *used_freq_lines = mp3_sfBandIndex[sfreq].s[sfb+1] * 3; + + sfb = 13; /* force out of the for-loop */ + } + } + } +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.h new file mode 100644 index 0000000..19a79a9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.h @@ -0,0 +1,96 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_reorder.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_REORDER_H +#define PVMP3_REORDER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_reorder(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + granuleInfo *gr_info, + int32 *used_freq_lines, + mp3Header *info, + int32 Scratch_mem[168]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.cpp new file mode 100644 index 0000000..4a0532f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.cpp @@ -0,0 +1,293 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_seek_synch.cpp + + Functions: + pvmp3_seek_synch + pvmp3_header_sync + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +pvmp3_frame_synch + +Input + pExt = pointer to the external interface structure. See the file + pvmp3decoder_api.h for a description of each field. + Data type of pointer to a tPVMP3DecoderExternal + structure. + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tmp3dec_file structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tmp3dec_file + structure. + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + search mp3 sync word, when found, it verifies, based on header parameters, + the locations of the very next sync word, + - if fails, then indicates a false sync, + - otherwise, it confirm synchronization of at least 2 consecutives frames + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_seek_synch.h" +#include "pvmp3_getbits.h" +#include "s_tmp3dec_file.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_tables.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +ERROR_CODE pvmp3_frame_synch(tPVMP3DecoderExternal *pExt, + void *pMem) /* bit stream structure */ +{ + uint16 val; + ERROR_CODE err; + + tmp3dec_file *pVars; + + pVars = (tmp3dec_file *)pMem; + + pVars->inputStream.pBuffer = pExt->pInputBuffer; + pVars->inputStream.usedBits = (pExt->inputBufferUsedLength << 3); // in bits + + + pVars->inputStream.inputBufferCurrentLength = (pExt->inputBufferCurrentLength); // in bits + + err = pvmp3_header_sync(&pVars->inputStream); + + if (err == NO_DECODING_ERROR) + { + /* validate synchronization by checking two consecutive sync words */ + + // to avoid multiple bitstream accesses + uint32 temp = getNbits(&pVars->inputStream, 21); + // put back whole header + pVars->inputStream.usedBits -= 21 + SYNC_WORD_LNGTH; + + int32 version; + + switch (temp >> 19) /* 2 */ + { + case 0: + version = MPEG_2_5; + break; + case 2: + version = MPEG_2; + break; + case 3: + version = MPEG_1; + break; + default: + version = INVALID_VERSION; + break; + } + + int32 freq_index = (temp << 20) >> 30; + + if (version != INVALID_VERSION && (freq_index != 3)) + { + int32 numBytes = fxp_mul32_Q28(mp3_bitrate[version][(temp<<16)>>28] << 20, + inv_sfreq[freq_index]); + + numBytes >>= (20 - version); + + if (version != MPEG_1) + { + numBytes >>= 1; + } + if ((temp << 22) >> 31) + { + numBytes++; + } + + if (numBytes > (int32)pVars->inputStream.inputBufferCurrentLength) + { + /* frame should account for padding and 2 bytes to check sync */ + pExt->CurrentFrameLength = numBytes + 3; + return (SYNCH_LOST_ERROR); + } + else if (numBytes == (int32)pVars->inputStream.inputBufferCurrentLength) + { + /* No enough data to validate, but current frame appears to be correct ( EOF case) */ + pExt->inputBufferUsedLength = pVars->inputStream.usedBits >> 3; + return (NO_DECODING_ERROR); + } + else + { + + int32 offset = pVars->inputStream.usedBits + ((numBytes) << 3); + + offset >>= INBUF_ARRAY_INDEX_SHIFT; + uint8 *pElem = pVars->inputStream.pBuffer + offset; + uint16 tmp1 = *(pElem++); + uint16 tmp2 = *(pElem); + + val = (tmp1 << 3); + val |= (tmp2 >> 5); + } + } + else + { + val = 0; // force mismatch + } + + if (val == SYNC_WORD) + { + pExt->inputBufferUsedLength = pVars->inputStream.usedBits >> 3; /// !!!!! + err = NO_DECODING_ERROR; + } + else + { + pExt->inputBufferCurrentLength = 0; + err = SYNCH_LOST_ERROR; + } + } + else + { + pExt->inputBufferCurrentLength = 0; + } + + return(err); + +} + +/* +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +pvmp3_header_sync + +Input + tmp3Bits *inputStream, structure holding the input stream parameters + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + search mp3 sync word + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +ERROR_CODE pvmp3_header_sync(tmp3Bits *inputStream) +{ + uint16 val; + uint32 availableBits = (inputStream->inputBufferCurrentLength << 3); // in bits + + // byte aligment + inputStream->usedBits = (inputStream->usedBits + 7) & 8; + + val = (uint16)getUpTo17bits(inputStream, SYNC_WORD_LNGTH); + + while (((val&SYNC_WORD) != SYNC_WORD) && (inputStream->usedBits < availableBits)) + { + val <<= 8; + val |= getUpTo9bits(inputStream, 8); + } + + if ((val&SYNC_WORD) == SYNC_WORD && (inputStream->usedBits < availableBits)) + { + return(NO_DECODING_ERROR); + } + else + { + return(SYNCH_LOST_ERROR); + } + +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.h new file mode 100644 index 0000000..4250283 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.h @@ -0,0 +1,98 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_seek_synch.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_SEEK_SYNCH_H +#define PVMP3_SEEK_SYNCH_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" +#include "pvmp3decoder_api.h" +#include "s_tmp3dec_file.h" +#include "pvmp3_dec_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + ERROR_CODE pvmp3_frame_synch(tPVMP3DecoderExternal *pExt, + void *pMem); + + ERROR_CODE pvmp3_header_sync(tmp3Bits *inputStream); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* DECODE_READ_INPUT_H */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.cpp new file mode 100644 index 0000000..d69a46d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.cpp @@ -0,0 +1,676 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_stereo_proc.cpp + + Functions: + + pvmp3_st_mid_side + pvmp3_st_intensity + pvmp3_stereo_proc + +------------------------------------------------------------------------------ + +pvmp3_st_mid_side + + INPUT AND OUTPUT DEFINITIONS + +Input + + int32 xr[], input channel + int32 xl[], + int32 Start, Location of first element where stereo intensity is applied + int32 Number number of elements affected + + Returns + + int32 xl[], generated stereo channel + + +------------------------------------------------------------------------------ + +pvmp3_st_intensity + + INPUT AND OUTPUT DEFINITIONS + +Input + + int32 xr[], input channel + int32 xl[], + int32 is_pos, index to table is_ratio_factor[] + int32 Start, Location of first element where stereo intensity is applied + int32 Number number of elements affected + + Returns + + int32 xl[], generated stereo channel + + +------------------------------------------------------------------------------ + +pvmp3_stereo_proc + + INPUT AND OUTPUT DEFINITIONS + +Input + + int32 xr[], input channel + int32 xl[], + mp3ScaleFactors *scalefac, scale factors structure + struct gr_info_s *gr_info, granule structure + mp3Header *info mp3 header info + Returns + + int32 xl[], generated stereo channel + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + stereo processing for mpeg1 layer III + After requantization, the reconstructed values are processed for ms_stereo + or intensity_stereo modes or both, before passing them to the synthesis + filterbank + + In ms_stereo mode the values of the normalized middle/side channels + M[l] and S[l] are transmitted instead of the left/right channel values + L[l] and R[l]. From here, L[l] and R[l] are reconstructed + + Intensity_stereo is done by specifying the magnitude (via the + scalefactors of the left channel) and a stereo position is_pos[sfb], + which is transmitted instead of scalefactors of the right channel. + The stereo position is used to derive the left and right channel signals + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_stereo_proc.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_tables.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define N31 31 + +#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*a)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/* + * TmpFac= tan(is_pos * (PI /12)); + * + * TmpFac /= (1 + TmpFac); + * + */ + +const int32 is_ratio_factor[8] = {0, + Q31_fmt(0.21132486540519), Q31_fmt(0.36602540378444), Q31_fmt(0.50000000000000), + Q31_fmt(0.63397459621556), Q31_fmt(0.78867513459481), Q31_fmt(1.00000000000000), + 0 + }; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_st_mid_side(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 Start, + int32 Number) +{ + + int32 *pt_xr = &xr[Start]; + int32 *pt_xl = &xl[Start]; + + for (int32 i = Number >> 1; i != 0; i--) + { + int32 xxr = *(pt_xr) << 1; + int32 xxl = *(pt_xl) << 1; + *(pt_xr++) = fxp_mul32_Q32((xxr + xxl), Q31_fmt(0.70710678118655)); /* Sum */ + *(pt_xl++) = fxp_mul32_Q32((xxr - xxl), Q31_fmt(0.70710678118655)); /* Diff */ + xxr = *(pt_xr) << 1; + xxl = *(pt_xl) << 1; + *(pt_xr++) = fxp_mul32_Q32((xxr + xxl), Q31_fmt(0.70710678118655)); /* Sum */ + *(pt_xl++) = fxp_mul32_Q32((xxr - xxl), Q31_fmt(0.70710678118655)); /* Diff */ + } + + + if (Number&1) + { + int32 xxr = *(pt_xr) << 1; + int32 xxl = *(pt_xl) << 1; + *(pt_xr) = fxp_mul32_Q32((xxr + xxl), Q31_fmt(0.70710678118655)); /* Sum */ + *(pt_xl) = fxp_mul32_Q32((xxr - xxl), Q31_fmt(0.70710678118655)); /* Diff */ + } + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_st_intensity(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 is_pos, + int32 Start, + int32 Number) +{ + + int32 TmpFac = is_ratio_factor[ is_pos & 7]; + + int32 *pt_xr = &xr[Start]; + int32 *pt_xl = &xl[Start]; + + for (int32 i = Number >> 1; i != 0; i--) + { + int32 tmp = fxp_mul32_Q32((*pt_xr) << 1, TmpFac); + *(pt_xl++) = (*pt_xr) - tmp; + *(pt_xr++) = tmp; + tmp = fxp_mul32_Q32((*pt_xr) << 1, TmpFac); + *(pt_xl++) = (*pt_xr) - tmp; + *(pt_xr++) = tmp; + } + + if (Number&1) + { + int32 tmp = fxp_mul32_Q32((*pt_xr) << 1, TmpFac); + *(pt_xl) = (*pt_xr) - tmp; + *(pt_xr) = tmp; + } + +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void pvmp3_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, + granuleInfo *gr_info, + int32 used_freq_lines, + mp3Header *info) +{ + + + int32 sb; + int32 ss; + int32 sfbNo; + int32 sfbStart; + + int32 sfb; + int32 sfbTemp; + int32 i; + int32 j; + + + int32 i_stereo = (info->mode == MPG_MD_JOINT_STEREO) && + (info->mode_ext & 0x1); + + int32 ms_stereo = (info->mode == MPG_MD_JOINT_STEREO) && + (info->mode_ext & 0x2); + + int32 sfreq = info->version_x + (info->version_x << 1); + sfreq += info->sampling_frequency; + + + + + if (i_stereo) + { + if (gr_info->window_switching_flag && (gr_info->block_type == 2)) + { + if (gr_info->mixed_block_flag) + { + /* + * mixed blocks processing + */ + i = 31; + ss = 17; + sb = 0; + while (i >= 0) + { + if (xl[(i*FILTERBANK_BANDS) + ss]) + { + sb = (i << 4) + (i << 1) + ss; + i = -1; + } + else + { + ss--; + if (ss < 0) + { + i--; + ss = 17; + } + } + } + + if (sb < 36) + { + /* + * mixed blocks processing: intensity bound inside long blocks + */ + /* 1. long blocks up to intensity border: not intensity */ + + if (mp3_sfBandIndex[sfreq].l[4] <= sb) + { + sfb = 4; + } + else + { + sfb = 0; + } + + while (mp3_sfBandIndex[sfreq].l[sfb] < sb) + { + sfb++; + } + + /* from that sfb on intensity stereo */ + sfbTemp = sfb; /* save for later use */ + + sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; + + /* from 0 up to sfbStart do ms_stereo or normal stereo */ + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, sfbStart); + } + + /* 2. long blocks from intensity border up to sfb band 8: intensity */ + /* calc. is_ratio */ + + + /* Start of intensity stereo of remaining sfc bands: */ + for (; sfbTemp < 8; sfbTemp++) + { + sfbStart = mp3_sfBandIndex[sfreq].l[sfbTemp]; /* = Start in 0 ... 575 */ + sfbNo = mp3_sfBandIndex[sfreq].l[sfbTemp+1] - mp3_sfBandIndex[sfreq].l[sfbTemp]; /* No of lines to process */ + + if (scalefac->l[sfbTemp] != 7) + { + pvmp3_st_intensity(xr, xl, scalefac->l[sfbTemp], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (; sfbTemp < 8; sfbTemp++) */ + + for (j = 0; j < 3; j++) + { + /* 3. short blocks from sfbcnt to last sfb do intensity stereo */ + for (sfbTemp = 3; sfbTemp < 13; sfbTemp++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo; + + if (scalefac->s[j][sfbTemp] != 7) + { + pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (; sfbTemp < 22; sfbTemp++) */ + } /* for (j = 0; j < 3; j++) */ + } + else /* else for (sb >= 36) */ + { + /* + * mixed blocks processing: intensity bound outside long blocks + */ + + + /* + * 2. short blocks from sfb band 3 up to intensity border: normal stereo, ms stereo and intensity + */ + for (j = 0; j < 3; j++) + { + int32 sfbcnt; + sfbcnt = -1; + + for (sfb = 12; sfb >= 3; sfb--) + { + int32 lines; + lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1; + + while (lines > 0) + { + if (xl[i]) + { + sfbcnt = sfb; + sfb = -10; + lines = -10; + } + lines--; + i--; + } + } + + sfbcnt += 1; + if (sfbcnt < 3) + { + sfbcnt = 3; + } + + sfbTemp = sfbcnt; /* for later use */ + + + /* + * do normal stereo or MS stereo from sfb 3 to < sfbcnt: + */ + for (sb = 3; sb < sfbcnt; sb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sb+1] - mp3_sfBandIndex[sfreq].s[sb]; + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sb] + j * sfbNo; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } + + /* from sfbcnt to last sfb do intensity stereo */ + for (; sfbTemp < 13; sfbTemp++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo; + + if (scalefac->s[j][sfbTemp] != 7) + { + pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (; sfbTemp < 22; sfbTemp++) */ + + } /* for (j = 0; j < 3; j++) */ + + /* 1. long blocks up to sfb band 8: not intensity */ + /* from 0 to sfb 8 ms_stereo or normal stereo */ + + sfbStart = mp3_sfBandIndex[sfreq].l[8]; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, sfbStart); + } + + } + } /* if (gr_info->mixed_block_flag) */ + else + { + /* + * short block processing + */ + for (j = 0; j < 3; j++) + { + int32 sfbcnt = -1; + + for (sfb = 12; sfb >= 0; sfb--) + { + int32 lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1; + + while (lines > 0) + { + if (xl[i]) + { + sfbcnt = sfb; + sfb = -10; + lines = -10; + } + lines--; + i--; + } + } + + sfbcnt += 1; + sfbTemp = sfbcnt; /* for later use */ + + /* do normal stereo or MS stereo from 0 to sfbcnt */ + for (sb = 0; sb < sfbcnt; sb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sb+1] - mp3_sfBandIndex[sfreq].s[sb]; + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sb] + j * sfbNo; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + + + /* from sfbcnt to last sfb do intensity stereo */ + for (; sfbTemp < 13; sfbTemp++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo; + + if (scalefac->s[j][sfbTemp] != 7) + { + pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (; sfbTemp < 22; sfbTemp++) */ + + } /* for (j = 0; j < 3; j++) */ + + } /* if( gr_info->mixed_block_flag) */ + + + + } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */ + else + { + /* + * long block processing + */ + i = 31; + ss = 17; + sb = 0; + + while (i >= 0) + { + if (xl[(i*FILTERBANK_BANDS) + ss] != 0) + { + sb = (i << 4) + (i << 1) + ss; + i = -2; + } + else + { + ss--; + if (ss < 0) + { + i--; + ss = 17; + } + } + } + + if (sb) + { + if (mp3_sfBandIndex[sfreq].l[14] <= sb) + { + sfb = 14; + } + else if (mp3_sfBandIndex[sfreq].l[7] <= sb) + { + sfb = 7; + } + else + { + sfb = 0; + } + + + while (mp3_sfBandIndex[sfreq].l[sfb] <= sb) + { + sfb++; + } + } + else + { + if (i == -1) + { + /* all xr[1][][] are 0: set IS bound sfb to 0 */ + sfb = 0; + } + else + { + /* xr[1][0][0] is unequal 0 and all others are 0: set IS bound sfb to 1 */ + sfb = 1; + } + } + + sfbTemp = sfb; /* save for later use */ + + + sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; + + /* from 0 to sfbStart ms_stereo or normal stereo */ + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, sfbStart); + } + + /* now intensity stereo of the remaining sfb's: */ + for (; sfb < 21; sfb++) + { + sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; + sfbNo = mp3_sfBandIndex[sfreq].l[sfb+1] - mp3_sfBandIndex[sfreq].l[sfb]; /* No of lines to process */ + + if (scalefac->l[sfb] != 7) + { + pvmp3_st_intensity(xr, xl, scalefac->l[sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (; sfbTemp < 22; sfbTemp++) */ + + + + sfbStart = mp3_sfBandIndex[sfreq].l[21]; + sfbNo = mp3_sfBandIndex[sfreq].l[22] - mp3_sfBandIndex[sfreq].l[21]; /* No of lines to process */ + + if (scalefac->l[21] != 7) + { + if (sfbTemp < 21) + { + sfbTemp = scalefac->l[20]; + } + else + { + sfbTemp = 0; /* if scalefac[20] is not an intensity position, is_pos = 0 */ + } + + pvmp3_st_intensity(xr, xl, sfbTemp, sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */ + + + } /* if (i_stereo) */ + else + { + /* + * normal or ms stereo processing + */ + if (ms_stereo) + { + + pvmp3_st_mid_side(xr, xl, 0, used_freq_lines); + + } + + } /* if (i_stereo) */ + +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.h new file mode 100644 index 0000000..dab3091 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.h @@ -0,0 +1,107 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_stereo_proc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_STEREO_PROC_H +#define PVMP3_STEREO_PROC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + + void pvmp3_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, + granuleInfo *gr_info, + int32 used_freq_lines, + mp3Header *info); + + void pvmp3_st_intensity(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 is_pos, + int32 Start, + int32 Number); + + void pvmp3_st_mid_side(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 Start, + int32 Number); +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_tables.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_tables.cpp new file mode 100644 index 0000000..a3bcf99 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_tables.cpp @@ -0,0 +1,2922 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_tables.cpp + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_tables.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const int32 mp3_s_freq[4][4] = +{ + {44100, 48000, 32000, 0}, + {22050, 24000, 16000, 0}, + {11025, 12000, 8000, 0} +}; // MPEG-2.5 + + +/* + * 144000./s_freq + */ +const int32 inv_sfreq[4] = +{ + Qfmt_28(3.26530612244898), + Qfmt_28(3.0), + Qfmt_28(4.5), + 0 +}; + + +/* 1: MPEG-1, 0: MPEG-2 LSF, 1995-07-11 shn */ + + +const int16 mp3_bitrate[3][15] = +{ + {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320}, + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}, + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160} +}; + + +const mp3_scaleFactorBandIndex mp3_sfBandIndex[9] = +{ + + /* MPEG 1 */ + + {{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418, 576}, + {0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192}}, + {{0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330, 384, 576}, + {0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192}}, + {{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448, 550, 576}, + {0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192}}, + + /* MPEG 2 - LSF */ + + {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, + {0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192}}, + {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 332, 394, 464, 540, 576}, + {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192}}, + {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, + {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}}, + + /* MPEG 2.5 extension */ + + {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, + {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}}, + {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, + {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}}, + {{0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568, 570, 572, 574, 576}, + {0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164, 166, 192}} + +}; + +#define INV_Q31( x) (int32)(0x7FFFFFFF/(float)x - 1.0f) + +const int32 mp3_shortwindBandWidths[9][13] = +{ + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), + INV_Q31(12), INV_Q31(14), INV_Q31(18), INV_Q31(22), INV_Q31(30), INV_Q31(56)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(6), INV_Q31(10), + INV_Q31(12), INV_Q31(14), INV_Q31(16), INV_Q31(20), INV_Q31(26), INV_Q31(66)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(12), + INV_Q31(16), INV_Q31(20), INV_Q31(26), INV_Q31(34), INV_Q31(42), INV_Q31(12)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(6), INV_Q31(8), INV_Q31(10), + INV_Q31(14), INV_Q31(18), INV_Q31(26), INV_Q31(32), INV_Q31(42), INV_Q31(18)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12), + INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(32), INV_Q31(44), INV_Q31(12)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12), + INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(30), INV_Q31(40), INV_Q31(18)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12), + INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(30), INV_Q31(40), INV_Q31(18)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12), + INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(30), INV_Q31(40), INV_Q31(18)}, + { INV_Q31(8), INV_Q31(8), INV_Q31(8), INV_Q31(12), INV_Q31(16), INV_Q31(20), INV_Q31(24), + INV_Q31(28), INV_Q31(36), INV_Q31(2), INV_Q31(2), INV_Q31(2), INV_Q31(26)} +}; + + +#define Q30_fmt(a) (int32((0x40000000)*a)) + +const int32 pqmfSynthWin[(HAN_SIZE/2) + 8] = +{ + Q30_fmt(-0.000015259F), Q30_fmt(0.000396729F), Q30_fmt(0.000473022F), Q30_fmt(0.003173828F), + Q30_fmt(0.003326416F), Q30_fmt(0.006118770F), Q30_fmt(0.007919310F), Q30_fmt(0.031478880F), + Q30_fmt(0.030517578F), Q30_fmt(0.073059080F), Q30_fmt(0.084182740F), Q30_fmt(0.108856200F), + Q30_fmt(0.090927124F), Q30_fmt(0.543823240F), Q30_fmt(0.600219727F), Q30_fmt(1.144287109F), + + Q30_fmt(-0.000015259F), Q30_fmt(0.000366211F), Q30_fmt(0.000534058F), Q30_fmt(0.003082275F), + Q30_fmt(0.003387451F), Q30_fmt(0.005294800F), Q30_fmt(0.008865360F), Q30_fmt(0.031738280F), + Q30_fmt(0.029785160F), Q30_fmt(0.067520140F), Q30_fmt(0.089706420F), Q30_fmt(0.116577150F), + Q30_fmt(0.080688480F), Q30_fmt(0.515609740F), Q30_fmt(0.628295900F), Q30_fmt(1.142211914F), + + Q30_fmt(-0.000015259F), Q30_fmt(0.000320435F), Q30_fmt(0.000579834F), Q30_fmt(0.002990723F), + Q30_fmt(0.003433228F), Q30_fmt(0.004486080F), Q30_fmt(0.009841920F), Q30_fmt(0.031845090F), + Q30_fmt(0.028884890F), Q30_fmt(0.061996460F), Q30_fmt(0.095169070F), Q30_fmt(0.123474120F), + Q30_fmt(0.069595340F), Q30_fmt(0.487472530F), Q30_fmt(0.656219480F), Q30_fmt(1.138763428F), + + Q30_fmt(-0.000015259F), Q30_fmt(0.000289917F), Q30_fmt(0.000625610F), Q30_fmt(0.002899170F), + Q30_fmt(0.003463745F), Q30_fmt(0.003723140F), Q30_fmt(0.010849000F), Q30_fmt(0.031814580F), + Q30_fmt(0.027801510F), Q30_fmt(0.056533810F), Q30_fmt(0.100540160F), Q30_fmt(0.129577640F), + Q30_fmt(0.057617190F), Q30_fmt(0.459472660F), Q30_fmt(0.683914180F), Q30_fmt(1.133926392F), + + Q30_fmt(-0.000015259F), Q30_fmt(0.000259399F), Q30_fmt(0.000686646F), Q30_fmt(0.002792358F), + Q30_fmt(0.003479004F), Q30_fmt(0.003005981F), Q30_fmt(0.011886600F), Q30_fmt(0.031661990F), + Q30_fmt(0.026535030F), Q30_fmt(0.051132200F), Q30_fmt(0.105819700F), Q30_fmt(0.134887700F), + Q30_fmt(0.044784550F), Q30_fmt(0.431655880F), Q30_fmt(0.711318970F), Q30_fmt(1.127746582F), + + Q30_fmt(-0.000015259F), Q30_fmt(0.000244141F), Q30_fmt(0.000747681F), Q30_fmt(0.002685547F), + Q30_fmt(0.003479004F), Q30_fmt(0.002334595F), Q30_fmt(0.012939450F), Q30_fmt(0.031387330F), + Q30_fmt(0.025085450F), Q30_fmt(0.045837400F), Q30_fmt(0.110946660F), Q30_fmt(0.139450070F), + Q30_fmt(0.031082153F), Q30_fmt(0.404083250F), Q30_fmt(0.738372800F), Q30_fmt(1.120223999F), + + Q30_fmt(-0.000030518F), Q30_fmt(0.000213623F), Q30_fmt(0.000808716F), Q30_fmt(0.002578735F), + Q30_fmt(0.003463745F), Q30_fmt(0.001693726F), Q30_fmt(0.014022830F), Q30_fmt(0.031005860F), + Q30_fmt(0.023422240F), Q30_fmt(0.040634160F), Q30_fmt(0.115921020F), Q30_fmt(0.143264770F), + Q30_fmt(0.016510010F), Q30_fmt(0.376800540F), Q30_fmt(0.765029907F), Q30_fmt(1.111373901F), + + Q30_fmt(-0.000030518F), Q30_fmt(0.000198364F), Q30_fmt(0.000885010F), Q30_fmt(0.002456665F), + Q30_fmt(0.003417969F), Q30_fmt(0.001098633F), Q30_fmt(0.015121460F), Q30_fmt(0.030532840F), + Q30_fmt(0.021575930F), Q30_fmt(0.035552980F), Q30_fmt(0.120697020F), Q30_fmt(0.146362300F), + Q30_fmt(0.001068120F), Q30_fmt(0.349868770F), Q30_fmt(0.791213990F), Q30_fmt(1.101211548F), + + Q30_fmt(-0.000030518F), Q30_fmt(0.000167847F), Q30_fmt(0.000961304F), Q30_fmt(0.002349854F), + Q30_fmt(0.003372192F), Q30_fmt(0.000549316F), Q30_fmt(0.016235350F), Q30_fmt(0.029937740F), + Q30_fmt(0.019531250F), Q30_fmt(0.030609130F), Q30_fmt(0.125259400F), Q30_fmt(0.148773190F), + Q30_fmt(-0.015228270F), Q30_fmt(0.323318480F), Q30_fmt(0.816864010F), Q30_fmt(1.089782715F), + + Q30_fmt(-0.000030518F), Q30_fmt(0.000152588F), Q30_fmt(0.001037598F), Q30_fmt(0.002243042F), + Q30_fmt(0.003280640F), Q30_fmt(0.000030518F), Q30_fmt(0.017349240F), Q30_fmt(0.029281620F), + Q30_fmt(0.017257690F), Q30_fmt(0.025817870F), Q30_fmt(0.129562380F), Q30_fmt(0.150497440F), + Q30_fmt(-0.032379150F), Q30_fmt(0.297210693F), Q30_fmt(0.841949463F), Q30_fmt(1.077117920F), + + Q30_fmt(-0.000045776F), Q30_fmt(0.000137329F), Q30_fmt(0.001113892F), Q30_fmt(0.002120972F), + Q30_fmt(0.003173828F), Q30_fmt(-0.000442505F), Q30_fmt(0.018463130F), Q30_fmt(0.028533940F), + Q30_fmt(0.014801030F), Q30_fmt(0.021179200F), Q30_fmt(0.133590700F), Q30_fmt(0.151596070F), + Q30_fmt(-0.050354000F), Q30_fmt(0.271591190F), Q30_fmt(0.866363530F), Q30_fmt(1.063217163F), + + Q30_fmt(-0.000045776F), Q30_fmt(0.000122070F), Q30_fmt(0.001205444F), Q30_fmt(0.002014160F), + Q30_fmt(0.003051758F), Q30_fmt(-0.000869751F), Q30_fmt(0.019577030F), Q30_fmt(0.027725220F), + Q30_fmt(0.012115480F), Q30_fmt(0.016708370F), Q30_fmt(0.137298580F), Q30_fmt(0.152069090F), + Q30_fmt(-0.069168090F), Q30_fmt(0.246505740F), Q30_fmt(0.890090940F), Q30_fmt(1.048156738F), + + Q30_fmt(-0.000061035F), Q30_fmt(0.000106812F), Q30_fmt(0.001296997F), Q30_fmt(0.001907349F), + Q30_fmt(0.002883911F), Q30_fmt(-0.001266479F), Q30_fmt(0.020690920F), Q30_fmt(0.026840210F), + Q30_fmt(0.009231570F), Q30_fmt(0.012420650F), Q30_fmt(0.140670780F), Q30_fmt(0.151962280F), + Q30_fmt(-0.088775630F), Q30_fmt(0.221984860F), Q30_fmt(0.913055420F), Q30_fmt(1.031936646F), + + Q30_fmt(-0.000061035F), Q30_fmt(0.000106812F), Q30_fmt(0.001388550F), Q30_fmt(0.001785278F), + Q30_fmt(0.002700806F), Q30_fmt(-0.001617432F), Q30_fmt(0.021789550F), Q30_fmt(0.025909420F), + Q30_fmt(0.006134030F), Q30_fmt(0.008316040F), Q30_fmt(0.143676760F), Q30_fmt(0.151306150F), + Q30_fmt(-0.109161380F), Q30_fmt(0.198059080F), Q30_fmt(0.935195920F), Q30_fmt(1.014617920F), + + Q30_fmt(-0.000076294F), Q30_fmt(0.000091553F), Q30_fmt(0.001480103F), Q30_fmt(0.001693726F), + Q30_fmt(0.002487183F), Q30_fmt(-0.001937866F), Q30_fmt(0.022857670F), Q30_fmt(0.024932860F), + Q30_fmt(0.002822880F), Q30_fmt(0.004394530F), Q30_fmt(0.146255490F), Q30_fmt(0.150115970F), + Q30_fmt(-0.130310060F), Q30_fmt(0.174789430F), Q30_fmt(0.956481930F), Q30_fmt(0.996246338F), + + Q30_fmt(0.000000000F), Q30_fmt(0.000442505F), Q30_fmt(0.001586910F), Q30_fmt(0.003250122F), + Q30_fmt(0.007003780F), Q30_fmt(0.023910525F), Q30_fmt(0.031082153F), Q30_fmt(0.078628545F), + Q30_fmt(0.148422240F), Q30_fmt(0.100311279F), Q30_fmt(0.572036740F), Q30_fmt(0.976852417F), + Q30_fmt(1.144989014F), Q30_fmt(-0.572036745F), Q30_fmt(-0.152206421F), Q30_fmt(0.100311279F), + + Q30_fmt(-0.078628540F), Q30_fmt(-0.000686646F), Q30_fmt(0.031082153F), Q30_fmt(-0.007003785F), + Q30_fmt(0.002227783F), Q30_fmt(0.003250122F), Q30_fmt(-0.000442500F), Q30_fmt(-0.000076294F), +}; + + + + + +const uint16 huffTable_1[8] = +{ + 0x1103, 0x0103, 0x1002, 0x1002, + 0x0001, 0x0001, 0x0001, 0x0001 +}; + +const uint16 huffTable_2[15] = +{ + 0x1103, 0x0103, 0x1003, 0x0001, + 0x0001, 0x0001, 0x0001, 0x2206, + 0x0206, 0x1205, 0x1205, 0x2105, + 0x2105, 0x2005, 0x2005 +}; + +const uint16 huffTable_3[15] = +{ + + 0x1003, 0x1102, 0x1102, 0x0102, + 0x0102, 0x0002, 0x0002, 0x2206, + 0x0206, 0x1205, 0x1205, 0x2105, + 0x2105, 0x2005, 0x2005 +}; + +const uint16 huffTable_5[25] = +{ + + 0x1103, 0x0103, 0x1003, 0x0001, + 0x0001, 0x0001, 0x0001, 0x3106, + 0x3106, 0x1307, 0x0307, 0x3007, + 0x2207, 0x1206, 0x1206, 0x2106, + 0x2106, 0x0206, 0x0206, 0x2006, + 0x2006, 0x3308, 0x2308, 0x3207, + 0x3207 +}; + + +const uint16 huffTable_6[26] = +{ + + 0x1204, 0x2104, 0x2004, 0x0103, + 0x0103, 0x1102, 0x1102, 0x1102, + 0x1102, 0x1003, 0x1003, 0x0003, + 0x0003, 0x2306, 0x3206, 0x3006, + 0x1305, 0x1305, 0x3105, 0x3105, + 0x2205, 0x2205, 0x0205, 0x0205, + 0x3307, 0x0307 +}; + + + +const uint16 huffTable_7[73] = +{ + 0x0103, + 0x1003, + 0x0001, + 0x0001, + 0x0001, + 0x0001, + 0x1206, + 0x2105, + 0x2105, + 0x0206, + 0x2006, + 0x1104, + 0x1104, + 0x1104, + 0x1104, + 0x3509, + 0x4409, + 0x2509, + 0x5209, + 0x1508, + 0x1508, + 0x5108, + 0x5108, + 0x0509, + 0x3409, + 0x5008, + 0x5008, + 0x4309, + 0x3309, + 0x2408, + 0x2408, + 0x4208, + 0x4208, + 0x1407, + 0x1407, + 0x1407, + 0x1407, + 0x4107, + 0x4107, + 0x4107, + 0x4107, + 0x4007, + 0x4007, + 0x4007, + 0x4007, + 0x0408, + 0x0408, + 0x2308, + 0x2308, + 0x3208, + 0x3208, + 0x0308, + 0x0308, + 0x1307, + 0x1307, + 0x1307, + 0x1307, + 0x3107, + 0x3107, + 0x3107, + 0x3107, + 0x3007, + 0x3007, + 0x3007, + 0x3007, + 0x2207, + 0x2207, + 0x2207, + 0x2207, + 0x550a, + 0x450a, + 0x540a, + 0x530a +}; + +const uint16 huffTable_8[66] = +{ + 0x1204, + 0x2104, + 0x1102, + 0x1102, + 0x1102, + 0x1102, + 0x0103, + 0x0103, + 0x1003, + 0x1003, + 0x0002, + 0x0002, + 0x0002, + 0x0002, + 0x2206, + 0x0206, + 0x2006, + 0x2509, + 0x5209, + 0x0509, + 0x1508, + 0x1508, + 0x5108, + 0x5108, + 0x3409, + 0x4309, + 0x5009, + 0x3309, + 0x2408, + 0x2408, + 0x4208, + 0x4208, + 0x1408, + 0x1408, + 0x4107, + 0x4107, + 0x4107, + 0x4107, + 0x0408, + 0x0408, + 0x4008, + 0x4008, + 0x2308, + 0x2308, + 0x3208, + 0x3208, + 0x1308, + 0x1308, + 0x3108, + 0x3108, + 0x0308, + 0x0308, + 0x3008, + 0x3008, + 0x550b, + 0x540b, + 0x450a, + 0x450a, + 0x5309, + 0x5309, + 0x5309, + 0x5309, + 0x350a, + 0x350a, + 0x440a, + 0x440a + +}; + + +const uint16 huffTable_9[53] = +{ + 0x1204, + 0x2104, + 0x2004, + 0x1103, + 0x1103, + 0x0103, + 0x0103, + 0x1003, + 0x1003, + 0x0003, + 0x0003, + 0x1406, + 0x4106, + 0x2306, + 0x3206, + 0x1305, + 0x1305, + 0x3105, + 0x3105, + 0x0306, + 0x3006, + 0x2205, + 0x2205, + 0x0205, + 0x0205, + 0x4408, + 0x2508, + 0x5208, + 0x1508, + 0x5107, + 0x5107, + 0x3407, + 0x3407, + 0x4307, + 0x4307, + 0x5008, + 0x0408, + 0x2407, + 0x2407, + 0x4207, + 0x4207, + 0x3307, + 0x3307, + 0x4007, + 0x4007, + 0x5509, + 0x4509, + 0x3508, + 0x3508, + 0x5308, + 0x5308, + 0x5409, + 0x0509 + +}; + + +const uint16 huffTable_10[96] = +{ + 0x0001, + 0x1104, + 0x0103, + 0x0103, + 0x1003, + 0x1003, + 0x1206, + 0x2106, + 0x0206, + 0x2006, + 0x1408, + 0x4108, + 0x4008, + 0x2308, + 0x3208, + 0x0308, + 0x1307, + 0x1307, + 0x3107, + 0x3107, + 0x3007, + 0x3007, + 0x2207, + 0x2207, + 0x1608, + 0x1608, + 0x6108, + 0x6108, + 0x6008, + 0x6008, + 0x0509, + 0x5009, + 0x2409, + 0x4209, + 0x3309, + 0x0409, + 0x2709, + 0x2709, + 0x7209, + 0x7209, + 0x640a, + 0x070a, + 0x7009, + 0x7009, + 0x6209, + 0x6209, + 0x450a, + 0x350a, + 0x0609, + 0x0609, + 0x530a, + 0x440a, + 0x1708, + 0x1708, + 0x1708, + 0x1708, + 0x7108, + 0x7108, + 0x7108, + 0x7108, + 0x3609, + 0x3609, + 0x2609, + 0x2609, + 0x250a, + 0x520a, + 0x1509, + 0x1509, + 0x5109, + 0x5109, + 0x340a, + 0x430a, + 0x770b, + 0x670b, + 0x760b, + 0x570b, + 0x750b, + 0x660b, + 0x470a, + 0x470a, + 0x740a, + 0x740a, + 0x560a, + 0x560a, + 0x650a, + 0x650a, + 0x370a, + 0x370a, + 0x730a, + 0x730a, + 0x460a, + 0x460a, + 0x550b, + 0x540b, + 0x630a, + 0x630a +}; + + +const uint16 huffTable_11[116] = +{ + 0x1103, + 0x0103, + 0x1003, + 0x0002, + 0x0002, + 0x2105, + 0x1204, /* 0100 */ + 0x1204, /* 010 */ + 0x0205, /* 01010 */ + 0x2005, /* 01011 */ + 0x1408, /* 10 */ + 0x4108, /* 00 */ + 0x0408, /* 0 0 */ + 0x4008, /* 0 1 */ + 0x2307, /* 0 */ + 0x2307, /* */ + 0x3207, /* 1 */ + 0x3207, /* */ + 0x1306, /* 010 */ + 0x1306, /* 01 */ + 0x1306, /* 01 */ + 0x1306, /* 01 */ + 0x3106, /* 011 */ + 0x3106, /* 01 */ + 0x3106, /* 01 */ + 0x3106, /* 01 */ + 0x0307, /* 1000 */ + 0x0307, /* 100 */ + 0x3007, /* 1 */ + 0x3007, /* 100 */ + 0x2206, /* 101 */ + 0x2206, /* 10 */ + 0x2206, /* 10 */ + 0x2206, /* 10 */ + 0x2708, + 0x2708, /* 000 0 */ + 0x7208, /* 000 10 */ + 0x7208, /* 000 1 */ + 0x6409, /* 000 110 */ + 0x0709, + 0x7107, + 0x7107, + 0x7107, /* 00 0 */ + 0x7107, /* 00 0 */ + 0x1708, + 0x1708, /* 00 01 */ + 0x7008, + 0x7008, + 0x3608, + 0x3608, /* 00 10 */ + 0x6308, /* 00 101 */ + 0x6308, /* 00 10 */ + 0x6008, + 0x6008, /* 00 11 */ + 0x4409, + 0x2509, + 0x5209, /* 0 */ + 0x0509, /* 0 00 */ + 0x1508, /* 0 0 */ + 0x1508, /* 0 000 */ + 0x6207, /* 0 */ + 0x6207, /* 0 00 */ + 0x6207, /* 0 00 */ + 0x6207, /* 0 00 */ + 0x2608, + 0x2608, /* 0 010 */ + 0x0608, + 0x0608, + 0x1607, + 0x1607, + 0x1607, + 0x1607, + 0x6107, + 0x6107, + 0x6107, + 0x6107, + 0x5108, + 0x5108, + 0x3408, + 0x3408, + 0x5008, + 0x5008, + 0x4309, + 0x3309, + 0x2408, + 0x2408, /* 0 111 */ + 0x4208, /* 0 1111 */ + 0x4208, /* 0 111 */ + 0x560a, + 0x650a, + 0x3709, + 0x3709, + 0x7309, + 0x7309, + 0x4609, + 0x4609, + 0x450a, + 0x540a, /* 000 0 */ + 0x350a, /* 000 0 */ + 0x530a, /* 000 1 */ + 0x770a, + 0x770a, + 0x670a, + 0x670a, + 0x760a, /* 0 */ + 0x760a, /* */ + 0x750a, /* 1 */ + 0x750a, /* */ + 0x660a, /* 00 */ + 0x660a, /* 0 */ + 0x470a, /* 01 */ + 0x470a, /* 0 */ + 0x740a, /* 10 */ + 0x740a, /* 1 */ + 0x570b, /* 110 */ + 0x550b /* 111 */ + +}; + +const uint16 huffTable_12[134] = +{ + + 0x1103, /* 101 */ + 0x0103, /* 110 */ + 0x1003, /* 111 */ + 0x1204, + 0x1204, /* 011 */ + 0x2104, /* 0111 */ + 0x2104, /* 011 */ + 0x0205, /* 10000 */ + 0x2005, /* 10 */ + 0x0004, /* 1 */ + 0x0004, /* 100 */ + 0x3006, + 0x1305, /* 01 */ + 0x1305, /* 0100 */ + 0x3105, + 0x3105, + 0x2205, + 0x2205, /* 0101 */ + 0x1507, + 0x1507, /* 000 */ + 0x5107, /* 0 */ + 0x5107, /* 000 */ + 0x3407, /* 0 */ + 0x3407, /* */ + 0x4307, /* 1 */ + 0x4307, /* */ + 0x5008, + 0x0408, + 0x2407, + 0x2407, /* 010 */ + 0x4207, + 0x4207, + 0x1407, /* 0111 */ + 0x1407, /* 011 */ + 0x3306, + 0x3306, + 0x3306, + 0x3306, + 0x4106, + 0x4106, + 0x4106, + 0x4106, + 0x2306, + 0x2306, + 0x2306, + 0x2306, + 0x3206, + 0x3206, + 0x3206, + 0x3206, + 0x4007, + 0x4007, + 0x0307, + 0x0307, /* 010000 */ + 0x7208, + 0x7208, /* 00 00 */ + 0x4608, /* 00 */ + 0x4608, /* 00 00 */ + 0x6408, + 0x6408, /* 00 01 */ + 0x1708, /* 00 011 */ + 0x1708, + 0x7108, /* 00 100 */ + 0x7108, + 0x0709, + 0x7009, + 0x3608, + 0x3608, /* 00 11 */ + 0x6308, + 0x6308, + 0x4508, + 0x4508, + 0x5408, /* 0 0 */ + 0x5408, /* 0 000 */ + 0x4408, /* 0 0 */ + 0x4408, /* 0 */ + 0x0609, /* 0 10 */ + 0x0509, /* 0 11 */ + 0x2607, + 0x2607, + 0x2607, + 0x2607, + 0x6207, + 0x6207, + 0x6207, + 0x6207, + 0x6107, + 0x6107, + 0x6107, + 0x6107, + 0x1608, /* 0 1010 */ + 0x1608, /* 0 101 */ + 0x6008, /* 0 1011 */ + 0x6008, /* 0 101 */ + 0x3508, + 0x3508, /* 0 110 */ + 0x5308, /* 0 1101 */ + 0x5308, /* 0 110 */ + 0x2508, + 0x2508, /* 0 111 */ + 0x5208, /* 0 1111 */ + 0x5208, /* 0 111 */ + 0x770a, + 0x670a, + 0x7609, /* */ + 0x7609, + 0x5709, /* 0 */ + 0x5709, /* */ + 0x7509, /* 1 */ + 0x7509, /* */ + 0x6609, + 0x6609, + 0x4709, /* 0000 01 */ + 0x4709, /* 0000 0 */ + 0x7409, + 0x7409, /* 0000 1 */ + 0x6509, + 0x6509, /* 0000 1 */ + 0x5608, + 0x5608, + 0x5608, + 0x5608, + 0x3708, + 0x3708, + 0x3708, + 0x3708, + 0x7309, /* 000 100 */ + 0x7309, /* 000 10 */ + 0x5509, + 0x5509, /* 000 10 */ + 0x2708, + 0x2708, + 0x2708, + 0x2708, +}; + + + +const uint16 huffTable_13[491] = +{ + 0x0001, + 0x1104, + 0x0104, + 0x1003, + 0x1003, + 0x4107, + 0x4107, + 0x0408, + 0x4008, + 0x2308, + 0x3208, + 0x1307, + 0x1307, + 0x3107, + 0x3107, + 0x0307, + 0x0307, + 0x3007, + 0x3007, + 0x2207, + 0x2207, + 0x1206, + 0x1206, + 0x1206, + 0x1206, + 0x2106, + 0x2106, + 0x2106, + 0x2106, + 0x0206, + 0x0206, + 0x0206, + 0x0206, + 0x2006, + 0x2006, + 0x2006, + 0x2006, + 0x370a, + 0x270a, /* 0 000 */ + 0x1709, /* 0 00 */ + 0x1709, + 0x7109, + 0x7109, /* 0 0 */ + 0x550a, + 0x070a, /* 0 0 11 */ + 0x700a, + 0x360a, /* 0 */ + 0x630a, + 0x450a, /* 0 011 */ + 0x540a, + 0x260a, /* 0 101 */ + 0x620a, + 0x350a, /* 0 111 */ + 0x8108, + 0x8108, /* 0 010 */ + 0x8108, + 0x8108, /* 0 010 */ + 0x0809, + 0x0809, /* 0 0101 */ + 0x8009, + 0x8009, /* 0 0101 */ + 0x1609, + 0x1609, /* 0 0110 */ + 0x6109, + 0x6109, /* 0 0110 */ + 0x0609, + 0x0609, /* 0 0111 */ + 0x6009, + 0x6009, /* 0 0111 */ + 0x530a, + 0x440a, /* 0 100 */ + 0x2509, + 0x2509, /* 0 1000 */ + 0x5209, + 0x5209, /* 0 1 */ + 0x0509, + 0x0509, /* 0 1 */ + 0x1508, + 0x1508, /* 0 101 */ + 0x1508, + 0x1508, /* 0 101 */ + 0x5108, + 0x5108, /* 0 101 */ + 0x5108, + 0x5108, /* 0 101 */ + 0x3409, + 0x3409, /* 0 1100 */ + 0x4309, + 0x4309, /* 0 1100 */ + 0x5009, + 0x5009, /* 0 1101 */ + 0x2409, + 0x2409, /* 0 1101 */ + 0x4209, + 0x4209, /* 0 1110 */ + 0x3309, + 0x3309, /* 0 1110 */ + 0x1408, + 0x1408, /* 0 111 */ + 0x1408, + 0x1408, /* 0 111 */ + 0x1a0a, + 0x1a0a, + 0xa10a, /* 00 00 */ + 0xa10a, + 0x0a0b, + 0x680b, + 0xa00a, + 0xa00a, + 0x860b, + 0x490b, + 0x930a, + 0x930a, + 0x390b, + 0x580b, + 0x850b, + 0x670b, + 0x290a, + 0x290a, + 0x920a, + 0x920a, + 0x570b, + 0x750b, + 0x380a, + 0x380a, + 0x830a, + 0x830a, + 0x660b, + 0x470b, + 0x740b, + 0x560b, + 0x650b, + 0x730b, + 0x1909, + 0x1909, + 0x1909, + 0x1909, + 0x9109, + 0x9109, + 0x9109, + 0x9109, + 0x090a, /* 00 10100 */ + 0x090a, + 0x900a, /* 00 10101 */ + 0x900a, + 0x480a, /* 00 10110 */ + 0x480a, + 0x840a, /* 00 10111 */ + 0x840a, + 0x720a, /* 00 11000 */ + 0x720a, + 0x460b, /* 00 11 0 */ + 0x640b, + 0x2809, + 0x2809, + 0x2809, + 0x2809, + 0x8209, + 0x8209, + 0x8209, + 0x8209, + 0x1809, + 0x1809, + 0x1809, + 0x1809, + 0xc10b, + 0xc10b, /* 000 0000 */ + 0x980c, + 0x0c0c, /* 000 00 1 */ + 0xc00b, + 0xc00b, /* 000 0 */ + 0xb40c, + 0x6a0c, /* 000 0 11 */ + 0xa60c, + 0x790c, /* 000 */ + 0x3b0b, + 0x3b0b, /* 000 0 */ + 0xb30b, + 0xb30b, /* 000 1 */ + 0x880c, + 0x5a0c, /* 000 111 */ + 0x2b0b, + 0x2b0b, /* 000 0100 */ + 0xa50c, + 0x690c, /* 000 01 1 */ + 0xa40b, + 0xa40b, /* 000 0101 */ + 0x780c, + 0x870c, + 0x940b, + 0x940b, /* 000 0110 */ + 0x770c, + 0x760c, /* 000 011011 */ + 0xb20a, + 0xb20a, /* 000 011 */ + 0xb20a, + 0xb20a, /* 000 011 */ + 0x1b0a, + 0x1b0a, /* 000 100 */ + 0x1b0a, + 0x1b0a, /* 000 100 */ + 0xb10a, + 0xb10a, + 0xb10a, /* 000 100 */ + 0xb10a, /* 000 100 */ + 0x0b0b, /* 000 10100 */ + 0x0b0b, /* 000 1010 */ + 0xb00b, + 0xb00b, /* 000 1010 */ + 0x960b, /* 000 10110 */ + 0x960b, /* 000 1011 */ + 0x4a0b, + 0x4a0b, /* 000 1011 */ + 0x3a0b, /* 000 11000 */ + 0x3a0b, /* 000 1100 */ + 0xa30b, /* 000 11 */ + 0xa30b, /* 000 1100 */ + 0x590b, + 0x590b, /* 000 1101 */ + 0x950b, /* 000 11011 */ + 0x950b, /* 000 1101 */ + 0x2a0a, + 0x2a0a, + 0x2a0a, + 0x2a0a, + 0xa20a, + 0xa20a, + 0xa20a, + 0xa20a, + 0xf00c, + 0xf00c, /* 000 */ + 0xba0d, + 0xe50d, /* 0 1 */ + 0xe40d, + 0x8c0d, /* 01 */ + 0x6d0d, + 0xe30d, /* 11 */ + 0xe20c, /* 0100 */ + 0xe20c, + 0x2e0d, /* 01010 */ + 0x0e0d, + 0x1e0c, /* 0110 */ + 0x1e0c, + 0xe10c, /* 0111 */ + 0xe10c, + 0xe00d, /* 10000 */ + 0x5d0d, + 0xd50d, /* 1 0 */ + 0x7c0d, + 0xc70d, + 0x4d0d, + 0x8b0d, + 0xb80d, + 0xd40d, + 0x9a0d, + 0xa90d, + 0x6c0d, + 0xc60c, + 0xc60c, + 0x3d0c, + 0x3d0c, /* 111 */ + 0xd30d, /* 0000 */ + 0x7b0d, + 0x2d0c, + 0x2d0c, + 0xd20c, + 0xd20c, + 0x1d0c, + 0x1d0c, + 0xb70c, + 0xb70c, /* 0000 0 */ + 0x5c0d, + 0xc50d, /* 0000 011 */ + 0x990d, + 0x7a0d, + 0xc30c, + 0xc30c, /* 0000 1 */ + 0xa70d, + 0x970d, + 0x4b0c, + 0x4b0c, + 0xd10b, + 0xd10b, + 0xd10b, /* 0000 010 */ + 0xd10b, + 0x0d0c, + 0x0d0c, + 0xd00c, + 0xd00c, + 0x8a0c, + 0x8a0c, + 0xa80c, + 0xa80c, + 0x4c0c, + 0x4c0c, + 0xc40c, + 0xc40c, + 0x6b0c, + 0x6b0c, /* 0000 1 */ + 0xb60c, /* 0000 1 1 */ + 0xb60c, /* 0000 1 */ + 0x3c0b, + 0x3c0b, + 0x3c0b, + 0x3c0b, + 0x2c0b, /* 0000 1011 */ + 0x2c0b, /* 0000 101 */ + 0x2c0b, /* 0000 101 */ + 0x2c0b, /* 0000 101 */ + 0xc20b, + 0xc20b, + 0xc20b, + 0xc20b, + 0x5b0b, /* 0000 1101 */ + 0x5b0b, + 0x5b0b, /* 0000 110 */ + 0x5b0b, /* 0000 110 */ + 0xb50c, + 0xb50c, + 0x890c, + 0x890c, /* 0000 1110 */ + 0x1c0b, + 0x1c0b, + 0x1c0b, + 0x1c0b, + 0x2f0d, + 0x2f0d, /* 000 */ + 0xf20d, /* 0 */ + 0xf20d, /* 000 */ + 0x6e0e, /* 00 */ + 0x9c0e, /* 01 */ + 0x0f0d, /* 1 */ + 0x0f0d, /* */ + 0xc90e, + 0x5e0e, /* 01 */ + 0xab0d, /* 0101 */ + 0xab0d, + 0x7d0e, /* 01100 */ + 0xd70e, + 0x4e0d, /* 0111 */ + 0x4e0d, + 0xc80e, + 0xd60e, /* 10 */ + 0x3e0d, + 0x3e0d, /* 100 */ + 0xb90d, + 0xb90d, /* 101 */ + 0x9b0e, + 0xaa0e, /* 10111 */ + 0x1f0c, + 0x1f0c, /* 11 */ + 0x1f0c, /* 11 */ + 0x1f0c, + 0xf10c, /* 111 */ + 0xf10c, /* 11 */ + 0xf10c, /* 11 */ + 0xf10c, /* 11 */ + 0xe80e, + 0xe80e, + 0x5f0e, + 0x5f0e, + 0x9d0e, + 0x9d0e, + 0xd90e, + 0xd90e, /* 0000000 */ + 0xf50e, + 0xf50e, + 0xe70e, + 0xe70e, + 0xac0e, + 0xac0e, + 0xbb0e, + 0xbb0e, + 0x4f0e, + 0x4f0e, + 0xf40e, /* 0000000 1 */ + 0xf40e, + 0xca0f, + 0xe60f, + 0xf30e, + 0xf30e, /* 0000000 101 */ + 0x3f0d, + 0x3f0d, /* 0000000 11 */ + 0x3f0d, + 0x3f0d, /* 0000000 11 */ + 0x8d0e, + 0x8d0e, + 0xd80e, /* 0000000 1111 */ + 0xd80e, + 0x8f0f, + 0x8f0f, /* 00000000 000 */ + 0xf80f, /* 00000000 0 */ + 0xf80f, + 0xcc0f, /* 00000000 0 */ + 0xcc0f, + 0xae10, + 0x9e10, /* 00000000 11 */ + 0x8e0f, + 0x8e0f, + 0x7f10, + 0x7e10, + 0xf70e, /* 00000000 011 */ + 0xf70e, + 0xf70e, + 0xf70e, /* 00000000 01 */ + 0xda0e, + 0xda0e, /* 00000000 10 */ + 0xda0e, + 0xda0e, /* 00000000 10 */ + 0xad0f, + 0xad0f, /* 00000000 101 */ + 0xbc0f, + 0xbc0f, /* 00000000 101 */ + 0xcb0f, + 0xcb0f, /* 00000000 110 */ + 0xf60f, + 0xf60f, /* 00000000 110 */ + 0x6f0e, + 0x6f0e, /* 00000000 11 */ + 0x6f0e, /* 00000000 11 */ + 0x6f0e, /* 00000000 11 */ + 0xff10, + 0xff10, + 0xef10, + 0xef10, /* 000000000000 */ + 0xdf10, /* 000000000000 1 */ + 0xdf10, /* 000000000000 */ + 0xee10, /* 00000000000 00 */ + 0xee10, /* 00000000000 0 */ + 0xcf10, /* 00000000000 01 */ + 0xcf10, + 0xde10, /* 00000000000 10 */ + 0xde10, + 0xbf10, /* 00000000000 11 */ + 0xbf10, /* 00000000000 1 */ + 0xfb10, + 0xfb10, + 0xce10, + 0xce10, /* 0000000000 00 */ + 0xdc10, /* 0000000000 010 */ + 0xdc10, + 0xaf11, + 0xe911, + 0xec0f, /* 0000000000 10 */ + 0xec0f, /* 0000000000 1 */ + 0xec0f, /* 0000000000 1 */ + 0xec0f, /* 0000000000 1 */ + 0xdd0f, /* 0000000000 11 */ + 0xdd0f, /* 0000000000 1 */ + 0xdd0f, /* 0000000000 1 */ + 0xdd0f, /* 0000000000 1 */ + 0xfa10, /* 000000000 0000 */ + 0xfa10, /* 000000000 000 */ + 0xcd10, /* 000000000 0 */ + 0xcd10, /* 000000000 000 */ + 0xbe0f, /* 000000000 */ + 0xbe0f, + 0xbe0f, + 0xbe0f, + 0xeb0f, + 0xeb0f, + 0xeb0f, + 0xeb0f, /* 000000000 01 */ + 0x9f0f, /* 000000000 011 */ + 0x9f0f, /* 000000000 01 */ + 0x9f0f, + 0x9f0f, + 0xf90f, /* 000000000 100 */ + 0xf90f, /* 000000000 10 */ + 0xf90f, /* 000000000 10 */ + 0xf90f, /* 000000000 10 */ + 0xea0f, /* 000000000 101 */ + 0xea0f, /* 000000000 10 */ + 0xea0f, /* 000000000 10 */ + 0xea0f, /* 000000000 10 */ + 0xbd0f, /* 000000000 110 */ + 0xbd0f, /* 000000000 11 */ + 0xbd0f, /* 000000000 11 */ + 0xbd0f, /* 000000000 11 */ + 0xdb0f, /* 000000000 111 */ + 0xdb0f, /* 000000000 11 */ + 0xdb0f, /* 000000000 11 */ + 0xdb0f, /* 000000000 11 */ + 0xfe13, + 0xfc13, + 0xfd12, + 0xfd12, + 0xed11, + 0xed11, + 0xed11, + 0xed11 + +}; + + + +const uint16 huffTable_15[421] = +{ + 0x1103, + 0x1103, + 0x0104, + 0x1004, + 0x0003, /* 111 */ + 0x0003, /* 11 */ + 0x3407, + 0x4307, + 0x2407, /* 0101 */ + 0x4207, /* 0101010 */ + 0x3307, + 0x4106, /* 010110 */ + 0x4106, + 0x1407, /* 0101110 */ + 0x0407, + 0x2306, /* 011000 */ + 0x2306, + 0x3206, /* 011 */ + 0x3206, + 0x4007, + 0x0307, + 0x1306, /* 011011 */ + 0x1306, /* 01101 */ + 0x3106, /* 011100 */ + 0x3106, /* 01110 */ + 0x3006, /* 011101 */ + 0x3006, /* 01110 */ + 0x2205, /* 01111 */ + 0x2205, /* 0111 */ + 0x2205, /* 0111 */ + 0x2205, /* 0111 */ + 0x1205, /* 10000 */ + 0x1205, /* 1000 */ + 0x1205, /* 1000 */ + 0x1205, /* 1000 */ + 0x2105, /* 10 */ + 0x2105, /* 1000 */ + 0x2105, /* 1000 */ + 0x2105, /* 1000 */ + 0x0205, + 0x0205, /* 1 */ + 0x0205, /* 1 */ + 0x0205, /* 1 */ + 0x2005, /* 1 1 */ + 0x2005, /* 1 */ + 0x2005, /* 1 */ + 0x2005, /* 1 */ + 0x5809, + 0x8509, + 0x2909, /* */ + 0x6709, /* 000 */ + 0x7609, /* 00 0 */ + 0x9209, /* 00 1 */ + 0x9108, /* 0 0 */ + 0x9108, /* 0 */ + 0x1909, /* 0 10 */ + 0x9009, /* 0 11 */ + 0x4809, /* 000 */ + 0x8409, /* */ + 0x5709, /* 010 */ + 0x7509, /* 011 */ + 0x3809, /* 100 */ + 0x8309, /* 101 */ + 0x6609, /* 110 */ + 0x4709, /* 111 */ + 0x2808, + 0x2808, /* 0100 */ + 0x8208, /* 01 */ + 0x8208, /* 0100 */ + 0x1808, /* 01010 */ + 0x1808, /* 0101 */ + 0x8108, /* 01011 */ + 0x8108, /* 0101 */ + 0x7409, + 0x0809, /* 011 */ + 0x8009, /* 011010 */ + 0x5609, + 0x6509, /* 011100 */ + 0x3709, + 0x7309, /* 011110 */ + 0x4609, + 0x2708, /* 10000 */ + 0x2708, /* 1000 */ + 0x7208, /* 10 */ + 0x7208, /* 1000 */ + 0x6408, /* 1 0 */ + 0x6408, /* 1 */ + 0x1708, /* 1 1 */ + 0x1708, /* 1 */ + 0x5508, /* 10100 */ + 0x5508, + 0x7108, /* 10101 */ + 0x7108, + 0x0709, /* 101100 */ + 0x7009, /* 101101 */ + 0x3608, /* 10111 */ + 0x3608, /* 1011 */ + 0x6308, /* 11000 */ + 0x6308, /* 1100 */ + 0x4508, /* 11 */ + 0x4508, /* 1100 */ + 0x5408, /* 11010 */ + 0x5408, /* 1101 */ + 0x2608, /* 11011 */ + 0x2608, /* 1101 */ + 0x6208, /* 11100 */ + 0x6208, /* 1110 */ + 0x1608, /* 11101 */ + 0x1608, /* 1110 */ + 0x0609, /* 111100 */ + 0x6009, /* 111101 */ + 0x3508, /* 11111 */ + 0x3508, /* 1111 */ + 0x6107, + 0x6107, + 0x6107, + 0x6107, + 0x5308, /* 0100 0 */ + 0x5308, /* 0100 */ + 0x4408, /* 0100 1 */ + 0x4408, /* 0100 */ + 0x2507, /* 010 0 */ + 0x2507, /* 010 */ + 0x2507, /* 010 */ + 0x2507, /* 010 */ + 0x5207, /* 010 1 */ + 0x5207, /* 010 */ + 0x5207, /* 010 */ + 0x5207, /* 010 */ + 0x1507, /* 01 00 */ + 0x1507, /* 01 0 */ + 0x1507, /* 01 0 */ + 0x1507, /* 01 0 */ + 0x5107, /* 01 01 */ + 0x5107, /* 01 0 */ + 0x5107, /* 01 0 */ + 0x5107, /* 01 0 */ + 0x0508, /* 01 100 */ + 0x0508, /* 01 10 */ + 0x5008, /* 01 101 */ + 0x5008, /* 01 10 */ + 0xc209, + 0xc209, + 0x2c0a, /* 00 11110 */ + 0x5b0a, + 0xb50a, /* 0 */ + 0x1c0a, /* 0 000 */ + 0x890a, /* 0 00 0 */ + 0x980a, + 0xc10a, /* 0 0 00 */ + 0x4b0a, /* 0 0 01 */ + 0xb40a, /* 0 0 10 */ + 0x6a0a, /* 0 0 11 */ + 0x3b0a, /* 0 000 */ + 0x790a, /* 0 */ + 0xb309, /* 0 01 */ + 0xb309, /* 0 0 */ + 0x970a, /* 0 100 */ + 0x880a, /* 0 101 */ + 0x2b0a, /* 0 110 */ + 0x5a0a, /* 0 111 */ + 0xb209, /* 0 01000 */ + 0xb209, /* 0 0100 */ + 0xa50a, /* 0 01 0 */ + 0x1b0a, /* 0 01 1 */ + 0xb109, /* 0 01010 */ + 0xb109, /* 0 0101 */ + 0xb00a, /* 0 010110 */ + 0x690a, /* 0 010111 */ + 0x960a, /* 0 011000 */ + 0x4a0a, /* 0 011 */ + 0xa40a, /* 0 011010 */ + 0x780a, /* 0 011011 */ + 0x870a, /* 0 011100 */ + 0x3a0a, /* 0 011101 */ + 0xa309, /* 0 01111 */ + 0xa309, /* 0 0111 */ + 0x5909, /* 0 10000 */ + 0x5909, /* 0 1000 */ + 0x9509, /* 0 10 */ + 0x9509, /* 0 1000 */ + 0x2a09, /* 0 1 0 */ + 0x2a09, /* 0 1 */ + 0xa209, /* 0 1 1 */ + 0xa209, /* 0 1 */ + 0x1a09, /* 0 10100 */ + 0x1a09, /* 0 1010 */ + 0xa109, /* 0 10101 */ + 0xa109, /* 0 1010 */ + 0x0a0a, /* 0 101100 */ + 0xa00a, /* 0 101101 */ + 0x6809, /* 0 10111 */ + 0x6809, /* 0 1011 */ + 0x8609, /* 0 11000 */ + 0x8609, /* 0 1100 */ + 0x4909, /* 0 11 */ + 0x4909, /* 0 1100 */ + 0x9409, /* 0 11010 */ + 0x9409, /* 0 1101 */ + 0x3909, /* 0 11011 */ + 0x3909, /* 0 1101 */ + 0x9309, /* 0 11100 */ + 0x9309, /* 0 1110 */ + 0x770a, /* 0 111010 */ + 0x090a, /* 0 111011 */ + 0x7c0b, + 0xc70b, /* 00 000 */ + 0x4d0b, /* 00 00 0 */ + 0x8b0b, /* 00 00 1 */ + 0xd40a, /* 00 0 0 */ + 0xd40a, /* 00 0 */ + 0xb80b, /* 00 0 10 */ + 0x9a0b, /* 00 0 11 */ + 0xa90b, /* 00 000 */ + 0x6c0b, /* 00 */ + 0xc60b, /* 00 010 */ + 0x3d0b, /* 00 011 */ + 0xd30a, /* 00 10 */ + 0xd30a, /* 00 1 */ + 0xd20a, /* 00 11 */ + 0xd20a, /* 00 1 */ + 0x2d0b, /* 00 010000 */ + 0x0d0b, /* 00 010 */ + 0x1d0a, /* 00 01 */ + 0x1d0a, /* 00 0100 */ + 0x7b0a, /* 00 01010 */ + 0x7b0a, /* 00 0101 */ + 0xb70a, /* 00 01011 */ + 0xb70a, /* 00 0101 */ + 0xd10a, /* 00 01100 */ + 0xd10a, /* 00 0110 */ + 0x5c0b, /* 00 011010 */ + 0xd00b, /* 00 011011 */ + 0xc50a, /* 00 01110 */ + 0xc50a, /* 00 0111 */ + 0x8a0a, /* 00 01111 */ + 0x8a0a, /* 00 0111 */ + 0xa80a, /* 00 10000 */ + 0xa80a, /* 00 1000 */ + 0x4c0a, /* 00 10 */ + 0x4c0a, /* 00 1000 */ + 0xc40a, /* 00 1 0 */ + 0xc40a, /* 00 1 */ + 0x6b0a, /* 00 1 1 */ + 0x6b0a, /* 00 1 */ + 0xb60a, /* 00 10100 */ + 0xb60a, /* 00 1010 */ + 0x990b, /* 00 101010 */ + 0x0c0b, /* 00 101011 */ + 0x3c0a, /* 00 10110 */ + 0x3c0a, /* 00 1011 */ + 0xc30a, /* 00 10111 */ + 0xc30a, /* 00 1011 */ + 0x7a0a, /* 00 11000 */ + 0x7a0a, /* 00 1100 */ + 0xa70a, /* 00 11 */ + 0xa70a, /* 00 1100 */ + 0xa60a, /* 00 11010 */ + 0xa60a, /* 00 1101 */ + 0xc00b, /* 00 110110 */ + 0x0b0b, /* 00 110111 */ + 0xcb0b, + 0xcb0b, /* 0000 000 */ + 0xf60b, /* 0000 0 */ + 0xf60b, /* 0000 000 */ + 0x8e0c, /* 0000 00 */ + 0xe80c, /* 0000 01 */ + 0x5f0c, /* 0000 10 */ + 0x9d0c, /* 0000 11 */ + 0xf50b, /* 0000 0100 */ + 0xf50b, /* 0000 010 */ + 0x7e0b, /* 0000 0101 */ + 0x7e0b, /* 0000 010 */ + 0xe70b, /* 0000 0110 */ + 0xe70b, /* 0000 011 */ + 0xac0b, /* 0000 0111 */ + 0xac0b, /* 0000 011 */ + 0xca0b, /* 0000 1000 */ + 0xca0b, /* 0000 100 */ + 0xbb0b, /* 0000 1 */ + 0xbb0b, /* 0000 100 */ + 0xd90c, /* 0000 10100 */ + 0x8d0c, /* 0000 10101 */ + 0x4f0b, /* 0000 1011 */ + 0x4f0b, /* 0000 101 */ + 0xf40b, /* 0000 1100 */ + 0xf40b, /* 0000 110 */ + 0x3f0b, /* 0000 1101 */ + 0x3f0b, /* 0000 110 */ + 0xf30b, /* 0000 1110 */ + 0xf30b, /* 0000 111 */ + 0xd80b, /* 0000 1111 */ + 0xd80b, /* 0000 111 */ + 0xe60b, /* 000 */ + 0xe60b, /* 000 0000 */ + 0x2f0b, /* 000 00 */ + 0x2f0b, /* 000 0000 */ + 0xf20b, /* 000 0 0 */ + 0xf20b, /* 000 0 */ + 0x6e0c, /* 000 0 10 */ + 0xf00c, /* 000 0 11 */ + 0x1f0b, /* 000 00 */ + 0x1f0b, /* 000 0 */ + 0xf10b, /* 000 01 */ + 0xf10b, /* 000 0 */ + 0x9c0b, /* 000 10 */ + 0x9c0b, /* 000 1 */ + 0xc90b, /* 000 11 */ + 0xc90b, /* 000 1 */ + 0x5e0b, /* 000 01000 */ + 0x5e0b, /* 000 0100 */ + 0xab0b, /* 000 01 */ + 0xab0b, /* 000 0100 */ + 0xba0b, /* 000 01010 */ + 0xba0b, /* 000 0101 */ + 0xe50b, /* 000 01011 */ + 0xe50b, /* 000 0101 */ + 0x7d0b, /* 000 01100 */ + 0x7d0b, /* 000 0110 */ + 0xd70b, /* 000 01101 */ + 0xd70b, + 0x4e0b, /* 000 01110 */ + 0x4e0b, + 0xe40b, /* 000 01111 */ + 0xe40b, /* 000 0111 */ + 0x8c0b, + 0x8c0b, /* 000 1000 */ + 0xc80b, /* 000 10 */ + 0xc80b, + 0x3e0b, /* 000 1 0 */ + 0x3e0b, /* 000 1 */ + 0x6d0b, + 0x6d0b, /* 000 1 */ + 0xd60b, /* 000 10100 */ + 0xd60b, /* 000 1010 */ + 0xe30b, + 0xe30b, /* 000 1010 */ + 0x9b0b, /* 000 10110 */ + 0x9b0b, /* 000 1011 */ + 0xb90b, + 0xb90b, /* 000 1011 */ + 0x2e0b, /* 000 11000 */ + 0x2e0b, /* 000 1100 */ + 0xaa0b, + 0xaa0b, /* 000 1100 */ + 0xe20b, + 0xe20b, /* 000 1101 */ + 0x1e0b, + 0x1e0b, /* 000 1101 */ + 0xe10b, + 0xe10b, /* 000 1110 */ + 0x0e0c, + 0xe00c, /* 000 111011 */ + 0x5d0b, + 0x5d0b, /* 000 1111 */ + 0xd50b, + 0xd50b, /* 000 1111 */ + 0xff0d, + 0xef0d, + 0xfe0d, + 0xdf0d, + 0xee0c, + 0xee0c, + 0xfd0d, + 0xcf0d, + 0xfc0d, + 0xde0d, + 0xed0d, + 0xbf0d, + 0xfb0c, + 0xfb0c, + 0xce0d, + 0xec0d, + 0xdd0c, /* 000 */ + 0xdd0c, /* 00 */ + 0xaf0c, /* */ + 0xaf0c, /* 00 */ + 0xfa0c, /* 010 */ + 0xfa0c, /* 01 */ + 0xbe0c, /* 011 */ + 0xbe0c, /* 01 */ + 0xeb0c, /* 100 */ + 0xeb0c, /* 10 */ + 0xcd0c, /* 101 */ + 0xcd0c, /* 10 */ + 0xdc0c, /* 110 */ + 0xdc0c, /* 11 */ + 0x9f0c, /* 111 */ + 0x9f0c, /* 11 */ + 0xf90c, /* 0000 */ + 0xf90c, /* 000 */ + 0xea0c, /* 0 */ + 0xea0c, /* 000 */ + 0xbd0c, /* 0 */ + 0xbd0c, /* */ + 0xdb0c, /* 1 */ + 0xdb0c, /* */ + 0x8f0c, /* 0100 */ + 0x8f0c, /* 010 */ + 0xf80c, /* 0101 */ + 0xf80c, /* 010 */ + 0xcc0c, + 0xcc0c, /* 011 */ + 0x9e0c, /* 0111 */ + 0x9e0c, /* 011 */ + 0xe90c, /* 1000 */ + 0xe90c, /* 100 */ + 0x7f0c, /* 1 */ + 0x7f0c, + 0xf70c, /* 1010 */ + 0xf70c, /* 101 */ + 0xad0c, /* 1011 */ + 0xad0c, /* 101 */ + 0xda0c, /* 1100 */ + 0xda0c, /* 110 */ + 0xbc0c, + 0xbc0c, /* 110 */ + 0x6f0c, /* 1110 */ + 0x6f0c, /* 111 */ + 0xae0d, /* 11110 */ + 0x0f0d +}; + +const uint16 huffTable_16[465] = +{ + 0x0001, + 0x1104, + 0x0104, + 0x1003, + 0x1003, + 0x2308, + 0x3208, /* 11 */ + 0x1307, /* 0100 */ + 0x1307, /* 010 */ + 0x3107, + 0x3107, + 0x0308, + 0x3008, + 0x2207, /* 0111 */ + 0x2207, /* 011 */ + 0x1206, /* 100 */ + 0x1206, /* 10 */ + 0x1206, /* 10 */ + 0x1206, /* 10 */ + 0x2106, /* 101 */ + 0x2106, /* 10 */ + 0x2106, /* 10 */ + 0x2106, /* 10 */ + 0x0206, + 0x0206, + 0x0206, + 0x0206, + 0x2006, + 0x2006, + 0x2006, + 0x2006, + 0x1709, + 0x1709, /* 0 0111 */ + 0x7109, /* 0 10000 */ + 0x7109, /* 0 1000 */ + 0x700a, /* 0 10 0 */ + 0x360a, /* 0 10 1 */ + 0x630a, /* 0 1 00 */ + 0x450a, /* 0 1 01 */ + 0x540a, /* 0 1 10 */ + 0x260a, /* 0 1 11 */ + 0x6209, /* 0 10100 */ + 0x6209, /* 0 1010 */ + 0x1609, + 0x1609, + 0x6109, /* 0 10110 */ + 0x6109, /* 0 1011 */ + 0x060a, /* 0 101110 */ + 0x600a, + 0x5309, + 0x5309, /* 0 1100 */ + 0x350a, /* 0 11 0 */ + 0x440a, /* 0 11 1 */ + 0x2509, /* 0 11010 */ + 0x2509, /* 0 1101 */ + 0x5209, /* 0 11011 */ + 0x5209, /* 0 1101 */ + 0x5108, + 0x5108, + 0x5108, + 0x5108, + 0x1509, + 0x1509, /* 0 1111 */ + 0x0509, /* 0 11111 */ + 0x0509, /* 0 1111 */ + 0x3409, /* */ + 0x3409, /* */ + 0x4309, /* 000 */ + 0x4309, /* */ + 0x5009, /* 00 0 */ + 0x5009, /* 00 */ + 0x2409, /* 00 1 */ + 0x2409, /* 00 */ + 0x4209, /* 0 00 */ + 0x4209, /* 0 0 */ + 0x3309, /* 0 01 */ + 0x3309, /* 0 0 */ + 0x1408, /* 0 1 */ + 0x1408, /* 0 */ + 0x1408, /* 0 */ + 0x1408, /* 0 */ + 0x4108, /* 00 */ + 0x4108, /* 0 */ + 0x4108, /* 0 */ + 0x4108, /* 0 */ + 0x0409, /* 010 */ + 0x0409, /* 01 */ + 0x4009, /* 011 */ + 0x4009, /* 01 */ + 0x1d0b, + 0x1d0b, /* 00 10101 */ + 0xc40c, /* 00 1011000 */ + 0x6b0c, /* 00 1011 */ + 0xc30c, /* 00 1011010 */ + 0xa70c, /* 00 1011011 */ + 0x2c0b, /* 00 101110 */ + 0x2c0b, /* 00 10111 */ + 0xc20c, /* 00 1011110 */ + 0xb50c, /* 00 1011111 */ + 0xc10c, /* 00 1100000 */ + 0x0c0c, /* 00 1100 */ + 0x4b0c, /* 00 110 0 */ + 0xb40c, /* 00 110 1 */ + 0x6a0c, /* 00 11 00 */ + 0xa60c, /* 00 11 01 */ + 0xb30b, /* 00 11 1 */ + 0xb30b, /* 00 11 */ + 0x5a0c, /* 00 1101000 */ + 0xa50c, /* 00 1101 */ + 0x2b0b, /* 00 110101 */ + 0x2b0b, /* 00 11010 */ + 0xb20b, /* 00 110110 */ + 0xb20b, /* 00 11011 */ + 0x1b0b, /* 00 110111 */ + 0x1b0b, /* 00 11011 */ + 0xb10b, /* 00 111000 */ + 0xb10b, /* 00 11100 */ + 0x0b0c, /* 00 111 0 */ + 0xb00c, /* 00 111 1 */ + 0x690c, /* 00 1110100 */ + 0x960c, /* 00 1110101 */ + 0x4a0c, /* 00 1110110 */ + 0xa40c, /* 00 1110111 */ + 0x780c, /* 00 1111000 */ + 0x870c, /* 00 1111 */ + 0xa30b, /* 00 111101 */ + 0xa30b, /* 00 11110 */ + 0x3a0c, /* 00 1111100 */ + 0x590c, /* 00 1111101 */ + 0x2a0b, /* 00 111111 */ + 0x2a0b, /* 00 11111 */ + 0x950c, /* 0 00000000 */ + 0x680c, /* 0 */ + 0xa10b, /* 0 0000 */ + 0xa10b, /* 0 */ + 0x860c, /* 0 000 00 */ + 0x770c, /* 0 000 01 */ + 0x940b, /* 0 000 1 */ + 0x940b, /* 0 000 */ + 0x490c, /* 0 00 000 */ + 0x570c, /* 0 00 */ + 0x670b, /* 0 00 01 */ + 0x670b, /* 0 00 0 */ + 0xa20a, /* 0 00 1 */ + 0xa20a, /* 0 00 */ + 0xa20a, /* 0 00 */ + 0xa20a, /* 0 00 */ + 0x1a0a, /* 0 0 00 */ + 0x1a0a, /* 0 0 0 */ + 0x1a0a, /* 0 0 0 */ + 0x1a0a, /* 0 0 0 */ + 0x0a0b, /* 0 0 010 */ + 0x0a0b, /* 0 0 01 */ + 0xa00b, /* 0 0 011 */ + 0xa00b, /* 0 0 01 */ + 0x390b, /* 0 0 100 */ + 0x390b, /* 0 0 10 */ + 0x930b, /* 0 0 101 */ + 0x930b, /* 0 0 10 */ + 0x580b, /* 0 0 110 */ + 0x580b, /* 0 0 11 */ + 0x850b, /* 0 0 111 */ + 0x850b, /* 0 0 11 */ + 0x290a, /* 0 000 */ + 0x290a, /* 0 00 */ + 0x290a, /* 0 00 */ + 0x290a, /* 0 00 */ + 0x920a, /* 0 */ + 0x920a, /* 0 00 */ + 0x920a, /* 0 00 */ + 0x920a, /* 0 00 */ + 0x760b, /* 0 0100 */ + 0x760b, /* 0 010 */ + 0x090b, /* 0 0101 */ + 0x090b, /* 0 010 */ + 0x190a, /* 0 011 */ + 0x190a, /* 0 01 */ + 0x190a, /* 0 01 */ + 0x190a, /* 0 01 */ + 0x910a, /* 0 100 */ + 0x910a, /* 0 10 */ + 0x910a, /* 0 10 */ + 0x910a, /* 0 10 */ + 0x900b, /* 0 1010 */ + 0x900b, /* 0 101 */ + 0x480b, /* 0 1011 */ + 0x480b, /* 0 101 */ + 0x840b, /* 0 1100 */ + 0x840b, /* 0 110 */ + 0x750b, /* 0 1101 */ + 0x750b, /* 0 110 */ + 0x380b, /* 0 1110 */ + 0x380b, /* 0 111 */ + 0x830b, /* 0 1111 */ + 0x830b, /* 0 111 */ + 0x660b, /* 0 0100000 */ + 0x660b, /* 0 010000 */ + 0x280b, /* 0 0100 */ + 0x280b, /* 0 010000 */ + 0x820a, /* 0 010 */ + 0x820a, /* 0 01000 */ + 0x820a, /* 0 01000 */ + 0x820a, /* 0 01000 */ + 0x470b, /* 0 01 00 */ + 0x470b, /* 0 01 0 */ + 0x740b, /* 0 01 01 */ + 0x740b, /* 0 01 0 */ + 0x180a, /* 0 01 1 */ + 0x180a, /* 0 01 */ + 0x180a, /* 0 01 */ + 0x180a, /* 0 01 */ + 0x810a, /* 0 010100 */ + 0x810a, /* 0 01010 */ + 0x810a, /* 0 01010 */ + 0x810a, /* 0 01010 */ + 0x800a, /* 0 010101 */ + 0x800a, /* 0 01010 */ + 0x800a, /* 0 01010 */ + 0x800a, /* 0 01010 */ + 0x080b, /* 0 0101100 */ + 0x080b, /* 0 010110 */ + 0x560b, /* 0 0101101 */ + 0x560b, /* 0 010110 */ + 0x370a, /* 0 010111 */ + 0x370a, /* 0 01011 */ + 0x370a, /* 0 01011 */ + 0x370a, /* 0 01011 */ + 0x730a, /* 0 011000 */ + 0x730a, /* 0 01100 */ + 0x730a, /* 0 01100 */ + 0x730a, /* 0 01100 */ + 0x650b, /* 0 011 0 */ + 0x650b, /* 0 011 */ + 0x460b, /* 0 011 1 */ + 0x460b, /* 0 011 */ + 0x270a, /* 0 011010 */ + 0x270a, /* 0 01101 */ + 0x270a, /* 0 01101 */ + 0x270a, /* 0 01101 */ + 0x720a, /* 0 011011 */ + 0x720a, /* 0 01101 */ + 0x720a, /* 0 01101 */ + 0x720a, /* 0 01101 */ + 0x640b, /* 0 0111000 */ + 0x640b, /* 0 011100 */ + 0x550b, /* 0 0111 */ + 0x550b, /* 0 011100 */ + 0x070a, /* 0 011101 */ + 0x070a, /* 0 01110 */ + 0x070a, /* 0 01110 */ + 0x070a, /* 0 01110 */ + 0x9e0d, + 0x9e0d, /* 00 0110000 */ + 0xbc0e, /* 00 01100 0 */ + 0xcb0e, /* 00 01100 1 */ + 0x8e0e, /* 00 0110 00 */ + 0xe80e, /* 00 0110 01 */ + 0x9d0e, /* 00 0110 10 */ + 0xe70e, /* 00 0110 11 */ + 0xbb0e, /* 00 011 000 */ + 0x8d0e, /* 00 011 */ + 0xd80e, /* 00 011 010 */ + 0x6e0e, /* 00 011 011 */ + 0xe60d, /* 00 011 10 */ + 0xe60d, /* 00 011 1 */ + 0x9c0d, /* 00 011 11 */ + 0x9c0d, /* 00 011 1 */ + 0xab0e, /* 00 011010000 */ + 0xba0e, /* 00 011010 */ + 0xe50e, /* 00 01101 0 */ + 0xd70e, /* 00 01101 1 */ + 0x4e0d, /* 00 01101010 */ + 0x4e0d, /* 00 0110101 */ + 0xe40e, /* 00 011010110 */ + 0x8c0e, /* 00 011010111 */ + 0xc80d, /* 00 01101100 */ + 0xc80d, /* 00 0110110 */ + 0x3e0d, /* 00 01101101 */ + 0x3e0d, /* 00 0110110 */ + 0x6d0d, /* 00 01101110 */ + 0x6d0d, /* 00 0110111 */ + 0xd60e, /* 00 011011110 */ + 0x9b0e, /* 00 011011111 */ + 0xb90e, /* 00 011100000 */ + 0xaa0e, /* 00 011100 */ + 0xe10d, /* 00 01110 */ + 0xe10d, /* 00 0111000 */ + 0xd40d, /* 00 0111 0 */ + 0xd40d, /* 00 0111 */ + 0xb80e, /* 00 0111 10 */ + 0xa90e, /* 00 0111 11 */ + 0x7b0d, /* 00 01110100 */ + 0x7b0d, /* 00 0111010 */ + 0xb70e, /* 00 011101010 */ + 0xd00e, /* 00 011101011 */ + 0xe30c, /* 00 0111011 */ + 0xe30c, /* 00 011101 */ + 0xe30c, /* 00 011101 */ + 0xe30c, /* 00 011101 */ + 0x0e0d, /* 00 01111000 */ + 0x0e0d, /* 00 0111100 */ + 0xe00d, /* 00 01111 */ + 0xe00d, /* 00 0111100 */ + 0x5d0d, /* 00 01111010 */ + 0x5d0d, /* 00 0111101 */ + 0xd50d, /* 00 01111011 */ + 0xd50d, /* 00 0111101 */ + 0x7c0d, /* 00 01111100 */ + 0x7c0d, /* 00 0111110 */ + 0xc70d, /* 00 01111101 */ + 0xc70d, /* 00 0111110 */ + 0x4d0d, /* 00 01111110 */ + 0x4d0d, /* 00 0111111 */ + 0x8b0d, /* 00 01111111 */ + 0x8b0d, /* 00 0111111 */ + 0x9a0d, + 0x6c0d, /* 00 10000 */ + 0xc60d, /* 00 1000 0 */ + 0x3d0d, /* 00 1000 1 */ + 0x5c0d, /* 00 100 00 */ + 0xc50d, /* 00 100 01 */ + 0x0d0c, /* 00 100 1 */ + 0x0d0c, /* 00 100 */ + 0x8a0d, /* 00 10 000 */ + 0xa80d, /* 00 10 */ + 0x990d, /* 00 10 010 */ + 0x4c0d, /* 00 10 011 */ + 0xb60d, /* 00 10 100 */ + 0x7a0d, /* 00 10 101 */ + 0x3c0c, /* 00 10 11 */ + 0x3c0c, /* 00 10 1 */ + 0x5b0d, /* 00 1 0000 */ + 0x890d, /* 00 1 0 */ + 0x1c0c, /* 00 1 */ + 0x1c0c, /* 00 1 00 */ + 0xc00c, /* 00 1 010 */ + 0xc00c, /* 00 1 01 */ + 0x980d, /* 00 1 0110 */ + 0x790d, /* 00 1 0111 */ + 0xe20b, /* 00 1 10 */ + 0xe20b, /* 00 1 1 */ + 0xe20b, /* 00 1 1 */ + 0xe20b, /* 00 1 1 */ + 0x2e0c, /* 00 1 110 */ + 0x2e0c, /* 00 1 11 */ + 0x1e0c, /* 00 1 111 */ + 0x1e0c, /* 00 1 11 */ + 0xd30c, /* 00 1010000 */ + 0xd30c, /* 00 101000 */ + 0x2d0c, /* 00 1010 */ + 0x2d0c, /* 00 101000 */ + 0xd20c, /* 00 101 0 */ + 0xd20c, /* 00 101 */ + 0xd10c, /* 00 101 1 */ + 0xd10c, /* 00 101 */ + 0x3b0c, /* 00 1010100 */ + 0x3b0c, /* 00 101010 */ + 0x970d, /* 00 10101010 */ + 0x880d, /* 00 10101011 */ + 0xf208, + 0xf208, /* 000 1 */ + 0x2f09, /* 00 0000 */ + 0x0f09, /* 00 0 */ + 0x1f08, /* 00 */ + 0x1f08, /* 00 00 */ + 0xf108, /* 00 010 */ + 0xf108, /* 00 01 */ + 0xce10, + 0xce10, /* 000 101100000 */ + 0xec11, /* 000 1011000 0 */ + 0xdd11, /* 000 1011000 1 */ + 0xde0f, /* 000 101100 */ + 0xde0f, /* 000 10110000 */ + 0xde0f, /* 000 10110000 */ + 0xde0f, /* 000 10110000 */ + 0xe90f, /* 000 10110 0 */ + 0xe90f, /* 000 10110 */ + 0xe90f, /* 000 10110 */ + 0xe90f, /* 000 10110 */ + 0xea10, /* 000 10110 10 */ + 0xea10, /* 000 10110 1 */ + 0xd910, /* 000 10110 11 */ + 0xd910, /* 000 10110 1 */ + 0xee0e, + 0xee0e, /* 000 1011 */ + 0xed0f, /* 000 1011 10 */ + 0xeb0f, /* 000 1011 11 */ + 0xbe0e, /* 000 10110100 */ + 0xbe0e, /* 000 1011010 */ + 0xcd0e, /* 000 10110101 */ + 0xcd0e, /* 000 1011010 */ + 0xdc0f, /* 000 101101100 */ + 0xdb0f, /* 000 101101101 */ + 0xae0e, /* 000 10110111 */ + 0xae0e, /* 000 1011011 */ + 0xcc0e, /* 000 10111000 */ + 0xcc0e, /* 000 1011100 */ + 0xad0f, /* 000 10111 0 */ + 0xda0f, /* 000 10111 1 */ + 0x7e0f, /* 000 101110100 */ + 0xac0f, /* 000 101110101 */ + 0xca0e, /* 000 10111011 */ + 0xca0e, /* 000 1011101 */ + 0xc90f, /* 000 101111000 */ + 0x7d0f, /* 000 101111 */ + 0x5e0e, /* 000 10111101 */ + 0x5e0e, /* 000 1011110 */ + 0xbd0d, /* 000 1011111 */ + 0xbd0d, /* 000 101111 */ + 0xbd0d, /* 000 101111 */ + 0xbd0d, /* 000 101111 */ + 0xef0b, + 0xfe0b, /* 00000000 */ + 0xdf0b, /* 0000000 0 */ + 0xfd0b, /* 0000000 1 */ + 0xcf0b, /* 00 */ + 0xfc0b, /* 01 */ + 0xbf0b, /* 10 */ + 0xfb0b, /* 11 */ + 0xaf0a, /* 00 */ + 0xaf0a, /* 0 */ + 0xfa0b, /* 010 */ + 0x9f0b, /* 011 */ + 0xf90b, /* 100 */ + 0xf80b, /* 101 */ + 0x8f0a, /* 11 */ + 0x8f0a, /* 1 */ + 0x7f0a, /* 0000 000 */ + 0x7f0a, /* 0000 00 */ + 0xf70a, /* 0000 */ + 0xf70a, /* 0000 00 */ + 0x6f0a, /* 0000 010 */ + 0x6f0a, /* 0000 01 */ + 0xf60a, /* 0000 011 */ + 0xf60a, /* 0000 01 */ + 0xff08, /* 0000 1 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0x5f0a, /* 000 0000 */ + 0x5f0a, /* 000 000 */ + 0xf50a, /* 000 0 */ + 0xf50a, /* 000 000 */ + 0x4f09, /* 000 */ + 0x4f09, /* 000 00 */ + 0x4f09, /* 000 00 */ + 0x4f09, /* 000 00 */ + 0xf409, /* 000 010 */ + 0xf409, /* 000 01 */ + 0xf409, /* 000 01 */ + 0xf409, /* 000 01 */ + 0xf309, /* 000 011 */ + 0xf309, /* 000 01 */ + 0xf309, /* 000 01 */ + 0xf309, /* 000 01 */ + 0xf009, /* 000 100 */ + 0xf009, /* 000 10 */ + 0xf009, /* 000 10 */ + 0xf009, /* 000 10 */ + 0x3f0a, + 0x3f0a +}; + + + +const uint16 huffTable_24[478] = +{ + + 0x2206, /* 101 */ + 0x1205, /* 10101 */ + 0x1205, /* 1010 */ + 0x2105, /* 10110 */ + 0x2105, /* 1011 */ + 0x0206, /* 101110 */ + 0x2006, /* 101111 */ + 0x1104, + 0x1104, + 0x1104, + 0x1104, + 0x0104, + 0x0104, + 0x0104, + 0x0104, + 0x1004, + 0x1004, + 0x1004, + 0x1004, + 0x0004, + 0x0004, + 0x0004, + 0x0004, + 0x7308, + 0x7308, + 0x3709, + 0x2709, + 0x7208, + 0x7208, + 0x4608, /* 01110000 */ + 0x4608, /* 0111000 */ + 0x6408, /* 01110 */ + 0x6408, /* 0111000 */ + 0x5508, /* 0111 0 */ + 0x5508, /* 0111 */ + 0x7108, /* 0111 1 */ + 0x7108, /* 0111 */ + 0x3608, /* 01110100 */ + 0x3608, /* 0111010 */ + 0x6308, /* 01110101 */ + 0x6308, /* 0111010 */ + 0x4508, /* 01110110 */ + 0x4508, /* 0111011 */ + 0x5408, /* 01110111 */ + 0x5408, /* 0111011 */ + 0x2608, /* 01111000 */ + 0x2608, /* 0111100 */ + 0x6208, /* 01111 */ + 0x6208, /* 0111100 */ + 0x1608, /* 01111010 */ + 0x1608, /* 0111101 */ + 0x6108, /* 01111011 */ + 0x6108, /* 0111101 */ + 0x0609, /* 011111000 */ + 0x6009, /* 011111 */ + 0x3508, /* 01111101 */ + 0x3508, /* 0111110 */ + 0x5308, /* 01111110 */ + 0x5308, /* 0111111 */ + 0x4408, /* 01111111 */ + 0x4408, /* 0111111 */ + 0x2508, /* 10000000 */ + 0x2508, /* 1000000 */ + 0x5208, /* 10000 */ + 0x5208, /* 1000000 */ + 0x1508, /* 1000 0 */ + 0x1508, /* 1000 */ + 0x0509, /* 1000 10 */ + 0x5009, /* 1000 11 */ + 0x5107, /* 100 0 */ + 0x5107, /* 100 */ + 0x5107, /* 100 */ + 0x5107, /* 100 */ + 0x3408, /* 100 10 */ + 0x3408, /* 100 1 */ + 0x4308, /* 100 11 */ + 0x4308, /* 100 1 */ + 0x2407, /* 10 00 */ + 0x2407, /* 10 0 */ + 0x2407, /* 10 0 */ + 0x2407, /* 10 0 */ + 0x4207, /* 10 01 */ + 0x4207, /* 10 0 */ + 0x4207, /* 10 0 */ + 0x4207, /* 10 0 */ + 0x3307, /* 10 10 */ + 0x3307, /* 10 1 */ + 0x3307, /* 10 1 */ + 0x3307, /* 10 1 */ + 0x1407, /* 10 11 */ + 0x1407, /* 10 1 */ + 0x1407, /* 10 1 */ + 0x1407, /* 10 1 */ + 0x4107, /* 1 000 */ + 0x4107, /* 1 00 */ + 0x4107, /* 1 00 */ + 0x4107, /* 1 00 */ + 0x0408, /* 1 0 */ + 0x0408, /* 1 */ + 0x4008, /* 1 1 */ + 0x4008, /* 1 */ + 0x2307, /* 1 010 */ + 0x2307, /* 1 01 */ + 0x2307, /* 1 01 */ + 0x2307, /* 1 01 */ + 0x3207, /* 1 011 */ + 0x3207, /* 1 01 */ + 0x3207, /* 1 01 */ + 0x3207, /* 1 01 */ + 0x1306, /* 1 10 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x3106, /* 1 11 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x0307, /* 1010000 */ + 0x0307, /* 101000 */ + 0x0307, /* 101000 */ + 0x0307, /* 101000 */ + 0x3007, /* 1010 */ + 0x3007, /* 101000 */ + 0x3007, /* 101000 */ + 0x3007, /* 101000 */ + 0xb309, + 0xb309, + 0x8809, /* 010101 */ + 0x8809, /* 01010100 */ + 0x2b0a, /* 0101010100 */ + 0x5a0a, /* 0101010101 */ + 0xb209, /* 010101011 */ + 0xb209, /* 01010101 */ + 0xa50a, /* 0101011000 */ + 0x1b0a, /* 0101011 */ + 0xb10a, /* 0101011010 */ + 0x690a, /* 0101011011 */ + 0x9609, /* 010101110 */ + 0x9609, /* 01010111 */ + 0xa409, /* 010101111 */ + 0xa409, /* 01010111 */ + 0x4a0a, /* 0101100000 */ + 0x780a, /* 0101100 */ + 0x8709, /* 010110 */ + 0x8709, /* 01011000 */ + 0x3a09, /* 01011 0 */ + 0x3a09, /* 01011 */ + 0xa309, /* 01011 1 */ + 0xa309, /* 01011 */ + 0x5909, /* 010110100 */ + 0x5909, /* 01011010 */ + 0x9509, /* 010110101 */ + 0x9509, /* 01011010 */ + 0x2a09, /* 010110110 */ + 0x2a09, /* 01011011 */ + 0xa209, /* 010110111 */ + 0xa209, /* 01011011 */ + 0xa109, /* 010111000 */ + 0xa109, /* 01011100 */ + 0x6809, /* 010111 */ + 0x6809, /* 01011100 */ + 0x8609, /* 010111010 */ + 0x8609, /* 01011101 */ + 0x7709, /* 010111011 */ + 0x7709, /* 01011101 */ + 0x4909, /* 010111100 */ + 0x4909, /* 01011110 */ + 0x9409, /* 010111101 */ + 0x9409, /* 01011110 */ + 0x3909, /* 010111110 */ + 0x3909, /* 01011111 */ + 0x9309, /* 010111111 */ + 0x9309, /* 01011111 */ + 0x5809, /* 011000000 */ + 0x5809, /* 01100000 */ + 0x8509, /* 011000 */ + 0x8509, /* 01100000 */ + 0x2909, /* 01100 0 */ + 0x2909, /* 01100 */ + 0x6709, /* 01100 1 */ + 0x6709, /* 01100 */ + 0x7609, /* 0110 00 */ + 0x7609, /* 0110 0 */ + 0x9209, /* 0110 01 */ + 0x9209, /* 0110 0 */ + 0x1909, /* 0110 10 */ + 0x1909, /* 0110 1 */ + 0x9109, /* 0110 11 */ + 0x9109, /* 0110 1 */ + 0x4809, /* 011 000 */ + 0x4809, /* 011 00 */ + 0x8409, /* 011 */ + 0x8409, /* 011 00 */ + 0x5709, /* 011 010 */ + 0x5709, /* 011 01 */ + 0x7509, /* 011 011 */ + 0x7509, /* 011 01 */ + 0x3809, /* 011 100 */ + 0x3809, /* 011 10 */ + 0x8309, /* 011 101 */ + 0x8309, /* 011 10 */ + 0x6609, /* 011 110 */ + 0x6609, /* 011 11 */ + 0x2809, /* 011 111 */ + 0x2809, /* 011 11 */ + 0x8209, /* 011010000 */ + 0x8209, /* 01101000 */ + 0x1809, /* 011010 */ + 0x1809, /* 01101000 */ + 0x4709, /* 01101 0 */ + 0x4709, /* 01101 */ + 0x7409, /* 01101 1 */ + 0x7409, /* 01101 */ + 0x8109, /* 011010100 */ + 0x8109, /* 01101010 */ + 0x080a, /* 0110101010 */ + 0x800a, /* 0110101011 */ + 0x5609, /* 011010110 */ + 0x5609, /* 01101011 */ + 0x6509, /* 011010111 */ + 0x6509, /* 01101011 */ + 0x1709, /* 011011000 */ + 0x1709, /* 01101100 */ + 0x070a, /* 011011 0 */ + 0x700a, /* 011011 1 */ + 0x6e0b, + 0x9c0b, + 0xc90a, /* 01000 01 */ + 0xc90a, /* 01000 0 */ + 0x5e0a, /* 01000 10 */ + 0x5e0a, /* 01000 1 */ + 0xba0a, /* 01000 11 */ + 0xba0a, /* 01000 1 */ + 0xe50a, /* 0100 000 */ + 0xe50a, /* 0100 00 */ + 0xab0b, /* 0100 0 */ + 0x7d0b, /* 0100 1 */ + 0xd70a, /* 0100 010 */ + 0xd70a, /* 0100 01 */ + 0xe40a, /* 0100 011 */ + 0xe40a, /* 0100 01 */ + 0x8c0a, /* 0100 100 */ + 0x8c0a, + 0xc80a, + 0xc80a, + 0x4e0b, /* 0100 1100 */ + 0x2e0b, /* 0100 1101 */ + 0x3e0a, /* 0100 111 */ + 0x3e0a, /* 0100 11 */ + 0x6d0a, /* 010 0000 */ + 0x6d0a, /* 010 000 */ + 0xd60a, /* 010 0 */ + 0xd60a, /* 010 000 */ + 0xe30a, /* 010 0 */ + 0xe30a, /* 010 */ + 0x9b0a, /* 010 1 */ + 0x9b0a, /* 010 */ + 0xb90a, /* 010 0100 */ + 0xb90a, /* 010 010 */ + 0xaa0a, /* 010 0101 */ + 0xaa0a, + 0xe20a, + 0xe20a, + 0x1e0a, + 0x1e0a, + 0xe10a, + 0xe10a, + 0x5d0a, + 0x5d0a, + 0xd50a, + 0xd50a, + 0x7c0a, + 0x7c0a, + 0xc70a, + 0xc70a, + 0x4d0a, + 0x4d0a, + 0x8b0a, + 0x8b0a, + 0xb80a, + 0xb80a, + 0xd40a, + 0xd40a, + 0x9a0a, + 0x9a0a, + 0xa90a, /* 01 0 0 */ + 0xa90a, /* 01 0 */ + 0x6c0a, /* 01 0 1 */ + 0x6c0a, /* 01 0 */ + 0xc60a, /* 01 00 */ + 0xc60a, /* 01 0 */ + 0x3d0a, /* 01 01 */ + 0x3d0a, /* 01 0 */ + 0xd30a, /* 01 10 */ + 0xd30a, /* 01 1 */ + 0x2d0a, /* 01 11 */ + 0x2d0a, /* 01 1 */ + 0xd20a, + 0xd20a, + 0x1d0a, /* 01 01 */ + 0x1d0a, /* 01 0100 */ + 0x7b0a, /* 01 01010 */ + 0x7b0a, /* 01 0101 */ + 0xb70a, /* 01 01011 */ + 0xb70a, + 0xd10a, + 0xd10a, /* 01 0110 */ + 0x5c0a, /* 01 01101 */ + 0x5c0a, /* 01 0110 */ + 0xc50a, /* 01 01110 */ + 0xc50a, /* 01 0111 */ + 0x8a0a, /* 01 01111 */ + 0x8a0a, /* 01 0111 */ + 0xa80a, /* 01 10000 */ + 0xa80a, /* 01 1000 */ + 0x990a, /* 01 10 */ + 0x990a, /* 01 1000 */ + 0x4c0a, /* 01 1 0 */ + 0x4c0a, /* 01 1 */ + 0xc40a, /* 01 1 1 */ + 0xc40a, /* 01 1 */ + 0x6b0a, /* 01 10100 */ + 0x6b0a, /* 01 1010 */ + 0xb60a, /* 01 10101 */ + 0xb60a, /* 01 1010 */ + 0xd00b, /* 01 101100 */ + 0x0c0b, /* 01 101101 */ + 0x3c0a, /* 01 10111 */ + 0x3c0a, /* 01 1011 */ + 0xc30a, /* 01 11000 */ + 0xc30a, /* 01 1100 */ + 0x7a0a, /* 01 11 */ + 0x7a0a, /* 01 1100 */ + 0xa70a, /* 01 11010 */ + 0xa70a, /* 01 1101 */ + 0x2c0a, /* 01 11011 */ + 0x2c0a, /* 01 1101 */ + 0xc20a, /* 01 11100 */ + 0xc20a, /* 01 1110 */ + 0x5b0a, /* 01 11101 */ + 0x5b0a, /* 01 1110 */ + 0xb50a, /* 01 11110 */ + 0xb50a, /* 01 1111 */ + 0x1c0a, + 0x1c0a, + 0x890a, + 0x890a, + 0x980a, + 0x980a, + 0xc10a, /* 010100 0 */ + 0xc10a, /* 010100 */ + 0x4b0a, /* 010100 1 */ + 0x4b0a, /* 010100 */ + 0xc00b, /* 01010 000 */ + 0x0b0b, /* 01010 */ + 0x3b0a, /* 01010 01 */ + 0x3b0a, /* 01010 0 */ + 0xb00b, /* 01010 100 */ + 0x0a0b, /* 01010 101 */ + 0x1a0a, /* 01010 11 */ + 0x1a0a, /* 01010 1 */ + 0xb409, /* 0101 00 */ + 0xb409, /* 0101 0 */ + 0xb409, /* 0101 0 */ + 0xb409, /* 0101 0 */ + 0x6a0a, /* 0101 010 */ + 0x6a0a, /* 0101 01 */ + 0xa60a, /* 0101 011 */ + 0xa60a, /* 0101 01 */ + 0x790a, /* 0101 100 */ + 0x790a, /* 0101 10 */ + 0x970a, /* 0101 101 */ + 0x970a, /* 0101 10 */ + 0xa00b, /* 0101 1100 */ + 0x090b, /* 0101 1101 */ + 0x900a, /* 0101 111 */ + 0x900a, /* 0101 11 */ + 0xca0b, + 0xca0b, + 0xbb0b, + 0xbb0b, + 0x8d0b, + 0x8d0b, /* 0100000 */ + 0xd80b, /* 0100000 1 */ + 0xd80b, /* 0100000 */ + 0x0e0c, /* 010000 000 */ + 0xe00c, /* 010000 */ + 0x0d0b, /* 010000 01 */ + 0x0d0b, /* 010000 0 */ + 0xe60a, /* 010000 1 */ + 0xe60a, /* 010000 */ + 0xe60a, /* 010000 */ + 0xe60a, /* 010000 */ + 0x0f09, /* 011000 401 */ + 0x0f09, /* 01100 */ + 0x0f09, /* 01100 */ + 0x0f09, /* 01100 */ + 0xee0b, /* 011 00 */ + 0xde0b, /* 011 01 */ + 0xed0b, /* 011 10 */ + 0xce0b, /* 011 11 */ + 0xec0b, /* 01101000 */ + 0xdd0b, /* 01101 */ + 0xbe0b, /* 01101010 */ + 0xeb0b, /* 01101011 */ + 0xcd0b, /* 01101100 */ + 0xdc0b, /* 01101101 */ + 0xae0b, /* 01101110 */ + 0xea0b, /* 01101111 */ + 0xbd0b, /* 01110000 */ + 0xdb0b, /* 01110 */ + 0xcc0b, /* 0111 0 */ + 0x9e0b, /* 0111 1 */ + 0xe90b, /* 01110100 */ + 0xad0b, /* 01110101 */ + 0xda0b, /* 01110110 */ + 0xbc0b, /* 01110111 */ + 0xcb0b, /* 01111000 */ + 0x8e0b, + 0xe80b, + 0x9d0b, + 0xd90b, + 0x7e0b, + 0xe70b, + 0xac0b, + 0xff04, + 0xef08, + 0xfe08, + 0xdf08, /* 0000 0 */ + 0xfd08, /* 0000 1 */ + 0xcf08, /* 000 00 */ + 0xfc08, /* 000 01 */ + 0xbf08, /* 000 10 */ + 0xfb08, /* 000 11 */ + 0xfa07, /* 00 00 */ + 0xfa07, /* 00 0 */ + 0xaf08, /* 00 010 */ + 0x9f08, /* 00 011 */ + 0xf907, /* 00 10 */ + 0xf907, /* 00 1 */ + 0xf807, /* 00 11 */ + 0xf807, /* 00 1 */ + 0x8f08, + 0x7f08, /* 0 0 */ + 0xf707, /* 0 */ + 0xf707, /* 0 00 */ + 0x6f07, /* 0 010 */ + 0x6f07, /* 0 01 */ + 0xf607, /* 0 011 */ + 0xf607, /* 0 01 */ + 0x5f07, + 0x5f07, /* 0 10 */ + 0xf507, /* 0 101 */ + 0xf507, /* 0 10 */ + 0x4f07, /* 0 110 */ + 0x4f07, /* 0 11 */ + 0xf407, /* 0 111 */ + 0xf407, /* 0 11 */ + 0x3f07, + 0x3f07, + 0xf307, /* 0 */ + 0xf307, + 0x2f07, /* 0 */ + 0x2f07, /* */ + 0xf207, /* 1 */ + 0xf207, /* */ + 0xf107, + 0xf107, + 0x1f08, + 0xf008 + +}; + + +const uint16 huffTable_32[33] = +{ + + 0x0b06, + 0x0f06, + 0x0d06, + 0x0e06, + 0x0706, + 0x0506, + 0x0905, + 0x0905, + 0x0605, + 0x0605, + 0x0305, + 0x0305, + 0x0a05, + 0x0a05, + 0x0c05, + 0x0c05, + 0x0204, + 0x0204, + 0x0204, + 0x0204, + 0x0104, + 0x0104, + 0x0104, + 0x0104, + 0x0404, + 0x0404, + 0x0404, + 0x0404, + 0x0804, + 0x0804, + 0x0804, + 0x0804, + 0x0001 + +}; + + +/* + * MM = 512; z = [0:(MM)]; a = z.^(1/3); + * Table is in Q27 + */ +const int32 power_one_third[513] = +{ + + 0x00000000, 0x08000000, 0x0A14517D, 0x0B89BA25, + 0x0CB2FF53, 0x0DAE07DE, 0x0E897685, 0x0F4DAEDD, + 0x10000000, 0x10A402FD, 0x113C4841, 0x11CAB613, + 0x1250BFE2, 0x12CF8890, 0x1347F8AB, 0x13BACD65, + 0x1428A2FA, 0x1491FC15, 0x14F74744, 0x1558E2F7, + 0x15B72095, 0x161246D7, 0x166A9399, 0x16C03D55, + 0x17137449, 0x17646369, 0x17B33124, 0x18000000, + 0x184AEF29, 0x18941AD8, 0x18DB9CB7, 0x19218C2E, + 0x1965FEA5, 0x19A907C2, 0x19EAB998, 0x1A2B24D0, + 0x1A6A58D5, 0x1AA863EE, 0x1AE5535D, 0x1B213377, + 0x1B5C0FBD, 0x1B95F2EC, 0x1BCEE70F, 0x1C06F590, + 0x1C3E2745, 0x1C74847A, 0x1CAA1501, 0x1CDEE035, + 0x1D12ED0B, 0x1D464212, 0x1D78E582, 0x1DAADD3A, + 0x1DDC2ECF, 0x1E0CDF8C, 0x1E3CF476, 0x1E6C7257, + 0x1E9B5DBA, 0x1EC9BAF6, 0x1EF78E2C, 0x1F24DB4E, + 0x1F51A620, 0x1F7DF23C, 0x1FA9C314, 0x1FD51BF2, + 0x20000000, 0x202A7244, 0x205475A6, 0x207E0CEE, + 0x20A73ACA, 0x20D001CC, 0x20F8646D, 0x2120650E, + 0x214805FA, 0x216F4963, 0x2196316C, 0x21BCC020, + 0x21E2F77A, 0x2208D961, 0x222E67AD, 0x2253A425, + 0x22789082, 0x229D2E6E, 0x22C17F82, 0x22E5854F, + 0x23094155, 0x232CB509, 0x234FE1D5, 0x2372C918, + 0x23956C26, 0x23B7CC47, 0x23D9EABB, 0x23FBC8B9, + 0x241D676E, 0x243EC7FF, 0x245FEB86, 0x2480D319, + 0x24A17FC3, 0x24C1F28B, 0x24E22C6C, 0x25022E5F, + 0x2521F954, 0x25418E33, 0x2560EDE2, 0x2580193E, + 0x259F111F, 0x25BDD657, 0x25DC69B4, 0x25FACBFE, + 0x2618FDF8, 0x26370060, 0x2654D3EF, 0x2672795C, + 0x268FF156, 0x26AD3C8A, 0x26CA5BA2, 0x26E74F41, + 0x27041808, 0x2720B695, 0x273D2B81, 0x27597762, + 0x27759ACB, 0x2791964B, 0x27AD6A6F, 0x27C917C0, + 0x27E49EC5, 0x28000000, 0x281B3BF3, 0x2836531B, + 0x285145F3, 0x286C14F5, 0x2886C096, 0x28A1494B, + 0x28BBAF85, 0x28D5F3B3, 0x28F01641, 0x290A179B, + 0x2923F82A, 0x293DB854, 0x2957587E, 0x2970D90A, + 0x298A3A59, 0x29A37CCA, 0x29BCA0BB, 0x29D5A687, + 0x29EE8E87, 0x2A075914, 0x2A200684, 0x2A38972C, + 0x2A510B5F, 0x2A696370, 0x2A819FAE, 0x2A99C069, + 0x2AB1C5ED, 0x2AC9B088, 0x2AE18085, 0x2AF9362C, + 0x2B10D1C6, 0x2B28539B, 0x2B3FBBEF, 0x2B570B09, + 0x2B6E412B, 0x2B855E97, 0x2B9C6390, 0x2BB35056, + 0x2BCA2527, 0x2BE0E242, 0x2BF787E4, 0x2C0E1649, + 0x2C248DAD, 0x2C3AEE4A, 0x2C513859, 0x2C676C13, + 0x2C7D89AF, 0x2C939164, 0x2CA98368, 0x2CBF5FF1, + 0x2CD52731, 0x2CEAD95E, 0x2D0076A9, 0x2D15FF45, + 0x2D2B7363, 0x2D40D332, 0x2D561EE4, 0x2D6B56A7, + 0x2D807AAA, 0x2D958B19, 0x2DAA8823, 0x2DBF71F4, + 0x2DD448B7, 0x2DE90C98, 0x2DFDBDC0, 0x2E125C5C, + 0x2E26E892, 0x2E3B628D, 0x2E4FCA75, 0x2E642070, + 0x2E7864A8, 0x2E8C9741, 0x2EA0B862, 0x2EB4C831, + 0x2EC8C6D3, 0x2EDCB46C, 0x2EF09121, 0x2F045D14, + 0x2F18186A, 0x2F2BC345, 0x2F3F5DC7, 0x2F52E812, + 0x2F666247, 0x2F79CC88, 0x2F8D26F4, 0x2FA071AC, + 0x2FB3ACD0, 0x2FC6D87F, 0x2FD9F4D7, 0x2FED01F8, + 0x30000000, 0x3012EF0C, 0x3025CF39, 0x3038A0A6, + 0x304B636D, 0x305E17AD, 0x3070BD81, 0x30835504, + 0x3095DE51, 0x30A85985, 0x30BAC6B9, 0x30CD2609, + 0x30DF778D, 0x30F1BB60, 0x3103F19C, 0x31161A59, + 0x312835B0, 0x313A43BA, 0x314C4490, 0x315E3849, + 0x31701EFD, 0x3181F8C4, 0x3193C5B4, 0x31A585E6, + 0x31B7396F, 0x31C8E066, 0x31DA7AE1, 0x31EC08F6, + 0x31FD8ABC, 0x320F0047, 0x322069AC, 0x3231C702, + 0x3243185C, 0x32545DCF, 0x32659770, 0x3276C552, + 0x3287E78A, 0x3298FE2C, 0x32AA094A, 0x32BB08F9, + 0x32CBFD4A, 0x32DCE652, 0x32EDC423, 0x32FE96D0, + 0x330F5E6A, 0x33201B04, 0x3330CCB0, 0x33417380, + 0x33520F85, 0x3362A0D0, 0x33732774, 0x3383A380, + 0x33941506, 0x33A47C17, 0x33B4D8C4, 0x33C52B1B, + 0x33D5732F, 0x33E5B10F, 0x33F5E4CA, 0x34060E71, + 0x34162E14, 0x342643C1, 0x34364F88, 0x34465178, + 0x345649A1, 0x34663810, 0x34761CD6, 0x3485F800, + 0x3495C99D, 0x34A591BB, 0x34B55069, 0x34C505B4, + 0x34D4B1AB, 0x34E4545B, 0x34F3EDD2, 0x35037E1D, + 0x3513054B, 0x35228367, 0x3531F881, 0x354164A3, + 0x3550C7DC, 0x35602239, 0x356F73C5, 0x357EBC8E, + 0x358DFCA0, 0x359D3408, 0x35AC62D1, 0x35BB8908, + 0x35CAA6B9, 0x35D9BBF0, 0x35E8C8B9, 0x35F7CD20, + 0x3606C92F, 0x3615BCF3, 0x3624A878, 0x36338BC8, + 0x364266EE, 0x365139F6, 0x366004EC, 0x366EC7D9, + 0x367D82C9, 0x368C35C6, 0x369AE0DC, 0x36A98414, + 0x36B81F7A, 0x36C6B317, 0x36D53EF7, 0x36E3C323, + 0x36F23FA5, 0x3700B488, 0x370F21D5, 0x371D8797, + 0x372BE5D7, 0x373A3CA0, 0x37488BF9, 0x3756D3EF, + 0x37651489, 0x37734DD1, 0x37817FD1, 0x378FAA92, + 0x379DCE1D, 0x37ABEA7C, 0x37B9FFB7, 0x37C80DD7, + 0x37D614E6, 0x37E414EC, 0x37F20DF1, 0x38000000, + 0x380DEB20, 0x381BCF5A, 0x3829ACB6, 0x3837833D, + 0x384552F8, 0x38531BEE, 0x3860DE28, 0x386E99AF, + 0x387C4E89, 0x3889FCC0, 0x3897A45B, 0x38A54563, + 0x38B2DFDF, 0x38C073D7, 0x38CE0152, 0x38DB885A, + 0x38E908F4, 0x38F68329, 0x3903F701, 0x39116483, + 0x391ECBB6, 0x392C2CA1, 0x3939874D, 0x3946DBC0, + 0x39542A01, 0x39617218, 0x396EB40C, 0x397BEFE4, + 0x398925A7, 0x3996555C, 0x39A37F09, 0x39B0A2B7, + 0x39BDC06A, 0x39CAD82B, 0x39D7EA01, 0x39E4F5F0, + 0x39F1FC01, 0x39FEFC3A, 0x3A0BF6A2, 0x3A18EB3E, + 0x3A25DA16, 0x3A32C32F, 0x3A3FA691, 0x3A4C8441, + 0x3A595C46, 0x3A662EA6, 0x3A72FB67, 0x3A7FC28F, + 0x3A8C8425, 0x3A99402E, 0x3AA5F6B1, 0x3AB2A7B3, + 0x3ABF533A, 0x3ACBF94D, 0x3AD899F1, 0x3AE5352C, + 0x3AF1CB03, 0x3AFE5B7D, 0x3B0AE6A0, 0x3B176C70, + 0x3B23ECF3, 0x3B306830, 0x3B3CDE2C, 0x3B494EEB, + 0x3B55BA74, 0x3B6220CC, 0x3B6E81F9, 0x3B7ADE00, + 0x3B8734E5, 0x3B9386B0, 0x3B9FD364, 0x3BAC1B07, + 0x3BB85D9E, 0x3BC49B2F, 0x3BD0D3BE, 0x3BDD0751, + 0x3BE935ED, 0x3BF55F97, 0x3C018453, 0x3C0DA427, + 0x3C19BF17, 0x3C25D52A, 0x3C31E662, 0x3C3DF2C6, + 0x3C49FA5B, 0x3C55FD24, 0x3C61FB27, 0x3C6DF468, + 0x3C79E8ED, 0x3C85D8B9, 0x3C91C3D2, 0x3C9DAA3C, + 0x3CA98BFC, 0x3CB56915, 0x3CC1418E, 0x3CCD156A, + 0x3CD8E4AE, 0x3CE4AF5E, 0x3CF0757F, 0x3CFC3714, + 0x3D07F423, 0x3D13ACB0, 0x3D1F60BF, 0x3D2B1055, + 0x3D36BB75, 0x3D426224, 0x3D4E0466, 0x3D59A23F, + 0x3D653BB4, 0x3D70D0C8, 0x3D7C6180, 0x3D87EDE0, + 0x3D9375EC, 0x3D9EF9A8, 0x3DAA7918, 0x3DB5F43F, + 0x3DC16B23, 0x3DCCDDC7, 0x3DD84C2E, 0x3DE3B65D, + 0x3DEF1C58, 0x3DFA7E22, 0x3E05DBC0, 0x3E113535, + 0x3E1C8A85, 0x3E27DBB3, 0x3E3328C4, 0x3E3E71BB, + 0x3E49B69C, 0x3E54F76B, 0x3E60342B, 0x3E6B6CE0, + 0x3E76A18D, 0x3E81D237, 0x3E8CFEE0, 0x3E98278D, + 0x3EA34C40, 0x3EAE6CFE, 0x3EB989CA, 0x3EC4A2A8, + 0x3ECFB79A, 0x3EDAC8A5, 0x3EE5D5CB, 0x3EF0DF10, + 0x3EFBE478, 0x3F06E606, 0x3F11E3BE, 0x3F1CDDA2, + 0x3F27D3B6, 0x3F32C5FD, 0x3F3DB47B, 0x3F489F32, + 0x3F538627, 0x3F5E695C, 0x3F6948D5, 0x3F742494, + 0x3F7EFC9D, 0x3F89D0F3, 0x3F94A19A, 0x3F9F6E94, + 0x3FAA37E4, 0x3FB4FD8E, 0x3FBFBF94, 0x3FCA7DFB, + 0x3FD538C4, 0x3FDFEFF3, 0x3FEAA38A, 0x3FF5538E, + 0x40000000 +}; + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_tables.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_tables.h new file mode 100644 index 0000000..31c6fe0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/pvmp3_tables.h @@ -0,0 +1,120 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: pvmp3_tables.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PVMP3_TABLES_H +#define PVMP3_TABLES_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pv_mp3_huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ +#define Qfmt_28(a) (int32(double(0x10000000)*a)) + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +typedef struct +{ + int16 l[23]; + int16 s[14]; +} mp3_scaleFactorBandIndex; + + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + extern const int32 mp3_s_freq[4][4]; + extern const int32 inv_sfreq[4]; + extern const int16 mp3_bitrate[3][15]; + extern const int32 power_one_third[513]; + + extern const mp3_scaleFactorBandIndex mp3_sfBandIndex[9]; + extern const int32 mp3_shortwindBandWidths[9][13]; + extern const int32 pqmfSynthWin[(HAN_SIZE/2) + 8]; + + + extern const uint16 huffTable_1[]; + extern const uint16 huffTable_2[]; + extern const uint16 huffTable_3[]; + extern const uint16 huffTable_5[]; + extern const uint16 huffTable_6[]; + extern const uint16 huffTable_7[]; + extern const uint16 huffTable_8[]; + extern const uint16 huffTable_9[]; + extern const uint16 huffTable_10[]; + extern const uint16 huffTable_11[]; + extern const uint16 huffTable_12[]; + extern const uint16 huffTable_13[]; + extern const uint16 huffTable_15[]; + extern const uint16 huffTable_16[]; + extern const uint16 huffTable_24[]; + extern const uint16 huffTable_32[]; + extern const uint16 huffTable_33[]; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_huffcodetab.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_huffcodetab.h new file mode 100644 index 0000000..bd975f6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_huffcodetab.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: s_huffcodetab.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_HUFFCODETAB_H +#define S_HUFFCODETAB_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define HUFF_TBL 34 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +struct huffcodetab +{ + uint32 linbits; /*number of linbits */ + uint16(*pdec_huff_tab)(tmp3Bits *); +}; + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_mp3bits.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_mp3bits.h new file mode 100644 index 0000000..cb1a159 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_mp3bits.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: s_mp3bits.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, BITS + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_MP3BITS_H +#define S_MP3BITS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +/* + * Name: BITS + * Description: Holds information for processing the input data buffer + * as a "stream". The data is in packed format. + * Fields: + * pBuffer - pointer to the beginning of the buffer. If the data type of + * this changes, make sure to update the constants in ibstream.h + * usedBits - number of bits read thus far from the buffer. Bit 0 is + * the LSB of pBuffer[0]. + */ + + +typedef struct +{ + uint8 *pBuffer; + uint32 usedBits; + uint32 inputBufferCurrentLength; + uint32 offset; +} tmp3Bits; + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_tmp3dec_chan.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_tmp3dec_chan.h new file mode 100644 index 0000000..c832a62 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_tmp3dec_chan.h @@ -0,0 +1,103 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: s_tmp3dec_chan.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, tmp3dec_chan. + This structure contains information per channel that needs to persist + between calls + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_TMP3DEC_CHAN_H +#define S_TMP3DEC_CHAN_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" +#include "pvmp3_dec_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct + { + int32 used_freq_lines; + int32 overlap[SUBBANDS_NUMBER*FILTERBANK_BANDS]; + int32 work_buf_int32[SUBBANDS_NUMBER*FILTERBANK_BANDS]; /* working buffer */ + int32 circ_buffer[480 + 576]; + + } tmp3dec_chan; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_tmp3dec_file.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_tmp3dec_file.h new file mode 100644 index 0000000..c4c7247 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/dec/src/s_tmp3dec_file.h @@ -0,0 +1,111 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: s_tmp3dec_file.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, tmp3dec_file. + This structure contains information that needs to persist between calls + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_TMP3DEC_FILE_H +#define S_TMP3DEC_FILE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_tmp3dec_chan.h" +#include "s_mp3bits.h" +#include "s_huffcodetab.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct + { + int32 num_channels; + int32 predicted_frame_size; + int32 frame_start; + int32 Scratch_mem[168]; + tmp3dec_chan perChan[CHAN]; + mp3ScaleFactors scaleFactors[CHAN]; + mp3SideInfo sideInfo; + tmp3Bits mainDataStream; + uint8 mainDataBuffer[BUFSIZE]; + tmp3Bits inputStream; + huffcodetab ht[HUFF_TBL]; + } tmp3dec_file; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/patent_disclaimer.txt b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/patent_disclaimer.txt new file mode 100644 index 0000000..b4bf11d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/codecs_v2/audio/mp3/patent_disclaimer.txt @@ -0,0 +1,9 @@ + +THIS IS NOT A GRANT OF PATENT RIGHTS. + +Google makes no representation or warranty that the codecs for which +source code is made available hereunder are unencumbered by +third-party patents. Those intending to use this source code in +hardware or software products are advised that implementations of +these codecs, including in open source software or shareware, may +require patent licenses from the relevant patent holders. diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/local.mk new file mode 100644 index 0000000..cc33a7b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/local.mk @@ -0,0 +1,29 @@ +LOCAL_PATH := $(call get_makefile_dir) + +# save off the local_path because it will be overwritten +# by other includes +#SRC_ROOT := $(LOCAL_PATH) + +ifeq ($(USE_LOADABLE_MODULES),1) + LOCAL_MAKEFILES_LIST := $(SRC_ROOT)/oscl/oscl/oscllib/build/make/local.mk +endif + +LOCAL_MAKEFILES_LIST += \ +$(SRC_ROOT)/oscl/pvlogger/build/make/local.mk \ +$(SRC_ROOT)/oscl/oscl/osclregcli/build/make/local.mk \ +$(SRC_ROOT)/oscl/oscl/osclregserv/build/make/local.mk \ +$(SRC_ROOT)/oscl/oscl/osclutil/build/make/local.mk \ +$(SRC_ROOT)/oscl/oscl/osclproc/build/make/local.mk \ +$(SRC_ROOT)/oscl/oscl/osclio/build/make/local.mk \ +$(SRC_ROOT)/oscl/oscl/osclmemory/build/make/local.mk \ +$(SRC_ROOT)/oscl/oscl/osclerror/build/make/local.mk \ +$(SRC_ROOT)/oscl/oscl/osclbase/build/make/local.mk + +include $(MK)/intermediate_level.mk + +doc_target := oscl +doc_title := "OSCL API" +doc_paths := "$(SRC_ROOT)/oscl/oscl/config/shared $(SRC_ROOT)/oscl/oscl/config/$(BUILD_ARCH) $(SRC_ROOT)/oscl/oscl/osclbase $(SRC_ROOT)/oscl/oscl/osclerror $(SRC_ROOT)/oscl/oscl/osclio $(SRC_ROOT)/oscl/oscl/osclmemory $(SRC_ROOT)/oscl/oscl/osclproc $(SRC_ROOT)/oscl/oscl/osclregcli $(SRC_ROOT)/oscl/oscl/osclregserv $(SRC_ROOT)/oscl/oscl/osclutil" +doc_version := $(OSCL_VERSION) + +include $(MK)/doc.mk diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig.h new file mode 100644 index 0000000..aa00dfa --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig.h @@ -0,0 +1,108 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G ( P L A T F O R M C O N F I G I N F O ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig.h + * \brief This file contains configuration information for the linux platform + * + */ + +#ifndef OSCLCONFIG_H_INCLUDED +#define OSCLCONFIG_H_INCLUDED + +// system includes for dynamic registry +#include +#include +#include +#include +#include + +#define OSCL_HAS_ANDROID_SUPPORT 1 +#define OSCL_HAS_ANDROID_FILE_IO_SUPPORT 1 + +#define OSCL_EXPORT_REF __attribute__ ((visibility("default"))) +#define OSCL_IMPORT_REF __attribute__ ((visibility("default"))) + +// include common include for determining sizes from limits.h +#include "osclconfig_limits_typedefs.h" + +//This switch turns off some profiling and debug settings +#ifndef OSCL_RELEASE_BUILD +#ifdef NDEBUG +#define OSCL_RELEASE_BUILD 1 +#else +#define OSCL_RELEASE_BUILD 0 +#endif +#endif + +#ifndef PVLOGGER_INST_LEVEL +#if (OSCL_RELEASE_BUILD) +//Release mode logging - should be kept minimum +#define PVLOGGER_INST_LEVEL 1 +#else +//full logging +#define PVLOGGER_INST_LEVEL 5 +#endif +#endif + +// include common unix definitions +#include "osclconfig_unix_android.h" + +// define the suffix for unsigned constants +#define OSCL_UNSIGNED_CONST(x) x##u + +// override the common definition for +#undef OSCL_NATIVE_UINT64_TYPE +#define OSCL_NATIVE_UINT64_TYPE u_int64_t + +// include the definitions for the processor +#include "osclconfig_ix86.h" + +// the syntax for explicitly calling the destructor varies on some platforms +// below is the default syntax as defined by another ARM project +#define OSCL_TEMPLATED_DESTRUCTOR_CALL(type,simple_type) ~type () + + +/* The __TFS__ macro is used to optionally expand to "<>" depending on the + * compiler. Some compilers require it to indicate that the friend function + * is a template function as specified in the standard, but others don't + * like it so it will handled with a macro expansion that depends on the + * compiler. + */ +#define __TFS__ <> + +#define OSCL_HAS_PRAGMA_PACK 0 +#define OSCL_HAS_PACKED_STRUCT 1 +#define OSCL_PACKED_VAR(x) x __attribute__((packed)) +#define OSCL_PACKED_STRUCT_BEGIN +#define OSCL_PACKED_STRUCT_END __attribute__((packed)) + +//set this to 1 to enable OSCL_ASSERT in release builds. +#define OSCL_ASSERT_ALWAYS 0 + + +// check all osclconfig required macros are defined +#include "osclconfig_check.h" + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_compiler_warnings.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_compiler_warnings.h new file mode 100644 index 0000000..28d7418 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_compiler_warnings.h @@ -0,0 +1,44 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ C O M P I L E R _ W A R N I N G S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_compiler_warnings.h + * \brief This file contains the ability to turn off/on compiler warnings + * + */ + +// This macro enables the "#pragma GCC system_header" found in any header file that +// includes this config file. +// "#pragma GCC system_header" suppresses compiler warnings in the rest of that header +// file by treating the header as a system header file. +// For instance, foo.h has 30 lines, "#pragma GCC system_header" is inserted at line 10, +// from line 11 to the end of file, all compiler warnings are disabled. +// However, this does not affect any files that include foo.h. +// +#ifdef __GNUC__ +#define OSCL_DISABLE_GCC_WARNING_SYSTEM_HEADER +#endif + +#define OSCL_FUNCTION_PTR(x) (&x) + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_error.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_error.h new file mode 100644 index 0000000..6cdf86c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_error.h @@ -0,0 +1,53 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ E R R O R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_error.h + * \brief This file contains the common typedefs and header files needed to compile osclerror + * + */ + + +#ifndef OSCLCONFIG_ERROR_H_INCLUDED +#define OSCLCONFIG_ERROR_H_INCLUDED + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#define OSCL_HAS_EXCEPTIONS 1 +#define OSCL_HAS_ERRNO_H 1 +#define OSCL_HAS_SYMBIAN_ERRORTRAP 0 +#define OSCL_HAS_SETJMP_H 1 + +// system header files +#include +#include + + +// confirm that all definitions have been defined +#include "osclconfig_error_check.h" + +#endif // OSCLCONFIG_ERROR_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_io.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_io.h new file mode 100644 index 0000000..0ee117e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_io.h @@ -0,0 +1,311 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ I O + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_io.h + * \brief This file contains common typedefs based on the ANSI C limits.h header + * + * This header file should work for any ANSI C compiler to determine the + * proper native C types to use for OSCL integer types. + */ + + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#define OSCLCONFIG_IO_H_INCLUDED + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#if (OSCL_HAS_ANSI_STDLIB_SUPPORT) +#if (OSCL_HAS_UNIX_SUPPORT) +#include +#endif +#endif + +//For File I/O +#define OSCL_HAS_GLOB 0 +#define OSCL_HAS_ANSI_FILE_IO_SUPPORT 1 +#define OSCL_HAS_ANSI_64BIT_FILE_IO_SUPPORT 0 +#define OSCL_HAS_MSWIN_FILE_IO_SUPPORT 0 +#define OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION 0 +#define OSCL_HAS_NATIVE_FILE_CACHE_ENABLE 1 +#define OSCL_FILE_BUFFER_MAX_SIZE 32768 +#define OSCL_HAS_PV_FILE_CACHE 0 +#define OSCL_HAS_LARGE_FILE_SUPPORT 1 + +//For Sockets +#define OSCL_HAS_SYMBIAN_SOCKET_SERVER 0 +#define OSCL_HAS_SYMBIAN_DNS_SERVER 0 +#define OSCL_HAS_BERKELEY_SOCKETS 1 +#define OSCL_HAS_SOCKET_SUPPORT 1 + +//basic socket types +typedef int TOsclSocket; +typedef struct sockaddr_in TOsclSockAddr; +typedef socklen_t TOsclSockAddrLen; +typedef struct ip_mreq TIpMReq; + +//Init addr macro, inet_addr returns an uint32 +#define OsclValidInetAddr(addr) (inet_addr(addr)!=INADDR_NONE) + +//address conversion macro-- from string to network address. +#define OsclMakeSockAddr(sockaddr,port,addrstr,ok)\ + sockaddr.sin_family=OSCL_AF_INET;\ + sockaddr.sin_port=htons(port);\ + int32 result=inet_aton((const char*)addrstr,&sockaddr.sin_addr);\ + ok=(result!=0); + +//address conversion macro-- from network address to string +#define OsclUnMakeSockAddr(sockaddr,addrstr)\ + addrstr=inet_ntoa(sockaddr.sin_addr); +//address conversion macro-- from string to inaddr +#define OsclMakeInAddr(in_addr,addrstr,ok)\ + int32 result = inet_aton((const char*)addrstr, &in_addr);\ + ok=(result!=0); + +//address conversion macro-- from inaddr to string +#define OsclUnMakeInAddr(in_addr,addrstr)\ + addrstr=inet_ntoa(in_addr); + +//wrappers for berkeley socket calls +#define OsclSetRecvBufferSize(s,val,ok,err) \ + ok=(setsockopt(s,SOL_SOCKET,SO_RCVBUF,(char*)&val, sizeof(int)) !=-1);\ + if (!ok)err=errno + +#define OsclBind(s,addr,ok,err)\ + TOsclSockAddr* tmpadr = &addr;\ + sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\ + ok=(bind(s,sadr,sizeof(addr))!=(-1));\ + if (!ok)err=errno + +#define OsclSetSockOpt(s,optLevel,optName,optVal,optLen,ok,err)\ + ok=(setsockopt(s,optLevel,optName,OSCL_STATIC_CAST(const char*,optVal),optLen) != (-1));\ + if (!ok)err=errno +#define OsclJoin(s,addr,ok,err)\ +{\ + struct ip_mreq mreq; \ + void* p = &addr; \ + ok=(bind(s,(sockaddr*)p,sizeof(addr))!=(-1));\ + mreq.imr_multiaddr.s_addr = addr.sin_addr.s_addr ; \ + mreq.imr_interface.s_addr = htonl(INADDR_ANY); \ + ok=(setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(struct ip_mreq))!=(-1)); \ + if (!ok)err=errno;\ +} + + +#define OsclListen(s,size,ok,err)\ + ok=(listen(iSocket,qSize)!=(-1));\ + if (!ok)err=errno + +#define OsclAccept(s,accept_s,ok,err,wouldblock)\ + accept_s=accept(s,NULL,NULL);\ + ok=(accept_s!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);} + +#define OsclSetNonBlocking(s,ok,err)\ + ok=(fcntl(s,F_SETFL,O_NONBLOCK)!=(-1));\ + if (!ok)err=errno + +#define OsclShutdown(s,how,ok,err)\ + ok=(shutdown(iSocket,how)!=(-1));\ + if (!ok)err=errno + +#define OsclSocket(s,fam,type,prot,ok,err)\ + s=socket(fam,type,prot);\ + ok=(s!=(-1));\ + if (!ok)err=errno + +#define OsclSendTo(s,buf,len,addr,ok,err,nbytes,wouldblock)\ + TOsclSockAddr* tmpadr = &addr;\ + sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\ + nbytes=sendto(s,(const void*)(buf),(size_t)(len),0,sadr,(socklen_t)sizeof(addr));\ + ok=(nbytes!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);} + +#define OsclSend(s,buf,len,ok,err,nbytes,wouldblock)\ + nbytes=send(s,(const void*)(buf),(size_t)(len),0);\ + ok=(nbytes!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);} + +#define OsclCloseSocket(s,ok,err)\ + ok=(close(s)!=(-1));\ + if (!ok)err=errno + +#define OsclConnect(s,addr,ok,err,wouldblock)\ + TOsclSockAddr* tmpadr = &addr;\ + sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\ + ok=(connect(s,sadr,sizeof(addr))!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EINPROGRESS);} +#define OsclGetPeerName(s,name,namelen,ok,err)\ + ok=(getpeername(s,(sockaddr*)&name,(socklen_t*)&namelen) != (-1) );\ + if (!ok)err=errno + +#define OsclGetAsyncSockErr(s,ok,err)\ + int opterr;socklen_t optlen=sizeof(opterr);\ + ok=(getsockopt(s,SOL_SOCKET,SO_ERROR,(void *)&opterr,&optlen)!=(-1));\ + if(ok)err=opterr;else err=errno; + +#define OsclPipe(x) pipe(x) +#define OsclReadFD(fd,buf,cnt) read(fd,buf,cnt) +#define OsclWriteFD(fd,buf,cnt) write(fd,buf,cnt) + +//unix reports connect completion in write set in the getsockopt +//error. +#define OsclConnectComplete(s,wset,eset,success,fail,ok,err)\ + success=fail=false;\ + if (FD_ISSET(s,&eset))\ + {fail=true;OsclGetAsyncSockErr(s,ok,err);}\ + else if (FD_ISSET(s,&wset))\ + {OsclGetAsyncSockErr(s,ok,err);if (ok && err==0)success=true;else fail=true;} + +#define OsclRecv(s,buf,len,ok,err,nbytes,wouldblock)\ + nbytes=recv(s,(void *)(buf),(size_t)(len),0);\ + ok=(nbytes!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EAGAIN);} + +#define OsclRecvFrom(s,buf,len,paddr,paddrlen,ok,err,nbytes,wouldblock)\ +{\ +void* p=paddr;\ +nbytes=recvfrom(s,(void*)(buf),(size_t)(len),0,(struct sockaddr*)p,paddrlen);\ + ok=(nbytes!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EAGAIN);}\ +} + + +#define OsclSocketSelect(nfds,rd,wr,ex,timeout,ok,err,nhandles)\ + nhandles=select(nfds,&rd,&wr,&ex,&timeout);\ + ok=(nhandles!=(-1));\ + if (!ok)err=errno + +//there's not really any socket startup needed on unix, but +//you need to define a signal handler for SIGPIPE to avoid +//broken pipe crashes. +#define OsclSocketStartup(ok)\ + signal(SIGPIPE,SIG_IGN);\ + ok=true + +#define OsclSocketCleanup(ok)\ + signal(SIGPIPE,SIG_DFL);\ + ok=true + +//hostent type +typedef struct hostent TOsclHostent; + +//wrapper for gethostbyname +#define OsclGethostbyname(name,hostent,ok,err)\ + hostent=gethostbyname((const char*)name);\ + ok=(hostent!=NULL);\ + if (!ok)err=errno; + +//extract dotted address from a hostent +#define OsclGetDottedAddr(hostent,dottedaddr,ok)\ + long *_hostaddr=(long*)hostent->h_addr_list[0];\ + struct in_addr _inaddr;\ + _inaddr.s_addr=*_hostaddr;\ + dottedaddr=inet_ntoa(_inaddr);\ + ok=(dottedaddr!=NULL); + +//extract dotted address from a hostent into the vector of OsclNetworkAddress +#define OsclGetDottedAddrVector(hostent,dottedaddr,dottedaddrvect,ok)\ + if(dottedaddrvect)\ + {\ + long **_addrlist=(long**)hostent->h_addr_list;\ + for(int i = 0; _addrlist[i] != NULL; i++){\ + struct in_addr _inaddr;\ + _inaddr.s_addr=*_addrlist[i];\ + OsclNetworkAddress addr(inet_ntoa(_inaddr), 0);\ + dottedaddrvect->push_back(addr);\ + }\ + if (!dottedaddrvect->empty())\ + {dottedaddr->port = dottedaddrvect->front().port; dottedaddr->ipAddr.Set(dottedaddrvect->front().ipAddr.Str());}\ + ok=(!dottedaddrvect->empty() && (((*dottedaddrvect)[0]).ipAddr.Str() != NULL));\ + }\ + else\ + {\ + char *add;\ + OsclGetDottedAddr(hostent,add,ok);\ + if(ok) dottedaddr->ipAddr.Set(add);\ + } + +//socket shutdown codes +#define OSCL_SD_RECEIVE SHUT_RD +#define OSCL_SD_SEND SHUT_WR +#define OSCL_SD_BOTH SHUT_RDWR + +//address family codes +#define OSCL_AF_INET AF_INET + +//socket type codes +#define OSCL_SOCK_STREAM SOCK_STREAM +#define OSCL_SOCK_DATAGRAM SOCK_DGRAM + +//IP protocol codes +#define OSCL_IPPROTO_IP IPPROTO_IP +#define OSCL_IPPROTO_TCP IPPROTO_TCP +#define OSCL_IPPROTO_UDP IPPROTO_UDP + +//Socket option Levels +#define OSCL_SOL_SOCKET SOL_SOCKET +#define OSCL_SOL_IP IPPROTO_IP +#define OSCL_SOL_TCP IPPROTO_TCP +#define OSCL_SOL_UDP IPPROTO_UDP + +//Socket Option Values (level = IP) +#define OSCL_SOCKOPT_IP_MULTICAST_TTL IP_MULTICAST_TTL +#define OSCL_SOCKOPT_IP_ADDMEMBERSHIP IP_ADD_MEMBERSHIP +#define OSCL_SOCKOPT_IP_TOS IP_TOS + +//Socket Option Values (level = Socket) +#define OSCL_SOCKOPT_SOL_REUSEADDR SO_REUSEADDR +//End sockets + +// file IO support +#if (OSCL_HAS_LARGE_FILE_SUPPORT) +typedef off64_t TOsclFileOffset; +#define MAX_TOSCLFILEOFFSET_VALUE 0x7FFFFFFFFFFFFFFFLL; +#else +typedef int32 TOsclFileOffset; +#define MAX_TOSCLFILEOFFSET_VALUE 0x7FFFFFFF; +#endif + +#include "osclconfig_io_check.h" + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_lib.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_lib.h new file mode 100644 index 0000000..ee71a6a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_lib.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ L I B ( P L A T F O R M C O N F I G I N F O ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_lib.h + \brief This file contains configuration information for the ANSI build. + +*/ + +#ifndef OSCLCONFIG_LIB_H_INCLUDED +#define OSCLCONFIG_LIB_H_INCLUDED + + + +//Set this to 1 to indicate this platform has oscllib support +#define OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT 1 +#define PV_RUNTIME_LIB_FILENAME_EXTENSION "so" + +//Set this to 1 to enable looking for debug versions of libraries. +//Use #ifndef to allow the compiler setting to override this definition +#ifndef OSCL_LIB_READ_DEBUG_LIBS +#if (OSCL_RELEASE_BUILD) +#define OSCL_LIB_READ_DEBUG_LIBS 0 +#else +#define OSCL_LIB_READ_DEBUG_LIBS 1 +#endif +#endif + +// The path recursively from which the config files are picked up +#ifndef PV_DYNAMIC_LOADING_CONFIG_FILE_PATH +#ifdef ANDROID +#define PV_DYNAMIC_LOADING_CONFIG_FILE_PATH "/system/etc" +#else +#define PV_DYNAMIC_LOADING_CONFIG_FILE_PATH "./" +#endif +#endif + +// check all osclconfig required macros are defined +#include "osclconfig_lib_check.h" + +#endif // OSCLCONFIG_LIB_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_memory.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_memory.h new file mode 100644 index 0000000..b5c69d0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_memory.h @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ M E M O R Y + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + + + +#ifndef OSCLCONFIG_MEMORY_H_INCLUDED +#define OSCLCONFIG_MEMORY_H_INCLUDED + + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#ifndef OSCLCONFIG_ANSI_MEMORY_H_INCLUDED +#include "osclconfig_ansi_memory.h" +#endif + +/* OSCL_HAS_GLOBAL_NEW_DELETE - Enables or disables the definition of overloaded + * global memory operators in oscl_mem.h + * + * Release Mode: OSCL_HAS_GLOBAL_NEW_DELETE 0 + * Debug Mode: OSCL_HAS_GLOBAL_NEW_DELETE 1 + */ + + +#if (OSCL_RELEASE_BUILD) +#define OSCL_BYPASS_MEMMGT 1 +#define OSCL_HAS_GLOBAL_NEW_DELETE 0 +#else +#define OSCL_BYPASS_MEMMGT 1 //Temporarily disabling +#define OSCL_HAS_GLOBAL_NEW_DELETE 1 +#endif + +/* PVMEM_INST_LEVEL - Memory leak instrumentation level enables the compilation + * of detailed memory leak info (filename + line number). + * PVMEM_INST_LEVEL 0: Release mode. + * PVMEM_INST_LEVEL 1: Debug mode. + */ + +#if(OSCL_RELEASE_BUILD) +#define PVMEM_INST_LEVEL 0 +#else +#define PVMEM_INST_LEVEL 1 +#endif + +#if(OSCL_HAS_GLOBAL_NEW_DELETE) +//Detect if or is included anyplace to avoid a compile error. +#if defined(_INC_NEW) +#error Duplicate New Definition! +#endif //_INC_NEW +#if defined(_NEW_) +#error Duplicate New Definition! +#endif //_NEW_ +#endif //OSCL_HAS_GLOBAL_NEW_DELETE + +#ifdef __cplusplus +#include //for placement new +#endif //__cplusplus + +//OSCL_HAS_HEAP_BASE_SUPPORT - Enables or disables overloaded memory operators in HeapBase class +#define OSCL_HAS_HEAP_BASE_SUPPORT 1 + +#define OSCL_HAS_SYMBIAN_MEMORY_FUNCS 0 + + +#include "osclconfig_memory_check.h" + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_proc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_proc.h new file mode 100644 index 0000000..9f43965 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_proc.h @@ -0,0 +1,43 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ P R O C ( P L A T F O R M C O N F I G I N F O ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_proc.h + * \brief This file contains configuration information for the linux platform + * + */ + +#ifndef OSCLCONFIG_PROC_H_INCLUDED +#define OSCLCONFIG_PROC_H_INCLUDED + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#include "osclconfig_proc_unix_android.h" + +#include "osclconfig_proc_check.h" + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_proc_unix_android.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_proc_unix_android.h new file mode 100644 index 0000000..c5d05eb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_proc_unix_android.h @@ -0,0 +1,60 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ P R O C ( P L A T F O R M C O N F I G I N F O ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_proc.h + * \brief This file contains configuration information for the linux platform + * + */ + +#ifndef OSCLCONFIG_PROC_UNIX_ANDROID_H_INCLUDED +#define OSCLCONFIG_PROC_UNIX_ANDROID_H_INCLUDED + +#define OSCL_HAS_SYMBIAN_SCHEDULER 0 + +#define OSCL_HAS_THREAD_SUPPORT 1 +#define OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT 0 + +//semaphore with advanced realtime features incl. timed wait. +#define OSCL_HAS_SEM_TIMEDWAIT_SUPPORT 0 +//#include +//#include + +//pthreads +#define OSCL_HAS_PTHREAD_SUPPORT 1 +#include +#include +#include + +// threads, mutex, semaphores +typedef pthread_t TOsclThreadId; +typedef void* TOsclThreadFuncArg; +typedef void* TOsclThreadFuncRet; +#define OSCL_THREAD_DECL +typedef pthread_t TOsclThreadObject; +typedef pthread_mutex_t TOsclMutexObject; +typedef int TOsclSemaphoreObject; +typedef pthread_cond_t TOsclConditionObject; + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_time.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_time.h new file mode 100644 index 0000000..cb53659 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_time.h @@ -0,0 +1,50 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ T I M E ( T I M E - D E F I N I T I O N S ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + + + +#ifndef OSCLCONFIG_TIME_H_INCLUDED +#define OSCLCONFIG_TIME_H_INCLUDED + + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +// system header files +#include // timeval +#include // timercmp +#include + + + +#define OSCL_HAS_UNIX_TIME_FUNCS 1 + +typedef struct timeval OsclBasicTimeStruct; +typedef tm OsclBasicDateTimeStruct; + +#include "osclconfig_time_check.h" + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_unix_android.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_unix_android.h new file mode 100644 index 0000000..f4508ac --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_unix_android.h @@ -0,0 +1,105 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ U N I X _ C O M M O N + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_limits_typedefs.h + * \brief This file contains common typedefs based on the ANSI C limits.h header + * + * This header file should work for any ANSI C compiler to determine the + * proper native C types to use for OSCL integer types. + */ + + +#ifndef OSCLCONFIG_UNIX_ANDROID_H_INCLUDED +#define OSCLCONFIG_UNIX_ANDROID_H_INCLUDED + + +// system header files +#include // abort +#include // va_list +#include +#include +//#include +#include +#include //for sleep +#include +#include // for tolower and toupper +#ifdef __cplusplus +#include //for placement new +#endif +#include + +#define OSCL_DISABLE_INLINES 0 + +#define OSCL_HAS_ANSI_STDLIB_SUPPORT 1 +#define OSCL_HAS_ANSI_MATH_SUPPORT 1 +#define OSCL_HAS_GLOBAL_VARIABLE_SUPPORT 1 +#define OSCL_HAS_ANSI_STRING_SUPPORT 1 +#define OSCL_HAS_ANSI_WIDE_STRING_SUPPORT 0 +#define OSCL_HAS_ANSI_STDIO_SUPPORT 1 + +#define OSCL_MEMFRAG_PTR_BEFORE_LEN 1 + +#define OSCL_HAS_UNIX_SUPPORT 1 +#define OSCL_HAS_MSWIN_SUPPORT 0 +#define OSCL_HAS_MSWIN_PARTIAL_SUPPORT 0 +#define OSCL_HAS_SYMBIAN_SUPPORT 0 +#define OSCL_HAS_IPHONE_SUPPORT 0 + + +// 64-bit int +#define OSCL_NATIVE_INT64_TYPE int64_t +#define OSCL_NATIVE_UINT64_TYPE uint64_t +#define INT64(x) x##LL +#define UINT64(x) x##ULL +#define INT64_HILO(high,low) ((((high##LL))<<32)|low) +#define UINT64_HILO(high,low) ((((high##ULL))<<32)|low) + +// character set. +#define OSCL_HAS_UNICODE_SUPPORT 1 +#define OSCL_NATIVE_WCHAR_TYPE wchar_t +#if (OSCL_HAS_UNICODE_SUPPORT) +#define _STRLIT(x) L ## x +#else +#define _STRLIT(x) x +#endif +#define _STRLIT_CHAR(x) x +#define _STRLIT_WCHAR(x) L ## x + +// Thread-local storage. Unix has keyed TLS. +#define OSCL_HAS_TLS_SUPPORT 1 +#define OSCL_TLS_IS_KEYED 1 +typedef pthread_key_t TOsclTlsKey ; +#define OSCL_TLS_KEY_CREATE_FUNC(key) (pthread_key_create(&key,NULL)==0) +#define OSCL_TLS_KEY_DELETE_FUNC(key) pthread_key_delete(key) +#define OSCL_TLS_STORE_FUNC(key,ptr) (pthread_setspecific(key,(const void*)ptr)==0) +#define OSCL_TLS_GET_FUNC(key) pthread_getspecific(key) + +//Basic lock +#define OSCL_HAS_BASIC_LOCK 1 +#include +typedef pthread_mutex_t TOsclBasicLockObject; + +#endif // OSCLCONFIG_UNIX_COMMON_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_util.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_util.h new file mode 100644 index 0000000..21fbb84 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/android/osclconfig_util.h @@ -0,0 +1,46 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCLCONFIG_UTIL_H_INCLUDED +#define OSCLCONFIG_UTIL_H_INCLUDED + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#include //sprintf +#include // OSCL clock +#include // timeval + +#define OSCL_CLOCK_HAS_DRIFT_CORRECTION 0 +#define OSCL_HAS_SYMBIAN_TIMERS 0 +#define OSCL_HAS_SYMBIAN_MATH 0 + +#define OSCL_RAND_MAX RAND_MAX + +#define OSCL_HAS_SNPRINTF_LONGLONG_SUPPORT 1 + + +//Define system sleep call for the tick count test here. +#include +#define SLEEP_ONE_SEC sleep(1) + + +#include "osclconfig_util_check.h" + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig.h new file mode 100644 index 0000000..31c4388 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G ( P L A T F O R M C O N F I G I N F O ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig.h + * \brief This file contains configuration information for the linux platform + * + */ + +#ifndef OSCLCONFIG_H_INCLUDED +#define OSCLCONFIG_H_INCLUDED + +// system includes for dynamic registry +#include +#include +#include +#include + +// include common include for determining sizes from limits.h +#include "osclconfig_limits_typedefs.h" + +//This switch turns off some profiling and debug settings +#ifndef OSCL_RELEASE_BUILD +#ifdef NDEBUG +#define OSCL_RELEASE_BUILD 1 +#else +#define OSCL_RELEASE_BUILD 0 +#endif +#endif + +#define OSCL_HAS_ANDROID_SUPPORT 0 +#define OSCL_HAS_IPHONE_SUPPORT 0 + +// include common unix definitions +#include "osclconfig_unix_common.h" + +// define the suffix for unsigned constants +#define OSCL_UNSIGNED_CONST(x) x##u + +// override the common definition for +#undef OSCL_NATIVE_UINT64_TYPE +#define OSCL_NATIVE_UINT64_TYPE u_int64_t + +// include the definitions for the processor +#include "osclconfig_ix86.h" + +/* The __TFS__ macro is used to optionally expand to "<>" depending on the + * compiler. Some compilers require it to indicate that the friend function + * is a template function as specified in the standard, but others don't + * like it so it will handled with a macro expansion that depends on the + * compiler. + */ +#define __TFS__ <> + +#ifdef __GNUC__ +#if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)) +#define OSCL_TEMPLATED_DESTRUCTOR_CALL(type,simple_type) ~type () +#endif +#endif + +#define OSCL_HAS_PRAGMA_PACK 0 +#define OSCL_HAS_PACKED_STRUCT 1 +#define OSCL_PACKED_VAR(x) x __attribute__((packed)) +#define OSCL_PACKED_STRUCT_BEGIN +#define OSCL_PACKED_STRUCT_END __attribute__((packed)) + +#if (OSCL_RELEASE_BUILD) +#define PVLOGGER_INST_LEVEL 1 +#else +//full logging +#define PVLOGGER_INST_LEVEL 5 +#endif + +//set this to 1 to enable OSCL_ASSERT in release builds. +#define OSCL_ASSERT_ALWAYS 0 + + +// check all osclconfig required macros are defined +#include "osclconfig_check.h" + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_compiler_warnings.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_compiler_warnings.h new file mode 100644 index 0000000..563346b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_compiler_warnings.h @@ -0,0 +1,32 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ C O M P I L E R _ W A R N I N G S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_compiler_warnings.h + * \brief This file contains the ability to turn off/on compiler warnings + * + */ + +#define OSCL_FUNCTION_PTR(x) (&x) + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_error.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_error.h new file mode 100644 index 0000000..6cdf86c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_error.h @@ -0,0 +1,53 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ E R R O R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_error.h + * \brief This file contains the common typedefs and header files needed to compile osclerror + * + */ + + +#ifndef OSCLCONFIG_ERROR_H_INCLUDED +#define OSCLCONFIG_ERROR_H_INCLUDED + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#define OSCL_HAS_EXCEPTIONS 1 +#define OSCL_HAS_ERRNO_H 1 +#define OSCL_HAS_SYMBIAN_ERRORTRAP 0 +#define OSCL_HAS_SETJMP_H 1 + +// system header files +#include +#include + + +// confirm that all definitions have been defined +#include "osclconfig_error_check.h" + +#endif // OSCLCONFIG_ERROR_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_io.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_io.h new file mode 100644 index 0000000..842d51c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_io.h @@ -0,0 +1,300 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ I O + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_io.h + * \brief This file contains common typedefs based on the ANSI C limits.h header + * + * This header file should work for any ANSI C compiler to determine the + * proper native C types to use for OSCL integer types. + */ + + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#define OSCLCONFIG_IO_H_INCLUDED + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//For File I/O +#define OSCL_HAS_GLOB 1 +#define OSCL_HAS_MSWIN_FILE_IO_SUPPORT 0 +#define OSCL_HAS_ANSI_64BIT_FILE_IO_SUPPORT 0 +#define OSCL_HAS_ANSI_FILE_IO_SUPPORT 1 +#define OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION 0 +#define OSCL_HAS_NATIVE_FILE_CACHE_ENABLE 1 +#define OSCL_FILE_BUFFER_MAX_SIZE 32768 +#define OSCL_HAS_PV_FILE_CACHE 1 +#define OSCL_HAS_LARGE_FILE_SUPPORT 1 + +//For Sockets +#define OSCL_HAS_SYMBIAN_SOCKET_SERVER 0 +#define OSCL_HAS_SYMBIAN_DNS_SERVER 0 +#define OSCL_HAS_BERKELEY_SOCKETS 1 +#define OSCL_HAS_SOCKET_SUPPORT 1 +#define OSCL_HAS_SELECTABLE_PIPES 1 + +//basic socket types +typedef int TOsclSocket; +typedef struct sockaddr_in TOsclSockAddr; +typedef socklen_t TOsclSockAddrLen; +typedef struct ip_mreq TIpMReq; + +//Init addr macro +#define OsclValidInetAddr(addr) (inet_addr(addr)!=((in_addr_t)(-1))) + +//address conversion macro-- from string to network address. +#define OsclMakeSockAddr(sockaddr,port,addrstr,ok)\ + sockaddr.sin_family=OSCL_AF_INET;\ + sockaddr.sin_port=htons(port);\ + int32 result=inet_aton((const char*)addrstr,&sockaddr.sin_addr);\ + ok=(result!=0); + +//address conversion macro-- from network address to string +#define OsclUnMakeSockAddr(sockaddr,addrstr)\ + addrstr=inet_ntoa(sockaddr.sin_addr); + +//address conversion macro-- from string to inaddr +#define OsclMakeInAddr(in_addr,addrstr,ok)\ + int32 result = inet_aton((const char*)addrstr, &in_addr);\ + ok=(result!=0); + +//address conversion macro-- from inaddr to string +#define OsclUnMakeInAddr(in_addr,addrstr)\ + addrstr=inet_ntoa(in_addr); + +//wrappers for berkeley socket calls +#define OsclSetRecvBufferSize(s,val,ok,err) \ + ok=(setsockopt(s,SOL_SOCKET,SO_RCVBUF,(char*)&val, sizeof(int)) !=-1);\ + if (!ok)err=errno + +#define OsclBind(s,addr,ok,err)\ + TOsclSockAddr* tmpadr = &addr;\ + sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\ + ok=(bind(s,sadr,sizeof(addr))!=(-1));\ + if (!ok)err=errno + +#define OsclSetSockOpt(s,optLevel,optName,optVal,optLen,ok,err)\ + ok=(setsockopt(s,optLevel,optName,OSCL_STATIC_CAST(const char*,optVal),optLen) != (-1));\ + if (!ok)err=errno + +#define OsclJoin(s,addr,ok,err)\ + struct ip_mreq mreq; \ + ok=(bind(s,(sockaddr*)&addr,sizeof(addr))!=(-1));\ + mreq.imr_multiaddr.s_addr = addr.sin_addr.s_addr ; \ + mreq.imr_interface.s_addr = htonl(INADDR_ANY); \ + ok=(setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(struct ip_mreq))!=(-1)); \ + if (!ok)err=errno + +#define OsclListen(s,size,ok,err)\ + ok=(listen(iSocket,qSize)!=(-1));\ + if (!ok)err=errno + +#define OsclAccept(s,accept_s,ok,err,wouldblock)\ + accept_s=accept(s,NULL,NULL);\ + ok=(accept_s!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);} + +#define OsclSetNonBlocking(s,ok,err)\ + ok=(fcntl(s,F_SETFL,O_NONBLOCK)!=(-1));\ + if (!ok)err=errno + +#define OsclShutdown(s,how,ok,err)\ + ok=(shutdown(iSocket,how)!=(-1));\ + if (!ok)err=errno + +#define OsclSocket(s,fam,type,prot,ok,err)\ + s=socket(fam,type,prot);\ + ok=(s!=(-1));\ + if (!ok)err=errno + +#define OsclSendTo(s,buf,len,addr,ok,err,nbytes,wouldblock)\ + TOsclSockAddr* tmpadr = &addr;\ + sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\ + nbytes=sendto(s,buf,(size_t)(len),0,sadr,(socklen_t)sizeof(addr));\ + ok=(nbytes!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);} + +#define OsclSend(s,buf,len,ok,err,nbytes,wouldblock)\ + nbytes=send(s,(const void*)(buf),(size_t)(len),0);\ + ok=(nbytes!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);} + +#define OsclCloseSocket(s,ok,err)\ + ok=(close(s)!=(-1));\ + if (!ok)err=errno + +#define OsclConnect(s,addr,ok,err,wouldblock)\ + TOsclSockAddr* tmpadr = &addr;\ + sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\ + ok=(connect(s,sadr,sizeof(addr))!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EINPROGRESS);} +#define OsclGetPeerName(s,name,namelen,ok,err)\ + ok=(getpeername(s,(sockaddr*)&name,(socklen_t*)&namelen) != (-1) );\ + if (!ok)err=errno + +#define OsclGetAsyncSockErr(s,ok,err)\ + int opterr;socklen_t optlen=sizeof(opterr);\ + ok=(getsockopt(s,SOL_SOCKET,SO_ERROR,(void *)&opterr,&optlen)!=(-1));\ + if(ok)err=opterr;else err=errno; + +#define OsclPipe(x) pipe(x) +#define OsclReadFD(fd,buf,cnt) read(fd,buf,cnt) +#define OsclWriteFD(fd,buf,cnt) write(fd,buf,cnt) + +//unix reports connect completion in write set in the getsockopt +//error. +#define OsclConnectComplete(s,wset,eset,success,fail,ok,err)\ + success=fail=false;\ + if (FD_ISSET(s,&eset))\ + {fail=true;OsclGetAsyncSockErr(s,ok,err);}\ + else if (FD_ISSET(s,&wset))\ + {OsclGetAsyncSockErr(s,ok,err);if (ok && err==0)success=true;else fail=true;} + +#define OsclRecv(s,buf,len,ok,err,nbytes,wouldblock)\ + nbytes=recv(s,(void *)(buf),(size_t)(len),0);\ + ok=(nbytes!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EAGAIN);} + +#define OsclRecvFrom(s,buf,len,paddr,paddrlen,ok,err,nbytes,wouldblock)\ + nbytes=recvfrom(s,(void*)(buf),(size_t)(len),0,(struct sockaddr*)paddr,paddrlen);\ + ok=(nbytes!=(-1));\ + if (!ok){err=errno;wouldblock=(err==EAGAIN);} + +#define OsclSocketSelect(nfds,rd,wr,ex,timeout,ok,err,nhandles)\ + nhandles=select(nfds,&rd,&wr,&ex,&timeout);\ + ok=(nhandles!=(-1));\ + if (!ok)err=errno + +//there's not really any socket startup needed on unix, but +//you need to define a signal handler for SIGPIPE to avoid +//broken pipe crashes. +#define OsclSocketStartup(ok)\ + signal(SIGPIPE,SIG_IGN);\ + ok=true + +#define OsclSocketCleanup(ok)\ + signal(SIGPIPE,SIG_DFL);\ + ok=true + +//hostent type +typedef struct hostent TOsclHostent; + +//wrapper for gethostbyname +#define OsclGethostbyname(name,hostent,ok,err)\ + hostent=gethostbyname((const char*)name);\ + ok=(hostent!=NULL);\ + if (!ok)err=errno; + +//extract dotted address from a hostent +#define OsclGetDottedAddr(hostent,dottedaddr,ok)\ + long *_hostaddr=(long*)hostent->h_addr_list[0];\ + struct in_addr _inaddr;\ + _inaddr.s_addr=*_hostaddr;\ + dottedaddr=inet_ntoa(_inaddr);\ + ok=(dottedaddr!=NULL); + +//extract dotted address from a hostent into the vector of OsclNetworkAddress +#define OsclGetDottedAddrVector(hostent,dottedaddr,dottedaddrvect,ok)\ + if(dottedaddrvect)\ + {\ + long **_addrlist=(long**)hostent->h_addr_list;\ + for(int i = 0; _addrlist[i] != NULL; i++){\ + struct in_addr _inaddr;\ + _inaddr.s_addr=*_addrlist[i];\ + OsclNetworkAddress addr(inet_ntoa(_inaddr), 0);\ + dottedaddrvect->push_back(addr);\ + }\ + if (!dottedaddrvect->empty())\ + {dottedaddr->port = dottedaddrvect->front().port; dottedaddr->ipAddr.Set(dottedaddrvect->front().ipAddr.Str());}\ + ok=(!dottedaddrvect->empty() && (((*dottedaddrvect)[0]).ipAddr.Str() != NULL));\ + }\ + else\ + {\ + char *add;\ + OsclGetDottedAddr(hostent,add,ok);\ + if(ok) dottedaddr->ipAddr.Set(add);\ + } + +//socket shutdown codes +#define OSCL_SD_RECEIVE SHUT_RD +#define OSCL_SD_SEND SHUT_WR +#define OSCL_SD_BOTH SHUT_RDWR + +//address family codes +#define OSCL_AF_INET AF_INET + +//socket type codes +#define OSCL_SOCK_STREAM SOCK_STREAM +#define OSCL_SOCK_DATAGRAM SOCK_DGRAM + +//IP protocol codes +#define OSCL_IPPROTO_IP IPPROTO_IP +#define OSCL_IPPROTO_TCP IPPROTO_TCP +#define OSCL_IPPROTO_UDP IPPROTO_UDP + +//Socket option Levels +#define OSCL_SOL_SOCKET SOL_SOCKET +#define OSCL_SOL_IP IPPROTO_IP +#define OSCL_SOL_TCP IPPROTO_TCP +#define OSCL_SOL_UDP IPPROTO_UDP + +//Socket Option Values (level = IP) +#define OSCL_SOCKOPT_IP_MULTICAST_TTL IP_MULTICAST_TTL +#define OSCL_SOCKOPT_IP_ADDMEMBERSHIP IP_ADD_MEMBERSHIP +#define OSCL_SOCKOPT_IP_TOS IP_TOS + +//Socket Option Values (level = Socket) +#define OSCL_SOCKOPT_SOL_REUSEADDR SO_REUSEADDR +//End sockets + +// file IO support +#if (OSCL_HAS_LARGE_FILE_SUPPORT) +typedef off64_t TOsclFileOffset; +#define MAX_TOSCLFILEOFFSET_VALUE 0x7FFFFFFFFFFFFFFFLL; +#else +typedef int32 TOsclFileOffset; +#define MAX_TOSCLFILEOFFSET_VALUE 0x7FFFFFFF; +#endif + + +#include "osclconfig_io_check.h" + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_lib.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_lib.h new file mode 100644 index 0000000..854def8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_lib.h @@ -0,0 +1,58 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ L I B ( P L A T F O R M C O N F I G I N F O ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_lib.h + \brief This file contains configuration information for the ANSI build. + +*/ + +#ifndef OSCLCONFIG_LIB_H_INCLUDED +#define OSCLCONFIG_LIB_H_INCLUDED + + +//Set this to 1 to indicate this platform has oscllib support +#define OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT 1 +#define PV_RUNTIME_LIB_FILENAME_EXTENSION "so" + +//Set this to 1 to enable looking for debug versions of libraries. +//Use #ifndef to allow the compiler setting to override this definition +#ifndef OSCL_LIB_READ_DEBUG_LIBS +#if (OSCL_RELEASE_BUILD) +#define OSCL_LIB_READ_DEBUG_LIBS 0 +#else +#define OSCL_LIB_READ_DEBUG_LIBS 1 +#endif +#endif + +// The path recursively from which the config files are picked up +#ifndef PV_DYNAMIC_LOADING_CONFIG_FILE_PATH +#define PV_DYNAMIC_LOADING_CONFIG_FILE_PATH "./" +#endif + +// check all osclconfig required macros are defined +#include "osclconfig_lib_check.h" + +#endif // OSCLCONFIG_LIB_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_memory.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_memory.h new file mode 100644 index 0000000..3ee7407 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_memory.h @@ -0,0 +1,90 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ M E M O R Y + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + + + +#ifndef OSCLCONFIG_MEMORY_H_INCLUDED +#define OSCLCONFIG_MEMORY_H_INCLUDED + + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#ifndef OSCLCONFIG_ANSI_MEMORY_H_INCLUDED +#include "osclconfig_ansi_memory.h" +#endif + +/* PVMEM_INST_LEVEL - Memory leak instrumentation level enables the compilation + * of detailed memory leak info (filename + line number). + * PVMEM_INST_LEVEL 0: Release mode. + * PVMEM_INST_LEVEL 1: Debug mode. + */ + +/* OSCL_HAS_GLOBAL_NEW_DELETE - Enables or disables the definition of overloaded + * global memory operators in oscl_mem.h + * + * Release Mode: OSCL_HAS_GLOBAL_NEW_DELETE 0 + * Debug Mode: OSCL_HAS_GLOBAL_NEW_DELETE 1 + */ + +#if(OSCL_HAS_GLOBAL_NEW_DELETE) +//Detect if or is included anyplace to avoid a compile error. +#if defined(_INC_NEW) +#error Duplicate New Definition! +#endif //_INC_NEW +#if defined(_NEW_) +#error Duplicate New Definition! +#endif //_NEW_ +#endif //OSCL_HAS_GLOBAL_NEW_DELETE + +#ifdef __cplusplus +#include //for placement new +#endif //__cplusplus + +//OSCL_HAS_HEAP_BASE_SUPPORT - Enables or disables overloaded memory operators in HeapBase class +#define OSCL_HAS_HEAP_BASE_SUPPORT 1 + + +#define OSCL_HAS_SYMBIAN_MEMORY_FUNCS 0 + + +// OSCL_BYPASS_MEMMGT - by default turn off for release build and on for debug +// OSCL_HAS_GLOBAL_NEW_DELETE - Enables or disables the definition of overloaded +// global memory operators in oscl_mem.h +#if (OSCL_RELEASE_BUILD) +#define OSCL_BYPASS_MEMMGT 1 +#define OSCL_HAS_GLOBAL_NEW_DELETE 0 +#define PVMEM_INST_LEVEL 0 +#else +#define OSCL_BYPASS_MEMMGT 0 +#define OSCL_HAS_GLOBAL_NEW_DELETE 1 +#define PVMEM_INST_LEVEL 1 +#endif + +#include "osclconfig_memory_check.h" + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_proc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_proc.h new file mode 100644 index 0000000..87a5bdb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_proc.h @@ -0,0 +1,43 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ P R O C ( P L A T F O R M C O N F I G I N F O ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_proc.h + * \brief This file contains configuration information for the linux platform + * + */ + +#ifndef OSCLCONFIG_PROC_H_INCLUDED +#define OSCLCONFIG_PROC_H_INCLUDED + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#include "osclconfig_proc_unix_common.h" + +#include "osclconfig_proc_check.h" + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_time.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_time.h new file mode 100644 index 0000000..cb53659 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_time.h @@ -0,0 +1,50 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ T I M E ( T I M E - D E F I N I T I O N S ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + + + +#ifndef OSCLCONFIG_TIME_H_INCLUDED +#define OSCLCONFIG_TIME_H_INCLUDED + + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +// system header files +#include // timeval +#include // timercmp +#include + + + +#define OSCL_HAS_UNIX_TIME_FUNCS 1 + +typedef struct timeval OsclBasicTimeStruct; +typedef tm OsclBasicDateTimeStruct; + +#include "osclconfig_time_check.h" + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_util.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_util.h new file mode 100644 index 0000000..8b7eee0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/linux/osclconfig_util.h @@ -0,0 +1,46 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCLCONFIG_UTIL_H_INCLUDED +#define OSCLCONFIG_UTIL_H_INCLUDED + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#include //sprintf +#include // OSCL clock +#include // timeval + +#define OSCL_CLOCK_HAS_DRIFT_CORRECTION 0 +#define OSCL_HAS_SYMBIAN_TIMERS 0 +#define OSCL_HAS_SYMBIAN_MATH 0 + +#define OSCL_RAND_MAX RAND_MAX + +//Define system sleep call for the tick count test here. +#include +#define SLEEP_ONE_SEC sleep(1) + +#define OSCL_HAS_SNPRINTF_LONGLONG_SUPPORT 1 + + + +#include "osclconfig_util_check.h" + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_ansi_memory.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_ansi_memory.h new file mode 100644 index 0000000..fb53ea1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_ansi_memory.h @@ -0,0 +1,42 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ A N S I _ M E M O R Y + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_ansi_memory.h + * \brief This file contains common typedefs based on the ANSI C limits.h header + * + * This header file should work for any ANSI C compiler to determine the + * proper native C types to use for OSCL integer types. + */ + + +#ifndef OSCLCONFIG_ANSI_MEMORY_H_INCLUDED +#define OSCLCONFIG_ANSI_MEMORY_H_INCLUDED + +#include +typedef size_t oscl_memsize_t; +#define OSCL_HAS_ANSI_MEMORY_FUNCS 1 + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_check.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_check.h new file mode 100644 index 0000000..19d0b63 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_check.h @@ -0,0 +1,423 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCLCONFIG_CHECK_H_INCLUDED +#define OSCLCONFIG_CHECK_H_INCLUDED + +/*! \addtogroup osclconfig OSCL config + * + * @{ + */ + +/** +\def Make sure the basic types are defined, +either in osclconfig_limits_typedefs.h or elsewhere. +*/ +typedef int8 __int8__check__; +typedef uint8 __uint8__check__; +typedef int16 __int16__check__; +typedef uint16 __uint16__check__; +typedef int32 __int32__check__; +typedef uint32 __uint32__check__; + +/** +\def OSCL_ASSERT_ALWAYS macro should be set to 0 or 1. +When set to 1, OSCL_ASSERT will be compiled in release mode as well +as debug mode. +*/ +#ifndef OSCL_ASSERT_ALWAYS +#error "ERROR: OSCL_ASSERT_ALWAYS has to be defined to either 1 or 0." +#endif + + +/** +\def OSCL_DISABLE_INLINES macro should be set to 1 if +the target compiler supports 'inline' function definitions. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_DISABLE_INLINES +#error "ERROR: OSCL_DISABLE_INLINES has to be defined to either 1 or 0." +#endif + +/** +\def OSCL_HAS_ANSI_STDLIB_SUPPORT macro should be set to 1 if +the target compiler supports ANSI C standard lib functions. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_ANSI_STDLIB_SUPPORT +#error "ERROR: OSCL_HAS_ANSI_STDLIB_SUPPORT has to be defined to either 1 or 0." +#endif + +/** +\def OSCL_HAS_ANSI_STDIO_SUPPORT macro should be set to 1 if +the target compiler supports ANSI C standard I/O functions. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_ANSI_STDIO_SUPPORT +#error "ERROR: OSCL_HAS_ANSI_STDIO_SUPPORT has to be defined to either 1 or 0." +#endif + +/** +\def OSCL_HAS_ANSI_STRING_SUPPORT macro should be set to 1 if +the target compiler supports ANSI C standard string functions. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_ANSI_STRING_SUPPORT +#error "ERROR: OSCL_HAS_ANSI_STRING_SUPPORT has to be defined to either 1 or 0." +#endif + +/** +\def OSCL_HAS_UNICODE_SUPPORT macro should be set to 1 if +the target platform has a native 16-bit (wide) character type. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_UNICODE_SUPPORT +#error "ERROR: OSCL_HAS_UNICODE_SUPPORT has to be defined to either 1 or 0." +#endif + +/** +\def _STRLIT macro should be set to an expression to convert +a constant character string into a string literal type +appropriate for the platform. +Otherwise it should be set to 0. +*/ +#ifndef _STRLIT +#error "ERROR: _STRLIT has to be defined." +#endif + +/** +\def _STRLIT_CHAR macro should be set to an expression to convert +a constant character string into a char string literal type +appropriate for the platform. +Otherwise it should be set to 0. +*/ +#ifndef _STRLIT_CHAR +#error "ERROR: _STRLIT_CHAR has to be defined." +#endif + +/** +When OSCL_HAS_UNICODE_SUPPORT==1, +\def _STRLIT_WCHAR macro should be set to an expression to convert +a constant character string into a wchar string literal type +appropriate for the platform. +Otherwise it should be set to 0. +*/ +#if (OSCL_HAS_UNICODE_SUPPORT) && !defined(_STRLIT_WCHAR) +#error "ERROR: _STRLIT_WCHAR has to be defined" +#endif + +/** +When OSCL_HAS_UNICODE_SUPPORT==1, +\def OSCL_NATIVE_WCHAR_TYPE macro should be set to +the native wide character type for the platform. +Otherwise it should be set to 0. +*/ +#if (OSCL_HAS_UNICODE_SUPPORT) && !defined(OSCL_NATIVE_WCHAR_TYPE) +#error "ERROR: OSCL_NATIVE_WCHAR_TYPE has to be defined." +#endif + +/** +\def OSCL_HAS_MSWIN_SUPPORT macro should be set to 1 if +the target platform supports the Win32 API. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_MSWIN_SUPPORT +#error "ERROR: OSCL_HAS_MSWIN_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +\def OSCL_HAS_MSWIN_PARTIAL_SUPPORT macro should be set to 1 if +the target platform supports the WinMobile API. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_MSWIN_PARTIAL_SUPPORT +#error "ERROR: OSCL_HAS_MSWIN_PARTIAL_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +\def OSCL_HAS_UNIX_SUPPORT macro should be set to 1 if +the target platform supports the Unix API. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_UNIX_SUPPORT +#error "ERROR: OSCL_HAS_UNIX_SUPPORT has to be defined to either 1 or 0." +#endif + +/** +\def OSCL_HAS_SYMBIAN_SUPPORT macro should be set to 1 if +the target platform supports the Symbian API. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SYMBIAN_SUPPORT +#error "ERROR: OSCL_HAS_SYMBIAN_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +\def OSCL_HAS_ANDROID_SUPPORT macro should be set to 1 if +the target platform supports the Android API. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_ANDROID_SUPPORT +#error "ERROR: OSCL_HAS_ANDROID_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +\def OSCL_HAS_IPHONE_SUPPORT macro should be set to 1 if +the target platform supports the iPhone API. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_IPHONE_SUPPORT +#error "ERROR: OSCL_HAS_IPHONE_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +\def OSCL_INTEGERS_WORD_ALIGNED macro should be set to 1 if +the target platform requires integers to be word-aligned in memory. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_INTEGERS_WORD_ALIGNED +#error "ERROR: OSCL_INTEGERS_WORD_ALIGNED has to be defined to either 1 or 0." +#endif + +/** +\def OSCL_BYTE_ORDER_BIG_ENDIAN macro should be set to 1 if +the target platform uses big-endian byte order in memory. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_BYTE_ORDER_BIG_ENDIAN +#error "ERROR: OSCL_BYTE_ORDER_BIG_ENDIAN has to be defined to either 1 or 0." +#endif + +/** +\def OSCL_BYTE_ORDER_LITTLE_ENDIAN macro should be set to 1 if +the target platform uses little-endian byte order in memory. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_BYTE_ORDER_LITTLE_ENDIAN +#error "ERROR: OSCL_BYTE_ORDER_LITTLE_ENDIAN has to be defined to either 1 or 0." +#endif + +/** +\def Either OSCL_BYTE_ORDER_BIG_ENDIAN must be set to 1 +or else OSCL_BYTE_ORDER_LITTLE_ENDIAN must be set to 1. +*/ +#if !(OSCL_BYTE_ORDER_BIG_ENDIAN) && !(OSCL_BYTE_ORDER_LITTLE_ENDIAN) +#error "ERROR: either OSCL_BYTE_ORDER_LITTLE_ENDIAN or else OSCL_BYTE_ORDER_BIG_ENDIAN must be 1." +#endif +#if (OSCL_BYTE_ORDER_BIG_ENDIAN) && (OSCL_BYTE_ORDER_LITTLE_ENDIAN) +#error "ERROR: either OSCL_BYTE_ORDER_LITTLE_ENDIAN or else OSCL_BYTE_ORDER_BIG_ENDIAN must be 1." +#endif + +/** +\def OSCL_HAS_GLOBAL_VARIABLE_SUPPORT macro should be set to 1 if +the target platform allows global variable definitions. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_GLOBAL_VARIABLE_SUPPORT +#error "ERROR: OSCL_HAS_GLOBAL_VARIABLE_SUPPORT has to be defined to either 1 or 0." +#endif + +/** +Note: only one byte order mode can be defined per platform. +*/ +#if (OSCL_BYTE_ORDER_LITTLE_ENDIAN) && (OSCL_BYTE_ORDER_BIG_ENDIAN) +#error "ERROR: Multiple selection for OSCL_BYTE_ORDER." +#endif + +/** +\def OSCL_HAS_ANSI_STRING_SUPPORT macro should be set to 1 if +the target platform supports C standard string functions (string.h). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_ANSI_STRING_SUPPORT +#error "ERROR: OSCL_HAS_ANSI_STRING_SUPPORT has to be defined to either 1 or 0." +#endif + +/** +\def OSCL_NATIVE_INT64_TYPE has to be defined to the native +signed 64-bit integer type. +*/ +#ifndef OSCL_NATIVE_INT64_TYPE +#error "ERROR: OSCL_NATIVE_INT64_TYPE has to be defined." +#endif + +/** +\def OSCL_NATIVE_UINT64_TYPE has to be defined to the native +unsigned 64-bit integer type. +*/ +#ifndef OSCL_NATIVE_UINT64_TYPE +#error "ERROR: OSCL_NATIVE_UINT64_TYPE has to be defined." +#endif + +/** +\def INT64(x) has to be defined to the expression for a signed +64-bit literal. +*/ +#ifndef INT64 +#error "ERROR: INT64(x) has to be defined." +#endif + +/** +\def UINT64(x) has to be defined to the expression for an unsigned +64-bit literal. +*/ +#ifndef UINT64 +#error "ERROR: UINT64(x) has to be defined." +#endif + +/** +\def INT64_HILO(high,low) has to be defined to an expression +to create a signed 64-bit integer from 2 32-bit integers. +*/ +#ifndef INT64_HILO +#error "ERROR: INT64_HILO(high,low) has to be defined." +#endif + +/** +\def UINT64_HILO(high,low) has to be defined to an expression +to create an unsigned 64-bit integer from 2 32-bit integers. +*/ +#ifndef UINT64_HILO +#error "ERROR: UINT64_HILO(high,low) has to be defined." +#endif + +/** +\def OSCL_MEMFRAG_PTR_BEFORE_LEN macro should be set to 1 if +memory fragements data structures, such as used by sendmsg +(i.e., the iovec data structures), should use ptr before length. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_MEMFRAG_PTR_BEFORE_LEN +#error "ERROR: OSCL_MEMFRAG_PTR_BEFORE_LEN has to be defined to either 0 or 1" +#endif + +/** +\def OSCL_HAS_TLS_SUPPORT macro should be set to 1 if +the target platform has thread-local storage functions. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_TLS_SUPPORT +#error "ERROR: OSCL_HAS_TLS_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +\def OSCL_TLS_IS_KEYED macro should be set to 1 if +the target platform's thread local storage function requires an +input key value to uniquely identify the TLS. +If the thread local storage function does not require any key, +or thread local storage is not supported, it should be set to 0. +*/ +#ifndef OSCL_TLS_IS_KEYED +#error "ERROR: OSCL_TLS_IS_KEYED has to be defined to either 1 or 0" +#endif + + +/** +When OSCL_TLS_IS_KEYED==1, +\def OSCL_TLS_STORE_FUNC macro must be set to an expression that will +set the TLS value and evalutes to true on success, false on failure. +The macro takes 2 input parameters (key, ptr). +*/ +#if (OSCL_TLS_IS_KEYED) && !defined(OSCL_TLS_STORE_FUNC) +#error "ERROR: OSCL_TLS_STORE_FUNC has to be defined" +#endif + +/** +When OSCL_TLS_IS_KEYED==1, +\def OSCL_TLS_GET_FUNC macro should be set to an expression that +returns the TLS value. +The macro takes 1 input parameter (key). +*/ +#if (OSCL_TLS_IS_KEYED) && !defined(OSCL_TLS_GET_FUNC) +#error "ERROR: OSCL_TLS_GET_FUNC has to be defined" +#endif + +/** +When OSCL_TLS_IS_KEYED==1, +\def OSCL_TLS_GET_FUNC macro should be set to an expression that +creates a TLS entry and evalutes to true on success, false on failure. +The macro takes 1 input parameter (key). +*/ +#if (OSCL_TLS_IS_KEYED) && !defined(OSCL_TLS_KEY_CREATE_FUNC) +#error "ERROR: OSCL_TLS_KEY_CREATE_FUNC has to be defined" +#endif + +/** +When OSCL_TLS_IS_KEYED==1, +\def OSCL_TLS_GET_FUNC macro should be set to an expression that +deletes a TLS entry. +The macro takes 1 input parameter (key). +*/ +#if (OSCL_TLS_IS_KEYED) && !defined(OSCL_TLS_KEY_DELETE_FUNC) +#error "ERROR: OSCL_TLS_KEY_DELETE_FUNC has to be defined" +#endif + + +/** +When OSCL_TLS_IS_KEYED==0, +\def OSCL_TLS_STORE_FUNC macro must be set to an expression that will +set the TLS value and evalutes to true on success, false on failure. +The macro takes 1 input parameter (ptr). +*/ +#if (OSCL_HAS_TLS_SUPPORT) && !(OSCL_TLS_IS_KEYED) && !defined(OSCL_TLS_STORE_FUNC) +#error "ERROR: OSCL_TLS_STORE_FUNC has to be defined" +#endif + +/** +When OSCL_TLS_IS_KEYED==0, +\def OSCL_TLS_GET_FUNC macro should be set to an expression that +returns the TLS value. +*/ +#if (OSCL_HAS_TLS_SUPPORT) && !(OSCL_TLS_IS_KEYED) && !defined(OSCL_TLS_GET_FUNC) +#error "ERROR: OSCL_TLS_GET_FUNC has to be defined" +#endif + +/** +OSCL_HAS_BASIC_LOCK should be set to 1 if the platform has basic lock support. +*/ +#if !defined(OSCL_HAS_BASIC_LOCK ) +#error "ERROR: OSCL_HAS_BASIC_LOCK must be defined to 0 or 1" +#endif + + +/** +When OSCL_HAS_BASIC_LOCK is 1, +type TOsclBasicLockObject should be defined as the type used as +a mutex object or handle on the target platform. It can +be either typedef'd as a C-compilable type or can be #defined. +Examples: +typedef pthread_mutex_t TOsclBasicLockObject; +#define TOsclBasicLockObject RMutex +*/ +#if (OSCL_HAS_BASIC_LOCK) && !defined(TOsclBasicLockObject) +typedef TOsclBasicLockObject __verify__TOsclBasicLockObject__defined__; +#endif + +/** +\def OSCL_HAS_PRAGMA_PACK macro should be set to 1 if the compiler supports +pragma pack, 0 if it does not. +*/ +#ifndef OSCL_HAS_PRAGMA_PACK +#error "ERROR: OSCL_HAS_PRAGMA_PACK must be defined to 0 or 1" +#endif + +/*! @} */ + +#endif // OSCLCONFIG_CHECK_H_INCLUDED + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_error_check.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_error_check.h new file mode 100644 index 0000000..301181e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_error_check.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCLCONFIG_ERROR_CHECK_H_INCLUDED +#define OSCLCONFIG_ERROR_CHECK_H_INCLUDED + + +/** +OSCL_HAS_EXCEPTIONS macro should be set to 1 if +the target platform supports C++ exceptions (throw, catch). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_EXCEPTIONS +#error "ERROR: OSCL_HAS_EXCEPTIONS has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_EXCEPTIONS macro should be set to 1 if +the target platform supports the POSIX-compliant errno.h header file. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_ERRNO_H +#error "ERROR: OSCL_HAS_ERRNO_H has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_SYMBIAN_ERRORTRAP macro should be set to 1 if +the target platform has Symbian leave, trap, and cleanup stack support. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SYMBIAN_ERRORTRAP +#error "ERROR: OSCL_HAS_SYMBIAN_ERRORTRAP has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_SETJMP_H macro should be set to 1 if +the target platform supports the setjmp.h header file including +the setjmp and longjmp functions. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SETJMP_H +#error "ERROR: OSCL_HAS_SETJMP_H has to be defined to either 1 or 0" +#endif + + +#endif //OSCLCONFIG_ERROR_CHECK_H_INCLUDED + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_global_new_delete.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_global_new_delete.h new file mode 100644 index 0000000..d3d0112 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_global_new_delete.h @@ -0,0 +1,30 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCLCONFIG_GLOBAL_NEW_DELETE_H_INCLUDED +#define OSCLCONFIG_GLOBAL_NEW_DELETE_H_INCLUDED + +//This file contains overloads for the global new/delete operators +//for use in configurations without a native new/delete operator, +//or where it is desirable to overload the existing global new/delete +//operators. The implementation of the operators is in oscl_mem.cpp. + +void* operator new(size_t); +void operator delete(void*); + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_global_placement_new.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_global_placement_new.h new file mode 100644 index 0000000..4ab19e7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_global_placement_new.h @@ -0,0 +1,31 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCLCONFIG_GLOBAL_PLACEMENT_NEW_H_INCLUDED +#define OSCLCONFIG_GLOBAL_PLACEMENT_NEW_H_INCLUDED + +//This file contains a definition of placement new operator +//for use in configurations without a native placement new +//operator definition. + +inline void* operator new(size_t, void* ptr) +{ + return ptr; +} + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_io_check.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_io_check.h new file mode 100644 index 0000000..22ddebb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_io_check.h @@ -0,0 +1,605 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCLCONFIG_IO_CHECK_H_INCLUDED +#define OSCLCONFIG_IO_CHECK_H_INCLUDED + +/** +OSCL_HAS_ANSI_FILE_IO_SUPPORT macro should be set to 1 if +the target platform supports the ANSI C file I/O functions (fopen, fread, etc). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_ANSI_FILE_IO_SUPPORT +#error "ERROR: OSCL_HAS_ANSI_FILE_IO_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_ANSI_64BIT_FILE_IO_SUPPORT macro should be set to 1 if +the target platform supports the 64-bit ANSI C file I/O functions (fopen, fread, etc). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_ANSI_64BIT_FILE_IO_SUPPORT +#error "ERROR: OSCL_HAS_ANSI_64BIT_FILE_IO_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_MSWIN_FILE_IO_SUPPORT macro should be set to 1 if +the target platform supports the ANSI C file I/O functions (fopen, fread, etc). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_MSWIN_FILE_IO_SUPPORT +#error "ERROR: OSCL_HAS_MSWIN_FILE_IO_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION macro should be set to 1 if +the target platform supports the Symbian file I/O functions (RFile, RFs). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION +#error "ERROR: OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION has to be defined to either 1 or 0" +#endif + +/** +On Symbian platforms only: +OSCL_HAS_NATIVE_DUPLICATE_FILE_HANDLE macro should be set to 1 if +the target platform supports the Symbian file I/O function RFile::Duplicate. +Otherwise it should be set to 0. +*/ +#if (OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION) +#ifndef OSCL_HAS_NATIVE_DUPLICATE_FILE_HANDLE +#error "ERROR: OSCL_HAS_NATIVE_DUPLICATE_FILE_HANDLE has to be defined to either 1 or 0" +#endif +#endif + + +/** +OSCL_HAS_NATIVE_FILE_CACHE_ENABLE macro should be set to 1 if +the target platform includes native file cache capability. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_NATIVE_FILE_CACHE_ENABLE +#error "ERROR: OSCL_HAS_NATIVE_FILE_CACHE_ENABLE has to be defined to either 1 or 0" +#endif + + +/** +OSCL_HAS_PV_FILE_CACHE macro should be set to 1 if +the target platform includes PV file cache capability. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_PV_FILE_CACHE +#error "ERROR: OSCL_HAS_PV_FILE_CACHE has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_LARGE_FILE_SUPPORT macro should be set to 1 if +the target platform supports more than 32bit file I/O capability. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_LARGE_FILE_SUPPORT +#error "ERROR: OSCL_HAS_LARGE_FILE_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +type TOsclFileOffset should be defined as the type used for file size +and offsets on the target platform. +Example: +typedef size_t TOsclFileOffset; +*/ +typedef TOsclFileOffset __verify__TOsclFileOffset__defined__; + + +/** +OSCL_FILE_BUFFER_MAX_SIZE macro should be set to +the desired size of the file I/O cache in bytes. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_FILE_BUFFER_MAX_SIZE +#error "ERROR: OSCL_FILE_BUFFER_MAX_SIZE has to be defined to a numeric value" +#endif + +/** +OSCL_HAS_SOCKET_SUPPORT macro should be set to 1 if +the target platform supports sockets of any type. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SOCKET_SUPPORT +#error "ERROR: OSCL_HAS_SOCKET_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_SYMBIAN_SOCKET_SERVER macro should be set to +1 if the platform supports Symbian socket API (RSocket, RSocketServ). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SYMBIAN_SOCKET_SERVER +#error "ERROR: OSCL_HAS_SYMBIAN_SOCKET_SERVER has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_SYMBIAN_DNS_SERVER macro should be set to +1 if the platform supports Symbian Host Resolver API (RHostResolver). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SYMBIAN_DNS_SERVER +#error "ERROR: OSCL_HAS_SYMBIAN_DNS_SERVER has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_BERKELEY_SOCKETS macro should be set to +1 if the platform supports Berkeley style socket API, including +non-blocking I/O and a 'select' call. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_BERKELEY_SOCKETS +#error "ERROR: OSCL_HAS_BERKELEY_SOCKETS has to be defined to either 1 or 0" +#endif + +/** +For platforms with Berkeley type sockets, +TOsclSocket typedef should be set to platform native socket type. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +typedef TOsclSocket __TOsclSocketCheck___; +#endif + +/** +For platforms with Berkeley type sockets, +TOsclSockAddr typedef should be set to platform native socket address type. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +typedef TOsclSockAddr __TOsclSockAddrCheck___; +#endif + +/** +For platforms with Berkeley type sockets, +TOsclSockAddrLen typedef should be set to platform native socket address +length type. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +typedef TOsclSockAddrLen __TOsclSockAddrLenCheck___; +#endif + +/** +For platforms with Berkeley type sockets, +OsclBind(s,addr,ok,err) must be defined to +an expression that does a bind call. +'s' and 'addr' are the socket and address parameters +to the bind command. +On success, 'ok' must be set to true. +On failure, 'ok' must be set to false and 'err' must be set +to the bind error. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclBind +#error "ERROR: OsclBind(s,addr,ok,err) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclListen(s,size,ok,err) must be defined to +an expression that does a listen call and sets 'ok' and 'err' +to indicate the result. +'s' and 'size' are the socket and queue size args to the listen +call. +On success, 'ok' must be set to true. +On failure, 'ok' must be set to false and 'err' must be set +to the listen error. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclListen +#error "ERROR: OsclListen(s,size,ok,err) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclAccept(s,accept_s,ok,err,wouldblock) must be defined to +an expression that does an accept call and sets 'ok', 'err', +and 'wouldblock' to indicate the result. +'s' and 'accept_s' are the socket and accept socket args to the +accept call. +On success, 'ok' must be set to true. +On failure, 'ok' must be set to false and 'err' must be set +to the accept error. Additionally 'wouldblock' must be set to true +if the error code indicates that the socket is non-blocking and +would block, or to false otherwise. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclAccept +#error "ERROR: OsclAccept(s,accept_s,ok,err,wouldblock) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclSetNonBlocking(s,ok,err) must be defined to +an expression that sets socket 's' to non-blocking I/O mode +and sets 'ok' and 'err' to indicate the result. +On success, 'ok' must be set to true. +On failure, 'ok' must be set to false and 'err' must be set +to the error. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclSetNonBlocking +#error "ERROR: OsclSetNonBlocking(s,ok,err) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclShutdown(s,how,ok,err) must be defined to +an expression that does a shutdown call and sets 'ok' and 'err' +to indicate the result. +'s' and 'how' are the socket and shutdown type args to the +shutdown call. +On success, 'ok' must be set to true. +On failure, 'ok' must be set to false and 'err' must be set +to the shutdown error. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclShutdown +#error "ERROR: OsclShutdown(s,how,ok,err) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclSocket(s,fam,type,prot,ok,err) must be defined to +an expression that does a socket creation call and sets 'ok' +and 'err' to indicate the result. +'s', 'fam', 'type', and 'prot' are the socket, family, type, and +protocol args to the socket call. +On success, 'ok' must be set to true. +On failure, 'ok' must be set to false and 'err' must be set +to the socket error. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclSocket +#error "ERROR: OsclSocket(s,fam,type,prot,ok,err) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclSendTo(s,buf,len,addr,ok,err,nbytes,wouldblock) must be defined +to an expression that does a sendto call and sets 'ok, 'err', 'nbytes', +and 'wouldblock' to indicate the result. +'s', 'buf', 'len', 'flags' and 'addr' are the arguments to the sendto +call. +On success, 'ok' must be set to true, and 'nbytes' must be set to +the number of bytes sent. +On failure, 'ok' must be set to false 'err' must be set +to the socket error. Additionally 'wouldblock' must be set to true +if the error code indicates that the socket is non-blocking and +would block, or to false otherwise. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclSendTo +#error "ERROR: OsclSendTo(s,buf,len,flags,addr,ok,err,nbytes,wouldblock) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclSend(s,buf,len,ok,err,nbytes,wouldblock) must be defined to +an expression that does a send operation and sets 'ok, 'err', 'nbytes', +and 'wouldblock' to indicate the result. +'s', 'buf', and 'len' are the args to the send call. +On success, 'ok' must be set to true, and 'nbytes' must be set to +the number of bytes sent. +On failure, 'ok' must be set to false 'err' must be set +to the socket error. Additionally 'wouldblock' must be set to true +if the error code indicates that the socket is non-blocking and +would block, or to false otherwise. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclSend +#error "ERROR: OsclSend(s,buf,len,ok,err,nbytes,wouldblock) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclCloseSocket(s,ok,err) must be defined to +an expression that closes socket 's' and sets 'ok and 'err' +to indicate the result. +On success, 'ok' must be set to true. +On failure, 'ok' must be set to false and 'err' must be set +to the close error. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclCloseSocket +#error "ERROR: OsclCloseSocket(s,ok,err) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclConnect(s,addr,ok,err,wouldblock) must be defined to +an expression that does a connect call and sets 'ok', 'err', +and 'wouldblock' to indicate the result. +'s' and 'addr' are the socket and address args to the connect call. +On success, 'ok' must be set to true. +On failure, 'ok' must be set to false 'err' must be set +to the socket error. Additionally 'wouldblock' must be set to true +if the error code indicates that the socket is non-blocking and +would block, or to false otherwise. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclConnect +#error "ERROR: OsclConnect(s,addr,ok,err,wouldblock) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclConnectComplete(s,wset,eset,success,fail,ok,err) must be set +to an expression that checks for completion of a connect operation +on a non-blocking socket and sets 'success', 'fail', 'ok', and 'err' +to indicate the result. +'s' is the socket, 'wset' is the write set from the select call, +'eset' is the exception set from the select call. +If connect is not yet complete, 'success' and 'fail' must be +set false. +On connect success, 'success' must be set true. +On conneect failure, 'success' must be set false, 'fail' must be +set true. Additionally, the call attempts to retrieve the connect error. +If the connect error is obtained, 'ok' is set true and 'err' contains +the error. If the connect error is not obtained, 'ok' is set false +and 'err' is the error code from the attempt. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclConnectComplete +#error "ERROR: OsclConnectComplete(s,wset,eset,success,fail,ok,err) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclRecv(s,buf,len,ok,err,nbytes,wouldblock) must be defined to +an expression that does a recv call and sets 'ok', 'err', 'nbytes', +and 'wouldblock' to indicate the result. +'s', 'buf', and 'len' are the arguments to the recv call. +On success, 'ok' must be set to true, and 'nbytes' must be set to +the number of bytes received. +On failure, 'ok' must be set to false 'err' must be set +to the socket error. Additionally 'wouldblock' must be set to true +if the error code indicates that the socket is non-blocking and +would block, or to false otherwise. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclRecv +#error "ERROR: OsclRecv(s,buf,len,ok,err,nbytes,wouldblock) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclRecvFrom(s,buf,len,addr,addrlen,ok,err,nbytes,wouldblock) must be defined to +an expression that does a recvfrom call and sets 'ok', 'err', 'nbytes', +and 'wouldblock' to indicate the result. +'s', 'buf', 'len', 'paddr', and 'paddrlen' are the arguments to the recvfrom call. +On success, 'ok' must be set to true, 'nbytes' must be set to +the number of bytes received, and 'paddr' must be set to the source address. +On failure, 'ok' must be set to false 'err' must be set +to the socket error. Additionally 'wouldblock' must be set to true +if the error code indicates that the socket is non-blocking and +would block, or to false otherwise. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclRecvFrom +#error "ERROR: OsclRecvFrom(s,buf,len,paddr,paddrlen,ok,err,nbytes,wouldblock) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclSocketSelect(nfds,rd,wr,ex,timeout,ok,err,nhandles) must be defined to +an expression that does a select call and sets 'ok', 'err', and +'nhandles' to indicate the result. +'nfds', 'rd', 'wr', 'ex', and 'timeout' are the arguments to the +select call. +On success, 'ok' must be set to true, and 'nhandles' must be set to +the number of socket handles with activitiy detected. +On failure, 'ok' must be set to false 'err' must be set +to the select error. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclSocketSelect +#error "ERROR: OsclSocketSelect(nfds,rd,wr,ex,timeout,ok,err,nhandles) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclSocketStartup(ok) must be defined to +an expression that does any necessary startup of the socket system +and sets 'ok' to indicate the result. +On success, 'ok' must be set to true. +On failure, 'ok' must be set to false. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclSocketStartup +#error "ERROR: OsclSocketStartup(ok) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclSocketCleanup(ok) must be defined to +an expression that does any necessary cleanup of the socket system +and sets 'ok' to indicate the result. +On success, 'ok' must be set to true. +On failure, 'ok' must be set to false. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclSocketCleanup +#error "ERROR: OsclSocketCleanup(ok) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclGetAsyncSockErr(s,ok,err) must be defined to +an expression that does a getsockopt call to retrieve a socket error +and sets 'ok' and 'err' to indicate the result. +'s' is the socket argument to the getsockopt call. +On success, 'ok' must be set true and 'err' must be set to the +error retrieved. +On failure, 'ok' must be set false and 'err' must be set to the +error from the getsockopt call. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclGetAsyncSockErr +#error "ERROR: OsclGetAsyncSockErr(s,ok,err) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +TOsclHostent typedef should be set to platform native hostent type. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +typedef TOsclHostent __TOsclHostentCheck___; +#endif + +/** +For platforms with Berkeley type sockets, +OsclGethostbyname(name,hostent,ok,err) must be defined to +an expression that does a gethostbyname call on host 'name' +and sets 'hostent', 'ok' and 'err' to indicate the result. +'name' is the name argument to the gethostbyname call. +On success, 'ok' must be set true and 'hostent' must be set to +the TOsclHostent* retrieved. +On failure, 'ok' must be set false and 'err' must be set to the +error from the gethostbyname call. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclGethostbyname +#error "ERROR: OsclGethostbyname(name,hostent,ok,err) has to be defined" +#endif +#endif + +/** +For platforms with Berkeley type sockets, +OsclGetDottedAddr(hostent,dottedaddr,ok) must be defined to +an expression that does extracts an address in dotted decimal +notation from a hostent structure. +'hostent' is the TOsclHostent*, +'dottedaddr' is a char* output containing the dotted address, +and 'ok' is a bool that should be set true on success, false on failure. +*/ +#if OSCL_HAS_BERKELEY_SOCKETS +#ifndef OsclGetDottedAddr +#error "ERROR: OsclGetDottedAddr(hostent,dottedaddr,ok) has to be defined" +#endif +#endif + + +/** +For platforms in which file descriptors created with a pipe() command can be +used with the select() system call the following 3 macros must be defined +*/ + +#if OSCL_HAS_SELECTABLE_PIPES +#ifndef OsclPipe +#error "ERROR: OsclPipe(pipearray) has to be defined" +#endif +#endif + +#if OSCL_HAS_SELECTABLE_PIPES +#ifndef OsclReadFD +#error "ERROR: OsclReadFD(fd,buffer,cnt) has to be defined" +#endif +#endif + +#if OSCL_HAS_SELECTABLE_PIPES +#ifndef OsclWriteFD +#error "ERROR: OsclWriteFD(fd,buffer,cnt) has to be defined" +#endif +#endif + +#if OSCL_HAS_SOCKET_SUPPORT +/** +OsclValidInetAddr must be defined to a boolean expression to +evaluate whether an address is proper IP4 format. +'addr' is a char* containing the address string. +*/ +#ifndef OsclValidInetAddr +#error "ERROR: OsclValidInetAddr(addr) must be defined" +#endif +#endif + +#if OSCL_HAS_SOCKET_SUPPORT +/** +OSCL_SD_RECEIVE, OSCL_SD_SEND, and OSCL_SD_BOTH must be defined to +the platform-specific socket shutdown codes. +*/ +#ifndef OSCL_SD_RECEIVE +#error "ERROR: OSCL_SD_RECEIVE has to be defined" +#endif +#ifndef OSCL_SD_SEND +#error "ERROR: OSCL_SD_SEND has to be defined" +#endif +#ifndef OSCL_SD_BOTH +#error "ERROR: OSCL_SD_BOTH has to be defined" +#endif +#endif + +#if OSCL_HAS_SOCKET_SUPPORT +/** +OSCL_AF_INET must be defined to the platform-specific +network address family codes for INET. +*/ +#ifndef OSCL_AF_INET +#error "ERROR: OSCL_AF_INET has to be defined" +#endif +#endif + +#if OSCL_HAS_SOCKET_SUPPORT +/** +OSCL_SOCK_STREAM and OSCL_SOCK_DATAGRAM must be defined to +the platform-specific socket type codes. +*/ +#ifndef OSCL_SOCK_STREAM +#error "ERROR: OSCL_SOCK_STREAM has to be defined" +#endif +#ifndef OSCL_SOCK_DATAGRAM +#error "ERROR: OSCL_SOCK_DATAGRAM has to be defined" +#endif +#endif + +#if OSCL_HAS_SOCKET_SUPPORT +/** +OSCL_IPPROTO_TCP and OSCL_IPPROTO_UDP must be defined to +the platform-specific IP protocol codes. +*/ +#ifndef OSCL_IPPROTO_TCP +#error "ERROR: OSCL_IPPROTO_TCP has to be defined" +#endif +#ifndef OSCL_IPPROTO_UDP +#error "ERROR: OSCL_IPPROTO_UDP has to be defined" +#endif +#endif + + +#endif // OSCLCONFIG_IO_CHECK_H_INCLUDED + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_ix86.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_ix86.h new file mode 100644 index 0000000..87d7afb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_ix86.h @@ -0,0 +1,41 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G ( P L A T F O R M C O N F I G I N F O ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_ix86.h + * \brief This file contains configuration information for the ix86 processor family + * + */ + +#ifndef OSCLCONFIG_IX86_H_INCLUDED +#define OSCLCONFIG_IX86_H_INCLUDED + + +// Define macros for integer alignment and little endian byte order. +#define OSCL_INTEGERS_WORD_ALIGNED 1 +#define OSCL_BYTE_ORDER_BIG_ENDIAN 0 +#define OSCL_BYTE_ORDER_LITTLE_ENDIAN 1 + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_lib_check.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_lib_check.h new file mode 100644 index 0000000..e4f7479 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_lib_check.h @@ -0,0 +1,67 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCLCONFIG_LIB_CHECK_H_INCLUDED +#define OSCLCONFIG_LIB_CHECK_H_INCLUDED + +/*! \addtogroup osclconfig OSCL config + * + * @{ + */ + + + +/** +OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT should be set to 1 if the platform has basic explicit runtime DLL loading support. +*/ +#if !defined(OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT ) +#error "ERROR: OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT must be defined to 0 or 1" +#endif + +#if(OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT) +/** +** When OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT is 1, +** OSCL_LIB_READ_DEBUG_LIBS should be set to 0 or 1. Set to 1 to enable loading +** debug versions of libs. +*/ +#if !defined(OSCL_LIB_READ_DEBUG_LIBS) +#error "ERROR: OSCL_LIB_READ_DEBUG_LIBS must be defined to 0 or 1" +#endif + +/* +** When OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT is 1, +** PV_DYNAMIC_LOADING_CONFIG_FILE_PATH should be set. +*/ +#if !defined(PV_DYNAMIC_LOADING_CONFIG_FILE_PATH) +#error "ERROR: PV_DYNAMIC_LOADING_CONFIG_FILE_PATH must be set to a path where the config files are expected to be present" +#endif + +/* +** When OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT is 1, +** PV_RUNTIME_LIB_FILENAME_EXTENSION should be set. +*/ +#if !defined(PV_RUNTIME_LIB_FILENAME_EXTENSION) +#error "ERROR: PV_RUNTIME_LIB_FILENAME_EXTENSION must be specified for use as the dynamic library file extension" +#endif +#endif // OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT + +/*! @} */ + +#endif // OSCLCONFIG_LIB_CHECK_H_INCLUDED + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_limits_typedefs.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_limits_typedefs.h new file mode 100644 index 0000000..4ce355d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_limits_typedefs.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G_ L I M I T S _ T Y P E D E F S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_limits_typedefs.h + * \brief This file contains common typedefs based on the ANSI C limits.h header + * + * This header file should work for any ANSI C compiler to determine the + * proper native C types to use for OSCL integer types. + */ + + +#ifndef OSCLCONFIG_LIMITS_TYPEDEFS_H_INCLUDED +#define OSCLCONFIG_LIMITS_TYPEDEFS_H_INCLUDED + + +#include + +// determine if char is signed or unsigned +#if ( CHAR_MIN == 0 ) +#define OSCL_CHAR_IS_UNSIGNED 1 +#define OSCL_CHAR_IS_SIGNED 0 +#elif ( CHAR_MIN == SCHAR_MIN ) +#define OSCL_CHAR_IS_UNSIGNED 0 +#define OSCL_CHAR_IS_SIGNED 1 +#else +#error "Cannot determine if char is signed or unsigned" +#endif + + +#if ( (CHAR_MAX == 255) || (CHAR_MAX == 127) ) +typedef signed char int8; +typedef unsigned char uint8; +#else +#error "Cannot determine an 8-bit interger type" +#endif + + +#if ( SHRT_MAX == 32767 ) +typedef short int16; +typedef unsigned short uint16; + +#elif ( INT_MAX == 32767 ) +typedef int int16; +typedef unsigned int uint16; + +#else +#error "Cannot determine 16-bit integer type" +#endif + + + +#if ( INT_MAX == 2147483647 ) +typedef int int32; +typedef unsigned int uint32; + +#elif ( LONG_MAX == 2147483647 ) +typedef long int32; +typedef unsigned long uint32; + +#else +#error "Cannot determine 32-bit integer type" +#endif + + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_memory_check.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_memory_check.h new file mode 100644 index 0000000..8903111 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_memory_check.h @@ -0,0 +1,72 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCLCONFIG_MEMORY_CHECK_H_INCLUDED +#define OSCLCONFIG_MEMORY_CHECK_H_INCLUDED + + +/** +OSCL_BYPASS_MEMMGT macro should be set to 1 if +it is desirable to bypass the PV memory management system and just +use the native memory management. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_BYPASS_MEMMGT +#error "ERROR: OSCL_BYPASS_MEMMGT has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_ANSI_MEMORY_FUNCS macro should be set to 1 if +the target platform supports ANSI C memory functions (malloc, free, etc). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_ANSI_MEMORY_FUNCS +#error "ERROR: OSCL_HAS_ANSI_MEMORY_FUNCS has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_SYMBIAN_MEMORY_FUNCS macro should be set to 1 if +the target platform supports Symbian memory functions User::Alloc, User::Free, etc. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SYMBIAN_MEMORY_FUNCS +#error "ERROR: OSCL_HAS_SYMBIAN_MEMORY_FUNCS has to be defined to either 1 or 0" +#endif + +/* + * OSCL_HAS_HEAP_BASE_SUPPORT macro should be set to 1 for the + * platforms that allows inheritance from HeapBase class for + * overloading of new/delete operators. + */ + +#ifndef OSCL_HAS_HEAP_BASE_SUPPORT +#error "ERROR: OSCL_HAS_HEAP_BASE_SUPPORT has to be defined to either 1 or 0." +#endif + +/* + * OSCL_HAS_GLOBAL_NEW_DELETE macro should be set to 1 for the + * platforms that allows overloading of new/delete operators. + */ + +#ifndef OSCL_HAS_GLOBAL_NEW_DELETE +#error "ERROR: OSCL_HAS_GLOBAL_NEW_DELETE has to be defined to either 1 or 0." +#endif + +#endif // OSCLCONFIG_MEMORY_CHECK_H_INCLUDED + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_no_os.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_no_os.h new file mode 100644 index 0000000..c1a06e3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_no_os.h @@ -0,0 +1,71 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCLCONFIG_NO_OS_H_INCLUDED +#define OSCLCONFIG_NO_OS_H_INCLUDED + +/*! \addtogroup osclconfig OSCL config + * + * @{ + */ + +//a file to turn off ALL os-specific switches. + +//osclconfig +#define OSCL_HAS_UNIX_SUPPORT 0 +#define OSCL_HAS_MSWIN_SUPPORT 0 +#define OSCL_HAS_MSWIN_PARTIAL_SUPPORT 0 +#define OSCL_HAS_SYMBIAN_SUPPORT 0 +#define OSCL_HAS_SAVAJE_SUPPORT 0 +#define OSCL_HAS_PV_C_OS_SUPPORT 0 +#define OSCL_HAS_ANDROID_SUPPORT 0 +#define OSCL_HAS_IPHONE_SUPPORT 0 + +//osclconfig_error +#define OSCL_HAS_SYMBIAN_ERRORTRAP 0 + +//osclconfig_memory +#define OSCL_HAS_SYMBIAN_MEMORY_FUNCS 0 +#define OSCL_HAS_PV_C_OS_API_MEMORY_FUNCS 0 + +//osclconfig_time +#define OSCL_HAS_PV_C_OS_TIME_FUNCS 0 +#define OSCL_HAS_UNIX_TIME_FUNCS 0 + +//osclconfig_util +#define OSCL_HAS_SYMBIAN_TIMERS 0 +#define OSCL_HAS_SYMBIAN_MATH 0 + +//osclconfig_proc +#define OSCL_HAS_SYMBIAN_SCHEDULER 0 +#define OSCL_HAS_SEM_TIMEDWAIT_SUPPORT 0 +#define OSCL_HAS_PTHREAD_SUPPORT 0 + +//osclconfig_io +#define OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION 0 +#define OSCL_HAS_SAVAJE_IO_SUPPORT 0 +#define OSCL_HAS_SYMBIAN_SOCKET_SERVER 0 +#define OSCL_HAS_SYMBIAN_DNS_SERVER 0 +#define OSCL_HAS_BERKELEY_SOCKETS 0 + + +/*! @} */ + +#endif // OSCLCONFIG_CHECK_H_INCLUDED + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_proc_check.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_proc_check.h new file mode 100644 index 0000000..0cba8f2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_proc_check.h @@ -0,0 +1,157 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCLCONFIG_PROC_CHECK_H_INCLUDED +#define OSCLCONFIG_PROC_CHECK_H_INCLUDED + +/** +OSCL_HAS_THREAD_SUPPORT macro should be set to 1 if +the target platform supports threads. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_THREAD_SUPPORT +#error "ERROR: OSCL_HAS_THREAD_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT macro should be set to 1 if +the target platform supports non-pre-emptive threads. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT +#error "ERROR: OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_SYMBIAN_SCHEDULER macro should be set to 1 if +the target platform supports Symbian active object scheduler. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SYMBIAN_SCHEDULER +#error "ERROR: OSCL_HAS_SYMBIAN_SCHEDULER has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_SEM_TIMEDWAIT_SUPPORT macro should be set to 1 if +the target platform supports POSIX-compliant semaphores (semaphore.h) +with advanced realtime features including sem_timedwait. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SEM_TIMEDWAIT_SUPPORT +#error "ERROR: OSCL_HAS_SEM_TIMEDWAIT_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_PTHREAD_SUPPORT macro should be set to 1 if +the target platform supports POSIX-compliand pthreads (pthread.h). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_PTHREAD_SUPPORT +#error "ERROR: OSCL_HAS_PTHREAD_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +type TOsclThreadId should be defined as the type used as +a thread ID +on the target platform. +Example: +typedef DWORD TOsclThreadId; +*/ +typedef TOsclThreadId __verify__TOsclThreadId__defined__; + +/** +type TOsclThreadFuncRet should be defined as the type used as +a thread function return value +on the target platform. +Example: +typedef DWORD TOsclThreadFuncRet; +*/ +typedef TOsclThreadFuncRet __verify__TOsclThreadFuncRet__defined__; + +/** +type TOsclThreadFuncArg should be defined as the type used as +a thread function argument +on the target platform. +Example: +typedef LPVOID TOsclThreadFuncArg; +*/ +typedef TOsclThreadFuncArg __verify__TOsclThreadFuncArg__defined__; + +/** +OSCL_THREAD_DECL macro should be defined to the +necessary function declaration modifiers for thread routines, +or a null macro if no modifiers are needed. +Example: +#define OSCL_THREAD_DECL WINAPI +*/ +#ifndef OSCL_THREAD_DECL +#error "ERROR: OSCL_THREAD_DECL has to be defined." +#endif + +/** +Example of a declaration of a thread routine called MyThreadMain using +the Oscl definitions: + +static TOsclThreadFuncRet OSCL_THREAD_DECL MyThreadMain(TOsclThreadFuncArg arg); +*/ + +/** +type TOsclThreadObject should be defined as the type used as +a thread object or handle +on the target platform. +Example: +typedef pthread_t TOsclThreadObject; +*/ +typedef TOsclThreadObject __verify__TOsclThreadObject__defined__; + +/** +type TOsclMutexObject should be defined as the type used as +a mutex object or handle +on the target platform. +Example: +typedef pthread_mutex_t TOsclMutexObject; +*/ +typedef TOsclMutexObject __verify__TOsclMutexObject__defined__; + +/** +type TOsclSemaphoreObject should be defined as the type used as +a mutex object or handle +on the target platform. +Example: +typedef sem_t TOsclSemaphoreObject; +*/ +typedef TOsclSemaphoreObject __verify__TOsclSemaphoreObject__defined__; + +/** +type TOsclConditionObject should be defined as the type used as +a condition variable +on the target platform. +Example: +typedef pthread_cond_t TOsclConditionObject; + +Note: Condition variables are only used with certain semaphore implementations. +If the semaphore implementation does not require a condition variable, +then this type can be defined as 'int' as follows: +typedef int TOsclConditionObject; //not used +*/ +typedef TOsclConditionObject __verify__TOsclConditionObject__defined__; + + +#endif //OSCLCONFIG_PROC_CHECK_H_INCLUDED + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_proc_unix_common.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_proc_unix_common.h new file mode 100644 index 0000000..104a2cc --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_proc_unix_common.h @@ -0,0 +1,59 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ P R O C ( P L A T F O R M C O N F I G I N F O ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_proc.h + * \brief This file contains configuration information for the linux platform + * + */ + +#ifndef OSCLCONFIG_PROC_UNIX_COMMON_H_INCLUDED +#define OSCLCONFIG_PROC_UNIX_COMMON_H_INCLUDED + +#define OSCL_HAS_SYMBIAN_SCHEDULER 0 + +#define OSCL_HAS_THREAD_SUPPORT 1 +#define OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT 0 + +//semaphore with advanced realtime features incl. timed wait. +#define OSCL_HAS_SEM_TIMEDWAIT_SUPPORT 1 +#include +#include + +//pthreads +#define OSCL_HAS_PTHREAD_SUPPORT 1 +#include +#include + +// threads, mutex, semaphores +typedef pthread_t TOsclThreadId; +typedef void* TOsclThreadFuncArg; +typedef void* TOsclThreadFuncRet; +#define OSCL_THREAD_DECL +typedef pthread_t TOsclThreadObject; +typedef pthread_mutex_t TOsclMutexObject; +typedef sem_t TOsclSemaphoreObject; +typedef pthread_cond_t TOsclConditionObject; + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_time_check.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_time_check.h new file mode 100644 index 0000000..0243d5c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_time_check.h @@ -0,0 +1,47 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +//osclconfig: this build configuration file is for win32 +#ifndef OSCLCONFIG_TIME_CHECK_H_INCLUDED +#define OSCLCONFIG_TIME_CHECK_H_INCLUDED + + +/** +OSCL_HAS_UNIX_TIME_FUNCS macro should be set to 1 if +the target platform supports unix time of day functions. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_UNIX_TIME_FUNCS +#error "ERROR: OSCL_HAS_UNIX_TIME_FUNCS has to be defined to either 1 or 0" +#endif + +/** +OsclBasicTimeStruct type should be defined to the platform-specific +time of day type. +*/ +typedef OsclBasicTimeStruct __Validate__BasicTimeStruct__; + +/** +OsclBasicDateTimeStruct type should be defined to the platform-specific +date + time type. +*/ +typedef OsclBasicDateTimeStruct __Validate__BasicTimeDateStruct__; + +#endif //OSCLCONFIG_TIME_CHECK_H_INCLUDED + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_unix_common.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_unix_common.h new file mode 100644 index 0000000..d795c49 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_unix_common.h @@ -0,0 +1,103 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L C O N F I G _ U N I X _ C O M M O N + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file osclconfig_limits_typedefs.h + * \brief This file contains common typedefs based on the ANSI C limits.h header + * + * This header file should work for any ANSI C compiler to determine the + * proper native C types to use for OSCL integer types. + */ + + +#ifndef OSCLCONFIG_UNIX_COMMON_H_INCLUDED +#define OSCLCONFIG_UNIX_COMMON_H_INCLUDED + + +// system header files +#include // abort +#include // va_list +#include +#include +#include +#include +#include //for sleep +#include +#include // for tolower and toupper +#ifdef __cplusplus +#include //for placement new +#endif +#include + +#define OSCL_DISABLE_INLINES 0 + +#define OSCL_HAS_ANSI_STDLIB_SUPPORT 1 +#define OSCL_HAS_ANSI_MATH_SUPPORT 1 +#define OSCL_HAS_GLOBAL_VARIABLE_SUPPORT 1 +#define OSCL_HAS_ANSI_STRING_SUPPORT 1 +#define OSCL_HAS_ANSI_WIDE_STRING_SUPPORT 1 +#define OSCL_HAS_ANSI_STDIO_SUPPORT 1 + +#define OSCL_MEMFRAG_PTR_BEFORE_LEN 1 + +#define OSCL_HAS_UNIX_SUPPORT 1 +#define OSCL_HAS_MSWIN_SUPPORT 0 +#define OSCL_HAS_MSWIN_PARTIAL_SUPPORT 0 +#define OSCL_HAS_SYMBIAN_SUPPORT 0 + +// 64-bit int +#define OSCL_NATIVE_INT64_TYPE int64_t +#define OSCL_NATIVE_UINT64_TYPE uint64_t +#define INT64(x) x##LL +#define UINT64(x) x##ULL +#define INT64_HILO(high,low) ((((high##LL))<<32)|low) +#define UINT64_HILO(high,low) ((((high##ULL))<<32)|low) + +// character set. +#define OSCL_HAS_UNICODE_SUPPORT 1 +#define OSCL_NATIVE_WCHAR_TYPE wchar_t +#if (OSCL_HAS_UNICODE_SUPPORT) +#define _STRLIT(x) L ## x +#else +#define _STRLIT(x) x +#endif +#define _STRLIT_CHAR(x) x +#define _STRLIT_WCHAR(x) L ## x + +// Thread-local storage. Unix has keyed TLS. +#define OSCL_HAS_TLS_SUPPORT 1 +#define OSCL_TLS_IS_KEYED 1 +typedef pthread_key_t TOsclTlsKey ; +#define OSCL_TLS_KEY_CREATE_FUNC(key) (pthread_key_create(&key,NULL)==0) +#define OSCL_TLS_KEY_DELETE_FUNC(key) pthread_key_delete(key) +#define OSCL_TLS_STORE_FUNC(key,ptr) (pthread_setspecific(key,(const void*)ptr)==0) +#define OSCL_TLS_GET_FUNC(key) pthread_getspecific(key) + +//Basic lock +#define OSCL_HAS_BASIC_LOCK 1 +#include +typedef pthread_mutex_t TOsclBasicLockObject; + +#endif // OSCLCONFIG_UNIX_COMMON_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_util_check.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_util_check.h new file mode 100644 index 0000000..f615c4a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/config/shared/osclconfig_util_check.h @@ -0,0 +1,58 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCLCONFIG_UTIL_CHECK_H_INCLUDED +#define OSCLCONFIG_UTIL_CHECK_H_INCLUDED + +/** +OSCL_HAS_SYMBIAN_TIMERS macro should be set to 1 if +the target platform supports Symbian timers (RTimer). +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SYMBIAN_TIMERS +#error "ERROR: OSCL_HAS_SYMBIAN_TIMERS has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_SYMBIAN_MATH macro should be set to 1 if +the target platform supports Symbian features. +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_SYMBIAN_MATH +#error "ERROR: OSCL_HAS_SYMBIAN_MATH has to be defined to either 1 or 0" +#endif + +/** +OSCL_HAS_ANSI_MATH_SUPPORT macro should be set to 1 if +the target platform supports the ANSI C math functions (math.h) +Otherwise it should be set to 0. +*/ +#ifndef OSCL_HAS_ANSI_MATH_SUPPORT +#error "ERROR: OSCL_HAS_ANSI_MATH_SUPPORT has to be defined to either 1 or 0" +#endif + +/** +OSCL_CLOCK_HAS_DRIFT_CORRECTION macro should be set to 1 if the target platform +has drift correction Otherwise it should be set to 0. +*/ +#ifndef OSCL_CLOCK_HAS_DRIFT_CORRECTION +#error "ERROR: OSCL_CLOCK_HAS_DRIFT_CORRECTION has to be defined to either 1 or 0" +#endif + +#endif // OSCLCONFIG_UTIL_CHECK_H_INCLUDED + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/Android.mk new file mode 100644 index 0000000..adf3311 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/Android.mk @@ -0,0 +1,80 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/oscl_time.cpp \ + src/oscl_assert.cpp \ + src/oscl_byte_order.cpp \ + src/oscl_tree.cpp \ + src/oscl_tagtree.cpp \ + src/oscl_stdstring.cpp \ + src/oscl_string_utils.cpp \ + src/oscl_int64_utils.cpp \ + src/oscl_base.cpp \ + src/oscl_tls.cpp \ + src/oscl_mem_basic_functions.cpp \ + src/oscl_singleton.cpp \ + src/oscl_vector.cpp \ + src/oscl_queue.cpp \ + src/oscl_linked_list.cpp \ + src/pvlogger.cpp \ + src/pvlogger_c.cpp + + +LOCAL_MODULE := libosclbase + +LOCAL_CFLAGS := $(PV_CFLAGS) + + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/oscl/oscl/osclbase/src \ + $(PV_TOP)/oscl/oscl/osclbase/src \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + src/oscl_assert.h \ + src/oscl_base.h \ + src/oscl_base_alloc.h \ + src/oscl_base_macros.h \ + src/oscl_byte_order.h \ + src/oscl_defalloc.h \ + src/oscl_dll.h \ + src/oscl_exclusive_ptr.h \ + src/oscl_int64_utils.h \ + src/oscl_mem_inst.h \ + src/oscl_mem_basic_functions.h \ + src/oscl_mem_basic_functions.inl \ + src/oscl_linked_list.h \ + src/oscl_lock_base.h \ + src/oscl_map.h \ + src/oscl_opaque_type.h \ + src/oscl_queue.h \ + src/oscl_refcounter.h \ + src/oscl_refcounter_memfrag.h \ + src/oscl_shared_ptr.h \ + src/oscl_stdstring.h \ + src/oscl_string_utils.h \ + src/oscl_tagtree.h \ + src/oscl_time.h \ + src/oscl_tls.h \ + src/oscl_tree.h \ + src/oscl_types.h \ + src/oscl_uuid.h \ + src/oscl_uuid_utils.h \ + src/oscl_vector.h \ + src/oscl_singleton.h \ + src/oscl_assert.inl \ + src/oscl_byte_order.inl \ + src/oscl_time.inl \ + src/pvlogger.h \ + src/pvlogger_c.h \ + src/pvlogger_registry.h \ + src/pvlogger_accessories.h + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/build/make/local.mk new file mode 100644 index 0000000..01fb8e8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/build/make/local.mk @@ -0,0 +1,75 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + + + +TARGET := osclbase + + +SRCDIR := ../../src +INCSRCDIR := ../../src + +# compose final src list for actual build +SRCS := oscl_time.cpp \ + oscl_assert.cpp \ + oscl_byte_order.cpp \ + oscl_tree.cpp \ + oscl_tagtree.cpp \ + oscl_stdstring.cpp \ + oscl_string_utils.cpp \ + oscl_int64_utils.cpp \ + oscl_base.cpp \ + oscl_tls.cpp \ + oscl_mem_basic_functions.cpp \ + oscl_singleton.cpp \ + oscl_vector.cpp \ + oscl_queue.cpp \ + oscl_linked_list.cpp \ + pvlogger.cpp \ + pvlogger_c.cpp + + +HDRS := oscl_assert.h \ + oscl_base.h \ + oscl_base_alloc.h \ + oscl_base_macros.h \ + oscl_byte_order.h \ + oscl_defalloc.h \ + oscl_dll.h \ + oscl_exclusive_ptr.h \ + oscl_int64_utils.h \ + oscl_mem_inst.h \ + oscl_mem_basic_functions.h \ + oscl_mem_basic_functions.inl \ + oscl_linked_list.h \ + oscl_lock_base.h \ + oscl_map.h \ + oscl_opaque_type.h \ + oscl_queue.h \ + oscl_refcounter.h \ + oscl_refcounter_memfrag.h \ + oscl_shared_ptr.h \ + oscl_stdstring.h \ + oscl_string_utils.h \ + oscl_tagtree.h \ + oscl_time.h \ + oscl_tls.h \ + oscl_tree.h \ + oscl_types.h \ + oscl_uuid.h \ + oscl_uuid_utils.h \ + oscl_vector.h \ + oscl_singleton.h \ + oscl_assert.inl \ + oscl_byte_order.inl \ + oscl_time.inl \ + pvlogger.h \ + pvlogger_c.h \ + pvlogger_registry.h \ + pvlogger_accessories.h + + +include $(MK)/library.mk diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_assert.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_assert.cpp new file mode 100644 index 0000000..e0cc9e7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_assert.cpp @@ -0,0 +1,59 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_assert.h" +#include "osclconfig.h" + +#if (OSCL_DISABLE_INLINES) +#include "oscl_assert.inl" +#endif + +#include "pvlogger.h" + +OSCL_EXPORT_REF void OSCL_Assert(const char *expression, const char *filename, int line_number) +{ +#if(OSCL_HAS_ERROR_HOOK) + //If there's an error hook installed, just log and jump there. + //This is mainly for unit test support, but conceivably some platform + //might also have an error hook. + int32 error; + OsclAny* ptr = OsclTLSRegistry::getInstance(OSCL_TLS_ID_ERRORHOOK, error); + if (ptr) + { + //log the assertion. + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, PVLogger::GetLoggerObject("OSCL_Assert"), PVLOGMSG_EMERG + , (0, "Assertion failure for: %s, at %s:%d", expression, filename, line_number)); + //jump to the error hook + longjmp(*((jmp_buf*)ptr), -1); + } +#endif + + //Print to standard debug output... + + + //default + fprintf(stderr, "Assertion failure for: %s, at %s:%d\n", expression, filename, line_number); + + + //log the assertion. + //this is risky if OsclBase is un-initialized, so do it last. + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, PVLogger::GetLoggerObject("OSCL_Assert"), PVLOGMSG_EMERG + , (0, "Assertion failure for: %s, at %s:%d", expression, filename, line_number)); + + // ...then abort + _OSCL_Abort(); +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_assert.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_assert.h new file mode 100644 index 0000000..9bab497 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_assert.h @@ -0,0 +1,71 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ A S S E R T + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + +/*! \file oscl_assert.h + * \brief The file oscl_assert.h provides an OSCL_ASSERT macro to document + assumptions and test them during development. +*/ + + +#ifndef OSCL_ASSERT_H_INCLUDED +#define OSCL_ASSERT_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + + +//! This function terminates the current process abnormally +/*! +*/ +OSCL_COND_IMPORT_REF void _OSCL_Abort(); + +//! OSCL_ASSERT macro evaluates an expression and when the result is false, prints a diagnostic message and aborts the program. +/*! + \param expr is the expression to be evaluated + \param filename is the name of the current source file + \param line_number is the line number in the current source file +*/ +#if (!OSCL_RELEASE_BUILD) || (OSCL_ASSERT_ALWAYS) +OSCL_IMPORT_REF void OSCL_Assert(const char *expr, const char *filename, int line_number); + +#define OSCL_ASSERT(_expr) \ + ((_expr)?((void)0):OSCL_Assert(# _expr,__FILE__,__LINE__)) + +#else +#define OSCL_ASSERT(_expr) ((void)0) +#endif + +#if (!OSCL_DISABLE_INLINES) +#include "oscl_assert.inl" +#endif + +/*! @} */ + +#endif // OSCL_ASSERT_H_INCLUDED diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_assert.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_assert.inl new file mode 100644 index 0000000..1c24a24 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_assert.inl @@ -0,0 +1,25 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#if(OSCL_HAS_ERROR_HOOK) +#include "oscl_tls.h" +#endif + +OSCL_COND_EXPORT_REF OSCL_INLINE void _OSCL_Abort() +{ + abort(); +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base.cpp new file mode 100644 index 0000000..d66d77b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base.cpp @@ -0,0 +1,118 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_base.h" +#include "oscl_defalloc.h" +#include "oscl_dll.h" +#include "oscl_tls.h" +#include "oscl_singleton.h" +#include "oscl_base_alloc.h" + + + +OSCL_EXPORT_REF int32 OsclBase::Init() +{ + { + _OsclBasicAllocator alloc; + int32 error; + OsclTLSRegistry::initialize(alloc, error); + //exit on error + if (error) + return error; + } + return 0; +} + +OSCL_EXPORT_REF int32 OsclBase::Cleanup() +{ + int32 result = 0; + { + _OsclBasicAllocator alloc; + int32 error; + OsclTLSRegistry::cleanup(alloc, error); + //continue if error + if (error) + result = error; + } + //return the last error encountered. + return result; +} + +void PVOsclBase_Init() +{ + OsclBase::Init(); +} + +void PVOsclBase_Cleanup() +{ + OsclBase::Cleanup(); +} + +OSCL_DLL_ENTRY_POINT_DEFAULT() + + +#if(OSCL_HAS_BASIC_LOCK) +// +// _OsclBasicLock +// +#include "oscl_lock_base.h" + +OSCL_EXPORT_REF _OsclBasicLock::_OsclBasicLock() +{ + iError = 0; + + + int result = pthread_mutex_init(&ObjLock, NULL); + if (result != 0) + iError = result; + +} + +OSCL_EXPORT_REF _OsclBasicLock::~_OsclBasicLock() +{ + + int result = pthread_mutex_destroy(&ObjLock); + if (result != 0) + iError = result; + +} + + +OSCL_EXPORT_REF void _OsclBasicLock::Lock() +{ + + int result = pthread_mutex_lock(&ObjLock); + if (result != 0) + iError = result; + +} + + +OSCL_EXPORT_REF void _OsclBasicLock::Unlock() +{ + + + int result = pthread_mutex_unlock(&ObjLock); + if (result != 0) + iError = result; + +} +#endif //OSCL_HAS_BASIC_LOCK + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base.h new file mode 100644 index 0000000..6bc7b4c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base.h @@ -0,0 +1,164 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ B A S E + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_base.h + \brief The file oscl_base.h is the public header that should be included to pick up the platform configuration, basic type definitions, and common macros.*/ + + +#ifndef OSCL_BASE_H_INCLUDED +#define OSCL_BASE_H_INCLUDED + +#include "osclconfig.h" +#include "oscl_base_macros.h" +#include "oscl_types.h" +#include "osclconfig_check.h" + +#include "pv_config.h" + +//singleton support derives from global var support. +#define OSCL_HAS_SINGLETON_SUPPORT 1 + +#ifdef __cplusplus + +class OsclLockBase; + +class OsclBase +{ + public: + /** + * Initializes OsclBase functionality. + * OsclBase must be initialized before any OsclBase + * functionality can be used. + * + * Note: The first call to OsclBase::Init will initialize + * the thread lock that is used to avoid thread contention + * for process scope singleton access. The last call to + * OsclBase::Cleanup will cleanup the thread lock. + * Case should be taken to avoid possible thread contention + * on the first Init and the last Cleanup call. + * + * @return 0 on success + */ + OSCL_IMPORT_REF static int32 Init(); + + /** + * Cleanup OsclBase functionality + * OsclBase should be cleaned once OsclBase + * functions are no longer needed + * @return 0 on success + */ + OSCL_IMPORT_REF static int32 Cleanup(); +}; + +/** +//OsclBase error codes. These values are used as return codes for OsclBase, OsclTLSRegistry, +//and OsclSingletonRegistry. +//Maintenance note: _OsclBaseToErrorMap in oscl_error must match this list +*/ +enum TPVBaseErrorEnum +{ + EPVErrorBaseNotInstalled = 1 + , EPVErrorBaseAlreadyInstalled = 2 + , EPVErrorBaseOutOfMemory = 3 + , EPVErrorBaseSystemCallFailed = 4 + , EPVErrorBaseTooManyThreads = 5 +}; + +#include "oscl_lock_base.h" + +/** + * _OsclBasicLock is a simple thread lock class for internal use by + * OsclTLSRegistry and OsclSingleton. + * Higher-level code should use OsclMutex instead. + */ +#if (OSCL_HAS_BASIC_LOCK) +class _OsclBasicLock : public OsclLockBase +{ + public: + + /** + * Class constructor. + */ + OSCL_IMPORT_REF _OsclBasicLock(); + + /** + * Class destructor + */ + OSCL_IMPORT_REF ~_OsclBasicLock(); + + /** + * Takes the lock + * + */ + OSCL_IMPORT_REF void Lock(); + + /** + * Releases the lock + * + */ + OSCL_IMPORT_REF void Unlock(); + + + /** + * Set to non-zero on error + */ + int32 iError; + + private: + TOsclBasicLockObject ObjLock; + +}; +#else +typedef OsclNullLock _OsclBasicLock; +#endif + +#else + +/** + * Initializes OsclBase functionality. + * OsclBase must be initialized before any OsclBase + * functionality can be used. + * + * @exception leaves if out-of-memory + */ +void PVOsclBase_Init(); + +/** + * Cleanup OsclBase functionality + * OsclBase should be cleaned once OsclBase + * functions are no longer needed + */ +void PVOsclBase_Cleanup(); + +#endif + +/*! @} */ + +#endif // OSCL_BASE_H_INCLUDED diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base_alloc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base_alloc.h new file mode 100644 index 0000000..9f315ea --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base_alloc.h @@ -0,0 +1,68 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ B A S E _ A L L O C + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_base_alloc.h + \brief A basic allocator that does not rely on other modules +*/ + + +#ifndef OSCL_BASE_ALLOC_H_INCLUDED +#define OSCL_BASE_ALLOC_H_INCLUDED + +#include "osclconfig.h" +#include "oscl_defalloc.h" +#include "osclconfig_memory.h" + +/** A basic allocator that does not rely on other modules. + * There is no memory auditing or exception generation. + * + * Note: this allocator is for internal use by Oscl code only. + * Higher level code should use OsclMemAllocator defined in + * "oscl_mem.h". + */ +class _OsclBasicAllocator: public Oscl_DefAlloc +{ + public: + OsclAny* allocate(const uint32 size) + { + return malloc(size); + } + + void deallocate(OsclAny *p) + { + free(p); + } + + virtual ~_OsclBasicAllocator() {} +}; + +/*! @} */ + +#endif // OSCL_BASE_H_INCLUDED diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base_macros.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base_macros.h new file mode 100644 index 0000000..30fc868 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_base_macros.h @@ -0,0 +1,159 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L B A S E _ M A C R O S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_base_macros.h + \brief This file defines common macros and constants for basic compilation support. +*/ + +#ifndef OSCL_BASE_MACROS_H_INCLUDED +#define OSCL_BASE_MACROS_H_INCLUDED + +// Pick up any platform-specific definitions for the common +// macros. +#include "osclconfig.h" + +// Define default values for the common macros +#ifndef OSCL_EXPORT_REF +#define OSCL_EXPORT_REF +#endif + +#ifndef OSCL_IMPORT_REF +#define OSCL_IMPORT_REF +#endif + +//! The NULL_TERM_CHAR is used to terminate c-style strings. +//static const char NULL_TERM_CHAR = '\0'; +#ifndef NULL_TERM_CHAR +#define NULL_TERM_CHAR '\0' +#endif + +//! if the NULL macro isn't already defined, then define it as zero. +#ifndef NULL +#define NULL (0) +#endif + +#if (OSCL_DISABLE_INLINES) +#define OSCL_INLINE +#define OSCL_COND_EXPORT_REF OSCL_EXPORT_REF +#define OSCL_COND_IMPORT_REF OSCL_IMPORT_REF +#else +#define OSCL_INLINE inline +#define OSCL_COND_EXPORT_REF +#define OSCL_COND_IMPORT_REF +#endif + +//this macro may not be defined in all configurations +//so a default is defined here. + +//! Type casting macros +/*! + \param type Destination type of cast + \param exp Expression to cast +*/ + +#define OSCL_CONST_CAST(type,exp) ((type)(exp)) +#define OSCL_STATIC_CAST(type,exp) ((type)(exp)) +#define OSCL_REINTERPRET_CAST(type,exp) ((type)(exp)) +#define OSCL_DYNAMIC_CAST(type, exp) ((type)(exp)) +#define OSCL_VIRTUAL_BASE(type) type + + +/** + * The following two macros are used to avoid compiler warnings. + * + * OSCL_UNUSED_ARG(vbl) is used to "reference" an otherwise unused + * parameter or variable, often one which is used only in an + * OSCL_ASSERT and thus unreferenced in release mode + * OSCL_UNUSED_RETURN(val) provides a "return" of a value, in places + * which will not actually be executed, such as after an + * OSCL_LEAVE or Thread::exit or abort. The value needs to + * be of an appropriate type for the current function, though + * zero will usually suffice. Note that OSCL_UNUSED_RETURN + * will not be necessary for 'void' functions, as there is no + * requirement for a value-return operation. + */ +#define OSCL_UNUSED_ARG(vbl) (void)(vbl) +#define OSCL_UNUSED_RETURN(value) return value + +/* The __TFS__ macro is used to optionally expand to "<>" depending on the + * compiler. Some compilers require it to indicate that the friend function + * is a template function as specified in the standard, but others don't + * like it so it will handled with a macro expansion that depends on the + * compiler. + */ +#ifndef __TFS__ +#define __TFS__ +#endif + +#define OSCL_MIN(a,b) ((a) < (b) ? (a) : (b)) +#define OSCL_MAX(a,b) ((a) > (b) ? (a) : (b)) +#define OSCL_ABS(a) ((a) > (0) ? (a) : -(a)) + +// the syntax for explicitly calling the destructor varies on some platforms +// below is the default syntax as defined in the C++ standard +#ifndef OSCL_TEMPLATED_DESTRUCTOR_CALL +#define OSCL_TEMPLATED_DESTRUCTOR_CALL(type,simple_type) type :: ~simple_type () +#endif + + +/* + * The OSCL_UNSIGNED_CONST macro is used to optionally add a suffix to the + * end of integer constants to identify them as unsigned constants. It is + * usually only necessary to do that for very large constants that are too + * big to fit within the range of a signed integer. Some compilers will issue + * warnings for that. The default behavior will be to add no suffix. + */ + +#ifndef OSCL_UNSIGNED_CONST +#define OSCL_UNSIGNED_CONST(x) x +#endif + +/* + * These macros are used by MTP to avoid byte aligning structures. + */ +#ifndef OSCL_PACKED_VAR +#define OSCL_PACKED_VAR "error" +#endif + + +/* The following macros enumerate the possible values of the build flag PV_COMPILER */ + +#define EPV_ARM_GNUC 1 /* for GNU compiler */ +#define EPV_ARM_RVCT 2 /* for RVCT compiler from ARM */ +#define EPV_ARM_MSEVC 3 /* for MS Embedded VC compiler */ + +/* PV_COMPILER value must be set to build command. + In addition, PV_CPU_ARCH_VERSION must be defined to take on an integer value that specifies the version of target + ARM architecture. */ + + +/*! @} */ + +#endif // OSCL_BASE_MACROS_H_INCLUDED diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_byte_order.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_byte_order.cpp new file mode 100644 index 0000000..759956e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_byte_order.cpp @@ -0,0 +1,34 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// B Y T E O R D E R U T I L S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \file byte_order_utils.cpp This file defines functions providing byte ordering utility. +Implementor's note: These four functions are all identical in their implementation except for the ifdefs. +We could probably move all the common code into one function and call it from each of the four? +*/ +#include "oscl_byte_order.h" + +#if (OSCL_DISABLE_INLINES) +#include "oscl_byte_order.inl" +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_byte_order.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_byte_order.h new file mode 100644 index 0000000..12f53f2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_byte_order.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L B Y T E O R D E R U T I L S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_byte_order.h + \brief This file defines functions providing byte ordering utility (e.g., switching between big and little endian orders). +*/ + + +#ifndef OSCL_BYTE_ORDER_H_INCLUDED +#define OSCL_BYTE_ORDER_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + + +//! Convert little endian to host format. +/*! + This function takes a buffer of data which is assumed to be in little endian order and + rearranges it to the native order of the machine running the code. If the machine is a + little endian machine, nothing is done. + \param data A pointer to the input/output buffer + \param size The number of bytes in the buffer. +*/ +void little_endian_to_host(char *data, uint32 size); + +//! Convert host to little endian format. +/*! + This function takes a buffer of data which is assumed to be in the host's native order and + rearranges it to the little endian format. If the machine is a little endian machine, nothing is done. + \param data A pointer to the input/output buffer + \param size The number of bytes in the buffer. +*/ +void host_to_little_endian(char *data, unsigned int size); + +//! Convert big endian to host format. +/*! + This function takes a buffer of data which is assumed to be in big endian order and + rearranges it to the native order of the machine running the code. If the machine is a + big endian machine, nothing is done. + \param data A pointer to the input/output buffer + \param size The number of bytes in the buffer. +*/ +void big_endian_to_host(char *data, unsigned int size); + +//! Convert host to big endian format. +/*! + This function takes a buffer of data which is assumed to be in native host order and + rearranges it to big endian format. If the machine is a big endian machine, nothing is done. + \param data A pointer to the input/output buffer + \param size The number of bytes in the buffer. +*/ +void host_to_big_endian(char *data, unsigned int size); + +#if (!OSCL_DISABLE_INLINES) +#include "oscl_byte_order.inl" +#endif + +/*! @} */ + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_byte_order.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_byte_order.inl new file mode 100644 index 0000000..76eaed9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_byte_order.inl @@ -0,0 +1,138 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// B Y T E O R D E R U T I L S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \file byte_order_utils.inl This file defines functions providing byte ordering utility. +*/ + +//! Convert little endian to host format. +/*! + This function takes a buffer of data which is assumed to be in little endian order and + rearranges it to the native order of the machine running the code. If the machine is a + little endian machine, nothing is done. + \param data A pointer to the input/output buffer + \param size The number of bytes in the buffer. +*/ + +#if !(OSCL_BYTE_ORDER_LITTLE_ENDIAN) && !(OSCL_BYTE_ORDER_BIG_ENDIAN) +#error must define either OSCL_BYTE_ORDER_LITTLE_ENDIAN or OSCL_BYTE_ORDER_BIG_ENDIAN +#elif (OSCL_BYTE_ORDER_LITTLE_ENDIAN) && (OSCL_BYTE_ORDER_BIG_ENDIAN) +#error must only define one of OSCL_BYTE_ORDER_LITTLE_ENDIAN, OSCL_BYTE_ORDER_BIG_ENDIAN +#endif + +//! Swap the order of bytes. +/*! + This function takes a buffer of data and reverses the order of the bytes. + \param data A pointer to the input/output buffer + \param size The number of bytes in the buffer. +*/ +OSCL_INLINE void swap_byte_order(char *data, unsigned int size) +{ + char tmp; + char *ptr1, *ptr2; + + ptr1 = data; + ptr2 = data + size - 1; + + while (ptr1 < ptr2) + { + tmp = *ptr1; + *ptr1++ = *ptr2; + *ptr2-- = tmp; + } + +} + + + + +OSCL_INLINE void little_endian_to_host(char *data, uint32 size) +{ +#if (OSCL_BYTE_ORDER_BIG_ENDIAN) + swap_byte_order(data, size); +#else + OSCL_UNUSED_ARG(data); // to remove warning 'unreferenced parameter + OSCL_UNUSED_ARG(size); // to remove warning 'unreferenced parameter + // data=data; size=size; +#endif +} + + + +//! Convert host to little endian format. +/*! + This function takes a buffer of data which is assumed to be in the host's native order and + rearranges it to the little endian format. If the machine is a little endian machine, nothing is done. + \param data A pointer to the input/output buffer + \param size The number of bytes in the buffer. +*/ +OSCL_INLINE void host_to_little_endian(char *data, unsigned int size) +{ +#if (OSCL_BYTE_ORDER_BIG_ENDIAN) + swap_byte_order(data, size); +#else + OSCL_UNUSED_ARG(data); // to remove warning 'unreferenced parameter + OSCL_UNUSED_ARG(size); // to remove warning 'unreferenced parameter +#endif +} + +//! Convert big endian to host format. +/*! + This function takes a buffer of data which is assumed to be in big endian order and + rearranges it to the native order of the machine running the code. If the machine is a + big endian machine, nothing is done. + \param data A pointer to the input/output buffer + \param size The number of bytes in the buffer. +*/ +OSCL_INLINE void big_endian_to_host(char *data, unsigned int size) +{ +#if (OSCL_BYTE_ORDER_LITTLE_ENDIAN) + swap_byte_order(data, size); +#else + OSCL_UNUSED_ARG(data); // to remove warning 'unreferenced parameter + OSCL_UNUSED_ARG(size); // to remove warning 'unreferenced parameter +#endif + +} + + +//! Convert host to big endian format. +/*! + This function takes a buffer of data which is assumed to be in native host order and + rearranges it to big endian format. If the machine is a big endian machine, nothing is done. + \param data A pointer to the input/output buffer + \param size The number of bytes in the buffer. +*/ +OSCL_INLINE void host_to_big_endian(char *data, unsigned int size) +{ +#if (OSCL_BYTE_ORDER_LITTLE_ENDIAN) + swap_byte_order(data, size); +#else + OSCL_UNUSED_ARG(data); // to remove warning 'unreferenced parameter + OSCL_UNUSED_ARG(size); // to remove warning 'unreferenced parameter +#endif + + +} + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_defalloc.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_defalloc.h new file mode 100644 index 0000000..d0b5a12 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_defalloc.h @@ -0,0 +1,221 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ D E F A L L O C + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + +/*! \file oscl_defalloc.h + \brief The file defines simple default memory allocator classes. These allocators are used by the Oscl_Vector and Oscl_Map class, etc. +*/ + + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#define OSCL_DEFALLOC_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + +#ifndef OSCL_MEM_INST_H_INCLUDED +#include "oscl_mem_inst.h" +#endif + +//A macro for using the Oscl_Alloc or Oscl_DefAlloc call with file name and +//line number inputs to aid memory auditing. +#if(PVMEM_INST_LEVEL>0) +#define ALLOCATE(n) allocate_fl(n,__FILE__,__LINE__) +#else +#define ALLOCATE(n) allocate(n) +#endif + +//A macro for using the Oscl_TAlloc call with file name and line number inputs +//to aid memory auditing. +#if(PVMEM_INST_LEVEL>0) +#define ALLOC_AND_CONSTRUCT(n) alloc_and_construct_fl(n,__FILE__,__LINE__) +#else +#define ALLOC_AND_CONSTRUCT(n) alloc_and_construct(n) +#endif + +class Oscl_Alloc +{ + public: + virtual ~Oscl_Alloc() {} + virtual OsclAny* allocate(const uint32 size) = 0; + + //Allocator with file name and line number inputs to aid memory auditing. + //This call should be used in cases where the allocation will invoke + //the Oscl memory manager. + //A default implementation is provided for use with allocators that don't + //invoke Oscl memory manager. + virtual OsclAny* allocate_fl(const uint32 size, const char * file_name, const int line_num) + { + OSCL_UNUSED_ARG(file_name); + OSCL_UNUSED_ARG(line_num); + return allocate(size); + } +}; + +class Oscl_Dealloc +{ + public: + virtual void deallocate(OsclAny* p) = 0; + virtual ~Oscl_Dealloc() {} +}; + + +class Oscl_DefAlloc : public Oscl_Alloc, public Oscl_Dealloc +{ + public: + virtual OsclAny* allocate(const uint32 size) = 0; + + //Allocator with file name and line number inputs to aid memory auditing. + //This call should be used in cases where the allocation will invoke + //the Oscl memory manager. + //A default implementation is provided for use with allocators that don't + //invoke Oscl memory manager. + virtual OsclAny* allocate_fl(const uint32 size, const char * file_name, const int line_num) + { + OSCL_UNUSED_ARG(file_name); + OSCL_UNUSED_ARG(line_num); + return allocate(size); + } + virtual void deallocate(OsclAny* p) = 0; +}; + + +class OsclDestructDealloc +{ + public: + virtual ~OsclDestructDealloc() {} + virtual void destruct_and_dealloc(OsclAny* ptr) = 0; +}; + +class OsclAllocDestructDealloc + : public OsclDestructDealloc, public Oscl_DefAlloc +{ + + public: + virtual ~OsclAllocDestructDealloc() {}; +}; + +template +class Oscl_TAlloc : public OsclDestructDealloc +{ + public: + typedef T value_type; + typedef T * pointer; + typedef const T * const_pointer; + typedef uint32 size_type; + typedef T& reference; + typedef const T& const_reference; + + virtual ~Oscl_TAlloc() {}; + + //this is the preferred call-- with file and line number recorded by + //the caller. It can be invoked with the ALLOCATE macro. + pointer allocate_fl(uint32 size , const char * file_name, const int line_num) + { + OsclAny* tmp = alloc.allocate_fl(size * sizeof(value_type), file_name, line_num); + return OSCL_STATIC_CAST(pointer, tmp); + } + + pointer allocate(uint32 size) + { + OsclAny* tmp = alloc.allocate_fl(size * sizeof(value_type), NULL, 0); + return OSCL_STATIC_CAST(pointer, tmp); + } + + //this is the preferred call-- with file and line number recorded by + //the caller. It can be invoked by the ALLOC_AND_CONSTRUCT macro. + pointer alloc_and_construct_fl(const_reference val, const char * file_name, const int line_num) + { + OsclAny* tmp = alloc.allocate_fl(sizeof(value_type), file_name, line_num); + construct(OSCL_STATIC_CAST(pointer, tmp), val); + return OSCL_STATIC_CAST(pointer, tmp); + } + + pointer alloc_and_construct(const_reference val) + { + //note: recording file & line # here is not useful-- the caller + //should provide them. Just pass zero to aid debugging. + OsclAny* tmp = alloc.allocate_fl(sizeof(value_type), NULL, 0); + construct(OSCL_STATIC_CAST(pointer, tmp), val); + return OSCL_STATIC_CAST(pointer, tmp); + } + + void deallocate(OsclAny* p) + { + alloc.deallocate(p); + } + + void deallocate(OsclAny* p, size_type n) + { + OSCL_UNUSED_ARG(n); + alloc.deallocate(p); + } + + void destruct_and_dealloc(OsclAny* p) + { + destroy(OSCL_STATIC_CAST(pointer, p)); + deallocate(p); + } + + pointer address(reference r) + { + return &r; + } + const_pointer address(const_reference r) const + { + return &r; + } + + void construct(pointer p, const_reference val) + { + new(p) T(val); + } + void destroy(pointer p) + { + OSCL_UNUSED_ARG(p); + p->~T(); + } + + template + struct rebind + { + typedef Oscl_TAlloc other; + }; + + private: + Alloc alloc; +}; + + +/*! @} */ + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_dll.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_dll.h new file mode 100644 index 0000000..50b30fd --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_dll.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ D L L + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/** + * @file oscl_dll.h + * @brief Defines a DLL entry point. + * + */ + +#ifndef OSCL_DLL_H_INCLUDED +#define OSCL_DLL_H_INCLUDED + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +/** + * DLL entry/exit point. + * + * Allows you to define custom operations at the + * entry and exit of the DLL. Place this macro + * within one souce file for each DLL. + * + * Functions with the custom commands for the + * DLL entry and exit point must also be defined. + * The entry point custom function is LocalDllEntry(), + * and the exit point custom function is LocalDllExit(). + * + * These functions will be called as a result of + * executing this macro. + * + * Usage : + * + * LocalDllEntry() { + * custom operations... + * } + * + * LocalDllExit() { + * custom operations... + * } + * + * OSCL_DLL_ENTRY_POINT() + * + */ +#define OSCL_DLL_ENTRY_POINT() void oscl_dll_entry_point() {} + + +/** + * Default DLL entry/exit point function. + * + * The body of the DLL entry point is given. The macro + * only needs to be declared within the source file. + * + * Usage : + * + * OSCL_DLL_ENTRY_POINT_DEFAULT() + */ + +#define OSCL_DLL_ENTRY_POINT_DEFAULT() + + + +/*! @} */ + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_exclusive_ptr.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_exclusive_ptr.h new file mode 100644 index 0000000..e3ffd86 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_exclusive_ptr.h @@ -0,0 +1,475 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E X C L U S I V E _ P T R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + + +/** + * @file oscl_exclusive_ptr.h + * @brief This file defines the OsclExclusivePtr template class. This class is + * used to avoid any potential memory leaks that may arise while returning + * from methods in case of error. + * + */ + +#ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED +#define OSCL_EXCLUSIVE_PTR_H_INCLUDED + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +/** + * @brief The OsclExclusivePtr class is a template class that defines a pointer + * like object intended to be assigned an address obtanined (directly or + * or indirectly) by new. When the OsclExclusivePtr expires, its destructor + * uses delete to free the memory. + * + * The purpose of this class is to provide a way to prevent accidental memory + * leaks in a class or a method, due to "not remembering to delete" variables + * allocated on the heap. Thus if you assign an address returned by new to an + * OsclExclusivePtr object, you don't have to remember to free the memory later, + * it will be freed automatically when the object goes out of scope. + * The OsclExclusivePtr is an example of a smart pointer, an object that acts like + * a pointer, but with additional features. The class is defined so that it acts + * like a regular pointer in most respects + * + */ + +template class OsclExclusivePtr +{ + protected: + T* _Ptr; + + public: + + /** + * @brief Default constructor + * Initializes the pointer and takes ownership. + */ + explicit OsclExclusivePtr(T* inPtr = 0) : _Ptr(inPtr) {}; + + /** + * @brief Copy constructor + * + * Initializes the pointer and takes ownership from another OsclExclusivePtr. + * Note that the other class does NOT own the pointer any longer, and + * hence it is NOT its responsibility to free it. + */ + OsclExclusivePtr(OsclExclusivePtr& _Y): _Ptr(_Y.release()) {}; + + + /** + * @brief Assignment operator from an another OsclExclusivePtr + * + * @param _Y The value parameter should be another OsclExclusivePtr + * @returns Returns a reference to this OsclExclusivePtr instance with + * pointer initialized. + * @pre The input class should be non-null and should point to + * a valid pointer. + * + * This assignment operator initializes the class to the contents + * of the OsclExclusivePtr given as the input parameter. The ownership + * of the pointer is transferred. + */ + OsclExclusivePtr& operator=(OsclExclusivePtr& _Y) + { + if (this != &_Y) + { + if (_Ptr != _Y.get()) + { + delete _Ptr; + } + _Ptr = _Y.release(); + } + return (*this); + } + + /** + * @brief Destructor + * + * The pointer is deleted in case this class still has ownership + */ + virtual ~OsclExclusivePtr() + { + if (_Ptr) + delete _Ptr; + } + + /** + * @brief The indirection operator (*) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclExclusivePtr can be used like the + * regular pointer that it was initialized with. + */ + T& operator*() const + { + return (*get()); + } + + /** + * @brief The indirection operator (->) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclExclusivePtr can be used like the + * regular pointer that it was initialized with. + */ + T *operator->() const + { + return (get()); + } + + /** + * @brief get() method returns the pointer, currently owned by the class. + * + */ + T *get() const + { + return (_Ptr); + } + + /** + * @brief release() method releases ownership of the pointer, currently owned + * by the class. It returns the pointer as well. + * + */ + T *release() + { + T *tmp = _Ptr; + _Ptr = NULL; + return (tmp); + } + + /** + * @brief set() method sets ownership to the pointer, passed. + * This method is needed when the class is created with a default + * constructor. Returns false in case the class is non-empty. + * + */ + bool set(T* ptr) + { + if ((_Ptr == NULL)) + { + _Ptr = ptr; + return true; + } + return false; + } + +}; + +/** + * @brief The OsclExclusiveArrayPtr class is a template class that defines an array pointer + * like object intended to be assigned an address obtanined (directly or + * or indirectly) by new. When the OsclExclusiveArrayPtr expires, its destructor + * uses delete to free the memory. + * + * The purpose of this class is to provide a way to prevent accidental memory + * leaks in a class or a method, due to "not remembering to delete" variables + * allocated on the heap. Thus if you assign an address returned by new to an + * OsclExclusivePtr object, you don't have to remember to free the memory later, + * it will be freed automatically when the object goes out of scope. + * The OsclExclusivePtr is an example of a smart pointer, an object that acts like + * a pointer, but with additional features. The class is defined so that it acts + * like a regular pointer in most respects + * + */ +template class OsclExclusiveArrayPtr +{ + protected: + T* _Ptr; + + public: + + /** + * @brief Default constructor + * Initializes the pointer and takes ownership. + */ + explicit OsclExclusiveArrayPtr(T* inPtr = 0) : _Ptr(inPtr) {}; + + /** + * @brief Copy constructor + * + * Initializes the pointer and takes ownership from another OsclExclusiveArrayPtr. + * Note that the other class does NOT own the pointer any longer, and + * hence it is NOT its responsibility to free it. + */ + OsclExclusiveArrayPtr(OsclExclusiveArrayPtr& _Y): _Ptr(_Y.release()) {}; + + + /** + * @brief Assignment operator from an another OsclExclusiveArrayPtr + * + * @param _Y The value parameter should be another OsclExclusiveArrayPtr + * @returns Returns a reference to this OsclExclusiveArrayPtr instance with + * pointer initialized. + * @pre The input class should be non-null and should point to + * a valid pointer. + * + * This assignment operator initializes the class to the contents + * of the OsclExclusiveArrayPtr given as the input parameter. The ownership + * of the pointer is transferred. + */ + OsclExclusiveArrayPtr& operator=(OsclExclusiveArrayPtr& _Y) + { + if (this != &_Y) + { + if (_Ptr != _Y.get()) + { + delete [] _Ptr; + } + _Ptr = _Y.release(); + } + return (*this); + } + + /** + * @brief Destructor + * + * The pointer is deleted in case this class still has ownership + */ + virtual ~OsclExclusiveArrayPtr() + { + if (_Ptr) + delete [] _Ptr; + } + + /** + * @brief The indirection operator (*) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclExclusiveArrayPtr can be used like the + * regular pointer that it was initialized with. + */ + T& operator*() const + { + return (*get()); + } + + /** + * @brief The indirection operator (->) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclExclusiveArrayPtr can be used like the + * regular pointer that it was initialized with. + */ + T *operator->() const + { + return (get()); + } + + /** + * @brief get() method returns the pointer, currently owned by the class. + * + */ + T *get() const + { + return (_Ptr); + } + + /** + * @brief release() method releases ownership of the pointer, currently owned + * by the class. It returns the pointer as well. + * + */ + T *release() + { + T *tmp = _Ptr; + _Ptr = NULL; + return (tmp); + } + + /** + * @brief set() method sets ownership to the pointer, passed. + * This method is needed when the class is created with a default + * constructor. Returns false in case the class is non-empty. + * + */ + bool set(T* ptr) + { + if ((_Ptr == NULL)) + { + _Ptr = ptr; + return true; + } + return false; + } + +}; + + +/** + * @brief The OsclExclusivePtrA class is a template class that defines any pointer + * like object intended to be assigned an address obtanined (directly or + * or indirectly) through Alloc. When the OsclExclusivePtrA expires, Alloc + * is used to free the memory. + * + * The purpose of this class is to provide a way to prevent accidental memory + * leaks in a class or a method, due to "not remembering to delete" variables + * allocated on the heap. Thus if you assign an address returned by new to an + * OsclExclusivePtr object, you don't have to remember to free the memory later, + * it will be freed automatically when the object goes out of scope. + * The OsclExclusivePtr is an example of a smart pointer, an object that acts like + * a pointer, but with additional features. The class is defined so that it acts + * like a regular pointer in most respects + * + */ +template class OsclExclusivePtrA +{ + protected: + T* _Ptr; + + public: + + /** + * @brief Default constructor + * Initializes the pointer and takes ownership. + */ + explicit OsclExclusivePtrA(T* inPtr = 0) : _Ptr(inPtr) {}; + + /** + * @brief Copy constructor + * + * Initializes the pointer and takes ownership from another OsclExclusiveArrayPtr. + * Note that the other class does NOT own the pointer any longer, and + * hence it is NOT its responsibility to free it. + */ + OsclExclusivePtrA(OsclExclusivePtrA& _Y): _Ptr(_Y.release()) {}; + + + /** + * @brief Assignment operator from an another OsclExclusiveArrayPtr + * + * @param _Y The value parameter should be another OsclExclusiveArrayPtr + * @returns Returns a reference to this OsclExclusiveArrayPtr instance with + * pointer initialized. + * @pre The input class should be non-null and should point to + * a valid pointer. + * + * This assignment operator initializes the class to the contents + * of the OsclExclusiveArrayPtr given as the input parameter. The ownership + * of the pointer is transferred. + */ + OsclExclusivePtrA& operator=(OsclExclusivePtrA& _Y) + { + if (this != &_Y) + { + if (_Ptr != _Y.get()) + { + defAlloc.deallocate(_Ptr); + } + _Ptr = _Y.release(); + } + return (*this); + } + + /** + * @brief Destructor + * + * The pointer is deleted in case this class still has ownership + */ + virtual ~OsclExclusivePtrA() + { + defAlloc.deallocate(_Ptr); + } + + /** + * @brief The indirection operator (*) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclExclusiveArrayPtr can be used like the + * regular pointer that it was initialized with. + */ + T& operator*() const + { + return (*get()); + } + + /** + * @brief The indirection operator (->) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclExclusiveArrayPtr can be used like the + * regular pointer that it was initialized with. + */ + T *operator->() const + { + return (get()); + } + + /** + * @brief get() method returns the pointer, currently owned by the class. + * + */ + T *get() const + { + return (_Ptr); + } + + /** + * @brief release() method releases ownership of the pointer, currently owned + * by the class. It returns the pointer as well. + * + */ + T *release() + { + T *tmp = _Ptr; + _Ptr = NULL; + return (tmp); + } + + /** + * @brief set() method sets ownership to the pointer, passed. + * This method is needed when the class is created with a default + * constructor. Returns false in case the class is non-empty. + * + */ + bool set(T* ptr) + { + if ((_Ptr == NULL)) + { + _Ptr = ptr; + return true; + } + return false; + } + + private: + Oscl_TAlloc defAlloc; +}; + +/*! @} */ + + +#endif //OSCL_EXCLUSIVE_PTR_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_int64_utils.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_int64_utils.cpp new file mode 100644 index 0000000..69dc04d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_int64_utils.cpp @@ -0,0 +1,66 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "osclconfig.h" +#include "oscl_int64_utils.h" + +OSCL_EXPORT_REF void Oscl_Int64_Utils::set_int64(int64& input_value, const int32 upper, const uint32 lower) +{ + input_value = (int64)((int64(upper) << 32) | lower); +}; + + +OSCL_EXPORT_REF int32 Oscl_Int64_Utils::get_int64_upper32(const int64& input_value) +{ + return (int32)((input_value >> 32) & 0xFFFFFFFF); +}; + + +OSCL_EXPORT_REF uint32 Oscl_Int64_Utils::get_int64_lower32(const int64& input_value) +{ + return (uint32)((input_value) & 0xFFFFFFFF); +}; + + +OSCL_EXPORT_REF uint32 Oscl_Int64_Utils::get_int64_middle32(const int64& input_value) +{ + return (uint32)((input_value >> 16) & 0xFFFFFFFF); +}; + + +OSCL_EXPORT_REF void Oscl_Int64_Utils::set_uint64(uint64& input_value, const uint32 upper, const uint32 lower) +{ + input_value = (uint64)((uint64(upper) << 32) | lower); +}; + + +OSCL_EXPORT_REF uint32 Oscl_Int64_Utils::get_uint64_upper32(const uint64& input_value) +{ + return (uint32)((input_value >> 32) & 0xFFFFFFFF); +}; + + +OSCL_EXPORT_REF uint32 Oscl_Int64_Utils::get_uint64_lower32(const uint64& input_value) +{ + return (uint32)((input_value) & 0xFFFFFFFF); +}; + + +OSCL_EXPORT_REF uint32 Oscl_Int64_Utils::get_uint64_middle32(const uint64& input_value) +{ + return (uint32)((input_value >> 16) & 0xFFFFFFFF); +}; diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_int64_utils.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_int64_utils.h new file mode 100644 index 0000000..6786ced --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_int64_utils.h @@ -0,0 +1,67 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_INT64_UTILS_H_INCLUDED +#define OSCL_INT64_UTILS_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +//! The Oscl_Int64_Utils class provides a wrapper for commonly used int64/uint64 operations +/*! + * The Oscl_Int64_Utils class: + * + * Provides a wrapper for commonly used operations to mask the differences between OSes + * that have an int64/uint64 class instead of a 64-bit integer. + */ +class Oscl_Int64_Utils +{ + public: + OSCL_IMPORT_REF static void set_int64(int64& input_value, const int32 upper, const uint32 lower); + + OSCL_IMPORT_REF static int32 get_int64_upper32(const int64& input_value); + + OSCL_IMPORT_REF static uint32 get_int64_lower32(const int64& input_value); + + OSCL_IMPORT_REF static uint32 get_int64_middle32(const int64& input_value); + + OSCL_IMPORT_REF static void set_uint64(uint64& input_value, const uint32 upper, const uint32 lower); + + OSCL_IMPORT_REF static uint32 get_uint64_upper32(const uint64& input_value); + + OSCL_IMPORT_REF static uint32 get_uint64_lower32(const uint64& input_value); + + OSCL_IMPORT_REF static uint32 get_uint64_middle32(const uint64& input_value); +}; + +/** + * OsclInteger64Transport Structure + * + * Structure to only transport 64-bit integer values + * uint64 and int64 could be classes so needed for cases + * where having a class will not work. + */ +typedef struct OsclInteger64Transport +{ + uint32 iHigh; + uint32 iLow; +} _OsclInteger64Transport; + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_linked_list.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_linked_list.cpp new file mode 100644 index 0000000..179714a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_linked_list.cpp @@ -0,0 +1,423 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_linked_list.h" + + + +OSCL_EXPORT_REF void Oscl_Linked_List_Base::construct(Oscl_Opaque_Type_Alloc_LL* op) +{ + num_elements = 0; + head = tail = iterator = NULL; + pOpaqueType = op; +} + +OSCL_EXPORT_REF void Oscl_Linked_List_Base::destroy() +{ + OsclAny* tmp; + while (num_elements && head) + { + tmp = pOpaqueType->get_next(head); + pOpaqueType->destroy(head); + pOpaqueType->deallocate(head); + --num_elements; + head = tmp; + } + head = tail = iterator = NULL; +} + +/** + * Return the first element of list in passed parameter, + * @param ele return the value of first element of list in this parameter + * @return 32-bit interger,If first element found, it returns 1 + * otherwise it returns 0 + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::get_first(OsclAny* ele) +{ + if (!head) return 0; + iterator = head; + pOpaqueType->get_data(iterator, ele); + return 1; +}; + +/** + * Return the next element of list in passed parameter, + * @param ele return the value of next element of list in this parameter + * @return 32-bit interger ,if next element is found in list,it returns 1 + * otherwise it returns 0 + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::get_next(OsclAny* ele) +{ + if (iterator == tail) return 0; + if (! iterator) + { + if (!head) return 0; + iterator = head; + } + else + { + iterator = pOpaqueType->get_next(iterator); + } + pOpaqueType->get_data(iterator, ele); + return 1; +}; + +/** + * Debug routine: Checks the list for elements. + * @return 32-bit integer, if node count is equal to number of node added + * to the list then returns 1 otherwise returns 0. + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::check_list() +{ + OsclAny *tmp; + + int32 ii; + for (tmp = head, ii = 0; tmp ; ++ii) + tmp = pOpaqueType->get_next(tmp); + + return (ii == num_elements); +} + +/** + * Adds new element to the list.if list is already there then it adds element at end of list otherwise + * it create the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::add_element(const OsclAny* new_element) +{ + if (!tail) + { + OsclAny* ptr = pOpaqueType->allocate(sizeof_T); + pOpaqueType->construct(ptr, new_element); + head = tail = ptr; + if (head == NULL) + return 0; // Memory Allocation Error + } + else + { + OsclAny* ptr = pOpaqueType->allocate(sizeof_T); + pOpaqueType->construct(ptr, new_element); + pOpaqueType->set_next(tail, ptr); + if (pOpaqueType->get_next(tail) == NULL) + return 0; // Memory Allocation Error + tail = pOpaqueType->get_next(tail); + } + + ++num_elements; + return 1; +} + +/** + * Adds new element at the start of the list.if list is already + * exist then it adds element at start of list otherwise + * it create the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::add_to_front(const OsclAny* new_element) +{ + if (!head) + { + OsclAny* ptr = pOpaqueType->allocate(sizeof_T); + pOpaqueType->construct(ptr, new_element); + head = tail = ptr; + if (head == NULL) + return 0; // Memory Allocation Error + } + else + { + OsclAny* ptr = pOpaqueType->allocate(sizeof_T); + pOpaqueType->construct(ptr, new_element); + if (ptr == NULL) + return 0; // Memory Allocation Error + pOpaqueType->set_next(ptr, head); + head = ptr; + } + ++num_elements; + return 1; +} + +/** + * Search and returs the element in the list for passed index. + * @param index, element The index is the count for the node. + * @return 32-bit integer on success returns 1 otherwise returns 0. + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::get_element(int32 index, OsclAny* element) +{ + + OsclAny *tmp; + int32 ii; + + if (index < 0 || index >= num_elements) + { + return 0; + } + + for (tmp = head, ii = 0; ii < index; ++ii, tmp = pOpaqueType->get_next(tmp)) + { + } + + pOpaqueType->get_data(tmp, element); + return 1; +} + +/** + * Removes the element from the list. + * @param data_to_remove + * @return 32-bit integer on if element fount in the list returns 1 otherwise returns 0. + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::remove_element(const OsclAny* data_to_remove) +{ + OsclAny *tmp; + OsclAny *prev; + int32 found = 0; + + for (tmp = head, prev = NULL; tmp; prev = tmp, tmp = pOpaqueType->get_next(tmp)) + { + + if (pOpaqueType->compare_data(tmp, data_to_remove)) + { + found = 1; + if (prev) + { + pOpaqueType->set_next(prev, pOpaqueType->get_next(tmp)); + if (iterator == tmp) iterator = prev; + } + else + { + head = pOpaqueType->get_next(tmp); + if (iterator == tmp) iterator = NULL; + } + if (tmp == tail) + { + tail = prev; + } + pOpaqueType->destroy(tmp); + pOpaqueType->deallocate(tmp); + --num_elements; + break; + } + + } + return found; +} + +/** + * Returns the index for requested element. + * @param data the element for which index to be return. + * @return 32-bit integer if data is found in the list it returns index + * otherwise it returns -1. + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::get_index(const OsclAny* data) +{ + OsclAny *tmp; + int32 index = 0; + int32 found = 0; + + for (tmp = head, index = 0; tmp; tmp = pOpaqueType->get_next(tmp), ++index) + { + + if (pOpaqueType->compare_data(tmp, data)) + { + found = 1; + break; + } + } + if (found) + return index; + + return -1; +} + +/** + * Removes the element for requested index. + * @param index_to_remove + * @return on success return 1 otherwise return 0. + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::remove_element(const int32 index_to_remove) +{ + OsclAny *tmp; + OsclAny *prev; + int32 ii; + + if (index_to_remove < 0 || index_to_remove >= num_elements) + { + return 0; + } + + // skip to desired element + for (tmp = head, prev = NULL, ii = 0; tmp && ii < index_to_remove; + ++ii, prev = tmp, tmp = pOpaqueType->get_next(tmp)) + { + } + + if (ii != index_to_remove) + { + return 0; + } + + if (prev) + { + pOpaqueType->set_next(prev, pOpaqueType->get_next(tmp)); + if (iterator == tmp) iterator = prev; + } + else + { + head = pOpaqueType->get_next(tmp); + if (iterator == tmp) iterator = NULL; + } + if (tmp == tail) + { + tail = prev; + } + + pOpaqueType->destroy(tmp); + pOpaqueType->deallocate(tmp); + --num_elements; + + return 1; +} + +/** + * Moves the element to end of the list + * @param data_to_move + * @return On success returns 1 otherwise returns 0. + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::move_to_end(const OsclAny* data_to_move) +{ + OsclAny *tmp; + OsclAny *prev; + uint32 found = 0; + + for (tmp = head, prev = NULL; tmp; prev = tmp, tmp = pOpaqueType->get_next(tmp)) + { + + if (pOpaqueType->compare_data(tmp, data_to_move)) + { + found = 1; + if (tmp == tail) + { + return 1; // nothing to do + } + if (prev) + { + pOpaqueType->set_next(prev, pOpaqueType->get_next(tmp)); + if (iterator == tmp) iterator = prev; + } + if (tmp == head) + { + head = pOpaqueType->get_next(tmp); + if (iterator == tmp) iterator = NULL; + } + pOpaqueType->set_next(tail, tmp); + pOpaqueType->set_next(tmp, NULL); + tail = tmp; + + return 1; + } + } + + return 0; +} + +/** + * Moves the element to front of the list + * @param data_to_move + * @return On success returns 1 otherwise returns 0. + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::move_to_front(const OsclAny* data_to_move) +{ + OsclAny *tmp; + OsclAny *prev; + int32 found = 0; + + for (tmp = head, prev = NULL; tmp; prev = tmp, tmp = pOpaqueType->get_next(tmp)) + { + + if (pOpaqueType->compare_data(tmp, data_to_move)) + { + found = 1; + if (tmp == head) + { + return 1; // nothing to do + } + + if (prev) + { + pOpaqueType->set_next(prev, pOpaqueType->get_next(tmp)); + + if (iterator == tmp) + { + iterator = prev; + } + } + + if (tmp == tail) + { + tail = prev; + } + pOpaqueType->set_next(tmp, head); + head = tmp; + + return 1; + } + } + + return 0; +} + + + +/** + * Inserts new element in the list. If the index is past the end of + * the list + * it creates the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ +OSCL_EXPORT_REF int32 Oscl_Linked_List_Base::insert_element(const OsclAny* new_element, int index) +{ + if (index >= num_elements) + { + return add_element(new_element); + } + else if (index == 0) + { + return add_to_front(new_element); + } + else + { + OsclAny *tmp, *next, *newelem; + int32 ii; + if (index < 0) + return 0; + for (tmp = head, ii = 0; ii < index - 1; ++ii, tmp = pOpaqueType->get_next(tmp)) + { } + + next = pOpaqueType->get_next(tmp); + newelem = pOpaqueType->allocate(sizeof_T); + if (newelem == NULL) + return 0; + pOpaqueType->construct(newelem, new_element); + pOpaqueType->set_next(tmp, newelem); + pOpaqueType->set_next(newelem, next); + ++num_elements; + return 1; + } + return 0; +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_linked_list.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_linked_list.h new file mode 100644 index 0000000..62c6940 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_linked_list.h @@ -0,0 +1,605 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ L I N K E D _ L I S T + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_linked_list.h + \brief The file oscl_linked_list.h defines the template class Oscl_Linked_List which has a very similar API as the STL Vector class (it basically provides a subset of the STL functionality). Memory allocation is abstracted through the use of an allocator template parameter. +*/ + +#ifndef OSCL_LINKED_LIST_H_INCLUDED +#define OSCL_LINKED_LIST_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif +#ifndef OSCL_OPAQUE_TYPE_H_INCLUDED +#include "oscl_opaque_type.h" +#endif +#ifndef OSCL_ASSERT_H_INCLUDED +#include "oscl_assert.h" +#endif + + +/** + * oscl_linked_list supports random access to elements, constant time insertion + * and removal of elements from the list, and linear time + * insertion and removal of elements at the beginning or middle of the + * list. The number of elements in a list can vary dynamically, and + * memory management is performed using new and delete operators. + */ + +template class Oscl_Linked_List; +/** + * Linked List Element Class + */ +template class LinkedListElement +{ + + public: + LinkedListElement(LLClass in_data) + { + data = in_data; + next = NULL; + }; + // ~LinkedListElement() {}; + +// friend class Oscl_Linked_List; + LinkedListElement* next; + LLClass data; + + private: +}; + +/** + * Oscl Linked List Base Class. A non-templated base class is used to avoid + * large inline functions in the Oscl_Linked_List implementation. + */ +class Oscl_Linked_List_Base +{ + protected: + virtual ~Oscl_Linked_List_Base() + {} + + OSCL_IMPORT_REF void construct(Oscl_Opaque_Type_Alloc_LL* op); + + OSCL_IMPORT_REF void destroy(); + + /** + * Return the first element of list in passed parameter, + * @param ele return the value of first element of list in this parameter + * @return 32-bit interger,If first element found, it returns 1 + * otherwise it returns 0 + */ + OSCL_IMPORT_REF int32 get_first(OsclAny* ele); + + /** + * Return the next element of list in passed parameter, + * @param ele return the value of next element of list in this parameter + * @return 32-bit interger ,if next element is found in list,it returns 1 + * otherwise it returns 0 + */ + OSCL_IMPORT_REF int32 get_next(OsclAny* ele); + + /** + * Debug routine: Checks the list for elements. + * @return 32-bit integer, if node count is equal to number of node added + * to the list then returns 1 otherwise returns 0. + */ + OSCL_IMPORT_REF int32 check_list(); + + /** + * Adds new element to the list.if list is already there then it adds element at end of list otherwise + * it create the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ + OSCL_IMPORT_REF int32 add_element(const OsclAny* new_element); + + /** + * Adds new element at the start of the list.if list is already + * exist then it adds element at start of list otherwise + * it create the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ + OSCL_IMPORT_REF int32 add_to_front(const OsclAny* new_element); + + /** + * Inserts new element in the list. If the index is past the end of + * the list + * it creates the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ + OSCL_IMPORT_REF int32 insert_element(const OsclAny* new_element, int index); + + /** + * Search and returs the element in the list for passed index. + * @param index, element The index is the count for the node. + * @return 32-bit integer on success returns 1 otherwise returns 0. + */ + OSCL_IMPORT_REF int32 get_element(int32 index, OsclAny* element); + + /** + * Removes the element from the list. + * @param data_to_remove + * @return 32-bit integer on if element fount in the list returns 1 otherwise returns 0. + */ + OSCL_IMPORT_REF int32 remove_element(const OsclAny* data_to_remove); + + /** + * Returns the index for requested element. + * @param data the element for which index to be return. + * @return 32-bit integer if data is found in the list it returns index + * otherwise it returns -1. + */ + OSCL_IMPORT_REF int32 get_index(const OsclAny* data); + + /** + * Removes the element for requested index. + * @param index_to_remove + * @return on success return 1 otherwise return 0. + */ + OSCL_IMPORT_REF int32 remove_element(const int32 index_to_remove); + + /** + * Moves the element to end of the list + * @param data_to_move + * @return On success returns 1 otherwise returns 0. + */ + OSCL_IMPORT_REF int32 move_to_end(const OsclAny* data_to_move); + + /** + * Moves the element to front of the list + * @param data_to_move + * @return On success returns 1 otherwise returns 0. + */ + OSCL_IMPORT_REF int32 move_to_front(const OsclAny* data_to_move); + + OsclAny *head; + OsclAny *tail; + OsclAny *iterator; + int32 num_elements; + uint32 sizeof_T; + + private: + Oscl_Opaque_Type_Alloc_LL* pOpaqueType; +}; + +/** + * Oscl Linked List Class + */ +template class Oscl_Linked_List + : public Oscl_Linked_List_Base + , public Oscl_Opaque_Type_Alloc_LL +{ + + public: + /** + * Initialized the protected variables of list. + */ + Oscl_Linked_List(): Oscl_Linked_List_Base(), Oscl_Opaque_Type_Alloc_LL() + { + sizeof_T = sizeof(LinkedListElement); + Oscl_Linked_List_Base::construct(this); + } + + /** + * The destructor. + */ + ~Oscl_Linked_List() + { + Oscl_Linked_List_Base::destroy(); + } + + void clear() + { + Oscl_Linked_List_Base::destroy(); + } + + int32 dequeue_element(LLClass & element) + { + get_element(0, element); + return remove_element((int32) 0); + } + // get_first() and get_next() together provide iterator function + + /** + * Return the first element of list in passed parameter, + * @param ele return the value of first element of list in this parameter + * @return 32-bit interger,If first element found, it returns 1 + * otherwise it returns 0 + */ + int32 get_first(LLClass & ele) + { + return Oscl_Linked_List_Base::get_first(&ele); + } + + /** + * Return the next element of list in passed parameter, + * @param ele return the value of next element of list in this parameter + * @return 32-bit interger ,if next element is found in list,it returns 1 + * otherwise it returns 0 + */ + int32 get_next(LLClass & ele) + { + return Oscl_Linked_List_Base::get_next(&ele); + } + + /** + * Debug routine: Checks the list for elements. + * @return 32-bit integer, if node count is equal to number of node added + * to the list then returns 1 otherwise returns 0. + */ + int32 check_list() + { + return Oscl_Linked_List_Base::check_list(); + } + + /** + * Get number of elements in the list. + * @return 32-bit integer, number of elements in list. + */ + int32 get_num_elements() + { + return num_elements; + } + + /** + * Adds new element to the list.if list is already there then it adds element at end of list otherwise + * it create the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ + int32 add_element(LLClass& new_element) + { + return Oscl_Linked_List_Base::add_element(&new_element); + } + + /** + * Adds new element at the start of the list.if list is already + * exist then it adds element at start of list otherwise + * it create the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ + int32 add_to_front(const LLClass& new_element) + { + return Oscl_Linked_List_Base::add_to_front(&new_element); + } + /** + * Inserts new element in the list. If the index is past the end of + * the list + * it creates the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ + int32 insert_element(const LLClass& new_element, int index) + { + return Oscl_Linked_List_Base::insert_element(&new_element, index); + } + + /** + * Search and returs the element in the list for passed index. + * @param index, element The index is the count for the node. + * @return 32-bit integer on success returns 1 otherwise returns 0. + */ + int32 get_element(int32 index, LLClass& element) + { + return Oscl_Linked_List_Base::get_element(index, &element); + } + + /** + * Removes the element from the list. + * @param data_to_remove + * @return 32-bit integer on if element fount in the list returns 1 otherwise returns 0. + */ + int32 remove_element(const LLClass& data_to_remove) + { + return Oscl_Linked_List_Base::remove_element(&data_to_remove); + } + + /** + * Returns the index for requested element. + * @param data the element for which index to be return. + * @return 32-bit integer if data is found in the list it returns index + * otherwise it returns -1. + */ + int32 get_index(const LLClass& data) + { + return Oscl_Linked_List_Base::get_index(&data); + } + + /** + * Removes the element for requested index. + * @param index_to_remove + * @return on success return 1 otherwise return 0. + */ + int32 remove_element(const int32 index_to_remove) + { + return Oscl_Linked_List_Base::remove_element(index_to_remove); + } + + /** + * Moves the element to end of the list + * @param data_to_move + * @return On success returns 1 otherwise returns 0. + */ + int32 move_to_end(const LLClass& data_to_move) + { + return Oscl_Linked_List_Base::move_to_end(&data_to_move); + } + + /** + * Moves the element to front of the list + * @param data_to_move + * @return On success returns 1 otherwise returns 0. + */ + int32 move_to_front(const LLClass& data_to_move) + { + return Oscl_Linked_List_Base::move_to_front(&data_to_move); + } + + + private: + + //from Oscl_Opaque_Type_Alloc_LL + void construct(OsclAny* p, const OsclAny* init_val) + { + OSCL_ASSERT(init_val); + OSCL_ASSERT(p); + new(p) LinkedListElement(*(LLClass*)init_val); + } + + //this typedef is needed to avoid compile errors ADS 1.2 compiler. + typedef LinkedListElement* p_elem_type; + + //from Oscl_Opaque_Type_Alloc_LL + void destroy(OsclAny* p) + { + OSCL_ASSERT(p); + ((p_elem_type)p)->~LinkedListElement(); + } + + //from Oscl_Opaque_Type_Alloc_LL + OsclAny* allocate(const uint32 size) + { + return alloc.ALLOCATE(size); + } + + //from Oscl_Opaque_Type_Alloc_LL + void deallocate(OsclAny* p) + { + alloc.deallocate(p); + } + + //from Oscl_Opaque_Type_Alloc_LL + OsclAny* get_next(const OsclAny* elem)const + { + return ((LinkedListElement*)elem)->next; + } + + //from Oscl_Opaque_Type_Alloc_LL + void set_next(OsclAny* elem, const OsclAny* nextelem) + { + OSCL_ASSERT(elem); + ((LinkedListElement*)elem)->next = (LinkedListElement*)nextelem; + } + + //from Oscl_Opaque_Type_Alloc_LL + void get_data(OsclAny*elem, OsclAny*data_val) + { + OSCL_ASSERT(elem); + OSCL_ASSERT(data_val); + *((LLClass*)data_val) = ((LinkedListElement*)elem)->data ; + } + + //from Oscl_Opaque_Type_Alloc_LL + bool compare_data(const OsclAny*elem, const OsclAny*data_val)const + { + OSCL_ASSERT(elem); + OSCL_ASSERT(data_val); + return ((LinkedListElement*)elem)->data == *((LLClass*)data_val); + } + + Alloc alloc; + +}; + +/** + * Oscl_MTLinked_List is a multi-threaded version of + * the LinkedList. It has mutex protection to + * allow access by different threads. + */ +template class Oscl_MTLinked_List +{ + + public: + /** + * Constructor for Oscl_MTLinked_List + */ + Oscl_MTLinked_List() {}; + + /** + * Destructor for Oscl_MTLinked_List + */ + ~Oscl_MTLinked_List() {}; + + int32 dequeue_element(LLClass & element) + { + int32 status; + TheLock Mylock; + Mylock.Lock(); + status = the_list.dequeue_element(element); + Mylock.Unlock(); + return status; + } + + /** + * Adds new element to the Multi Threaded Linked list.if list + * is already there then it adds element at end of list otherwise + * it create the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ + int32 add_element(LLClass& new_element) + { + int32 status; + TheLock Mylock; + Mylock.Lock(); + status = the_list.add_element(new_element); + Mylock.Unlock(); + return status; + } + + /** + * Adds new element at the start of the Multi Threaded Linked list. + * if list is already exist then it adds element at start of list otherwise + * it create the list and add the element as first element of list. + * @param new_element the element to be add in the list. + * @return 32-bit integer on the success returns 1. + */ + int32 add_to_front(LLClass& new_element) + { + int32 status; + TheLock Mylock; + Mylock.Lock(); + status = the_list.add_to_front(new_element); + Mylock.Unlock(); + return status; + } + + /** + * Search and returs the element in the Multi Treaded Linked List + * for passed index. + * @param index, element The index is the count for the node. + * @return 32-bit integer on success returns 1 otherwise returns 0. + */ + uint32 get_element(int32 index, LLClass& element) + { + + int32 status; + TheLock Mylock; + Mylock.Lock(); + status = the_list.get_element(index, element); + Mylock.Unlock(); + return status; + } + + /** + * Removes the element from the list. + * @param data_to_remove + * @return 32-bit integer on if element fount in the list returns 1 otherwise returns 0. + */ + int32 remove_element(const LLClass& data_to_remove) + { + int32 status; + TheLock Mylock; + Mylock.Lock(); + status = the_list.remove_element(data_to_remove); + Mylock.Unlock(); + return status; + } + + /** + * Returns the index for requested element. + * @param data the element for which index to be return. + * @return 32-bit integer if data is found in the list it returns index + * otherwise it returns -1. + */ + int32 get_index(const LLClass& data) + { + int32 status; + TheLock Mylock; + Mylock.Lock(); + status = the_list.get_index(data); + Mylock.Unlock(); + return status; + } + + /** + * Removes the element for requested index. + * @param index_to_remove + * @return on success return 1 otherwise return 0. + */ + int32 remove_element(const int32 index_to_remove) + { + int32 status; + TheLock Mylock; + Mylock.Lock(); + status = the_list.remove_element(index_to_remove); + Mylock.Unlock(); + return status; + } + + /** + * Moves the element to end of the list + * @param data_to_move + * @return On success returns 1 otherwise returns 0. + */ + int32 move_to_end(const LLClass& data_to_move) + { + int32 status; + TheLock Mylock; + Mylock.Lock(); + status = the_list.move_to_end(data_to_move); + Mylock.Unlock(); + return status; + } + + /** + * Moves the element to front of the list + * @param data_to_move + * @return On success returns 1 otherwise returns 0. + */ + int32 move_to_front(const LLClass& data_to_move) + { + int32 status; + TheLock Mylock; + Mylock.Lock(); + status = the_list.move_to_front(data_to_move); + Mylock.Unlock(); + return status; + } + + protected: + Oscl_Linked_List the_list; +// PVMutex mutex; + +}; + + +/*! @} */ + + +#endif // __LINKED_LIST_H + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_lock_base.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_lock_base.h new file mode 100644 index 0000000..99d17d7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_lock_base.h @@ -0,0 +1,150 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ L O C K _ B A S E + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_lock_base.h + * \brief This file defines an abstract lock class, OsclLockBase, + * that is used for APIs potentially requiring multi-thread safety. + * A null-lock implementation, OsclNullLock, is also provided for + * single-thread configurations (basically a noop for lock/unlock). + * Also provides the OsclScopedLock class which is template class + * takes care of freeing the lock when the class goes out of scope. +*/ + +#ifndef OSCL_LOCK_BASE_H_INCLUDED +#define OSCL_LOCK_BASE_H_INCLUDED + + +class OsclLockBase +{ + + public: + virtual void Lock() = 0; + virtual void Unlock() = 0; + virtual ~OsclLockBase() {} + +}; + +class OsclNullLock: public OsclLockBase +{ + + public: + virtual void Lock() {}; + virtual void Unlock() {}; + virtual ~OsclNullLock() {} + +}; + + + +/** + * @brief The OsclScopedLock class is a template class that handles unlocking + * an abstract class on destruction. This is very useful for ensuring that + * the lock is released when the OsclScopedLock goes out of scope. + * + * The purpose of this class is to provide a way to prevent accidental resource + * leaks in a class or a method, due to "not remembering to unlock" variables + * which might lead to deadlock conditions. + * + */ + +template class OsclScopedLock +{ + private: + LockClass* _Ptr; + + // make copy constructor private so no default is created. + /** + * @brief Copy constructor + * + * Initializes the pointer and takes ownership from another oscl_auto_ptr. + * Note that the other class does NOT own the pointer any longer, and + * hence it is NOT its responsibility to free it. + */ + OsclScopedLock(const OsclScopedLock&) {} + + + /** + * @brief release() method releases ownership of the pointer, currently owned + * by the class. It returns the pointer as well. + * + */ + void release() + { + if (_Ptr) + { + _Ptr->Unlock(); + _Ptr = NULL; + } + } + + + /** + * @brief acquire() method acquires ownership of the lock. + * + */ + void acquire() + { + if (_Ptr) + { + _Ptr->Lock(); + } + } + + + public: + + /** + * @brief Default constructor + * Initializes the pointer and takes ownership. + */ + explicit OsclScopedLock(LockClass& inLock) : _Ptr(&inLock) + { + acquire(); + }; + + /** + * @brief Destructor + * + * The pointer is deleted in case this class still has ownership + */ + ~OsclScopedLock() + { + release(); + } + + + +}; + + +/*! @} */ + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_map.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_map.h new file mode 100644 index 0000000..ffda878 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_map.h @@ -0,0 +1,345 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M A P + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_map.h + \brief The file oscl_map.h defines the template class Oscl_Map which has a very similar API as the STL Map class (it basically provides a subset of the STL functionality). Memory allocation is abstracted through the use of an allocator template parameter. +*/ + +#ifndef OSCL_MAP_H_INCLUDED +#define OSCL_MAP_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_TREE_H_INCLUDED +#include "oscl_tree.h" +#endif + +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + +template +struct Oscl_Less +{ + bool operator()(const T& x, const T& y) const + { + return x < y ? true : false ; + } +}; + +template +struct Oscl_Select1st +{ + const U& operator()(const V& x) const + { + return x.first; + } +}; + +/** + * Oscl_Map Class. A subset of STL::Map methods. + * Oscl_Map is a sorted associative container that associates objects of type Key with objects of type T. + * It is also a unique associative container, meaning that no two elements have the same key. Oscl_Map + * uses the key to speed lookup, insertion, and deletion of elements. It is often superior to all other + * containers when you need to lookup an element by key value. Due to the underlying tree structure, + * inserts and erases can be performed in logarithmic time, where a vector would take linear time in + * some cases. + */ + +template < class Key, class T, class Alloc, class Compare = Oscl_Less > +class Oscl_Map +{ + + public: + typedef Key key_type; + typedef Compare key_compare; + typedef Oscl_Pair value_type; + typedef Oscl_Map self; + + private: + typedef Oscl_Rb_Tree < key_type, value_type, + Oscl_Select1st, + key_compare, Alloc > rep_type; + rep_type t; // red-black tree representing map + + public: + typedef typename rep_type::pointer pointer; + typedef typename rep_type::reference reference; + typedef typename rep_type::const_reference const_reference; + typedef typename rep_type::iterator iterator; + typedef typename rep_type::const_iterator const_iterator; + typedef typename rep_type::size_type size_type; + + class value_compare + { + friend class Oscl_Map; + protected : + Compare comp; + value_compare(Compare c) : comp(c) {} + public: + bool operator()(const value_type& x, const value_type& y) const + { + return comp(x.first, y.first); + } + }; + + public: + + /** + * Creates an empty map using comp as the key compare object + */ + Oscl_Map(const Compare& comp = Compare()) : t(comp) {} +// Oscl_Map(const value_type* first, const value_type* last, +// const Compare& comp = Compare()) : t(first, last, comp, false) {} + + /** + * Oscl_Map copy constructor + */ + Oscl_Map(const self& x) : t(x.t) {} + /** + * Oscl_Map assignment operator + */ + self& operator=(const self& x) + { + t = x.t; + return *this; + } + /** + * Returns the key compare object used by the map + */ + key_compare key_comp() const + { + return t.key_comp(); + } + /** + * Returns the value compare object used by the map + */ + value_compare value_comp() const + { + return value_compare(t.key_comp()); + } + /** + * Returns an iterator pointing to the beginning of the map + */ + iterator begin() + { + return t.begin(); + } + /** + * Returns a const iterator pointing to the beginning of the map + */ + const_iterator begin() const + { + return t.begin(); + } + /** + * Returns an iterator pointing to the end of the map. + */ + iterator end() + { + return t.end(); + } + /** + * Returns a const iterator pointing to the end of the map. + */ + const_iterator end() const + { + return t.end(); + } + /** + * Returns true if map size is 0 + */ + bool empty() const + { + return t.empty(); + } + /** + * Returns the size of the map + */ + size_type size() const + { + return t.size(); + } + /** + * Returns the maximum possible size of the map + */ + size_type max_size() const + { + return t.max_size(); + } + /** + * Returns a reference to the object that is associated with a particular key. + * If the map does not already contain such an object, operator[] inserts the default object value_type(). + */ + T& operator[](const key_type& k) + { + return (*((insert(value_type(k, T()))).first)).second; + } +// void swap(map& x) { t.swap(x.t); } + + + typedef Oscl_Pair pair_iterator_bool; + /** + * Inserts x into the map + */ + pair_iterator_bool insert(const value_type& x) + { + return t.insert_unique(x); + } + /** + * Inserts x into the map using position as a hint as to where it should be inserted + */ + iterator insert(iterator position, const value_type& x) + { + return t.insert_unique(position, x); + } + /** + * Inserts the range [first,last) into the map + */ + void insert(const value_type* first, const value_type* last) + { + t.insert_unique(first, last); + } + /** + * Erases the element pointed to by position + */ + void erase(iterator position) + { + t.erase(position); + } + /** + * Erases the element with key x + */ + size_type erase(const key_type& x) + { + return t.erase(x); + } + /** + * Erases all elements in the range [first,last) + */ + void erase(iterator first, iterator last) + { + t.erase(first, last); + } + /** + * Erases all elements + */ + void clear() + { + t.clear(); + } + /** + * Finds an element whose key is x + */ + iterator find(const key_type& x) + { + return t.find(x); + } + /** + * Finds an element whose key is x + */ + const_iterator find(const key_type& x) const + { + return t.find(x); + } + /** + * Returns the number of elements with key x. For map this will either be 0 or 1. + */ + size_type count(const key_type& x) const + { + return t.count(x); + } + /** + * Finds the first element whose key is not less than x + */ + iterator lower_bound(const key_type& x) + { + return t.lower_bound(x); + } + /** + * Finds the first element whose key is not less than x + */ + const_iterator lower_bound(const key_type& x) const + { + return t.lower_bound(x); + } + /** + * Finds the first element whose key is not greater than x + */ + iterator upper_bound(const key_type& x) + { + return t.upper_bound(x); + } + /** + * Finds the first element whose key is not greater than x + */ + const_iterator upper_bound(const key_type& x) const + { + return t.upper_bound(x); + } + typedef Oscl_Pair pair_iterator_iterator; + /** + * Finds a range containing all elements whose key is x + */ + pair_iterator_iterator equal_range(const key_type& x) + { + return t.equal_range(x); + } + typedef Oscl_Pair pair_citerator_citerator; + /** + * Finds a range containing all elements whose key is x + */ + pair_citerator_citerator equal_range(const key_type& x) const + { + return t.equal_range(x); + } + + private: + +}; + +//template +//inline bool operator==(const map& x, +// const map& y) { +// return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +//} + +//template +//inline bool operator<(const map& x, +// const map& y) { +// return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +//} + + +/*! @} */ + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_basic_functions.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_basic_functions.cpp new file mode 100644 index 0000000..ede227a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_basic_functions.cpp @@ -0,0 +1,23 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_mem_basic_functions.h" + +#if (OSCL_DISABLE_INLINES) +#include "oscl_mem_basic_functions.inl" +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_basic_functions.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_basic_functions.h new file mode 100644 index 0000000..a61e160 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_basic_functions.h @@ -0,0 +1,183 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* -*- c++ -*- */ +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M E M _ B A S I C _ F U N C T I O N S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclmemory OSCL Memory + * + * @{ + */ + + +/*! \file oscl_mem_basic_functions.h + \brief This file contains prototypes for the basic memory functions. +*/ + +#ifndef OSCL_MEM_BASIC_FUNCTIONS_H +#define OSCL_MEM_BASIC_FUNCTIONS_H + +#ifndef OSCL_BASE_MACROS_H_INCLUDED +#include "oscl_base_macros.h" +#endif + +/* + * Note: the public oscl_malloc call has been deprecated. This + * function is for internal use by Oscl code only. Higher level + * code should include "oscl_mem.h" and use OSCL_MALLOC. + * + * Allocates a memory block. + * + * @param count number of bytes to allocate + * + * @return a void pointer to the allocated space, or NULL if there is insufficient + * memory available. + */ +OSCL_COND_IMPORT_REF void* _oscl_malloc(int32 count); + +/* + * Note: the public oscl_calloc call has been deprecated. This + * function is for internal use by Oscl code only. Higher level + * code should include "oscl_mem.h" and use OSCL_CALLOC. + * + * + * Allocates a memory block and fills with zeros. + * + * + * @param nelems number of elements of size bytes to allocate. + * @param size the size in bytes of each element + * + * the total space allocated = nelems * size bytes. + * + * @return a void pointer to the allocated space, or NULL if there is insufficient + * memory available. + */ +OSCL_COND_IMPORT_REF void* _oscl_calloc(int32 nelems, int32 size); + + +/* + * Note: the public oscl_realloc call has been deprecated. This + * function is for internal use by Oscl code only. Higher level + * code should include "oscl_mem.h" and use OSCL_REALLOC. + * + * + * Reallocates a memory block + * If src is NULL, realloc behaves the same way as oscl_malloc and allocates a new + * block of size count. + * + * @param src pointer to previously allocated memory block + * @param count number of bytes to allocate + * + * @return a void pointer to the reallocated (and possibly moved) memory block. The + * return value is NULL if the size is zero and the buffer argument is not NULL, + * or if there is not enough available memory to expand the block to the given + * size. + */ +OSCL_COND_IMPORT_REF void* _oscl_realloc(void* src, int32 count); + +/* + * Note: the public oscl_free call has been deprecated. This + * function is for internal use by Oscl code only. Higher level + * code should include "oscl_mem.h" and use OSCL_FREE. + * + * + * Deallocates or frees a memory block + * + * @param src pointer to previously allocated memory block + * + * @return + */ +OSCL_COND_IMPORT_REF void _oscl_free(void* src); + +/** + * Copies characters between buffers + * The oscl_memcpy function copies count bytes of src to dest. If the source and + * destination overlap, this function does not ensure that the original source + * bytes in the overlapping region are copied before being overwritten. Use + * oscl_memmove to handle overlapping regions + * + * @param dest new buffer + * @param src buffer to copy + * @param count number of bytes to copy + * + * @return the value of dest + */ +OSCL_COND_IMPORT_REF void* oscl_memcpy(void* dest, const void* src, uint32 count); + +/** + * Moves chars from one buffer to another + * The memmove function copies count bytes of characters from src to dest. If + * some regions of the source area and the destination overlap, memmove ensures + * that the original source bytes in the overlapping region are copied before + * being overwritten. + * + * @param dest new buffer + * @param src buffer to copy + * @param count number of bytes to copy + * + * @return the value of dest + */ +OSCL_COND_IMPORT_REF void* oscl_memmove(void* dest, const void* src, uint32 count); + +/** + * Same functionality as oscl_memmove, yet optimized for memory alligned on + * 32-bit boundary + * + * @param dest new buffer + * @param src buffer to copy + * @param count number of bytes to copy + * + * @return the value of dest + */ +OSCL_COND_IMPORT_REF void* oscl_memmove32(void* dest, const void* src, uint32 count); + +/** + * Sets the bytes of a buffer to a specified character + * + * @param dest buffer to modify + * @param val character to set + * @param count number of bytes to set + * + * @return the value of dest + */ +OSCL_COND_IMPORT_REF void* oscl_memset(void* dest, uint8 val, uint32 count); + +/** + * Compare characters in two buffers + * + * @param buf1 first buffer + * @param buf2 second buffer + * @param count number of bytes to compare + * + * @return <0 buf1 less than buf2 + * 0 buf1 equal to buf2 + * >0 buf1 greater than buf2 + */ +OSCL_COND_IMPORT_REF int oscl_memcmp(const void* buf1, const void* buf2, uint32 count); + + +#if (!OSCL_DISABLE_INLINES) +#include "oscl_mem_basic_functions.inl" +#endif + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_basic_functions.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_basic_functions.inl new file mode 100644 index 0000000..ebfeec3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_basic_functions.inl @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCL_MEM_BASIC_FUNCTIONS_INL +#define OSCL_MEM_BASIC_FUNCTIONS_INL + +#ifndef OSCLCONFIG_MEMORY_H_INCLUDED +#include "osclconfig_memory.h" +#endif + +#ifndef OSCL_MEM_BASIC_FUNCTIONS_H +#include "oscl_mem_basic_functions.h" +#endif + +// Basic memory manipulation functions +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + +OSCL_INLINE OSCL_COND_EXPORT_REF void* _oscl_malloc(int32 size) +{ + return malloc(size); +} + +OSCL_INLINE OSCL_COND_EXPORT_REF void* _oscl_realloc(void* src, int32 size) +{ + return realloc(src, size); +} + +OSCL_INLINE OSCL_COND_EXPORT_REF void* _oscl_calloc(int32 size1, int32 size2) +{ + return calloc(size1, size2); +} + +OSCL_INLINE OSCL_COND_EXPORT_REF void _oscl_free(void* src) +{ + free(src); +} + +OSCL_INLINE OSCL_COND_EXPORT_REF void* oscl_memcpy(void* dest, const void* src, uint32 count) +{ + return memcpy(dest, src, count); +} + +OSCL_INLINE OSCL_COND_EXPORT_REF void* oscl_memmove(void* dest, const void* src, uint32 count) +{ + return memmove(dest, src, count); +} + +OSCL_INLINE OSCL_COND_EXPORT_REF void* oscl_memmove32(void* dest, const void* src, uint32 count) +{ + return memmove(dest, src, count); +} + +OSCL_INLINE OSCL_COND_EXPORT_REF void* oscl_memset(void* dest, uint8 val, uint32 count) +{ + return memset(dest, val, count); +} + +OSCL_INLINE OSCL_COND_EXPORT_REF int oscl_memcmp(const void* dest, const void* src, uint32 count) +{ + return memcmp(dest, src, count); +} + +#endif /*OSCL_MEM_BASIC_FUNCTIONS_INL*/ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_inst.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_inst.h new file mode 100644 index 0000000..96101ad --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_mem_inst.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M E M _ I N S T . H + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + +/*! \file oscl_mem_inst.h + \brief The file defines default memory instrumentation level. +*/ + + +#ifndef OSCL_MEM_INST_H_INCLUDED +#define OSCL_MEM_INST_H_INCLUDED + +#ifndef OSCLCONFIG_MEMORY_H_INCLUDED +#include "osclconfig_memory.h" +#endif + +/* +** PVMEM_INST_LEVEL controls the instrumentation level for +** memory leak tracking. Detailed memory leak information (file +** and line # of each allocation) is compiled in or out depending +** on the level. This information is an aid to debugging memory leaks, +** but compiling it in will increase code size and run-time overhead. +** +** Values are as follows +** PVMEM_INST_LEVEL 0 -- detailed memory leak reporting information +** is compiled out. +** PVMEM_INST_LEVEL 1 -- detailed memory leak reporting information +** is compiled in. +** +** The value can be defined in the osclconfig_memory.h file for the platform. +** In case PVMEM_INST_LEVEL is not defined for the platform, default +** values are defined here. +*/ +#ifndef PVMEM_INST_LEVEL +#if (OSCL_RELEASE_BUILD) +/* release mode-- no instrumentation */ +#define PVMEM_INST_LEVEL 0 +#else +/* debug mode-- full instrumentation */ +#define PVMEM_INST_LEVEL 1 +#endif +#endif + +/* +** When bypassing the Oscl memory manager, instrumentation +** is not needed, so should always be compiled out. +*/ +#if(OSCL_BYPASS_MEMMGT) +#undef PVMEM_INST_LEVEL +#define PVMEM_INST_LEVEL 0 +#endif + + +/*! @} */ + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_opaque_type.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_opaque_type.h new file mode 100644 index 0000000..84b37bc --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_opaque_type.h @@ -0,0 +1,159 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ O P A Q U E _ T Y P E + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * Additional osclbase comment + * @{ + */ + +/*! \file oscl_opaque_type.h + \brief The file oscl_opaque_type.h defines pure virtual classes for working + with opaque types. +*/ + +#ifndef OSCL_OPAQUE_TYPE_H_INCLUDED +#define OSCL_OPAQUE_TYPE_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + + + +/** + * This class combines opaque type operations with memory allocation operations. + */ +class Oscl_Opaque_Type_Alloc +{ + public: + virtual ~Oscl_Opaque_Type_Alloc() {} + + /** + * Construct element at p using element at init_val as the initial value. + * Both pointers must be non-NULL. + */ + virtual void construct(OsclAny* p, const OsclAny* init_val) = 0; + + /** + * Destroy element at p. + */ + virtual void destroy(OsclAny* p) = 0; + + /** + * Allocate "size" bytes + */ + virtual OsclAny* allocate(const uint32 size) = 0; + + /** + * Deallocate memory previously allocated with "allocate" + */ + virtual void deallocate(OsclAny* p) = 0; +}; + +/** + * Opaque type operations with swap & comparisons. + */ +class Oscl_Opaque_Type_Compare +{ + public: + virtual ~Oscl_Opaque_Type_Compare() {} + + /** + * Swap element at "a" with element at "b". + * Both pointers must be non-NULL. + */ + virtual void swap(OsclAny* a, const OsclAny* b) = 0; + + /** + * Return a bufsize) + { + OsclAny* newElems = pOpaqueType->allocate(n * sizeof_T); + // transfer old contents using normal operations on (this) queue + // constructing new copy in "new__" variables. Note that data + // won't wrap here, so ok to just use [i++]. + uint32 i = 0; + while (! empty()) + { + pOpaqueType->construct(increment_T(newElems, i++), front()); + pop(); + } + if (elems) + { + pOpaqueType->deallocate(elems); + } + // now set new values + elems = newElems; + bufsize = n; + numelems = i; + ifront = 0; + irear = numelems > 0 ? ifront + numelems - 1 : bufsize - 1; + } +} + +OSCL_EXPORT_REF void Oscl_Queue_Base::construct(Oscl_Opaque_Type_Alloc* aType) +{ + numelems = 0; + bufsize = 0; + elems = NULL; + pOpaqueType = aType; +} + +OSCL_EXPORT_REF void Oscl_Queue_Base::construct(Oscl_Opaque_Type_Alloc* aType, uint32 n) +{ + numelems = 0; + bufsize = n; + pOpaqueType = aType; + elems = pOpaqueType->allocate(n * sizeof_T); +} + +OSCL_EXPORT_REF void Oscl_Queue_Base::destroy() +{ + if (elems) + { + clear(); + pOpaqueType->deallocate(elems); + elems = NULL; + numelems = 0; + bufsize = 0; + } +} + +OSCL_EXPORT_REF void Oscl_Queue_Base::push(const OsclAny* x) +{ + if (numelems == bufsize) + { + // increase to 1.25x previous size, but at least +4 + uint32 new_bufsize = bufsize + + ((bufsize > 16) ? bufsize >> 2 : 4); + reserve(new_bufsize); + } + ++irear; + if (irear >= bufsize) + { + irear = 0; // wrap around + } + + pOpaqueType->construct(increment_T(elems, irear), x); + numelems++; +} + +OSCL_EXPORT_REF void Oscl_Queue_Base::pop() +{ + OSCL_ASSERT(! empty()); + pOpaqueType->destroy(increment_T(elems, ifront)); + ifront++; + if (ifront >= bufsize) // (== check is sufficient) + { + ifront = 0; + } + numelems--; +} + +OSCL_EXPORT_REF void Oscl_Queue_Base::clear() +{ + while (! empty()) + pop(); +} + + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_queue.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_queue.h new file mode 100644 index 0000000..1333c51 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_queue.h @@ -0,0 +1,371 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- + + + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ Q U E U E +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * Additional osclbase comment + * @{ + */ + +/*! \file oscl_queue.h + \brief The file oscl_queue.h defines the template class Oscl_Queue. It is + similar to the STL::queue class, with some differences: + - less complete + - based on array rather than a deque + - some interfaces modeled on oscl_vector, for ease of transition + Memory allocation is abstracted through the use of an allocator template parameter. +*/ + +#ifndef OSCL_QUEUE_H_INCLUDED +#define OSCL_QUEUE_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_MEM_BASIC_FUNCTIONS_H_INCLUDED +#include "oscl_mem_basic_functions.h" +#endif + +#ifndef OSCL_ASSERT_H_INCLUDED +#include "oscl_assert.h" +#endif + +#ifndef OSCL_OPAQUE_TYPE_H_INCLUDED +#include "oscl_opaque_type.h" +#endif + +/** + * Oscl_Queue_Base is a non-templatized base class for Oscl_Queue. + * The purpose of this base class is to avoid large inline routines + * in the Oscl_Queue implementation. + * This class is not intended for direct instantiation except by + * Oscl_Queue. + */ +class Oscl_Queue_Base +{ + public: + + /** + * Returns the size of the queue. + */ + uint32 size() const + { + return numelems; + } + + /** + * Returns the allocated memory of the queue. + */ + uint32 capacity() const + { + return bufsize; + } + + /** + * True if there are no elements in the queue + */ + bool empty() const + { + return numelems == 0; + } + + /** + * Reallocates memory if necessary to a capacity of n elements. + * The main reason for reserve is efficiency. If you know the capacity to + * which your vector must grow, then it is more efficient to allocate the + * vector all at once rather than rely on the automatic reallocation scheme. + * This also helps cotrol the invalidation of iterators. + * @param n size of vector + */ + OSCL_IMPORT_REF void reserve(uint32 n) ; + + protected: + + //for use in default constructor. vtable is needed so this is a subroutine. + OSCL_IMPORT_REF void construct(Oscl_Opaque_Type_Alloc* aType); + + //for use in constructor with pre-allocation for "n" elements. + OSCL_IMPORT_REF void construct(Oscl_Opaque_Type_Alloc* aType, uint32 n) ; + + /** + * The destructor. + */ + virtual ~Oscl_Queue_Base() + {} + + /** + * Like an explicit destructor call. + */ + OSCL_IMPORT_REF void destroy(); + + /** + * Inserts a new element at the end. + * Queue will be grown if necessary. If allocation fails, an OSCL_LEAVE will occur + * @param x new element + */ + OSCL_IMPORT_REF void push(const OsclAny* x) ; + + /** + * Removes the first element + */ + OSCL_IMPORT_REF void pop() ; + + /** + * Removes all elements. + */ + OSCL_IMPORT_REF void clear() ; + + uint32 numelems; // number of valid entries in queue + uint32 bufsize; // size of elems + OsclAny* elems; // array holding the elements + uint32 sizeof_T; + + uint32 ifront; // front of queue: removal point + uint32 irear; // just before back of queue: increment=>insertion point + + private: + + /** + * return a T* incremented by n. + */ + OsclAny* increment_T(OsclAny* p_T, int32 n) const + { + return (OsclAny*)((int32)p_T + n*sizeof_T); + } + + /** + * Returns the first element. + */ + OsclAny* front() + { + return increment_T(elems, ifront); + } + + Oscl_Opaque_Type_Alloc* pOpaqueType; +}; + +/** + * Oscl_Queue Class. A subset of STL::Queue methods. + * Oscl_Queue supports constant time insertion (at the end) and removal of + * elements at the front of the queue. It does not support + * insertion or removal of elements at the other ends or middle of the + * queue, nor random access to elements. + * * No iteration capability is [currently] supplied. + * * No assignment or copy capability is [currently] supplied. + * The number of elements in a queue can vary dynamically, and + * memory management is performed automatically. + */ + +template +class Oscl_Queue + : public Oscl_Queue_Base + , public Oscl_Opaque_Type_Alloc +{ + + public: + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef const T& const_reference; + typedef uint32 size_type; + + /** + * Creates an empty queue. + */ + Oscl_Queue() : Oscl_Queue_Base(), Oscl_Opaque_Type_Alloc() + { + sizeof_T = sizeof(T); + Oscl_Queue_Base::construct(this); + } + + /** + * Creates an empty queue with capacity n. + * @param n creates a queue with n elements. The main reason for specifying n + * is efficiency. If you know the capacity to which your queue must grow, then + * it is more efficient to allocate the queue all at once rather than rely on + * the automatic reallocation scheme. + */ + Oscl_Queue(uint32 n) : Oscl_Queue_Base(), Oscl_Opaque_Type_Alloc() + { + sizeof_T = sizeof(T); + Oscl_Queue_Base::construct(this, n); + } + + /** + * The destructor. + */ + virtual ~Oscl_Queue() + { + Oscl_Queue_Base::destroy(); + } + + /** + * Inserts a new element at the end. + * Queue will be grown if necessary. If allocation fails, an OSCL_LEAVE will occur + * @param x new element + */ + void push(const T& x) + { + Oscl_Queue_Base::push(&x); + } + + /** + * Returns the first element. + */ + reference front() + { + OSCL_ASSERT(! empty()); + return (reference)((pointer)elems)[ifront]; + } + + /** + * Returns the first element (const) + */ + const_reference front() const + { + OSCL_ASSERT(! empty()); + return (const_reference)((pointer)elems)[ifront]; + } + + + /** + * Removes the first element + */ + void pop() + { + Oscl_Queue_Base::pop(); + } + + /** + * Returns the last element: "back" + * (generally not too useful, but some debugging aids might + * want to find out what was just added) + */ + reference back() + { + OSCL_ASSERT(! empty()); + return (reference)((pointer)elems)[irear]; + } + + /** + * Returns the last element (const) + */ + const_reference back() const + { + OSCL_ASSERT(! empty()); + return (const_reference)((pointer)elems)[irear]; + } + + /** + * Removes all elements. + */ + void clear() + { + Oscl_Queue_Base::clear(); + } + + /** + * Return various iterators + * : not provided for queues. Paradigm is FIFO + */ + + /** + * Erases the element pointed to by iterator pos. + * : not provided for queues. Paradigm is QUEUE. + */ + + private: + Alloc defAlloc; + + //from Oscl_Opaque_Type_Alloc + OsclAny* allocate(const uint32 size) + { + return defAlloc.allocate(size); + } + + //from Oscl_Opaque_Type_Alloc + void deallocate(OsclAny* p) + { + defAlloc.deallocate(p); + } + + //from Oscl_Opaque_Type_Alloc + void construct(OsclAny* p, const OsclAny* x) + { + OSCL_ASSERT(x); + new(p) value_type(*((T*)x)); + } + + //from Oscl_Opaque_Type_Alloc + void destroy(OsclAny* first) + { + OSCL_ASSERT(first); + OSCL_UNUSED_ARG(first); + //must use "pointer" instead of "T*" here to avoid ADS 1.2 compile error. + ((pointer)first)->~T(); + } + + + /*************************** + * things we don't believe are needed + * -- private definitions to block implicit ones -- + */ + + /** + * The assignment operator -- + * - private, to block use of implicit assignment + * - not actually implemented, don't believe it's needed + */ + Oscl_Queue& operator=(const Oscl_Queue& x) + { + // Do we need to copy a queue? Why...? + // .. unless there's a need, let's not bother with the + // complexity here.. + // (need something here, we don't want implicit assignment either + OSCL_UNUSED_ARG(x); + OSCL_ASSERT(false); + return *this; + } + + /** + * Copy Constructor. + * @param x queue class to copy, also for value passage as argument + * (but: why do we want to copy a queue??) + */ + Oscl_Queue(const Oscl_Queue& x) + : Oscl_Queue_Base(sizeof(T), this, this) + { + OSCL_UNUSED_ARG(x); + OSCL_ASSERT(false); + } +}; // end class oscl_queue + +/*! @} */ + + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_refcounter.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_refcounter.h new file mode 100644 index 0000000..bf620e3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_refcounter.h @@ -0,0 +1,489 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ R E F C O U N T E R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + + +/** + * @file oscl_refcounter.h + * @brief A general purpose reference counter to object lifetimes. + * + */ + +#ifndef OSCL_REFCOUNTER_H_INCLUDED +#define OSCL_REFCOUNTER_H_INCLUDED + +#ifndef OSCL_ASSERT_H_INCLUDED +#include "oscl_assert.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +/** + * Interface class for OsclRefCounter implementations + */ +class OsclRefCounter +{ + public: + /** + * Add to the reference count + */ + virtual void addRef() = 0; + + /** + * Delete from reference count + */ + virtual void removeRef() = 0; + + /** + * Gets the current number of references + */ + virtual uint32 getCount() = 0; + + virtual ~OsclRefCounter() {} +}; + + +/** + * Implementation of an OsclRefCounter that uses a dynamically + * created deallocator. + */ +class OsclRefCounterDA : public OsclRefCounter +{ + public: + + /** + * Constructor + * Takes a pointer to the buffer to track, and a pointer + * to the deallocator object which will be used to delete + * the buffer. + * + * When the reference count reaches zero, the buffer will + * be deleted by the deallocator. Also, the OsclRefCounter + * object (this) will self-destruct when the reference count + * is zero. In some cases the OsclRefCounter object will + * be part of the buffer being deleted. For such cases, + * the object pointer must be equal to the buffer pointer + * given at construction. If the object is not part of the + * buffer being deleted, it will self-destruct with a call + * to delete(). + * + * @param p pointer to the buffer to track + * @param dealloc pointer to the deallocator to use when + * deleting the buffer + */ + OsclRefCounterDA(OsclAny *p, OsclDestructDealloc *dealloc): + ptr(p), deallocator(dealloc), refcnt(1) + { + OSCL_ASSERT(ptr != NULL && deallocator != NULL); + } + + /** + * Destructor + * empty + */ + virtual ~OsclRefCounterDA() {} + + /** + * Add to the reference count + */ + void addRef() + { + ++refcnt; + } + + /** + * Remove from the reference count + */ + void removeRef() + { + if (--refcnt == 0) + { + if (ptr == this) + { + // buffer is part of the refcounter + deallocator->destruct_and_dealloc(this); + } + else + { + // delete the buffer and the refcounter object + deallocator->destruct_and_dealloc(ptr); + delete(this); + } + } + } + + /** + * Gets the current number of references + */ + uint32 getCount() + { + return refcnt; + } + + private: + OsclRefCounterDA(); + OsclRefCounterDA(const OsclRefCounterDA& x); + OsclRefCounterDA& operator=(const OsclRefCounterDA& x); + + OsclAny *ptr; + OsclDestructDealloc *deallocator; + uint32 refcnt; +}; + + +/** + * Implementation of an OsclRefCounter that uses a statically + * created deallocator. + */ +template +class OsclRefCounterSA : public OsclRefCounter +{ + public: + /** + * Constructor + * Takes a pointer to the buffer to track. + * + * When the reference count reaches zero, the buffer will + * be deleted by the deallocator. Also, the OsclRefCounter + * object (this) will self-destruct when the reference count + * is zero. In some cases the OsclRefCounter object will + * be part of the buffer being deleted. For such cases, + * the object pointer must be equal to the buffer pointer + * given at construction. If the object is not part of the + * buffer being deleted, it will self-destruct with a call + * to delete(). + * + * @param p pointer to the buffer to track + */ + OsclRefCounterSA(OsclAny *p) : + ptr(p), refcnt(1) + { + OSCL_ASSERT(ptr != NULL); + } + + /** + * Destructor + * empty + */ + virtual ~OsclRefCounterSA() {} + + /** + * Add to the reference count + */ + void addRef() + { + ++refcnt; + } + + /** + * Remove from the reference count + */ + void removeRef() + { + if (--refcnt == 0) + { + if (ptr == this) + { + + // buffer is part of the refcounter + DeallocType deallocator; + deallocator.destruct_and_dealloc(this); + } + else + { + + // delete the buffer and the recounter object + DeallocType deallocator; + deallocator.destruct_and_dealloc(ptr); + delete(this); + } + } + } + + /** + * Gets the current number of references + */ + uint32 getCount() + { + return refcnt; + } + + private: + OsclRefCounterSA(); + OsclRefCounterSA(const OsclRefCounterSA& x); + OsclRefCounterSA& operator=(const OsclRefCounterSA& x); + + OsclAny *ptr; + uint32 refcnt; +}; + +/** + * Implementation of OsclRefCounterDA for multi-threaded use. + * A templated lock class must be specified. + */ +template +class OsclRefCounterMTDA : public OsclRefCounter +{ + public: + + /** + * Constructor + * Takes a pointer to the buffer to track, and a pointer + * to the deallocator object which will be used to delete + * the buffer. + * + * When the reference count reaches zero, the buffer will + * be deleted by the deallocator. Also, the OsclRefCounter + * object (this) will self-destruct when the reference count + * is zero. In some cases the OsclRefCounter object will + * be part of the buffer being deleted. For such cases, + * the object pointer must be equal to the buffer pointer + * given at construction. If the object is not part of the + * buffer being deleted, it will self-destruct with a call + * to delete(). + * + * @param p pointer to the buffer to track + * @param dealloc pointer to the deallocator to use when + * deleting the buffer + */ + OsclRefCounterMTDA(OsclAny *p, OsclDestructDealloc *dealloc) : + ptr(p), deallocator(dealloc), refcnt(1) + { + OSCL_ASSERT(ptr != NULL && deallocator != NULL); + } + + /** + * Destructor + * empty + */ + virtual ~OsclRefCounterMTDA() {} + + /** + * Add to the reference count + */ + void addRef() + { + lock.Lock(); + ++refcnt; + lock.Unlock(); + } + + /** + * Remove from the reference count + */ + void removeRef() + { + lock.Lock(); + if (--refcnt == 0) + { + if (ptr == this) + { + + // buffer is part of the refcounter + deallocator->destruct_and_dealloc(this); + } + else + { + // delete the buffer and the refcounter object + deallocator->destruct_and_dealloc(ptr); + delete(this); + } + } + else + { + lock.Unlock(); + } + } + + /** + * Gets the current number of references + */ + uint32 getCount() + { + return refcnt; + } + + private: + OsclRefCounterMTDA(); + OsclRefCounterMTDA(const OsclRefCounterMTDA& x); + OsclRefCounterMTDA& operator=(const OsclRefCounterMTDA& x); + + OsclAny *ptr; + OsclDestructDealloc *deallocator; + LockType lock; + uint32 refcnt; +}; + + +/** + * Implementation of OsclRefCounterSA for multi-threaded use. + * A templated lock class must be specified. + */ +template +class OsclRefCounterMTSA : public OsclRefCounter +{ + public: + /** + * Constructor + * Takes a pointer to the buffer to track. + * + * When the reference count reaches zero, the buffer will + * be deleted by the deallocator. Also, the OsclRefCounter + * object (this) will self-destruct when the reference count + * is zero. In some cases the OsclRefCounter object will + * be part of the buffer being deleted. For such cases, + * the object pointer must be equal to the buffer pointer + * given at construction. If the object is not part of the + * buffer being deleted, it will self-destruct with a call + * to delete(). + * + * @param p pointer to the buffer to track + */ + OsclRefCounterMTSA(OsclAny *p) : + ptr(p), refcnt(1) + { + OSCL_ASSERT(ptr != NULL); + } + + /** + * Destructor + * empty + */ + virtual ~OsclRefCounterMTSA() {} + + /** + * Add to the reference count + */ + void addRef() + { + lock.Lock(); + ++refcnt; + lock.Unlock(); + } + + /** + * Remove from the reference count + */ + void removeRef() + { + lock.Lock(); + if (--refcnt == 0) + { + if (ptr == this) + { + // buffer is part of the refcounter + DeallocType deallocator; + deallocator.destruct_and_dealloc(this); + } + else + { + + // delete the buffer and the recounter object + DeallocType deallocator; + deallocator.destruct_and_dealloc(ptr); + delete(this); + } + } + else + { + lock.Unlock(); + } + } + + /** + * Gets the current number of references + */ + uint32 getCount() + { + return refcnt; + } + + private: + OsclRefCounterMTSA(); + OsclRefCounterMTSA(const OsclRefCounterMTSA& x); + OsclRefCounterMTSA& operator=(const OsclRefCounterMTSA& x); + + OsclAny *ptr; + LockType lock; + uint32 refcnt; +}; + +/** + Implementation of an Oscl_DefAlloc class with a + built-in ref counter. + */ +template +class Oscl_DefAllocWithRefCounter: public OsclRefCounter, public DefAlloc +{ + public: + /** Create object + */ + static Oscl_DefAllocWithRefCounter* New() + { + DefAlloc alloc; + OsclAny* p = alloc.ALLOCATE(sizeof(Oscl_DefAllocWithRefCounter)); + return new(p) Oscl_DefAllocWithRefCounter(); + } + + /** Delete object + */ + void Delete() + { + removeRef(); + } + + void addRef() + { + refcount++; + } + + void removeRef() + { + --refcount; + if (refcount == 0) + DefAlloc::deallocate(this); + } + + uint32 getCount() + { + return refcount; + } + + private: + Oscl_DefAllocWithRefCounter(): refcount(1) + {} + uint32 refcount; +}; + +/*! @} */ + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_refcounter_memfrag.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_refcounter_memfrag.h new file mode 100644 index 0000000..4871ac5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_refcounter_memfrag.h @@ -0,0 +1,214 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ R E F C O U N T E R _ M E M F R A G + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + + +/** + * @file oscl_refcounter_memfrag.h + * @brief This file provides the definition of reference counted + * memory fragment, which provides access to a buffer and helps manage + * its manage its lifetime through the refcount. + * + */ + +#ifndef OSCL_REFCOUNTER_MEMFRAG_H_INCLUDED +#define OSCL_REFCOUNTER_MEMFRAG_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_REFCOUNTER_H_INCLUDED +#include "oscl_refcounter.h" +#endif + + +/** + * Class to contain a memory fragment with it's associated + * reference counter. + */ +class OsclRefCounterMemFrag +{ + public: + + /** + * Constructor. + * A valid memory fragment and reference counter are + * required as input. The memory fragment structure + * will be copied locally. + * + * @param m reference to memory fragment + * @param r pointer to the reference counter associated with the + * memory fragment. + */ + OsclRefCounterMemFrag(OsclMemoryFragment &m, OsclRefCounter *r, + uint32 in_capacity) : + memfrag(m), refcnt(r), capacity(in_capacity) + // no need to increment refcnt--it should already be done. + {} + + /** + * Copy constructor. + */ + OsclRefCounterMemFrag(const OsclRefCounterMemFrag &x) : + memfrag(x.memfrag), refcnt(x.refcnt), capacity(x.capacity) + { + if (refcnt) + { + refcnt->addRef(); + } + } + + /** + * Default constructor. + */ + OsclRefCounterMemFrag() + { + memfrag.ptr = 0; + memfrag.len = 0; + refcnt = 0; + capacity = 0; + } + + + /** + * Assignment Operator + */ + OsclRefCounterMemFrag& operator= (const OsclRefCounterMemFrag &x) + { + if (this == &x) + { + // protect against self-assignment + return *this; + } + + // remove ref for current memfrag + if (refcnt) + { + refcnt->removeRef(); + } + + // copy assigned object + memfrag = x.memfrag; + refcnt = x.refcnt; + capacity = x.capacity; + + // add ref for new memfrag + if (refcnt) + { + refcnt->addRef(); + } + + return *this; + } + + /** + * Destructor. + * Removes this object's reference from the reference counter. + * The reference counter will not be deleted. The reference + * counter is designed to self-delete when it's reference + * count reaches 0. + */ + ~OsclRefCounterMemFrag() + { + if (refcnt) + { + refcnt->removeRef(); + } + } + + /** + * Returns a pointer to the contained reference counter + * object + */ + OsclRefCounter* getRefCounter() + { + return refcnt; + } + + /** + * Returns a reference to the contained memory fragment + * structure. + */ + OsclMemoryFragment& getMemFrag() + { + return memfrag; + } + + /** + * Returns a pointer to the memory fragment data. + */ + OsclAny* getMemFragPtr() + { + return memfrag.ptr; + } + + /** + * Returns the size of the memory fragment data which + * equals its filled size. + * + * @return + */ + uint32 getMemFragSize() + { + return memfrag.len; + } + + /** + * Returns the capacity of the memory fragment + * + * @return + */ + uint32 getCapacity() + { + return capacity; + } + + /** + * Returns the reference counter's current count. + */ + uint32 getCount() + { + return (refcnt) ? refcnt->getCount() : 0; + } + + + + private: + + OsclMemoryFragment memfrag; + OsclRefCounter *refcnt; + uint32 capacity; +}; + + +/*! @} */ + + +#endif // OSCL_REFCOUNTER_MEMFRAG_H diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_shared_ptr.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_shared_ptr.h new file mode 100644 index 0000000..d2b0a2c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_shared_ptr.h @@ -0,0 +1,198 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S H A R E D _ P T R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_shared_ptr.h + \brief This file defines a template class OsclSharedPtr which is a "smart pointer" to the parameterized type. +*/ + + +#ifndef OSCL_SHARED_PTR_H_INCLUDED +#define OSCL_SHARED_PTR_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_REFCOUNTER_H_INCLUDED +#include "oscl_refcounter.h" +#endif + +#define OSCL_DISABLE_WARNING_RETURN_TYPE_NOT_UDT +#include "osclconfig_compiler_warnings.h" + +//! A parameterized smart pointer class. +template +class OsclSharedPtr +{ + public: + //! Constructor + OsclSharedPtr() : + mpRep(NULL), refcnt(NULL) {} + + //! Constructor + /*! + \param inClassPtr A pointer to an instance of the parameterized type that the new OsclSharedPtr will wrap. + */ + OsclSharedPtr(TheClass* inClassPtr, OsclRefCounter* in_refcnt) : + mpRep(inClassPtr), refcnt(in_refcnt) {}; + + + //! Copy constructor + OsclSharedPtr(const OsclSharedPtr& inSharedPtr) : + mpRep(inSharedPtr.mpRep), refcnt(inSharedPtr.refcnt) + { + if (refcnt) + { + refcnt->addRef(); + } + } + + + //! Destructor. + virtual ~OsclSharedPtr() + { + if (refcnt != NULL) + { + refcnt->removeRef(); + } + } // end destructor + + + //! The dereferencing operator returns a pointer to the parameterized type and can be used to access member + //! elements of TheClass. + TheClass* operator->() + { + return mpRep; + } + + //! The indirection operator returns a reference to an object of the parameterized type. + TheClass& operator*() + { + return *mpRep; + } + + //! Casting operator + operator TheClass*() + { + return mpRep; + } + + //! Use this function to get a pointer to the wrapped object. + TheClass* GetRep() + { + return mpRep; + } + + //! Get the refcount pointer. This should primarily be used for conversion operations + OsclRefCounter* GetRefCounter() + { + return refcnt; + } + + //! Get a count of how many references to the object exist. + int get_count() + { + return (refcnt == NULL) ? 0 : refcnt->getCount(); + } + + //! Use this function to bind an existing OsclSharedPtr to a already-wrapped object. + void Bind(const OsclSharedPtr& inHandle); + + //! Use this function to bind an existing OsclSharedPtr to a new (unwrapped) object. + void Bind(TheClass* ptr, OsclRefCounter* in_refcnt); + + //! Use this function of unbind an existing OsclSharedPtr. + void Unbind() + { + Bind(NULL, NULL); + }; + + //! Assignment operator. + OsclSharedPtr& operator=(const OsclSharedPtr& inSharedPtr) + { + Bind(inSharedPtr); + return *this; + } + + //! Test for equality to see if two PVHandles wrap the same object. + bool operator==(const OsclSharedPtr& b) const; + + private: + + TheClass* mpRep; + OsclRefCounter* refcnt; + +}; + + +template inline bool OsclSharedPtr::operator==(const OsclSharedPtr& b) const +{ + if ((this->mpRep == b.mpRep) && + (this->refcnt == b.refcnt)) + { + return true; + } + return false; +} + + +template inline void OsclSharedPtr::Bind(const OsclSharedPtr& inSharedPtr) +{ + if (mpRep == inSharedPtr.mpRep) return; + + if (refcnt != NULL) + { + refcnt->removeRef(); + } + + refcnt = inSharedPtr.refcnt; + mpRep = inSharedPtr.mpRep; + + if (refcnt != NULL) + { + refcnt->addRef(); + } + +} + +template inline void OsclSharedPtr::Bind(TheClass* ptr, + OsclRefCounter* in_refcnt) +{ + if (refcnt != NULL) + { + refcnt->removeRef(); + } + + mpRep = ptr; + refcnt = in_refcnt; + +} + +#endif // OSCL_SHARED_PTR_H_INCLUDED diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_singleton.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_singleton.cpp new file mode 100644 index 0000000..1ae3332 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_singleton.cpp @@ -0,0 +1,76 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#include "oscl_base.h" +#if (OSCL_HAS_SINGLETON_SUPPORT) + +#include "oscl_singleton.h" +#include "oscl_assert.h" +#include "oscl_lock_base.h" +#include "oscl_base_alloc.h" + +// static object instantiation, alive with application +OsclSingletonRegistry::SingletonTable OsclSingletonRegistry::sSingletonTable; + +OSCL_EXPORT_REF OsclAny* OsclSingletonRegistry::getInstance(uint32 ID, int32 &aError) +{ + OSCL_ASSERT(ID < OSCL_SINGLETON_ID_LAST); + + aError = 0; + sSingletonTable.iSingletonLocks[ID].Lock(); + OsclAny* value = sSingletonTable.iSingletons[ID]; + sSingletonTable.iSingletonLocks[ID].Unlock(); + return value; +} + +OSCL_EXPORT_REF void OsclSingletonRegistry::registerInstance(OsclAny* ptr, uint32 ID, int32 &aError) +{ + OSCL_ASSERT(ID < OSCL_SINGLETON_ID_LAST); + + aError = 0; + sSingletonTable.iSingletonLocks[ID].Lock(); + sSingletonTable.iSingletons[ID] = ptr; + sSingletonTable.iSingletonLocks[ID].Unlock(); +} + +OSCL_EXPORT_REF OsclAny* OsclSingletonRegistry::lockAndGetInstance(uint32 ID, int32 &aError) +{ + OSCL_ASSERT(ID < OSCL_SINGLETON_ID_LAST); + + aError = 0; + sSingletonTable.iSingletonLocks[ID].Lock(); + OsclAny* value = sSingletonTable.iSingletons[ID]; + //leave this table entry locked + + return value; +} + +OSCL_EXPORT_REF void OsclSingletonRegistry::registerInstanceAndUnlock(OsclAny* ptr, uint32 ID, int32 &aError) +{ + OSCL_ASSERT(ID < OSCL_SINGLETON_ID_LAST); + + aError = 0; + + //assume it's already locked. + sSingletonTable.iSingletons[ID] = ptr; + sSingletonTable.iSingletonLocks[ID].Unlock(); +} + +#endif //OSCL_HAS_SINGLETON_SUPPORT + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_singleton.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_singleton.h new file mode 100644 index 0000000..06c966d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_singleton.h @@ -0,0 +1,200 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S I N G L E T O N + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/** + * @file oscl_singleton.h + * @brief This file defines the OsclSingleton class. This class + * provides a container which used to give access to a set of + * process-level singleton objects. Each object is indexed + * by an integer ID, listed below. There can only be one instance of + * each object per process at a given time. + * + * OsclSingleton is initialized in OsclBase::Init. + * + */ + +#ifndef OSCL_SINGLETON_H_INCLUDED +#define OSCL_SINGLETON_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + + +#if (OSCL_HAS_SINGLETON_SUPPORT) + +//verify config-- singleton support requires global var support + +// list of singleton objects +const uint32 OSCL_SINGLETON_ID_TEST = 0; +const uint32 OSCL_SINGLETON_ID_OSCLMEM = 1; +const uint32 OSCL_SINGLETON_ID_PVLOGGER = 2; +const uint32 OSCL_SINGLETON_ID_PVSCHEDULER = 3; +const uint32 OSCL_SINGLETON_ID_PVERRORTRAP = 4; +const uint32 OSCL_SINGLETON_ID_SDPMEDIAPARSER = 5; +const uint32 OSCL_SINGLETON_ID_PAYLOADPARSER = 6; +const uint32 OSCL_SINGLETON_ID_CPM_PLUGIN = 7; +const uint32 OSCL_SINGLETON_ID_PVMFRECOGNIZER = 8; +const uint32 OSCL_SINGLETON_ID_OSCLREGISTRY = 9; +const uint32 OSCL_SINGLETON_ID_OMX = 10; +const uint32 OSCL_SINGLETON_ID_OMXMASTERCORE = 11; +const uint32 OSCL_SINGLETON_ID_TICKCOUNT = 12; +const uint32 OSCL_SINGLETON_ID_WMDRMLOCK = 13; +const uint32 OSCL_SINGLETON_ID_LAST = 14; + + +class OsclSingletonRegistry +{ + public: + /* + ** Get an entry + ** @param ID: identifier + ** @param error (output) 0 for success or an error from TPVBaseErrorEnum + ** @returns: the entry value + */ + OSCL_IMPORT_REF static OsclAny* getInstance(uint32 ID, int32 &error); + /* + ** Set an entry + ** @param ID: identifier + ** @param error (output) 0 for success or an error from TPVBaseErrorEnum + ** @returns: the entry value + */ + OSCL_IMPORT_REF static void registerInstance(OsclAny* ptr, uint32 ID, int32 &error); + + /* + //These two APIs can be used to do "test and set" operations on a singleton. + //Be sure to always call both APIs to avoid deadlock. + */ + + /* + * Return the current value of the singleton and leave the singleton table locked + * on return. + * @param ID the singleton ID + ** @param error (output) 0 for success or an error from TPVBaseErrorEnum + * @returns the singleton value. + */ + OSCL_IMPORT_REF static OsclAny* lockAndGetInstance(uint32 ID, int32& error); + /* + * Set the value of the singleton. Assume the singleton table is locked on entry. + * @param ptr the singleton value + * @param ID the singleton ID + ** @param error (output) 0 for success or an error from TPVBaseErrorEnum + */ + OSCL_IMPORT_REF static void registerInstanceAndUnlock(OsclAny* ptr, uint32 ID, int32& error); + + private: + OsclSingletonRegistry() + {} + typedef OsclAny* registry_type; + typedef registry_type* registry_pointer_type; + + private: + friend class OsclBase; + + private: + class SingletonTable + { + public: + SingletonTable() + { + for (uint32 i = 0; i < OSCL_SINGLETON_ID_LAST; i++) + iSingletons[i] = NULL; + } + OsclAny* iSingletons[OSCL_SINGLETON_ID_LAST]; + _OsclBasicLock iSingletonLocks[OSCL_SINGLETON_ID_LAST]; + }; + //The singleton table is a global variable. + static SingletonTable sSingletonTable; +}; + +template < class T, uint32 ID, class Registry = OsclSingletonRegistry > class OsclSingleton +{ + private: + // make the copy constructor and assignment operator private + OsclSingleton& operator=(OsclSingleton& _Y) + { + return(*this); + } + + protected: + T* _Ptr; + + public: + OsclSingleton() + { + int32 err; + _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID, err)); + } + + ~OsclSingleton() {}; + + /** + * @brief The indirection operator (*) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclSingleton can be used like the + * regular pointer that it was initialized with. + */ + T& operator*() const + { + return(*_Ptr); + } + + /** + * @brief The indirection operator (->) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclSingleton can be used like the + * regular pointer that it was initialized with. + */ + T *operator->() const + { + return(_Ptr); + } + + + /** + * @brief set() method sets ownership to the pointer, passed. + * This method is needed when the class is created with a default + * constructor. Returns false in case the class is non-empty. + * + */ + bool set() + { + int32 err; + _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID, err)); + return (_Ptr ? true : false); + } + +}; + + +#endif //OSCL_HAS_SINGLETON_SUPPORT + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_stdstring.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_stdstring.cpp new file mode 100644 index 0000000..b5f38ac --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_stdstring.cpp @@ -0,0 +1,383 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_stdstring.h" + +#define OSCL_ASCII_CASE_MAGIC_BIT 0x20 + +OSCL_EXPORT_REF uint32 oscl_strlen(const char* str) +{ + return (uint32)strlen(str); +} + +OSCL_EXPORT_REF uint32 oscl_strlen(const oscl_wchar* str) +{ + uint32 len = 0; + while (*str != '\0') + { + str++; + len++; + } + return len; +} + +OSCL_EXPORT_REF char* oscl_strncpy(char* dest, const char* src, uint32 count) +{ + if (dest == NULL) + { + return NULL; + } + return strncpy(dest, src, count); +} + +OSCL_EXPORT_REF oscl_wchar* oscl_strncpy(oscl_wchar *dest, const oscl_wchar *src, uint32 count) +{ + if (dest == NULL) + { + return NULL; + } + oscl_wchar* tmp = dest; + uint32 ii; + for (ii = 0; ii < count && *src != '\0'; ii++) + { + *tmp++ = *src++; + } + // pad with null chars upto length count + for (; ii < count; ii++) + { + *tmp++ = '\0'; + } + return dest; +} + +OSCL_EXPORT_REF int32 oscl_strcmp(const char* str1, const char* str2) +{ + return (int32)strcmp(str1, str2); +} + +OSCL_EXPORT_REF int32 oscl_strncmp(const char* str1, const char* str2, uint32 count) +{ + return (int32)strncmp(str1, str2, count); +} + + +OSCL_EXPORT_REF int32 oscl_strcmp(const oscl_wchar *str1, const oscl_wchar *str2) +{ + while ((*str1 == *str2) && (*str1 != '\0')) + { + str1++; + str2++; + } + return (*str1 - *str2); +} + + +OSCL_EXPORT_REF int32 oscl_strncmp(const oscl_wchar *str1, const oscl_wchar *str2, uint32 count) +{ + for (uint32 ii = 0; ii < count; ii++) + { + if (*str1 != *str2 || *str1 == '\0') + { + return (*str1 - *str2); + } + str1++; + str2++; + } + return 0; +} + + +OSCL_EXPORT_REF char* oscl_strncat(char* dest, const char* src, uint32 count) +{ + if (dest == NULL) + { + return NULL; + } + return strncat(dest, src, count); +} + +OSCL_EXPORT_REF oscl_wchar* oscl_strncat(oscl_wchar* dest, const oscl_wchar* src, uint32 count) +{ + if (dest == NULL) + { + return NULL; + } + oscl_wchar* tmp = dest + oscl_strlen(dest); + for (uint32 ii = 0; ii < count && *src != '\0'; ii++) + { + *tmp++ = *src++; + } + *tmp = '\0'; + return dest; +} + +OSCL_EXPORT_REF const char* oscl_strchr(const char *str, int32 c) +{ + if (str) + { + while (*str != '\0') + { + if (*str == (char)c) + return str; + str++; + } + if (*str == (char)c) + return str; + } + return NULL; +} + +OSCL_EXPORT_REF char* oscl_strchr(char *str, int32 c) +{ + return (char*)oscl_strchr((const char*)str, c); +} + +OSCL_EXPORT_REF const oscl_wchar* oscl_strchr(const oscl_wchar *str, int32 c) +{ + if (str) + { + while (*str != '\0') + { + if (*str == (oscl_wchar)c) + return str; + str++; + } + if (*str == (oscl_wchar)c) + return str; + } + return NULL; +} + +OSCL_EXPORT_REF oscl_wchar* oscl_strchr(oscl_wchar *str, int32 c) +{ + return (oscl_wchar*)oscl_strchr((const oscl_wchar*)str, c); +} + +OSCL_EXPORT_REF const char* oscl_strrchr(const char *str, int32 c) +{ + if (!str) + return NULL; + + const char*start = str; + + while (*str != '\0') + str++; + + while (str >= start) + { + if (*str == (char)c) + return str; + if (str == start) + return NULL; + str--; + } + return NULL; +} + +OSCL_EXPORT_REF char* oscl_strrchr(char *str, int32 c) +{ + return (char*)oscl_strrchr((const char*)str, c); +} + +OSCL_EXPORT_REF const oscl_wchar* oscl_strrchr(const oscl_wchar *str, int32 c) +{ + if (!str) + return NULL; + + const oscl_wchar*start = str; + + while (*str != '\0') + str++; + + while (str >= start) + { + if (*str == (oscl_wchar)c) + return str; + if (str == start) + return NULL; + str--; + } + return NULL; +} + +OSCL_EXPORT_REF oscl_wchar* oscl_strrchr(oscl_wchar *str, int32 c) +{ + return (oscl_wchar*)oscl_strrchr((const oscl_wchar*)str, c); +} + +OSCL_EXPORT_REF char* oscl_strset(char* dest, char val, uint32 count) +{ + if (dest == NULL) + { + return NULL; + } + + for (uint32 ii = 0; ii < count; ii++) + { + *dest++ = val; + } + return dest; +} + +OSCL_EXPORT_REF oscl_wchar* oscl_strset(oscl_wchar* dest, oscl_wchar val, uint32 count) +{ + if (dest == NULL) + { + return NULL; + } + + for (uint32 ii = 0; ii < count; ii++) + { + *dest++ = val; + } + return dest; +} + +OSCL_EXPORT_REF bool oscl_isLetter(const char c) +{ + return ((c >= 65 && c <= 90) || (c >= 97 && c <= 122)); +} + +OSCL_EXPORT_REF int32 oscl_CIstrcmp(const char *str1, const char *str2) +{ + + while ((*str1 != '\0') && (oscl_tolower(*str1) == oscl_tolower(*str2))) + { + str1++; + str2++; + } + return (oscl_tolower(*str1) - oscl_tolower(*str2)); +} + +OSCL_EXPORT_REF int32 oscl_CIstrcmp(const oscl_wchar *str1, const oscl_wchar *str2) +{ + while ((*str1 != '\0') && (oscl_tolower(*str1) == oscl_tolower(*str2))) + { + str1++; + str2++; + } + return (oscl_tolower(*str1) - oscl_tolower(*str2)); + +} + +OSCL_EXPORT_REF int32 oscl_CIstrncmp(const char *str1, const char *str2, uint32 count) +{ + for (uint32 i = 0; i < count; i++) + { + if ((*str1 == '\0') || (oscl_tolower(*str1) != oscl_tolower(*str2))) + return (oscl_tolower(*str1) - oscl_tolower(*str2)); + str1++; + str2++; + } + return 0; +} + +OSCL_EXPORT_REF int32 oscl_CIstrncmp(const oscl_wchar *str1, const oscl_wchar *str2, uint32 count) +{ + for (uint32 i = 0; i < count; i++) + { + if ((*str1 == '\0') || (oscl_tolower(*str1) != oscl_tolower(*str2))) + return (oscl_tolower(*str1) - oscl_tolower(*str2)); + str1++; + str2++; + } + return 0; +} + +OSCL_EXPORT_REF char oscl_tolower(const char car) +{ + return tolower(car); +} + +OSCL_EXPORT_REF oscl_wchar oscl_tolower(const oscl_wchar car) +{ + if (car >= 65 && car <= 90) + return (OSCL_STATIC_CAST(oscl_wchar, (car + OSCL_ASCII_CASE_MAGIC_BIT))); + else + return car; +} + +OSCL_EXPORT_REF const char* oscl_strstr(const char* str1, const char* str2) +{ + return (const char*)strstr(str1, str2); +} + +OSCL_EXPORT_REF char* oscl_strstr(char* str1, const char* str2) +{ + return (char*)strstr(str1, str2); +} + +OSCL_EXPORT_REF const oscl_wchar* oscl_strstr(const oscl_wchar* str1, const oscl_wchar* str2) +{ + uint32 size = oscl_strlen(str1); + uint32 size2 = oscl_strlen(str2); + const oscl_wchar* p = (oscl_wchar*) str1; + while ((*p != '\0') && (size >= size2)) + { + if (!oscl_strncmp(p, str2, size2)) + return p; + else + { + p += 1; + size -= 1; + } + } + return 0; +} + +OSCL_EXPORT_REF oscl_wchar* oscl_strstr(oscl_wchar* str1, const oscl_wchar* str2) +{ + uint32 size = oscl_strlen(str1); + uint32 size2 = oscl_strlen(str2); + oscl_wchar* p = (oscl_wchar*) str1; + while ((*p != '\0') && (size >= size2)) + { + if (!oscl_strncmp(p, str2, size2)) + return p; + else + { + p += 1; + size -= 1; + } + } + return 0; +} + +OSCL_EXPORT_REF char* oscl_strcat(char* dest, const char* src) +{ + if (dest == NULL) + { + return NULL; + } + + return strcat(dest, src); +} + +OSCL_EXPORT_REF oscl_wchar* oscl_strcat(oscl_wchar* dest, const oscl_wchar* src) +{ + if (dest == NULL) + { + return NULL; + } + oscl_wchar* tmp = dest + oscl_strlen(dest); + for (uint32 i = 0; *src != '\0'; i++) + { + *tmp++ = *src++; + } + *tmp = '\0'; + return dest; +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_stdstring.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_stdstring.h new file mode 100644 index 0000000..c36f9f9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_stdstring.h @@ -0,0 +1,417 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S T D S T R I N G + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/** + * @file oscl_stdstring.h + * @brief This file provides standard string operations such as strlen, + * strncpy, etc. ANSI defines undefined behavior when the destination + * pointer is null for operations such as strncpy, strncat, etc. But, + * we chose to define one. In such cases, we return the destination + * as null. + */ + + +#ifndef OSCL_STDSTRING_H_INCLUDED +#define OSCL_STDSTRING_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + + +/** + * Gets the length of a string + * + * @param str NULL terminated string. + * + * @return Returns the number of characters in string, excluding the + * terminal NULL. + */ +OSCL_IMPORT_REF uint32 oscl_strlen(const char* str); + +/** + * Gets the length of a wide char string + * + * @param str NULL terminated string. + * + * @return Returns the number of characters in string, excluding the + * terminal NULL. + */ +OSCL_IMPORT_REF uint32 oscl_strlen(const oscl_wchar* str); + +/** + * Copies the chars of one string to another. + * + * Copies the initial count characters of src to dest and + * returns dest. If count is less than or equal to the + * length of src, a null character is not appended automatically + * to the copied string. If count is greater than the length + * of src, the destination string is padded with null characters + * up to length count. The behavior of strncpy is undefined + * if the source and destination strings overlap. + * + * @param dest Destination string + * @param src NULL terminated source string + * @param count Number of chars to copy + * + * @return Returns dest. + */ +OSCL_IMPORT_REF char* oscl_strncpy(char* dest, const char* src, uint32 count); + +/** + * Copies the chars of one string to another. + * + * Copies the initial count characters of src to dest and + * returns dest. If count is less than or equal to the + * length of src, a null character is not appended automatically + * to the copied string. If count is greater than the length + * of src, the destination string is padded with null characters + * up to length count. The behavior of strncpy is undefined + * if the source and destination strings overlap. + * + * @param dest Destination string + * @param src NULL terminated source string + * @param count Number of chars to copy + * + * @return Returns dest. + */ +OSCL_IMPORT_REF oscl_wchar* oscl_strncpy(oscl_wchar* dest, const oscl_wchar* src, uint32 count); + +/** + * Lexicographically compares two NULL terminated strings, + * str1 and str2, and returns a value indicating the relationship + * between them. + * + * @param str1 String to compare + * @param str2 String to compare + * + * @return Negative if str1 < str2 + * Positive if str1 > str2 + * Zero if equal + */ +OSCL_IMPORT_REF int32 oscl_strcmp(const char* str1, const char* str2); + +/** + * Lexicographically compares two NULL terminated strings, + * str1 and str2, and returns a value indicating the relationship + * between them. + * + * @param str1 String to compare + * @param str2 String to compare + * + * @return Negative if str1 < str2 + * Positive if str1 > str2 + * Zero if equal + */ +OSCL_IMPORT_REF int32 oscl_strcmp(const oscl_wchar* str1, const oscl_wchar* str2); + + +/** + * Lexicographically compares, at most, the first count characters + * in str1 and str2 and returns a value indicating the relationship + * between the substrings. + * + * @param str1 String to compare + * @param str2 String to compare + * @param count Number of characters to compare + * + * @return Negative if str1 < str2 + * Positive if str1 > str2 + * Zero if equal + */ +OSCL_IMPORT_REF int32 oscl_strncmp(const char* str1, const char* str2, uint32 count); + +/** + * Lexicographically compares, at most, the first count characters + * in str1 and str2 and returns a value indicating the relationship + * between the substrings. + * + * @param str1 String to compare + * @param str2 String to compare + * @param count Number of characters to compare + * + * @return Negative if str1 < str2 + * Positive if str1 > str2 + * Zero if equal + */ +OSCL_IMPORT_REF int32 oscl_strncmp(const oscl_wchar* str1, const oscl_wchar* str2, uint32 count); + +/** + * Appends up to count characters from string src to string + * dest, and then appends a terminating null character. The + * initial character of src overwrites the null character at + * the end of dest. Subsequent characters in src are appended + * to dest until either the end of src is reached or count + * characters have been copied. If copying takes place between + * objects that overlap, the behavior is undefined. + * + * @param dest null terminated destination string + * @param src source string + * @param count number of characters to append. + * + * @return dest + */ +OSCL_IMPORT_REF char* oscl_strncat(char* dest, const char* src, uint32 count); + +/** + * Appends up to count characters from string src to string + * dest, and then appends a terminating null character. The + * initial character of src overwrites the null character at + * the end of dest. Subsequent characters in src are appended + * to dest until either the end of src is reached or count + * characters have been copied. If copying takes place between + * objects that overlap, the behavior is undefined. + * + * @param dest null terminated destination string + * @param src source string + * @param count number of characters to append. + * + * @return dest + */ +OSCL_IMPORT_REF oscl_wchar* oscl_strncat(oscl_wchar* dest, const oscl_wchar* src, uint32 count); + +/** + * Finds the first occurrence of c in string, or it + * returns NULL if c is not found. The null-terminating + * character is included in the search. + * + * @param str null terminated source string + * @param c character to search for + * + * @return + */ +OSCL_IMPORT_REF const char* oscl_strchr(const char *str, int32 c); +OSCL_IMPORT_REF char* oscl_strchr(char *str, int32 c); + +/** + * Finds the first occurrence of c in string, or it + * returns NULL if c is not found. The null-terminating + * character is included in the search. + * + * @param str null terminated source string + * @param c character to search for + * + * @return + */ +OSCL_IMPORT_REF const oscl_wchar* oscl_strchr(const oscl_wchar *str, int32 c); +OSCL_IMPORT_REF oscl_wchar* oscl_strchr(oscl_wchar *str, int32 c); + +/** + * Finds the last occurrence of c in string, or it + * returns NULL if c is not found. The null-terminating + * character is included in the search. + * + * @param str null terminated source string + * @param c character to search for + * + * @return + */ +OSCL_IMPORT_REF const char* oscl_strrchr(const char *str, int32 c); +OSCL_IMPORT_REF char* oscl_strrchr(char *str, int32 c); +OSCL_IMPORT_REF const oscl_wchar* oscl_strrchr(const oscl_wchar *str, int32 c); +OSCL_IMPORT_REF oscl_wchar* oscl_strrchr(oscl_wchar *str, int32 c); + +/** + * Sets the characters of a string to a specified character + * + * @param dest buffer to modify + * @param val character to set + * @param count number of chars to set + * + * @return the value of dest + */ +OSCL_IMPORT_REF char* oscl_strset(char* dest, char val, uint32 count); + +/** + * Sets the characters of a string to a specified character + * + * @param dest buffer to modify + * @param val character to set + * @param count number of chars to set + * + * @return the value of dest + */ +OSCL_IMPORT_REF oscl_wchar* oscl_strset(oscl_wchar* dest, oscl_wchar val, uint32 count); + + +/** + * Case in-sensitive string comparision. + * + * @param str1 string to compare + * @param str2 string to compare + * + * + * @return Negative if str1 < str2 + * Positive if str1 > str2 + * Zero if equal + */ +OSCL_IMPORT_REF int32 oscl_CIstrcmp(const char *str1, const char *str2); + +/** + * Case in-sensitive string comparision. + * + * @param str1 string to compare + * @param str2 string to compare + * + * + * @return Negative if str1 < str2 + * Positive if str1 > str2 + * Zero if equal + */ +OSCL_IMPORT_REF int32 oscl_CIstrcmp(const oscl_wchar *str1, const oscl_wchar *str2); + +/** + * Lexicographically compares(case in-sensitive), at most, the first + * count characters in str1 and str2 and returns a value indicating + * the relationship between the substrings. + * + * @param str1 string to compare + * @param str2 string to compare + * @param count Number of characters to compare + * + * + * @return Negative if str1 < str2 + * Positive if str1 > str2 + * Zero if equal + */ +OSCL_IMPORT_REF int32 oscl_CIstrncmp(const char *str1, const char *str2, uint32 count); + +/** + * Lexicographically compares(case in-sensitive), at most, the first + * count characters in str1 and str2 and returns a value indicating + * the relationship between the substrings. + * + * @param str1 string to compare + * @param str2 string to compare + * @param count Number of characters to compare + * + * + * @return Negative if str1 < str2 + * Positive if str1 > str2 + * Zero if equal + */ +OSCL_IMPORT_REF int32 oscl_CIstrncmp(const oscl_wchar *str1, const oscl_wchar *str2, uint32 count); + +/** + * convert upper case ASCII character to lower case. + * behaviour of this function for non-ASCII characters is not defined. + * + * @param car upper case character. + * + * @return lower case character. + */ +OSCL_IMPORT_REF char oscl_tolower(const char car); + + +/** + * convert upper case ASCII character to lower case. + * behaviour of this function for non-ASCII characters is not defined. + * + * @param car upper case character. + * + * @return lower case character. + */ +OSCL_IMPORT_REF oscl_wchar oscl_tolower(const oscl_wchar car); + + +/** + * check if supplied parameter is an alphabet (ASCII only). + * + * @param car + * + * @return 1 if car is an alphabet + * 0 if car is not an alphabet. + */ +OSCL_IMPORT_REF bool oscl_isLetter(const char car); + + +/** + * find the occurrence of sub-string in a string. + * + * @param str1 string. + * @param str2 sub-string + * + * @return pointer to the begining of sub-string. + */ +OSCL_IMPORT_REF const char* oscl_strstr(const char* str1, const char* str2); +OSCL_IMPORT_REF char* oscl_strstr(char* str1, const char* str2); + + +/** + * find the occurrence of sub-string in a string. + * + * @param str1 string. + * @param str2 sub-string + * + * @return pointer to the begining of sub-string. + */ +OSCL_IMPORT_REF const oscl_wchar* oscl_strstr(const oscl_wchar* str1, const oscl_wchar* str2); +OSCL_IMPORT_REF oscl_wchar* oscl_strstr(oscl_wchar* str1, const oscl_wchar* str2); + + +/** + * Appends string src to string dest, and then appends a + * terminating null character. The initial character of src + * overwrites the null character at the end of dest. + * Subsequent characters in src are appended to dest until + * the end of src is reached. If copying takes place between + * objects that overlap, the behavior is undefined. + * + * @param dest null terminated destination string + * @param src source string + * + * + * @return dest + */ +OSCL_IMPORT_REF char* oscl_strcat(char* dest, const char* src); + + +/** + * Appends up to count characters from string src to string + * dest, and then appends a terminating null character. The + * initial character of src overwrites the null character at + * the end of dest. Subsequent characters in src are appended + * to dest until either the end of src is reached or count + * characters have been copied. If copying takes place between + * objects that overlap, the behavior is undefined. + * + * @param dest null terminated destination string + * @param src source string + * @param count number of characters to append. + * + * @return dest + */ +OSCL_IMPORT_REF oscl_wchar* oscl_strcat(oscl_wchar* dest, const oscl_wchar* src); + + +/*! @} */ + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_string_utils.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_string_utils.cpp new file mode 100644 index 0000000..feef945 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_string_utils.cpp @@ -0,0 +1,591 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCL_STRING_UTILS_H_INCLUDED +#include "oscl_string_utils.h" +#endif + +#include "oscl_stdstring.h" + +/* ======================================================================== */ +/* Function : PV_atoi(char *buf,char new_format) */ +/* Date : 02/22/2001 */ +/* Purpose : Extracts an integer from the input string. */ +/* In/out : */ +/* Return : */ +/* Modified : */ +/* ======================================================================== */ +OSCL_EXPORT_REF bool PV_atoi(const char *buf, const char new_format, uint32& value) +{ + return PV_atoi(buf, new_format, oscl_strlen(buf), value); +} + + +OSCL_EXPORT_REF bool PV_atoi(const char *buf, const char new_format, int length, uint32& value) +{ + uint32 old, temp; + const char *ptr = buf; + value = 0; + + if (buf == NULL) return false; + + switch (new_format) + { + case 'x': + { + while (ptr - buf < length) + { + if ((*ptr == 'a') || (*ptr == 'A')) + temp = 10; + else if ((*ptr == 'b') || (*ptr == 'B')) + temp = 11; + else if ((*ptr == 'c') || (*ptr == 'C')) + temp = 12; + else if ((*ptr == 'd') || (*ptr == 'D')) + temp = 13; + else if ((*ptr == 'e') || (*ptr == 'E')) + temp = 14; + else if ((*ptr == 'f') || (*ptr == 'F')) + temp = 15; + else if ((*ptr >= 48) && (*ptr <= 57)) + temp = (int)(*ptr - 48); + else return false; + ++ptr; + old = value; + value = value * 16 + temp; + if (old > value) + { + // overflow + return false; + } + } + } + break; + case 'd': + { + while (ptr - buf < length) + { + if ((*ptr >= 48) && (*ptr <= 57)) + { + temp = (int)(*ptr - 48); + ++ptr; + old = value; + value = value * 10 + temp; + if (old > value) + { + // overflow + return false; + } + } + else + { + return false; + } + + } + } + break; + default : + { + while (ptr - buf < length) + { + if ((*ptr >= 48) && (*ptr <= 57)) + { + temp = (int)(*ptr - 48); + ++ptr; + old = value; + value = value * 10 + temp; + if (old > value) + { + // overflow + return false; + } + } + else + { + return false; + } + } + } + break; + } + + return true; +} + +OSCL_EXPORT_REF bool PV_atoi(const char *buf, const char new_format, int length, uint64& value) +{ + uint64 old, temp; + const char *ptr = buf; + value = 0; + + if (buf == NULL) return false; + + switch (new_format) + { + case 'x': + { + while (ptr - buf < length) + { + if ((*ptr == 'a') || (*ptr == 'A')) + temp = 10; + else if ((*ptr == 'b') || (*ptr == 'B')) + temp = 11; + else if ((*ptr == 'c') || (*ptr == 'C')) + temp = 12; + else if ((*ptr == 'd') || (*ptr == 'D')) + temp = 13; + else if ((*ptr == 'e') || (*ptr == 'E')) + temp = 14; + else if ((*ptr == 'f') || (*ptr == 'F')) + temp = 15; + else if ((*ptr >= 48) && (*ptr <= 57)) + temp = (int)(*ptr - 48); + else return false; + ++ptr; + old = value; + value = value * (uint64)16 + temp; + if (old > value) + { + // overflow + return false; + } + } + } + break; + case 'd': + { + while (ptr - buf < length) + { + if ((*ptr >= 48) && (*ptr <= 57)) + { + temp = (int)(*ptr - 48); + ++ptr; + old = value; + value = value * (uint64)10 + temp; + if (old > value) + { + // overflow + return false; + } + } + else + { + return false; + } + + } + } + break; + default : + { + while (ptr - buf < length) + { + if ((*ptr >= 48) && (*ptr <= 57)) + { + temp = (int)(*ptr - 48); + ++ptr; + old = value; + value = value * (uint64)10 + temp; + if (old > value) + { + // overflow + return false; + } + } + else + { + return false; + } + } + } + break; + } + + return true; +} + + + + +/* ======================================================================== */ +/* Function : skip_whitespace */ +/* Date : 1/1/2000 */ +/* Purpose : Skips over any leading whitespace (i.e., a space or */ +/* horizontal tab character) in the input string and */ +/* returns the pointer to the first non-whitespace */ +/* character. */ +/* In/out : */ +/* Return : pointer to first non-whitespace character */ +/* Modified : */ +/* ======================================================================== */ + +OSCL_EXPORT_REF const char* skip_whitespace(const char *ptr) +{ + while (ptr && *ptr) + { + if (*ptr != ' ' && *ptr != '\t') + { + break; + } + + ++ptr; + } + + return ptr; +} + +OSCL_EXPORT_REF char * skip_whitespace(char * ptr) +{ + while (ptr && *ptr) + { + if (*ptr != ' ' && *ptr != '\t') + { + break; + } + + ++ptr; + } + + return ptr; +} + + + +/* ======================================================================== */ +/* Function : skip_whitespace */ +/* Date : 1/1/2000 */ +/* Purpose : Skips over any leading whitespace (i.e., a space or */ +/* horizontal tab character) in the input string and */ +/* returns the pointer to the first non-whitespace */ +/* character. The input string is represented by */ +/* starting and ending pointers and does not need to be */ +/* NULL terminated. */ +/* In/out : */ +/* Return : pointer to first non-whitespace character */ +/* Modified : */ +/* ======================================================================== */ + +OSCL_EXPORT_REF const char* skip_whitespace(const char *start, const char *end) +{ + while (start && (start < end)) + { + if (*start != ' ' && *start != '\t') + { + break; + } + + ++start; + } + + return start; +} + + +/* ======================================================================== */ +/* Function : skip_to_whitespace */ +/* Date : 1/1/2001 */ +/* Purpose : Skips to the first whitespace character (i.e., a space */ +/* or horizontal tab character or line terminator) in the */ +/* input string and returns the pointer to the first */ +/* non-whitespace character. */ +/* The input string is represented by */ +/* starting and ending pointers and does not need to be */ +/* NULL terminated. */ +/* In/out : */ +/* Return : pointer to first non-whitespace character */ +/* Modified : */ +/* ======================================================================== */ + +OSCL_EXPORT_REF const char* skip_to_whitespace(const char *start, const char *end) +{ + while (start && (start < end)) + { + if (*start == ' ' || *start == '\t' || + *start == '\r' || *start == '\n') + { + break; + } + + ++start; + } + + return start; +} + +/* ======================================================================== */ +/* Function : skip_to_line_term */ +/* Date : 9/15/2001 */ +/* Purpose : Skips over any characters to the next line terminator */ +/* (i.e., \r and \n) and */ +/* returns the pointer to the line term character. */ +/* The input string is represented by */ +/* starting and ending pointers and does not need to be */ +/* NULL terminated. */ +/* In/out : */ +/* Return : pointer to line terminator character */ +/* Modified : */ +/* ======================================================================== */ + +OSCL_EXPORT_REF const char * skip_to_line_term(const char *start, const char *end) +{ + while (start && (start < end)) + { + if (*start == '\r' || *start == '\n') + { + return start; + } + ++start; + } + + return start; +} + + +/* ======================================================================== */ +/* Function : skip_whitespace_and_line_term */ +/* Date : 9/15/2001 */ +/* Purpose : Skips over any leading whitespace (i.e., a space or */ +/* horizontal tab character) or line terminator (i.e., \r */ +/* and \n) and */ +/* returns the pointer to the first non-whitespace */ +/* character. The input string is represented by */ +/* starting and ending pointers and does not need to be */ +/* NULL terminated. */ +/* In/out : */ +/* Return : pointer to first non-whitespace character */ +/* Modified : */ +/* ======================================================================== */ + +OSCL_EXPORT_REF const char* skip_whitespace_and_line_term(const char *start, const char *end) +{ + while (start && (start < end)) + { + if (*start != ' ' && *start != '\t' && + *start != '\r' && *start != '\n') + { + break; + } + + ++start; + } + + return start; +} + + + + +/* ======================================================================== */ +/* Function : extract_string */ +/* Date : 1/1/2000 */ +/* Purpose : Extracts string of a maximum size after skipping any */ +/* leading whitespace. The input string is represented by */ +/* starting and ending pointers and does not need to be */ +/* NULL terminated. */ +/* In/out : */ +/* Return : length of the extracted string */ +/* Modified : */ +/* ======================================================================== */ + + +OSCL_EXPORT_REF int extract_string(const char * start, const char *end, char *outstring, int maxsize) +{ + int len = 0; + + if (! outstring) + { + return 0; + } + + start = skip_whitespace(start, end); + + for (; start && (start < end) ; ++start) + { + + if (*start == ' ' || *start == '\t' || *start == '\n' || *start == '\r') + { + // whitespace so stop copying + break; + } + + if (len < maxsize) + { + *outstring++ = *start; + } + else if (len == maxsize) + { + // too long so just terminate the string + *(outstring - 1) = '\0'; + } + ++len; + + } + + if (len < maxsize) + { + // terminate the string + *outstring = '\0'; + } + + return len; +} + +/* ======================================================================== */ +/* Function : extract_string */ +/* Date : 1/1/2000 */ +/* Purpose : Extracts string of a maximum size after skipping any */ +/* leading whitespace. */ +/* In/out : */ +/* Return : length of the extracted string */ +/* Modified : */ +/* ======================================================================== */ + +OSCL_EXPORT_REF int extract_string(const char * in_ptr, char *outstring, int maxsize) +{ + int len = 0; + + if (! outstring) + { + return 0; + } + + in_ptr = skip_whitespace(in_ptr, in_ptr + oscl_strlen(in_ptr)); + + for (; in_ptr && *in_ptr ; ++in_ptr) + { + + if (*in_ptr == ' ' || *in_ptr == '\t' || *in_ptr == '\n' || *in_ptr == '\r') + { + // whitespace so stop copying + break; + } + + if (len < maxsize) + { + *outstring++ = *in_ptr; + } + else if (len == maxsize) + { + // too long so just terminate the string + *(outstring - 1) = '\0'; + } + ++len; + + } + + if (len < maxsize) + { + // terminate the string + *outstring = '\0'; + } + + return len; +} + +/* ======================================================================== */ +/* Function : PV_atof(char *buf, OsclFloat& value) */ +/* Purpose : Converts a character string to a float. The string */ +/* argument has the following form: */ +/* [whitespace] [sign] [digits] [.digits] */ +/* In/out : */ +/* Return : */ +/* Modified : */ +/* ======================================================================== */ +OSCL_EXPORT_REF bool PV_atof(const char *buf, OsclFloat& value) +{ + return PV_atof(buf, oscl_strlen(buf), value); +} + +OSCL_EXPORT_REF bool PV_atof(const char *buf, int length, OsclFloat& value) +{ + int i, decimal_point_index = -1; + OsclFloat old; + bool minus_sign = false; + bool digit_found = false; + value = 0.0; + + for (i = 0; i < length; i++) + { + if (buf[i] == ' ' || buf[i] == '\t' || buf[i] == '\r' || buf[i] == '\n') + { + if (digit_found) + break; // stop the conversion if the numeric value is ended with whitespace, tab, CR or LF (ie, "1.23 ") + else + continue; // skip leading whitespace or tab + } + else if (buf[i] == '-') + { + if (digit_found) + break; // stop the conversion if the numeric value is ended with a minus sign (ie, "1.23-") + else + { + minus_sign = true; + continue; + } + } + else if (buf[i] < '0' || buf[i] > '9') + { + if (buf[i] == '.') + { + if (decimal_point_index > -1) + break; // found another decimal point so stopping + else // continue the conversion if this is the first decimal point + { + decimal_point_index = i; + continue; + } + } + else + return false; // Non-numeric char so stopping + } + else + { + old = value; + value = value * 10 + buf[i] - '0'; + if (old > value) + { + // overflow + return false; + } + if (!digit_found) + digit_found = true; + } + } + + if (value > 0.0) + { + if (decimal_point_index != -1) + { + i = i - 1 - decimal_point_index; + if (i > 0) + { + while (i--) + value /= 10; + } + } + if (minus_sign) + value = (OsclFloat)(0.0 - value); + } + return true; +} + +OSCL_EXPORT_REF int oscl_abs(int aVal) +{ + return(aVal < 0 ? -aVal : aVal); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_string_utils.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_string_utils.h new file mode 100644 index 0000000..4f85d9f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_string_utils.h @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S T R I N G _ U T I L S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/** \file oscl_string_utils.h + \brief Utilities to parse and convert strings +*/ + +#ifndef OSCL_STRING_UTILS_H_INCLUDED +#define OSCL_STRING_UTILS_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#define oscl_isdigit(c) ((c) >= '0' && (c) <= '9') + +OSCL_IMPORT_REF const char* skip_whitespace(const char *ptr); + +OSCL_IMPORT_REF char * skip_whitespace(char * ptr); + +OSCL_IMPORT_REF const char* skip_whitespace(const char *start, const char *end); + +OSCL_IMPORT_REF const char* skip_to_whitespace(const char *start, const char *end); + +OSCL_IMPORT_REF const char * skip_to_line_term(const char *start_ptr, const char *end_ptr); + +OSCL_IMPORT_REF const char* skip_whitespace_and_line_term(const char *start, const char *end); + +OSCL_IMPORT_REF int extract_string(const char * in_ptr, char *outstring, int maxsize); + +OSCL_IMPORT_REF int extract_string(const char * start, const char *end, char *outstring, int maxsize); + +OSCL_IMPORT_REF bool PV_atoi(const char *buf, const char new_format, uint32& value); + +OSCL_IMPORT_REF bool PV_atoi(const char *buf, const char new_format, int length, uint32& value); +OSCL_IMPORT_REF bool PV_atoi(const char *buf, const char new_format, int length, uint64& value); +OSCL_IMPORT_REF bool PV_atof(const char *buf, OsclFloat& value); +OSCL_IMPORT_REF bool PV_atof(const char *buf, int length, OsclFloat& value); +OSCL_IMPORT_REF int oscl_abs(int aVal); +#endif // OSCL_STRING_UTILS_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tagtree.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tagtree.cpp new file mode 100644 index 0000000..190b0b0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tagtree.cpp @@ -0,0 +1,49 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_tagtree.h" + +OSCL_EXPORT_REF Oscl_Tag_Base::tag_base_type Oscl_Tag_Base::tag_ancestor(tag_base_type& dest, const tag_base_type& src) const +{ + // dest and src can be the same for this call. + // This is optimal in some cases when the src string can be modified to be the ancestor string. + if (dest != src) + { + tag_copy(dest, src); + } + + tag_base_type endptr = dest + oscl_strlen(dest); + while (*endptr != '.' && endptr != dest) endptr--; + *endptr = '\0'; + return dest; +} + +OSCL_EXPORT_REF Oscl_Tag_Base::size_type Oscl_Tag_Base::tag_depth(const tag_base_type& t) const +{ + if (*t == '\0') return 0; + + tag_base_type ptr = t; + size_type depth = 1; + + while (*ptr != '\0') + { + if (*ptr == '.') depth++; + ptr++; + } + return depth; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tagtree.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tagtree.h new file mode 100644 index 0000000..242f8d5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tagtree.h @@ -0,0 +1,596 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ T A G T R E E + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_tagtree.h + \brief The file oscl_tagtree.h ... +*/ + +#ifndef OSCL_TAGTREE_H_INCLUDED +#define OSCL_TAGTREE_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_MAP_H_INCLUDED +#include "oscl_map.h" +#endif + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +#ifndef OSCL_STDSTRING_H_INCLUDED +#include "oscl_stdstring.h" +#endif + +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + + +struct Oscl_Tag_Base +{ + typedef char tag_base_unit; + typedef tag_base_unit* tag_base_type; + typedef uint32 size_type; + + bool operator()(const tag_base_type& x, const tag_base_type& y) const + { + return tag_cmp(x, y) < 0; + } + size_type tag_len(const tag_base_type& t) const + { + return (size_type)oscl_strlen(t); + } + tag_base_type tag_copy(tag_base_type& dest, const tag_base_type& src) const + { + return oscl_strncpy(dest, src, oscl_strlen(src) + 1); + } + int32 tag_cmp(const tag_base_type& x, const tag_base_type& y) const + { + return oscl_strncmp(x, y, oscl_strlen(x) + 1); + } + OSCL_IMPORT_REF tag_base_type tag_ancestor(tag_base_type& dest, const tag_base_type& src) const; + OSCL_IMPORT_REF size_type tag_depth(const tag_base_type& t) const; +}; + +template +struct Oscl_Tag : public Oscl_Tag_Base +{ + + Oscl_Tag(const Oscl_Tag& t) + { + tag = tagAllocator.ALLOCATE(tag_len(t.tag) + 1); + tag_copy(tag, t.tag); + } + + Oscl_Tag(const tag_base_type& t) + { + tag = tagAllocator.ALLOCATE(tag_len(t) + 1); + tag_copy(tag, t); + } + + ~Oscl_Tag() + { + tagAllocator.deallocate(tag); + } + + bool operator<(const Oscl_Tag& x) const + { + return (tag_cmp(tag, x.tag) < 0); + } + + Oscl_TAlloc tagAllocator; + tag_base_type tag; +}; + +/** + * Oscl_TagTree Class. + */ +template +class Oscl_TagTree +{ + + public: + typedef Oscl_Tag tag_type; + typedef typename tag_type::tag_base_type tag_base_type; + + + struct Node + { + typedef Oscl_Vector children_type; + Node() {} + + tag_type tag; + T value; + Node* parent; + children_type children; + + void sort_children() + { + bool tryagain; + if (children.empty()) return; + do + { + tryagain = 0; + for (typename children_type::iterator it = children.begin(); it != (children.end() - 1); it++) + { + typename children_type::iterator it2 = it + 1; + if ((*it2)->tag < (*it)->tag) + { + // swap em + Node* tmp = *it; + *it = *it2; + *it2 = tmp; + tryagain = 1; + } + } + } + while (tryagain); + } + + typename tag_type::size_type depth() + { + return tag.tag_depth(tag.tag); + } + }; + + typedef Oscl_Vector children_type; + + typedef Node node_type; + typedef node_type* node_ptr; + typedef Oscl_Map map_type; + typedef typename map_type::size_type size_type; + typedef typename map_type::value_type value_type; + + struct iterator + { + typedef node_type& reference; + typedef node_type* pointer; + typedef typename map_type::iterator mapiter; + typedef iterator self; + + iterator() {} + iterator(mapiter x) + { + mapit = x; + } + iterator(const iterator& it) + { + mapit = it.mapit; + } + + reference operator*() const + { + return *((*mapit).second); + } + pointer operator->() const + { + return &(operator*()); + } + + bool operator==(const self& x) + { + return mapit == x.mapit; + } + + bool operator!=(const self& x) + { + return mapit != x.mapit; + } + + self& operator++() + { + mapit++; + return *this; + } + + self operator++(int) + { + self tmp = *this; + ++*this; + return tmp; + } + + self& operator--() + { + mapit--; + return *this; + } + + self operator--(int) + { + self tmp = *this; + --*this; + return tmp; + } + + mapiter mapit; + }; + + struct const_iterator + { + typedef const node_type& reference; + typedef const node_type* pointer; + typedef typename map_type::const_iterator mapiter; + typedef const_iterator self; + + const_iterator() {} + const_iterator(mapiter x) + { + mapit = x; + } + const_iterator(const const_iterator& it) + { + mapit = it.mapit; + } + + reference operator*() const + { + return *((*mapit).second); + } + pointer operator->() const + { + return &(operator*()); + } + + bool operator==(const self& x) + { + return mapit == x.mapit; + } + + bool operator!=(const self& x) + { + return mapit != x.mapit; + } + + self& operator++() + { + mapit++; + return *this; + } + + self operator++(int) + { + self tmp = *this; + ++*this; + return tmp; + } + + self& operator--() + { + mapit--; + return *this; + } + + self operator--(int) + { + self tmp = *this; + --*this; + return tmp; + } + + mapiter mapit; + }; + + public: + + /** + * Creates a tag tree with only a root node with tag "" + */ + Oscl_TagTree(size_type max_depth = 0) : maxDepth(max_depth) + { + // insert the root node + node_ptr node = create_node((char*)"", T()); + node->parent = NULL; + typename map_type::value_type pair(node->tag.tag, node); + nodeMap.insert(pair); + } + /** + * Copy constructor + */ + Oscl_TagTree(const Oscl_TagTree& x) : maxDepth(x.maxDepth) + { + for (const_iterator it = x.begin(); it != x.end(); it++) + { + insert(it->tag.tag, it->value); + } + } + /** + * Assignment operator + */ + Oscl_TagTree& operator=(const Oscl_TagTree& x) + { + maxDepth = x.maxDepth; + // clear the current tree + clear(); + // insert nodes from assigned tree + for (const_iterator it = x.begin(); it != x.end(); it++) + { + insert(it->tag.tag, it->value); + } + return *this; + } + /** + * Destructor + */ + ~Oscl_TagTree() + { + // destroy all nodes stored in the map + for (iterator it = begin(); it != end(); it++) + { + destroy_node(&(*it)); + } + } + /** + * Returns an iterator pointing to the first node in the tree. + */ + iterator begin() + { + return iterator(nodeMap.begin()); + } + /** + * Returns an iterator pointing to the first node in the tree. + */ + const_iterator begin() const + { + return const_iterator(nodeMap.begin()); + } + /** + * Returns an iterator pointing to the end of the tree. + */ + iterator end() + { + return iterator(nodeMap.end()); + } + /** + * Returns a const iterator pointing to the end of the tree. + */ + const_iterator end() const + { + return const_iterator(nodeMap.end()); + } + /** + * Returns true if tree size is 0 + */ + bool empty() const + { + return nodeMap.empty(); + } + /** + * Returns the number of nodes stored in the tree + */ + size_type size() const + { + return nodeMap.size(); + } + /** + * Returns a reference to the object that is associated with a particular tag. + * If the map does not already contain such an object, operator[] inserts the default object T(). + */ + T& operator[](const tag_base_type& t) + { + return (*((insert(t, T())).first)).value; + } + + typedef Oscl_Pair pair_iterator_bool; + /** + * Inserts x into the tree and associates it with tag t. If the tag already exists + * x will not be inserted, and an iterator pointing to the existing node with tag t + * is returned. + * + * @param t tag to use + * @param x element to insert + * + * @return Returns a pair of parameters, iterator and bool. The + * iterator points to the inserted node containing x. If + * the tag t already existed, then the iterator points to + * the node associated with tag t. The bool is true if x + * was inserted and false if it was not inserted due to an + * existing node with tag t. + */ + pair_iterator_bool insert(const tag_base_type& t, const T& x) + { + + tag_type currenttag(t); + pair_iterator_bool result(end(), false); + node_ptr child = NULL; + size_type ii; + size_type maxloops; + + // if it exceeds the max depth, then truncate it to the max depth size + if (maxDepth > 0 && currenttag.tag_depth(currenttag.tag) > maxDepth) + { + maxloops = currenttag.tag_depth(currenttag.tag) - maxDepth; + for (ii = 0; ii < maxloops; ii++) + { + currenttag.tag_ancestor(currenttag.tag, currenttag.tag); + } + } + + maxloops = currenttag.tag_depth(currenttag.tag) + 1; + for (ii = 0; ii < maxloops; ii++) + { + // check if tag already exists; if so then no need to continue creating nodes + typename map_type::iterator mit = nodeMap.find(currenttag.tag); + if (mit != nodeMap.end()) + { + // set child parent relationship + if (child) + { + child->parent = (*mit).second; + child->parent->children.push_back(child); + } + // if this is the first pass node, then set it for the return value + if (result.first == end()) result.first = iterator(mit); + break; + } + // otherwise create a new node, insert it into map, and set parent/child relationship + else + { + // insert the new node + // first pass sets the node to the given value, all others are default value + node_ptr node; + if (result.first == end()) + { + node = create_node(currenttag.tag, x); + } + else + { + node = create_node(currenttag.tag, T()); + } + + typename map_type::value_type pair(node->tag.tag, node); + typename map_type::pair_iterator_bool mapresult = (nodeMap.insert(pair)); + + // if this is the first pass node to insert, save it for the return value + if (result.first == end()) + { + result.first = iterator(mapresult.first); + result.second = mapresult.second; + } + // set child/parent relationship + if (child) + { + child->parent = (*(mapresult.first)).second; + child->parent->children.push_back(child); + } + child = node; + } + + currenttag.tag_ancestor(currenttag.tag, currenttag.tag); + } + + return result; + } + /** + * Erases the element pointed to by the iterator. If the + * node has children, then the node will not be erased from + * the tree. It will be replaced with the default node + * value. + * + * @param position Iterator pointing to the node to be erased + */ + void erase(iterator position) + { + // if node has children, then replace it with default node value + if (!(position->children.empty())) + { + position->value = T(); + return; + } + + // destroy the node since only the pointer is stored + destroy_node(&(*position)); + nodeMap.erase(position.mapit); + } + /** + * Erases the node with tag x. If the node has children, + * then the node will not be erased from the tree. It will + * be replaced with the default node value + * + * @param x Tag of node to erase + * + * @return Returns the number of nodes erased. Since one-to-one + * mapping between nodes and tags, this will be either 0 or 1 + */ + size_type erase(const tag_base_type& x) + { + iterator it = find(x); + if (it != end()) + { + erase(it); + return 1; + } + return 0; + } + /** + * Erases the entire tag tree. + */ + void clear() + { + // destroy all nodes stored in the map + for (iterator it = begin(); it != end(); it++) + { + destroy_node(&(*it)); + } + // clear the map + nodeMap.clear(); + } + /** + * Finds an element whose key is x + * + * @return returns an iterator to the element with key x. If no element is found, returns end() + */ + iterator find(const tag_base_type& x) + { + return iterator(nodeMap.find(x)); + } + /** + * Finds an element whose key is x + */ +//Removed this version due to ADS 1.2 compile problem +// const_iterator find(const tag_base_type& x) const { return const_iterator(nodeMap.find(x)); } + /** + * Returns the number of elements with key x. This can only be 0 or 1.. + */ + size_type count(const tag_base_type& x) const + { + return nodeMap.count(x); + } + + private: + node_ptr create_node(const tag_base_type& t, const T& x) + { + node_ptr n = nodeAllocator.ALLOCATE(1); + new(&n->tag) tag_type(t); + new(&n->value) T(x); + new(&n->children) Oscl_Vector(); + return n; + } + + void destroy_node(node_ptr x) + { + x->tag.OSCL_TEMPLATED_DESTRUCTOR_CALL(tag_type, Oscl_Tag); + x->value.T::~T(); + x->children.OSCL_TEMPLATED_DESTRUCTOR_CALL(children_type, Oscl_Vector); + nodeAllocator.deallocate(x); + } + + map_type nodeMap; + Oscl_TAlloc nodeAllocator; + size_type maxDepth; +}; + +/*! @} */ + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_time.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_time.cpp new file mode 100644 index 0000000..15ed5de --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_time.cpp @@ -0,0 +1,316 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_time.h" +#include "oscl_assert.h" +#include "oscl_stdstring.h" + +#if (OSCL_DISABLE_INLINES) +#include "oscl_time.inl" +#endif + + +//---OSCL_HAS_UNIX_TIME_FUNCS---// + +const uint32 origin_offset = 2208988800U; +const uint64 freq_conv = 281474977; + +int NTPTime::set_to_current_time() +{ + struct timeval tv; + uint64 tmp; + + // get the current time + // This gives back time since 0h Jan 1, 1970 + gettimeofday(&tv, 0); + + timevalue = origin_offset; + // now convert to proper time origin + timevalue += tv.tv_sec; + + timevalue <<= 32; + + // now convert the frequency of the fractional part + // from usec to 2^32 ticks/sec. + if (tv.tv_usec > 0) + { + tmp = (tv.tv_usec * freq_conv) >> 16; + timevalue += tmp; + } + + return 0; +} + + +NTPTime::NTPTime(const TimeValue& t) +{ + const timeval *pTimeVal = t.getBasicTimeStruct(); + + timevalue = origin_offset; + // now convert to proper time origin + timevalue += pTimeVal->tv_sec; + + timevalue <<= 32; + + + // now convert the frequency of the fractional part + // from usec to 2^32 ticks/sec. + uint64 tmp = (pTimeVal->tv_usec * freq_conv) >> 16; + + + timevalue += tmp; +} + + +int DayIndexFromDate(int year, int month, int day) +{ + // return index (0=Sunday, 1=Monday... etc + + int days_so_far[] = { 0 , 31 , 59 , 90 , 120, 151, + 181, 212, 243, 273, 304, 334 + }; + if (month > 12 || month < 0 || year < 1 || day < 1 || day > 31) + return 0; // bad value(s) + + int day_index = ((year - 1) * 365 + + (year - 1) / 4 + + days_so_far[month-1] + + day + + (((month > 2) && !(year % 4)) ? 1 : 0) + ) % 7; + return (day_index == 0) ? 6 : (day_index - 1); +} + +static const char* const months[] = { "Jan", "Feb", "Mar", "Apr", "May", + "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", + "" + }; +static const char* const days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + +OSCL_EXPORT_REF void PV8601ToRFC822(PV8601timeStrBuf pv8601_buffer, CtimeStrBuf ctime_buffer) +{ + // Convert from PV8601 Format (20010805T185430.000Z) + // to RFC822 Format (Sun Aug 5 18:54:30 2001) + // No functions will be used because this code must run on + // all platforms. + //---OSCL_HAS_ANSI_STRING_SUPPORT---// + if ((PV8601TIME_BUFFER_SIZE - 1) != strlen(pv8601_buffer)) + { + ctime_buffer[0] = 0; + return; + } + + char buf[5]; + + int year, mon, day, hour, min, sec; + + strncpy(buf, pv8601_buffer, 4); + buf[4] = 0; + year = atoi(buf); + + buf[2] = 0; + strncpy(buf, pv8601_buffer + 4, 2); + mon = atoi(buf); + if (mon <= 0 || mon > 13) + mon = 13; + strncpy(buf, pv8601_buffer + 6, 2); + day = atoi(buf); + strncpy(buf, pv8601_buffer + 9, 2); + hour = atoi(buf); + strncpy(buf, pv8601_buffer + 11, 2); + min = atoi(buf); + strncpy(buf, pv8601_buffer + 13, 2); + sec = atoi(buf); + + sprintf(ctime_buffer, + "%s %s %2d %02d:%02d:%02d %04d", + days[DayIndexFromDate(year, mon, day)], + months[mon-1], + day, hour, min, sec, year); + +} + +OSCL_EXPORT_REF void ISO8601ToRFC822(ISO8601timeStrBuf iso8601_buffer, CtimeStrBuf ctime_buffer) +{ + // Convert from ISO8601 Format (2001-08-05 18:54:30(Z)) + // to RFC822 Format (Sun Aug 5 18:54:30 2001) + // No functions will be used because this code must run on + // all platforms. + //---OSCL_HAS_ANSI_STRING_SUPPORT---// + if ((ISO8601TIME_BUFFER_SIZE - 1) != strlen(iso8601_buffer)) + { + ctime_buffer[0] = 0; + return; + } + + char buf[5]; + + int year, mon, day, hour, min, sec; + + strncpy(buf, iso8601_buffer, 4); + buf[4] = 0; + year = atoi(buf); + + buf[2] = 0; + strncpy(buf, iso8601_buffer + 5, 2); + mon = atoi(buf); + strncpy(buf, iso8601_buffer + 8, 2); + day = atoi(buf); + strncpy(buf, iso8601_buffer + 11, 2); + hour = atoi(buf); + strncpy(buf, iso8601_buffer + 14, 2); + min = atoi(buf); + strncpy(buf, iso8601_buffer + 17, 2); + sec = atoi(buf); + + sprintf(ctime_buffer, + "%s %s %2d %02d:%02d:%02d %04d", + days[DayIndexFromDate(year, mon, day)], + months[mon-1], + day, hour, min, sec, year); + +} +OSCL_EXPORT_REF void RFC822ToPV8601(CtimeStrBuf ctime_buffer, PV8601timeStrBuf pv8601_buffer) +{ + // Convert from RFC822 Format (Sun Aug 5 18:54:30 2001) + // to PV8601 Format (20010805T185430.000Z) + // No functions will be used because this code must run on + // all platforms. + + //---OSCL_HAS_ANSI_STRING_SUPPORT--- or ..// + const char *ptr = ctime_buffer; + + int mon = 0, day, hour, min, sec; + + for (int i = 0; *months[i]; i++) + { + if (!strncmp(ptr + 4, months[i], 3)) + { + mon = i + 1; + break; + } + } + + day = atoi(*(ptr + 8) == ' ' ? (ptr + 9) : (ptr + 8)); + hour = atoi(ptr + 11); + min = atoi(ptr + 14); + sec = atoi(ptr + 17); + + sprintf(pv8601_buffer, + "%04d%02d%02dT%02d%02d%02d.000Z", + atoi(ptr + 20), // year + mon, day, hour, min, sec); + +} + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +//! get_rfc822_gmtime_str not supported on all platforms +/*! + Notes: Symbian implementation feasible but not done. +*/ + +OSCL_EXPORT_REF char *TimeValue::get_rfc822_gmtime_str(int max_time_strlen, + char *time_str) +{ + //---OSCL_HAS_UNIX_TIME_FUNCS---// + struct tm *timeptr; + struct tm buffer; + timeptr = gmtime_r(&ts.tv_sec, &buffer); + + int length = snprintf(time_str, max_time_strlen, + "%s, %02d %s %04d %02d:%02d:%02d GMT", + days[timeptr->tm_wday], timeptr->tm_mday, + months[timeptr->tm_mon], timeptr->tm_year + 1900, + timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec); + if (length < 0 || length > max_time_strlen) + { + time_str[0] = NULL_TERM_CHAR; + } + return time_str; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +//! get_str_ctime not supported on all platforms +/*! + Notes: Symbian implementation of obsolete function get_str_time + modified to fit format returned by ctime +*/ +OSCL_EXPORT_REF char *TimeValue::get_str_ctime(CtimeStrBuf ctime_buffer) +{ + //---OSCL_HAS_UNIX_TIME_FUNCS---// + // Uses timeval basic time structure + char *ptr = ctime_r(&ts.tv_sec, ctime_buffer); + + char *ptr_end = strchr(ptr, '\n'); + if (ptr_end) *ptr_end = '\0'; + return ptr; + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSCL_EXPORT_REF int TimeValue::get_pv8601_str_time(PV8601timeStrBuf time_strbuf) +{ + //---OSCL_HAS_UNIX_TIME_FUNCS---// + int num_chars = 0; + struct tm *timeptr; + struct tm buffer; + + timeptr = gmtime_r(&ts.tv_sec, &buffer); + + if ((num_chars = strftime(time_strbuf, sizeof(PV8601timeStrBuf), + "%Y%m%dT%H%M%S", timeptr)) == 0) + time_strbuf[0] = NULL_TERM_CHAR; + else + num_chars += snprintf(time_strbuf + strlen(time_strbuf), + sizeof(PV8601timeStrBuf) - num_chars, + ".%03dZ", (int)(ts.tv_usec / 1000)); + + return num_chars; + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSCL_EXPORT_REF int TimeValue::get_ISO8601_str_time(ISO8601timeStrBuf time_strbuf) +{ + //---OSCL_HAS_UNIX_TIME_FUNCS---// + int num_chars = 0; + struct tm *timeptr; + struct tm buffer; + + // Get the time + timeptr = localtime_r(&ts.tv_sec, &buffer); + + char formatString[] = "%Y-%m-%d %H:%M:%S\0\0"; + + if (zulu) + { + formatString[sizeof("%Y-%m-%d %H:%M:%S")-1] = 'Z'; + } + + // Form the string. + if ((num_chars = strftime(time_strbuf, sizeof(ISO8601timeStrBuf), + formatString, timeptr)) == 0) + { + // Failed .. null the string and return. + time_strbuf[0] = NULL_TERM_CHAR; + } + + return num_chars; + +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_time.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_time.h new file mode 100644 index 0000000..821ee82 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_time.h @@ -0,0 +1,379 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ T I M E ( T I M E F U N C T I O N S ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_time.h + \brief The file oscl_time.h defines to classes NTPTime and TimeValue +for getting, manipulating, and formatting time values. +The TimeValue class is based on the native system time format while +NTPTime is used for the standard Network Time Protocol format. +*/ + + +#ifndef OSCL_TIME_H_INCLUDED +#define OSCL_TIME_H_INCLUDED + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCLCONFIG_TIME_H_INCLUDED +#include "osclconfig_time.h" +#endif + +#ifndef OSCL_INT64_UTILS_INCLUDED +#include "oscl_int64_utils.h" +#endif + +const int CTIME_BUFFER_SIZE = 26; + +const int PV8601TIME_BUFFER_SIZE = 21; +const int ISO8601TIME_BUFFER_SIZE = 21; + +typedef char CtimeStrBuf[CTIME_BUFFER_SIZE]; +typedef char PV8601timeStrBuf[PV8601TIME_BUFFER_SIZE]; +typedef char ISO8601timeStrBuf[ISO8601TIME_BUFFER_SIZE]; + +class TimeValue; // Forward definition + +OSCL_IMPORT_REF void PV8601ToRFC822(PV8601timeStrBuf pv8601_buffer, CtimeStrBuf ctime_buffer); +OSCL_IMPORT_REF void ISO8601ToRFC822(ISO8601timeStrBuf iso8601_buffer, CtimeStrBuf ctime_buffer); +OSCL_IMPORT_REF void RFC822ToPV8601(CtimeStrBuf ctime_buffer, PV8601timeStrBuf); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +//! The TimeUnits enum can be used when constructing a TimeValue class. +typedef enum { SECONDS = 0, MILLISECONDS = 1, MICROSECONDS = 2 } TimeUnits; + +const long USEC_PER_SEC = 1000000; +const long MSEC_PER_SEC = 1000; + +//! The following are used internally so not documented in the API +static const long MapToSeconds[] = {1, 1000, 1000000}; +static const long MapToUSeconds[] = {1000000, 1000, 1}; +static const long MapTo100NanoSeconds[] = {10000000, 10000, 10}; +const uint32 unix_ntp_offset = 2208988800U; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +//! The NTPTime class represents a time value as the number of seconds since 0h (UTC) Jan. 1, 1900 +/*! + The NTPTime class: + Conversion to/from Unix (epoch at 0h Jan. 1, 1970) amount to addition/subtraction of 2208988800. + A single 64 bit value is used to represent the time. This value represents the number of seconds + since 0h (UTC) Jan. 1, 1900. There is an implied binary point betweeen the upper 32 bits and lower + 32 bits (this is referred to as a 32.32 fractional representation). + For example a binary value of 00000000 00000000 00000000 00000011 10000000 00000000 00000000 00000000 + represents 3.5 seconds since Jan 1, 1900. +*/ +class NTPTime +{ + + private: + uint64 timevalue; + + public: + //! The default constructor creates an NTPTime instance representing the current system time. + OSCL_COND_IMPORT_REF NTPTime(); + + //! Copy constructor to create a new NTPTime from an existing one. + OSCL_COND_IMPORT_REF NTPTime(const NTPTime& src); + + //! Construct an NTPTime from a uint32. + /*! \param seconds The uint32 input represents the number of seconds since Jan. 1, 1900. */ + OSCL_COND_IMPORT_REF NTPTime(const uint32 seconds); + + //! Construct an NTPTime from a int. + /*! \param seconds The int input represents the number of seconds since Jan. 1, 1900. */ + OSCL_COND_IMPORT_REF NTPTime(const int32 seconds); + + //! Construct a NTPTime instance from a TimeValue instance. + /*! + This constructor creates an NTPTime value representing the same absolute time as the TimeValue parameter. + \param t A reference to a TimeValue object. + */ + OSCL_COND_IMPORT_REF NTPTime(const TimeValue& t); + + //! Construct a NTPTime instance from a uint64 value. + /*! \param value A 64 bit integer argument which is used as the ntp 32.32 fractional representation.*/ + OSCL_COND_IMPORT_REF NTPTime(const uint64 value); + + + //! The assignment operator for a 32 bit integer. + /*! \param newval A 32 bit integer representing the upper 32 bits of the 32.32 NTP time (e.g. the number of whole seconds since Jan 1, 1900 UTC).*/ + OSCL_COND_IMPORT_REF NTPTime& operator=(uint32 newval); + + //! The assignment operator for a 64 bit integer. + /*! \param newval A 64 bit value which represents the 32.32 fractional representation of the ntp time. */ + OSCL_COND_IMPORT_REF NTPTime& operator=(uint64 newval); + + //! The += operator is used to add a 64 bit 32.32 value to an existing NTPTime value. + /*! \param val The 64 bit 32.32 value to add to this object's value. */ + OSCL_COND_IMPORT_REF NTPTime& operator+=(uint64 val); + + //! The - operator allows subtraction of one NTPTime value from another. This is useful to measure an interval. + /*! \param ntpt A reference to the NTPTime object to be subracted from this one. */ + OSCL_COND_IMPORT_REF NTPTime operator-(const NTPTime &ntpt) const; + + //! This method converts a 32-bit system time to NTP time. + /*! + This method sets the value of the NTPTime instance to the absolute time + represented by the 32 bit input argument. + \param systemtime This 32-bit value is interpreted as the number of seconds + since the unix epoch Jan. 1 1970. + */ + void set_from_system_time(const uint32 systemtime); + + //! Grab the middle 32 bits of the 64 bit 32.32 representation. + /* \return This method returns the middle 32 bits of the 32.32 representation. */ + OSCL_COND_IMPORT_REF uint32 get_middle32() const; + + //! This method returns the upper 32 bits of the 32.32 representation. + OSCL_COND_IMPORT_REF uint32 get_upper32() const; + + //! This method returns the lower 32 bits of the 32.32 representation. + OSCL_COND_IMPORT_REF uint32 get_lower32() const; + + //! This method converts the ntp time value to system time. + /*! + This method returns a 32 bit value representing the same absolute time as the NTP time value, + but expressed as whole seconds since the unix epoch. The fractional part of the ntp value is discarded. + */ + int32 to_system_time() const; + + //! This method returns the 32.32 ntp representation. + OSCL_COND_IMPORT_REF uint64 get_value() const; + + //! This method sets the 32.32 representation to the current system time value. + OSCL_IMPORT_REF int set_to_current_time(); + +}; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +//! The TimeValue class represents a time value in a format native to the system. +/*! + This class provides common time functions independent of any OS. The actual representation used + is native to the system that the class is compiled on to increase efficiency. + Macros used in this class: + - OSCL_HAS_ANSI_STRING_SUPPORT: + + Definitions to determine the type of basic time structure used to store the time + - OSCL_HAS_UNIX_TIME_FUNCS + - OSCL_HAS_SYMBIAN_SUPPORT + - OSCL_HAS_MSWIN_SUPPORT + + +*/ +class TimeValue +{ + + public: + //! Create a TimeValue representing the current time. + OSCL_COND_IMPORT_REF TimeValue(); + + //! Copy constructor + OSCL_COND_IMPORT_REF TimeValue(const TimeValue& Tv); + + //! Create a TimeValue representing an interval of tv units. + /*! + \param tv The number of units in the interval to be represented by this TimeValue. + \param units The units of the tv argument. Must be in the enumeration TimeUnits. + */ + OSCL_COND_IMPORT_REF TimeValue(long tv, TimeUnits units); + + //! Create a TimeValue representing the absolute time specified by the BasicTimeStruct. + /*! \param in_tv OsclBasicTimeStruct as defined for each platform. + */ + OSCL_COND_IMPORT_REF TimeValue(const OsclBasicTimeStruct& in_tv); + + OSCL_COND_IMPORT_REF TimeValue(const ISO8601timeStrBuf time_strbuf); + //! Create a TimeValue representing the absolute time specified by the + //! year/month/day/hours/minutes/seconds/microseconds values passed as argument. + /*! + * TimeValue constructor that sets time according to following input parameter for a specific date time. + * Please note that no argument is check for its validity (range etc) + * It might assert incase wrong argument are passed by user of this api. + * @param [in] uint16 wYear; + * @param [in] uint16 wMonth; Jan = 1 to Dec = 12 + * @param [in] uint16 wDay; 1-28/29/30/31 + * @param [in] uint16 wHour; 0 to 23 + * @param [in] uint16 wMinute; 0 to 59 + * @param [in] uint16 wSecond; 0 to 59 + * @param [in] uint16 wMilliseconds; 0 to 999 + */ + OSCL_COND_IMPORT_REF TimeValue(uint16 aYear, uint16 aMonth, uint16 aDay, uint16 aHour, + uint16 aMinute, uint16 aSecond, uint16 aMilliseconds); + + //! Create a TimeValue representing the absolute time specified by the BasicDateTimeStruct. + /*! \param in_ts OsclBasicDateTimeStruct as defined for each platform provides the date in a + readable format (i.e. day, date , week etc.) + Notes: Implementation incomplete (= not done) on Win32, Wince, Symbian + */ + OSCL_COND_IMPORT_REF TimeValue(OsclBasicDateTimeStruct in_ts); + + //! Get the local time after having adjusted for daylight saving + /*! + Notes: Implementation incomplete (= not done) on Win32, Wince, Symbian + */ + OSCL_COND_IMPORT_REF int32 get_local_time(); + + + friend class NTPTime; + + //! Set the time value to zero (represents a zero interval). + OSCL_COND_IMPORT_REF void set_to_zero(); + + //! Set the time value to the current system time. + OSCL_COND_IMPORT_REF void set_to_current_time(); + + //! This method coverts a 32-bit NTP offset to system time + /*! + This method takes a 32-bit ntp offset which is the number of seconds from + 0 h Jan 1, 1900 and converts it to the system time + */ + OSCL_COND_IMPORT_REF void set_from_ntp_time(const uint32 ntp_offset); + + //! Get a 32 bit value representing the seconds since the (system dependent) epoch. + /*! + \return This call returns a 32 bit value representing the nubmer of seconds since the epoch. + On unix systems this represents the number of seconds since the unix epoch Jan 1 1970. + On Win32 this represents the number of seconds since Jan 1, 1601. This is intended to be used + for intervals rather than for absolute time. (On Win32 for example, a 32 bit value would be too + small to represent the number of seconds from the epoch until the current time.) + */ + OSCL_COND_IMPORT_REF uint32 get_sec() const ; + + OSCL_COND_IMPORT_REF int32 to_msec() const; + + //! Get a 32 bit value representing the number of microseconds in the time value. + /*! + \return Returns a uint32 value representing the number of microseconds in the time value after subtracting off the whole seconds. + */ + OSCL_COND_IMPORT_REF uint32 get_usec() const ; + //! Get a 64 bit value representing the time value converted to microseconds + /*! + \return Returns a uint64 value representing the time value in terms of microseconds.The + The time origin is dependent on platform for which OSCL is compiled. For example + for symbian it is midnight, January 1st, 0 AD + for windows it is January 1, 1601 (UTC) + */ + OSCL_COND_IMPORT_REF uint64 get_timevalue_in_usec() const ; + + //! Get a string containing a text representation of this TimeValue object. + /*! + \param ctime_strbuf A CtimeStrBuf object to which the text representation will be written, + \return A pointer to the input CtimeStrBuf is returned. This string is null terminated of the form + "Wed Jun 30 21:49:08 1993". + */ + OSCL_IMPORT_REF char *get_str_ctime(CtimeStrBuf ctime_strbuf); + + //! Get a PV extended text representation of the Time based on the PV 8601 format. + /*! + \param time_strbuf A PV8601timeStrBuf object to which the text representation will be written, + \return The number of characters copied to the buffer, not including the terminating null. The returned string is of the form "19850412T101530.047Z". + */ + OSCL_IMPORT_REF int get_pv8601_str_time(PV8601timeStrBuf time_strbuf); + + //! Get a PV extended text representation of the Time based on the ISO 8601 format. + /*! + \param time_strbuf A ISO8601timeStrBuf object to which the text representation will be written, + \return The number of characters copied to the buffer, not including the terminating null. The returned string is of the form "1985-04-12 10:15:30Z". + */ + OSCL_IMPORT_REF int get_ISO8601_str_time(ISO8601timeStrBuf time_strbuf); + + //! Get a text representation of the time in the GMT timezone based on the RFC 822 / RFC 1123 (also described in the HTTP spec RFC 2068 and RFC 2616. + /*! + \param max_time_strlen The maximum number of characters that can be written to the buffer. + \param time_str A pointer to the buffer to which the characters will be written. + \return Returns a pointer to the buffer (same as time_str) containing a null terminated (c-style) string + of the form "Wed, 30 Jun 1993 21:49:08 GMT". + */ + OSCL_IMPORT_REF char *get_rfc822_gmtime_str(int max_time_strlen, + char *time_str); + + //! Determine if the time value is zero. + OSCL_COND_IMPORT_REF bool is_zero(); + + //! Manipulate internal flags to mark the time value as being in "zulu" (GMT) time. + + OSCL_COND_IMPORT_REF bool is_zulu() const; + OSCL_COND_IMPORT_REF void set_zulu(bool is_zulu); + + // comparison operators + OSCL_COND_IMPORT_REF friend bool operator ==(const TimeValue& a, const TimeValue& b); + OSCL_COND_IMPORT_REF friend bool operator !=(const TimeValue& a, const TimeValue& b); + OSCL_COND_IMPORT_REF friend bool operator <=(const TimeValue& a, const TimeValue& b); + OSCL_COND_IMPORT_REF friend bool operator >=(const TimeValue& a, const TimeValue& b); + OSCL_COND_IMPORT_REF friend bool operator <(const TimeValue& a, const TimeValue& b); + OSCL_COND_IMPORT_REF friend bool operator >(const TimeValue& a, const TimeValue& b); + + //! Assignment operator + OSCL_COND_IMPORT_REF TimeValue& operator =(const TimeValue& a); + + // arithmetic operators + //! += operator + OSCL_COND_IMPORT_REF TimeValue& operator +=(const TimeValue& a); + //! -= operator + OSCL_COND_IMPORT_REF TimeValue& operator -=(const TimeValue& a); + //! This operator scales the time value by a constant. + OSCL_COND_IMPORT_REF TimeValue& operator *=(const int scale); + + OSCL_COND_IMPORT_REF OsclBasicTimeStruct * get_timeval_ptr(); + + OSCL_COND_IMPORT_REF TimeValue& operator+=(const int32 aSeconds); + OSCL_COND_IMPORT_REF TimeValue& operator-=(const int32 aSeconds); + private: + + bool zulu; + OsclBasicTimeStruct ts; + const OsclBasicTimeStruct *getBasicTimeStruct() const + { + return &ts; + }; + +}; + +OSCL_COND_IMPORT_REF TimeValue operator -(const TimeValue& a, const TimeValue& b); +OSCL_COND_IMPORT_REF TimeValue operator+(const TimeValue& a, const int32 bSeconds); +OSCL_COND_IMPORT_REF TimeValue operator+(const int32 aSeconds, const TimeValue& b); +OSCL_COND_IMPORT_REF TimeValue operator-(const TimeValue& a, const int32 bSeconds); +OSCL_COND_IMPORT_REF TimeValue operator-(const int32 aSeconds, const TimeValue& b); + +#if (!OSCL_DISABLE_INLINES) +#include "oscl_time.inl" +#endif + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +/*! @} */ + + +#endif // OSCL_TIME_H_INCLUDED diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_time.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_time.inl new file mode 100644 index 0000000..1a83d65 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_time.inl @@ -0,0 +1,499 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ T I M E ( T I M E F U N C T I O N S ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +#include "oscl_int64_utils.h" +#include "oscl_assert.h" +#include "oscl_stdstring.h" +#include "oscl_string_utils.h" + +//------ NTPTime ------------ +OSCL_COND_EXPORT_REF OSCL_INLINE NTPTime::NTPTime() +{ + set_to_current_time(); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE NTPTime::NTPTime(const NTPTime& src) +{ + timevalue = src.timevalue; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE NTPTime::NTPTime(const uint32 seconds) +{ + Oscl_Int64_Utils::set_uint64(timevalue, seconds, 0); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE NTPTime::NTPTime(const int32 seconds) +{ + if (seconds < 0) return; + timevalue = uint64(seconds) << 32; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE NTPTime::NTPTime(const uint64 value) +{ + timevalue = value; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE NTPTime& NTPTime::operator=(uint32 newval) +{ + Oscl_Int64_Utils::set_uint64(timevalue, newval, 0); + return *this; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE NTPTime& NTPTime::operator=(uint64 newval) +{ + timevalue = newval; + return *this; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE NTPTime& NTPTime::operator+=(uint64 val) +{ + timevalue += val; + return *this; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE NTPTime NTPTime::operator-(const NTPTime &ntpt) const +{ + NTPTime temp; + temp.timevalue = timevalue - ntpt.timevalue; + return temp; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE void NTPTime::set_from_system_time(const uint32 systemtime) +{ + timevalue = int64(systemtime + 2208988800U) << 32; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE uint32 NTPTime::get_middle32() const +{ + return Oscl_Int64_Utils::get_uint64_middle32(timevalue); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE uint32 NTPTime::get_upper32() const +{ + return Oscl_Int64_Utils::get_uint64_upper32(timevalue); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE uint32 NTPTime::get_lower32() const +{ + return Oscl_Int64_Utils::get_uint64_lower32(timevalue); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE int32 NTPTime::to_system_time() const +{ + return (uint32)((timevalue >> 32) - 2208988800U); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE uint64 NTPTime::get_value() const +{ + return timevalue; +} + +//------ TimeValue ---------- +OSCL_COND_EXPORT_REF OSCL_INLINE bool TimeValue::is_zero() +{ + return ((ts.tv_usec == 0) && (ts.tv_sec == 0)); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE bool TimeValue::is_zulu() const +{ + return zulu; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE void TimeValue::set_zulu(bool is_zulu) +{ + zulu = is_zulu; +} +OSCL_COND_EXPORT_REF OSCL_INLINE uint32 TimeValue::get_sec() const +{ + return ts.tv_sec; +}; + + +OSCL_COND_EXPORT_REF OSCL_INLINE int32 TimeValue::to_msec() const +{ + return ((ts.tv_usec / 1000) + (ts.tv_sec * 1000)); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE uint32 TimeValue::get_usec() const +{ + return ts.tv_usec; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE uint64 TimeValue::get_timevalue_in_usec() const +{ + + uint64 aTempSec = 0; + uint64 aTempUsec = 0; + + Oscl_Int64_Utils::set_uint64(aTempSec, 0, ts.tv_sec); + Oscl_Int64_Utils::set_uint64(aTempUsec, 0, ts.tv_usec); + + return ((aTempSec * 1000000) + (aTempUsec)); + +} + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue operator -(const TimeValue& a, const TimeValue& b) +{ + TimeValue c; + c = a; + c -= b; + return c; +} + + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue operator+(const TimeValue& a, const int32 bSeconds) +{ + TimeValue c = a; + return c += bSeconds; +} + +OSCL_COND_IMPORT_REF OSCL_INLINE TimeValue operator+(const int32 aSeconds, const TimeValue& b) +{ + TimeValue c = b; + return c += aSeconds; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue operator-(const TimeValue& a, const int32 bSeconds) +{ + TimeValue c = a; + return c -= bSeconds; +} + +OSCL_COND_IMPORT_REF OSCL_INLINE TimeValue operator-(const int32 aSeconds, const TimeValue& b) +{ + TimeValue c = b; + return c -= aSeconds; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue& TimeValue::operator+=(const int32 aSeconds) +{ + // Adding a negative number? + if (aSeconds < 0) + { + // Negative number. Convert to a positive. + int32 sec_value = OSCL_ABS(aSeconds); + + // Subtract instead. + return *this -= sec_value; + } + + TimeValue aSec(aSeconds, SECONDS); + return *this += aSec; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue& TimeValue::operator-=(const int32 aSeconds) +{ + // Subtracting a negative number? + if (aSeconds < 0) + { + // Negative number. Convert to a positive. + int32 sec_value = OSCL_ABS(aSeconds); + + // Add instead. + return *this += sec_value; + } + + TimeValue aSec(aSeconds, SECONDS); + return *this -= aSec; +} +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue& TimeValue::operator =(const TimeValue & a) +{ + this->zulu = a.zulu; + this->ts.tv_usec = a.ts.tv_usec; + this->ts.tv_sec = a.ts.tv_sec; + return *this; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue& TimeValue::operator +=(const TimeValue & a) +{ + this->ts.tv_usec += a.ts.tv_usec; + this->ts.tv_sec += a.ts.tv_sec; + + if (this->ts.tv_usec >= USEC_PER_SEC) + { + this->ts.tv_usec -= USEC_PER_SEC; + ++this->ts.tv_sec; + } + return *this; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue& TimeValue::operator -=(const TimeValue & a) +{ + this->ts.tv_usec -= a.ts.tv_usec; + this->ts.tv_sec -= a.ts.tv_sec; + + if ((this->ts.tv_sec > 0) && (this->ts.tv_usec < 0)) + { + this->ts.tv_usec += USEC_PER_SEC; + --this->ts.tv_sec; + } + return *this; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue& TimeValue::operator *=(const int scale) +{ + this->ts.tv_usec *= scale; + this->ts.tv_sec *= scale; + unsigned long secs = this->ts.tv_usec / USEC_PER_SEC; + this->ts.tv_sec += secs; + this->ts.tv_usec -= secs * USEC_PER_SEC; + return *this; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +OSCL_COND_EXPORT_REF OSCL_INLINE bool operator ==(const TimeValue& a, const TimeValue& b) +{ + return timercmp(&a.ts, &b.ts, ==); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OSCL_COND_EXPORT_REF OSCL_INLINE bool operator !=(const TimeValue& a, const TimeValue& b) +{ + return timercmp(&a.ts, &b.ts, !=); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OSCL_COND_EXPORT_REF OSCL_INLINE bool operator <=(const TimeValue& a, const TimeValue& b) +{ + + return !timercmp(&a.ts, &b.ts, >); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OSCL_COND_EXPORT_REF OSCL_INLINE bool operator >=(const TimeValue& a, const TimeValue& b) +{ + return !timercmp(&a.ts, &b.ts, <); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +OSCL_COND_EXPORT_REF OSCL_INLINE bool operator >(const TimeValue& a, const TimeValue& b) +{ + return timercmp(&a.ts, &b.ts, >); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OSCL_COND_EXPORT_REF OSCL_INLINE bool operator <(const TimeValue& a, const TimeValue& b) +{ + + return timercmp(&a.ts, &b.ts, <); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSCL_COND_EXPORT_REF OSCL_INLINE void TimeValue::set_to_current_time() +{ + gettimeofday(&ts, NULL); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +#include "oscl_mem_basic_functions.h" + +OSCL_COND_EXPORT_REF OSCL_INLINE void TimeValue::set_to_zero() +{ + oscl_memset(&ts, 0, sizeof(ts)); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue::TimeValue() +{ + zulu = false; + gettimeofday(&ts, NULL); +} + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue::TimeValue(const TimeValue& Tv) +{ + zulu = Tv.zulu; + ts.tv_usec = Tv.ts.tv_usec; + ts.tv_sec = Tv.ts.tv_sec; +} + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue::TimeValue(const OsclBasicTimeStruct& in_tv) +{ + zulu = false; + ts.tv_usec = in_tv.tv_usec; + ts.tv_sec = in_tv.tv_sec; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue::TimeValue(uint16 aYear, uint16 aMonth, uint16 aDay, uint16 aHour, + uint16 aMinute, uint16 aSecond, uint16 aMilliseconds) +{ + + /*struct tm aTmBuffer;*/ + + OsclBasicDateTimeStruct aTmBuffer; + memset(&aTmBuffer, 0, sizeof(aTmBuffer)); + + aTmBuffer.tm_sec = aSecond; /* seconds afterthe minute - [0, 61] */ + /* for sleap seconds */ + aTmBuffer.tm_min = aMinute; /* minutes after the hour - [0, 59] */ + aTmBuffer.tm_hour = aHour; /* hour since midnight - [0, 23] */ + aTmBuffer.tm_mday = aDay; /* day of the month- [1, 31] */ + aTmBuffer.tm_mon = aMonth - 1 ; /* months since January - [0, 11] */ + aTmBuffer.tm_year = (aYear - 1900);/* years since 1900*/ + + time_t AbsoluteTime = mktime(&aTmBuffer); + + if (AbsoluteTime == (time_t) - 1) + { + OSCL_ASSERT(false); // wrong input to this api + } + else + { + /*Filling the TimeVal ts Structure for further Use */ + memset(&ts, 0 , sizeof(ts)); + ts.tv_sec = AbsoluteTime ; + ts.tv_usec = ((aMilliseconds) * (1000)); + } + + +} +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue::TimeValue(long num_units, TimeUnits units) +{ + zulu = false; + ts.tv_sec = num_units / MapToSeconds[units]; + long diff = num_units - MapToSeconds[units] * ts.tv_sec; + ts.tv_usec = diff * MapToUSeconds[units]; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSCL_COND_EXPORT_REF OSCL_INLINE void TimeValue::set_from_ntp_time(const uint32 ntp_offset_seconds) +{ + ts.tv_sec = ntp_offset_seconds - unix_ntp_offset; + ts.tv_usec = 0; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue::TimeValue(const ISO8601timeStrBuf time_strbuf) +{ + char buf[5]; + + int year, mon, day, hour, min, sec; + + strncpy(buf, time_strbuf, 4); + buf[4] = 0; + year = atoi(buf); + buf[2] = 0; + strncpy(buf, time_strbuf + 5, 2); + mon = atoi(buf); + strncpy(buf, time_strbuf + 8, 2); + day = atoi(buf); + strncpy(buf, time_strbuf + 11, 2); + hour = atoi(buf); + strncpy(buf, time_strbuf + 14, 2); + min = atoi(buf); + strncpy(buf, time_strbuf + 17, 2); + sec = atoi(buf); + + zulu = (time_strbuf[19] == 'Z') ? true : false; + + // Fill in the time structure + OsclBasicDateTimeStruct timeStruct; + + timeStruct.tm_sec = sec; + timeStruct.tm_min = min; + timeStruct.tm_hour = hour; + timeStruct.tm_mday = day; + timeStruct.tm_mon = mon - 1; + timeStruct.tm_year = year - 1900; + timeStruct.tm_wday = -1; + timeStruct.tm_yday = -1; + timeStruct.tm_isdst = -1; + timeStruct.tm_gmtoff = -1; + + // Convert to a timeval + ts.tv_sec = mktime(&timeStruct); + ts.tv_usec = 0; + +} + + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OSCL_COND_EXPORT_REF OSCL_INLINE TimeValue::TimeValue(OsclBasicDateTimeStruct ints) +{ + ts.tv_sec = mktime(&ints); + ts.tv_usec = 0; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +OSCL_COND_EXPORT_REF OSCL_INLINE int32 TimeValue::get_local_time() +{ + // Daylight saving time offset of 1 hour in the summer + uint dst_offset = 60 * 60; + int32 GMTime = ts.tv_sec; + + struct tm *timeptr; + struct tm buffer; + int dstFlag; + timeptr = localtime_r(&ts.tv_sec, &buffer); + + GMTime -= timeptr->tm_gmtoff; + + dstFlag = timeptr->tm_isdst; + + if (dstFlag == 1) + { + // Daylight saving time. Add an hour's offset to get GMT + GMTime += dst_offset; + } + + return GMTime; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE OsclBasicTimeStruct * TimeValue::get_timeval_ptr() +{ + return &ts; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tls.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tls.cpp new file mode 100644 index 0000000..5b04632 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tls.cpp @@ -0,0 +1,256 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_base.h" + +#include "oscl_tls.h" +#include "oscl_assert.h" + +//Use a magic number to help detect un-initialized TLS. +#define OSCL_TLS_MAGIC_NUMBER 0x8765abcd +#define OSCL_TLS_REGISTRY_VALID(reg) (reg!=0 && reg[OSCL_TLS_ID_MAGICNUM]==(OsclAny*)OSCL_TLS_MAGIC_NUMBER) + +OSCL_EXPORT_REF void TLSStorageOps::save_registry(TOsclTlsKey* key, OsclAny* ptr, int32 &aError) +{ + aError = 0; +#if (OSCL_TLS_IS_KEYED) + OSCL_ASSERT(key); + if (!OSCL_TLS_STORE_FUNC(*key, ptr)) + { + aError = EPVErrorBaseSystemCallFailed; + return; + } +#else + OSCL_UNUSED_ARG(key); + if (!OSCL_TLS_STORE_FUNC(ptr)) + { + aError = EPVErrorBaseSystemCallFailed; + return; + } +#endif +} + +OSCL_EXPORT_REF OsclAny* TLSStorageOps::get_registry(TOsclTlsKey* key) +{ +#if (OSCL_TLS_IS_KEYED) + OSCL_ASSERT(key); + return OSCL_TLS_GET_FUNC(*key); +#else + OSCL_UNUSED_ARG(key); + return OSCL_TLS_GET_FUNC(); +#endif +} + +#if (OSCL_TLS_IS_KEYED) + +//Global var for Tls Key. +OsclTLSRegistry::TlsKey* OsclTLSRegistry::iTlsKey = NULL; + + +#endif //OSCL_TLS_IS_KEYED + +_OsclBasicLock OsclTLSRegistry::sLock; // static object instanciated, alive with application + +OSCL_EXPORT_REF void OsclTLSRegistry::initialize(Oscl_DefAlloc &alloc, int32 &aError) +{ + TOsclTlsKey* pkey = NULL; + aError = 0; + sLock.Lock(); + +#if ( OSCL_TLS_IS_KEYED) + //Allocate the table on the first init call. + //Note there's some risk of thread contention here, since + //the thread lock is not available until after this step. + if (!iTlsKey) + { + OsclAny* table = alloc.allocate(sizeof(TlsKey)); + if (!table) + { + aError = EPVErrorBaseOutOfMemory; + sLock.Unlock(); + return; + } + + //allocate space for key + pkey = (TOsclTlsKey*)alloc.allocate(sizeof(TOsclTlsKey)); + if (!pkey) + { + aError = EPVErrorBaseOutOfMemory; + alloc.deallocate(table); + sLock.Unlock(); + return; + } + + //create key for this thread. + if (!OSCL_TLS_KEY_CREATE_FUNC(*pkey)) + { + aError = EPVErrorBaseSystemCallFailed; + alloc.deallocate(pkey); + alloc.deallocate(table); + sLock.Unlock(); + return; + } + + iTlsKey = new(table) TlsKey(); + iTlsKey->iRefCnt++; + iTlsKey->iOsclTlsKey = pkey; + } + else + { + iTlsKey->iRefCnt++; + pkey = iTlsKey->iOsclTlsKey; + } + +#endif + + // allocate the space and save the pointer + registry_pointer_type registry = OSCL_STATIC_CAST(registry_pointer_type, + alloc.allocate(sizeof(registry_type) * OSCL_TLS_MAX_SLOTS)); + if (registry == 0) + { + aError = EPVErrorBaseOutOfMemory; + sLock.Unlock(); + return; + } + + // initialize all TLSs to 0 + for (uint32 ii = 0; ii < OSCL_TLS_MAX_SLOTS; ii++) + registry[ii] = 0; + // initialize the magic number + registry[OSCL_TLS_ID_MAGICNUM] = (OsclAny*)OSCL_TLS_MAGIC_NUMBER; + + // save it away + TLSStorageOps::save_registry(pkey, registry, aError); + sLock.Unlock(); +} + +OSCL_EXPORT_REF void OsclTLSRegistry::cleanup(Oscl_DefAlloc &alloc, int32 &aError) +{ + TOsclTlsKey* pkey = NULL; + aError = 0; + sLock.Lock(); + +#if (OSCL_TLS_IS_KEYED) + if (!iTlsKey) + { + aError = EPVErrorBaseNotInstalled;//No key! + sLock.Unlock(); + return; + } + pkey = iTlsKey->iOsclTlsKey; +#endif + + //Cleanup this thread's registry + registry_pointer_type registry = OSCL_STATIC_CAST(registry_pointer_type , TLSStorageOps::get_registry(pkey)); + if (!OSCL_TLS_REGISTRY_VALID(registry)) + { + aError = EPVErrorBaseNotInstalled;//No registry! + sLock.Unlock(); + return; + } + alloc.deallocate(registry); + + TLSStorageOps::save_registry(pkey, NULL, aError); + if (aError) + { + sLock.Unlock(); + return; + } + +#if (OSCL_TLS_IS_KEYED) + + //Remove Tls key + iTlsKey->iRefCnt--; + if (iTlsKey->iRefCnt == 0) + { + //Deallocate key. + OSCL_TLS_KEY_DELETE_FUNC(*pkey); + alloc.deallocate(pkey); + iTlsKey->~TlsKey(); + alloc.deallocate(iTlsKey); + iTlsKey = NULL; + } +#endif + + sLock.Unlock(); +} + +OSCL_EXPORT_REF OsclAny* OsclTLSRegistry::getInstance(uint32 ID, int32 &aError) +{ + OSCL_ASSERT(ID < OSCL_TLS_MAX_SLOTS); + + aError = 0; + + TOsclTlsKey* pkey = NULL; + + sLock.Lock(); +#if (OSCL_TLS_IS_KEYED) + if (!iTlsKey) + { + aError = EPVErrorBaseNotInstalled;//No table! + sLock.Unlock(); + return NULL; + } + pkey = iTlsKey->iOsclTlsKey; +#endif + + registry_pointer_type registry = OSCL_STATIC_CAST(registry_pointer_type , TLSStorageOps::get_registry(pkey)); + if (!OSCL_TLS_REGISTRY_VALID(registry)) + { + aError = EPVErrorBaseNotInstalled;//No registry! + sLock.Unlock(); + return NULL; + } + registry_type id = registry[ID]; + sLock.Unlock(); + + return id; +} + +OSCL_EXPORT_REF void OsclTLSRegistry::registerInstance(OsclAny* ptr, uint32 ID, int32 &aError) +{ + OSCL_ASSERT(ID < OSCL_TLS_MAX_SLOTS); + + aError = 0; + TOsclTlsKey *pkey = NULL; + sLock.Lock(); + +#if (OSCL_TLS_IS_KEYED) + if (!iTlsKey) + { + aError = EPVErrorBaseNotInstalled;//No table! + sLock.Unlock(); + return ; + } + pkey = iTlsKey->iOsclTlsKey; +#endif + + registry_pointer_type registry = OSCL_STATIC_CAST(registry_pointer_type , TLSStorageOps::get_registry(pkey)); + if (!OSCL_TLS_REGISTRY_VALID(registry)) + { + aError = EPVErrorBaseNotInstalled;//no registry! + sLock.Unlock(); + return; + } + + registry[ID] = ptr; + sLock.Unlock(); +} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tls.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tls.h new file mode 100644 index 0000000..6fcc2f5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tls.h @@ -0,0 +1,205 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ T L S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/** + * @file oscl_TLS.h + * @brief This file defines the OsclTLS template class. This class + * provides a container which used to give access to a single instance + * of a class within the scope of the TLS. + * + */ + +#ifndef OSCL_TLS_H_INCLUDED +#define OSCL_TLS_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + + +#if (OSCL_TLS_IS_KEYED) + +//Keyed TLS requires global variable support +#else + +//unused value. +typedef OsclAny TOsclTlsKey; + +#endif //OSCL_TLS_IS_KEYED + + +// list of TLS objects +const uint32 OSCL_TLS_ID_MAGICNUM = 0; +const uint32 OSCL_TLS_ID_ERRORHOOK = 1; +const uint32 OSCL_TLS_ID_PVLOGGER = 2; +const uint32 OSCL_TLS_ID_TEST = 3; +const uint32 OSCL_TLS_ID_PVSCHEDULER = 4; +const uint32 OSCL_TLS_ID_PVERRORTRAP = 5; +const uint32 OSCL_TLS_ID_SDPMEDIAPARSER = 6; +const uint32 OSCL_TLS_ID_PAYLOADPARSER = 7; +const uint32 OSCL_TLS_ID_PVMFRECOGNIZER = 8; +const uint32 OSCL_TLS_ID_WMDRM = 9; +const uint32 OSCL_TLS_ID_OSCLREGISTRY = 10; +const uint32 OSCL_TLS_ID_SQLITE3 = 11; +const uint32 OSCL_TLS_ID_BASE_LAST = 11; // should always equal the largest ID defined here + +#define OSCL_TLS_BASE_SLOTS OSCL_TLS_ID_BASE_LAST +1 + +//There may be additional slots defined in the osclconfig.h for the build. +#ifndef OSCL_TLS_EXTERNAL_SLOTS +#define OSCL_TLS_EXTERNAL_SLOTS 0 +#endif + +#define OSCL_TLS_MAX_SLOTS ( OSCL_TLS_BASE_SLOTS + OSCL_TLS_EXTERNAL_SLOTS) + +class TLSStorageOps +{ + public: + OSCL_IMPORT_REF static void save_registry(TOsclTlsKey* key, OsclAny* ptr, int32&); + OSCL_IMPORT_REF static OsclAny* get_registry(TOsclTlsKey* key); +}; + +class OsclTLSRegistry +{ + public: + /* + ** Get an entry + ** @param ID: identifier + ** @param error (output) 0 for success or an error from TPVBaseErrorEnum + ** @returns: the entry value + */ + OSCL_IMPORT_REF static OsclAny* getInstance(uint32 ID, int32 &error); + /* + ** Set an entry + ** @param ID: identifier + ** @param error (output) 0 for success or an error from TPVBaseErrorEnum + ** @returns: the entry value + */ + OSCL_IMPORT_REF static void registerInstance(OsclAny* ptr, uint32 ID, int32 &error); + + private: + OsclTLSRegistry() + {} + typedef OsclAny* registry_type; + typedef registry_type* registry_pointer_type; + static _OsclBasicLock sLock; // _osclbaselock declaration with TLS registry and key + +#if ( OSCL_TLS_IS_KEYED) + class TlsKey + { + public: + TlsKey(): iRefCnt(0), iOsclTlsKey(NULL) + {} + uint32 iRefCnt; + TOsclTlsKey *iOsclTlsKey; + }; + + //The key is a global variable. + static TlsKey* iTlsKey; +#endif + + private: + OSCL_IMPORT_REF static void initialize(Oscl_DefAlloc &alloc, int32 &error); + OSCL_IMPORT_REF static void cleanup(Oscl_DefAlloc &alloc, int32 &error); + friend class OsclBase; + +}; + +template < class T, uint32 ID, class Registry = OsclTLSRegistry > class OsclTLS +{ + private: + // make the copy constructor and assignment operator private + OsclTLS& operator=(OsclTLS& _Y) + { + return(*this); + } + + protected: + T* _Ptr; + + public: + OsclTLS() + { + int32 err; + _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID, err)); + } + + ~OsclTLS() {}; + + /** + * @brief The indirection operator (*) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclTLS can be used like the + * regular pointer that it was initialized with. + */ + T& operator*() const + { + return(*_Ptr); + } + + /** + * @brief The indirection operator (->) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclTLS can be used like the + * regular pointer that it was initialized with. + */ + T *operator->() const + { + return(_Ptr); + } + + + /** + * @brief set() method sets ownership to the pointer, passed. + * This method is needed when the class is created with a default + * constructor. Returns false in case the class is non-empty. + * + */ + bool set() + { + int32 err; + _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID, err)); + return (_Ptr ? true : false); + } + +}; + +/*! @} */ + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tree.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tree.cpp new file mode 100644 index 0000000..a1c9454 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tree.cpp @@ -0,0 +1,264 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_tree.h" + +OSCL_EXPORT_REF void Oscl_Rb_Tree_Base::rotate_left(base_link_type x, base_link_type& root) +{ + base_link_type y = x->right; + x->right = y->left; + if (y->left != 0) + y->left->parent = x; + y->parent = x->parent; + + if (x == root) + root = y; + else if (x == x->parent->left) + x->parent->left = y; + else + x->parent->right = y; + y->left = x; + x->parent = y; +} + +OSCL_EXPORT_REF void Oscl_Rb_Tree_Base::rotate_right(base_link_type x, base_link_type& root) +{ + base_link_type y = x->left; + x->left = y->right; + if (y->right != 0) + y->right->parent = x; + y->parent = x->parent; + + if (x == root) + root = y; + else if (x == x->parent->right) + x->parent->right = y; + else + x->parent->left = y; + y->right = x; + x->parent = y; +} + +OSCL_EXPORT_REF void Oscl_Rb_Tree_Base::rebalance(base_link_type x, base_link_type& root) +{ + x->color = Oscl_Rb_Tree_Node_Base::red; + while (x != root && x->parent->color == Oscl_Rb_Tree_Node_Base::red) + { + if (x->parent == x->parent->parent->left) + { + base_link_type y = x->parent->parent->right; + if (y && y->color == Oscl_Rb_Tree_Node_Base::red) + { + x->parent->color = Oscl_Rb_Tree_Node_Base::black; + y->color = Oscl_Rb_Tree_Node_Base::black; + x->parent->parent->color = Oscl_Rb_Tree_Node_Base::red; + x = x->parent->parent; + } + else + { + if (x == x->parent->right) + { + x = x->parent; + rotate_left(x, root); + } + x->parent->color = Oscl_Rb_Tree_Node_Base::black; + x->parent->parent->color = Oscl_Rb_Tree_Node_Base::red; + rotate_right(x->parent->parent, root); + } + } + else + { + base_link_type y = x->parent->parent->left; + if (y && y->color == Oscl_Rb_Tree_Node_Base::red) + { + x->parent->color = Oscl_Rb_Tree_Node_Base::black; + y->color = Oscl_Rb_Tree_Node_Base::black; + x->parent->parent->color = Oscl_Rb_Tree_Node_Base::red; + x = x->parent->parent; + } + else + { + if (x == x->parent->left) + { + x = x->parent; + rotate_right(x, root); + } + x->parent->color = Oscl_Rb_Tree_Node_Base::black; + x->parent->parent->color = Oscl_Rb_Tree_Node_Base::red; + rotate_left(x->parent->parent, root); + } + } + } + root->color = Oscl_Rb_Tree_Node_Base::black; +} + +OSCL_EXPORT_REF Oscl_Rb_Tree_Base::base_link_type Oscl_Rb_Tree_Base::rebalance_for_erase(base_link_type z, + base_link_type& root, + base_link_type& leftmost, + base_link_type& rightmost) +{ + base_link_type y = z; + base_link_type x = 0; + base_link_type x_parent = 0; + + if (y->left == 0) // z has at most one non-null child. y == z. + x = y->right; // x might be null. + else + { + if (y->right == 0) // z has exactly one non-null child. y == z. + x = y->left; // x is not null. + else // z has two non-null children. Set y to + { + y = y->right; // z's successor. x might be null. + while (y->left != 0) + y = y->left; + x = y->right; + } + } + if (y != z) // relink y in place of z. y is z's successor + { + z->left->parent = y; + y->left = z->left; + if (y != z->right) + { + x_parent = y->parent; + if (x) x->parent = y->parent; + y->parent->left = x; // y must be a left child + y->right = z->right; + z->right->parent = y; + } + else + x_parent = y; + if (root == z) + root = y; + else if (z->parent->left == z) + z->parent->left = y; + else + z->parent->right = y; + y->parent = z->parent; + // swap(y->color, z->color); + Oscl_Rb_Tree_Node_Base::color_type tmp_color = y->color; + y->color = z->color; + z->color = tmp_color; + y = z; + // y now points to node to be actually deleted + } + else // y == z + { + x_parent = y->parent; + if (x) x->parent = y->parent; + if (root == z) + root = x; + else + { + if (z->parent->left == z) + z->parent->left = x; + else + z->parent->right = x; + } + if (leftmost == z) + { + if (z->right == 0) // z->left must be null also + leftmost = z->parent; + // makes leftmost == header if z == root + else + leftmost = Oscl_Rb_Tree_Node_Base::minimum(x); + } + if (rightmost == z) + { + if (z->left == 0) // z->right must be null also + rightmost = z->parent; + // makes rightmost == header if z == root + else // x == z->left + rightmost = Oscl_Rb_Tree_Node_Base::maximum(x); + } + } + if (y->color != Oscl_Rb_Tree_Node_Base::red) + { + while (x != root && (x == 0 || x->color == Oscl_Rb_Tree_Node_Base::black)) + { + if (x == x_parent->left) + { + base_link_type w = x_parent->right; + if (w->color == Oscl_Rb_Tree_Node_Base::red) + { + w->color = Oscl_Rb_Tree_Node_Base::black; + x_parent->color = Oscl_Rb_Tree_Node_Base::red; + rotate_left(x_parent, root); + w = x_parent->right; + } + if ((w->left == 0 || w->left->color == Oscl_Rb_Tree_Node_Base::black) && + (w->right == 0 || w->right->color == Oscl_Rb_Tree_Node_Base::black)) + { + w->color = Oscl_Rb_Tree_Node_Base::red; + x = x_parent; + x_parent = x_parent->parent; + } + else + { + if (w->right == 0 || w->right->color == Oscl_Rb_Tree_Node_Base::black) + { + if (w->left) w->left->color = Oscl_Rb_Tree_Node_Base::black; + w->color = Oscl_Rb_Tree_Node_Base::red; + rotate_right(w, root); + w = x_parent->right; + } + w->color = x_parent->color; + x_parent->color = Oscl_Rb_Tree_Node_Base::black; + if (w->right) w->right->color = Oscl_Rb_Tree_Node_Base::black; + rotate_left(x_parent, root); + break; + } + } + else // same as above, with right <-> left. + { + base_link_type w = x_parent->left; + if (w->color == Oscl_Rb_Tree_Node_Base::red) + { + w->color = Oscl_Rb_Tree_Node_Base::black; + x_parent->color = Oscl_Rb_Tree_Node_Base::red; + rotate_right(x_parent, root); + w = x_parent->left; + } + if ((w->right == 0 || w->right->color == Oscl_Rb_Tree_Node_Base::black) && + (w->left == 0 || w->left->color == Oscl_Rb_Tree_Node_Base::black)) + { + w->color = Oscl_Rb_Tree_Node_Base::red; + x = x_parent; + x_parent = x_parent->parent; + } + else + { + if (w->left == 0 || w->left->color == Oscl_Rb_Tree_Node_Base::black) + { + if (w->right) w->right->color = Oscl_Rb_Tree_Node_Base::black; + w->color = Oscl_Rb_Tree_Node_Base::red; + rotate_left(w, root); + w = x_parent->left; + } + w->color = x_parent->color; + x_parent->color = Oscl_Rb_Tree_Node_Base::black; + if (w->left) w->left->color = Oscl_Rb_Tree_Node_Base::black; + rotate_right(x_parent, root); + break; + } + } + } + if (x) x->color = Oscl_Rb_Tree_Node_Base::black; + } + return y; +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tree.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tree.h new file mode 100644 index 0000000..e5c10d6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_tree.h @@ -0,0 +1,885 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ T R E E + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_tree.h + \brief The file oscl_tree.h defines the template class Oscl_Rb_Tree which has a very similar API as the STL Tree class. It is an implementation of a Red-Black Tree for use by the Oscl_Map class. Memory allocation is abstracted through the use of an allocator template parameter. +*/ + +#ifndef OSCL_TREE_H_INCLUDED +#define OSCL_TREE_H_INCLUDED + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + +template +struct Oscl_Pair +{ + T1 first; + T2 second; + Oscl_Pair() : first(T1()), second(T2()) {} + Oscl_Pair(const T1& a, const T2& b) : first(a), second(b) {} +}; + + +struct Oscl_Rb_Tree_Node_Base +{ + typedef Oscl_Rb_Tree_Node_Base* base_link_type; + typedef enum RedBl {red, black} color_type; + + color_type color; + base_link_type parent; + base_link_type left; + base_link_type right; + + static base_link_type minimum(base_link_type x) + { + if (x) + { + while (x->left != 0) x = x->left; + } + return x; + } + static base_link_type maximum(base_link_type x) + { + if (x) + { + while (x->right != 0) x = x->right; + } + return x; + } +}; + +template +struct Oscl_Rb_Tree_Node : public Oscl_Rb_Tree_Node_Base +{ + typedef Value value_type; + typedef Oscl_Rb_Tree_Node* link_type; + value_type value; +}; + + +template +struct Oscl_Rb_Tree_Iterator +{ + typedef Value value_type; + typedef value_type& reference; + typedef value_type* pointer; + typedef Oscl_Rb_Tree_Iterator iterator; + typedef Oscl_Rb_Tree_Iterator self; + typedef Oscl_Rb_Tree_Node_Base* base_link_type; + typedef Oscl_Rb_Tree_Node* link_type; + + base_link_type node; + + Oscl_Rb_Tree_Iterator() {} + Oscl_Rb_Tree_Iterator(link_type x) + { + node = x; + } + Oscl_Rb_Tree_Iterator(const iterator& it) + { + node = it.node; + } + + reference operator*() const + { + return link_type(node)->value; + } + pointer operator->() const + { + return &(operator*()); + } + + bool operator==(const self& x) + { + return node == x.node; + } + + bool operator!=(const self& x) + { + return node != x.node; + } + + self& operator++() + { + if (node->right != 0) + { + node = node->right; + while (node->left != 0) + { + node = node->left; + } + } + else + { + base_link_type y = node->parent; + while (node == y->right) + { + node = y; + y = y->parent; + } + if (node->right != y) node = y; + } + return *this; + } + + self operator++(int) + { + self tmp = *this; + ++*this; + return tmp; + } + + self& operator--() + { + if (node->color == Oscl_Rb_Tree_Node_Base::red && (node->parent)->parent == node) + { + node = node->right; // return rightmost + } + else if (node->left != 0) + { + base_link_type y = node->left; + while (y->right != 0) + y = y->right; + node = y; + } + else + { + base_link_type y = node->parent; + while (node == y->left) + { + node = y; + y = y->parent; + } + node = y; + } + return *this; + } + + self operator--(int) + { + self tmp = *this; + --*this; + return tmp; + } +}; + + +template +struct Oscl_Rb_Tree_Const_Iterator +{ + typedef Value value_type; + typedef const value_type& reference; + typedef const value_type* pointer; + typedef Oscl_Rb_Tree_Const_Iterator const_iterator; + typedef Oscl_Rb_Tree_Const_Iterator self; + typedef Oscl_Rb_Tree_Node_Base* base_link_type; + typedef Oscl_Rb_Tree_Node* link_type; + + base_link_type node; + + Oscl_Rb_Tree_Const_Iterator() {} + Oscl_Rb_Tree_Const_Iterator(link_type x) + { + node = x; + } + Oscl_Rb_Tree_Const_Iterator(const const_iterator& it) + { + node = it.node; + } + + reference operator*() const + { + return link_type(node)->value; + } + pointer operator->() const + { + return &(operator*()); + } + + bool operator==(const self& x) + { + return node == x.node; + } + + bool operator!=(const self& x) + { + return node != x.node; + } + + self& operator++() + { + if (node->right != 0) + { + node = node->right; + while (node->left != 0) + { + node = node->left; + } + } + else + { + base_link_type y = node->parent; + while (node == y->right) + { + node = y; + y = y->parent; + } + if (node->right != y) node = y; + } + return *this; + } + + self operator++(int) + { + self tmp = *this; + ++*this; + return tmp; + } + + self& operator--() + { + if (node->color == Oscl_Rb_Tree_Node_Base::red && (node->parent)->parent == node) + { + node = node->right; // return rightmost + } + else if (node->left != 0) + { + base_link_type y = node->left; + while (y->right != 0) + y = y->right; + node = y; + } + else + { + base_link_type y = node->parent; + while (node == y->left) + { + node = y; + y = y->parent; + } + node = y; + } + return *this; + } + + self operator--(int) + { + self tmp = *this; + --*this; + return tmp; + } +}; + + +class Oscl_Rb_Tree_Base +{ + + public: + typedef Oscl_Rb_Tree_Node_Base::base_link_type base_link_type; + + OSCL_IMPORT_REF void rotate_left(base_link_type x, base_link_type& root); + OSCL_IMPORT_REF void rotate_right(base_link_type x, base_link_type& root); + OSCL_IMPORT_REF void rebalance(base_link_type x, base_link_type& root); + OSCL_IMPORT_REF base_link_type rebalance_for_erase(base_link_type z, + base_link_type& root, + base_link_type& leftmost, + base_link_type& rightmost); +}; + + +template +class Oscl_Rb_Tree : public Oscl_Rb_Tree_Base +{ + + public: + typedef Key key_type; + typedef Value value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef typename Oscl_Rb_Tree_Node::link_type link_type; + typedef Oscl_Rb_Tree_Iterator iterator; + typedef Oscl_Rb_Tree_Const_Iterator const_iterator; + typedef uint32 size_type; + typedef int32 difference_type; + private: + typedef typename Oscl_Rb_Tree_Node::color_type color_type; + typedef Oscl_Rb_Tree_Node node_type; + + private: + link_type header; + size_type node_count; + Compare key_compare; + Oscl_TAlloc node_allocator; + + public: + Oscl_Rb_Tree(const Compare& comp = Compare()) + : node_count(0), key_compare(comp) + { + header = get_node(); + header->color = Oscl_Rb_Tree_Node_Base::red; + leftmost() = header; + rightmost() = header; + root() = 0; + } + + Oscl_Rb_Tree(const Oscl_Rb_Tree& x) + : node_count(0), key_compare(x.key_compare) + { + header = get_node(); + header->color = Oscl_Rb_Tree_Node_Base::red; + if (x.root() == 0) + { + leftmost() = header; + rightmost() = header; + root() = 0; + } + else + { + root() = copy(x.root(), header); + leftmost() = minimum(root()); + rightmost() = maximum(root()); + } + node_count = x.node_count; + } + + ~Oscl_Rb_Tree() + { + clear(); + release_node(header); + } + + Oscl_Rb_Tree& + operator=(const Oscl_Rb_Tree& x) + { + if (this != &x) + { + clear(); + node_count = 0; + key_compare = x.key_compare; + + if (x.root() == 0) + { + root() = 0; + leftmost() = header; + rightmost() = header; + } + else + { + root() = copy(x.root(), header); + leftmost() = minimum(root()); + rightmost() = maximum(root()); + node_count = x.node_count; + } + } + return *this; + } + + public: + iterator begin() + { + return leftmost(); + } + const_iterator begin() const + { + return leftmost(); + } + iterator end() + { + return header; + } + const_iterator end() const + { + return header; + } + bool empty() const + { + return node_count == 0; + } + size_type size() const + { + return node_count; + } + size_type max_size() const + { + return size_type(-1); + } + + Oscl_Pair insert_unique(const value_type& v) + { + link_type y = header; + link_type x = root(); + bool comp = true; + while (x != 0) + { + y = x; + comp = key_compare(KeyOfValue()(v), key(x)); + x = comp ? left(x) : right(x); + } + iterator j = iterator(y); + if (comp) + { + if (j == begin()) + return Oscl_Pair(insert(x, y, v), true); + else + --j; + } + if (key_compare(key(j.node), KeyOfValue()(v))) + return Oscl_Pair(insert(x, y, v), true); + + return Oscl_Pair(j, false); + } + + iterator insert_unique(iterator position, const value_type& v) + { + if (position.node == header->left) // begin() + { + if (size() > 0 && key_compare(KeyOfValue()(v), key(position.node))) + return insert((link_type)position.node, (link_type)position.node, v); + // first argument just needs to be non-null + else + return insert_unique(v).first; + } + else if (position.node == header) // end() + { + if (key_compare(key(rightmost()), KeyOfValue()(v))) + return insert(0, rightmost(), v); + else + return insert_unique(v).first; + } + else + { + iterator before = position; + --before; + if (key_compare(key(before.node), KeyOfValue()(v)) + && key_compare(KeyOfValue()(v), key(position.node))) + { + if (right(before.node) == 0) + return insert(0, (link_type)before.node, v); + else + return insert((link_type)position.node, (link_type)position.node, v); + // first argument just needs to be non-null + } + else + return insert_unique(v).first; + } + } + + void insert_unique(const_iterator first, const_iterator last) + { + for (; first != last; ++first) + insert_unique(*first); + } + + void insert_unique(const value_type* first, const value_type* last) + { + for (; first != last; ++first) + insert_unique(*first); + } + + void erase(iterator position) + { + link_type y = (link_type) rebalance_for_erase(position.node, + header->parent, + header->left, + header->right); + + destroy_node(y); + --node_count; + } + + size_type erase(const key_type& x) + { + Oscl_Pair p = equal_range(x); + size_type n = 0; + distance(p.first, p.second, n); + erase(p.first, p.second); + return n; + } + + void erase(iterator first, iterator last) + { + if (first == begin() && last == end()) + clear(); + else + while (first != last) erase(first++); + } + + void erase(const key_type* first, const key_type* last) + { + while (first != last) erase(*first++); + } + + void clear() + { + if (node_count != 0) + { + erase_without_rebalance(root()); + leftmost() = header; + root() = 0; + rightmost() = header; + node_count = 0; + } + } + + iterator find(const Key& k) + { + link_type y = header; // Last node which is not less than k. + link_type x = root(); // Current node. + + while (x != 0) + { + if (!key_compare(key(x), k)) + y = x, x = left(x); + else + x = right(x); + } + iterator j = iterator(y); + return (j == end() || key_compare(k, key(j.node))) ? end() : j; + } + + const_iterator find(const Key& k) const + { + link_type y = header; /* Last node which is not less than k. */ + link_type x = root(); /* Current node. */ + + while (x != 0) + { + if (!key_compare(key(x), k)) + y = x, x = left(x); + else + x = right(x); + } + const_iterator j = const_iterator(y); + return (j == end() || key_compare(k, key(j.node))) ? end() : j; + } + + size_type count(const Key& k) const + { + Oscl_Pair p = equal_range(k); + size_type n = 0; + distance(p.first, p.second, n); + return n; + } + + iterator lower_bound(const Key& k) + { + link_type y = header; /* Last node which is not less than k. */ + link_type x = root(); /* Current node. */ + + while (x != 0) + { + if (!key_compare(key(x), k)) + { + y = x; + x = left(x); + } + else + x = right(x); + } + return iterator(y); + } + + const_iterator lower_bound(const Key& k) const + { + link_type y = header; /* Last node which is not less than k. */ + link_type x = root(); /* Current node. */ + + while (x != 0) + { + if (!key_compare(key(x), k)) + { + y = x; + x = left(x); + } + else + x = right(x); + } + return const_iterator(y); + } + + iterator upper_bound(const Key& k) + { + link_type y = header; /* Last node which is greater than k. */ + link_type x = root(); /* Current node. */ + + while (x != 0) + { + if (key_compare(k, key(x))) + { + y = x; + x = left(x); + } + else + x = right(x); + } + return iterator(y); + } + + const_iterator upper_bound(const Key& k) const + { + link_type y = header; /* Last node which is greater than k. */ + link_type x = root(); /* Current node. */ + + while (x != 0) + { + if (key_compare(k, key(x))) + { + y = x; + x = left(x); + } + else + x = right(x); + } + return const_iterator(y); + } + + Oscl_Pair equal_range(const Key& k) + { + return Oscl_Pair(lower_bound(k), upper_bound(k)); + } + + Oscl_Pair equal_range(const Key& k) const + { + return Oscl_Pair(lower_bound(k), upper_bound(k)); + } + + private: + // this helper function performs a downcast from base_link_type& to link_type& + // under C99 (gcc 3.x) this breaks aliasing rules so we have to go via a void** instead + inline static link_type& cast_to_link_type(base_link_type &node) + { + void** ptr = (void**) & node; + link_type* base = (link_type*) ptr; + return *base; + } + + link_type& root() const + { + return cast_to_link_type(header->parent); + } + link_type& leftmost() const + { + return cast_to_link_type(header->left); + } + link_type& rightmost() const + { + return cast_to_link_type(header->right); + } + + const Key& key(link_type x) const + { + return KeyOfValue()(value(x)); + } + static reference value(link_type x) + { + return x->value; + } + static link_type& left(link_type x) + { + return cast_to_link_type(x->left); + } + static link_type& right(link_type x) + { + return cast_to_link_type(x->right); + } + static link_type& parent(link_type x) + { + return cast_to_link_type(x->parent); + } + + const Key& key(base_link_type x) const + { + return KeyOfValue()(value(x)); + } + static reference value(base_link_type x) + { + return ((link_type)x)->value; + } + static link_type& left(base_link_type x) + { + return cast_to_link_type(x->left); + } + static link_type& right(base_link_type x) + { + return cast_to_link_type(x->right); + } + static link_type& parent(base_link_type x) + { + return cast_to_link_type(x->parent); + } + + static link_type minimum(link_type x) + { + return (link_type) Oscl_Rb_Tree_Node_Base::minimum(x); + } + static link_type maximum(link_type x) + { + return (link_type) Oscl_Rb_Tree_Node_Base::maximum(x); + } + + iterator insert(link_type x, link_type y, const value_type& v) + { + link_type z; + + if (y == header || x != 0 || key_compare(KeyOfValue()(v), key(y))) + { + z = create_node(v); + left(y) = z; // also makes leftmost() = z when y == header + if (y == header) + { + root() = z; + rightmost() = z; + } + else if (y == leftmost()) + leftmost() = z; // maintain leftmost() pointing to min node + } + else + { + z = create_node(v); + right(y) = z; + if (y == rightmost()) + rightmost() = z; // maintain rightmost() pointing to max node + } + parent(z) = y; + left(z) = 0; + right(z) = 0; + rebalance(z, header->parent); + ++node_count; + return iterator(z); + + } + + void erase_without_rebalance(link_type x) + { + while (x != 0) + { + erase_without_rebalance((link_type)x->right); + link_type y = (link_type)x->left; + destroy_node(x); + x = y; + } + } + + link_type copy(link_type x, link_type p) + { + // structural copy. x and p must be non-null. + link_type top = clone_node(x); + top->parent = p; + + if (x->right) + { + top->right = copy(right(x), top); + } + p = top; + x = left(x); + + while (x != 0) + { + link_type y = clone_node(x); + p->left = y; + y->parent = p; + if (x->right) + { + y->right = copy(right(x), y); + } + p = y; + x = left(x); + } + + return top; + } + + link_type get_node() + { + return node_allocator.ALLOCATE(1); + } + void release_node(link_type node) + { + node_allocator.deallocate(node); + } + + link_type create_node(const value_type& v) + { + link_type x = get_node(); + new(&x->value) value_type(v); + return x; + } + + void destroy_node(link_type x) + { + x->value.~Value(); + release_node(x); + } + + link_type clone_node(link_type x) + { + link_type tmp = create_node(x->value); + tmp->color = x->color; + tmp->left = 0; + tmp->right = 0; + return tmp; + } + + void distance(const_iterator first, const_iterator last, size_type& n) const + { + while (first != last) + { + n++; + first++; + } + } + + void distance(iterator first, iterator last, size_type& n) const + { + while (first != last) + { + n++; + first++; + } + } +}; + + +/*! @} */ + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_types.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_types.h new file mode 100644 index 0000000..9768715 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_types.h @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ T Y P E S ( B A S I C T Y P E D E F S ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * + * @{ + */ + + +/*! \file oscl_types.h + * \brief This file contains basic type definitions for common use across platforms. + * + */ + +#ifndef OSCL_TYPES_H_INCLUDED +#define OSCL_TYPES_H_INCLUDED + + +// include the config header for the platform +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +//! The c_bool type is mapped to an integer to provide a bool type for C interfaces +typedef int c_bool; + + +//! The OsclAny is meant to be used the context of a generic pointer (i.e., no specific type). +typedef void OsclAny; + +//! mbchar is multi-byte char (e.g., UTF-8) with null termination. +typedef char mbchar; + +//! The uint type is a convenient abbreviation for unsigned int. +#if !defined(__USE_MISC) +// uint is defined in some Linux platform sys\types.h +typedef unsigned int uint; +#endif + +//! The octet type is meant to be used for referring to a byte or collection bytes without suggesting anything about the underlying meaning of the bytes. +typedef uint8 octet; + +//! The Float type defined as OsclFloat +typedef float OsclFloat; + +typedef size_t OsclSizeT; + +#ifndef OSCL_INT64_TYPES_DEFINED +//use native type +typedef OSCL_NATIVE_INT64_TYPE int64; +typedef OSCL_NATIVE_UINT64_TYPE uint64; +#define OSCL_INT64_TYPES_DEFINED +#endif + +// define OSCL_WCHAR +typedef OSCL_NATIVE_WCHAR_TYPE oscl_wchar; + +//! define OSCL_TCHAR +typedef oscl_wchar OSCL_TCHAR; + +// The definition of the MemoryFragment will probably +// be OS-dependant since the goal is to allow this data +// structure to be passed directly to I/O routines that take +// scatter/gather arrays. +#if ( OSCL_MEMFRAG_PTR_BEFORE_LEN ) + +struct OsclMemoryFragment +{ + void *ptr; + uint32 len; +}; + +#else +struct OsclMemoryFragment +{ + uint32 len; + void *ptr; +}; +#endif + + +/*! @} */ + + +#endif // OSCL_TYPES_H_INCLUDED diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_uuid.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_uuid.h new file mode 100644 index 0000000..a17abed --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_uuid.h @@ -0,0 +1,109 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/** + * @file oscl_uuid.h + * @brief This file defines the OSCL UUID structure used for unique + * identifiers as well as the short (32-bit) identifiers OsclUid32. + */ + +#ifndef OSCL_UUID_H_INCLUDED +#define OSCL_UUID_H_INCLUDED + +#ifndef OSCL_BASE_MACROS_H_INCLUDED +#include "oscl_base_macros.h" +#endif + +#ifndef OSCL_MEM_BASIC_FUNCTIONS_H +#include "oscl_mem_basic_functions.h" +#endif + +// __cplusplus + +#define EMPTY_UUID PVUuid(0,0,0,0,0,0,0,0,0,0,0) + +typedef uint32 OsclUid32; +/** + * OSCL UUID structure used for unique identification of modules and interfaces. + */ +struct OsclUuid +{ +#define BYTES_IN_UUID_ARRAY 8 + + OsclUuid() + { + oscl_memset(this, 0, sizeof(OsclUuid)); + } + + OsclUuid(uint32 l, uint16 w1, uint16 w2, uint8 b1, uint8 b2, uint8 b3, + uint8 b4, uint8 b5, uint8 b6, uint8 b7, uint8 b8) + { + data1 = l; + data2 = w1; + data3 = w2; + data4[0] = b1; + data4[1] = b2; + data4[2] = b3; + data4[3] = b4; + data4[4] = b5; + data4[5] = b6; + data4[6] = b7; + data4[7] = b8; + } + + OsclUuid(const OsclUuid &uuid) + { + oscl_memcpy(this, &uuid, sizeof(OsclUuid)); + } + + OsclUuid &operator=(const OsclUuid& src) + { + oscl_memcpy(this, &src, sizeof(OsclUuid)); + return *this; + } + + bool operator==(const OsclUuid& src) const + { + if (data1 != src.data1 || data2 != src.data2 || data3 != src.data3) + { + return false; + } + + for (int ii = 0; ii < 8; ++ii) + { + if (data4[ii] != src.data4[ii]) + { + return false; + } + } + + return true; + } + + bool operator!=(const OsclUuid &src) const + { + return !(*this == src); + } + + uint32 data1; + uint16 data2; + uint16 data3; + uint8 data4[BYTES_IN_UUID_ARRAY]; +}; + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_uuid_utils.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_uuid_utils.h new file mode 100644 index 0000000..5d579a4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_uuid_utils.h @@ -0,0 +1,158 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/** + * @file oscl_uuid_utils.h + */ + +#ifndef OSCL_UUID_UTILS_H_INCLUDED +#define OSCL_UUID_UTILS_H_INCLUDED + +#ifndef OSCL_STRING_UTILS_H +#include "oscl_string_utils.h" +#endif + +#ifndef OSCL_STDSTRING_H_INCLUDED +#include "oscl_stdstring.h" +#endif + +const char PV_CHAR_CLOSE_BRACKET = ')'; +const char PV_CHAR_COMMA = ','; +static void SetOsclUuid(OsclUuid& uuid, const char* aUuidString) +{ + //Initialize all data members to 0 to begin with + uuid.data1 = uuid.data2 = uuid.data3 = 0; + + for (int ii = 0; ii < 8; ++ii) + { + uuid.data4[ii] = 0; + } + + if (!aUuidString) + { + return; + } + int uuidStrLen = oscl_strlen(aUuidString); + + if (uuidStrLen != 0) + { + const char* sptr = NULL, *eptr = NULL; + int commaval = 0; + sptr = aUuidString; + ++sptr; //Increment over the starting parantheses '(' + eptr = sptr; + for (int i = 0; i < uuidStrLen - 1 ; ++i) + { + if ((*eptr != PV_CHAR_COMMA) && (*eptr != PV_CHAR_CLOSE_BRACKET)) //Increment the pointer unless you get to the "," + { //The comma signifies the beginning of the new OsclUuid parameter + ++eptr; + } + else + { + sptr = sptr + 2;//Move over the 0x characters in the beginning of the hex value; + ++commaval; + switch (commaval) + { + case 1: + { + PV_atoi(sptr , 'x', eptr - sptr, uuid.data1); + break; + } + case 2: + { + uint32 tempdata2 = 0; + PV_atoi(sptr , 'x', (eptr - sptr), tempdata2); + uuid.data2 = (uint16)tempdata2; + break; + } + case 3: + { + uint32 tempdata3 = 0; + PV_atoi(sptr , 'x', (eptr - sptr), tempdata3); + uuid.data3 = (uint16)tempdata3; + break; + } + case 4: + { + uint32 tempdata4_0 = 0; + PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_0); + uuid.data4[0] = (uint8)tempdata4_0; + break; + } + case 5: + { + uint32 tempdata4_1 = 0; + PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_1); + uuid.data4[1] = (uint8)tempdata4_1; + break; + } + case 6: + { + uint32 tempdata4_2 = 0; + PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_2); + uuid.data4[2] = (uint8)tempdata4_2; + break; + } + case 7: + { + uint32 tempdata4_3 = 0; + PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_3); + uuid.data4[3] = (uint8)tempdata4_3; + break; + } + case 8: + { + uint32 tempdata4_4 = 0; + PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_4); + uuid.data4[4] = (uint8)tempdata4_4; + break; + } + case 9: + { + uint32 tempdata4_5 = 0; + PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_5); + uuid.data4[5] = (uint8)tempdata4_5; + break; + } + case 10: + { + uint32 tempdata4_6 = 0; + PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_6); + uuid.data4[6] = (uint8)tempdata4_6; + break; + } + case 11: + { + uint32 tempdata4_7 = 0; + PV_atoi(sptr, 'x', (eptr - sptr), tempdata4_7); + uuid.data4[7] = (uint8)tempdata4_7; + break; + } + } + if (*eptr == PV_CHAR_CLOSE_BRACKET) //Break from the loop on finding + { + break; + } + ++eptr; + sptr = eptr; + } + } + } +} +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_vector.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_vector.cpp new file mode 100644 index 0000000..f235fc0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_vector.cpp @@ -0,0 +1,247 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ V E C T O R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * Additional osclbase comment + * @{ + */ + +/*! \file oscl_vector.cpp + \brief Implementation for oscl_vector.h +*/ + +#include "oscl_vector.h" + + +OSCL_EXPORT_REF void Oscl_Vector_Base::reserve(uint32 n) +{ + if (n > bufsize) + { + OsclAny* oldmem = elems; + elems = pOpaqueType->allocate(n * sizeof_T); + OsclAny* newelems = elems; + OsclAny* oldelems = oldmem; + for (uint32 i = 0; i < numelems; i++) + { + pOpaqueType->construct(newelems, oldelems); + newelems = increment_T(newelems, 1); + oldelems = increment_T(oldelems, 1); + } + if (oldmem) + { + destroy(oldmem, increment_T(oldmem, numelems)); + pOpaqueType->deallocate(oldmem); + } + bufsize = n; + } +} + +OSCL_EXPORT_REF void Oscl_Vector_Base::construct(Oscl_Opaque_Type_Alloc* aType) +{ + numelems = 0; + bufsize = 0; + elems = NULL; + pOpaqueType = aType; +} + +OSCL_EXPORT_REF void Oscl_Vector_Base::construct(Oscl_Opaque_Type_Alloc* aType, uint32 n) +{ + numelems = 0; + bufsize = n; + pOpaqueType = aType; + elems = pOpaqueType->allocate(n * sizeof_T); +} + +OSCL_EXPORT_REF void Oscl_Vector_Base::construct(Oscl_Opaque_Type_Alloc* aType, const Oscl_Vector_Base& x) +{ + numelems = x.numelems; + bufsize = x.numelems;//only enough for current elements + pOpaqueType = aType; + elems = pOpaqueType->allocate(bufsize * sizeof_T); + uninitialized_copy(x.begin(), x.end(), begin()); +} + +OSCL_EXPORT_REF void Oscl_Vector_Base::push_back(const OsclAny* x) +{ + if (numelems == bufsize) + { + uint32 new_bufsize = (bufsize) ? 2 * bufsize : 2; + reserve(new_bufsize); + } + pOpaqueType->construct(end(), x); + numelems++; +} + +OSCL_EXPORT_REF void Oscl_Vector_Base::pop_back() +{ + numelems--; + pOpaqueType->destroy(end()); +} + +OSCL_EXPORT_REF void Oscl_Vector_Base::push_front(const OsclAny* x) +{ + OSCL_ASSERT(x); + if (numelems == bufsize) + { + uint32 new_bufsize = (bufsize) ? 2 * bufsize : 2; + reserve(new_bufsize); + } + for (uint32 i = numelems; i > 0; i--) + { + pOpaqueType->construct(increment_T(elems, i), increment_T(elems, i - 1)); + pOpaqueType->destroy(increment_T(elems, i - 1)); + } + numelems++; + pOpaqueType->construct(begin(), x); +} + +OSCL_EXPORT_REF OsclAny* Oscl_Vector_Base::insert(OsclAny* pos, const OsclAny* x) +{ + OSCL_ASSERT(x); + if (numelems == bufsize) + { + uint32 new_bufsize = (bufsize) ? 2 * bufsize : 2; + OsclAny* oldPtr = elems; + reserve(new_bufsize); + int32 diff = ((char*)elems) - ((char*)oldPtr); + pos = (OsclAny*)(((char*)pos) + diff); + } + OsclAny* ptr = increment_T(elems, numelems); + while (ptr > pos) + { + OsclAny* previous = increment_T(ptr, -1); + pOpaqueType->construct(ptr, previous); + pOpaqueType->destroy(previous); + ptr = previous; + } + numelems++; + pOpaqueType->construct(pos, x); + return pos; +} + +OSCL_EXPORT_REF OsclAny* Oscl_Vector_Base::erase(OsclAny* pos) +{ + //note: use move instead of copy here since we assume + //it's not necessary to construct/destruct just to move + //an element. + pOpaqueType->destroy(pos); + if (increment_T(pos, 1) != end()) + move(increment_T(pos, 1), end(), pos); + numelems--; + return pos; +} + +OSCL_EXPORT_REF OsclAny* Oscl_Vector_Base::erase(OsclAny* first, OsclAny* last) +{ + //note: use move instead of copy here since we assume + //it's not necessary to construct/destruct just to move + //an element. + destroy(first, last); + move(last, end(), first); + numelems -= (((uint32)last - (uint32)first) / sizeof_T); + return first; +} + +OSCL_EXPORT_REF void Oscl_Vector_Base::assign_vector(const Oscl_Vector_Base& x) +{ + if (x.size() > capacity()) + { + // allocate space and copy + OsclAny* tmp = pOpaqueType->allocate((uint32)x.end() - (uint32)x.begin()); + uninitialized_copy(x.begin(), x.end(), tmp); + destroy(begin(), end()); + if (elems) + pOpaqueType->deallocate(elems); + elems = tmp; + bufsize = x.size(); + } + else if (size() >= x.size()) + { + OsclAny* i = copy(x.begin(), x.end(), begin()); + destroy(i, end()); + } + else + { + copy(x.begin(), increment_T(x.begin(), size()), begin()); + uninitialized_copy(increment_T(x.begin(), size()), x.end(), end()); + } + numelems = x.size(); +} + +OSCL_EXPORT_REF void Oscl_Vector_Base::destroy() +{ + if (elems) + { + destroy(begin(), end()); + pOpaqueType->deallocate(elems); + elems = NULL; + numelems = 0; + bufsize = 0; + } +} + +OsclAny* Oscl_Vector_Base::move(OsclAny* first, OsclAny* last, OsclAny* result) +{ + oscl_memmove(result, first, (uint32)last - (uint32)first); + return last; +} + +OsclAny* Oscl_Vector_Base::copy(OsclAny* first, OsclAny* last, OsclAny* result) +{ + while (first != last) + { + pOpaqueType->destroy(result); + pOpaqueType->construct(result, first); + result = increment_T(result, 1); + first = increment_T(first, 1); + } + return result; +} + +OsclAny* Oscl_Vector_Base::uninitialized_copy(OsclAny* first, OsclAny* last, OsclAny* result) +{ + while (first != last) + { + pOpaqueType->construct(result, first); + result = increment_T(result, 1); + first = increment_T(first, 1); + } + return result; +} + +void Oscl_Vector_Base::destroy(OsclAny* first, OsclAny* last) +{ + while (first != last) + { + pOpaqueType->destroy(first); + first = increment_T(first, 1); + } +} + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_vector.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_vector.h new file mode 100644 index 0000000..2926c5c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/oscl_vector.h @@ -0,0 +1,477 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ V E C T O R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclbase OSCL Base + * Additional osclbase comment + * @{ + */ + +/*! \file oscl_vector.h + \brief The file oscl_vector.h defines the template class Oscl_Vector which has a very similar API as the STL Vector class (it basically provides a subset of the STL functionality). Memory allocation is abstracted through the use of an allocator template parameter. +*/ + +#ifndef OSCL_VECTOR_H_INCLUDED +#define OSCL_VECTOR_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_MEM_BASIC_FUNCTIONS_H_INCLUDED +#include "oscl_mem_basic_functions.h" +#endif + +#ifndef OSCL_ASSERT_H_INCLUDED +#include "oscl_assert.h" +#endif + +#ifndef OSCL_OPAQUE_TYPE_H_INCLUDED +#include "oscl_opaque_type.h" +#endif + +#ifndef OSCL_DEF_ALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +/** + * Oscl_Vector_Base is a non-templatized base class for Oscl_Vector. + * The purpose of this base class is to avoid large inline routines + * in the Oscl_Vector implementation. + * This class is not intended for direct instantiation except by + * Oscl_Vector. + */ +class Oscl_Vector_Base +{ + public: + /** + * Returns the size of the vector in units of number of elements. + */ + uint32 size() const + { + return numelems; + } + + /** + * Returns the allocated memory of the vector in units of number of elements. + */ + uint32 capacity() const + { + return bufsize; + } + + /** + * True if the vector's size is 0. + */ + bool empty() const + { + return numelems == 0; + } + + /** + * Reallocates memory if necessary to a capacity of n elements. + * The main reason for reserve is efficiency. If you know the capacity to + * which your vector must grow, then it is more efficient to allocate the + * vector all at once rather than rely on the automatic reallocation scheme. + * This also helps cotrol the invalidation of iterators. + * @param n size of vector + */ + OSCL_IMPORT_REF void reserve(uint32 n) ; + + protected: + + //for use in default constructor. vtable isn't available in c'tor so this is a subroutine. + OSCL_IMPORT_REF void construct(Oscl_Opaque_Type_Alloc* aType); + + //for use in constructor with pre-allocation for "n" elements. + OSCL_IMPORT_REF void construct(Oscl_Opaque_Type_Alloc* aType, uint32 n) ; + + //for use in copy constructor. + OSCL_IMPORT_REF void construct(Oscl_Opaque_Type_Alloc* aType, const Oscl_Vector_Base& x); + + /** + * The destructor. + */ + virtual ~Oscl_Vector_Base() + {} + + /** + * Inserts a new element at the end. + * Inserting an element invalidates all iterators if memory reallocation occurs + * as a result of the insertion. + * @param x pointer to the new element + */ + OSCL_IMPORT_REF void push_back(const OsclAny* x) ; + + /** + * Removes the last element. + */ + OSCL_IMPORT_REF void pop_back() ; + + /** + * Inserts a new element at the front. + * Inserting an element invalidates all iterators if memory reallocation occurs + * as a result of the insertion. + * @param x pointer to new element + */ + OSCL_IMPORT_REF void push_front(const OsclAny* x) ; + + /** + * Inserts a new element at a specific position. + * @param pos iterator at insert position. + * @param x pointer to new element + */ + OSCL_IMPORT_REF OsclAny* insert(OsclAny* pos, const OsclAny* x); + + /** + * Erases the element pointed to by iterator pos. + * Erasing an element invalidates all iterators pointing to elements + * following the deletion point. + * @param pos iterator at erase position + */ + OSCL_IMPORT_REF OsclAny* erase(OsclAny* pos) ; + + /** + * Erases elements in range [first, last). + * Erasing an element invalidates all iterators pointing to elements + * following the deletion point. + * @param first starting position + * @param last ending position, this position is not erased + */ + OSCL_IMPORT_REF OsclAny* erase(OsclAny* first, OsclAny* last) ; + + //copy vector x into this vector + OSCL_IMPORT_REF void assign_vector(const Oscl_Vector_Base& x); + + OSCL_IMPORT_REF void destroy(); + + uint32 numelems; //number of T items in buffer. + uint32 bufsize; //available bufsize as number of T-sized items. + OsclAny* elems; //buffer + uint32 sizeof_T; + + friend class OsclPriorityQueueBase; + + private: + + /** + * return a T* incremented by n. + */ + OsclAny* increment_T(OsclAny* p_T, int32 n) const + { + return (OsclAny*)((int32)p_T + n*sizeof_T); + } + + /** + * Returns an iterator pointing to the beginning of the vector + */ + OsclAny* begin() const + { + return elems; + } + + /** + * Returns an iterator pointing to the end of the vector. + */ + OsclAny* end() const + { + return increment_T(elems, numelems); + } + + OsclAny* move(OsclAny* first, OsclAny* last, OsclAny* result) ; + + OsclAny* copy(OsclAny* first, OsclAny* last, OsclAny* result) ; + + OsclAny* uninitialized_copy(OsclAny* first, OsclAny* last, OsclAny* result) ; + + //destroy a range of T* + void destroy(OsclAny* first, OsclAny* last) ; + + Oscl_Opaque_Type_Alloc* pOpaqueType; +}; + +/** + * Oscl_Vector Class. A subset of STL::Vector methods. + * Oscl_Vector supports random access to elements, constant time insertion + * and removal of elements at the end of the vector, and linear time + * insertion and removal of elements at the beginning or middle of the + * vector. The number of elements in a vector can vary dynamically, and + * memory management is performed automatically. + */ +template +class Oscl_Vector + : public Oscl_Vector_Base + , public Oscl_Opaque_Type_Alloc +{ + + public: + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef const T& const_reference; + typedef T* iterator; + typedef const T* const_iterator; + + /** + * Creates an empty vector. + */ + Oscl_Vector() : Oscl_Vector_Base(), Oscl_Opaque_Type_Alloc() + { + sizeof_T = sizeof(T); + Oscl_Vector_Base::construct(this); + } + + /** + * Creates an empty vector with capacity n. + * @param n creates a vector with n elements. The main reason for specifying n + * is efficiency. If you know the capacity to which your vector must grow, then + * it is more efficient to allocate the vector all at once rather than rely on + * the automatic reallocation scheme. This also helps cotrol the invalidation + * of iterators. + */ + Oscl_Vector(uint32 n) : Oscl_Vector_Base(), Oscl_Opaque_Type_Alloc() + { + sizeof_T = sizeof(T); + Oscl_Vector_Base::construct(this, n); + } + + /** + * Copy Constructor. + * @param x vector class to copy. + */ + Oscl_Vector(const Oscl_Vector& x) : Oscl_Vector_Base(), Oscl_Opaque_Type_Alloc() + { + sizeof_T = sizeof(T); + Oscl_Vector_Base::construct(this, x); + } + + /** + * The destructor. + */ + virtual ~Oscl_Vector() + { + Oscl_Vector_Base::destroy(); + } + + /** + * The assignment operator + */ + Oscl_Vector& operator=(const Oscl_Vector& x) + { + if (&x != this) + Oscl_Vector_Base::assign_vector(x); + return *this; + } + + /** + * Inserts a new element at the end. + * Inserting an element invalidates all iterators if memory reallocation occurs + * as a result of the insertion. + * @param x new element + */ + void push_back(const T& x) + { + Oscl_Vector_Base::push_back(&x); + } + + /** + * Inserts a new element at the front. + * Inserting an element invalidates all iterators if memory reallocation occurs + * as a result of the insertion. + * @param x new element + */ + void push_front(const T& x) + { + Oscl_Vector_Base::push_front(&x); + } + + /** + * Inserts a new element before the one at pos. + * @param pos position at which to insert the new element. + * @param x new element + */ + iterator insert(iterator pos, const T& x) + { + return (iterator)Oscl_Vector_Base::insert(pos, &x); + } + + /** + * Returns the n'th element. + * @param n element position to return + */ + T& operator[](uint32 n) + { + return (*(begin() + n)); + } + + /** + * Returns the n'th element. + * @param n element position to return + */ + const T& operator[](uint32 n) const + { + return (*(begin() + n)); + } + + /** + * Returns the first element. + */ + T& front() + { + return *begin(); + } + + /** + * Returns the first element. + */ + const T& front() const + { + return *begin(); + } + + /** + * Returns the last element. + */ + T& back() + { + return (*(end() - 1)); + } + + /** + * Returns the last element. + */ + const T& back() const + { + return (*(end() - 1)); + } + + /** + * Removes the last element. + */ + void pop_back() + { + OSCL_ASSERT(numelems); + numelems--; + destroy(end()); + } + + /** + * Removes all elements. + */ + void clear() + { + Oscl_Vector_Base::erase(begin(), end()); + } + + /** + * Destroy -- this is like an explicit destructor call. + */ + void destroy() + { + Oscl_Vector_Base::destroy(); + } + + /** + * Returns an iterator pointing to the beginning of the vector. + */ + iterator begin() const + { + return (pointer)elems; + } + + /** + * Returns an iterator pointing to the end of the vector.. + */ + iterator end() const + { + return (pointer)elems + numelems; + } + + /** + * Erases the element pointed to by iterator pos. + * Erasing an element invalidates all iterators pointing to elements + * following the deletion point. + * @param pos iterator at erase position + */ + iterator erase(iterator pos) + { + return (iterator)Oscl_Vector_Base::erase(pos); + } + + /** + * Erases elements in range [first, last). + * Erasing an element invalidates all iterators pointing to elements + * following the deletion point. + * @param first starting position + * @param last ending position, this position is not erased + */ + iterator erase(iterator first, iterator last) + { + return (iterator)Oscl_Vector_Base::erase(first, last); + } + + private: + + Alloc defAlloc; + + //from Oscl_Opaque_Type_Alloc + OsclAny* allocate(const uint32 size) + { + //prevent zero-size allocations since some allocators don't handle this + return (size) ? defAlloc.ALLOCATE(size) : NULL; + } + + //from Oscl_Opaque_Type_Alloc + void deallocate(OsclAny* p) + { + defAlloc.deallocate(p); + } + + //from Oscl_Opaque_Type_Alloc + void construct(OsclAny* p, const OsclAny* x) + { + OSCL_ASSERT(x); + new(p) value_type(*((T*)x)); + } + + //from Oscl_Opaque_Type_Alloc + void destroy(OsclAny* first) + { + OSCL_ASSERT(first); + OSCL_UNUSED_ARG(first); + //note: must use "pointer" instead of "T*" here to avoid ADS 1.2 compile error. + ((pointer)first)->~T(); + } + +}; + + +/*! @} */ + + +#endif + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger.cpp new file mode 100644 index 0000000..cef1fa8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger.cpp @@ -0,0 +1,491 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "pvlogger.h" +#include "pvlogger_registry.h" +#include "pvlogger_accessories.h" +#include "oscl_dll.h" +#include "oscl_stdstring.h" + + +#ifndef OSCL_COMBINED_DLL +OSCL_DLL_ENTRY_POINT_DEFAULT() +#endif + +#if(PVLOGGER_ENABLE) +const char rootTag[] = ""; + +//use the TLS registry, or the singleton registry if no TLS. +//Note: singleton registry only works for single-threaded scenarios, +//since this implementation assumes a per-thread registry. +#include "oscl_base.h" +#include "oscl_tls.h" +#define PVLOGGER_REGISTRY OsclTLSRegistry +#define PVLOGGER_REGISTRY_ID OSCL_TLS_ID_PVLOGGER +#define PVLOGGER_REGISTRY_WRAPPER OsclTLS + +#endif //PVLOGGER_ENABLE + +OSCL_EXPORT_REF void PVLogger::Init() +{ +#if(PVLOGGER_ENABLE) + alloc_type alloc; + OsclAny* ptr = alloc.allocate(sizeof(PVLoggerRegistry)); + if (ptr) + { + PVLoggerRegistry *pvlogreg = new(ptr) PVLoggerRegistry(); + int32 err; + PVLOGGER_REGISTRY::registerInstance(pvlogreg, PVLOGGER_REGISTRY_ID, err); + } +#endif +} + +OSCL_EXPORT_REF void PVLogger::Cleanup() +{ +#if(PVLOGGER_ENABLE) + int32 err; + PVLoggerRegistry *pvlogreg = OSCL_STATIC_CAST(PVLoggerRegistry*, PVLOGGER_REGISTRY::getInstance(PVLOGGER_REGISTRY_ID, err)); + if (pvlogreg) + { + pvlogreg->~PVLoggerRegistry(); + alloc_type alloc; + alloc.deallocate(pvlogreg); + PVLOGGER_REGISTRY::registerInstance(NULL, PVLOGGER_REGISTRY_ID, err); + } +#endif +} + +OSCL_EXPORT_REF PVLogger* PVLogger::GetLoggerObject(const char* inputTag) +{ +#if(PVLOGGER_ENABLE) + PVLoggerRegistry* registry = PVLoggerRegistry::GetPVLoggerRegistry(); + return (registry) ? registry->GetPVLoggerObject(inputTag) : NULL; +#else + OSCL_UNUSED_ARG(inputTag); + return NULL; +#endif +} + +OSCL_EXPORT_REF void PVLogger::SetLogLevelAndPropagate(log_level_type level) +{ +#if(PVLOGGER_ENABLE) + _level = level; + PVLoggerRegistry::GetPVLoggerRegistry()->SetNodeLogLevelExplicit(_tag, level); +#else + OSCL_UNUSED_ARG(level); +#endif +} + +OSCL_EXPORT_REF bool PVLogger::IsActive(log_level_type level) +{ +#if(PVLOGGER_ENABLE) + _lastMsgLevel = level; + + if (_level == PVLOGGER_LEVEL_UNINTIALIZED) + { + if (_parentLogger != NULL) + { + return(_parentLogger->IsActive(level)); + } + else + { + /* + * We are the root node, as every node other + * than root MUST have a parent. If the root's + * log level is uninitialized, then we do not + * log anything + */ + return false; + } + } + if (level <= _level) + { + return true; + } +#else + OSCL_UNUSED_ARG(level); +#endif + return false; +} + +OSCL_EXPORT_REF void PVLogger::LogMsgStringV(message_id_type msgID, const char * fmt, va_list arguments) +{ +#if(PVLOGGER_ENABLE) + filter_status_type msgStatus = FilterMsg(msgID); + + if (msgStatus == PVLOGGER_FILTER_ACCEPT) + { + //Log msg to the current node + LogMsg(msgID, fmt, arguments); + } + + if ((_parentLogger != NULL) && (_oAppenderInheritance)) + { + //Pass the msg to the parent + _parentLogger->LogMsgStringV(msgID, fmt, arguments); + } +#else + OSCL_UNUSED_ARG(msgID); + OSCL_UNUSED_ARG(fmt); + OSCL_UNUSED_ARG(arguments); +#endif + return; +} + +OSCL_EXPORT_REF void PVLogger::LogMsgBuffersV(message_id_type msgID, int32 numPairs, va_list arguments) +{ +#if(PVLOGGER_ENABLE) + filter_status_type msgStatus = FilterMsg(msgID); + + if (msgStatus == PVLOGGER_FILTER_ACCEPT) + { + //Log msg to the current node + LogMsg(msgID, numPairs, arguments); + } + + if ((_parentLogger != NULL) && (_oAppenderInheritance)) + { + //Pass the msg to the parent + _parentLogger->LogMsgBuffersV(msgID, numPairs, arguments); + + } +#else + OSCL_UNUSED_ARG(msgID); + OSCL_UNUSED_ARG(numPairs); + OSCL_UNUSED_ARG(arguments); +#endif + return; +} + +OSCL_EXPORT_REF void PVLogger::LogMsgString(message_id_type msgID, const char * fmt, ...) +{ +#if(PVLOGGER_ENABLE) + va_list arguments; + va_start(arguments, fmt); + + filter_status_type msgStatus = FilterMsg(msgID); + + if (msgStatus == PVLOGGER_FILTER_ACCEPT) + { + LogMsg(msgID, fmt, arguments); + } + + if ((_parentLogger != NULL) && (_oAppenderInheritance)) + { + //Pass the msg to the parent + _parentLogger->LogMsgStringV(msgID, fmt, arguments); + } +#else + OSCL_UNUSED_ARG(msgID); + OSCL_UNUSED_ARG(fmt); +#endif + return; +} + +OSCL_EXPORT_REF void PVLogger::LogMsgBuffers(message_id_type msgID, int32 numPairs, ...) +{ +#if(PVLOGGER_ENABLE) + va_list arguments; + va_start(arguments, numPairs); + + filter_status_type msgStatus = FilterMsg(msgID); + + if (msgStatus == PVLOGGER_FILTER_ACCEPT) + { + LogMsg(msgID, numPairs, arguments); + } + + if ((_parentLogger != NULL) && (_oAppenderInheritance)) + { + //Pass the msg to the parent + _parentLogger->LogMsgBuffersV(msgID, numPairs, arguments); + } +#else + OSCL_UNUSED_ARG(msgID); + OSCL_UNUSED_ARG(numPairs); +#endif + return; +} + +OSCL_EXPORT_REF PVLogger::PVLogger(const char* inputTag, log_level_type level, bool oAppenderInheritance) +{ +#if(PVLOGGER_ENABLE) + _tag = _tagAllocator.ALLOCATE(oscl_strlen(inputTag) + 1); + + oscl_strncpy(_tag, inputTag, (oscl_strlen(inputTag) + 1)); + + _parentLogger = NULL; + _oAppenderInheritance = oAppenderInheritance; + _level = level; + _lastMsgLevel = PVLOGGER_LEVEL_UNINTIALIZED; +#else + OSCL_UNUSED_ARG(inputTag); + OSCL_UNUSED_ARG(level); + OSCL_UNUSED_ARG(oAppenderInheritance); +#endif + return; +} + +#if(PVLOGGER_ENABLE) +PVLogger::filter_status_type PVLogger::FilterMsg(message_id_type msgID) +{ + uint32 j; + + if (_pMsgFilterVec.size() > 0) + { + for (j = 0; j < _pMsgFilterVec.size(); j++) + { + PVLoggerFilter *msgFilter = _pMsgFilterVec[j]; + + filter_status_type msgStatus = msgFilter->FilterString(_tag, msgID, _level); + + if (msgStatus != PVLOGGER_FILTER_NEUTRAL) + { + return msgStatus; + } + } + } + /* + * Either All filters returned neutral => Accept msg + * or No msg filters => All msgs accepted by default + */ + return(PVLOGGER_FILTER_ACCEPT); +} + +void PVLogger::LogMsg(message_id_type msgID, const char *fmt, va_list arguments) +{ + uint32 i; + + for (i = 0; i < _pOwnAppenderVec.size(); i++) + { + PVLoggerAppender *appender = _pOwnAppenderVec[i]; + appender->AppendString(msgID, fmt, arguments); + } + return; +} + +void PVLogger::LogMsg(message_id_type msgID, int32 numPairs, va_list arguments) +{ + uint32 i; + + for (i = 0; i < _pOwnAppenderVec.size(); i++) + { + PVLoggerAppender *appender = _pOwnAppenderVec[i]; + appender->AppendBuffers(msgID, numPairs, arguments); + } + return; +} +#endif //PVLOGGER_ENABLE + +OSCL_EXPORT_REF PVLoggerRegistry* PVLoggerRegistry::GetPVLoggerRegistry() +{ +#if(PVLOGGER_ENABLE) + PVLOGGER_REGISTRY_WRAPPER< PVLoggerRegistry, PVLOGGER_REGISTRY_ID > pvLogRegSng; + return &(*pvLogRegSng); +#else + return NULL; +#endif +} + + +OSCL_EXPORT_REF PVLoggerRegistry::PVLoggerRegistry() +{ +#if(PVLOGGER_ENABLE) + /* + * Create the root logger node, by default turn off logging + * for the root node + */ + OsclAny* ptr = _pvloggerAlloc.allocate(sizeof(PVLogger)); + if (ptr) + { + PVLogger *logger = new(ptr) PVLogger(rootTag, PVLOGGER_LEVEL_UNINTIALIZED, true); + + // add logger to the tag tree + _loggerTree[OSCL_CONST_CAST(char*, (rootTag))] = logger; + } +#endif +}; + +OSCL_EXPORT_REF PVLoggerRegistry::~PVLoggerRegistry() +{ +#if(PVLOGGER_ENABLE) + Oscl_TagTree::iterator iter; + + for (iter = _loggerTree.begin(); + iter != _loggerTree.end(); iter++) + { + PVLogger* logger = iter->value; + logger->~PVLogger(); + _pvloggerAlloc.deallocate(logger); + } +#endif +} + +OSCL_EXPORT_REF PVLogger *PVLoggerRegistry::GetPVLoggerObject(const char* tagIn) +{ +#if(PVLOGGER_ENABLE) + Oscl_TagTree::iterator iter = + _loggerTree.find(OSCL_CONST_CAST(char*, (tagIn))); + + if (iter != _loggerTree.end()) + { + PVLogger* logger = iter->value; + return(logger); + } + else + { + /* creates a new logger object */ + PVLogger *logger = NULL; + logger = CreatePVLogger(tagIn, PVLOGGER_LEVEL_UNINTIALIZED, true); + return(logger); + } +#else + OSCL_UNUSED_ARG(tagIn); + return NULL; +#endif +} + +OSCL_EXPORT_REF PVLogger *PVLoggerRegistry::CreatePVLogger(const char* tagIn, log_level_type level, bool oAppenderInheritance) +{ +#if(PVLOGGER_ENABLE) + Oscl_TagTree::iterator iter; + + /* If the input tag already exists in the tagtree, it should have a pointer value of NULL */ + OSCL_ASSERT((_loggerTree.find(OSCL_CONST_CAST(char* const&, (tagIn))) == _loggerTree.end()) || + (_loggerTree.find(OSCL_CONST_CAST(char* const&, (tagIn))))->value == 0); + + OsclAny* ptr = _pvloggerAlloc.allocate(sizeof(PVLogger)); + if (!ptr) + return NULL;//fail gracefully + + PVLogger *logger = new(ptr) PVLogger(tagIn, level, oAppenderInheritance); + + // add logger to the tag tree + _loggerTree[OSCL_CONST_CAST(char*, (tagIn))] = logger; + + // how many levels deep is the node we just inserted? + iter = _loggerTree.find(OSCL_CONST_CAST(char*, (tagIn))); + uint32 depth = iter->depth(); + + // the tag tree will automatically create the parent, grandparent, etc. + // make sure each ancestor's stats node is initialized, i.e. initialize each ancestor + // until you reach one that is already initialized. + Oscl_TagTree::node_ptr parent = iter->parent; + + uint32 ii = 0; + + for (ii = 0; ii < depth; ii++) + { + OSCL_ASSERT(parent != 0); + + // if initialized then we're done + PVLogger* tmpPVLoggerNode = parent->value; + + if (tmpPVLoggerNode != NULL) + { + break; + } + + // create new Logger node, for tag use the tag created + // by the tag tree, for level use PV_LOG_LEVEL_UNINTIALIZED + // for oAppenderInheritance use true + OsclAny* ptr = _pvloggerAlloc.allocate(sizeof(PVLogger)); + if (ptr) + { + tmpPVLoggerNode = new(ptr) PVLogger(parent->tag.tag, PVLOGGER_LEVEL_UNINTIALIZED, true); + + // Add logger to tag tree + parent->value = tmpPVLoggerNode; + + parent = parent->parent; + } + } + + //Inherit the log level for the newly created node. + logger->SetLogLevel(level); + + parent = iter->parent; + OSCL_ASSERT(parent != NULL); + //Set the parent of the newly created node + logger->SetParent(parent->value); + + //Set the parent of the other nodes up the tree + for (ii = 0; ii < depth - 1; ii++) + { + + PVLogger* tmpPVLoggerNode = parent->value; + + parent = parent->parent; + OSCL_ASSERT(parent != NULL); + + //Set the parent for the node + tmpPVLoggerNode->SetParent(parent->value); + + } + + return(logger); +#else + OSCL_UNUSED_ARG(tagIn); + OSCL_UNUSED_ARG(level); + OSCL_UNUSED_ARG(oAppenderInheritance); + return NULL; +#endif +}; + +OSCL_EXPORT_REF bool PVLoggerRegistry::SetNodeLogLevelExplicit(char* tagIn, + log_level_type level) +{ +#if(PVLOGGER_ENABLE) + Oscl_TagTree::iterator iter; + + iter = _loggerTree.find(tagIn); + + if (iter != _loggerTree.end()) + { + Oscl_TagTree::node_type* currNode = &(*iter); + + SetNodeLogLevelExplicit(currNode, level); + + return true; + } +#else + OSCL_UNUSED_ARG(tagIn); + OSCL_UNUSED_ARG(level); +#endif + return false; + +} + +OSCL_EXPORT_REF void PVLoggerRegistry::SetNodeLogLevelExplicit(Oscl_TagTree::node_type* node, + log_level_type level) +{ +#if(PVLOGGER_ENABLE) + uint32 num_children = node->children.size(); + + for (uint32 i = 0; i < num_children; i++) + { + Oscl_TagTree::node_ptr child = (node->children)[i]; + + PVLogger* tmpPVLoggerNode = child->value; + tmpPVLoggerNode->SetLogLevel(level); + SetNodeLogLevelExplicit(child, level); + } +#else + OSCL_UNUSED_ARG(node); + OSCL_UNUSED_ARG(level); +#endif +}; diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger.h new file mode 100644 index 0000000..d9e0ee5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger.h @@ -0,0 +1,724 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/*! \file pvlogger.h + \brief This file contains basic logger interfaces for common use across platforms. + + This is the main entry point header file for the logger library. It should be + the only one users directly include. +*/ + +#ifndef PVLOGGER_H_INCLUDED +#define PVLOGGER_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_SHARED_PTR_H +#include "oscl_shared_ptr.h" +#endif + +#ifndef OSCL_BASE_ALLOC_H_INCLUDED +#include "oscl_base_alloc.h" +#endif + + +const int32 PVLOGGER_LEVEL_UNINTIALIZED = -1; + + + +//////////////////////////////////////////// +// The instrumentation layer allows groups +// of messages to be compiled in or out of +// the code based on a build-time parameter. +///////////////////////////////////////////// + +/** + * Release Layer + * + * The release layer should only be used for messages that + * should remain in the final release. In certain cases all + * messaging may be disabled depending on customer requirements. + * However, when allowed the release layer should contain + * information that will be useful diagnosing problems in a + * released product (perhaps after entering a diagnostic mode), + * but with absolutely minimal performance impact when disabled + * at runtime. + */ +#define PVLOGMSG_INST_REL 0 +/** + * Profile Layer + * + * The profile layer is used for messages and information + * related to messuring and reporting performance-related + * information. + */ +#define PVLOGMSG_INST_PROF 1 +/** + * High Level Debug Layer + * + * This layer should contain messages that have very minimal + * impact on performance, but are at lower level (i.e., provide + * more information) than would be appropriate in a shipping + * product. The messages are probably used to gather information + * and validate proper functionality at a high level as might + * be appropriate for IOT, stress testing, or QA testing. + */ +#define PVLOGMSG_INST_HLDBG 2 +/** + * Mid Level Debug Layer + * + * This layer should contain messages that are useful in the + * middle stages of the development cycle where major components + * are being integrated. The components themselves should + * already be well-tested so the emphasis is on interfaces + * between these components and integration testing. Messages + * at this layer may have some performance impact. + */ +#define PVLOGMSG_INST_MLDBG 3 +/** + * Low Level Debug Layer + * + * This layer should contain messages for early functional + * testing. The messages are typically at a very low-level + * and allow testing the functionality of individual modules + * and components. Messages at this layer will typically have + * a performance impact (sometimes significant) due to the + * fact that they are at such a low level. + */ +#define PVLOGMSG_INST_LLDBG 4 + +/* +** Default logger instrumentation level. To override this +** setting, define PVLOGGER_INST_LEVEL in the osclconfig.h file. +** Possible values and the resulting intrumentation: +** +** PVLOGGER_INST_LEVEL 0 : No logging. All logging statements compiled out. +** PVLOGGER_INST_LEVEL 1 : Release level only. +** PVLOGGER_INST_LEVEL 2 : Release level + profile level +** PVLOGGER_INST_LEVEL 3 : Release level + profile level + high-level debug +** PVLOGGER_INST_LEVEL 4 : Release level + profile level + high-level debug + mid-level debug +** PVLOGGER_INST_LEVEL 5 & above : Release level + profile level + high-level debug +** + mid-level debug + low-level debug +*/ +#ifndef PVLOGGER_INST_LEVEL +#if (OSCL_RELEASE_BUILD) +/* Release mode-- Profile logging */ +#define PVLOGGER_INST_LEVEL 1 +#else +/* Debug mode-- Complete logging */ +#define PVLOGGER_INST_LEVEL 5 +#endif +#endif + + +#if (PVLOGGER_INST_LEVEL<1) + +/* +** Disable and compile-out all logging +*/ +#define PVLOGGER_LOGMSG(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGMSG_V(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_V(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOG_USE_ONLY(x) + +#else //PVLOGGER_INST_LEVEL + +/* +** Internal use macros that make the logging calls to PVLogger. +*/ +#define _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)\ +{\ + if (LOGGER)\ + {\ + if (LOGGER->IsActive(LEVEL))\ + {\ + LOGGER->LogMsgString MESSAGE;\ + }\ + }\ +} + +#define _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)\ +{\ + if (LOGGER)\ + {\ + if (LOGGER->IsActive(LEVEL))\ + {\ + LOGGER->LogMsgStringV MESSAGE;\ + }\ + }\ +} + +#define _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE) \ +{\ + if (LOGGER)\ + {\ + if (LOGGER->IsActive(LEVEL))\ + {\ + LOGGER->LogMsgBuffers MESSAGE;\ + }\ + }\ +} + +#define _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE) \ +{\ + if (LOGGER)\ + {\ + if (LOGGER->IsActive(LEVEL))\ + {\ + LOGGER->LogMsgBuffersV MESSAGE;\ + }\ + }\ +} + +/* +** In case some compilers cannot support the instrumentation-level macros, +** they can be disabled by defining PVLOGGER_INST_LEVEL_SUPPORT to 0 +** in their osclconfig.h. If instrumentation level is not supported, then +** all instrumentation levels will be compiled in. +** +** If PVLOGGER_INST_LEVEL_SUPPORT is not defined, the default is set here to allow +** compile-time instrumentation level support. +*/ +#ifndef PVLOGGER_INST_LEVEL_SUPPORT +#define PVLOGGER_INST_LEVEL_SUPPORT 1 +#endif + +#if !(PVLOGGER_INST_LEVEL_SUPPORT) + +/* +** A set of logging macros that ignore the instrumentation level. +** All instrumentation levels will be compiled in. +*/ +#define PVLOGGER_LOGMSG(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGMSG_V(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_V(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE) + +#else //PVLOGGER_INST_LEVEL_SUPPORT + +/* +** This set of macros compiles the logging statements in or out based on the instrumtation +** level. +*/ + +#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_REL) +#define PVLOGGER_LOGMSG_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE) +#else +#define PVLOGGER_LOGMSG_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#endif + +#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_PROF) +#define PVLOGGER_LOGMSG_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE) +#else +#define PVLOGGER_LOGMSG_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#endif + +#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_HLDBG) +#define PVLOGGER_LOGMSG_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE) +#else +#define PVLOGGER_LOGMSG_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#endif + +#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_MLDBG) +#define PVLOGGER_LOGMSG_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_V_PVLOGMSG_V_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE) +#else +#define PVLOGGER_LOGMSG_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_V_PVLOGMSG_V_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#endif + +#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG) +#define PVLOGGER_LOGMSG_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE) +#else +#define PVLOGGER_LOGMSG_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER); +#endif + + +/** + * This is the text based API to log messages + * + * @param IL Instrumentation level. + * @param LOGGER Pointer to the logger object, that acts as the logging + * control/interface point + * @param LEVEL Log level of the message + * @param MESSAGE Log Message which includes the message id, and any kind + * of formatting information + * + * Example Usage: + * PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, logger_1, PVLOGMSG_WARNING, (13, "Test Messsage to Node 1\n")); + * -This message of log level PVLOGMSG_WARNING, and has a message id of 13 + */ +#define PVLOGGER_LOGMSG(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGMSG_ ## IL (LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGMSG_V(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGMSG_V_ ## IL (LOGGER, LEVEL, MESSAGE) + +/** + * This is a binary API to log messages + * + * @param IL Instrumentation level. + * @param LOGGER Pointer to the logger object, that acts as the logging + * control/interface point + * @param LEVEL Log level of the message + * @param MESSAGE Log Message which includes the message id, and message + * buffers that need to be logged. + * + * Example Usage: + * PVLOGGER_LOGBIN (PVLOGMSG_INST_LLDBG, logger_1, PVLOGMSG_WARNING, (10, 3, msgBuf1Size, msgBuf1, + * msgBuf2Size, msgBuf2, + * msgBuf3Size, msgBuf3)); + * + * -This message contains THREE (ptr_len, ptr) pairs. + * Log level of this msg is PVLOGMSG_WARNING, + * message id is 10. + */ +#define PVLOGGER_LOGBIN(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGBIN_ ## IL (LOGGER, LEVEL, MESSAGE) +#define PVLOGGER_LOGBIN_V(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGBIN_V_ ## IL (LOGGER, LEVEL, MESSAGE) + +#endif //PVLOGGER_INST_LEVEL_SUPPORT + +/** + * Used to compile in/out lines of code that are used only + * for PVLogger macros. + * + * This code will be removed at compile time when PVLogger + * is disabled, i.e. Release mode. So do not put in any + * code that is necessary for correct functionality of the module + */ +#define PVLOGGER_LOG_USE_ONLY(x) x + +#endif // PVLOGGER_INST_LEVEL + +/** + * In case logging is compiled out, there is no need to compile + * the logger runtime code either. + */ +#ifndef PVLOGGER_ENABLE +#if (PVLOGGER_INST_LEVEL<1) +#define PVLOGGER_ENABLE 0 +#else +#define PVLOGGER_ENABLE 1 +#endif +#endif + +/** + * Class: PVLogger + * + * Each logger instance is associated with a unique tag. PVLoggerRegistry + * class, maintains a repository of all the loggers, along with their + * associated tags. Each logger has an associated list of appenders. Appenders + * are entities that act as a sink for all the incoming messages. They could be + * file appenders, serial port appenders, buffer appenders etc. Each logger + * also has a list of message filters. These filters remove any unwanted messages + * from the output. + */ +class PVLoggerAppender; +class PVLoggerFilter; +class PVLogger +{ + public: + + typedef int32 log_level_type; + typedef int32 message_id_type; + typedef int32 filter_status_type; + typedef _OsclBasicAllocator alloc_type; + + /** + * PVLogger needs to be initialized once per thread. This + * creates the PVLogger singleton that is used throughout + * the duration of the thread. Initialization must occur + * before the first message is logged. + * + * @exception leaves if out of memory + */ + OSCL_IMPORT_REF static void Init(); + + + /** + * Frees the PVLogger singleton used by the current thread. + * This must be called before thread exit. No messages + * can be logged after cleanup. + * + * @return + */ + OSCL_IMPORT_REF static void Cleanup(); + + /** + * This is a factory method to create a log control point, with a + * certain input tag. There is a central registry of all the loggers, + * with their corresponding tags, called PV Logger Registry. In case + * the logger with the specified tag exists in the global registry, it + * is returned, else a new one is created and a pointer to the same is + * returend. + * + * @param inputTag logger tag, viz. "x.y.z" + * @param level log level associated with the logging control point + * (All messages with log levels less than equal to the + * log level of the control point would be logged) + * + * @param oAppenderInheritance + * + * @return PVLogger* Pointer to the logging control point + * + * @exception leaves if out of memory + */ + + OSCL_IMPORT_REF static PVLogger *GetLoggerObject(const char* inputTag); + + /** + * This method is used to set the log level of a control point. + * + * @param level log level associated with the logging control point + * + * @return NONE + */ + void SetLogLevel(log_level_type level) + { +#if(PVLOGGER_ENABLE) + _level = level; +#else + OSCL_UNUSED_ARG(level); +#endif + } + + /** + * This method is used to set the log level of a control point, as well as + * to propagate the level to all the descendants of this control point. + * + * @param level log level associated with the logging control point + * + * @return NONE + */ + OSCL_IMPORT_REF void SetLogLevelAndPropagate(log_level_type level); + + /** + * This method returns the log level of a control point. This could either + * have been set explicitly by the user (at the time of creation or later) + * or could have been inherited from one of its ancestors. + * + * @return log level associated with the logging control point + */ + log_level_type GetLogLevel() + { +#if(PVLOGGER_ENABLE) + return(_level); +#else + return 0; +#endif + } + + /** + * This method disables appender inheritance for the logging control point + * + */ + void DisableAppenderInheritance() + { +#if(PVLOGGER_ENABLE) + _oAppenderInheritance = false; +#endif + } + + /** + * This method adds an appender to the logging control point. Each logger + * maintains a list of appenders. Any msg to a logger if deemed active is + * logged to all the appenders. + * + * @param appender pointer to the appender to add + * + * @return NONE + * + * @exception leaves if out of memory + */ + void AddAppender(OsclSharedPtr &appender) + { +#if(PVLOGGER_ENABLE) + _pOwnAppenderVec.push_back(appender); +#else + OSCL_UNUSED_ARG(appender); +#endif + } + + /** + * This method removes an appender from the logging control point. Each logger + * maintains a list of appenders. Any msg to a logger if deemed active is + * logged to all the appenders. + * + * @param appender pointer to the appender to delete + * + * @return NONE + */ + void RemoveAppender(OsclSharedPtr &appender) + { +#if(PVLOGGER_ENABLE) + for (Oscl_Vector, alloc_type>::iterator it = _pOwnAppenderVec.begin(); + it != _pOwnAppenderVec.end(); + it++) + { + if ((*it).GetRep() == appender.GetRep()) + { + _pOwnAppenderVec.erase(it); + break; + } + } +#else + OSCL_UNUSED_ARG(appender); +#endif + } + + /** + * This method adds a message filter to the logging control point. Each logger + * maintains a list of filters. Any msg to a logger if deemed active is + * passed through the msg filters prior to logging. + * + * @param msgFilter pointer to the filter to add + * + * @return NONE + * + * @exception leaves if out of memory + */ + void AddFilter(OsclSharedPtr &filter) + { +#if(PVLOGGER_ENABLE) + _pMsgFilterVec.push_back(filter); +#else + OSCL_UNUSED_ARG(filter); +#endif + }; + + /** + * This method returns the number of appenders attached to the logging control point. + */ + uint32 GetNumAppenders() + { +#if(PVLOGGER_ENABLE) + return(_pOwnAppenderVec.size()); +#else + return 0; +#endif + } + + /** + * This method determines if a msg passed to the logging control point is active + * or not. Only messages that are deemed active are logged. Messages are considered + * not active if any of the following criteria are met: + * - All logging is disabled at this logging control point + * - If all the log levels, leading upto the root log point are uninitialized + * - If the log level of the incoming message is LESS THAN that of the active + * log level of the logging control point. + * + * @return BOOL + */ + OSCL_IMPORT_REF bool IsActive(log_level_type level); + + /** + * This method logs formatted text msg to all the appenders, after running thrrough + * the message filters. After logging the message to the appenders attached to the + * current control point, the message is passed up to the parent node, only if + * appender inheritance is enabled. + * + * + * @param msgID Message ID, that is unique to a message + * @param fmt format string, similar to one taken by printf + * @param arguments Variable list of arguments + * + * @return NONE + */ + OSCL_IMPORT_REF void LogMsgStringV(message_id_type msgID, const char * fmt, va_list arguments); + + /** + * This method logs opaque data buffers to all the appenders, after running thrrough + * the message filters. After logging the message to the appenders attached to the + * current control point, the message is passed up to the parent node, only if + * appender inheritance is enabled. + * + * + * @param msgID Message ID, that is unique to a message + * @param numPairs Number of (ptr_len, ptr) pairs + * @param arguments Variable list of arguments + * + * @return NONE + */ + OSCL_IMPORT_REF void LogMsgBuffersV(message_id_type msgID, int32 numPairs, va_list arguments); + + /** + * This method logs formatted text msg to all the appenders, after running thrrough + * the message filters. After logging the message to the appenders attached to the + * current control point, the message is passed up to the parent node, only if + * appender inheritance is enabled. + * + * + * @param msgID Message ID, that is unique to a message + * @param fmt format string, similar to one taken by printf + * @param arguments Variable list of arguments + * + * @return NONE + */ + OSCL_IMPORT_REF void LogMsgString(message_id_type msgID, const char * fmt, ...); + + /** + * This method logs opaque data buffers to all the appenders, after running thrrough + * the message filters. After logging the message to the appenders attached to the + * current control point, the message is passed up to the parent node, only if + * appender inheritance is enabled. + * + * + * @param msgID Message ID, that is unique to a message + * @param numPairs Number of (ptr_len, ptr) pairs + * @param arguments Variable list of arguments + * + * @return NONE + */ + OSCL_IMPORT_REF void LogMsgBuffers(message_id_type msgID, int32 numPairs, ...); + + /** + * Logger Constructor + * + * + * @param tag Logger tag, unique to a logging control point + * @param level Active Log level of the logger + * @param oAppenderInheritance + * + * @return NONE + */ + OSCL_IMPORT_REF PVLogger(const char* inputTag, log_level_type level, bool oAppenderInheritance); + + virtual ~PVLogger() + { +#if(PVLOGGER_ENABLE) + _tagAllocator.deallocate(_tag); +#endif + } + +#if(PVLOGGER_ENABLE) + protected: + friend class PVLoggerRegistry; + void SetParent(PVLogger *parentLogger) + { + _parentLogger = parentLogger; + } + PVLogger *GetParent() + { + return(_parentLogger); + } + + private: + filter_status_type FilterMsg(message_id_type msgID); + void LogMsg(message_id_type msgID, const char *fmt, va_list arguments); + void LogMsg(message_id_type msgID, int32 numPairs, va_list arguments); + + char* _tag; + log_level_type _level; + log_level_type _lastMsgLevel; + bool _oAppenderInheritance; + + PVLogger *_parentLogger; + Oscl_TAlloc _tagAllocator; + + Oscl_Vector, alloc_type> _pMsgFilterVec; + Oscl_Vector, alloc_type> _pOwnAppenderVec; +#endif //PVLOGGER_ENABLE +}; + +////////////////////////////////////// +// log message levels +////////////////////////////////////// + +/** + * system is unusable + */ +const PVLogger::log_level_type PVLOGMSG_EMERG = 0; +/** + * action must be taken immediately + */ +const PVLogger::log_level_type PVLOGMSG_ALERT = 1; +/** + * critical conditions + */ +const PVLogger::log_level_type PVLOGMSG_CRIT = 2; +/** + * error conditions + */ +const PVLogger::log_level_type PVLOGMSG_ERR = 3; +/** + * warning conditions + */ +const PVLogger::log_level_type PVLOGMSG_WARNING = 4; +/** + * normal but significant condition + */ +const PVLogger::log_level_type PVLOGMSG_NOTICE = 5; +/** + * informational + */ +const PVLogger::log_level_type PVLOGMSG_INFO = 6; +/** + * function enter and exit + */ +const PVLogger::log_level_type PVLOGMSG_STACK_TRACE = 7; +/** + * debug-level messages + */ +const PVLogger::log_level_type PVLOGMSG_DEBUG = 8; + +/////////////////////////////////// +// do not use these levels +// for backward compatibility only +/////////////////////////////////// +const PVLogger::log_level_type PVLOGMSG_FATAL_ERROR = PVLOGMSG_EMERG; +const PVLogger::log_level_type PVLOGMSG_NONFATAL_ERROR = PVLOGMSG_ERR; +const PVLogger::log_level_type PVLOGMSG_STATISTIC = PVLOGMSG_INFO; +const PVLogger::log_level_type PVLOGMSG_VERBOSE = PVLOGMSG_DEBUG; + +#endif // PVLOGGER_H_INCLUDED diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_accessories.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_accessories.h new file mode 100644 index 0000000..e856353 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_accessories.h @@ -0,0 +1,129 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef PVLOGGER_ACCESSORIES_H_INCLUDED +#define PVLOGGER_ACCESSORIES_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef PVLOGGER_H_INCLUDED +#include "pvlogger.h" +#endif + +/** + * Base class for all message formatters. This class defines the interface to + * the message formatter. There are two kinds of msg formatting APIs, one to + * format text messages, and other to format opaque message buffers. + */ +class PVLoggerLayout +{ + public: + typedef PVLogger::message_id_type message_id_type; + + virtual ~PVLoggerLayout() {} + + /** + * Formats the string and copies it to the given buffer. + * + * @return The length of the string not including the trailing '\0' + */ + virtual int32 FormatString(char* formatBuf, int32 formatBufSize, + message_id_type msgID, const char * fmt, + va_list va) = 0; + + /** + * Formats the data and copies it to the given buffer. + * + * @return The length of the buffer used. + */ + virtual int32 FormatOpaqueMessage(char* formatBuf, int32 formatBufSize, + message_id_type msgID, int32 numPairs, + va_list va) = 0; +}; + +/** + * Base class for all message filters. This class defines the interface to + * the message filters. There are two kinds of msg filtering APIs, one to + * filter text messages, and other to filter opaque message buffers. + */ +class PVLoggerFilter +{ + public: + virtual ~PVLoggerFilter() {} + + typedef PVLogger::message_id_type message_id_type; + typedef PVLogger::log_level_type log_level_type; + typedef PVLogger::filter_status_type filter_status_type; + + virtual filter_status_type FilterString(char* tag, message_id_type msgID, log_level_type level) = 0; + virtual filter_status_type FilterOpaqueMessge(char* tag, message_id_type msgID, log_level_type level) = 0; +}; + +const PVLoggerFilter::filter_status_type PVLOGGER_FILTER_ACCEPT = 1; +const PVLoggerFilter::filter_status_type PVLOGGER_FILTER_REJECT = 2; +const PVLoggerFilter::filter_status_type PVLOGGER_FILTER_NEUTRAL = 3; + +/** + * Example filter that allows all messages to be logged. + */ +class AllPassFilter : public PVLoggerFilter +{ + public: + typedef PVLoggerFilter::message_id_type message_id_type; + typedef PVLoggerFilter::log_level_type log_level_type; + typedef PVLoggerFilter::filter_status_type filter_status_type; + + AllPassFilter() {}; + virtual ~AllPassFilter() {}; + + filter_status_type FilterString(char* tag, message_id_type msgID, log_level_type level) + { + OSCL_UNUSED_ARG(tag); + OSCL_UNUSED_ARG(msgID); + OSCL_UNUSED_ARG(level); + return (PVLOGGER_FILTER_ACCEPT); + }; + filter_status_type FilterOpaqueMessge(char* tag, message_id_type msgID, log_level_type level) + { + OSCL_UNUSED_ARG(tag); + OSCL_UNUSED_ARG(msgID); + OSCL_UNUSED_ARG(level); + return (PVLOGGER_FILTER_ACCEPT); + }; +}; + +/** + * Base class for all message appenders. This class defines the interface to + * the message appenders. There are two kinds of msg appender APIs, one to + * append text messages, and other to append opaque message buffers. + */ +class PVLoggerAppender +{ + public: + typedef PVLogger::message_id_type message_id_type; + + virtual ~PVLoggerAppender() {} + + virtual void AppendString(message_id_type msgID, const char *fmt, va_list va) = 0; + virtual void AppendBuffers(message_id_type msgID, int32 numPairs, va_list va) = 0; +}; + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_c.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_c.cpp new file mode 100644 index 0000000..618f59a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_c.cpp @@ -0,0 +1,48 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "pvlogger.h" +#include "pvlogger_c.h" + + + +//C-callable version of PVLogger::GetLoggerObject +OSCL_EXPORT_REF void* pvLogger_GetLoggerObject(const char* tag) +{ + return PVLogger::GetLoggerObject(tag); +} + +//C-callable version of PVLogger::IsActive +OSCL_EXPORT_REF int pvLogger_IsActive(void* logger, int log_level) +{ + if (logger) + return (int)((PVLogger*)logger)->IsActive(log_level); + return 0; +} + +//C-callable version of PVLogger::LogMsgString +OSCL_EXPORT_REF void pvLogger_LogMsgString(void* logger, int msgID, const char * fmt, ...) +{ + if (logger) + { + va_list arguments; + va_start(arguments, fmt); + + ((PVLogger*)logger)->LogMsgStringV(msgID, fmt, arguments); + } +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_c.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_c.h new file mode 100644 index 0000000..1cb29ea --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_c.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/*! \file pvlogger_c.h + \brief This file contains basic logger interfaces for common use across platforms. + C-callable version + + This is the main entry point header file for the logger library. It should be + the only one users directly include. +*/ + +#ifndef PVLOGGER_C_H_INCLUDED +#define PVLOGGER_C_H_INCLUDED + +#include "osclconfig.h" + +#ifndef OSCL_IMPORT_REF +#define OSCL_IMPORT_REF +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +//C-callable logging routines. + OSCL_IMPORT_REF void* pvLogger_GetLoggerObject(const char* tag); + OSCL_IMPORT_REF int pvLogger_IsActive(void* logger, int log_level); + OSCL_IMPORT_REF void pvLogger_LogMsgString(void* logger, int msgID, const char * fmt, ...); + +#ifdef __cplusplus +} +#endif + + +//Logging instrumentation level default. To change this for a project, add a definition of +//PVLOGGER_C_INST_LEVEL to the osclconfig.h file. This default sets level to 2 for release +//mode, full logging for debug build. + +#ifndef PVLOGGER_C_INST_LEVEL +#if (OSCL_RELEASE_BUILD) +#define PVLOGGER_C_INST_LEVEL 2 +#else +#define PVLOGGER_C_INST_LEVEL 5 +#endif +#endif + +//Instrumentation levels. +#define PVLOGMSG_C_INST_REL 0 +#define PVLOGMSG_C_INST_PROF 1 +#define PVLOGMSG_C_INST_HLDBG 2 +#define PVLOGMSG_C_INST_MLDBG 3 +#define PVLOGMSG_C_INST_LLDBG 4 + +//Logging levels +#define PVLOGMSG_C_EMERG 0 +#define PVLOGMSG_C_ALERT 1 +#define PVLOGMSG_C_CRIT 2 +#define PVLOGMSG_C_ERR 3 +#define PVLOGMSG_C_WARNING 4 +#define PVLOGMSG_C_NOTICE 5 +#define PVLOGMSG_C_INFO 6 +#define PVLOGMSG_C_STACK_TRACE 7 +#define PVLOGMSG_C_STACK_DEBUG 8 + +/* +//Example Usage: + +#if (PVLOGGER_C_INST_LEVEL > PVLOGMSG_C_INST_LLDBG) + if(pvLogger_IsActive(logger ,PVLOGMSG_C_ERR)) + pvLogger_LogMsgString( logger , 0 ,"Some message, value %d", intvalue ); + +#endif +*/ + + + +#endif // PVLOGGER_C_H_INCLUDED diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_registry.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_registry.h new file mode 100644 index 0000000..fbacec0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclbase/src/pvlogger_registry.h @@ -0,0 +1,123 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef PVLOGGER_REGISTRY_H_INCLUDED +#define PVLOGGER_REGISTRY_H_INCLUDED + +#ifndef PVLOGGER_H_INCLUDED +#include "pvlogger.h" +#endif + +#ifndef OSCL_TAGTREE_H_INCLUDED +#include "oscl_tagtree.h" +#endif + +/** + * Class: PVLoggerRegistry + * + * PVLoggerRegistry class, maintains a repository of all the loggers, along with + * their associated tags, in a tag tree. Any request for a log control point is + * serviced by this class. + * + * Memory Ownership: Creates log control points for each tag, and holds these + * pointers in the tag tree. PVLogger registry is responsible for calling the + * destructor on each of these loggers. + * + */ + +class PVLoggerRegistry +{ + public: + + typedef PVLogger::log_level_type log_level_type; + typedef PVLogger::alloc_type alloc_type; + + /** + * Get the logger registry. There is only one logger + * registry instance per thread. + */ + OSCL_IMPORT_REF static PVLoggerRegistry* GetPVLoggerRegistry(); + + /** + * PVLoggerRegistry Constructor + * + */ + OSCL_IMPORT_REF PVLoggerRegistry(); + + /** + * PVLoggerRegistry Destructor + * + */ + OSCL_IMPORT_REF virtual ~PVLoggerRegistry(); + + /** + * PVLoggerRegistry method to get access to a logging control point, associated with + * a tag. In case the logger for this tag does not exist, it is created afresh, else + * pointer to the existing one is returned. + * + * @param inputTag logger tag, viz. "x.y.z" + * @param level log level associated with the logging control point + * + * @param oAppenderInheritance + * + * @return PVLogger* Pointer to the logging control point + */ + OSCL_IMPORT_REF PVLogger *GetPVLoggerObject(const char* tagIn); + + /** + * This method creates a log control point, with specified tag, and level + * + * @param inputTag logger tag, viz. "x.y.z" + * @param level log level associated with the logging control point + * + * @param oAppenderInheritance + * + * @return PVLogger* Pointer to the logging control point + */ + OSCL_IMPORT_REF PVLogger *CreatePVLogger(const char* tagIn, log_level_type level, bool oAppenderInheritance); + + /** + * This method propagates the log level to all the descendents of the node, + * with a specified tag. + * + * @param tagIn logger tag, viz. "x.y.z" + * @param level log level associated with the logging control point + * + * @return true on success, else false. + */ + OSCL_IMPORT_REF bool SetNodeLogLevelExplicit(char* tagIn, log_level_type level); + + /** + * This method recursively propagates the log level to all the descendents, + * of a node. + * + * @param node Node ptr, associated with a logger, from the tag tree. + * @param level log level associated with the logging control point + * + * @return NONE + */ + OSCL_IMPORT_REF void SetNodeLogLevelExplicit(Oscl_TagTree::node_type* node, log_level_type level); + + private: +#if (PVLOGGER_ENABLE) + Oscl_TAlloc _pvloggerAlloc; + Oscl_TagTree _loggerTree; +#endif +}; + +#endif // PVLOGGER_REGISTRY_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/Android.mk new file mode 100644 index 0000000..90c7fd0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/Android.mk @@ -0,0 +1,44 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/oscl_errno.cpp \ + src/oscl_error.cpp \ + src/oscl_error_imp_jumps.cpp \ + src/oscl_error_trapcleanup.cpp \ + src/oscl_heapbase.cpp + + +LOCAL_MODULE := libosclerror + +LOCAL_CFLAGS := $(PV_CFLAGS) + + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/oscl/oscl/osclerror/src \ + $(PV_TOP)/oscl/oscl/osclerror/src \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + src/oscl_errno.h \ + src/oscl_error_allocator.h \ + src/oscl_error_codes.h \ + src/oscl_error.h \ + src/oscl_error_imp_cppexceptions.h \ + src/oscl_error_imp_fatalerror.h \ + src/oscl_error_imp.h \ + src/oscl_error_imp_jumps.h \ + src/oscl_error_trapcleanup.h \ + src/oscl_exception.h \ + src/oscl_heapbase.h \ + src/oscl_namestring.h \ + src/oscl_errno.inl \ + src/oscl_heapbase.inl + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/build/make/local.mk new file mode 100644 index 0000000..98a8b01 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/build/make/local.mk @@ -0,0 +1,37 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + + +TARGET = osclerror + + +SRCDIR = ../../src +INCSRCDIR = ../../src + +SRCS = oscl_errno.cpp \ + oscl_error.cpp \ + oscl_error_imp_jumps.cpp \ + oscl_error_trapcleanup.cpp \ + oscl_heapbase.cpp + +HDRS = oscl_errno.h \ + oscl_error_allocator.h \ + oscl_error_codes.h \ + oscl_error.h \ + oscl_error_imp_cppexceptions.h \ + oscl_error_imp_fatalerror.h \ + oscl_error_imp.h \ + oscl_error_imp_jumps.h \ + oscl_error_trapcleanup.h \ + oscl_exception.h \ + oscl_heapbase.h \ + oscl_namestring.h \ + oscl_errno.inl \ + oscl_heapbase.inl + + +include $(MK)/library.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_errno.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_errno.cpp new file mode 100644 index 0000000..777206d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_errno.cpp @@ -0,0 +1,27 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_errno.h" + +#if (OSCL_DISABLE_INLINES) +#include "oscl_errno.inl" +#endif + +#ifndef OSCL_COMBINED_DLL +#include "oscl_dll.h" +OSCL_DLL_ENTRY_POINT_DEFAULT() +#endif // OSCL_COMBINED_DLL diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_errno.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_errno.h new file mode 100644 index 0000000..4b7685e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_errno.h @@ -0,0 +1,100 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E R R N O + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_errno.h + \brief Defines functions to access additional information on errors where supported through an errno or similar service. +*/ + +//! oscl_errno.h contains functions to access the global errno + +#ifndef OSCL_ERRNO_H_INCLUDED +#define OSCL_ERRNO_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCLCONFIG_ERROR_H_INCLUDED +#include "osclconfig_error.h" +#endif + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +/*! + +*/ +//! This function determines if a particular system saves the error number that occurs on a system call +/*! + \return This method returns false on systems that do not save the + error number that occurs on a system call in a global variable. + Returns true for systems that do save the error number +*/ +OSCL_IMPORT_REF bool OSCL_IsErrnoSupported(); + +//! This function returns the value of the system's global error number variable +/*! + \return Returns 0 for system's that do not have this functionality + The value of the error number variable does not change until the user + calls SetLastError or if another system call occurs that changes the value + Supported Platforms: Win32/wince, Unix + Unsupported Platforms : Symbian +*/ +OSCL_IMPORT_REF int OSCL_GetLastError(); + +//! This function sets the last error code for the system +/*! + \param newVal This value represents the new value for the global error number + This method can be used to reset the error number after having retrieved it + using GetLastError. + Supported Platforms: Win32/wince, Unix + Unsupported Platforms : Symbian +*/ +OSCL_IMPORT_REF bool OSCL_SetLastError(int newVal); + +//! This function maps an error number to an error-message string. +/*! + \param errnum This value represents the error number to map + \return This method returns a pointer to a string containing the + system error-message. It returns NULL for systems that do not have + this functionality + Supported Platforms: Win32/wince, Unix + Unsupported Platforms : Symbian +*/ +OSCL_IMPORT_REF char *OSCL_StrError(int errnum); + +#if (!OSCL_DISABLE_INLINES) +#include "oscl_errno.inl" +#endif + + +#endif // INCLUDED_OSCL_ERRNO_H + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_errno.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_errno.inl new file mode 100644 index 0000000..c5ce65c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_errno.inl @@ -0,0 +1,37 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +OSCL_COND_EXPORT_REF OSCL_INLINE bool OSCL_IsErrnoSupported() +{ + return true; +}; + +OSCL_COND_EXPORT_REF OSCL_INLINE int OSCL_GetLastError() +{ + return errno; +}; + +OSCL_COND_EXPORT_REF OSCL_INLINE bool OSCL_SetLastError(int newVal) +{ + errno = newVal; + return true; +}; + +OSCL_COND_EXPORT_REF OSCL_INLINE char * OSCL_StrError(int errNum) +{ + return (strerror(errNum)); +}; diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error.cpp new file mode 100644 index 0000000..f18acea --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error.cpp @@ -0,0 +1,214 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#include "oscl_error.h" +#include "oscl_assert.h" +#include "oscl_error_trapcleanup.h" +#include "oscl_error_imp.h" +#include "oscl_heapbase.h" +#include "pvlogger.h" + +// +// OsclErrorTrap +// +OSCL_EXPORT_REF int32 OsclErrorTrap::Init(Oscl_DefAlloc *aAlloc) +//Init the error trap for this thread. +{ + + //make sure OsclError is only initialized once per thread + int32 error; + if (OsclErrorTrapImp::GetErrorTrap(error)) + return OsclErrAlreadyInstalled; + if (error) + return error;//from GetErrorTrap + + _OsclBasicAllocator defalloc; + OsclAny *ptr = (aAlloc) ? aAlloc->ALLOCATE(sizeof(OsclErrorTrapImp)) + : defalloc.ALLOCATE(sizeof(OsclErrorTrapImp)); + if (!ptr) + return OsclErrNoMemory; + + OsclErrorTrapImp* self = new(ptr) OsclErrorTrapImp(aAlloc, error); + if (error) + {//not successfully constructed. + self->~OsclErrorTrapImp(); + (aAlloc) ? aAlloc->deallocate(ptr) : defalloc.deallocate(ptr); + return error; + } + + OsclErrorTrapImp::SetErrorTrap(self, error); + + return error; +} + +OSCL_EXPORT_REF int32 OsclErrorTrap::Cleanup() +//Cleanup the error trap for this thread. +{ + int32 error; + OsclErrorTrapImp *errortrap = OsclErrorTrapImp::GetErrorTrap(error); + if (errortrap) + { + Oscl_DefAlloc *alloc = errortrap->iAlloc; + + bool default_alloc = (errortrap->iAlloc == &errortrap->iDefAlloc); + errortrap->~OsclErrorTrapImp(); + if (default_alloc) + { + _OsclBasicAllocator defalloc; + defalloc.deallocate(errortrap); + } + else + { + alloc->deallocate(errortrap); + } + OsclErrorTrapImp::SetErrorTrap(NULL, error); + } + else if (!error) + error = OsclErrNotInstalled;//no errortrap. + + return error; +} + +OSCL_EXPORT_REF OsclErrorTrapImp* OsclErrorTrap::GetErrorTrapImp() +{ + return OsclErrorTrapImp::GetErrorTrap(); +} + +// +// OsclError +// +OSCL_EXPORT_REF void OsclError::PushL(_OsclHeapBase * aPtr) +{ + OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap(); + if (!trap) + { + OsclError::Leave(OsclErrNotInstalled); + return; + } + trap->iTrapStack->PushL(aPtr); +} + +OSCL_EXPORT_REF void OsclError::PushL(OsclAny* aPtr) +{ + OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap(); + if (!trap) + { + OsclError::Leave(OsclErrNotInstalled); + return; + } + //convert from TAny to TCleanupItem so the correct + //deallocator will get used. + OsclTrapItem item(OsclErrorTrapImp::TrapOperation, aPtr); + trap->iTrapStack->PushL(item); +} + +OSCL_EXPORT_REF void OsclError::PushL(OsclTrapItem anItem) +{ + OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap(); + if (!trap) + { + OsclError::Leave(OsclErrNotInstalled); + return; + } + trap->iTrapStack->PushL(anItem); +} + +OSCL_EXPORT_REF void OsclError::Pop() +{ + OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap(); + if (!trap) + { + OsclError::Leave(OsclErrNotInstalled); + return; + } + trap->iTrapStack->Pop(); +} + +OSCL_EXPORT_REF void OsclError::Pop(int32 aCount) +{ + OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap(); + if (!trap) + { + OsclError::Leave(OsclErrNotInstalled); + return; + } + trap->iTrapStack->Pop(aCount); +} + +OSCL_EXPORT_REF void OsclError::PopDealloc() +{ + OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap(); + if (!trap) + { + OsclError::Leave(OsclErrNotInstalled); + return; + } + trap->iTrapStack->PopDealloc(); +} + +OSCL_EXPORT_REF void OsclError::PopDealloc(int32 aCount) +{ + OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap(); + if (!trap) + { + OsclError::Leave(OsclErrNotInstalled); + return; + } + trap->iTrapStack->PopDealloc(aCount); +} + +OSCL_EXPORT_REF void OsclError::Leave(int32 aReason) +{ + //log the leave + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, PVLogger::GetLoggerObject("OsclError"), PVLOGMSG_ERR + , (0, "OsclError::Leave! reason %d", aReason)); + + + //set the global leave code if errortrap is installed. + OsclErrorTrapImp *errortrap = OsclErrorTrapImp::GetErrorTrap(); + if (errortrap) + { + OSCL_ASSERT(!errortrap->iLeave);//to avoid infinite recursion + errortrap->iLeave = aReason; + } + + //Process the cleanup stack. + if (errortrap) + errortrap->iTrapStack->Leaving(); + + PVError_DoLeave(); +} + +OSCL_EXPORT_REF void OsclError::LeaveIfNull(OsclAny* p) +{ + if (!p) + Leave(OsclErrNoMemory); +} + +OSCL_EXPORT_REF void OsclError::LeaveIfError(int32 aReason) +{ + if (aReason != OsclErrNone) + Leave(aReason); +} + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error.h new file mode 100644 index 0000000..7dfb2e1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error.h @@ -0,0 +1,401 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E R R O R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_error.h + \brief OSCL Error trap and cleanup include file +*/ + +#ifndef OSCL_ERROR_H_INCLUDED +#define OSCL_ERROR_H_INCLUDED + +#ifndef OSCL_HEAPBASE_H_INCLUDED +#include "oscl_heapbase.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_ERROR_CODES_H_INCLUDED +#include "oscl_error_codes.h" +#endif + +/** +//Per-thread Error trap init. +*/ +class OsclErrorTrapImp; +class OsclErrorTrap +{ + public: + /** + * Allocate and initialize error trap for + * the calling thread. + * @param aAlloc: optional, allocator to use for + * the internal implementation. + * @return 0 for success, or an error + */ + OSCL_IMPORT_REF static int32 Init(Oscl_DefAlloc *aAlloc = NULL); + /** + * Cleanup and destroy error trap for + * the calling thread. + * @return 0 for success, or an error + */ + OSCL_IMPORT_REF static int32 Cleanup(); + /** + * Get the ErrorTrapImp for the current thread. + * Leaves on error. + */ + OSCL_IMPORT_REF static OsclErrorTrapImp* GetErrorTrapImp(); +}; + + +/** +//User Error class +*/ +class OsclError +{ + public: + /** + //Cleanup stack operations. + */ + + /** Push an _OsclHeapBase item onto the cleanup stack. + */ + OSCL_IMPORT_REF static void PushL(_OsclHeapBase * aPtr); + + /** Push an OsclAny item onto the cleanup stack. + */ + OSCL_IMPORT_REF static void PushL(OsclAny* aPtr); + + /** Push an OsclTrapItem onto the cleanup stack + */ + OSCL_IMPORT_REF static void PushL(OsclTrapItem anItem); + + /** Pop the cleanup stack + */ + OSCL_IMPORT_REF static void Pop(); + + /** Pop the cleanup stack N times + */ + OSCL_IMPORT_REF static void Pop(int32 aCount); + + /** Destroy the item on the top of the cleanup + * stack and pop it + */ + OSCL_IMPORT_REF static void PopDealloc(); + + /** PopDealloc N times + */ + OSCL_IMPORT_REF static void PopDealloc(int32 aCount); + + /** Do a Leave error, with the given reason code. + ** When a leave occurs, all items on the cleanup stack + ** for the current trap level will be destroyed, and + ** execution will jump to the trap handler. + */ + OSCL_IMPORT_REF static void Leave(int32 aReason); + + /** Evaluate the input parameter, and if it is null, + ** do a Leave with OsclErrNoMemory reason code. + */ + OSCL_IMPORT_REF static void LeaveIfNull(OsclAny *a); + + /** Evaluate the input parameter, and if it is an + ** error code (non-zero), then do a Leave with the + ** provided reason code. + */ + OSCL_IMPORT_REF static void LeaveIfError(int32 aReason); + +}; + +/** Cleanup Stack user macros +*/ +#define OSCL_TRAPSTACK_PUSH(a) OsclError::PushL(a) +#define OSCL_TRAPSTACK_POP() OsclError::Pop() +#define OSCL_TRAPSTACK_POPDEALLOC() OsclError::PopDealloc() + +/** +* TLS & Singleton registry calls that throw exceptions on errors. +*/ + +//Map TPVBaseErrorEnum return codes to Oscl Error leave codes +//Some of these codes indicate failure to init Oscl layer, in +//that case they map to zero and assert. +static const int32 _OsclBaseToErrorMap[] = +{ + /*0*/OsclErrGeneral + ,/*EPVErrorBaseNotInstalled=1*/0 + ,/*EPVErrorBaseAlreadyInstalled=2*/OsclErrAlreadyInstalled + ,/*EPVErrorBaseOutOfMemory=3*/OsclErrNoMemory + ,/*EPVErrorBaseSystemCallFailed=4*/OsclErrSystemCallFailed + ,/*EPVErrorBaseTooManyThreads=5*/0 + ,/*EPVErrorBaseNotSupported=6*/OsclErrNotSupported + ,/*EPVErrorBaseNotReady=7*/OsclErrNotReady +}; + +#include "oscl_singleton.h" +#include "oscl_assert.h" +#if(OSCL_HAS_SINGLETON_SUPPORT) +class OsclSingletonRegistryEx +{ + public: + /* + ** Get an entry + ** @param ID: identifier + ** @returns: the entry value + ** @exception: leaves on error. + */ + static OsclAny* getInstance(uint32 ID) + { + int32 error; + OsclAny* val = OsclSingletonRegistry::getInstance(ID, error); + if (error) + { + OSCL_ASSERT(_OsclBaseToErrorMap[error]); + OsclError::Leave(_OsclBaseToErrorMap[error]); + } + return val; + } + + /* + ** Set an entry + ** @param ID: identifier + ** @returns: the entry value + ** @exception: leaves on error. + */ + static void registerInstance(OsclAny* ptr, uint32 ID) + { + int32 error; + OsclSingletonRegistry::registerInstance(ptr, ID, error); + if (error) + { + OSCL_ASSERT(_OsclBaseToErrorMap[error]); + OsclError::Leave(_OsclBaseToErrorMap[error]); + } + } + + /* + //These two APIs can be used to do "test and set" operations on a singleton. + //Be sure to always call both APIs to avoid deadlock. + */ + + /* + * Return the current value of the singleton and leave the singleton table locked + * on return. + * @param ID the singleton ID + * @returns the singleton value. + ** @exception: leaves on error. + */ + static OsclAny* lockAndGetInstance(uint32 ID) + { + int32 error; + OsclAny* val = OsclSingletonRegistry::lockAndGetInstance(ID, error); + if (error) + { + OSCL_ASSERT(_OsclBaseToErrorMap[error]); + OsclError::Leave(_OsclBaseToErrorMap[error]); + } + return val; + } + + /* + * Set the value of the singleton. Assume the singleton table is locked on entry. + * @param ptr the singleton value + * @param ID the singleton ID + ** @exception: leaves on error. + */ + static void registerInstanceAndUnlock(OsclAny* ptr, uint32 ID) + { + int32 error; + OsclSingletonRegistry::registerInstanceAndUnlock(ptr, ID, error); + if (error) + { + OSCL_ASSERT(_OsclBaseToErrorMap[error]); + OsclError::Leave(_OsclBaseToErrorMap[error]); + } + } +}; + +template < class T, uint32 ID, class Registry = OsclSingletonRegistryEx > class OsclSingletonEx +{ + private: + // make the copy constructor and assignment operator private + OsclSingletonEx& operator=(OsclSingletonEx& _Y) + { + return(*this); + } + + protected: + T* _Ptr; + + public: + OsclSingletonEx(): _Ptr(OSCL_STATIC_CAST(T*, Registry::getInstance(ID))) {}; + + ~OsclSingletonEx() {}; + + /** + * @brief The indirection operator (*) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclSingleton can be used like the + * regular pointer that it was initialized with. + */ + T& operator*() const + { + return(*_Ptr); + } + + /** + * @brief The indirection operator (->) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclSingleton can be used like the + * regular pointer that it was initialized with. + */ + T *operator->() const + { + return(_Ptr); + } + + + /** + * @brief set() method sets ownership to the pointer, passed. + * This method is needed when the class is created with a default + * constructor. Returns false in case the class is non-empty. + * + */ + bool set() + { + _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID)); + return (_Ptr ? true : false); + } + +}; +#endif //OSCL_HAS_SINGLETON_SUPPORT + +#include "oscl_tls.h" +#include "oscl_assert.h" +class OsclTLSRegistryEx +{ + public: + /* + ** Get an entry + ** @param ID: identifier + ** @returns: the entry value + ** @exception: leaves on error. + */ + static OsclAny* getInstance(uint32 ID) + { + int32 error; + OsclAny* val = OsclTLSRegistry::getInstance(ID, error); + if (error) + { + OSCL_ASSERT(_OsclBaseToErrorMap[error]); + OsclError::Leave(_OsclBaseToErrorMap[error]); + } + return val; + } + /* + ** Set an entry + ** @param ID: identifier + ** @returns: the entry value + ** @exception: leaves on error. + */ + static void registerInstance(OsclAny* ptr, uint32 ID) + { + int32 error; + OsclTLSRegistry::registerInstance(ptr, ID, error); + if (error) + { + OSCL_ASSERT(_OsclBaseToErrorMap[error]); + OsclError::Leave(_OsclBaseToErrorMap[error]); + } + } +}; + +template < class T, uint32 ID, class Registry = OsclTLSRegistryEx > class OsclTLSEx +{ + private: + // make the copy constructor and assignment operator private + OsclTLSEx& operator=(OsclTLSEx& _Y) + { + return(*this); + } + + protected: + T* _Ptr; + + public: + OsclTLSEx(): _Ptr(OSCL_STATIC_CAST(T*, Registry::getInstance(ID))) {}; + + ~OsclTLSEx() {}; + + /** + * @brief The indirection operator (*) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclTLS can be used like the + * regular pointer that it was initialized with. + */ + T& operator*() const + { + return(*_Ptr); + } + + /** + * @brief The indirection operator (->) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OsclTLS can be used like the + * regular pointer that it was initialized with. + */ + T *operator->() const + { + return(_Ptr); + } + + + /** + * @brief set() method sets ownership to the pointer, passed. + * This method is needed when the class is created with a default + * constructor. Returns false in case the class is non-empty. + * + */ + bool set() + { + _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID)); + return (_Ptr ? true : false); + } + +}; + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_allocator.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_allocator.h new file mode 100644 index 0000000..6efc2ad --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_allocator.h @@ -0,0 +1,119 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E R R O R _ A L L O C A T O R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_error_allocator.h + \brief Defines a memory allocation class used by the oscl error layer. +*/ + + +#ifndef OSCL_ERROR_ALLOCATOR_H_INCLUDED +#define OSCL_ERROR_ALLOCATOR_H_INCLUDED + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_BASE_MACROS_H_INCLUDED +#include "oscl_base_macros.h" +#endif + +#ifndef OSCLCONFIG_ERROR_H_INCLUDED +#include "osclconfig_error.h" +#endif + +#ifndef OSCL_ASSERT_H_INCLUDED +#include "oscl_assert.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + + +//! This class provides static methods to invoke the user defined memory allocation routines +/*! +This class must be instantiated before the static methods are called, else asserts will happen +*/ +class OsclErrorAllocator +{ + public: + //! constructor method + /*! + \param allocator - a pointer to the concrete object that provides the allocator/deallocator + */ + OsclErrorAllocator(Oscl_DefAlloc* allocator) + { + iAllocator = allocator; + } + //! static method to allocate a block of memory on heap + /*! + \param aSize - number of bytes to allocate + */ + static OsclAny* allocate(uint32 aSize) + { + OSCL_ASSERT(iAllocator != NULL); + return iAllocator->ALLOCATE(aSize); + } + + //! static method to deallocate a block of memory on heap + /*! + \param aPointer - pointer to block of memory to be deallocated + */ + static OsclAny deallocate(OsclAny* aPointer) + { + OSCL_ASSERT(iAllocator != NULL); + iAllocator->deallocate(aPointer); + } + + //! placement new operator that allocates memory using the user defined methods + void* operator new(uint32 size, OsclAny* aPtr) + { + OSCL_UNUSED_ARG(size); + return aPtr; + } + + //! delete operator that doesn't do anything, user has to deallocate manually + void operator delete(OsclAny* aPtr, OsclAny* aPtr2) + { + OSCL_UNUSED_ARG(aPtr); + OSCL_UNUSED_ARG(aPtr2); + } + + private: + static Oscl_DefAlloc* iAllocator; +}; + + + +#endif //OSCL_ERROR_ALLOCATOR_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_codes.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_codes.h new file mode 100644 index 0000000..f2b58d5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_codes.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E R R O R _ C O D E S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_error_codes.h + \brief Defines basic error and leave codes. +*/ + +#ifndef OSCL_ERROR_CODES_H_INCLUDED +#define OSCL_ERROR_CODES_H_INCLUDED + + +/** Leave Codes +*/ +typedef int32 OsclLeaveCode; + +#define OsclErrNone 0 +#define OsclErrGeneral 100 +#define OsclErrNoMemory 101 +#define OsclErrCancelled 102 +#define OsclErrNotSupported 103 +#define OsclErrArgument 104 +#define OsclErrBadHandle 105 +#define OsclErrAlreadyExists 106 +#define OsclErrBusy 107 +#define OsclErrNotReady 108 +#define OsclErrCorrupt 109 +#define OsclErrTimeout 110 +#define OsclErrOverflow 111 +#define OsclErrUnderflow 112 +#define OsclErrInvalidState 113 +#define OsclErrNoResources 114 +#define OsclErrNotInstalled 115 +#define OsclErrAlreadyInstalled 116 +#define OsclErrSystemCallFailed 117 +#define OsclErrNoHandler 118 +#define OsclErrThreadContextIncorrect 119 + +/** For backward compatibility with old definitions +*/ +#define OSCL_ERR_NONE OsclErrNone +#define OSCL_BAD_ALLOC_EXCEPTION_CODE OsclErrNoMemory + +/** Return Codes +*/ +typedef int32 OsclReturnCode; + +#define OsclSuccess 0 +#define OsclPending 1 +#define OsclFailure -1 + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp.h new file mode 100644 index 0000000..0d26381 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp.h @@ -0,0 +1,75 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E R R O R _ I M P + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_error_imp.h + \brief Internal error implementation support +*/ + +#ifndef OSCL_ERROR_IMP_H_INCLUDED +#define OSCL_ERROR_IMP_H_INCLUDED + +#ifndef OSCLCONFIG_ERROR_H_INCLUDED +#include "osclconfig_error.h" +#endif + +/** Internal leave/trap implementation. +*/ + +//This selects the type of implementation +//based on OSCL capabilities. +#define PVERROR_IMP_JUMPS + + +/* +#define PVERROR_IMP_CPP_EXCEPTIONS +#undef PVERROR_IMP_JUMPS +#undef PVERROR_IMP_FATAL_ERROR +*/ + +/** +//include the internal leave/trap implementation macros. +*/ +#if defined( PVERROR_IMP_JUMPS) +#include "oscl_error_imp_jumps.h" +#elif defined (PVERROR_IMP_CPP_EXCEPTIONS) +#include "oscl_error_imp_cppexceptions.h" +#elif defined(PVERROR_IMP_FATAL_ERROR) +#include "oscl_error_imp_fatalerror.h" +#else +#error No leave implementation! +#endif + + + + +#endif + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_cppexceptions.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_cppexceptions.h new file mode 100644 index 0000000..9573b69 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_cppexceptions.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E R R O R _ I M P _ C P P E X C E P T I O N S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_error_imp_cppexceptions.h + \brief Implementation File for Leave using C++ exceptions. +*/ + +#ifndef OSCL_ERROR_IMP_CPPEXCEPTIONS_H_INCLUDED +#define OSCL_ERROR_IMP_CPPEXCEPTIONS_H_INCLUDED + +#ifndef OSCL_ERROR_TRAPCLEANUP_H_INCLUDED +#include "oscl_error_trapcleanup.h" +#endif + +//Implementation file for Leave using C++ exceptions. + +//This is a full implementation of Leave. + +class internalLeave +{ + public: + int a; +}; + +//Leave throws C++ exceptions. +#define PVError_DoLeave() internalLeave __ilv;__ilv.a=0;throw(__ilv) + + +//_PV_TRAP catches Leaves. +//_r is the leave code, _s are statements to execute +#define _PV_TRAP(__r,__s)\ + __r=OsclErrNone;\ + {\ + OsclErrorTrapImp* __tr=OsclErrorTrapImp::Trap();\ + if(!__tr){__s;}else{\ + try{__s;}\ + catch(internalLeave __lv)\ + {__lv.a=__r=__tr->iLeave;}\ + __tr->UnTrap();}\ + } + +//_PV_TRAP_NO_TLS catches Leaves. +//_r is the leave code, _s are statements to execute +#define _PV_TRAP_NO_TLS(__trapimp,__r,__s)\ + __r=OsclErrNone;\ + {\ + OsclErrorTrapImp* __tr=OsclErrorTrapImp::TrapNoTls(__trapimp);\ + if(!__tr){__s;}else{\ + try{__s;}\ + catch(internalLeave __lv)\ + {__lv.a=__r=__tr->iLeave;}\ + __tr->UnTrap();}\ + } + + +#endif // OSCL_ERROR_IMP_CPPEXCEPTIONS_H_INCLUDED + +/*! @} */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_fatalerror.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_fatalerror.h new file mode 100644 index 0000000..26527a7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_fatalerror.h @@ -0,0 +1,73 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E R R O R _ I M P _ F A T A L E R R O R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_error_imp_fatalerror.h + \brief Implementation File for Leave using system fatal error. +*/ + +#ifndef OSCL_ERROR_IMP_FATALERROR_H_INCLUDED +#define OSCL_ERROR_IMP_FATALERROR_H_INCLUDED + +// Implementation File for Leave using system fatal error. + +//Fatal error implementation for compilers without C++ exceptions. +//This implementation is very limited. Leave conditions +//just cause fatal program errors. There is no way to catch or trap +//any Leave. +#ifndef OSCL_ASSERT_H_INCLUDED +#include "oscl_assert.h" +#endif + +//Leave just calls a system fatal error. +#define PVError_DoLeave() _OSCL_Abort() + +//_PV_TRAP +//_r is leave code, _s is statements. +//this macro isn't really functional since any +//leave will abort the program, but it's needed +//to compile. +#define _PV_TRAP(__r,__s) \ + __r=OsclErrNone;\ + {__s;} + +//_PV_TRAP_NO_TLS +//_r is leave code, _s is statements. +//this macro isn't really functional since any +//leave will abort the program, but it's needed +//to compile. +#define _PV_TRAP_NO_TLS(__tr,__r,__s) \ + __r=OsclErrNone;\ + {__s;} + + + +#endif // OSCL_ERROR_IMP_FATALERROR_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_jumps.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_jumps.cpp new file mode 100644 index 0000000..92ee0c8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_jumps.cpp @@ -0,0 +1,55 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +//Implementation file for OsclJump class, +//for use with the setjmp/longjmp error handler. + +#include "oscl_error_imp.h" + +#ifdef PVERROR_IMP_JUMPS + +#include "oscl_assert.h" + + +//////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF void OsclJump::StaticJump(int jmpcode) +//jump to latest jumpmark +{ + int32 error; + OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap(error); + if (!trap) + { + //Note: you can't leave here, since leave would + //invoke this routine again. It is not safe to return + //either, because calling code is expecting an execution + //end. + OSCL_ASSERT(false); + _OSCL_Abort(); + } + else + { + trap->iJumpData->Jump(jmpcode); + } +} + + +#endif + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_jumps.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_jumps.h new file mode 100644 index 0000000..305d22f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_imp_jumps.h @@ -0,0 +1,167 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E R R O R _ I M P _ J U M P S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_error_imp_jumps.h + \brief Implemenation of using Setjmp / Longjmp. +*/ + +#ifndef OSCL_ERROR_IMP_JUMPS_H_INCLUDED +#define OSCL_ERROR_IMP_JUMPS_H_INCLUDED + +#ifndef OSCL_ERROR_TRAPCLEANUP_H_INCLUDED +#include "oscl_error_trapcleanup.h" +#endif +#ifndef OSCL_ASSERT_H_INCLUDED +#include "oscl_assert.h" +#endif + +// Implemenation of Leave using Setjmp / Longjmp. + +//ANSI setjmp/longjmp implementation. This is needed on any OS +//that does not support C++ exceptions. This is a complete implementation. + +#ifndef OSCLCONFIG_ERROR_H_INCLUDED +#include "osclconfig_error.h" +#endif + +#ifndef OSCL_ERROR_TRAPCLEANUP_H_INCLUDED +#include "oscl_error_trapcleanup.h" +#endif +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif +#ifndef OSCL_ERROR_H_INCLUDED +#include "oscl_error.h" +#endif + +class Oscl_DefAlloc; + +//this defines the maximum depth of the jump mark stack. +#define OSCL_JUMP_MAX_JUMP_MARKS OSCL_MAX_TRAP_LEVELS + + +//OsclJump class +class OsclJump +{ + public: + //for use in macros only. + + OSCL_IMPORT_REF static void StaticJump(int a); + + void Jump(int a) + { + if (!Top()) + { + //Note: you can't leave here, since leave would + //invoke this routine again. It is not safe to return + //either, because calling code is expecting an execution + //end. + OSCL_ASSERT(false); + _OSCL_Abort(); + } + longjmp(*Top(), a); + } + + jmp_buf *Top() + { + OSCL_ASSERT(iJumpIndex >= 0); + return &iJumpArray[iJumpIndex]; + } + + ~OsclJump() + { + //jump mark stack should be empty at this point. + OSCL_ASSERT(iJumpIndex == (-1)); + } + + private: + OsclJump(): iJumpIndex(-1) {} + + void PushMark() + { + OSCL_ASSERT(iJumpIndex < (OSCL_JUMP_MAX_JUMP_MARKS - 1));//jump stack is full! + iJumpIndex++; + } + + void PopMark() + { + OSCL_ASSERT(iJumpIndex >= 0);//jump stack is empty! + iJumpIndex--; + } + + jmp_buf iJumpArray[OSCL_JUMP_MAX_JUMP_MARKS]; + + //index to top of stack, or (-1) when stack is empty + int32 iJumpIndex; + + friend class OsclErrorTrapImp; +}; + + +//internal jump type codes. +#define internalLeave (-1) + +//Leave uses the OsclJump methods +#define PVError_DoLeave() OsclJump::StaticJump(internalLeave) + +//_PV_TRAP macro catches leaves. +//_r is leave code, _s is statements to execute. +#define _PV_TRAP(__r,__s)\ + __r=OsclErrNone;\ + {\ + OsclErrorTrapImp* __trap=OsclErrorTrapImp::Trap();\ + if(!__trap){__s;}else{\ + int __tr=setjmp(*(__trap->iJumpData->Top()));\ + if (__tr==0)\ + {__s;}\ + else if (__tr==internalLeave)\ + {__r=__trap->iLeave;}\ + __trap->UnTrap();}\ + } + +//Same as _PV_TRAP but avoids a TLS lookup. +// __trapimp is the OsclErrorTrapImp* for the calling thread. +#define _PV_TRAP_NO_TLS(__trapimp,__r,__s)\ + __r=OsclErrNone;\ + {\ + OsclErrorTrapImp* __trap=OsclErrorTrapImp::TrapNoTls(__trapimp);\ + if(!__trap){__s;}else{\ + int __tr=setjmp(*(__trap->iJumpData->Top()));\ + if (__tr==0)\ + {__s;}\ + else if (__tr==internalLeave)\ + {__r=__trap->iLeave;}\ + __trap->UnTrap();}\ + } + + +#endif // OSCL_ERROR_IMP_JUMPS_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_trapcleanup.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_trapcleanup.cpp new file mode 100644 index 0000000..c1dc90c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_trapcleanup.cpp @@ -0,0 +1,312 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_error_trapcleanup.h" +#include "oscl_assert.h" +#include "oscl_error_codes.h" + + +OsclErrorTrapImp::OsclErrorTrapImp(Oscl_DefAlloc *alloc, int32 &aError) +{ + aError = 0; + iAlloc = (alloc) ? alloc : &iDefAlloc; +#if defined(PVERROR_IMP_JUMPS) + { + OsclAny* ptr = iAlloc->ALLOCATE(sizeof(OsclJump)); + if (!ptr) + { + iJumpData = NULL; + aError = OsclErrNoMemory; + } + else + { + iJumpData = new(ptr) OsclJump(); + } + } +#endif + OsclAny* ptr = iAlloc->ALLOCATE(sizeof(OsclTrapStack)); + if (!ptr) + { + iTrapStack = NULL; + aError = OsclErrNoMemory; + } + else + { + iTrapStack = new(ptr) OsclTrapStack(iAlloc); + } + iLeave = OsclErrNone; +} + + +OsclErrorTrapImp::~OsclErrorTrapImp() +{ + if (iTrapStack) + { + iTrapStack->~OsclTrapStack(); + iAlloc->deallocate(iTrapStack); + } +#if defined(PVERROR_IMP_JUMPS) + if (iJumpData) + { + iJumpData->~OsclJump(); + iAlloc->deallocate(iJumpData); + } +#endif +} + + +OSCL_EXPORT_REF OsclErrorTrapImp * OsclErrorTrapImp::Trap() +//static function to enter a trap level. +{ + int32 error; + OsclErrorTrapImp *trap = GetErrorTrap(error); + if (!trap) + return NULL;//trap is non-functional. + trap->iLeave = OsclErrNone; + trap->iTrapStack->Trap(); +#if defined(PVERROR_IMP_JUMPS) + trap->iJumpData->PushMark(); +#endif + return trap; +} + +OSCL_EXPORT_REF OsclErrorTrapImp* OsclErrorTrapImp::TrapNoTls(OsclErrorTrapImp* aTrap) +//static function to enter a trap level. the trapimp can be passed in to avoid +//the overhead of a TLS lookup. +{ + //thread context check + int32 error; + OSCL_ASSERT(aTrap == NULL || aTrap == GetErrorTrap(error)); + + OsclErrorTrapImp* trap = (aTrap) ? aTrap : GetErrorTrap(error); + if (!trap) + return NULL;//trap is non-functional. + trap->iLeave = OsclErrNone; + trap->iTrapStack->Trap(); +#if defined(PVERROR_IMP_JUMPS) + trap->iJumpData->PushMark(); +#endif + return trap; +} + +OSCL_EXPORT_REF void OsclErrorTrapImp::UnTrap() +{ + //clear the global leave code + iLeave = 0; + + bool notempty = iTrapStack->UnTrap(); + OSCL_UNUSED_ARG(notempty); + +#if defined(PVERROR_IMP_JUMPS) + iJumpData->PopMark(); +#endif + + OSCL_ASSERT(!notempty);//ETrapLevelNotEmpty +} + +/////////////// +//OsclTrapStack +/////////////// + +inline void OsclTrapStack::Trap() +//enter a trap by marking the current top of the cleanup stack. +{ + if (iTop) + PushTrapL(iTop->iTAny); + else + PushTrapL((OsclAny*)NULL); +} + +inline bool OsclTrapStack::UnTrap() +//leave the current trap by popping the trap stack. +{ + //check for untrap without corresponding trap. + OSCL_ASSERT(TrapTop());//ETrapLevelUnderflow + + //make sure all cleanup items in this level have + //been popped. + bool notempty = (iTop + && iTop->iTAny != TrapTop()->iTAny); + + PopTrap(); + + return notempty; +} + + +OsclTrapStack::OsclTrapStack(Oscl_DefAlloc *alloc) +{ + iTop = NULL; + iTrapTopIndex = (-1); + iAlloc = alloc; +} + +OsclTrapStack::~OsclTrapStack() +{ + //there should not be leftover items at this point + OSCL_ASSERT(!iTop); + OSCL_ASSERT(!TrapTop()); + + //pop all items off the stack so memory gets freed. + while (iTop) + Pop(); + while (TrapTop()) + PopTrap(); +} + +void OsclTrapStack::PushL(_OsclHeapBase *aCBase) +//Push a CBase item onto the cleanup stack +{ + //Note: on Symbian you get a panic for doing + //a push outside any TRAP statement, so generate an + //error here also. + OSCL_ASSERT(TrapTop());//ETrapPushAtLevelZero + + OsclAny* ptr = iAlloc->ALLOCATE(sizeof(OsclTrapStackItem)); + OsclError::LeaveIfNull(ptr); + OsclTrapStackItem * item = new(ptr) OsclTrapStackItem(aCBase); + Push(item); +} + +void OsclTrapStack::PushL(OsclAny *aTAny) +//Push a nonOsclTrapStackCBase item onto the cleanup stack +{ + //Note: on Symbian you get a panic for doing + //a push outside any TRAP statement, so generate an + //error here also. + OSCL_ASSERT(TrapTop());//ETrapPushAtLevelZero + + OsclAny* ptr = iAlloc->ALLOCATE(sizeof(OsclTrapStackItem)); + OsclError::LeaveIfNull(ptr); + OsclTrapStackItem *item = new(ptr) OsclTrapStackItem(aTAny); + Push(item); +} + +inline void OsclTrapStack::PushTrapL(OsclAny *aTAny) +//Push a nonOsclTrapStackCBase item onto the trap mark stack +{ + pushTrapIndex(); + //construct this item using the stack top element memory + new((OsclAny*)TrapTop()) OsclTrapStackItem(aTAny); +} + +void OsclTrapStack::PushL(OsclTrapItem anItem) +{ + //Note: on Symbian you get a panic for doing + //a push outside any TRAP statement, so generate an + //error here also. + OSCL_ASSERT(TrapTop());//ETrapPushAtLevelZero + + OsclAny* ptr = iAlloc->ALLOCATE(sizeof(OsclTrapStackItem)); + OsclError::LeaveIfNull(ptr); + OsclTrapStackItem *item = new(ptr) OsclTrapStackItem(anItem); + Push(item); +} + +void OsclTrapStack::Push(OsclTrapStackItem *aItem) +//push the given item onto the stack. +{ + if (aItem) + { + aItem->iNext = iTop; + iTop = aItem; + } +} + +void OsclTrapStack::Pop() +//pop the stack. +{ + if (!iTop) + OsclError::Leave(OsclErrUnderflow);//ETrapPopUnderflow + + //check for a pop beyond the current trap level + if (TrapTop() && iTop->iTAny == TrapTop()->iTAny) + OsclError::Leave(OsclErrUnderflow);//ETrapPopAcrossLevels + + OsclTrapStackItem *next = iTop->iNext; + iTop->~OsclTrapStackItem(); + iAlloc->deallocate(iTop); + iTop = next; +} + +inline void OsclTrapStack::PopTrap() +//pop the trap mark stack. +{ + OSCL_ASSERT(TrapTop());//ETrapPopUnderflow + + //call destructor on the item in-place + TrapTop()->~OsclTrapStackItem(); + + popTrapIndex(); +} + +void OsclTrapStack::Pop(int32 aCount) +{ + OSCL_ASSERT(aCount >= 0);//ETrapPopCountNegative + for (int i = 0; i < aCount; i++) + Pop(); +} + +void OsclTrapStack::PopDealloc() +{ + if (!iTop) + OsclError::Leave(OsclErrUnderflow);//ETrapPopUnderflow; + + if (TrapTop() && iTop->iTAny == TrapTop()->iTAny) + OsclError::Leave(OsclErrUnderflow);//ETrapPopAcrossLevels; + + if (iTop->iCBase) + { + //CBase destructor will be called. + //Note: we assume the delete operator is + //defined in the CBase-derived class. If not, + //we won't get correct memory mgmt here. + delete(iTop->iCBase); + } + else if (iTop->iTrapOperation) + { + //user-supplied cleanup + (iTop->iTrapOperation)(iTop->iTAny); + } + else if (iTop->iTAny) + { + //no destructor, just free memory. + iAlloc->deallocate(iTop->iTAny); + } + Pop(); +} + +void OsclTrapStack::PopDealloc(int32 aCount) +{ + for (int i = 0; i < aCount; i++) + PopDealloc(); +} + +void OsclTrapStack::Leaving() +//a leave is happening, so cleanup all items on the stack +//for the current trap level. +{ + //check for a leave outside any trap. + OSCL_ASSERT(TrapTop());//ETrapLevelUnderflow + + while (iTop && iTop->iTAny != TrapTop()->iTAny) + PopDealloc(); +} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_trapcleanup.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_trapcleanup.h new file mode 100644 index 0000000..0a15664 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_error_trapcleanup.h @@ -0,0 +1,278 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E R R O R _ T R A P C L E A N U P + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_error_trapcleanup.h + \brief OSCL Error trap and cleanup implementation include file +*/ + +#ifndef OSCL_ERROR_TRAPCLEANUP_H_INCLUDED +#define OSCL_ERROR_TRAPCLEANUP_H_INCLUDED + +#ifndef OSCLCONFIG_ERROR_H_INCLUDED +#include "osclconfig_error.h" +#endif + + + +#ifndef OSCL_HEAPBASE_H_INCLUDED +#include "oscl_heapbase.h" +#endif + +#define OSCL_MAX_TRAP_LEVELS 20 + +/** +//Internal cleanup stack item type. +*/ +class OsclTrapStackItem +{ + public: + OsclTrapStackItem() {} + OsclTrapStackItem(_OsclHeapBase *aCBase) + { + iCBase = aCBase; + iTAny = (OsclAny*)aCBase; + iTrapOperation = NULL; + iNext = NULL; + } + OsclTrapStackItem(OsclAny *aTAny) + { + iCBase = NULL; + iTAny = aTAny; + iTrapOperation = NULL; + iNext = NULL; + } + OsclTrapStackItem(OsclTrapItem aItem) + { + iCBase = NULL; + iTAny = aItem.iPtr; + iTrapOperation = aItem.iOperation; + iNext = NULL; + } + _OsclHeapBase *iCBase; + OsclAny *iTAny; + OsclTrapOperation iTrapOperation; + OsclTrapStackItem *iNext; +}; + +class OsclJump; + +#ifndef OSCL_ERROR_IMP_H_INCLUDED +#include "oscl_error_imp.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_ASSERT_H_INCLUDED +#include "oscl_assert.h" +#endif + +#ifndef OSCL_ERROR_H_INCLUDED +#include "oscl_error.h" +#endif + +/** +//A common type for cleanup stack and trap mark stack. +//for internal use only. +*/ +class OsclTrapStack +{ + private: + OsclTrapStack(Oscl_DefAlloc *iAlloc); + ~OsclTrapStack(); + + //Trap APIs + inline void Trap(); + inline bool UnTrap(); + + //Cleanup stack APIs + void PushL(_OsclHeapBase *aCBase); + void PushL(OsclAny *aTAny); + void PushL(OsclTrapItem anItem); + void Push(OsclTrapStackItem *aItem); + void Pop(); + void Pop(int32 aCount); + void PopDealloc(); + void PopDealloc(int32 aCount); + void Leaving(); + + //top of cleanup stack + OsclTrapStackItem *iTop; + + //cleanup stack allocator. + Oscl_DefAlloc *iAlloc; + + friend class OsclError; + friend class OsclErrorTrap; + friend class OsclErrorTrapImp; + + private: + //The trap mark stack is a stack used to mark the top of the cleanup stack + //for each trap level. + + inline void PushTrapL(OsclAny *aTAny); + inline void PopTrap(); + + //top of trap mark stack + OsclTrapStackItem *TrapTop() + { + if (iTrapTopIndex >= 0) + return &iTrapTopArray[iTrapTopIndex]; + return NULL; + } + + OsclTrapStackItem iTrapTopArray[OSCL_MAX_TRAP_LEVELS]; + + //index to top of stack, or (-1) when stack is empty + int32 iTrapTopIndex; + + void pushTrapIndex() + { + OSCL_ASSERT(iTrapTopIndex < (OSCL_MAX_TRAP_LEVELS - 1));//stack overflow + iTrapTopIndex++; + } + + void popTrapIndex() + { + OSCL_ASSERT(iTrapTopIndex >= 0);//stack underflow + iTrapTopIndex--; + } +}; + + + +#ifndef OSCL_BASE_ALLOC_H_INCLUDED +#include "oscl_base_alloc.h" +#endif + +//For non-symbian, the error trap stack must be in a global registry. +// +//Use TLS registry unless it's not available, then +//use singleton. +//Note: singleton-based registry only works for single-threaded +//scenarios because this implementation assumes a per-thread registry. +#include "oscl_tls.h" +#include "oscl_singleton.h" +#define PVERRORTRAP_REGISTRY_ID OSCL_TLS_ID_PVERRORTRAP +#define PVERRORTRAP_REGISTRY OsclTLSRegistry + + +/** +//A per-thread cleanup stack with nested trap support. +*/ +class OsclErrorTrapImp +{ + public: + /** + //these are used in public macros, but + //aren't intended as public methods or members. + */ + OSCL_IMPORT_REF void UnTrap(); +#if defined(PVERROR_IMP_JUMPS) + OsclJump *iJumpData; +#endif + + //Global leave info. + int32 iLeave; + + public: + /** + //PV trap cleanup. Public for use in macros only. + */ + OSCL_IMPORT_REF static OsclErrorTrapImp* Trap(); + //This version of Trap is identical to the above, except it avoids the TLS lookup. + OSCL_IMPORT_REF static OsclErrorTrapImp* TrapNoTls(OsclErrorTrapImp*); + OsclTrapStack *iTrapStack; + + private: + OsclErrorTrapImp(Oscl_DefAlloc *aAlloc, int32 &error); + ~OsclErrorTrapImp(); + Oscl_DefAlloc *iAlloc; + + static OsclErrorTrapImp* GetErrorTrap(int32& aError) + //static function to get currently installed error trap + //for this thread. + { + OsclErrorTrapImp *current = (OsclErrorTrapImp*)PVERRORTRAP_REGISTRY::getInstance(PVERRORTRAP_REGISTRY_ID, aError); + return current; + } + static OsclErrorTrapImp* GetErrorTrap() + //static function to get currently installed error trap + //for this thread. returns NULL on error. + { + int32 error; + OsclErrorTrapImp* current = GetErrorTrap(error); + if (error) + return NULL; + return current; + } + + static OsclErrorTrapImp* SetErrorTrap(OsclErrorTrapImp* a, int32& aError) + //static function to set currently installed error trap + //for this thread. return previous error trap, if any. + { + OsclErrorTrapImp* temp = GetErrorTrap(aError); + PVERRORTRAP_REGISTRY::registerInstance(a, PVERRORTRAP_REGISTRY_ID, aError); + return temp; + } + + //Global cleanup function for OsclAny items. + static void TrapOperation(OsclAny *ptr) + { + int32 error; + OsclErrorTrapImp *trap = GetErrorTrap(error); + if (trap && trap->iAlloc) + trap->iAlloc->deallocate(ptr); + else + { + _OsclBasicAllocator alloc; + alloc.deallocate(ptr); + } + } + + //default allocators. + _OsclBasicAllocator iDefAlloc; + + friend class OsclErrorTrap; + friend class OsclError; + friend class OsclExecScheduler; + friend class OsclExecSchedulerCommonBase; + friend class OsclJump; + friend class OsclJumpMark; + friend class OsclTrapStack; + friend class CPVInterfaceProxy; + friend class OsclScheduler; +}; + + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_exception.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_exception.h new file mode 100644 index 0000000..1479689 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_exception.h @@ -0,0 +1,155 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ E X C E P T I O N + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_exception.h + \brief contains all the exception handling macros and classes +*/ + + +#ifndef OSCL_EXCEPTION_H_INCLUDED +#define OSCL_EXCEPTION_H_INCLUDED + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#ifndef OSCL_ERROR_H_INCLUDED +#include "oscl_error.h" +#endif + +#ifndef OSCL_ERROR_IMP_H_INCLUDED +#include "oscl_error_imp.h" +#endif + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +//! oscl_exception.h contains all the exception handling macros and classes + + +//! This template class provides the base exception class that all exceptions derive from +/*! + All PacketVideo exception classes will be derived from the OsclException class. + Each derived class will have a static function where the leave code + can be obtained. This avoids the issue of having static members in a DLL. + The function needs to be static so it can be called without an instance + of the class +*/ +template class OsclException +{ + public: + OsclException() {} + static int getLeaveCode() + { + return LeaveCode; + }; +}; + + +//! Use this macro to cause a Leave. It terminates the execution of the current active function +/*! + It also tries to cleanup the items on the cleanup stack. + \param oscl_leave_status tells the cause for the Leave +*/ +#define OSCL_LEAVE(_leave_status) OsclError::Leave(_leave_status) + + +//! This macro will be used to set up a try block +/*! + The try block identifies a block of code that might throw exceptions + (or leave) + \param oscl_leave_status oscl_leave_status will receive the result of any + OSCL_LEAVE (which will get called from a OSCL_THROW) on systems that do not + support exception handling.This is unused on systems that do support + exception handling + \param statements is a statement or block of statements that could throw + exceptions and will be executed in the try block +*/ +#define OSCL_TRY(_leave_status,_statements) _PV_TRAP(_leave_status,_statements) +//Same as above, but avoids the TLS lookup. +// param __trampimp is the OsclErrorTrapImp* for the current thread. +#define OSCL_TRY_NO_TLS(__trapimp,_leave_status,_statements) _PV_TRAP_NO_TLS(__trapimp,_leave_status,_statements) + +//! This section defines the macros to be used in the catch block following the try block + +//! Use this macro to call a function that handles all exception types thrown in the preceding try block +/*! + \param _leave_status + \param _statements is a statement or block of statements that will + catch all the exception types thrown by the preceding try block + This is a standalone macro and should not be used with any of the macros above +*/ +#define OSCL_FIRST_CATCH_ANY(_leave_status, _statements) \ + if (_leave_status!=OsclErrNone) { _statements; } + +//! Use this macro to define a block of code that catches the first exception type thrown in the preceding try block +/*! + \param oscl_leave_status is the leave code that was returned by OSCL_THROW + \param exceptiontype is the exception handled by this catch block + This macro MUST be used in conjunction with either OSCL_LAST_CATCH or OSCL_CATCH_ANY +*/ +#define OSCL_FIRST_CATCH( _leave_status, _catch_value, _statements) \ + if (_leave_status!=OsclErrNone && _leave_status == _catch_value){_statements;} + +//! Use this macro to define a block of code for catching additional exception types +/*! + OSCL_FIRST_CATCH can be used to catch one exception type. Then the + OSCL_CATCH macro can be used to catch each subsequent type. The catch + block must end with OSCL_LAST_CATCH or OSCL_CATCH_ANY + \param oscl_leave_status is the result of any OSCL_THROW + \param exceptiontype is the exception handled by this catch block +*/ +#define OSCL_CATCH( _leave_status, _catch_value, _statements) \ + else if (_leave_status!=OsclErrNone && _leave_status == _catch_value){_statements;} + +//! Use this macro to call a function that will catch all remaining exception types +/*! + \param _leave_status + \param _statements is a statement or block of statements to + handle all remaining exception types. + This macro ends the try block. +*/ +#define OSCL_CATCH_ANY(_leave_status,_statements) \ + else if (_leave_status!=OsclErrNone){ _statements;} + +//! Use this macro if OSCL_CATCH_ANY has not been used. It will mark the end of the catch block +/*! + \param _leave_status will be propagated up the call stack + This macro will do an OSCL_LEAVE if the leave has not been handled by the calls above. + This macro ends the try block. +*/ + +#define OSCL_LAST_CATCH(_leave_status) \ + else if (_leave_status!=OsclErrNone){OSCL_LEAVE(_leave_status);} + + +#endif // INCLUDED_OSCL_EXCEPTION_H + + + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_heapbase.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_heapbase.cpp new file mode 100644 index 0000000..cd7cafc --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_heapbase.cpp @@ -0,0 +1,26 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "osclconfig.h" +#include "oscl_heapbase.h" + +#if (OSCL_DISABLE_INLINES) +#include "oscl_heapbase.inl" +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_heapbase.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_heapbase.h new file mode 100644 index 0000000..1c3223e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_heapbase.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ H E A P B A S E + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_heapbase.h + \brief OSCL Heap Base include file +*/ +#ifndef OSCL_HEAPBASE_H_INCLUDED +#define OSCL_HEAPBASE_H_INCLUDED + +#ifndef OSCLCONFIG_ERROR_H_INCLUDED +#include "osclconfig_error.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +/** +//_OsclHeapBase is used as the base for cleanup stack +//items with virtual destructor. +*/ + + +class _OsclHeapBase +{ + public: + virtual ~_OsclHeapBase() {} + + protected: + _OsclHeapBase() {} + _OsclHeapBase(const _OsclHeapBase&) {} + private: + _OsclHeapBase& operator=(const _OsclHeapBase&); + friend class PVCleanupStack; +}; + +/** +//OsclTrapItem may be used in the cleanup stack when +//a custom cleanup operation is needed. +*/ + +typedef void (*OsclTrapOperation)(OsclAny*); + +class OsclTrapItem +{ + public: + OSCL_INLINE OsclTrapItem(OsclTrapOperation anOperation); + OSCL_INLINE OsclTrapItem(OsclTrapOperation anOperation, OsclAny* aPtr); + private: + OsclTrapOperation iOperation; + OsclAny* iPtr; + friend class OsclTrapStackItem; + friend class OsclTrapStack; +}; + + + +#if !(OSCL_DISABLE_INLINES) +#include "oscl_heapbase.inl" +#endif + +#endif // + + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_heapbase.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_heapbase.inl new file mode 100644 index 0000000..b00af4f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_heapbase.inl @@ -0,0 +1,30 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/** \file oscl_heapbase.inl + \brief OSCL Heap Base inline file +*/ + +OSCL_INLINE OsclTrapItem::OsclTrapItem(OsclTrapOperation anOperation) + : iOperation(anOperation) +{} +OSCL_INLINE OsclTrapItem::OsclTrapItem(OsclTrapOperation anOperation, OsclAny *aPtr) + : iOperation(anOperation), iPtr(aPtr) +{} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_mem_align.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_mem_align.inl new file mode 100644 index 0000000..de767a7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_mem_align.inl @@ -0,0 +1,39 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_mem_align.h" +// Basic memory manipulation functions +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + + +OSCL_INLINE OSCL_COND_EXPORT_REF uint oscl_mem_aligned_size(uint x) +{ + uint y; + + if (x & 0x7) + { + y = x & (~0x7); + y += 8; + } + else + { + y = x; + } + + return y; +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_namestring.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_namestring.h new file mode 100644 index 0000000..2b2fe71 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclerror/src/oscl_namestring.h @@ -0,0 +1,110 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ N A M E S T R I N G + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclerror OSCL Error + * + * @{ + */ + + +/** \file oscl_namestring.h + \brief Name string class include file. +*/ + +#ifndef OSCL_NAMESTRING_H_INCLUDED +#define OSCL_NAMESTRING_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +/** +// Name string class appropriate for passing +// short constant ASCII strings around. +// All strings are automatically truncated +// and null-terminated. +*/ +template +class OsclNameString +{ + public: + OsclNameString() + { + Set(""); + } + + OsclNameString(const char a[]) + { + Set((uint8*)a); + } + + OsclNameString(uint8* a) + { + Set(a); + } + + /** + * Set the string to the input value. The string + * will be truncated to fit the storage class and + * automatically null-terminated. + * + * @param a (input param): null-terminated character + * string. + */ + void Set(uint8* a) + { + for (int i = 0; i < __len; i++) + iStr[i] = '\0'; + if (a) + { + for (int i = 0; i < __len - 1; i++) + { + iStr[i] = a[i]; + if (a[i] == '\0') + return; + } + } + } + + void Set(const char a[]) + { + Set((uint8*)a); + } + + uint8* Str()const + { + return (uint8*)&iStr[0]; + } + + int32 MaxLen()const + { + return __len; + } + + private: + uint8 iStr[__len]; +}; +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/Android.mk new file mode 100644 index 0000000..ebde742 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/Android.mk @@ -0,0 +1,74 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/oscl_dns.cpp \ + src/oscl_dns_gethostbyname.cpp \ + src/oscl_dns_imp_base.cpp \ + src/oscl_dns_imp_pv.cpp \ + src/oscl_dns_method.cpp \ + src/oscl_dns_param.cpp \ + src/oscl_dns_request.cpp \ + src/oscl_file_async_read.cpp \ + src/oscl_file_cache.cpp \ + src/oscl_file_dir_utils.cpp \ + src/oscl_file_find.cpp \ + src/oscl_file_io.cpp \ + src/oscl_file_native.cpp \ + src/oscl_file_server.cpp \ + src/oscl_file_stats.cpp \ + src/oscl_file_manager.cpp \ + src/oscl_ip_socket.cpp \ + src/oscl_socket.cpp \ + src/oscl_socket_accept.cpp \ + src/oscl_socket_bind.cpp \ + src/oscl_socket_connect.cpp \ + src/oscl_socket_imp_base.cpp \ + src/oscl_socket_imp_pv.cpp \ + src/oscl_socket_imp_serv.cpp \ + src/oscl_socket_listen.cpp \ + src/oscl_socket_method.cpp \ + src/oscl_socket_recv.cpp \ + src/oscl_socket_recv_from.cpp \ + src/oscl_socket_request.cpp \ + src/oscl_socket_send.cpp \ + src/oscl_socket_send_to.cpp \ + src/oscl_socket_serv_imp_pv.cpp \ + src/oscl_socket_serv_imp_reqlist.cpp \ + src/oscl_socket_shutdown.cpp \ + src/oscl_socket_stats.cpp \ + src/oscl_tcp_socket.cpp \ + src/oscl_udp_socket.cpp + + +LOCAL_MODULE := libosclio + +LOCAL_CFLAGS := $(PV_CFLAGS) + + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/oscl/oscl/osclio/src \ + $(PV_TOP)/oscl/oscl/osclio/src \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + src/oscl_file_dir_utils.h \ + src/oscl_file_find.h \ + src/oscl_file_handle.h \ + src/oscl_file_io.h \ + src/oscl_file_manager.h \ + src/oscl_file_cache.h \ + src/oscl_file_server.h \ + src/oscl_socket.h \ + src/oscl_socket_types.h \ + src/oscl_dns.h \ + src/oscl_file_types.h \ + src/oscl_file_native.h + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/build/make/local.mk new file mode 100644 index 0000000..800f492 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/build/make/local.mk @@ -0,0 +1,66 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + +TARGET := osclio + + +SRCDIR := ../../src +INCSRCDIR := ../../src + +# compose final src list for actual build +SRCS := oscl_dns.cpp \ + oscl_dns_gethostbyname.cpp \ + oscl_dns_imp_base.cpp \ + oscl_dns_imp_pv.cpp \ + oscl_dns_method.cpp \ + oscl_dns_param.cpp \ + oscl_dns_request.cpp \ + oscl_file_async_read.cpp \ + oscl_file_cache.cpp \ + oscl_file_dir_utils.cpp \ + oscl_file_find.cpp \ + oscl_file_io.cpp \ + oscl_file_native.cpp \ + oscl_file_server.cpp \ + oscl_file_stats.cpp \ + oscl_file_manager.cpp \ + oscl_ip_socket.cpp \ + oscl_socket.cpp \ + oscl_socket_accept.cpp \ + oscl_socket_bind.cpp \ + oscl_socket_connect.cpp \ + oscl_socket_imp_base.cpp \ + oscl_socket_imp_pv.cpp \ + oscl_socket_imp_serv.cpp \ + oscl_socket_listen.cpp \ + oscl_socket_method.cpp \ + oscl_socket_recv.cpp \ + oscl_socket_recv_from.cpp \ + oscl_socket_request.cpp \ + oscl_socket_send.cpp \ + oscl_socket_send_to.cpp \ + oscl_socket_serv_imp_pv.cpp \ + oscl_socket_serv_imp_reqlist.cpp \ + oscl_socket_shutdown.cpp \ + oscl_socket_stats.cpp \ + oscl_tcp_socket.cpp \ + oscl_udp_socket.cpp + + +HDRS := oscl_file_dir_utils.h \ + oscl_file_find.h \ + oscl_file_handle.h \ + oscl_file_io.h \ + oscl_file_manager.h \ + oscl_file_cache.h \ + oscl_file_server.h \ + oscl_socket.h \ + oscl_socket_types.h \ + oscl_dns.h \ + oscl_file_types.h \ + oscl_file_native.h + +include $(MK)/library.mk diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns.cpp new file mode 100644 index 0000000..429fcac --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns.cpp @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_dns.h" +#include "oscl_error.h" +#include "oscl_exception.h" +#include "oscl_dns_gethostbyname.h" +#include "oscl_dns_imp.h" + +OSCL_EXPORT_REF OsclDNS* OsclDNS::NewL( + Oscl_DefAlloc &alloc, + OsclSocketServ& serv, + OsclDNSObserver& obs, + uint32 id) +{ + OsclAny *p = alloc.ALLOCATE(sizeof(OsclDNS)); + OsclError::LeaveIfNull(p); + OsclDNS *self = OSCL_PLACEMENT_NEW(p, OsclDNS(alloc, obs, id)); + OsclError::PushL(self); + self->ConstructL(serv); + OsclError::Pop(); + return self; +} + +OsclDNS::OsclDNS( + Oscl_DefAlloc &alloc, + OsclDNSObserver & obs, + uint32 id) + : iGetHostByNameMethod(NULL) + , iAlloc(alloc) + , iObserver(obs) + , iId(id) + , iDNS(NULL) +{ +} + +void OsclDNS::ConstructL(OsclSocketServ &aServ) +{ + iDNS = OsclDNSI::NewL(iAlloc); + if (iDNS->Open(*aServ.iServ) != OsclErrNone) + OsclError::Leave(OsclErrGeneral); + iGetHostByNameMethod = OsclGetHostByNameMethod::NewL(iAlloc, iDNS, &iObserver, iId); +} + + +OSCL_EXPORT_REF OsclDNS::~OsclDNS() +{ + if (iGetHostByNameMethod) + { + iGetHostByNameMethod->AbortAll(); + iGetHostByNameMethod->~OsclGetHostByNameMethod(); + iAlloc.deallocate(iGetHostByNameMethod); + } + if (iDNS) + { + iDNS->~OsclDNSI(); + iAlloc.deallocate(iDNS); + } +} + +OSCL_EXPORT_REF TPVDNSEvent OsclDNS::GetHostByName(char *name, OsclNetworkAddress &addr, + int32 aTimeoutMsec, Oscl_Vector* aAddressList) +{ + return iGetHostByNameMethod->GetHostByName(name, &addr, aTimeoutMsec, aAddressList); +} + +OSCL_EXPORT_REF void OsclDNS::CancelGetHostByName() +{ + iGetHostByNameMethod->CancelMethod(); +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns.h new file mode 100644 index 0000000..9e5b6de --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns.h @@ -0,0 +1,171 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ D N S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_dns.h + \brief The file oscl_socket.h defines the OSCL DNS APIs. + +*/ +#ifndef OSCL_DNS_H_INCLUDED +#define OSCL_DNS_H_INCLUDED + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#include "osclconfig_io.h" +#endif + +#ifndef OSCL_SOCKET_TYPES_H_INCLUDED +#include "oscl_socket_types.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_SOCKET_H_INCLUDED +#include "oscl_socket.h" +#endif + +enum TPVDNSFxn +{ + EPVDNSGetHostByName +} ; + +enum TPVDNSEvent +{ + EPVDNSSuccess + , EPVDNSPending + , EPVDNSTimeout + , EPVDNSFailure + , EPVDNSCancel +} ; + +/** +* DNS event observer. The client implements this to get +* asynchronous command completion. +*/ +class OsclDNSObserver +{ + public: + /** + * DNS Event callback. + * + * @param aId: The ID that was supplied when + * the DNS object was created. + * @param aEvent: Function completion event. Will be + * EPVDNSSuccess, EPVDNSTimeout, or EPVDNSFailure. + * @param aError: When the event is EPVDNSFailure, this + * may contain a platform-specific error code, or zero if + * none is available. + */ + OSCL_IMPORT_REF virtual void HandleDNSEvent(int32 aId, TPVDNSFxn aFxn, TPVDNSEvent aEvent, int32 aError) = 0; + + virtual ~OsclDNSObserver() {} +}; + +class OsclGetHostByNameMethod; +class OsclDNSI; + +/** +* The DNS class +*/ +class OsclDNS: public HeapBase +{ + public: + /** + * DNS object creation. + * + * @param alloc: Memory allocator + * @param aServ: Socket server. + * @param aObserver: DNS Event observer + * @param aId: Unique ID for this DNS object. This ID + * will be included in all callbacks associated with + * this DNS object. + */ + OSCL_IMPORT_REF static OsclDNS* NewL( + Oscl_DefAlloc &alloc, + OsclSocketServ& aServ, + OsclDNSObserver & aObserver, + uint32 aId); + + /** + * Destructor. + * + * Note: the application must de-allocate the DNS object + * using the same allocator that was passed in the + * NewL object creation call. + */ + OSCL_IMPORT_REF ~OsclDNS(); + + /** + * GetHostByName. + * This is an asynchronous method. + * + * @param name: Null-terminated string containing the host + * name. + * @param addr: The output address corresponding to the host. + * The ipAddr field will contain the network address of the + * host in dotted decimal notation. + * @param aTimeoutMsec: A timeout for the request in milliseconds, + * or (-1) to indicate infinite wait. + * @param aAddressList : A list of addresses for the host. + * @returns: EPVDNSPending for success, EPVDNSFailure for failure. + */ + OSCL_IMPORT_REF TPVDNSEvent GetHostByName(char *name, OsclNetworkAddress& addr, + int32 aTimeoutMsec = -1, Oscl_Vector* aAddressList = NULL); + + /** + * Cancel GetHostByName + * + * This method will cancel any pending GetHostByName operation + * on the current object, causing the GetHostByName to complete + * with error EPVDNSCancel. If there is no pending + * GetHostByName operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelGetHostByName(); + + private: + OsclDNS( + Oscl_DefAlloc &alloc, + OsclDNSObserver& obs, + uint32 id); + void ConstructL(OsclSocketServ &aServ); + + OsclGetHostByNameMethod* iGetHostByNameMethod; + Oscl_DefAlloc& iAlloc; + OsclDNSObserver& iObserver; + uint32 iId; + OsclDNSI *iDNS; + friend class OsclDNSRequestAO; + +}; + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_gethostbyname.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_gethostbyname.cpp new file mode 100644 index 0000000..342617b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_gethostbyname.cpp @@ -0,0 +1,175 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_scheduler_ao.h" +#include "oscl_dns_gethostbyname.h" +#include "oscl_dns_imp.h" +#include "osclconfig_io.h" +#include "oscl_dns_request.h" +#include "oscl_dns_param.h" + +//////////// Method ///////////////////// + +OsclGetHostByNameMethod *OsclGetHostByNameMethod::NewL(Oscl_DefAlloc &a, + OsclDNSI *aDNS, + OsclDNSObserver *aObserver, + uint32 aId) +{ + OsclAny*p = a.ALLOCATE(sizeof(OsclGetHostByNameMethod)); + OsclError::LeaveIfNull(p); + OsclGetHostByNameMethod* self = OSCL_PLACEMENT_NEW(p, OsclGetHostByNameMethod(a)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(aDNS, aObserver, aId); + OsclError::Pop(); + return self; +} + +void OsclGetHostByNameMethod::ConstructL( + OsclDNSI *aDNS, + OsclDNSObserver *aObserver, + uint32 aId) +{ + iGetHostByNameRequest = OsclGetHostByNameRequest::NewL(aDNS, this); + OsclDNSMethod::ConstructL(aObserver, iGetHostByNameRequest, aId); +} + +OsclGetHostByNameMethod::~OsclGetHostByNameMethod() +{ + if (iGetHostByNameRequest) + { + iGetHostByNameRequest->~OsclGetHostByNameRequest(); + iAlloc.deallocate(iGetHostByNameRequest); + } +} + +TPVDNSEvent OsclGetHostByNameMethod::GetHostByName(char *name, OsclNetworkAddress *addr, + int32 aTimeout, Oscl_Vector * aAddressList) +{ + if (!StartMethod(aTimeout)) + return EPVDNSFailure; + + iGetHostByNameRequest->GetHostByName(name, addr, aAddressList); + + return EPVDNSPending; +} + +//////////// AO ///////////////////// + +OsclGetHostByNameRequest *OsclGetHostByNameRequest::NewL( + OsclDNSI *aDNS, + OsclGetHostByNameMethod *aMethod) +{ + OsclAny*p = aMethod->iAlloc.ALLOCATE(sizeof(OsclGetHostByNameRequest)); + OsclError::LeaveIfNull(p); + OsclGetHostByNameRequest* self = OSCL_PLACEMENT_NEW(p, OsclGetHostByNameRequest()); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(aDNS, aMethod); + OsclError::Pop(); + return self; +} + +OsclGetHostByNameRequest::~OsclGetHostByNameRequest() +{ + if (iParam) + iParam->RemoveRef(); + iParam = NULL; +} + +void OsclGetHostByNameRequest::GetHostByName(char *name, OsclNetworkAddress *addr, Oscl_Vector *aAddressList) +{ + NewRequest(); + + if (iParam) + iParam->RemoveRef(); + iParam = NULL; + + if (!name || !addr) + { + PendComplete(OsclErrGeneral); + return; + } + + iParam = GetHostByNameParam::Create(name, addr, aAddressList); + if (!iParam) + PendComplete(OsclErrNoMemory); + else + iDNSI->GetHostByName(*iParam, *this); +} + +void OsclGetHostByNameRequest::Success() +{ + switch (iRequestPhase) + { + case GetFirstHostAddress: + { + iDNSI->GetHostByNameSuccess(*iParam); + if (!iDNSI->GetHostByNameResponseContainsAliasInfo() && iParam->canPersistMoreHostAddresses()) + { + iRequestPhase = GetAlternateHostAddress; + NewRequest(); + iDNSI->GetNextHost(*this); + } + else + { + iDNSMethod->iDNSObserver->HandleDNSEvent(iDNSMethod->iId, iDNSMethod->iDNSFxn, EPVDNSSuccess, 0); + } + } + break; + case GetAlternateHostAddress: + { + iDNSI->GetNextHostSuccess(*iParam); + NewRequest(); + iDNSI->GetNextHost(*this); + } + break; + } +} + +void OsclGetHostByNameRequest::Failure() +{ + switch (iRequestPhase) + { + case GetFirstHostAddress: + { + iDNSMethod->iDNSObserver->HandleDNSEvent(iDNSMethod->iId, iDNSMethod->iDNSFxn, EPVDNSFailure, GetSocketError()); + } + break; + case GetAlternateHostAddress: + { + iDNSMethod->iDNSObserver->HandleDNSEvent(iDNSMethod->iId, iDNSMethod->iDNSFxn, EPVDNSSuccess, 0); + iRequestPhase = GetFirstHostAddress; + } + break; + } +} + +void OsclGetHostByNameRequest::Cancelled() +{ + switch (iRequestPhase) + { + case GetFirstHostAddress: + case GetAlternateHostAddress: + { + iDNSMethod->iDNSObserver->HandleDNSEvent(iDNSMethod->iId, iDNSMethod->iDNSFxn, EPVDNSCancel, 0); + iRequestPhase = GetFirstHostAddress; + } + break; + } +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_gethostbyname.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_gethostbyname.h new file mode 100644 index 0000000..bb626dd --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_gethostbyname.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_DNS_GETHOSTBYNAME_H_INCLUDED +#define OSCL_DNS_GETHOSTBYNAME_H_INCLUDED + +//#include "oscl_socket_serv_imp.h" +#include "oscl_dns_method.h" +#include "oscl_dns.h" +#include "osclconfig_io.h" + + +class OsclGetHostByNameRequest; + +class OsclGetHostByNameMethod : public OsclDNSMethod +{ + public: + static OsclGetHostByNameMethod *NewL(Oscl_DefAlloc &a, + OsclDNSI *aDNS, + OsclDNSObserver *aObserver, + uint32 aId); + + ~OsclGetHostByNameMethod(); + + TPVDNSEvent GetHostByName(char *name, OsclNetworkAddress *addr, + int32 aTimeout, Oscl_Vector * aAddressList); + + + private: + OsclGetHostByNameMethod(Oscl_DefAlloc &a) + : OsclDNSMethod(a, "osclghbnmethod", EPVDNSGetHostByName) + , iGetHostByNameRequest(NULL) + {} + + void ConstructL(OsclDNSI* aDNS, + OsclDNSObserver *aObserver, + uint32 aId); + + OsclGetHostByNameRequest *iGetHostByNameRequest; +}; + +class GetHostByNameParam; + +class OsclGetHostByNameRequest : public OsclDNSRequestAO +{ + private: + static OsclGetHostByNameRequest *NewL( + OsclDNSI *aDNS, + OsclGetHostByNameMethod *aMethod); + + ~OsclGetHostByNameRequest(); + + + OsclGetHostByNameRequest() + : OsclDNSRequestAO("osclghbnrequest") + , iParam(NULL) + , iRequestPhase(GetFirstHostAddress) + {} + + void ConstructL(OsclDNSI *aDNS, + OsclGetHostByNameMethod *aMethod) + { + OsclDNSRequestAO::ConstructL(aDNS, aMethod); + } + + virtual void Success(); + virtual void Failure(); + virtual void Cancelled(); + + void GetHostByName(char *name, OsclNetworkAddress *addr, Oscl_Vector *aAddressList); + + GetHostByNameParam *iParam; + enum GetHostByNameRequestPhase + { + GetFirstHostAddress, + GetAlternateHostAddress + }; + + GetHostByNameRequestPhase iRequestPhase; + friend class OsclGetHostByNameMethod; + +}; + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp.h new file mode 100644 index 0000000..138b7e8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp.h @@ -0,0 +1,37 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#ifndef OSCL_DNS_IMP_H_INCLUDED +#define OSCL_DNS_IMP_H_INCLUDED +/*! +** A common include file for OsclDNSI declaration +*/ + +#include "oscl_dns_tuneables.h" +#if PV_DNS_SERVER +#include "oscl_dns_imp_pv.h" +#else +#error No Implementation! +#endif + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_base.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_base.cpp new file mode 100644 index 0000000..184baed --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_base.cpp @@ -0,0 +1,61 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! +** DNS server base class implementation +*/ + +#include "osclconfig_io.h" +#include "oscl_scheduler_ao.h" +#include "oscl_dns_imp_base.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_error.h" +#include "oscl_assert.h" +#include "oscl_dns_method.h" + +//Common section... + +OsclDNSIBase::OsclDNSIBase(Oscl_DefAlloc &a) : iAlloc(a) +{ + iSocketServ = NULL; +} + +OsclDNSIBase::~OsclDNSIBase() +{ +} + +void OsclDNSIBase::CancelFxn(TPVDNSFxn aFxn) +{ + switch (aFxn) + { + case EPVDNSGetHostByName: + CancelGetHostByName(); + break; + default: + OSCL_ASSERT(false); + break; + } +} + + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_base.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_base.h new file mode 100644 index 0000000..093b394 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_base.h @@ -0,0 +1,72 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#ifndef OSCL_DNS_IMP_BASE_H_INCLUDED +#define OSCL_DNS_IMP_BASE_H_INCLUDED + +#include "oscl_socket_imp.h" +#include "oscl_dns_request.h" +#include "oscl_dns.h" + +class OsclSocketServI; +class GetHostByNameParam; +class OsclDNSRequestAO; + +/*! +** OsclDNSIBase is a common base class for all +** implementations. +*/ +class OsclDNSIBase +{ + public: + virtual ~OsclDNSIBase(); + + //synchronous methods + virtual int32 Open(OsclSocketServI& aServer) = 0; + virtual int32 Close() = 0; + + //asynchronous methods. + + virtual void GetHostByName(GetHostByNameParam& , OsclDNSRequestAO&) = 0; + virtual void GetHostByNameSuccess(GetHostByNameParam&) = 0; + virtual bool GetHostByNameResponseContainsAliasInfo() = 0; + virtual void GetNextHost(OsclDNSRequestAO&) = 0; + virtual void GetNextHostSuccess(GetHostByNameParam&) = 0; + void CancelFxn(TPVDNSFxn); + + protected: + OsclDNSIBase(Oscl_DefAlloc &a); + + Oscl_DefAlloc &iAlloc; + + virtual bool IsReady(OsclDNSRequestAO& aObject) = 0; + + virtual void CancelGetHostByName() = 0; + + //link to socket server. + OsclSocketServI *iSocketServ; + + friend class OsclDNSRequest; + friend class OsclGetHostByNameRequest; +}; + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_pv.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_pv.cpp new file mode 100644 index 0000000..2e9bb9f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_pv.cpp @@ -0,0 +1,180 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/*! +** PV DNS server implementation +*/ + +#include "oscl_dns_tuneables.h" +#if (PV_DNS_SERVER) +#include "oscl_scheduler_ao.h" +#include "oscl_dns_imp_pv.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_error.h" +#include "oscl_assert.h" +#include "oscl_dns_method.h" +#include "oscl_dns_param.h" + +OsclDNSI::OsclDNSI(Oscl_DefAlloc &a) : OsclDNSIBase(a) +{ +} + +OsclDNSI::~OsclDNSI() +{ + Close(); +} + +OsclDNSI* OsclDNSI::NewL(Oscl_DefAlloc &a) +{ + OsclAny*p = a.ALLOCATE(sizeof(OsclDNSI)); + OsclError::LeaveIfNull(p); + OsclDNSI *self = OSCL_PLACEMENT_NEW(p, OsclDNSI(a)); + OsclError::LeaveIfNull(self); + return self; +} + + + +int32 OsclDNSI::Close() +{ + + //nothing needed + return 0; + +} + +void OsclDNSI::GetHostByName(GetHostByNameParam &aParam, OsclDNSRequestAO &ao) +{ + if (!IsReady(ao)) + return; + + iGetHostByNameRequest.Activate(&aParam, ao); + +} + +void OsclDNSI::GetHostByNameSuccess(GetHostByNameParam &aParam) +{ + //Nothing needed. + OSCL_UNUSED_ARG(aParam); +} + +void OsclDNSI::GetNextHost(OsclDNSRequestAO& ao) +{ + OSCL_UNUSED_ARG(ao); +} + +void OsclDNSI::GetNextHostSuccess(GetHostByNameParam &aParam) +{ + OSCL_UNUSED_ARG(aParam); +} +void OsclDNSI::CancelGetHostByName() +{ + iGetHostByNameRequest.CancelRequest(); +} + +int32 OsclDNSI::Open(OsclSocketServI& aServer) +{ + iSocketServ = &aServer; + + + //nothing needed + return 0; + +} + +bool OsclDNSI::IsReady(OsclDNSRequestAO &ao) +//see if server is ready to handle dns requests. +{ + //Make sure server is ok. + //Note: we only really need the server active + //for Symbian, but to make the DNS calling protocol + //consistent, require an active server on all + //platforms. + if (!iSocketServ) + { + //use the pv server err code + ao.iSocketError = PVSOCK_ERR_SOCK_NO_SERV; + ao.PendComplete(OSCL_REQUEST_ERR_GENERAL); + return false; + } + if (!iSocketServ->IsServConnected()) + { + //report the error from the server, if any. + ao.iSocketError = iSocketServ->iServError; + //use the pv server err code + if (ao.iSocketError == 0) + ao.iSocketError = PVSOCK_ERR_SERV_NOT_CONNECTED; + ao.PendComplete(OSCL_REQUEST_ERR_GENERAL); + return false; + } + return true; +} +bool OsclDNSI::GetHostByNameResponseContainsAliasInfo() +{ + return true; +} + +void OsclDNSI::ProcessDnsRequest(GetHostByNameParam* aParam, int32& aComplete, int32& aSockerr) +//called under server thread or AO. +//This routine must not access any object memory outside of aParam. +{ + aComplete = OSCL_REQUEST_ERR_GENERAL; + aSockerr = 0; + +#if defined(OsclGethostbyname) && defined(OsclGetDottedAddr) + + //make the platform-specific gethostbyname call... + TOsclHostent *hostent; + bool ok; + int sockerr = 0; + + //this call blocks + OsclGethostbyname(aParam->iName, hostent, ok, sockerr); + + if (!ok) + { + aSockerr = sockerr; + } + else + { + //convert to dotted address notation + //char *dottedaddr; + //OsclGetDottedAddr(hostent, dottedaddr, ok); + OsclGetDottedAddrVector(hostent, aParam->iAddr, aParam->iAddressList, ok); + if (ok) + { + // aParam->iAddr->ipAddr.Set(dottedaddr); + aComplete = OSCL_REQUEST_ERR_NONE; + aSockerr = sockerr; + } + else + { + aSockerr = sockerr; + } + } +#endif +} + +#endif //OS switch + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_pv.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_pv.h new file mode 100644 index 0000000..d618850 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_imp_pv.h @@ -0,0 +1,70 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#ifndef OSCL_DNS_IMP_PV_H_INCLUDED +#define OSCL_DNS_IMP_PV_H_INCLUDED + +#include "oscl_socket_imp_base.h" +#include "oscl_dns_request.h" +#include "oscl_dns_imp_base.h" + +class OsclSocketServI; + +/*! +** OsclDNSI, non-Symbian implementation +*/ +class OsclDNSI: public OsclDNSIBase +{ + public: + static OsclDNSI* NewL(Oscl_DefAlloc &a); + ~OsclDNSI(); + + //synchronous methods + int32 Open(OsclSocketServI& aServer); + int32 Close(); + + //asynchronous methods. + + void GetHostByName(GetHostByNameParam& , OsclDNSRequestAO&); + void GetHostByNameSuccess(GetHostByNameParam&); + void GetNextHost(OsclDNSRequestAO&); + void GetNextHostSuccess(GetHostByNameParam&); + bool GetHostByNameResponseContainsAliasInfo(); + + private: + OsclDNSI(Oscl_DefAlloc &a); + + bool IsReady(OsclDNSRequestAO& aObject); + + void CancelGetHostByName(); + + friend class OsclDNSRequest; + + //active requests + OsclDNSRequest iGetHostByNameRequest; + static void ProcessDnsRequest(GetHostByNameParam*, int32&, int32&); + friend class OsclGetHostByNameRequest; + + friend class DNSRequestParam; +}; + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_method.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_method.cpp new file mode 100644 index 0000000..31b05b2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_method.cpp @@ -0,0 +1,164 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "osclconfig_io.h" +#include "oscl_scheduler_ao.h" +#include "oscl_dns_method.h" +#include "oscl_dns.h" +#include "oscl_socket_imp.h" +#include "oscl_dns_imp.h" + +#define LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_DEBUG,m); + +static const char* const TPVDNSFxnStr[] = +{ + "EPVDNSGetHostByName" +} ; + +static const char* const TPVDNSEventStr[] = +{ + "EPVDNSSuccess" + , "EPVDNSPending" + , "EPVDNSTimeout" + , "EPVDNSFailure" + , "EPVDNSCancel" +} ; + +//////////// Request AO ////////////////////// +void OsclDNSRequestAO::NewRequest() +{ + AddToScheduler(); + PendForExec(); + LOGINFOMED((0, "OsclSocket: New Request %s", TPVDNSFxnStr[iDNSMethod->iDNSFxn])); +} + +void OsclDNSRequestAO::RequestDone() +{ + iDNSMethod->Abort(); + RemoveFromScheduler(); +} + +int OsclDNSRequestAO::GetSocketError() +{ +#if PV_DNS_SERVER + + //Errors from PV socket server are in + //iSocketError. + return iSocketError; +#else + +#error No Implementation! + +#endif +} + +void OsclDNSRequestAO::DoCancel() +{ + iDNSI->CancelFxn(iDNSMethod->iDNSFxn); +} + +void OsclDNSRequestAO::Run() +{ + //the request was completed. + RequestDone(); + switch (Status()) + { + case OSCL_REQUEST_ERR_NONE: + LOGINFOMED((0, "OsclSocket: %s %s", TPVDNSFxnStr[iDNSMethod->iDNSFxn], TPVDNSEventStr[EPVDNSSuccess])); + Success(); + break; + case OSCL_REQUEST_ERR_CANCEL: + LOGINFOMED((0, "OsclSocket: %s %s", TPVDNSFxnStr[iDNSMethod->iDNSFxn], TPVDNSEventStr[EPVDNSCancel])); + Cancelled(); + break; + default: + LOGINFOMED((0, "OsclSocket: %s %s %d", TPVDNSFxnStr[iDNSMethod->iDNSFxn], TPVDNSEventStr[EPVDNSCancel], GetSocketError())); + Failure(); + break; + } +} + +//////////// Method ////////////////////// + +void OsclDNSMethod::ConstructL( + OsclDNSObserver*aObserver, + OsclDNSRequestAO *aAO, + uint32 aId) +{ + if (!aAO) + OsclError::Leave(OsclErrGeneral); + iDNSRequestAO = aAO; + iDNSObserver = aObserver; + iId = aId; +} + +void OsclDNSMethod::Abort() +{ + Cancel(); + RemoveFromScheduler(); +} + +void OsclDNSMethod::AbortAll() +{ + Abort(); + if (iDNSRequestAO) + iDNSRequestAO->Abort(); +} + +bool OsclDNSMethod::StartMethod(int32 aTimeoutMsec) +{ + //make sure there's not already a request + //in progress + if (IsAdded() || iDNSRequestAO->IsAdded()) + return false; + + AddToScheduler(); + //iDNSRequestAO->AddToScheduler(); + + //set the timeout + if (aTimeoutMsec > 0) + After(aTimeoutMsec*1000); + + iDNSRequestAO->iSocketError = 0; + + return true; +} + +void OsclDNSMethod::MethodDone() +{ + iDNSRequestAO->Abort(); + RemoveFromScheduler(); +} + +void OsclDNSMethod::CancelMethod() +{ + //cancel the timeout if any + Abort(); + //cancel the request. + iDNSRequestAO->iDNSI->CancelFxn(iDNSFxn); +} + +void OsclDNSMethod::Run() +{ + //the request timed out! + MethodDone(); + LOGINFOMED((0, "OsclSocket: %s %s", TPVDNSFxnStr[iDNSFxn], TPVDNSEventStr[EPVDNSTimeout])); + iDNSObserver->HandleDNSEvent(iId, iDNSFxn, EPVDNSTimeout, 0); +} + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_method.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_method.h new file mode 100644 index 0000000..6380e80 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_method.h @@ -0,0 +1,131 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_DNS_METHOD_H_INCLUDED +#define OSCL_DNS_METHOD_H_INCLUDED + +#include "osclconfig_io.h" +#include "oscl_socket_types.h" +#include "oscl_scheduler_ao.h" +#include "oscl_dns.h" +#include "pvlogger.h" + +class OsclDNSObserver; +class OsclDNSRequestAO; +class OsclSocketServ; +class OsclDNSI; +class OsclDNS; + +/** This is the base class for all socket methods. +* It provides the timeout on socket requests. +*/ +class OsclDNSMethod : public OsclTimerObject +{ + public: + OsclDNSMethod(Oscl_DefAlloc &a, const char *name, TPVDNSFxn fxn) + : OsclTimerObject(OsclActiveObject::EPriorityNominal, name) + , iDNSObserver(NULL) + , iId(0) + , iAlloc(a) + , iDNSFxn(fxn) + , iDNSRequestAO(NULL) + { + iLogger = PVLogger::GetLoggerObject("oscldns"); + } + + void Abort(); + void AbortAll(); + void CancelMethod(); + void Run(); + + OsclDNSObserver *iDNSObserver; + uint32 iId; + Oscl_DefAlloc &iAlloc; + TPVDNSFxn iDNSFxn; + PVLogger* iLogger; + + protected: + void ConstructL( + OsclDNSObserver*aObserver, + OsclDNSRequestAO *aAO, + uint32 aId); + + bool StartMethod(int32 aTimeoutMsec); + void MethodDone(); + + OsclDNSRequestAO *iDNSRequestAO; +}; + + +/** This is the base class for all requests to the +* socket server. +*/ +class OsclDNSRequestAO : public OsclActiveObject +{ + protected: + + OsclDNSRequestAO(const char *name) + : OsclActiveObject(OsclActiveObject::EPriorityNominal, name) + , iDNSI(NULL) + , iDNSMethod(NULL) + , iSocketError(0) + { + } + + void ConstructL( + OsclDNSI *aDNS, + OsclDNSMethod *aMethod) + { + if (!aMethod) + OsclError::Leave(OsclErrGeneral); + iDNSMethod = aMethod; + iLogger = iDNSMethod->iLogger; + if (!aDNS) + OsclError::Leave(OsclErrGeneral); + iDNSI = aDNS; + } + + void Abort() + { + Cancel(); + RemoveFromScheduler(); + } + void NewRequest(); + void RequestDone(); + int GetSocketError(); + OsclSocketServI *Serv(); + void DoCancel(); + void Run(); + + virtual void Success() {} + virtual void Failure() {} + virtual void Cancelled() {} + + OsclDNSI *iDNSI; + OsclDNSMethod *iDNSMethod; + int32 iSocketError; + PVLogger* iLogger; + + friend class OsclDNSI; + friend class OsclDNSMethod; + friend class OsclDNSRequest; + friend class GetHostByNameParam; +}; + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_param.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_param.cpp new file mode 100644 index 0000000..fc79475 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_param.cpp @@ -0,0 +1,160 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_dns_tuneables.h" + +#include "oscl_dns_param.h" +#include "oscl_scheduler_ao.h" +#include "oscl_dns_request.h" +#include "oscl_assert.h" +#include "oscl_error.h" +#include "oscl_dns_method.h" +#include "oscl_dns_imp.h" +#include "pvlogger.h" + + +//Remove ref from either thread. +void DNSRequestParam::RemoveRef() +{ + uint32 count; +#if(PV_DNS_IS_THREAD) + iLock.Lock(); +#endif + count = --iRefCount; +#if(PV_DNS_IS_THREAD) + iLock.Unlock(); +#endif + if (count == 0) + Destroy(); +} + +DNSRequestParam::DNSRequestParam(TPVDNSFxn aFxn) + : iFxn(aFxn) + , iDNSRequest(NULL) +#if (PV_DNS_IS_THREAD) + , iThreadKillFlag(false) +#endif +{ +#if (PV_DNS_IS_THREAD) + iLock.Create(); + iStartup.Create(); +#endif + iRefCount = 1; +} + +#if(PV_DNS_SERVER) +void DNSRequestParam::InThread() +//Called under get host by name request thread or under caller's API. +{ + //Add a ref to this object + iRefCount++; + +#if (PV_DNS_IS_THREAD) + //Signal that thread startup is complete. + //Note: A "kill" could occur at any time after this point so + //it's important not to access any memory outside of + //this class from now on. + iStartup.Signal(); +#endif + + int32 complete; + int32 dnserr; + + OSCL_ASSERT(iFxn == EPVDNSGetHostByName); + + //this call blocks + OsclDNSI::ProcessDnsRequest((GetHostByNameParam*)this, complete, dnserr); + +#if(PV_DNS_IS_THREAD) + + //Check for kill flag. If so, then the request was completed by + //app thread. In that case this thread just exits gracefully + //without reporting completion to the original caller which may no longer + //exist. + + iLock.Lock(); + + bool kill = iThreadKillFlag; + + if (!kill) + iDNSRequest->Complete(true, complete, dnserr); + + iLock.Unlock(); + +#else + iDNSRequest->Complete(true, complete, dnserr); +#endif + + //Remove the ref to this object. + RemoveRef(); + +} +#endif + +GetHostByNameParam* GetHostByNameParam::Create(const char *name, + OsclNetworkAddress* &addr, Oscl_Vector* aAddressList) +{ + Oscl_TAlloc alloc; + GetHostByNameParam* self = alloc.allocate(1); + if (self) + OSCL_PLACEMENT_NEW(self, GetHostByNameParam(name, addr, aAddressList)); + return self; +} + +void GetHostByNameParam::Destroy() +{ + Oscl_TAlloc alloc; + alloc.destruct_and_dealloc(this); +} + +GetHostByNameParam::~GetHostByNameParam() +{ + TDNSRequestParamAllocator alloc; + alloc.deallocate(iName); + iName = NULL; +} + +GetHostByNameParam::GetHostByNameParam(const char *name, + OsclNetworkAddress* &addr, + Oscl_Vector* aAddressList) + : DNSRequestParam(EPVDNSGetHostByName) + , iName(NULL) + , iAddr(addr) + , iAddressList(aAddressList) +{ + uint32 size = oscl_strlen(name); + TDNSRequestParamAllocator alloc; + iName = (char*)alloc.allocate(size + 8); + OsclError::LeaveIfNull(iName); + oscl_strncpy(iName, name, (size + 1)); + + iAddr->ipAddr.Set(""); + if (iAddressList) + { + iAddressList->clear(); + iAddressList->reserve(addressListCapacity); + } +} + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_param.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_param.h new file mode 100644 index 0000000..d2d54f6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_param.h @@ -0,0 +1,136 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_DNS_PARAM_H_INCLUDED +#define OSCL_DNS_PARAM_H_INCLUDED + +#include "oscl_socket_types.h" +#include "oscl_dns_tuneables.h" +#include "oscl_namestring.h" +#include "oscl_dns.h" +#include "oscl_mutex.h" +#include "oscl_semaphore.h" + +class OsclDNSRequestAO; +class OsclDNSRequest; + +#if(PV_DNS_IS_THREAD) +/* +** Only the _OsclBasicAllocator is used in order to +** avoid the need to init memory manager in the DNS thread. +*/ +typedef _OsclBasicAllocator TDNSRequestParamAllocator; +#else +typedef OsclMemAllocator TDNSRequestParamAllocator; +#endif + +/* +** Base class for all DNS method parameter sets +** A thread-safe, reference-counted parameter set. +** A reference count is used since the data may need +** to persist after the request is canceled while still +** waiting on some blocking OS-level operation to complete. +*/ +class DNSRequestParam +{ + public: + + virtual ~DNSRequestParam() + { +#if(PV_DNS_IS_THREAD) + iLock.Close(); + iStartup.Close(); +#endif + } + + void RemoveRef(); + +#if(PV_DNS_SERVER) + void InThread(); +#endif + + virtual void Destroy() = 0; + + TPVDNSFxn iFxn; + OsclDNSRequest *iDNSRequest; + +#if(PV_DNS_IS_THREAD) + bool iThreadKillFlag; + OsclMutex iLock; + OsclSemaphore iStartup; +#endif + + + protected: + + DNSRequestParam(TPVDNSFxn aFxn); + + uint32 iRefCount; +}; + + +/* +** Parameters for GetHostByName request +*/ +class GetHostByNameParam: public DNSRequestParam +{ + public: + + //Use this routine to create, use DNSRequestParam::RemoveRef when finished. + static GetHostByNameParam* Create(const char *name, OsclNetworkAddress* &addr, Oscl_Vector* aAddressList); + + //from DNSRequestParam + void Destroy(); + + ~GetHostByNameParam(); + + void PersistHostAddress(const OsclNetworkAddress& addr) + { + if (iAddressList && (iAddressList->size() < iAddressList->capacity())) + { + iAddressList->push_back(addr); + } + + if (0 == oscl_strcmp(OSCL_STATIC_CAST(const char*, iAddr->ipAddr.Str()), "")) + iAddr->ipAddr.Set(addr.ipAddr.Str()); + } + + bool canPersistMoreHostAddresses() + { + return (iAddressList && (iAddressList->size() < iAddressList->capacity())) || (0 == oscl_strcmp(OSCL_STATIC_CAST(const char*, iAddr->ipAddr.Str()), "")); + } + + //request params. + char *iName; + OsclNetworkAddress *iAddr; + Oscl_Vector *iAddressList; + enum + { + addressListCapacity = 10 + }; + + private: + + GetHostByNameParam(const char *name, OsclNetworkAddress* &addr, Oscl_Vector* aAddressList); + + +} ; + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_request.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_request.cpp new file mode 100644 index 0000000..7234129 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_request.cpp @@ -0,0 +1,130 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_dns_tuneables.h" +#if PV_DNS_SERVER +//PV DNS Server implementation + +#include "oscl_scheduler_ao.h" +#include "oscl_dns_request.h" +#include "oscl_assert.h" +#include "oscl_error.h" +#include "oscl_dns_method.h" +#include "oscl_dns_imp.h" +#include "pvlogger.h" +#include "oscl_dns_param.h" + + +void OsclDNSRequest::CancelRequest() +//cancel an active request +{ + Complete(false, OSCL_REQUEST_ERR_CANCEL, 0); +} + +void OsclDNSRequest::Complete(bool reqthread, int32 aStatus, int32 aSockErr) +//called by either request thread or app thread +//when dns request is complete. +{ + if (iActive) + { + //de-activate this request + iActive = false; + iDNSRequestAO->iSocketError = aSockErr; + +#if(PV_DNS_IS_THREAD) + if (!reqthread + && iDNSRequestParam) + { + //This call is from app thread. + //Set the "kill" flag for the thread before + //completing the request. Setting kill thread + //will prevent any callback from the thread. + iDNSRequestParam->iLock.Lock(); + iDNSRequestParam->iThreadKillFlag = true; + iDNSRequestAO->PendComplete(aStatus); + iDNSRequestParam->iLock.Unlock(); + return; + } +#endif + iDNSRequestAO->PendComplete(aStatus); + } +} + +void OsclDNSRequest::Activate(DNSRequestParam* p, OsclDNSRequestAO &a) +//activate a dns request +{ + //make sure we don't have multiple requests... + //calling logic should prevent this, but just in case. + if (iActive) + a.PendComplete(OSCL_REQUEST_ERR_GENERAL); + + p->iDNSRequest = this; + iDNSRequestAO = &a; + iDNSRequestParam = p; + iActive = true; + +#if(PV_DNS_IS_THREAD) + //launch the thread. + OsclThread thread; + OsclProcStatus::eOsclProcError err = thread.Create( + (TOsclThreadFuncPtr)ThreadFunc, + 1024, + (TOsclThreadFuncArg)p); + if (err == OsclProcStatus::SUCCESS_ERROR) + { + //Wait on the thread to start + p->iStartup.Wait(); + } + else + { + iDNSRequestAO->PendComplete(OSCL_REQUEST_ERR_GENERAL); + } + //the request is completed under the DNS thread. + +#else + //non-threaded implementation. + //call the thread routine directly-- this call blocks. + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, a.iLogger, PVLOGMSG_NOTICE, (0, "PVOSCLIO:OsclDNSRequest:Issuing blocking call to DNS...")); + ((DNSRequestParam*)p)->InThread(); + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, a.iLogger, PVLOGMSG_NOTICE, (0, "PVOSCLIO:OsclDNSRequest:...request complete")); +#endif +} + + +#if PV_DNS_IS_THREAD + +TOsclThreadFuncRet OSCL_THREAD_DECL OsclDNSRequest::ThreadFunc(TOsclThreadFuncArg arg) +//generic dns request thread. +{ + //call the request-specific thread routine. + if (arg) + ((DNSRequestParam*)arg)->InThread(); + + OSCL_UNUSED_RETURN(0); // Exit doesn't return +} + +#endif //PV_DNS_IS_THREAD + +#endif //PV_DNS_SERVER + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_request.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_request.h new file mode 100644 index 0000000..a03bdbe --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_request.h @@ -0,0 +1,71 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_DNS_REQUEST_H_INCLUDED +#define OSCL_DNS_REQUEST_H_INCLUDED + +#include "oscl_dns_tuneables.h" +#if PV_DNS_SERVER + +#include "oscl_namestring.h" +#include "oscl_dns.h" +#include "oscl_socket_types.h" +#include "oscl_dns_tuneables.h" + +#if PV_DNS_IS_THREAD +#include "oscl_thread.h" +#include "oscl_mutex.h" +#endif + +class DNSRequestParam; +class OsclDNSRequestAO; + +/** This class defines the interface to the dns +implementation threads. +*/ +class OsclDNSRequest +{ + public: + OsclDNSRequest() + : iDNSRequestAO(NULL) + , iDNSRequestParam(NULL) + , iActive(false) + { + } + ~OsclDNSRequest() + { + } + + OsclDNSRequestAO *iDNSRequestAO;//the AO that is waiting on completion. + DNSRequestParam *iDNSRequestParam; + bool iActive; + +#if PV_DNS_IS_THREAD + static TOsclThreadFuncRet OSCL_THREAD_DECL ThreadFunc(TOsclThreadFuncArg arg); +#endif + + void CancelRequest(); + void Complete(bool, int32 aStatus, int32 aSockErr); + void Activate(DNSRequestParam *iParam, OsclDNSRequestAO &a); +}; + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_tuneables.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_tuneables.h new file mode 100644 index 0000000..b65f502 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_dns_tuneables.h @@ -0,0 +1,61 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_DNS_TUNEABLES_H_INCLUDED +#define OSCL_DNS_TUNEABLES_H_INCLUDED + + +/*! +** This file contains default definitions of all the +** the tuning parameters for the Oscl DNS. +*/ + +/*! +** If parameters are defined in osclconfig_io.h, those definitions +** will take precedence over the ones in this file. +*/ +#include "osclconfig_io.h" +#include "osclconfig_proc.h" + +/*! +** Enable/disable the PV DNS server here. +*/ +#ifndef PV_DNS_SERVER +#define PV_DNS_SERVER 1 +#endif + +#if(PV_DNS_SERVER) + +/*! +** PV_DNS_IS_THREAD chooses either the threaded or AO-based +** implementation of the PV DNS request. Note: AO-based +** option is not good here, since some DNS requests will +** block the caller until completion. +*/ +#if !defined PV_DNS_IS_THREAD +#define PV_DNS_IS_THREAD OSCL_HAS_THREAD_SUPPORT +#endif + +//for test-- to force AO implementation +//#undef PV_DNS_IS_THREAD +//#define PV_DNS_IS_THREAD 0 + + +#endif//PV_DNS_SERVER +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_async_read.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_async_read.cpp new file mode 100644 index 0000000..3ac3e03 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_async_read.cpp @@ -0,0 +1,1204 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +* ============================================================================= +* Name : oscl_file_async_read.cpp +* Part of : +* Interface : +* Description : +* Version : +* ============================================================================= +*/ + + + +#include "oscl_file_async_read.h" +#include "oscl_file_handle.h" +#include "pvlogger.h" +#include "oscl_file_native.h" + +//When set, this code will create a duplicate file handle and +//verify every single API call against results from that handle. +//Great for debugging. +//Make sure this is 0 in checked-in code! +#define VERIFY_THIS 0 + +// ================== Class OsclAsyncFileBuffer ===================================== // + +OsclAsyncFileBuffer* OsclAsyncFileBuffer::NewL(int32 aBufferSize, int32 aId) +{ + OsclAsyncFileBuffer* self = OSCL_NEW(OsclAsyncFileBuffer, (aBufferSize, aId)); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +OsclAsyncFileBuffer::OsclAsyncFileBuffer(int32 aBufferSize, int32 aId) : + iBufferSize(aBufferSize), iId(aId) +{ + iBuffer = NULL; + iOffset = 0; + iInUse = false; + iLength = 0; + iValid = false; +} + +OsclAsyncFileBuffer::~OsclAsyncFileBuffer() +{ + if (iBuffer) + OsclBuf::Delete(iBuffer); +} + +void OsclAsyncFileBuffer::ConstructL() +{ + iBuffer = OsclBuf::NewL(iBufferSize); +} + +void OsclAsyncFileBuffer::UpdateData() +{ + iValid = true; + iLength = iBuffer->Length(); +} + +OsclBuf* OsclAsyncFileBuffer::Buffer() +{ + return iBuffer; +} + +bool OsclAsyncFileBuffer::HasThisOffset(TOsclFileOffset aOffset) +{ + if (!iValid) + return false; + if ((aOffset >= iOffset) && (aOffset <= iOffset + iLength - 1)) + return true; + return false; +} + + +// ================== Class OsclAsyncFile ===================================== // + +OsclAsyncFile* OsclAsyncFile::NewL(OsclNativeFile& aFile, int32 aCacheSize, PVLogger* aLogger) +{ + OsclAsyncFile* self = OSCL_NEW(OsclAsyncFile, (aFile, aCacheSize, aLogger)); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclAsyncFile::Delete(OsclAsyncFile*a) +{ + if (a) + OSCL_DELETE(a); +} + +OsclAsyncFile::~OsclAsyncFile() +{ + //Stop the tread, cancel any requests for Run() + //and remove AO from the scheduler + + StopAsyncReadThread(); + + Cancel(); + RemoveFromScheduler(); + + if (iNativeFileDuplicate) + { + OSCL_DELETE(iNativeFileDuplicate); + } + + for (uint32 i = 0; i < iDataBufferArray.size(); i++) + OSCL_DELETE(iDataBufferArray[i]); + + iDataBufferArray.clear(); + iSortedDataBufferArray.clear(); + iLinkedDataBufferArray.clear(); + OSCL_DELETE(iDataBuffer); + +} + + +OsclAsyncFile::OsclAsyncFile(OsclNativeFile& aFile, int32 aCacheSize, PVLogger* aLogger) + : OsclActiveObject(OsclActiveObject::EPriorityHighest, "OsclAsyncFile"), + iNativeFile(aFile), + iNativeFileDuplicate(NULL), + iTotalCacheSize(aCacheSize), + iStartAsyncRead(false), + iReadPtrDummyLen(0), + iReadPtr(0, iReadPtrDummyLen, 0) +{ + iLogger = aLogger; + + iNumOfRun = 0; + iNumOfRunErr = 0; + iHasNativeAsyncRead = iNativeFile.HasAsyncRead(); + + // Init thread state tracking variable(s) + if (iHasNativeAsyncRead) + { + /* For native async read set the thread state to active + * since this is logically equivalent to the read thread + * already running for the non-native implementation. Some + * of the shared logic in this class uses this state variable + * so it needs to be set properly for the native async case also. + */ + iAsyncReadThreadState = EAsyncReadActive; + } + else + { + /* otherwise there is not native async read support so this + * class will need to launch a reader thread. Initialize the + * state to EAsyncReadNotActive to record the fact that the thread + * has not been launched yet. + */ + iAsyncReadThreadState = EAsyncReadNotActive; + } + iAsyncReadThreadExitFlag = false; + + + + //this is the number of buffers we allocate internally for the linked buffer + //list. There is also one extra buffer of this size-- the 'iDataBuffer'. + iKCacheBufferCount = 4; + + //'min bytes read ahead' is how much data we will try to keep available + //from the async reads. It must be <= iKCacheBufferCount * iTotalCacheSize; + iKMinBytesReadAhead = (3 * iTotalCacheSize); + OSCL_ASSERT(iKMinBytesReadAhead <= (int32)(iKCacheBufferCount*iTotalCacheSize)); + + //this is the size of each read request to the native file system. + //it must be <= the individual buffer size, so we use 8k as the default, + //but then limit it to the input buffer size. + iKAsyncReadBufferSize = 8 * 1024 ; + if ((uint32)iKAsyncReadBufferSize > iTotalCacheSize) + iKAsyncReadBufferSize = iTotalCacheSize; + +} + +void OsclAsyncFile::ConstructL() +{ + //Create a duplicate file handle + //@todo: on symbian we need to make sure this is a duplicate of iNativeFile. + //on non-symbian it doesn't matter-- you can just create a new instance. + iNativeFileDuplicate = OSCL_NEW(OsclNativeFile, ()); + +#if(VERIFY_THIS) + iNativeFileVerify = OSCL_NEW(OsclNativeFile, ()); + iVerifyCount = 0; +#endif + + iFileSize = iNativeFile.Size(); + + iDataBufferArray.reserve(iKCacheBufferCount); + + // Create data buffers + + OsclAsyncFileBuffer* tmpBuffer; + for (int32 i = 0; i < iKCacheBufferCount; i++) + { + tmpBuffer = OsclAsyncFileBuffer::NewL(iTotalCacheSize, i); + iDataBufferArray.push_back(tmpBuffer); + } + + // create a local instance of OsclAsyncFileBuffer + iDataBuffer = OsclAsyncFileBuffer::NewL(iTotalCacheSize, -1); + + AddToScheduler(); + + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::ConstructL bufferSize %d numBuffers %d readSize %d readAhead %d" + , this, iTotalCacheSize, iKCacheBufferCount, iKAsyncReadBufferSize, iKMinBytesReadAhead)); +} + +int32 OsclAsyncFile::Open(const oscl_wchar *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::Open mode %d ", this, mode)); + + //open the duplicate file handle + if (!iNativeFileDuplicate) + return -1; + int32 result = iNativeFileDuplicate->Open(filename, mode, params, fileserv); + + //launch the thread + if (!iHasNativeAsyncRead) + { + LaunchAsyncReadThread(); + } + + iFilePosition = 0; + iSyncFilePosition = 0; + iAsyncFilePosition = 0; + iLastUserFileRead = 0; + + //start the async read if file is opened and thread is running + if ((result == 0) && (iAsyncReadThreadState == EAsyncReadActive)) + { + StartAsyncRead(true); + } + else + { + result = -1; + } + +#if(VERIFY_THIS) + if (iNativeFileVerify->Open(filename, mode, params, fileserv) != result) + OSCL_ASSERT(0); +#endif + return result; +} + +int32 OsclAsyncFile::Open(const char *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::Open filename '%s' mode %d ", this, filename, mode)); + + //open the duplicate file handle + if (!iNativeFileDuplicate) + return -1; + int32 result = iNativeFileDuplicate->Open(filename, mode, params, fileserv); + + //launch the thread + if (!iHasNativeAsyncRead) + { + LaunchAsyncReadThread(); + } + + iFilePosition = 0; + iSyncFilePosition = 0; + iAsyncFilePosition = 0; + iLastUserFileRead = 0; + + //start the async read if file is opened and thread is running + if ((result == 0) && (iAsyncReadThreadState == EAsyncReadActive)) + { + StartAsyncRead(true); + } + else + { + result = -1; + } + +#if(VERIFY_THIS) + if (iNativeFileVerify->Open(filename, mode, params, fileserv) != result) + OSCL_ASSERT(0); +#endif + return result; +} + +int32 OsclAsyncFile::Close() +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::Close", this)); + + //stop the async read + StartAsyncRead(false); + + //stop the thread + if (!iHasNativeAsyncRead) + { + StopAsyncReadThread(); + } + + //close the duplicate file handle + if (!iNativeFileDuplicate) + return -1; + int32 result = iNativeFileDuplicate->Close(); + +#if(VERIFY_THIS) + if (iNativeFileVerify->Close() != result) + OSCL_ASSERT(0); +#endif + return result; +} + +void OsclAsyncFile::StartAsyncRead(bool aStartAsyncRead) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::StartAsyncRead %d", this, aStartAsyncRead)); + + iStartAsyncRead = aStartAsyncRead; + // Do the asynchronous read +} + +uint32 OsclAsyncFile::Read(OsclAny* aBuffer, uint32 aDataSize, uint32 aNumElements) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::Read size %d numelements %d", this, aDataSize, aNumElements)); + +#if(VERIFY_THIS) + if (iVerifyCount == 1315) + fprintf(stderr, ""); + //verify file pos before the read + if (iNativeFileVerify->Tell() != iFilePosition) + OSCL_ASSERT(0); +#endif + + //Pull data from the internal buffers until we get the requested amount. + + //note: there's no logic to prevent reading partial elements here. + + uint32 bytesToRead = aDataSize * aNumElements; + + uint32 bytesRead = 0; + + uint8* databuf = NULL; + + uint8* dest = (uint8*)aBuffer; + + uint32 thisread; + + uint32 nbytes; + + while (bytesToRead > 0) + { + //note: the "doRead" routine only handles reads of <= iTotalCacheSize, + //so limit the read size here. + thisread = (bytesToRead > iTotalCacheSize) ? iTotalCacheSize : bytesToRead; + + nbytes = doRead(databuf, aDataSize, thisread / aDataSize, iFilePosition); + if (nbytes) + { + oscl_memcpy(dest, databuf, nbytes); + dest += nbytes; + bytesRead += nbytes; + bytesToRead -= nbytes; + } + else + break;//no more data or an error occurred. + } + +#if(VERIFY_THIS) + { + uint8* buf = (uint8*)OSCL_MALLOC(aDataSize * aNumElements); + int32 result2 = iNativeFileVerify->Read(buf, aDataSize, aNumElements); + if (result2 != bytesRead / aDataSize) + OSCL_ASSERT(0); + //verify file pos after the read + if (iNativeFileVerify->Tell() != iFilePosition) + OSCL_ASSERT(0); + //verify the data + if (oscl_memcmp(buf, aBuffer, bytesRead) != NULL) + OSCL_ASSERT(0); + OSCL_FREE(buf); + iVerifyCount++; + } +#endif + + //return number of whole elements read. + return bytesRead / aDataSize; +} + +//This routine locates the data in one of the internal buffers and returns a pointer. +//If data is not available, it will do a blocking read. +//The amount of data requested cannot exceed the internal buffer size. +//Note this returns bytes read, not number of elements read. +uint32 OsclAsyncFile::doRead(uint8 *& aBuffer1, uint32 aDataSize, uint32 aNumElements, TOsclFileOffset aOffset) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::doRead size %d numelements %d offset %d", this, aDataSize, aNumElements, aOffset)); + + //this routine only handles requests <= the individual buffer size-- it is + //the caller's responsibility to check. + OSCL_ASSERT(aNumElements*aDataSize <= iTotalCacheSize); + + // Clear buffers in use + for (int32 i = 0; i < iKCacheBufferCount; i++) + { + iDataBufferArray[i]->CleanInUse(); + } + + // Check if we have data already in the buffer + OsclAsyncFileBuffer* dataBuffer = NULL; + int32 bufferFoundId; + uint32 bytesRead = 0; + + // Check if we have data available + if (FindDataBuffer(dataBuffer, bufferFoundId, aOffset, aNumElements*aDataSize)) + { + // Mark buffer in use + dataBuffer->SetInUse(); + // update user pointer + OsclBuf* buff = dataBuffer->Buffer(); + OsclPtr ptrRead = buff->Des(); + aBuffer1 = const_cast(ptrRead.Ptr()); + // offset pointer to correct location + aBuffer1 += (aOffset - dataBuffer->Offset()); + bytesRead = dataBuffer->Length() - (uint32)(aOffset - dataBuffer->Offset()); + // Redo queue of linked buffers + ReOrderBuffersQueue(bufferFoundId); + } + else + { + //Data is not available-- must do a synchronous read. + + int32 ret = iNativeFileDuplicate->Seek(aOffset, Oscl_File::SEEKSET); + if (ret != 0) + { + // This is not good + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::doRead Seek Failed returned %d offset %d", this, ret, aOffset)); + return 0; + } + + // reset linked data bufferarray + iLinkedDataBufferArray.clear(); + + // Get buffer to read + OsclAsyncFileBuffer* dataBuffer; + bool bufferAvailable = GetNextDataBuffer(dataBuffer, aOffset); + if (!bufferAvailable) + { + // This case should never happen since iLinkedDataBufferArray was just closed + OSCL_ASSERT(0); + return 0; + } + + dataBuffer->SetOffset(aOffset); + + // Buffer is in use + dataBuffer->SetInUse(); + OsclBuf* readBuffer = dataBuffer->Buffer(); + OsclPtr ptrCurrentBuffer = readBuffer->Des(); + ptrCurrentBuffer.SetLength(0); + + // Do read. Might as well fill up the entire buffer while we're at it, so + // go ahead and read 'iTotalCacheSize'. The caller has already verified that + // the number of bytes requested in this read is <= 'iTotalCacheSize'. + bytesRead = iNativeFileDuplicate->Read(ptrCurrentBuffer.Ptr(), 1, iTotalCacheSize); + ptrCurrentBuffer.SetLength(bytesRead); + + // update data + dataBuffer->UpdateData(); + + // return value + aBuffer1 = (uint8*)ptrCurrentBuffer.Ptr(); + + iSyncFilePosition = aOffset + bytesRead; + + iLinkedDataBufferArray.push_back(dataBuffer); + } + + // set the returned byte count to the actual bytes available from this call + // or the amount requested, whichever is less. + if (bytesRead > aDataSize*aNumElements) + bytesRead = aDataSize * aNumElements; + + // Update virtual file pointer position + iFilePosition = aOffset + bytesRead; + + // This is the position from where we read + iLastUserFileRead = iFilePosition; + + // Continue reading + if (iStartAsyncRead) + { + UpdateReading(); + } + + return bytesRead; +} + +bool OsclAsyncFile::FindDataBuffer(OsclAsyncFileBuffer*& aDataBuffer, int32& aBufferId, TOsclFileOffset aOffset, int32 aSize) +{ + // Look for the requested value on the queue + OsclAsyncFileBuffer* tmpDataBuffer = NULL; + int32 i; + bool found = false; + for (i = 0; i < iKCacheBufferCount; i++) + { + tmpDataBuffer = iDataBufferArray[i]; + if (tmpDataBuffer->HasThisOffset(aOffset)) + { + // we want a linked buffer + if (IsLinkedDataBuffer(tmpDataBuffer)) + { + found = true; + break; + } + else + { + // check if it can be linked + if (CanBeLinked(tmpDataBuffer)) + { + found = true; + break; + } + } + } + } + + if (!found) + return false; + + aDataBuffer = tmpDataBuffer; + + // return id of the buffer (needed because down below we might return a different buffer than tmpDataBuffer) + // but we still need the id + aBufferId = tmpDataBuffer->Id(); + + // Check if we have enough data to return in a single buffer + TOsclFileOffset maxOffset = tmpDataBuffer->Offset() + tmpDataBuffer->Length(); + + // the easy case + if (aOffset + aSize <= maxOffset) + return true; + + // Last option, check if we can concatenate required data from two buffers + int32 availableData = (int32)(maxOffset - aOffset); + + // check again in the buffers for the remaining part of the data + OsclAsyncFileBuffer* tmpDataBuffer2 = iDataBufferArray[0]; //Init pointer to clean-up compiler warning=MG + for (i = 0; i < iKCacheBufferCount; i++) + { + tmpDataBuffer2 = iDataBufferArray[i]; + if (tmpDataBuffer2->HasThisOffset(maxOffset)) + { + break; + } + } + + // extra data not found + if (i == iKCacheBufferCount) + return false; + + // make sure data is valid + if (tmpDataBuffer2->Offset() != maxOffset) + return false; + + // Set the buffer + aDataBuffer = iDataBuffer; + + // length to copy from second buffer + int32 lengthToCopy; + if (tmpDataBuffer2->Length() + availableData >= aSize) + lengthToCopy = aSize - availableData; + else + return false; //shouldn't happen + + //note: could copy directly into target buffer here instead of into iDataBuffer, + //but would take some code re-structuring. + + // extra data found, proceed to concatenate with memcpy + OsclBuf* buffer = iDataBuffer->Buffer(); + OsclPtr ptrDes = buffer->Des(); + ptrDes.Zero(); + OsclPtrC tmpDataPtr = tmpDataBuffer->Buffer()->DesC(); + OsclPtrC temp_tmpDataPtr = tmpDataPtr.Right(availableData); + tmpDataPtr.Set(&temp_tmpDataPtr); + ptrDes.Append(tmpDataPtr); + // find out the length to copy + OsclBuf* buffer2 = tmpDataBuffer2->Buffer(); + OsclPtrC ptrDes2 = buffer2->DesC(); + OsclPtrC temp_ptrDes2 = ptrDes2.Left(lengthToCopy); + ptrDes2.Set(&temp_ptrDes2); + ptrDes.Append(ptrDes2); + iDataBuffer->UpdateData(); + iDataBuffer->SetOffset(aOffset); + + return true; +} + + +void OsclAsyncFile::UpdateReading() +{ + // Wait for Run() to process data + if (IsBusy()) + return; + + int32 bytesReadAhead = BytesReadAhead(); + + // don't need to read more + if (bytesReadAhead >= iKMinBytesReadAhead) + { + return; + } + + TOsclFileOffset posToReadFrom = iFilePosition + bytesReadAhead; + + // check for eof. We stop reading + if (posToReadFrom == iFileSize) + { + return; + } + + // Start next read + + StartNextRead(posToReadFrom); +} + +int32 OsclAsyncFile::BytesReadAhead() +{ + // Get the maximum offset of the last element in the linked buffer array + int32 index = iLinkedDataBufferArray.size() - 1; + if (index == -1) + { + return 0; + } + + OsclAsyncFileBuffer* tmpDataBuffer = iLinkedDataBufferArray[index]; + TOsclFileOffset maxOffset = tmpDataBuffer->Offset() + tmpDataBuffer->Length(); + int32 bytesReadAhead = (int32)(maxOffset - iLastUserFileRead); + + return bytesReadAhead; +} + +int32 OsclAsyncFile::SortDataBuffers() +{ + Oscl_Vector tmpArray; + // Append valid and not in use elements only + OsclAsyncFileBuffer* tmpDataBuffer; + uint32 i; + for (i = 0; i < (uint32)iKCacheBufferCount; i++) + { + tmpDataBuffer = iDataBufferArray[i]; + if (tmpDataBuffer->IsValid()) + { + tmpArray.push_back(tmpDataBuffer); + } + } + + iSortedDataBufferArray.clear(); + + // sort them out + for (i = 0; i < tmpArray.size(); i++) + { + if (i == 0) + iSortedDataBufferArray.push_back(tmpArray[i]); + else + { + OsclAsyncFileBuffer* tmpDataBuffer = tmpArray[i]; + bool insertedData = false; + // check where to insert new element + for (uint32 j = 0; j < iSortedDataBufferArray.size(); j++) + { + OsclAsyncFileBuffer* tmpDataBuffer2 = iSortedDataBufferArray[j]; + if (tmpDataBuffer->Offset() < tmpDataBuffer2->Offset()) + { + // Insert element + //iSortedDataBufferArray.Insert(tmpDataBuffer, j); + { + //note: there's no insert in oscl vector-- push to end then + //bubble down to desired spot. + iSortedDataBufferArray.push_back(tmpDataBuffer); + for (uint32 k = (uint32)iSortedDataBufferArray.size() - 1; k > j; k--) + { + OsclAsyncFileBuffer* temp = iSortedDataBufferArray[k-1]; + iSortedDataBufferArray[k-1] = iSortedDataBufferArray[k]; + iSortedDataBufferArray[k] = temp; + } + } + insertedData = true; + break; + } + } + + if (!insertedData) + { + iSortedDataBufferArray.push_back(tmpDataBuffer); + } + } + + } + tmpArray.clear(); + + return 0; +} + +bool OsclAsyncFile::GetNextDataBuffer(OsclAsyncFileBuffer*& aDataBuffer, TOsclFileOffset aFilePointerToReadFrom) +{ + uint32 i; + + OSCL_UNUSED_ARG(aFilePointerToReadFrom); + + // Loop through the buffer list and find out the first buffer available for use + OsclAsyncFileBuffer* tmpDataBuffer; + for (i = 0; i < iDataBufferArray.size(); i++) + { + tmpDataBuffer = iDataBufferArray[i]; + if (!tmpDataBuffer->IsValid()) + { + aDataBuffer = tmpDataBuffer; + return true; + } + } + + // if all buffers are valid, return the next one with oldest data + TOsclFileOffset smallerOffset = 0; + OsclAsyncFileBuffer* dataBufferToUse = NULL; + OsclAsyncFileBuffer* lastOptionBufferToUse = NULL; + for (i = 0; i < iDataBufferArray.size(); i++) + { + tmpDataBuffer = iDataBufferArray[i]; + // Only return valid buffers + if (tmpDataBuffer->IsInUse() || IsLinkedDataBuffer(tmpDataBuffer) || (tmpDataBuffer == iDataBufferInUse)) + continue; + + // We check if the buffer can be linked + // if so, we rather take another one that is not of any use. + if (CanBeLinked(tmpDataBuffer)) + { + // we remember it just in case there's no other buffer to use + lastOptionBufferToUse = dataBufferToUse; + continue; + } + + if (dataBufferToUse == NULL) + { + smallerOffset = tmpDataBuffer->Offset(); + dataBufferToUse = tmpDataBuffer; + } + else + { + if (tmpDataBuffer->Offset() < smallerOffset) + { + smallerOffset = tmpDataBuffer->Offset(); + dataBufferToUse = tmpDataBuffer; + } + } + + } + + // check what we have + if (dataBufferToUse == NULL) + dataBufferToUse = lastOptionBufferToUse; + + // If we didn't find any buffer, return false + if (dataBufferToUse == NULL) + return false; + + // Initialize buffer to use + aDataBuffer = dataBufferToUse; + + return true; +} + +void OsclAsyncFile::ReOrderBuffersQueue(int32 aFirstBufferId) +{ + // reset array + iLinkedDataBufferArray.clear(); + + // Sort data buffers first + SortDataBuffers(); + + // aFirstBufferId points to the index of the buffer in iDataBufferArray + OsclAsyncFileBuffer* tmpDataBuffer = iDataBufferArray[aFirstBufferId]; + + // Add the head element + iLinkedDataBufferArray.push_back(tmpDataBuffer); + + // Look for the linked elements + TOsclFileOffset offset = tmpDataBuffer->Offset() + tmpDataBuffer->Length(); + for (uint32 i = 0; i < iSortedDataBufferArray.size(); i++) + { + tmpDataBuffer = iSortedDataBufferArray[i]; + if (offset == tmpDataBuffer->Offset()) + { + offset = tmpDataBuffer->Offset() + tmpDataBuffer->Length(); + iLinkedDataBufferArray.push_back(tmpDataBuffer); + } + } +} + +bool OsclAsyncFile::IsLinkedDataBuffer(OsclAsyncFileBuffer* aDataBuffer) +{ + for (uint32 i = 0; i < iLinkedDataBufferArray.size(); i++) + { + OsclAsyncFileBuffer* tmpDataBuffer = iLinkedDataBufferArray[i]; + if (tmpDataBuffer == aDataBuffer) + { + return true; + } + } + return false; +} + +bool OsclAsyncFile::CanBeLinked(OsclAsyncFileBuffer* aDataBuffer) +{ + if (iLinkedDataBufferArray.size() == 0) + { + return false; + } + + if (aDataBuffer->Offset() + aDataBuffer->Length() == iLinkedDataBufferArray[0]->Offset()) + { + return true; + } + + return false; +} + +//The AO is invoked when the asynchronous Read request is complete. +void OsclAsyncFile::Run() +{ + iNumOfRun++; + if (iStatus != OSCL_REQUEST_ERR_NONE) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::Run Error!!!", this)); + iNumOfRunErr++; + return; + } + + if (iAsyncReadThreadState == EAsyncReadNotActive) + { + //This is a safeguard against the situation when the thread is already stopped, + //but the last completed request triggers the Run() execution + return; + } + + //update the iReadPtr descriptor length with the result of the async read. + //Note all reads are of size 1, so we can use "num elements" interchangeably with + //bytes here. + if (iHasNativeAsyncRead) + iReadPtr.SetLength(iNativeFile.GetReadAsyncNumElements()); + else + iReadPtr.SetLength(iAsyncReadNumBytes); + + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::Run numBytes %d ", this, iReadPtr.Length())); + + // First of all, update the internal file pointer + // and the current buffer + OsclBuf* readBuffer = iDataBufferInUse->Buffer(); + OsclPtr ptrCurrentBuffer = readBuffer->Des(); + int32 bytesRead = iReadPtr.Length(); + ptrCurrentBuffer.SetLength(ptrCurrentBuffer.Length() + bytesRead); + iAsyncFilePosition += bytesRead; + iDataBufferInUse->UpdateData(); + + // check how many bytes ahead of the user file position we have + // bool seekDone = false; + int32 bytesReadAhead = BytesReadAhead(); + + // next position to read from + TOsclFileOffset posToReadFrom = iLastUserFileRead + bytesReadAhead; + + // check for eof. We stop reading + if (posToReadFrom == iFileSize) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::Run Reached end of file ", this)); + return; + } + + // don't need to read more for now + if (bytesReadAhead >= iKMinBytesReadAhead) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::Run Reached the read-ahead count", this)); + return; + } + + // Start next read + StartNextRead(posToReadFrom); +} + +void OsclAsyncFile::DoCancel() +{ + if (!iHasNativeAsyncRead) + { + if (iAsyncReadThreadState == EAsyncReadNotActive) + { + //in case thread exited with some request active, this will + //complete it + OsclActiveObject::DoCancel(); + } + else + { + //in this case, thread is active. since there's no way to + //interrupt the thread's blocking read call, just do nothing + //here, then scheduler will wait on request completion. + } + } +} + +void OsclAsyncFile::StartNextRead(TOsclFileOffset aPosToReadFrom) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::StartNextRead pos %d ", this, aPosToReadFrom)); + + // Determine from which file pointer we're going to read + if (aPosToReadFrom == iAsyncFilePosition) + { + // just continue reading + OsclBuf* readBuffer = iDataBufferInUse->Buffer(); + OsclPtr ptrCurrentBuffer = readBuffer->Des(); + bool validBuffer = true; + // Extra validation. This should never be false, but let's check it + if (iDataBufferInUse->Offset() + iDataBufferInUse->Length() != aPosToReadFrom) + { + validBuffer = false; + } + + // Check if we need a new buffer + if (validBuffer && (iTotalCacheSize - ptrCurrentBuffer.Length() < (uint32)iKAsyncReadBufferSize)) + { + // This is the case where we could get NULL if + // we're trying to read ahead more data than what the + // buffers can hold. We just add some protection in case + // someone makes a wrong configuration + bool availableBuffer = GetNextDataBuffer(iDataBufferInUse, aPosToReadFrom); + if (!availableBuffer) + { + return; + } + // we link the new buffer as soon as we get it + iLinkedDataBufferArray.push_back(iDataBufferInUse); + iDataBufferInUse->SetOffset(aPosToReadFrom); + OsclBuf* newReadBuffer = iDataBufferInUse->Buffer(); + OsclPtr ptrNewReadBuffer = newReadBuffer->Des(); + ptrNewReadBuffer.SetLength(0); + iDataBufferInUse->UpdateData(); + iReadPtr.Set((uint8*)ptrNewReadBuffer.Ptr(), 0, iKAsyncReadBufferSize); + } + else + { + iReadPtr.Set((uint8*)(ptrCurrentBuffer.Ptr() + ptrCurrentBuffer.Length()), 0, iKAsyncReadBufferSize); + } + } + else if (aPosToReadFrom == iSyncFilePosition) + { + // update the async file pointer to the desired location + int32 result = iNativeFile.Seek(aPosToReadFrom, Oscl_File::SEEKSET); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::StartNextRead Seek failed, return %d, offset %d ", this, result, aPosToReadFrom)); + return; + } + + // we need to swap the file pointers + TOsclFileOffset tmpPosition = iSyncFilePosition; + iSyncFilePosition = iAsyncFilePosition; + iAsyncFilePosition = tmpPosition; + + // We need a new buffer + bool availableBuffer = GetNextDataBuffer(iDataBufferInUse, aPosToReadFrom); + if (!availableBuffer) + { + // This is an error condition. There should always be a buffer available + OSCL_ASSERT(0); + return; + } + // we link the new buffer as soon as we get it + iLinkedDataBufferArray.push_back(iDataBufferInUse); + iDataBufferInUse->SetOffset(aPosToReadFrom); + // Initialize the read pointer (iReadPtr) + OsclBuf* readBuffer = iDataBufferInUse->Buffer(); + OsclPtr ptrCurrentBuffer = readBuffer->Des(); + // reset length + ptrCurrentBuffer.SetLength(0); + iDataBufferInUse->UpdateData(); + iReadPtr.Set((uint8*)ptrCurrentBuffer.Ptr(), 0, iKAsyncReadBufferSize); + } + else + { + // This case should never happen.. check it out + OSCL_ASSERT(0); + return; + } + + // Issue the asynchronous read request. + + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::StartNextRead Issuing async read, size %d ", this, iKAsyncReadBufferSize)); + + if (iHasNativeAsyncRead) + { + //Activate the AO that will handle read completion. + PendForExec(); + + //Start the native async read operation + int32 result = iNativeFile.ReadAsync(iReadPtr.Ptr(), 1, iKAsyncReadBufferSize, StatusRef()); + + //if it failed to start, then cancel the request with an error. + if (result != 0) + PendComplete(OSCL_REQUEST_ERR_GENERAL); + } + else + { + //Start the non-native async read operation. + + StartNonNativeAsyncRead(); + //the AO will run when read is complete. + } +} + +int32 OsclAsyncFile::Seek(TOsclFileOffset offset, Oscl_File::seek_type origin) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::Seek offset %d origin %d", this, offset, origin)); + + if (origin == Oscl_File::SEEKCUR) + { + iFilePosition += offset; + } + else if (origin == Oscl_File::SEEKSET) + { + iFilePosition = offset; + } + else if (origin == Oscl_File::SEEKEND) + { + iFilePosition = iFileSize + offset; + } + + //some sanity checks. + OSCL_ASSERT(iFilePosition >= 0); + OSCL_ASSERT(iFilePosition <= iFileSize); + +#if(VERIFY_THIS) + if (iNativeFileVerify->Seek(offset, origin) != 0) + OSCL_ASSERT(0); + //also verify current position + if (iNativeFileVerify->Tell() != iFilePosition) + OSCL_ASSERT(0); +#endif + return 0; +} + + +TOsclFileOffset OsclAsyncFile::Tell() +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::Tell pos %d ", this, iFilePosition)); + +#if(VERIFY_THIS) + if (iNativeFileVerify->Tell() != iFilePosition) + OSCL_ASSERT(0); +#endif + return iFilePosition; +} + +int32 OsclAsyncFile::EndOfFile() +{ + int32 result = (iFilePosition >= iFileSize) ? 1 : 0; + +#if(VERIFY_THIS) + if (iNativeFileVerify->EndOfFile() != result) + OSCL_ASSERT(0); +#endif + + return result; +} + +TOsclFileOffset OsclAsyncFile::Size() +{ +#if(VERIFY_THIS) + if (iNativeFileVerify->Size() != iFileSize) + OSCL_ASSERT(0); +#endif + + return iFileSize; +} + +// ================== Non-Native async read implementation ========================== // + +void OsclAsyncFile::LaunchAsyncReadThread() +{ + if (iAsyncReadThreadState != EAsyncReadActive) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::LaunchAsyncReadThread starting thread ", this)); + + iAsyncReadSem.Create(0); + iAsyncReadExitSem.Create(0); + OsclThread thread; + OsclProcStatus::eOsclProcError status = thread.Create(iAsyncReadThreadFunc, 4096, (TOsclThreadFuncArg)this); + if (status == OsclProcStatus::SUCCESS_ERROR) + { + //Thread was successfuly started, update thread's state + iAsyncReadThreadState = EAsyncReadActive; + } + } +} + +void OsclAsyncFile::StopAsyncReadThread() +{ + if (iAsyncReadThreadState == EAsyncReadActive) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclAsyncFile(0x%x)::StopAsyncReadThread stopping thread ", this)); + + //signal the thread to exit & wake it up. + iAsyncReadThreadExitFlag = true; + iAsyncReadSem.Signal(); + + //wait on thread to exit so we can reset the sems safely + iAsyncReadExitSem.Wait(); + //Thread is terminated, update thread's state + iAsyncReadThreadState = EAsyncReadNotActive; + + iAsyncReadSem.Close(); + iAsyncReadExitSem.Close(); + } +} + +void OsclAsyncFile::StartNonNativeAsyncRead() +{ + //note: we assume the read requests are nicely serialized here, + //so there's no handling for overlapping requests. + + //Activate the AO that will wait on read completion. + PendForExec(); + + //wake up the thread + iAsyncReadSem.Signal(); +} + +void OsclAsyncFile::InThread() +{ + while (iAsyncReadThreadExitFlag != true) + { + //wait for the signal + iAsyncReadSem.Wait(); + + //see if it's a close request + if (iAsyncReadThreadExitFlag == true) + { + break; + } + + //issue the read. + iAsyncReadNumBytes = iNativeFile.Read(iReadPtr.Ptr(), 1, iKAsyncReadBufferSize); + + //complete the request. + if (IsAdded() && iStatus == OSCL_REQUEST_PENDING) + PendComplete(OSCL_REQUEST_ERR_NONE); + } + + // reset the thread exit flag + iAsyncReadThreadExitFlag = false; + //signal that thread is exiting. + iAsyncReadExitSem.Signal(); +} + +//static thread routine. +TOsclThreadFuncRet OSCL_THREAD_DECL OsclAsyncFile::iAsyncReadThreadFunc(TOsclThreadFuncArg aArg) +{ + OsclAsyncFile* This = (OsclAsyncFile*)aArg; + + This->InThread(); + + return 0; +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_async_read.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_async_read.h new file mode 100644 index 0000000..e2c5ae9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_async_read.h @@ -0,0 +1,459 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +* ============================================================================ +* Name : oscl_async_file.h +* Part of : osclio +* Interface : +* Description : +* Version : +* ============================================================================== +*/ + +#ifndef OSCL_FILE_ASYNC_READ_H_INCLUDED +#define OSCL_FILE_ASYNC_READ_H_INCLUDED + + +#include "oscl_base.h" +#include "osclconfig_io.h" +#include "oscl_vector.h" +#include "oscl_mem.h" +#include "oscl_scheduler_ao.h" +#include "oscl_file_io.h" + +#ifndef OSCL_SEMAPHORE_H_INCLUDED +#include "oscl_semaphore.h" +#endif + +class OsclNativeFile; + +//non-modifiable buffer pointer container +class OsclPtrC: public HeapBase +{ + public: + OsclPtrC(const uint8* ptr, int32 len, int32 max): iPtr(ptr), iMaxLength(max), iLength(len) + {} + OsclPtrC(const OsclPtrC& d): HeapBase(d), iPtr(d.iPtr), iMaxLength(d.iMaxLength), iLength(d.iLength) + {} + const uint8* Ptr() + { + return iPtr; + } + void SetLength(int32 l) + { + OSCL_ASSERT(l <= iMaxLength); + iLength = l; + } + int32 Length() + { + return iLength; + } + void Zero() + { + iLength = 0; + } + void Set(OsclPtrC* v) + { + iPtr = v->iPtr; + iMaxLength = v->iMaxLength; + iLength = v->iLength; + } + void Set(uint8* ptr, int32 len, int32 max) + { + iPtr = ptr; + iLength = len; + iMaxLength = max; + } + //extract the right-most data + OsclPtrC Right(int32 size) + { + OSCL_ASSERT(iLength >= size); + OsclPtrC des(iPtr + iLength - size, size, size); + return des; + } + //extract the left-most data + OsclPtrC Left(int32 size) + { + OSCL_ASSERT(iLength >= size); + OsclPtrC des(iPtr, size, size); + return des; + } + private: + const uint8* iPtr; + int32 iMaxLength; + int32 iLength; +}; + +//modifiable buffer pointer container +class OsclPtr: public HeapBase +{ + public: + OsclPtr(uint8* ptr, int32& len, int32 max): iPtr(ptr), iMaxLength(max), iLength(len) + {} + OsclPtr(const OsclPtr& d): HeapBase(d), iPtr(d.iPtr), iMaxLength(d.iMaxLength), iLength(d.iLength) + {} + uint8* Ptr() + { + return iPtr; + } + void SetLength(int32 l) + { + OSCL_ASSERT(l <= iMaxLength); + iLength = l; + } + int32 Length() + { + return iLength; + } + void Zero() + { + iLength = 0; + } + void Set(OsclPtr &v) + { + iPtr = v.iPtr; + iMaxLength = v.iMaxLength; + iLength = v.iLength; + } + void Set(uint8* ptr, int32 len, int32 max) + { + iPtr = ptr; + iLength = len; + iMaxLength = max; + } + void Append(OsclPtrC &v) + { + OSCL_ASSERT(iLength + v.Length() <= iMaxLength); + oscl_memmove(iPtr + iLength, v.Ptr(), v.Length()); + iLength += v.Length(); + } + private: + uint8* iPtr; + int32 iMaxLength; + int32& iLength; +}; + +//buffer container that allocates from the heap +class OsclBuf: public HeapBase +{ + public: + static OsclBuf* NewL(int32 size) + { + OsclBuf* self = OSCL_NEW(OsclBuf, (size)); + self->iBuffer = (uint8*)OSCL_MALLOC(self->iMaxLength); + if (!self->iBuffer) + { + OSCL_DELETE(self); + OsclError::Leave(OsclErrNoMemory); + } + return self; + } + + static void Delete(OsclBuf* a) + { + if (a) + { + if (a->iBuffer) + OSCL_FREE(a->iBuffer); + OSCL_DELETE(a); + } + } + + OsclBuf(int32 size): iBuffer(NULL), iMaxLength(size), iLength(0) + {} + + int32 Length() + { + return iLength; + } + + OsclPtr Des() + { + OsclPtr des(iBuffer, iLength, iMaxLength); + return des; + } + OsclPtrC DesC() + { + OsclPtrC des(iBuffer, iLength, iMaxLength); + return des; + } + + uint8* iBuffer; + int32 iMaxLength; + int32 iLength; +}; + + +/*! +** Buffer class used with async read. We keep an array of these, covering +** consecutive areas of the file. This allows for some seeking without requiring +** a full flush & refill each time. +*/ +class OsclAsyncFileBuffer: public HeapBase +{ + public: + static OsclAsyncFileBuffer* NewL(int32 aBufferSize, int32 aId); + ~OsclAsyncFileBuffer(); + + public: + void CleanInUse() + { + iInUse = false; + } + void SetInUse() + { + iInUse = true; + } + bool IsInUse() + { + return iInUse; + } + bool IsValid() + { + return iValid; + } + TOsclFileOffset Offset() + { + return iOffset; + } + void SetOffset(TOsclFileOffset aOffset) + { + iOffset = aOffset; + } + int32 Length() + { + return iLength; + } + bool HasThisOffset(TOsclFileOffset aOffset); + int32 Id() + { + return iId; + } + OsclBuf* Buffer(); + void UpdateData(); + void StartAsyncRead(bool aStartAsyncRead); + + private: + OsclAsyncFileBuffer(int32 aBufferSize, int32 aId); + void ConstructL(); + + private: + OsclBuf* iBuffer; + TOsclFileOffset iOffset; + bool iInUse; + int32 iLength; + bool iValid; + int32 iBufferSize; + int32 iId; +}; + + +/** +* OsclAsyncFile +*/ +class OsclAsyncFile : public OsclActiveObject +{ + public: + /** + * Two-phased constructor. + * + * @param aAsyncFile: open handle for async file read. + * Note: it is the caller's job to open/close this file handle. + * + * @param aSyncFile: duplicate open handle for sync file read. + * Note: it is the caller's job to open this file handle, but this + * class will close the handle. + * + * @param aCacheSize: size of one of the individual cache buffers. The total + * cached data size will be larger, since multiple buffers are used. + * + * @param aStartAsyncRead: When true, async file read will start immediately. + * When false, read will not begin until StartAsyncRead is called. + * + */ + static OsclAsyncFile* NewL(OsclNativeFile& aAsyncFile, int32 aCacheSize, PVLogger*); + static void Delete(OsclAsyncFile*); + + /** + * Destructor. + */ + ~OsclAsyncFile(); + + private: + //From OsclActiveObject + void Run(); + void DoCancel(); + + public: + //////////////////////// + // File IO methods. + //////////////////////// + + int32 Open(const oscl_wchar *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv); + int32 Open(const char *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv); + + int32 Seek(TOsclFileOffset offset, Oscl_File::seek_type origin); + TOsclFileOffset Tell(); + uint32 Read(OsclAny* aBuffer1, uint32 aDataSize, uint32 aNumElements); + int32 EndOfFile(); + TOsclFileOffset Size(); + int32 Close(); + + uint32 Write(const OsclAny* aBuffer1, uint32 aDataSize, uint32 aNumElements) + { + OSCL_UNUSED_ARG(aBuffer1); + OSCL_UNUSED_ARG(aDataSize); + OSCL_UNUSED_ARG(aNumElements); + return 0;//not supported + } + uint32 Flush() + { + return ((uint32) - 1);//not supported + } + + private: + OsclAsyncFile(OsclNativeFile& aAsyncFile, int32 aCacheSize, PVLogger*); + /** + * Second-phase constructor. + */ + void ConstructL(); + + private: + // private utility methods + void StartAsyncRead(bool aStartAsyncRead); + bool FindDataBuffer(OsclAsyncFileBuffer*& aDataBuffer, int32& aBufferId, TOsclFileOffset aOffset, int32 aSize); + void UpdateReading(); + int32 BytesReadAhead(); + int32 SortDataBuffers(); + bool GetNextDataBuffer(OsclAsyncFileBuffer*& aDataBuffer, TOsclFileOffset aFilePointerToReadFrom); + void StartNextRead(TOsclFileOffset aPosToReadFrom); + void ReOrderBuffersQueue(int32 aFirstBufferId); + bool IsLinkedDataBuffer(OsclAsyncFileBuffer* aDataBuffer); + bool CanBeLinked(OsclAsyncFileBuffer* aDataBuffer); + uint32 doRead(uint8*& aBuffer1, uint32 aDataSize, uint32 aNumElements, TOsclFileOffset aOffset); + + private: + TOsclFileOffset iFileSize; + + // File object to do async read from + OsclNativeFile& iNativeFile; + + // File position for async reads. + TOsclFileOffset iAsyncFilePosition; + + // For verification + OsclNativeFile* iNativeFileVerify; + int32 iVerifyCount; + + // Duplicate file handle for sync read + OsclNativeFile* iNativeFileDuplicate; + + // File position for sync reads. + TOsclFileOffset iSyncFilePosition; + + // Arrays of data buffers + Oscl_Vector iDataBufferArray; + Oscl_Vector iSortedDataBufferArray; + Oscl_Vector iLinkedDataBufferArray; + + // Local data buffer + OsclAsyncFileBuffer* iDataBuffer; + OsclAsyncFileBuffer* iDataBufferInUse; + + // Buffer for synchronous read + OsclBuf* iSyncBuffer; + + // Initialized in constructor. Determines the size of each data buffer + uint32 iTotalCacheSize; + + // Logical File Position (as seen by the client of this class) + TOsclFileOffset iFilePosition; + + // Last offset after a user read operation + TOsclFileOffset iLastUserFileRead; + + // Start async read enable flag + bool iStartAsyncRead; + + // Pointer to buffer for asynchronous read + int32 iReadPtrDummyLen; + OsclPtr iReadPtr; + + // For profiling + PVLogger* iLogger; + + //////////////////////// + // Configuration parameters. + //////////////////////// + + // Number of buffers in the linked list + int32 iKCacheBufferCount ; + + // This defines the limit on how much data we will + // read ahead of the current position + int32 iKMinBytesReadAhead ; + + // This defines the size of the individual async read operations. + int32 iKAsyncReadBufferSize ; + + //////////////////////// + // The non-native async read implementation. + //////////////////////// + + // Keeps track of whether we have native async read or not + bool iHasNativeAsyncRead; + + // Thread control sems + OsclSemaphore iAsyncReadSem; + OsclSemaphore iAsyncReadExitSem; + + // To keep track of the tread state: + // EAsyncReadNotActive - the thread is not created or the thread is stopped + // EAsyncReadActive - the thread is running + enum TAsyncReadThreadState {EAsyncReadNotActive, EAsyncReadActive}; + TAsyncReadThreadState iAsyncReadThreadState; + + // To signal the thread to exit + bool iAsyncReadThreadExitFlag; + + // Number of bytes read in the last call + int32 iAsyncReadNumBytes; + + // Thread routine + void InThread(); + static TOsclThreadFuncRet OSCL_THREAD_DECL iAsyncReadThreadFunc(TOsclThreadFuncArg); + + // Thread start/stop. + void LaunchAsyncReadThread(); + void StopAsyncReadThread(); + + // Request an async read. + void StartNonNativeAsyncRead(); + + public: + // for test&stat + uint32 iNumOfRun; + uint32 iNumOfRunErr; +}; + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_cache.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_cache.cpp new file mode 100644 index 0000000..ac6e690 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_cache.cpp @@ -0,0 +1,1076 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_base.h" +#include "oscl_file_cache.h" +#include "oscl_mem.h" +#include "oscl_file_io.h" +#include "oscl_file_native.h" +#include "pvlogger.h" + +OsclFileCache::OsclFileCache(Oscl_File& aContainer): + iContainer(aContainer) + , _curCache(NULL) + , _fileSize(0) + , _nativePosition(0) + , iLogger(NULL) +{ + _movableCache.iContainer = this; +} + +OsclFileCache::~OsclFileCache() +{ + Close(); +} + +int32 OsclFileCache::Open(uint32 mode, uint32 size) +//Called to open the cache for a newly opened file. +//The NativeOpen was just called prior to this and was successful. +{ + //should not be called with zero-size cache. + OSCL_ASSERT(size > 0); + + //Save the mode + _mode = mode; + + //open logger object only if logging is enabled on this + //file + if (iContainer.iLogger) + iLogger = PVLogger::GetLoggerObject("OsclFileCache"); + else + iLogger = NULL; + + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Open mode %d size %d", this, mode, size)); + + // Create the movable cache. + // Re-allocate it if the size has changed. + if (_movableCache.pBuffer + && size != _movableCache.capacity) + { + OSCL_FREE(_movableCache.pBuffer); + _movableCache.pBuffer = NULL; + } + if (!_movableCache.pBuffer + && size > 0) + { + _movableCache.pBuffer = (uint8*)OSCL_MALLOC(size); + } + if (!_movableCache.pBuffer) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Open ERROR no memory %d", this)); + return (-1);//error + } + _movableCache.capacity = _movableCache.usableSize = size; + _movableCache.filePosition = 0; + _movableCache.updateStart = _movableCache.updateEnd = 0; + _movableCache.currentPos = _movableCache.endPos = 0; + + //Position the cache at zero. + SetCachePosition(0); + + //get initial file size & native position + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Open CallingNativeSize", this)); + _fileSize = iContainer.CallNativeSize(); + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Open CallingNativeTell", this)); + _nativePosition = iContainer.CallNativeTell(); + + return 0; +} + +int32 OsclFileCache::UpdateFixedCaches() +//Process any queued requests to remove or add fixed caches. +{ + int32 error = 0; + if (iContainer.iRemoveFixedCache.size()) + { + for (uint32 i = 0; i < iContainer.iRemoveFixedCache.size(); i++) + { + for (uint32 j = 0; j < _fixedCaches.size(); j++) + { + if (_fixedCaches[j].filePosition < iContainer.iRemoveFixedCache[i]) + { + //fixed cache list is sorted, so we can end search now. + break; + } + else if (_fixedCaches[j].filePosition == iContainer.iRemoveFixedCache[i]) + { + //found it + if (_fixedCaches[j].IsUpdated()) + { + int32 result = _fixedCaches[j].WriteUpdatesToFile(); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::UpdateFixedCaches ERROR in WriteUpdatesToFile", this)); + error = result; + } + } + if (_fixedCaches[j].pBuffer) + { + OSCL_FREE(_fixedCaches[j].pBuffer); + _fixedCaches[j].pBuffer = NULL; + } + _fixedCaches.erase(&_fixedCaches[j]); + break; + } + } + } + iContainer.iRemoveFixedCache.clear(); + } + + if (iContainer.iAddFixedCache.size()) + { + for (uint32 i = 0; i < iContainer.iAddFixedCache.size(); i++) + { + if (!AddFixedCache(iContainer.iAddFixedCache[i])) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::UpdateFixedCaches ERROR in AddFixedCache", this)); + error = (-1); + } + } + iContainer.iAddFixedCache.clear(); + } + return error; +} + +//Enable/disable fixed cache array overlap checks. +//This is expensive, so it is normally disabled. +#define OVERLAP_CHECKS 0 + +//Add a new fixed cache, maintaining sorted order of the list. +OSCL_EXPORT_REF OsclFileCacheBuffer* OsclFileCache::AddFixedCache(const Oscl_File::OsclFixedCacheParam& aParam) +{ +#if (OVERLAP_CHECKS) + //Check for overlap with any existing fixed cache. + //Caller should ensure there is no overlap. + if (_fixedCaches.size()) + { + for (uint32 i = 0; i < _fixedCaches.size(); i++) + { + if (_fixedCaches[i].Contains(aParam.iFilePosition)) + { + //given start position falls in an existing cache. + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::AddFixedCache ERROR Overlap!", this)); + return NULL; + } + if (aParam.Contains(_fixedCaches[i].filePosition)) + { + //some cache start position falls in this range. + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::AddFixedCache ERROR Overlap!", this)); + return NULL; + } + //verify sort while we're at it + if (i > 0) + { + if (_fixedCaches[i].filePosition < _fixedCaches[i-1].filePosition) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::AddFixedCache ERROR Sort!", this)); + return NULL; + } + } + } + } +#endif + + //Check for overlap with current movable cache. + if (_movableCache.Contains(aParam.iFilePosition) + || aParam.Contains(_movableCache.filePosition)) + { + //There is overlap. Dump the movable cache. + //@TODO might be able to preserve some of the data here instead of complete + //cache dump. + + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::AddFixedCache Movable Cache Overlap, dumping data", this)); + + if (_movableCache.IsUpdated()) + { + int32 result = _movableCache.WriteUpdatesToFile(); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::AddFixedCache ERROR in WriteUpdatesToFile!", this)); + return NULL; + } + } + _movableCache.endPos = _movableCache.currentPos = 0; + _movableCache.filePosition = 0; + _movableCache.usableSize = _movableCache.capacity; + } + + + //Create new entry + OsclFileCacheBuffer fc; + fc.iContainer = this; + fc.isFixed = true; + fc.pBuffer = (uint8*)OSCL_MALLOC(aParam.iSize); + if (!fc.pBuffer) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::AddFixedCache ERROR no memory %d", this)); + return NULL;//error + } + fc.capacity = fc.usableSize = aParam.iSize; + fc.filePosition = aParam.iFilePosition; + + //Add this entry, maintaining sorted order. + int32 insertIndex = (-1); + if (_fixedCaches.size()) + { + for (uint32 i = 0; i < _fixedCaches.size(); i++) + { + if (fc.filePosition <= _fixedCaches[i].filePosition) + { + insertIndex = i; + break; + } + } + } + if (insertIndex >= 0) + { + _fixedCaches.insert(&_fixedCaches[insertIndex], fc); + return &_fixedCaches[insertIndex]; + } + else + { + _fixedCaches.push_back(fc); + return &_fixedCaches[_fixedCaches.size()-1]; + } +} + +void OsclFileCache::Close() +{ + //flush any cache updates & free the buffers + if (_movableCache.pBuffer) + { + _movableCache.WriteUpdatesToFile(); + OSCL_FREE(_movableCache.pBuffer); + _movableCache.pBuffer = NULL; + _movableCache.capacity = _movableCache.usableSize = 0; + } + + for (uint32 i = 0; i < _fixedCaches.size(); i++) + { + _fixedCaches[i].WriteUpdatesToFile(); + if (_fixedCaches[i].pBuffer) + { + OSCL_FREE(_fixedCaches[i].pBuffer); + _fixedCaches[i].pBuffer = NULL; + _fixedCaches[i].capacity = _fixedCaches[i].usableSize = 0; + } + } + _fixedCaches.clear(); +} + +/** + * Read + * Reads data from the file cache buffer and copies into + * the buffer supplied (outputBuffer) + * + * @param outputBuffer pointer to buffer of type void + * @param size element size in bytes + * @param numelements + * max number of elements to read + * + * @return returns the number of full elements actually read, which + * may be less than count if an error occurs or if the end + * of the file is encountered before reaching count. + */ +uint32 OsclFileCache::Read(void* outputBuffer, uint32 size, uint32 numelements) +{ + if (!outputBuffer) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Read ERROR invalid arg ", this)); + return 0; + } + + //check for a valid read mode + if ((_mode & Oscl_File::MODE_READWRITE) + || (_mode & Oscl_File::MODE_READ) + || (_mode & Oscl_File::MODE_APPEND) + || (_mode & Oscl_File::MODE_READ_PLUS)) + { + ;//ok to write + } + else + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Read ERROR invalid mode for reading ", this)); + return 0;//invalid mode. + } + + uint8* destBuf = (uint8*)(outputBuffer); + + uint32 bytesToRead = numelements * size; + + // If file is smaller than requested data amount, reduce bytesToRead to the lowest multiple + // of size that we can read + uint32 bytesLeftInFile = (uint32)(FileSize() - Tell()); + if (bytesToRead > bytesLeftInFile) + { + numelements = bytesLeftInFile / size; + bytesToRead = numelements * size; + } + + if (bytesToRead) + { + //prep current cache for reading + int32 retval = _curCache->PrepRead(); + if (retval != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Read ERROR PrepRead failed ", this)); + return 0; + } + } + + //pull data out of the cache until we run out, then re-fill the cache + //as needed until we get the desired amount. + + while (bytesToRead > 0) + { + OSCL_ASSERT(_curCache->endPos >= _curCache->currentPos); + uint32 bytesInCache = (uint32)(_curCache->endPos - _curCache->currentPos); + + if (bytesInCache > 0) + { + //pull out either all data in cache, or number of bytes required, + //whichever is less + uint32 thisRead = (bytesInCache > bytesToRead) ? bytesToRead : bytesInCache; + + oscl_memcpy(destBuf, _curCache->pBuffer + _curCache->currentPos, thisRead); + bytesToRead -= thisRead; + destBuf += thisRead; + + //update virtual position + _curCache->currentPos += thisRead; + } + else + { + //no more data-- reposition & refill the cache + int32 retval = SetCachePosition(Tell()); + if (retval != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Read ERROR SetCachePosition failed ", this)); + break;//error! + } + retval = _curCache->PrepRead(); + if (retval != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Read ERROR PrepRead failed ", this)); + break;//error! + } + + //When at EOF, cache will be empty after fillcache, + //so break out of loop. + if (_curCache->endPos - _curCache->currentPos == 0) + break; + } + } + + //return number of whole elements read. + return (size) ? ((size*numelements - bytesToRead) / size) : 0; + +} + + +/** + * Write + * Writes data from the input buffer into + * the buffer supplied (inputBuffer) + * + * @param inputBuffer pointer to buffer of type void + * @param size element size in bytes + * @param numelements + * number of elements to write + * + * @return returns the number of elements written + */ +uint32 OsclFileCache::Write(const void* inputBuffer, uint32 size, uint32 numelements) +{ + if (inputBuffer == NULL) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Write ERROR invalid arg ", this)); + return 0; + } + + //write the data only in the mode we are permitted to write + if ((_mode & Oscl_File::MODE_READWRITE) + || (_mode & Oscl_File::MODE_APPEND) + || (_mode & Oscl_File::MODE_READ_PLUS)) + { + ;//ok to write + } + else + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Write ERROR invalid mode for writing ", this)); + return 0;//invalid mode. + } + + //In Append mode, write always happens at the end of file, + //so relocate the cache now if needed. + if ((_mode & Oscl_File::MODE_APPEND) + && (Tell() != FileSize())) + { + int32 result = SetCachePosition(FileSize()); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Write ERROR SetCachePosition failed. ", this)); + return 0; + } + } + + //prep current cache for writing + int32 result = _curCache->PrepWrite(); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Write ERROR PrepWrite failed. ", this)); + return 0; + } + + uint8* srcBuf = (uint8*)(inputBuffer); + uint32 bytesToWrite = size * numelements; + + //write into cache, flushing as needed when it fills up. + + while (bytesToWrite > 0) + { + OSCL_ASSERT(_curCache->usableSize >= _curCache->currentPos); + uint32 spaceInCache = _curCache->usableSize - _curCache->currentPos; + if (spaceInCache > 0) + { + //write to cache + uint32 thisWrite = (spaceInCache > bytesToWrite) ? bytesToWrite : spaceInCache; + + oscl_memcpy((_curCache->pBuffer + _curCache->currentPos), srcBuf, thisWrite); + bytesToWrite -= thisWrite; + srcBuf += thisWrite; + + //keep track of the range of data in the cache that has been updated. + if (_curCache->updateEnd == _curCache->updateStart) + { + //first update in this cache + _curCache->updateStart = _curCache->currentPos; + _curCache->updateEnd = _curCache->currentPos + thisWrite; + } + else + { + //cache has already been updated. Expand the updated range + //to include this update. + + if (_curCache->currentPos < _curCache->updateStart) + _curCache->updateStart = _curCache->currentPos; + + if ((_curCache->currentPos + thisWrite) > _curCache->updateEnd) + _curCache->updateEnd = _curCache->currentPos + thisWrite; + } + + //update the virtual position. + _curCache->currentPos += thisWrite; + + //extend the end of cache data if needed + if (_curCache->endPos < _curCache->currentPos) + _curCache->endPos = _curCache->currentPos; + + //extend the virtual file size if needed. + if (_fileSize < (TOsclFileOffset)(_curCache->filePosition + _curCache->endPos)) + _fileSize = _curCache->filePosition + _curCache->endPos; + + //consistency checks. if these asserts fire, there is + //a logic error. + OSCL_ASSERT(_curCache->updateEnd >= _curCache->updateStart); + OSCL_ASSERT(_curCache->endPos >= _curCache->currentPos); + } + else + { + //entire cache is full-- re-set cache to current vpos and prep + //for write + int32 retval = SetCachePosition(Tell()); + if (retval != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Write ERROR SetCachePosition failed ", this)); + break;//error! + } + retval = _curCache->PrepWrite(); + if (retval != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Write ERROR PrepWrite failed ", this)); + break;//error! + } + } + } + + //return number of whole elements written. + return (size) ? ((size*numelements - bytesToWrite) / size) : 0; + +} + + +/** + * Seek + * + * @param [in] offset from origin + * @param [in] origin: either SEEKSET, SEEKCUR, or SEEKEND + * + * @return 0 for success. + */ +int32 OsclFileCache::Seek(TOsclFileOffset offset, Oscl_File::seek_type origin) +{ + //figure out the file position we're trying to seek to + TOsclFileOffset pos; + switch (origin) + { + case Oscl_File::SEEKCUR: + pos = Tell() + offset; + break; + case Oscl_File::SEEKSET: + pos = 0 + offset; + break; + case Oscl_File::SEEKEND: + pos = FileSize() + offset; + break; + default: + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Seek ERROR invalid origin %d", this, origin)); + return (-1);//error-- invalid origin! + } + + //don't allow seeking outside valid file size + if (pos < 0 || pos > FileSize()) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Seek ERROR invalid seek position %d", this, pos)); + return -1;//error + } + + if (_curCache->Contains(pos)) + { + //Seek in cur cache + _curCache->currentPos = (uint32)(pos - _curCache->filePosition); + } + else + { + //Seek outside cache + int32 retval = SetCachePosition(pos); + if (retval != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Seek ERROR SetPosition error %d", this, retval)); + return retval;//error + } + } + return 0; +} + + +/** + * Flush + * Flush file to disk. + * After this call, previously cached data + * is still available. + * + * @param void + * + * @return 0 for success. + */ +int32 OsclFileCache::Flush() +{ + bool nativeFlush = false; + + //Write all cache updates to file + //Note: don't reset caches here, since + //we may still want to use the data + //in read operations. + if (_movableCache.IsUpdated()) + { + int32 result = _movableCache.WriteUpdatesToFile(); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Flush ERROR WriteUpdatesToFile failed", this)); + return result; + } + nativeFlush = true; + } + for (uint32 i = 0; i < _fixedCaches.size(); i++) + { + if (_fixedCaches[i].IsUpdated()) + { + int32 result = _fixedCaches[i].WriteUpdatesToFile(); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Flush ERROR WriteUpdatesToFile failed", this)); + return result; + } + nativeFlush = true; + } + } + + //Flush to disk if there were any updates. + if (nativeFlush) + { + + //flush file to disk. + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Flush CallingNativeFlush", this)); + int32 retval = iContainer.CallNativeFlush(); + if (retval != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Flush ERROR CallNativeFlush failed", this)); + } + + //not sure if native file position is affected + //by a native flush, so query now. + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::Flush CallingNativeTell", this)); + _nativePosition = iContainer.CallNativeTell(); + + return retval; + } + else + { + //no updates in cache since last flush + //so nothing is needed. + + return 0; //success! + } +} + + +/** + * SetCachePosition + * + * Select _curCache and set position to + * the input position. + * + * @param [in] aNewPos: file position. + * + * return 0 on success. + * +*/ +int32 OsclFileCache::SetCachePosition(TOsclFileOffset aPos) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::SetCachePosition pos %d size %d", this, aPos)); + + //Remove or add any fixed caches + if (iContainer.iAddFixedCache.size() + || iContainer.iRemoveFixedCache.size()) + { + int32 result = UpdateFixedCaches(); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::SetCachePosition ERROR in UpdateFixedCaches %d" + , this, result)); + return result; + } + } + + //Choose current cache + if (iContainer.iCacheObserver) + { + //Invoke observer's algorithm if any was provided. + + _curCache = iContainer.iCacheObserver->ChooseCurCache(*this, aPos); + if (!_curCache) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::SetCachePosition ERROR in ChooseCurCache" + , this)); + return (-1); + } + } + else + { + //Default algorithm to choose current cache. + + _curCache = NULL; + + //First try to use a fixed cache. + if (_fixedCaches.size()) + { + for (uint32 i = 0; i < _fixedCaches.size(); i++) + { + if (aPos < _fixedCaches[i].filePosition) + { + //fixed cache list is sorted, so we can end search now. + break; + } + else if (_fixedCaches[i].Contains(aPos)) + { + _curCache = &_fixedCaches[i]; + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::SetCachePosition Using fixed cache index %d, pos %d size %d" + , this, i, (int32)_fixedCaches[i].filePosition, _fixedCaches[i].usableSize)); + break; + } + } + } + + //If no fixed cache works, use the movable cache. + if (!_curCache) + { + _curCache = &_movableCache; + } + } + + //Set position in the chosen cache. + return _curCache->SetPosition(aPos); +} + +/** + * SetPosition + * + * Set working position in this cache to the input + * position. For movable cache, may have a side-effect + * of flushing current updates to the file. + * + * Note: cache is not necessarily usable for reads & writes + * after this routine. Use PrepRead or PrepWrite + * to ensure valid data. + * + * @param [in] aNewPos: file position. + * + * return 0 on success. + * +*/ +int32 OsclFileCacheBuffer::SetPosition(TOsclFileOffset aNewPos) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::SetPosition newpos %d", this, aNewPos)); + + if (Contains(aNewPos)) + { + //new position is in current usable size + currentPos = (uint32)(aNewPos - filePosition); + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::SetPosition adjusted position in cache")); + } + else + { + //relocating the cache + if (isFixed) + { + //unexpected! + OSCL_ASSERT(0); + return -1; + } + else + { + //Movable cache + + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::SetPosition relocating movable cache")); + + //flush any updated data currently in cache. + if (IsUpdated()) + { + int32 result = WriteUpdatesToFile(); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::SetPosition ERROR FlushUpdatesToFile failed", this)); + return result;//error! + } + } + + //reset the virtual position and the cache location. + filePosition = aNewPos; + currentPos = 0; + + //cache is empty + endPos = 0; + + //Adjust the capacity downward to avoid overlapping any fixed cache + usableSize = capacity; + if (iContainer->_fixedCaches.size()) + { + for (uint32 i = 0; i < iContainer->_fixedCaches.size(); i++) + { + if (Preceeds(iContainer->_fixedCaches[i].filePosition)) + { + //end search now because fixed cache list is sorted. + break; + } + else if (Contains(iContainer->_fixedCaches[i].filePosition)) + { + //movable cache overlaps this fixed cache, so reduce its usable size + usableSize = (uint32)(iContainer->_fixedCaches[i].filePosition - filePosition); + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::SetPosition Movable Cache Overlap, adjusting size cap %d size %d" + , this, (int32)capacity, usableSize)); + break; + } + } + } + } + } + return 0; +} + +/** + * PrepRead + * + * Prepare to read from this cache. + * + * @param + * + * @return 0 if successful and a non-zero value otherwise + */ +int32 OsclFileCacheBuffer::PrepRead() +{ + //Prep for a read operation. If there is no readable data at current + //position, this will re-fill from end of usable data to end of cache. + if (endPos <= currentPos + && endPos < usableSize) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::PrepRead refilling cache", this)); + + return FillFromFile(endPos, usableSize); + } + return 0; +} + +/** + * PrepWrite + * + * Prepare to write into this cache + * + * @param + * + * @return 0 if successful and a non-zero value otherwise + */ +int32 OsclFileCacheBuffer::PrepWrite() +{ + //Prep for a write operation. Check for a gap from end of cache data to + //current write position. If there is any gap, then fill by reading from file. + //This ensures that we never have undefined data in the cache. + if (endPos < currentPos) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::PrepWrite filling gap in cache", this)); + return FillFromFile(endPos, currentPos); + } + return 0; +} + +/** + * FillFromFile + * + * Fills all or part of a cache from the file. + * + * @param aStart, aEnd: range to fill, units 0-based + * offset into cache. + * + * @return 0 if successful and a non-zero value otherwise + */ +int32 OsclFileCacheBuffer::FillFromFile(uint32 aStart, uint32 aEnd) +{ + OSCL_ASSERT(aStart < aEnd); + + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::FillFromFile fp %d start %d end %d", this, (int32)filePosition, aStart, aEnd)); + + //we are going to refill this cache from aStart to aEnd position. + //first make sure we do not lose any writes in the cache. + if (IsUpdated() + && updateStart <= aStart + && aStart < updateEnd) + { + //the fill area overlaps some updates, so flush them + int32 result = WriteUpdatesToFile(); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::FillFromFile ERROR WriteUpdatesToFile failed", this)); + return result;//error! + } + } + + TOsclFileOffset newpos = filePosition + aStart; + + if (iContainer->_nativePosition != newpos) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::FillFromFile CallingNativeSeek : %d", this, (int32)newpos)); + int32 result = iContainer->iContainer.CallNativeSeek(newpos, Oscl_File::SEEKSET); + if (result != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::FillFromFile ERROR CallNativeSeek failed", this)); + return result;//error! + } + + //keep track of the native file position + iContainer->_nativePosition = newpos; + } + + //Fill from aStart to aEnd We may hit EOF. + uint32 size = aEnd - aStart; + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::FillFromFile CallingNativeRead : %d", this, (int32)size)); + int32 nread = iContainer->iContainer.CallNativeRead((void*)(pBuffer + aStart), 1, size); + + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::FillFromFile got %d bytes", this, nread)); + + //update end pos + endPos = aStart + nread; + + //update native position + iContainer->_nativePosition += nread; + + //When reading to EOF in append mode, a subsequent native write will fail. + //Seeking to the EOF point after the read fixes it. Odd. + if (iContainer->_mode & Oscl_File::MODE_APPEND + && iContainer->_nativePosition >= iContainer->_fileSize) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::FillFromFile CallingNativeSeek : %d", this, (int32)iContainer->_nativePosition)); + int32 retval = iContainer->iContainer.CallNativeSeek(iContainer->_nativePosition, Oscl_File::SEEKSET); + if (retval != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::FillFromFile ERROR CallNativeSeek failed", this)); + return retval;//error! + } + } + + //It's possible read may fail, even when filesize suggests there is data. + //This has been observed in cases where a binary file is opened in text mode. + //It could also occur due to other errors. This results in seek position being + //past the end of readable data. This is an invalid state for the cache, so + //flag an error. It doesn't make sense to move the current position backward, + //because the Seek call has already succeeded. + if (endPos < currentPos) + { + return (-1); + } + + return 0; +} + + +/** + * WriteUpdatesToFile + * + * Writes any updated data in the cache to disk, but does not + * otherwise alter cache position or contents. Existing cache + * data is still available for read. + * + * Has a side effect of adjusting the native file position. + * + * @param void + * + * @return 0 if successful and a non-zero value otherwise + */ +int32 OsclFileCacheBuffer::WriteUpdatesToFile() +{ + if (updateEnd > updateStart) + { + uint32 bytesToWrite = (updateEnd - updateStart); + + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::WriteUpdatesToFile nbytes %d filepos %d start %d end %d " + , this, bytesToWrite, filePosition, updateStart, updateEnd)); + + //Seek to the correct write location in the file if needed + + TOsclFileOffset pos = filePosition + updateStart; + + if (iContainer->_nativePosition != pos) + { + if (iContainer->_mode & Oscl_File::MODE_APPEND) + { + //In Append mode, writes automatically happen at the end of file so there is no + //need to seek. + ; + } + else + { + //seek to the write location + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::WriteUpdatesToFile CallingNativeSeek : %d", this, (int32) pos)); + int32 retval = iContainer->iContainer.CallNativeSeek(pos, Oscl_File::SEEKSET); + if (retval != 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::WriteUpdatesToFile ERROR CallNativeSeek failed", this)); + return retval;//error! + } + } + + iContainer->_nativePosition = pos; + } + + //write the updated data range. + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::WriteUpdatesToFile CallingNativeWrite : %d", this, (int32) bytesToWrite)); + int32 retval = iContainer->iContainer.CallNativeWrite(pBuffer + updateStart, 1, bytesToWrite); + + //keep track of the native file position. + iContainer->_nativePosition += retval; + + //clear the updated data range. + updateStart = updateEnd = 0; + + if ((uint32)retval == bytesToWrite) + return 0;//success! + + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, + (0, "OsclFileCache(0x%x)::WriteUpdatesToFile ERROR CallNativeWrite only wrote %d of %d", this, retval, bytesToWrite)); + + /* + //At this point, the cache is corrupt, since we lost data. + //Recover by checking actual native file values, emptying the cache, + //and locating it as close as possible to the desired position. + iContainer->_fileSize = iContainer->iContainer.CallNativeSize(); + iContainer->_nativePosition = iContainer->iContainer.CallNativeTell(); + TOsclFileOffset newpos = iContainer->Tell(); + if (newpos > iContainer->_fileSize) + newpos = iContainer->_fileSize; + SetPosition(newpos); + */ + + return (-1); //error + } + return 0;//success-- nothing to do +} + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_cache.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_cache.h new file mode 100644 index 0000000..78f0e0a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_cache.h @@ -0,0 +1,188 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ F I L E _ C A C H E + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_file_cache.h + \brief The file oscl_file_cache.h defines the class OsclFileCache + +*/ + +#ifndef OSCL_FILE_CACHE_H_INCLUDED +#define OSCL_FILE_CACHE_H_INCLUDED + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#include "osclconfig_io.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#include "oscl_file_io.h" + +class OsclFileCache; + +class OsclFileCacheBuffer +{ + public: + OsclFileCacheBuffer(): isFixed(false) + , capacity(0) + , usableSize(0) + , pBuffer(NULL) + , filePosition(0) + , currentPos(0) + , endPos(0) + , updateStart(0) + , updateEnd(0) + {} + + OsclFileCache* iContainer; + + //Movable or fixed cache? + bool isFixed; + + //Capacity of the cache buffer + uint32 capacity; + + //Usable size of the cache buffer (may be l.t. its capacity) + uint32 usableSize; + + //constant pointer to cache buffer + uint8* pBuffer; + + //the native file position corresponding to the start of the + //cache + TOsclFileOffset filePosition; + + //current working position (virtual file pointer) in the cache. + //units: 0-based byte offset from beginning of cache + uint32 currentPos; + + //end of valid data in the cache. + //units: 0-based byte offset from beginning of cache + uint32 endPos; + + //variables to track the range of data in the cache that + //has been updated by write operations, but has not yet + //been written to disk. + //units: 0-based byte offset from beginning of cache + uint32 updateStart; + uint32 updateEnd; + + int32 SetPosition(TOsclFileOffset pos); + int32 PrepRead(); + int32 PrepWrite(); + int32 WriteUpdatesToFile(); + int32 FillFromFile(uint32, uint32); + + bool IsUpdated() + { + return updateEnd > updateStart; + } + + //return true if this cache contains the input position. + bool Contains(TOsclFileOffset pos) + { + return (filePosition <= pos && pos < filePosition + (TOsclFileOffset)usableSize); + } + //return true if this cache preceeds the input position. + bool Preceeds(TOsclFileOffset pos) + { + return (filePosition + (TOsclFileOffset)usableSize <= pos); + } +}; + +class Oscl_File; + +class OsclFileCache : public HeapBase +{ + public: + OsclFileCache(Oscl_File& aContainer); + ~OsclFileCache(); + + int32 Open(uint32 mode, uint32 cache_size); + + void Close(); + + uint32 Read(void* outputBuffer, uint32 size, uint32 numelements); + + uint32 Write(const void* inputBuffer, uint32 size, uint32 numelements); + + TOsclFileOffset FileSize() + { + return _fileSize; + } + + int32 Seek(TOsclFileOffset offset, Oscl_File::seek_type origin); + + TOsclFileOffset Tell() + { + return (_curCache) ? (_curCache->filePosition + _curCache->currentPos) : 0; + } + + int32 Flush(); + + int32 EndOfFile() + { + return (Tell() == FileSize()) ? 1 : 0; + } + + private: + friend class OsclFileCacheBuffer; + Oscl_File& iContainer; + + //file mode from the Open call. + uint32 _mode; + + public: + OsclFileCacheBuffer _movableCache; + Oscl_Vector _fixedCaches; + OSCL_IMPORT_REF OsclFileCacheBuffer* AddFixedCache(const Oscl_File::OsclFixedCacheParam&); + + private: + OsclFileCacheBuffer* _curCache; + int32 SetCachePosition(TOsclFileOffset); + int32 UpdateFixedCaches(); + + //Current file size. This is a virtual file size and + //may not match the native file size when there is + //cached data. + TOsclFileOffset _fileSize; + + //Current true native file position. + TOsclFileOffset _nativePosition; + + PVLogger* iLogger; +}; + + +#endif // OSCL_FILE_CACHE_H_INCLUDED + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_dir_utils.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_dir_utils.cpp new file mode 100644 index 0000000..394c588 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_dir_utils.cpp @@ -0,0 +1,278 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \file oscl_file_io.cpp + \brief This file contains file io APIs +*/ + +#ifndef OSCL_FILE_DIR_UTILS_H_INCLUDED +#include "oscl_file_dir_utils.h" +#endif +#ifndef OSCL_FILE_TYPES_H_INCLUDED +#include "oscl_file_types.h" +#endif +#ifndef OSCL_UTF8CONV_H +#include "oscl_utf8conv.h" +#endif +#ifndef OSCL_STDSTRING_H_INCLUDED +#include "oscl_stdstring.h" +#endif +#ifndef OSCL_INT64_UTILS_H_INCLUDED +#include "oscl_int64_utils.h" +#endif +#ifndef OSCL_FILE_IO_H_INCLUDED +#include "oscl_file_io.h" +#endif +#ifndef OSCLCONFIG_ERROR_H_INCLUDED +#include "osclconfig_error.h" +#endif +#ifndef OSCL_FILE_DIR_UTILS_H_INCLUDED +#include "oscl_file_dir_utils.h" +#endif +#ifndef OSCL_MEM_BASIC_FUNCTIONS_H +#include "oscl_mem_basic_functions.h" +#endif +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#include "oscl_string_containers.h" +#endif + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_getcwd(char *path, uint32 size) +{ + if (getcwd(path, size) != NULL) + return OSCL_FILEMGMT_E_OK; + return OSCL_FILEMGMT_E_PATH_NOT_FOUND; +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_getcwd(oscl_wchar *path, uint32 size) +{ + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (oscl_getcwd(convpathname, size > OSCL_IO_FILENAME_MAXLEN ? OSCL_IO_FILENAME_MAXLEN : size) == OSCL_FILEMGMT_E_OK) + { + if (0 == oscl_UTF8ToUnicode(convpathname, oscl_strlen(convpathname), path, size) && oscl_strlen(convpathname) != 0) + { + return OSCL_FILEMGMT_E_PATH_TOO_LONG; + } + return OSCL_FILEMGMT_E_OK; + } + return OSCL_FILEMGMT_E_PATH_NOT_FOUND; +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_stat(const oscl_wchar *path, OSCL_STAT_BUF *statbuf) +{ + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(path, oscl_strlen(path), convpathname, OSCL_IO_FILENAME_MAXLEN) && oscl_strlen(path) != 0) + { + return OSCL_FILEMGMT_E_PATH_TOO_LONG; + } + return oscl_stat(convpathname, statbuf); + + +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_stat(const char *path, OSCL_STAT_BUF *statbuf) +{ + oscl_memset(statbuf, 0, sizeof(OSCL_STAT_BUF)); + struct stat buf; + if (stat(path, &buf) == 0) + { + if (buf.st_mode & S_IRUSR) + statbuf->perms |= OSCL_FILEMGMT_PERMS_READ; + if (buf.st_mode & S_IWUSR) + statbuf->perms |= OSCL_FILEMGMT_PERMS_WRITE; + if (buf.st_mode & S_IFDIR) + statbuf->mode |= OSCL_FILEMGMT_MODE_DIR; + return OSCL_FILEMGMT_E_OK; + } + return OSCL_FILEMGMT_E_PATH_NOT_FOUND; +} + + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_statfs(OSCL_FSSTAT *stats, const char *path) +{ + struct statfs fs_stats; + if (statfs(path, &fs_stats) == 0) + { + stats->freebytes = fs_stats.f_bsize * fs_stats.f_bfree; + stats->totalbytes = fs_stats.f_bsize * fs_stats.f_blocks; + return OSCL_FILEMGMT_E_OK; + } + return OSCL_FILEMGMT_E_UNKNOWN; + +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_statfs(OSCL_FSSTAT *stats, const oscl_wchar *path) +{ + oscl_wchar* pMyPath; + oscl_wchar myPathCurrDir[2] = {'.', 0}; + + //if path is blank, pass "." + if ((path[0] == 0)) + pMyPath = myPathCurrDir; + else + pMyPath = (oscl_wchar*)path; + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(pMyPath, oscl_strlen(pMyPath), convpathname, OSCL_IO_FILENAME_MAXLEN) && + oscl_strlen(path) != 0 + ) + { + return OSCL_FILEMGMT_E_PATH_TOO_LONG; + } + return oscl_statfs(stats, convpathname); + +} + + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_mkdir(const oscl_wchar *path) +{ + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(path, oscl_strlen(path), convpathname, OSCL_IO_FILENAME_MAXLEN) && + oscl_strlen(path) != 0) + { + return OSCL_FILEMGMT_E_PATH_TOO_LONG; + } + return oscl_mkdir(convpathname); +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_mkdir(const char *path) +{ + if (mkdir(path, 0775) == 0) + { + return OSCL_FILEMGMT_E_OK; + } + else + { + switch (errno) + { + case EPERM: + case EACCES: + return OSCL_FILEMGMT_E_PERMISSION_DENIED; + break; + case EEXIST: + return OSCL_FILEMGMT_E_ALREADY_EXISTS; + break; + case ENOENT: + case ENOTDIR: + return OSCL_FILEMGMT_E_PATH_NOT_FOUND; + default: + break; + } + } + return OSCL_FILEMGMT_E_UNKNOWN; +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rmdir(const oscl_wchar *path) +{ + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(path, oscl_strlen(path), convpathname, OSCL_IO_FILENAME_MAXLEN) && + oscl_strlen(path) != 0) + { + return OSCL_FILEMGMT_E_PATH_TOO_LONG; + } + return oscl_rmdir(convpathname); +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rmdir(const char *path) +{ + if (rmdir(path) == 0) + { + return OSCL_FILEMGMT_E_OK; + } + else + { + switch (errno) + { + case EPERM: + return OSCL_FILEMGMT_E_PERMISSION_DENIED; + case ENOENT: + case ENOTDIR: + return OSCL_FILEMGMT_E_PATH_NOT_FOUND; + case ENOTEMPTY: + return OSCL_FILEMGMT_E_NOT_EMPTY; + default: + break; + } + } + return OSCL_FILEMGMT_E_UNKNOWN; +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_chdir(const oscl_wchar *path) +{ + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(path, oscl_strlen(path), convpathname, OSCL_IO_FILENAME_MAXLEN) && + oscl_strlen(path) != 0) + { + return OSCL_FILEMGMT_E_PATH_TOO_LONG; + } + return oscl_chdir(convpathname); +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_chdir(const char *path) +{ + if (chdir(path) == 0) + { + return OSCL_FILEMGMT_E_OK; + } + else + { + switch (errno) + { + case ENOENT: + case ENOTDIR: + return OSCL_FILEMGMT_E_PATH_NOT_FOUND; + case EACCES: + return OSCL_FILEMGMT_E_PERMISSION_DENIED; + default: + break; + } + } + return OSCL_FILEMGMT_E_UNKNOWN; +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rename(const oscl_wchar *oldpath, const oscl_wchar *newpath) +{ + char oldconvpathname[OSCL_IO_FILENAME_MAXLEN]; + char newconvpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(oldpath, oscl_strlen(oldpath), oldconvpathname, OSCL_IO_FILENAME_MAXLEN) || + 0 == oscl_UnicodeToUTF8(newpath, oscl_strlen(newpath), newconvpathname, OSCL_IO_FILENAME_MAXLEN)) + { + return OSCL_FILEMGMT_E_PATH_TOO_LONG; + } + return oscl_rename(oldconvpathname, newconvpathname); +} + +OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rename(const char *oldpath, const char *newpath) +{ + if (rename(oldpath, newpath) == 0) + { + return OSCL_FILEMGMT_E_OK; + } + else + { + switch (errno) + { + case EISDIR: + case EEXIST: + case ENOTEMPTY: + return OSCL_FILEMGMT_E_ALREADY_EXISTS; + case ENOTDIR: + return OSCL_FILEMGMT_E_PATH_NOT_FOUND; + default: + break; + } + } + return OSCL_FILEMGMT_E_UNKNOWN; +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_dir_utils.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_dir_utils.h new file mode 100644 index 0000000..e05bcff --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_dir_utils.h @@ -0,0 +1,210 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ F I L E _ Dir _ utils + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_file_dir_utils.h + \brief The file oscl_file_dir_utils.h defines some unix-style directory ops + +*/ + +#ifndef OSCL_FILE_DIR_UTILS_H_INCLUDED +#define OSCL_FILE_DIR_UTILS_H_INCLUDED + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#include "osclconfig_io.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + + + +typedef struct oscl_fsstat +{ + uint64 freebytes; + uint64 totalbytes; +} OSCL_FSSTAT; + +typedef enum +{ + OSCL_FILEMGMT_PERMS_READ = 0x1, + OSCL_FILEMGMT_PERMS_WRITE = 0x2, + OSCL_FILEMGMT_PERMS_EXECUTE = 0x4, +} OSCL_FILEMGMT_PERMS; + +typedef enum +{ + OSCL_FILEMGMT_MODE_DIR = 0x1 +} OSCL_FILEMGMT_MODES; + +typedef struct oscl_stat_buf +{ + uint32 mode; + uint32 perms; +} OSCL_STAT_BUF; + +typedef enum +{ + OSCL_FILEMGMT_E_OK = 0, + OSCL_FILEMGMT_E_PATH_TOO_LONG, + OSCL_FILEMGMT_E_PATH_NOT_FOUND, + OSCL_FILEMGMT_E_ALREADY_EXISTS, + OSCL_FILEMGMT_E_NOT_EMPTY, + OSCL_FILEMGMT_E_PERMISSION_DENIED, + OSCL_FILEMGMT_E_NO_MATCH, + OSCL_FILEMGMT_E_UNKNOWN, + OSCL_FILEMGMT_E_SYS_SPECIFIC, + OSCL_FILEMGMT_E_NOT_IMPLEMENTED +} OSCL_FILEMGMT_ERR_TYPE; + +/** + * oscl_getcwd function can be used to determine the full path name of the + * current directory. + * @param pointer to wide character buffer to receive the current directory + * @param size size of buffer in wide characters + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_getcwd(oscl_wchar *path, uint32 size); + + +/** + * oscl_getcwd function can be used to determine the full path name of the + * current directory. + * @param pointer to character buffer to receive the current directory + * @param size size of buffer in characters + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_getcwd(char *path, uint32 size); + + + +/** + * oscl_stat function can be used to determine the attributes of a file + * in addition to whether the file exists or not + * @param wide character path the full path of the file to stat. + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_stat(const oscl_wchar *path, OSCL_STAT_BUF *statbuf); + + +/** + * oscl_stat function can be used to determine the attributes of a file + * in addition to whether the file exists or not + * @param character path the full path of the file to stat. + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_stat(const char *path, OSCL_STAT_BUF *statbuf); + + +/** + * oscl_mkdir function creates a directory in the path given + * @param wide character path the full path of the directory to create. if parts + * of the path do not exist the function will fail + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_mkdir(const oscl_wchar *path); + +/** + * oscl_mkdir function creates a directory in the path given + * @param character path the full path of the directory to create. if parts + * of the path do not exist the function will fail + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_mkdir(const char *path); + +/** + * oscl_rmdir function removes and empty directory in the path given + * @param wide character path the full path of the directory to remove. + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rmdir(const oscl_wchar *path); + +/** + * oscl_rmdir removes an empty directory in the path given + * @param character path the full path of the directory to remove. + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rmdir(const char *path); + +/** + * oscl_chdir changes the current directory to the path given + * @param wide character path the full path of the directory to change to. + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_chdir(const oscl_wchar *path); + +/** + * oscl_chdir changes the current directory to the path given + * @param character path the full path of the directory to change to. + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_chdir(const char *path); + +/** + * oscl_rename function renames a file or directory + * @param wide character path the full path of the file or directory + * to rename. + * @param wide character path the full path the new name for the directory + * + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ + +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rename(const oscl_wchar *oldpath, const oscl_wchar *newpath); + +/** + * oscl_rmdir removes an empty directory in the path given + * @param character path the full path of the directory to remove. + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ + +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rename(const char *oldpath, const char *newpath); + +/** + * Oscl_StatFS function populates a general structure describing free space available on a filesystem + * @param stats pointer to structure to hold information + * @param path located in desired filesystem (utf8) + * Note: If the OS does not support a particular field in the structure, it is set to -1. + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_statfs(OSCL_FSSTAT *stats, const char *path); +/** + * Oscl_StatFS function populates a general structure describing free space available on a filesystem + * @param stats pointer to structure to hold information + * @param path located in desired filesystem (utf8) + * Note: If the OS does not support a particular field in the structure, it is set to -1. + * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. + */ +OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_statfs(OSCL_FSSTAT *stats, const oscl_wchar *path); + + +#endif // OSCL_FILE_DIR_UTILS_H_INCLUDED + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_find.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_find.cpp new file mode 100644 index 0000000..cb7e6b5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_find.cpp @@ -0,0 +1,526 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \file oscl_file_io.cpp + \brief This file contains file io APIs +*/ + +#include "oscl_file_find.h" +#include "oscl_utf8conv.h" +#include "oscl_stdstring.h" +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#include "oscl_string_containers.h" +#endif + +OSCL_EXPORT_REF Oscl_FileFind::Oscl_FileFind() +{ + lastError = Oscl_FileFind::E_OK; +#if ! OSCL_HAS_GLOB +#define OSCL_FILEFIND_NUMBER_OF_FILES_ENTRY 256 + int err = 0; + OSCL_TRY(err, + iDirEntVec.reserve(OSCL_FILEFIND_NUMBER_OF_FILES_ENTRY); + ); + if (err) + { + iDirEntVec.clear(); + OSCL_LEAVE(err); + lastError = Oscl_FileFind::E_OTHER; + } +#endif + delimeter = OSCL_FILE_CHAR_PATH_DELIMITER; + nullchar = _STRLIT_CHAR("\0"); + count = 0; + foundfirst = false; + appendPathDelimiter = false; + pathname = NULL; + type = Oscl_FileFind::INVALID_TYPE; +} + +OSCL_EXPORT_REF Oscl_FileFind::~Oscl_FileFind() +{ + + Close(); +} + +static bool oscl_strglob(const char *str, const char *p); +OSCL_EXPORT_REF const char *Oscl_FileFind::FindFirst(const char *directory, const char *pattern, char *buf, uint32 buflen) +{ + const char *def_pattern = "*"; + lastError = Oscl_FileFind::E_OK; + type = Oscl_FileFind::INVALID_TYPE; + if (directory == NULL || buf == NULL || buflen <= 0) + { + lastError = Oscl_FileFind::E_INVALID_ARG; + return NULL; + } + if (pattern == NULL) pattern = def_pattern; + if (foundfirst) + { + lastError = Oscl_FileFind::E_INVALID_STATE; + return NULL; + } +#if (OSCL_HAS_GLOB) + if (!setpathanddelimiter(directory)) + return NULL; + int retval; + OSCL_HeapString path(pathname); + path += pattern; + + if ((retval = glob(path.get_cstr(), GLOB_ERR | GLOB_NOSORT , NULL, &hFind)) == 0) + { + foundfirst = true; + if (hFind.gl_pathc > 0) + { + if (strlen(hFind.gl_pathv[count]) > buflen) + { + lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL; + return NULL; + } + oscl_strncpy(buf, hFind.gl_pathv[count++], buflen); + struct stat statbuf; + if (stat(buf, &statbuf) == 0) + { + type = (S_ISDIR(statbuf.st_mode)) ? DIR_TYPE : FILE_TYPE; + } + else + { + type = FILE_TYPE; + } + return buf; + } + else + { + Close(); + } + } + else + { + if (GLOB_NOMATCH == retval) + { + lastError = Oscl_FileFind::E_NO_MATCH; + } + else if (GLOB_ABORTED) + { + lastError = Oscl_FileFind::E_PATH_NOT_FOUND; + } + else + { + lastError = Oscl_FileFind::E_OTHER; + } + } +#else + // support linux having no glob.h support in glob pattern matching + if (!setpathanddelimiter(directory)) + return NULL; + DIR* pDir; + struct dirent* pEnt; + uint32 itr = 0; + struct stat statbuf; + if (oscl_strlen(directory) > 0) + { + pDir = opendir(directory); + } + else + { + // empty directory, replaced with searching current dir + // make the behavior consistent with the glob-based implementation + OSCL_HeapString curpath("."); + curpath += OSCL_FILE_CHAR_PATH_DELIMITER; + pDir = opendir(curpath.get_cstr()); + } + if (pDir == NULL) + { + lastError = Oscl_FileFind::E_PATH_NOT_FOUND; + return NULL; + } + // parsing thru dirent structure + while ((pEnt = readdir(pDir)) != NULL) + { + if (oscl_strglob(pEnt->d_name, pattern) && + oscl_strcmp(pEnt->d_name, ".") && + oscl_strcmp(pEnt->d_name, "..")) // excluded out '.' and '..' from readdir + { // pattern matched + buf[0] = *nullchar; + oscl_strcat(buf, pathname); + oscl_strcat(buf, pEnt->d_name); + iDirEntVec.push_back(buf); + // d_type is not all available on all lunix system, using stat() instead + if (itr == 0) + { // first find filetype + if (stat(iDirEntVec[0].get_cstr(), &statbuf) == 0) + { + type = (S_ISDIR(statbuf.st_mode)) ? DIR_TYPE : FILE_TYPE; + } + else + { + type = FILE_TYPE; + } + } + itr++; + } + } + closedir(pDir); + if (iDirEntVec.size()) + { + if (strlen(iDirEntVec[0].get_cstr()) > buflen) + { + lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL; + return NULL; + } + // copy and return the first found element + buf[0] = *nullchar; + oscl_strcat(buf, iDirEntVec[0].get_cstr()); + foundfirst = true; + count = 1; // advance to next element, used for findnext() + return buf; + } + lastError = Oscl_FileFind::E_NO_MATCH; +#endif + return NULL; +} + +OSCL_EXPORT_REF const oscl_wchar *Oscl_FileFind::FindFirst(const oscl_wchar *directory, const oscl_wchar *pattern, oscl_wchar *buf, uint32 buflen) +{ + const oscl_wchar *def_pattern = _STRLIT_WCHAR("*"); + lastError = Oscl_FileFind::E_OK; + type = Oscl_FileFind::INVALID_TYPE; + if (directory == NULL || buf == NULL || buflen <= 0) + { + lastError = Oscl_FileFind::E_INVALID_ARG; + return NULL; + } + if (pattern == NULL) pattern = def_pattern; + if (foundfirst) + { + lastError = Oscl_FileFind::E_INVALID_STATE; + return NULL; + } + // non-symbain OSs are converted to char type FindFirst() + char* convpattern = (char*) OSCL_MALLOC(oscl_strlen(pattern) + 1); + char* convdir = (char*) OSCL_MALLOC(oscl_strlen(directory) + 1); + char* utf8buf = (char*) OSCL_MALLOC(buflen / sizeof(chartype)); + if (!(convpattern && convdir && utf8buf)) + { + lastError = Oscl_FileFind::E_MEMORY_ERROR; + OSCL_FREE(convdir); + OSCL_FREE(convpattern); + OSCL_FREE(utf8buf); + return NULL; + } + if ((0 == oscl_UnicodeToUTF8(directory, oscl_strlen(directory), convdir, oscl_strlen(directory) + 1) + && oscl_strlen(directory)) + || (0 == oscl_UnicodeToUTF8(pattern, oscl_strlen(pattern), convpattern, oscl_strlen(pattern) + 1) + && oscl_strlen(pattern))) + { + lastError = Oscl_FileFind::E_PATH_TOO_LONG; + OSCL_FREE(convdir); + OSCL_FREE(convpattern); + OSCL_FREE(utf8buf); + return NULL; + } + const char* retval = FindFirst(convdir, convpattern, utf8buf, (buflen / sizeof(chartype))); + OSCL_FREE(convdir); + OSCL_FREE(convpattern); + if (retval != NULL) + { + int32 err = oscl_UTF8ToUnicode(retval, oscl_strlen(retval), buf, buflen); + OSCL_FREE(utf8buf); + if (!err && oscl_strlen(retval)) + { + lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL; + return NULL; + } + return buf; + } + OSCL_FREE(utf8buf); + return NULL; +} + +OSCL_EXPORT_REF char *Oscl_FileFind::FindNext(char *buf, uint32 buflen) +{ + lastError = Oscl_FileFind::E_OK; + type = Oscl_FileFind::INVALID_TYPE; + if (!buf || buflen <= 0) + { + lastError = Oscl_FileFind::E_INVALID_ARG; + return NULL; + } + if (!foundfirst) + { + lastError = Oscl_FileFind::E_INVALID_STATE; + return NULL; + } +#if (OSCL_HAS_GLOB) + if (count >= hFind.gl_pathc) + { + lastError = Oscl_FileFind::E_NO_MATCH; + return NULL; + } + if (oscl_strlen(hFind.gl_pathv[count]) > buflen) + { + lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL; + } + else + { + oscl_strncpy(buf, hFind.gl_pathv[count++], buflen); + struct stat statbuf; + if (stat(buf, &statbuf) == 0) + { + type = (S_ISDIR(statbuf.st_mode)) ? DIR_TYPE : FILE_TYPE; + } + else + { + type = FILE_TYPE; + } + return buf; + } +#else + if (count >= iDirEntVec.size()) + { + lastError = Oscl_FileFind::E_NO_MATCH; + return NULL; + } + if (oscl_strlen(iDirEntVec[count].get_cstr()) > buflen) + { + lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL; + } + else + { + buf[0] = *nullchar; + oscl_strcat(buf, iDirEntVec[count++].get_cstr()); + struct stat statbuf; + if (stat(buf, &statbuf) == 0) + { + type = (S_ISDIR(statbuf.st_mode)) ? DIR_TYPE : FILE_TYPE; + } + else + { + type = FILE_TYPE; + } + return buf; + } +#endif + return NULL; +} + +OSCL_EXPORT_REF oscl_wchar *Oscl_FileFind::FindNext(oscl_wchar *buf, uint32 buflen) +{ + lastError = Oscl_FileFind::E_OK; + type = Oscl_FileFind::INVALID_TYPE; + if (!buf || buflen <= 0) + { + lastError = Oscl_FileFind::E_INVALID_ARG; + return NULL; + } + if (!foundfirst) + { + lastError = Oscl_FileFind::E_INVALID_STATE; + return NULL; + } + char* utf8buf = (char*) OSCL_MALLOC(buflen * sizeof(chartype)); + if (!utf8buf) + { + lastError = Oscl_FileFind::E_MEMORY_ERROR; + return NULL; + } + const char* retval = FindNext(utf8buf, buflen * sizeof(chartype)); + if (retval != NULL) + { + int32 err = oscl_UTF8ToUnicode(retval, oscl_strlen(retval), buf, buflen); + OSCL_FREE(utf8buf); + if (!err && oscl_strlen(retval)) + { + lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL; + return NULL; + } + return buf; + } + lastError = Oscl_FileFind::E_NO_MATCH; + OSCL_FREE(utf8buf); + return NULL; +} + +OSCL_EXPORT_REF void Oscl_FileFind::Close() +{ +#if (OSCL_HAS_GLOB) + if (foundfirst) + globfree(&hFind); +#else + iDirEntVec.clear(); +#endif + foundfirst = false; + lastError = Oscl_FileFind::E_OK; + count = 0; + appendPathDelimiter = false; + if (pathname) + { + OSCL_FREE(pathname); + pathname = NULL; + } +} + +OSCL_EXPORT_REF Oscl_FileFind::element_type Oscl_FileFind::GetElementType() +{ + return type; +} + +OSCL_EXPORT_REF Oscl_FileFind::error_type Oscl_FileFind::GetLastError() +{ + return lastError; +} + +bool Oscl_FileFind::setpathanddelimiter(const chartype* directory) +{ + if (pathname) + { + lastError = Oscl_FileFind::E_INVALID_STATE; + return false; + } + if (directory[oscl_strlen(directory)-1] != *delimeter && oscl_strlen(directory)) + appendPathDelimiter = true; + if (appendPathDelimiter) + pathname = (chartype*) OSCL_MALLOC((oscl_strlen(directory) + 2) * sizeof(chartype)); + else + pathname = (chartype*) OSCL_MALLOC((oscl_strlen(directory) + 1) * sizeof(chartype)); + if (!pathname) + { + lastError = E_MEMORY_ERROR; + return false; + } + pathname[0] = *nullchar; + oscl_strcat(pathname, directory); + if (appendPathDelimiter) + oscl_strcat(pathname, delimeter); + return true; +} +// globmatch matches pattern strings p from str, follows linux glob.c man spec. +static bool oscl_strglob(const char *str, const char *p) +{ +#define NEGATE '^' /* std cset negation char */ + int negate; + int match; + int c; + + while (*p) + { + if (!*str && *p != '*') + return false; + + switch (c = *p++) + { + + case '*': + while (*p == '*') + p++; + + if (!*p) + return true; + + if (*p != '?' && *p != '[' && *p != '\\') + while (*str && *p != *str) + str++; + + while (*str) + { + if (oscl_strglob(str, p)) + return true; + str++; + } + return false; + + case '?': + if (*str) + break; + return false; + /* + * set specification is inclusive, that is [a-z] is a, z and + * everything in between. this means [z-a] may be interpreted + * as a set that contains z, a and nothing in between. + */ + case '[': + if (*p != NEGATE) + negate = false; + else + { + negate = true; + p++; + } + + match = false; + + while (!match && (c = *p++)) + { + if (!*p) + return false; + if (*p == '-') /* c-c */ + { + if (!*++p) + return false; + if (*p != ']') + { + if (*str == c || *str == *p || + (*str > c && *str < *p)) + match = true; + } + else /* c-] */ + { + if (*str >= c) + match = true; + break; + } + } + else /* cc or c] */ + { + if (c == *str) + match = true; + if (*p != ']') + { + if (*p == *str) + match = true; + } + else + break; + } + } + + if (negate == match) + return false; + /* + * if there is a match, skip past the cset and continue on + */ + while (*p && *p != ']') + p++; + if (!*p++) + return false; + break; + + case '\\': + if (*p) + c = *p++; + default: + if (c != *str) + return false; + break; + + } + str++; + } + + return !*str; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_find.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_find.h new file mode 100644 index 0000000..c1921b4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_find.h @@ -0,0 +1,187 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ F I L E _ FIND + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_file_find.h + \brief The file oscl_file_find.h defines the class Oscl_FileFind + +*/ + +#ifndef OSCL_FILE_FIND_H_INCLUDED +#define OSCL_FILE_FIND_H_INCLUDED + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#include "osclconfig_io.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#include "oscl_string_containers.h" +#endif + +#ifndef OSCL_FILE_TYPES_H_INCLUDED +#include "oscl_file_types.h" +#endif + +/** + * Oscl_FileFind class defines the generic way of finding filesystem elements that match a pattern within a directory + */ + +class Oscl_FileFind +{ + public: + + /** + * Finds first element matching the pattern. + * + * @param directory directory to search (utf8). + * @param pattern wildcard pattern filter (utf8). passing NULL, results in a universal match. + * @param buf buffer for returned pathname (utf8). + * @param buflen size in wide characters of buf. If buf is not large enough to hold the returned string, NULL is returned, and GetLastError is set to E_BUFFER_TOO_SMALL. + * + * @return returns a pointer to buffer supplied, which contains the pathname of the first found element, or NULL otherwise.On a NULL return value, GetLastError() returns a more detailed error. + */ + OSCL_IMPORT_REF const char *FindFirst(const char *directory, const char *pattern, char *buf, uint32 buflen); + /** + * Opens a directory for reading. + * + * @param directory directory to search (utf16). + * @param pattern wildcard pattern filter (utf16). passing NULL, results in a universal match. + * @param buf buffer for returned pathname (utf16). + * @param buflen size in wide characters of buf. If buf is not large enough to hold the returned string, NULL is returned, and GetLastError is set to E_BUFFER_TOO_SMALL. + * + * @return returns a pointer to buffer supplied, which contains the pathname of the first found element, or NULL otherwise. On a NULL return value, GetLastError() returns a more detailed error. + */ + OSCL_IMPORT_REF const oscl_wchar *FindFirst(const oscl_wchar *directory, const oscl_wchar *pattern, oscl_wchar *buf, uint32 buflen); + /** + * Reads the next element in the directory. + * Note: the pointer returned by this function is not persistent and + * should be stored. Its scope is limited to the lifetime of the class. + * @param buf buffer to hold directory name(utf8) + * @param buflen size in wide characters of buf. If buf is not large enough to hold the returned string, NULL is returned, and GetLastError is set to E_BUFFER_TOO_SMALL. + * @return returns a pointer to buffer supplied, which contains the pathname of the next found element, or NULL otherwise. On a NULL return value, GetLastError() returns a more detailed error. + */ + OSCL_IMPORT_REF char *FindNext(char *buf, uint32 buflen); + /** + * Reads the next element in a directory. + * Note: the pointer returned by this function is not persistent and + * should be stored. Its scope is limited to the lifetime of the class. + * @param buf buffer to hold directory name(utf16) + * @param buflen size in wide characters of buf. If buf is not large enough to hold the returned string, NULL is returned, and GetLastError is set to E_BUFFER_TOO_SMALL. + * @return returns a pointer to buffer supplied, which contains the pathname of the next found element, or NULL otherwise. On a NULL return value, GetLastError() returns a more detailed error. + */ + OSCL_IMPORT_REF oscl_wchar *FindNext(oscl_wchar *buf, uint32 buflen); + /** + * closes the handle to directory. + * @return none + */ + OSCL_IMPORT_REF void Close(); + + typedef enum + { + E_OK = 0, + E_INVALID_STATE, + E_INVALID_ARG, + E_PATH_TOO_LONG, + E_PATH_NOT_FOUND, + E_NO_MATCH, + E_BUFFER_TOO_SMALL, + E_NOT_IMPLEMENTED, + E_MEMORY_ERROR, + E_OTHER + } error_type; + + typedef enum + { + FILE_TYPE = 0, /* file */ + DIR_TYPE, /* directory */ + INVALID_TYPE /* no element available */ + } element_type; + + /** + * Returns the element type for the last element returned + * @return see enumeration above for more info. + */ + OSCL_IMPORT_REF element_type GetElementType(); + + + /** + * Returns the error code for the last operation. + * @return see enumeration above for more info. + */ + OSCL_IMPORT_REF error_type GetLastError(); + + /** + * constructor. + * @return none + */ + OSCL_IMPORT_REF Oscl_FileFind(); + /** + * destructor. will deallocate open handles if necessary + * + * @return none + */ + OSCL_IMPORT_REF ~Oscl_FileFind(); + + private: + + typedef char chartype; + bool setpathanddelimiter(const chartype* directory); + +#if (OSCL_HAS_GLOB) + glob_t hFind; +#else + Oscl_Vector, OsclMemAllocator> iDirEntVec; +#endif + uint32 count; + bool foundfirst; + error_type lastError; + element_type type; + bool appendPathDelimiter; + chartype* pathname; + const chartype* delimeter; + const chartype* nullchar; +}; + + +#endif // OSCL_FILE_FIND_H_INCLUDED + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_handle.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_handle.h new file mode 100644 index 0000000..3c2fe53 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_handle.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ F I L E _ HANDLE + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_file_handle.h + \brief The file oscl_file_handle.h defines the class OsclFileHandle + +*/ + +#ifndef OSCL_FILE_HANDLE_H_INCLUDED +#define OSCL_FILE_HANDLE_H_INCLUDED + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#include "osclconfig_io.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + + +/** +** TOsclFileHandle is an OS-native file handle type. +* With a class-based file API such as Symbian, a class ref is used +* as a file handle. +* For most ANSI-style file APIs, a file pointer is used as a +* file handle. +*/ +typedef FILE* TOsclFileHandle; + +/** +** OsclFileHandle is a container for a handle to a previously-opened file. +*/ +class OsclFileHandle +{ + public: + OsclFileHandle(TOsclFileHandle aHandle) + : iHandle(aHandle) + {} + OsclFileHandle(const OsclFileHandle& aHandle) + : iHandle(aHandle.iHandle) + {} + TOsclFileHandle Handle()const + { + return iHandle; + } + private: + TOsclFileHandle iHandle; + friend class Oscl_File; +}; + + +#endif // OSCL_FILE_HANDLE_H_INCLUDED + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_io.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_io.cpp new file mode 100644 index 0000000..c761476 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_io.cpp @@ -0,0 +1,1217 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \file oscl_file_io.cpp + \brief This file contains file io APIs +*/ + +#include "oscl_file_io.h" +#include "oscl_dll.h" +#include "oscl_mem.h" +#include "oscl_file_native.h" +#include "oscl_file_handle.h" +#include "oscl_file_cache.h" +#include "pvlogger.h" +#include "oscl_string_containers.h" +#include "oscl_file_stats.h" +#include "oscl_file_async_read.h" + +#ifndef OSCL_COMBINED_DLL +OSCL_DLL_ENTRY_POINT_DEFAULT() +#endif + + +OSCL_EXPORT_REF Oscl_File::Oscl_File() +{ + Construct(); + + //for back-compatibility, set the old compile-time defaults. + OldCacheDefaults(); +} + +void Oscl_File::Construct() +{ + iOpenFileHandle = NULL; + iLogger = NULL; + iStatsLogger = NULL; + iNativeLogger = NULL; + iAsyncLogger = NULL; + iFileStats = NULL; + iNativeFile = NULL; + iFileCache = NULL; + iIsOpen = false; + iNativeBufferSize = 0; + iNativeAccessMode = 0; + iPVCacheSize = 0; + iAsyncReadBufferSize = 0; + iAsyncFile = NULL; + iCacheObserver = NULL; + + //Create the native file I/O implementation + int32 err; + OSCL_TRY(err, iNativeFile = OSCL_NEW(OsclNativeFile, ());); +} + +//For back-compatibility, this sets cache defaults using the +//compile-switches (if defined). +void Oscl_File::OldCacheDefaults() +{ + + //native file cache enable chooses RFileBuf mode over RFile mode + //for symbian. + + SetNativeAccessMode(ESymbianAccessMode_RfileBuf); + +#if defined(OSCL_FILE_BUFFER_MAX_SIZE) + //native buffer size defaults to max buffer size + + SetNativeBufferSize(OSCL_FILE_BUFFER_MAX_SIZE); +#endif + +#if defined(OSCL_ASYNC_READ_BUFFER_SIZE) + // enable async file read operation + + SetAsyncReadBufferSize(OSCL_ASYNC_READ_BUFFER_SIZE); +#endif + + +} + +//For back-compatibility constructors. +//This sets the cache settings using a combination of the input value +//and the compile-time settings (if defined). +void Oscl_File::OldCacheSelect(uint32 aCacheSize) +{ + uint32 cacheSize = aCacheSize; + + //file buffer max limits the actual cache size when defined. +#if defined(OSCL_FILE_BUFFER_MAX_SIZE) + if (cacheSize > OSCL_FILE_BUFFER_MAX_SIZE) + cacheSize = OSCL_FILE_BUFFER_MAX_SIZE; +#endif + + + //cache option is "off" (or not defined) + + //cache option is "on" + SetNativeBufferSize(cacheSize); + +} + +//This constructor is deprecated, but present for back-compatibility. +OSCL_EXPORT_REF Oscl_File::Oscl_File(uint32 cacheSize) +{ + Construct(); + OldCacheDefaults(); + OldCacheSelect(cacheSize); +} + +//This constructor is deprecated, but present for back-compatibility. +OSCL_EXPORT_REF Oscl_File::Oscl_File(uint32 cacheSize, OsclFileHandle* aHandle) +{ + Construct(); + OldCacheDefaults(); + OldCacheSelect(cacheSize); + SetFileHandle(aHandle); +} + +OSCL_EXPORT_REF Oscl_File::~Oscl_File() +{ + if (iIsOpen) + Close(); + + if (iOpenFileHandle) + OSCL_DELETE(iOpenFileHandle); + iOpenFileHandle = NULL; + + if (iFileCache) + OSCL_DELETE(iFileCache); + iFileCache = NULL; + + if (iAsyncFile) + OsclAsyncFile::Delete(iAsyncFile); + iAsyncFile = NULL; + + if (iNativeFile) + OSCL_DELETE(iNativeFile); + iNativeFile = NULL; + + if (iFileStats) + OSCL_DELETE(iFileStats); + iFileStats = NULL; +} + +OSCL_EXPORT_REF void Oscl_File::SetPVCacheSize(uint32 aSize) +{ + //just save the value now-- it will take effect on the next open. + iPVCacheSize = aSize; +} + +OSCL_EXPORT_REF void Oscl_File::SetAsyncReadBufferSize(uint32 aSize) +{ + //just save the value now-- it will take effect on the next open. + iAsyncReadBufferSize = aSize; + +} + +OSCL_EXPORT_REF void Oscl_File::SetLoggingEnable(bool aEnable) +{ + if (aEnable) + { + iLogger = PVLogger::GetLoggerObject("Oscl_File"); + iNativeLogger = PVLogger::GetLoggerObject("OsclNativeFile"); + iAsyncLogger = PVLogger::GetLoggerObject("OsclAsyncFile"); + } + else + { + iLogger = NULL; + iNativeLogger = NULL; + iAsyncLogger = NULL; + } +} + +OSCL_EXPORT_REF void Oscl_File::SetSummaryStatsLoggingEnable(bool aEnable) +{ + if (aEnable) + { + iStatsLogger = PVLogger::GetLoggerObject("OsclFileStats"); + } + else + { + iStatsLogger = NULL; + } + CreateFileStats(); +} + +void Oscl_File::CreateFileStats() +{ + if (iFileStats) + OSCL_DELETE(iFileStats); + iFileStats = NULL; + if (iStatsLogger) + { + int32 err; + OSCL_TRY(err, iFileStats = OSCL_NEW(OsclFileStats, (this));); + } +} + + +OSCL_EXPORT_REF void Oscl_File::SetNativeAccessMode(uint32 aMode) +{ + //just save the value now-- it will take effect on the next open. + iNativeAccessMode = aMode; +} + +OSCL_EXPORT_REF void Oscl_File::SetNativeBufferSize(int32 aSize) +{ + //just save the value now-- it will take effect on the next open. + iNativeBufferSize = aSize; +} + +OSCL_EXPORT_REF int32 Oscl_File::SetFileHandle(OsclFileHandle* aHandle) +{ + if (iIsOpen) + return -1;//can't reset file handle when file is open. + + if (iOpenFileHandle) + OSCL_DELETE(iOpenFileHandle); + iOpenFileHandle = NULL; + + //make a copy to avoid memory persistence issues + if (aHandle) + { + int32 err; + OSCL_TRY(err, iOpenFileHandle = OSCL_NEW(OsclFileHandle, (*aHandle));); + if (!iOpenFileHandle) + return (-1);//allocation failed. + } + + return 0; +} + + +#include "pvlogger.h" + +int32 Oscl_File::OpenFileCacheOrAsyncBuffer(const char *filename + , const oscl_wchar* wfilename + , uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv) +//open pv cache or async file implementation for the given open mode. +//if cache is not enabled, then cleanup any old implementation. +{ + //use async buffer when read-only mode and iAsyncReadBufferSize is > 0 + bool asyncEnable = ((mode == MODE_READ || mode == MODE_READ + MODE_BINARY) && iAsyncReadBufferSize > 0); + + //use cache when *not* using async file and iPVCacheSize is > 0 + bool cacheEnable = !asyncEnable && (iPVCacheSize > 0); + + if (cacheEnable) + { + //create file cache implementation if needed. + if (!iFileCache) + { + int32 err; + OSCL_TRY(err, iFileCache = OSCL_NEW(OsclFileCache, (*this));); + if (!iFileCache) + return -1;//allocation failed + } + } + else + { + //cleanup any old implementation of file cache + if (iFileCache) + OSCL_DELETE(iFileCache); + iFileCache = NULL; + } + + if (asyncEnable) + { + //async file implementation isn't reusable so destroy + //& re-create it + if (iAsyncFile) + OsclAsyncFile::Delete(iAsyncFile); + iAsyncFile = NULL; + int32 err; + OSCL_TRY(err, iAsyncFile = OsclAsyncFile::NewL(*iNativeFile, iAsyncReadBufferSize, iAsyncLogger);); + if (!iAsyncFile) + return -1;//allocation failed + } + else + { + //cleanup any old implementation of async file. + if (iAsyncFile) + OsclAsyncFile::Delete(iAsyncFile); + iAsyncFile = NULL; + } + + //at this point we have either iFileCache, iAsyncFile, or neither. + + if (iFileCache) + { + return iFileCache->Open(mode, iPVCacheSize); + } + else if (iAsyncFile) + { + if (filename) + return iAsyncFile->Open(filename, mode, params, fileserv); + else if (wfilename) + return iAsyncFile->Open(wfilename, mode, params, fileserv); + else + return -1; + } + else + { + return 0; + } +} + +OSCL_EXPORT_REF int32 Oscl_File::Open(const oscl_wchar *filename, uint32 mode, Oscl_FileServer& fileserv) +{ + if (iLogger) + { + OSCL_wHeapString wstr(filename); + OSCL_HeapString str; + char buf[2]; + buf[1] = '\0'; + for (uint32 i = 0; i < wstr.get_size(); i++) + { + buf[0] = (char)wstr[i]; + str += buf; + } + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Open IN name '%s' mode %d serv 0x%x", this, str.get_cstr(), mode, &fileserv)); + } + + int32 result = (-1); + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + //protect against duplicate open calls + if (iIsOpen) + goto ErrorExit; + + //do native open or attach + { + OsclNativeFileParams params(iNativeAccessMode, iNativeBufferSize, iAsyncReadBufferSize); + if (iOpenFileHandle) + result = CallNativeOpen(*iOpenFileHandle, mode, params, fileserv); + else + result = CallNativeOpen(filename, mode , params, fileserv); + + if (result != 0) + goto ErrorExit; + + //create cache implementation if needed. + result = OpenFileCacheOrAsyncBuffer(NULL, filename, mode, params, fileserv); + } + if (result != 0) + goto ErrorExit; + +ErrorExit: + + if (result == 0) + iIsOpen = true; + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_Open, ticks); + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Open OUT result %d", this, result)); + } + + return result; +} + + +OSCL_EXPORT_REF int32 Oscl_File::Open(const char *filename, uint32 mode, Oscl_FileServer& fileserv) +{ + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Open IN name '%s' mode %d serv 0x%x", this, filename, mode, &fileserv)); + } + + int32 result = (-1); + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + //protect against duplicate open calls + if (iIsOpen) + goto ErrorExit; + + //do native open or attach + { + OsclNativeFileParams params(iNativeAccessMode, iNativeBufferSize, iAsyncReadBufferSize); + if (iOpenFileHandle) + result = CallNativeOpen(*iOpenFileHandle, mode, params, fileserv); + else + result = CallNativeOpen(filename, mode , params, fileserv); + + if (result != 0) + goto ErrorExit; + + //create file cache implementation if needed + result = OpenFileCacheOrAsyncBuffer(filename, NULL, mode, params, fileserv); + } + if (result != 0) + goto ErrorExit; + +ErrorExit: + + if (result == 0) + iIsOpen = true; + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_Open, ticks); + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Open OUT result %d", this, result)); + } + + return result; +} + +OSCL_EXPORT_REF int32 Oscl_File::Close() +{ + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Close IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + if (iIsOpen) + { + if (iFileCache) + iFileCache->Close(); + else if (iAsyncFile) + iAsyncFile->Close(); + + result = CallNativeClose(); + } + + iIsOpen = false; + + if (iFileStats + && result == 0) + { + iFileStats->End(EOsclFileOp_Close, ticks); + iFileStats->LogAll(iStatsLogger, PVLOGMSG_DEBUG); + } + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Close OUT result %d", this, result)); + } + + return result; +} + + +OSCL_EXPORT_REF uint32 Oscl_File::Read(OsclAny *buffer, uint32 size, uint32 numelements) +{ + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Read IN size %d num %d", this, size, numelements)); + } + + if (!size || !numelements || !buffer) + { + OSCL_LEAVE(OsclErrArgument); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + uint32 result = 0; + + if (iIsOpen) + { + if (iFileCache) + result = iFileCache->Read(buffer, size, numelements); + else if (iAsyncFile) + result = iAsyncFile->Read(buffer, size, numelements); + else + result = CallNativeRead(buffer, size, numelements); + } + + if (iFileStats + && result > 0) + iFileStats->End(EOsclFileOp_Read, ticks, result*size); + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Read OUT result %d", this, result)); + } + return result; +} + + +OSCL_EXPORT_REF uint32 Oscl_File::Write(const OsclAny *buffer, uint32 size, uint32 numelements) +{ + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Write IN size %d num %d", this, size, numelements)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + uint32 result = 0; + + if (iIsOpen) + { + if (iFileCache) + result = iFileCache->Write(buffer, size, numelements); + else if (iAsyncFile) + return iAsyncFile->Write(buffer, size, numelements); + else + result = CallNativeWrite(buffer, size, numelements); + } + + if (iFileStats + && result > 0) + iFileStats->End(EOsclFileOp_Write, ticks, result*size); + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Write OUT result %d", this, result)); + } + return result; +} + +OSCL_EXPORT_REF int32 Oscl_File::Seek(TOsclFileOffset offset, seek_type origin) +{ + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Seek IN offset %d origin %d", this, offset, origin)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + if (iIsOpen) + { + if (iFileCache) + result = iFileCache->Seek(offset, origin); + else if (iAsyncFile) + result = iAsyncFile->Seek(offset, origin); + else + result = CallNativeSeek(offset, origin); + } + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_Seek, ticks, origin, offset); + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Seek OUT result %d", this, result)); + } + return result; +} + + +OSCL_EXPORT_REF TOsclFileOffset Oscl_File::Tell() +{ + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Tell IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + TOsclFileOffset result = (-1); + + if (iIsOpen) + { + if (iFileCache) + result = iFileCache->Tell(); + else if (iAsyncFile) + result = iAsyncFile->Tell(); + else + result = CallNativeTell(); + } + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_Tell, ticks); + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Tell OUT result %d", this, result)); + } + return result; +} + +OSCL_EXPORT_REF int32 Oscl_File::SetSize(uint32 size) +{ + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::SetSize IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + if (iIsOpen) + { + if (iFileCache) + { + // do nothing. NOT SUPPORTED + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "SetSize() not implemented with File Cache ON")); + } + } + else if (iAsyncFile) + { + // do nothing. NOT SUPPORTED + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "SetSize() not implemented for AsyncFile")); + } + + } + else + result = CallNativeSetSize(size); + } + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_SetSize, ticks); + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::SetSize OUT result %d", this, result)); + } + return result; +} + +OSCL_EXPORT_REF int32 Oscl_File::Flush() +{ + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Flush IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + if (iIsOpen) + { + if (iFileCache) + result = iFileCache->Flush(); + else if (iAsyncFile) + return iAsyncFile->Flush(); + else + result = CallNativeFlush(); + } + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_Flush, ticks); + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Flush OUT result %d", this, result)); + } + return result; +} + + +OSCL_EXPORT_REF int32 Oscl_File::EndOfFile() +{ + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::EndOfFile IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + if (iIsOpen) + { + if (iFileCache) + result = iFileCache->EndOfFile(); + else if (iAsyncFile) + result = iAsyncFile->EndOfFile(); + else + result = CallNativeEndOfFile(); + } + + if (iFileStats + && result != (-1)) + iFileStats->End(EOsclFileOp_EndOfFile, ticks); + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::EndOfFile OUT result %d", this, result)); + } + return result; +} + +OSCL_EXPORT_REF TOsclFileOffset Oscl_File::Size() +{ + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Size IN")); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + TOsclFileOffset result = (-1); + + if (iIsOpen) + { + if (iFileCache) + result = iFileCache->FileSize(); + else if (iAsyncFile) + result = iAsyncFile->Size(); + else + result = CallNativeSize(); + } + + if (iFileStats + && result != (-1)) + iFileStats->End(EOsclFileOp_Size, ticks); + + if (iLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "Oscl_File(0x%x)::Size OUT result %d", this, result)); + } + return result; +} + +OSCL_EXPORT_REF int32 Oscl_File::GetError() +{ + return CallNativeGetError(); +} + +int32 Oscl_File::CallNativeOpen(const OsclFileHandle& handle, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv) +{ + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Open IN handle 0x%x mode %d serv 0x%x", this, &handle, mode, &fileserv)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + if (iNativeFile) + result = iNativeFile->Open(handle, mode, params, fileserv); + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_NativeOpen, ticks); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Open OUT result %d", this, result)); + } + + return result; +} + +int32 Oscl_File::CallNativeOpen(const oscl_wchar *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv) +{ + OSCL_UNUSED_ARG(params); + + if (iNativeLogger) + { + OSCL_wHeapString wstr(filename); + OSCL_HeapString str; + char buf[2]; + buf[1] = '\0'; + for (uint32 i = 0; i < wstr.get_size(); i++) + { + buf[0] = (char)wstr[i]; + str += buf; + } + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Open IN name '%s' mode %d serv 0x%x", this, str.get_cstr(), mode, &fileserv)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + { + OsclNativeFileParams params(iNativeAccessMode, iNativeBufferSize, iAsyncReadBufferSize); + if (iNativeFile) + result = iNativeFile->Open(filename, mode, params, fileserv); + } + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_NativeOpen, ticks); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Open OUT result %d", this, result)); + } + + return result; +} + +int32 Oscl_File::CallNativeOpen(const char *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv) +{ + OSCL_UNUSED_ARG(params); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Open IN name '%s' mode %d serv 0x%x", this, filename, mode, &fileserv)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + { + OsclNativeFileParams params(iNativeAccessMode, iNativeBufferSize, iAsyncReadBufferSize); + if (iNativeFile) + result = iNativeFile->Open(filename, mode, params, fileserv); + } + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_NativeOpen, ticks); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Open OUT result %d", this, result)); + } + + return result; +} + +uint32 Oscl_File::CallNativeRead(OsclAny *buffer, uint32 size, uint32 numelements) +{ + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Read IN size %d numelements %d", this, size, numelements)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = 0; + + if (iNativeFile) + result = iNativeFile->Read(buffer, size, numelements); + + if (iFileStats + && result > 0) + iFileStats->End(EOsclFileOp_NativeRead, ticks, result*size); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Read OUT result %d", this, result)); + } + + return result; +} + +uint32 Oscl_File::CallNativeWrite(const OsclAny *buffer, uint32 size, uint32 numelements) +{ + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Write IN size %d numelements %d", this, size, numelements)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = 0; + + if (iNativeFile) + result = iNativeFile->Write(buffer, size, numelements); + + if (iFileStats + && result > 0) + iFileStats->End(EOsclFileOp_NativeWrite, ticks, result*size); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Write OUT result %d", this, result)); + } + + return result; +} + +int32 Oscl_File::CallNativeSeek(TOsclFileOffset offset, Oscl_File::seek_type origin) +{ + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Seek IN offset %d origin %d", this, offset, origin)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + if (iNativeFile) + result = iNativeFile->Seek(offset, origin); + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_NativeSeek, ticks, origin, offset); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Seek OUT result %d", this, result)); + } + + return result; +} + +TOsclFileOffset Oscl_File::CallNativeTell() +{ + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Tell IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + TOsclFileOffset result = (-1); + + if (iNativeFile) + result = iNativeFile->Tell(); + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_NativeTell, ticks); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Tell OUT result %d", this, result)); + } + + return result; +} + +int32 Oscl_File::CallNativeSetSize(uint32 size) +{ + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::SetSize IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + if (iNativeFile) + result = iNativeFile->SetSize(size); + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_NativeSetSize, ticks); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::SetSize OUT result %d", this, result)); + } + + return result; +} + +int32 Oscl_File::CallNativeFlush() +{ + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Flush IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + if (iNativeFile) + result = iNativeFile->Flush(); + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_NativeFlush, ticks); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Flush OUT result", this, result)); + } + + return result; +} + +int32 Oscl_File::CallNativeEndOfFile() +{ + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::EndOfFile IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + if (iNativeFile) + result = iNativeFile->EndOfFile(); + + if (iFileStats + && result == 0) + iFileStats->End(EOsclFileOp_NativeEndOfFile, ticks); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::EndOfFile OUT result", this, result)); + } + + return result; +} + +TOsclFileOffset Oscl_File::CallNativeSize() +{ + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Size IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + TOsclFileOffset result = (-1); + + if (iNativeFile) + result = iNativeFile->Size(); + + if (iFileStats + && result >= 0) + iFileStats->End(EOsclFileOp_NativeSize, ticks); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Size OUT result", this, result)); + } + + return result; +} + +int32 Oscl_File::CallNativeClose() +{ + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Close IN", this)); + } + + uint32 ticks = 0; + if (iFileStats) + iFileStats->Start(ticks); + + int32 result = (-1); + + if (iNativeFile) + result = iNativeFile->Close(); + + if (iFileStats + && result >= 0) + iFileStats->End(EOsclFileOp_NativeClose, ticks); + + if (iNativeLogger) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG, + (0, "OsclNativeFile(0x%x)::Close OUT result", this, result)); + } + + return result; +} + +uint32 Oscl_File::CallNativeMode() +{ + int32 result = (-1); + + if (iNativeFile) + result = iNativeFile->Mode(); + + return result; +} + +int32 Oscl_File::CallNativeGetError() +{ + int32 result = (-1); + + if (iNativeFile) + result = iNativeFile->GetError(); + + return result; +} + +OSCL_EXPORT_REF uint32 Oscl_File::GetAsyncFileNumOfRun() +{ + if (iAsyncFile) + return iAsyncFile->iNumOfRun; + else + return 0; +} + +OSCL_EXPORT_REF uint32 Oscl_File::GetAsyncFileNumOfRunError() +{ + if (iAsyncFile) + return iAsyncFile->iNumOfRunErr; + else + return 0; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_io.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_io.h new file mode 100644 index 0000000..26ca68c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_io.h @@ -0,0 +1,557 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ F I L E _ I O + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_file_io.h + \brief The file oscl_file_io.h defines the class Oscl_File. This is the + public API to the basic file I/O operations. +*/ + + + +#ifndef OSCL_FILE_IO_H_INCLUDED +#define OSCL_FILE_IO_H_INCLUDED + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#include "osclconfig_io.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +/** + * Oscl_File_IO class defines the generic way of creating all the file object for all the platforms. + * The class defines all the input output files operations like open, close, read, write, seek, tell + * that will be common over various Operating Systems we are supporting. + * It stores an file pointer that is used to access the file, a cache reference depending whether + * cache is supported by the OS + */ +class PVLogger; +class OsclFileCache; +class OsclFileCacheBuffer; +class Oscl_FileServer; +class OsclFileHandle; +class OsclNativeFile; +class OsclFileStats; +class OsclNativeFileParams; +class OsclAsyncFile; +#define TOsclFileOffsetInt32 int32 + +class Oscl_File : public HeapBase +{ + public: + + typedef enum + { + /** + * Beginning of file + */ + SEEKSET, + /** + * Current position of file pointer + */ + SEEKCUR, + /** + * End of file + */ + SEEKEND + } seek_type; + + typedef enum + { + /** + * Opens a file for reading. The file must exist. + */ + MODE_READ = 0x0001, + /** + * Opens the file for reading and writing. If the file exists, + * its contents will be overwritten unless APPEND mode is + * specified. If the file does not exist, it will be created. + */ + MODE_READWRITE = 0x0002, + /** + * Specifies all write operations to occur at the end of the + * file. The file pointer can be moved with the Seek command, + * but will always be moved to the end of the file for write + * commands. + */ + MODE_APPEND = 0x0004, + /** + * Opens the file in 'binary' mode. This is the default. + */ + MODE_BINARY = 0x0008, + /** + * Opens the file in 'text' mode. The default mode is 'binary'. + */ + MODE_TEXT = 0x0010, + /** + * Open a file for reading and writing. The file must exist. + * The default mode is 'binary'. + */ + MODE_READ_PLUS = 0x0020 + + } mode_type; + + /** + * Constructor + */ + OSCL_IMPORT_REF Oscl_File(); + + /** + * Deprecated Constructor, present for back-compatibility. + * @param aCacheSize: sets native buffer size, and when pv cache is enabled, + * also sets pv cache size. + */ + OSCL_IMPORT_REF Oscl_File(uint32 aCacheSize); + /** + * Deprecated Constructor, present for back-compatibility. + * @param aCacheSize: sets native buffer size, and when pv cache is enabled, + * also sets pv cache size. + * @param aFileHandle: open file handle. + */ + OSCL_IMPORT_REF Oscl_File(uint32 aCacheSize, OsclFileHandle* aFileHandle); + + /** + * Destructor + */ + OSCL_IMPORT_REF ~Oscl_File(); + + /** + * SetPVCacheSize configures the read/write cache. + * + * This should be called before opening the file. If used when + * the file is open, the option will not take effect until the + * next Open. + * + * @param aSize: cache size in bytes. Zero disables the cache. + */ + OSCL_IMPORT_REF void SetPVCacheSize(uint32 aSize); + + /** + * Parameters for defining a fixed cache + */ + class OsclFixedCacheParam + { + public: + /* + ** File position where the fixed cache is located. + */ + TOsclFileOffset iFilePosition; + /* + ** Fixed cache size in bytes. + */ + uint32 iSize; + + bool Contains(TOsclFileOffset pos) const + { + return (iFilePosition <= pos && pos < iFilePosition + (TOsclFileOffset)iSize); + } + }; + + /** + * AddFixedCache adds a fixed cache. The fixed cache will + * be used on the next opportunity. + * The fixed cache must not overlap with any other fixed cache. + * + * @param aParam: Cache location and size. + */ + void AddFixedCache(const OsclFixedCacheParam& aParam) + { + iAddFixedCache.push_back(aParam); + } + + /** + * RemoveFixedCache removes a fixed cache. + * + * @param aPos: Cache location and size. + */ + void RemoveFixedCache(const TOsclFileOffset &aPos) + { + iRemoveFixedCache.push_back(aPos); + } + + /** + * For defining a cache observer. Cache observer + * can implement customized cache schemes by replacing the + * SetCachePosition routine. + */ + class OsclCacheObserver + { + public: + virtual ~OsclCacheObserver() {}; + virtual OsclFileCacheBuffer* ChooseCurCache(OsclFileCache& aContext, TOsclFileOffset aPos) = 0; + }; + void SetCacheObserver(OsclCacheObserver* aObs) + { + iCacheObserver = aObs; + } + + /** + * SetNativeAccessMode allows switching between different native file access + * modes, when available. + * + * Note: for For Symbian, use the TSymbianAccessMode values to choose the mode. + * If multiple access modes are not available on the platform, this call will + * have no effect. + * + * @param aMode: access mode. + */ + OSCL_IMPORT_REF void SetNativeAccessMode(uint32 aMode); + + /** + * Defines mode options for SetNativeAccessMode on Symbian. + */ + enum TSymbianAccessMode + { + ESymbianAccessMode_Rfile = 0 + , ESymbianAccessMode_RfileBuf = 1 + }; + + /** + * SetNativeBufferSize configures the native file buffering feature, + * when available. + * + * This should be called before opening the file. If used when + * the file is open, the option will not take effect until the + * next Open. + * + * Note: For Symbian, this sets the RFileBuf cache size. + * If native buffing is not available on the platform, this call + * will have no effect. + * + * @param aSize: native buffer size in bytes. Zero disables the feature. + */ + OSCL_IMPORT_REF void SetNativeBufferSize(int32 aSize); + + /** + * SetAsyncReadBufferSize configures the asynchronous background + * read function. May not be available on all platforms. + * + * This should be called before opening the file. If used when + * the file is open, the option will not take effect until the + * next Open. + * + * Note: if asynchronous read is not available on the platform, + * this call will have no effect. + * + * @param aSize: buffer size in bytes. Zero disables the feature. + */ + OSCL_IMPORT_REF void SetAsyncReadBufferSize(uint32 aSize); + + /** + * SetFileHandle adds an open file handle to the Oscl_File object. + * The Oscl_File object will use that handle to access the file. + * + * This call is not available when the Oscl_File object is already + * open. + * + * Note: This feature is used in Symbian with the MMF framework. + * The MMF framework provides an open RFile handle to access content. + * When using RFileBuf access mode with an RFile handle, the RFileBuf + * will be attached to the open RFile handle. + * + * To use the external file handle, the caller starts with a native file handle to an open file. The caller must + * wrap the native file handle in an OsclFileHandle object, pass the OsclFileHandle pointer to SetFileHandle, + * call Oscl_File::Open, then proceed to use the Oscl_File object, finally calling Oscl_File::Close. + * In this usage mode, Oscl_File::Open and Oscl_File::Close do not actually call native file open and close. + * It is assumed that the caller will close the original native file handle after usage is complete. + * + * @param aHandle: container for an open file handle. + * @return returns 0 if successful, non-zero if error. + * + */ + OSCL_IMPORT_REF int32 SetFileHandle(OsclFileHandle* aHandle); + + /** + * Opens a file. + * + * Note: when an external file handle is used, Open will attach to the file + * handle and initialize cacheing features, but will not do a native file open. + * + * + * @param filename name of file to open (Utf8) + * @param mode combination of open mode flags + * @param fileserv fileserver to use + * + * @return returns 0 if successful and a non-zero value otherwise + */ + OSCL_IMPORT_REF int32 Open(const char *filename, uint32 mode, Oscl_FileServer& fileserv); + + /** + * Opens a file. + * + * Note: when an external file handle is used, Open will attach to the file + * handle and initialize cacheing features, but will not do a native file open. + * + * @param filename name of file to open (Unicode) + * @param mode combination of open mode flags + * @param fileserv fileserver to use + * + * @return returns 0 if successful and a non-zero value otherwise + */ + OSCL_IMPORT_REF int32 Open(const oscl_wchar *filename, uint32 mode, Oscl_FileServer& fileserv); + + /** + * The File Read operation + * Reads from the file into the buffer a maximum of 'numelements' + * of size 'size'. + * + * @param buffer pointer to buffer of type void + * @param size element size in bytes + * @param numelements + * max number of elements to read + * + * @return returns the number of full elements actually read, which + * may be less than count if an error occurs or if the end + * of the file is encountered before reaching count. Use the + * CheckEndOfFile or GetError function to distinguish a read + * error from an end-of-file condition. + */ + OSCL_IMPORT_REF uint32 Read(OsclAny *buffer, + uint32 size, + uint32 numelements); + + /** + * The File Write operation + * Writes from the buffer 'numelements' objects of size 'size' + * + * @param buffer pointer to buffer of type void + * @param size element size in bytes + * @param numelements + * number of elements to write + * + * @return The number of elements written + */ + OSCL_IMPORT_REF uint32 Write(const OsclAny *buffer, + uint32 size, + uint32 numelements); + + + /** + * The File Seek operation + * Sets the position for file pointer + * + * @param offset offset from the specified origin. + * @param origin starting point + * + * @return returns 0 on success, and a non-zero value otherwise + */ + OSCL_IMPORT_REF int32 Seek(TOsclFileOffset offset, + seek_type origin); + + /** + * The File Tell operation + * Returns the current file position for file specified by fp + */ + OSCL_IMPORT_REF TOsclFileOffset Tell(); + + + /** + * The File Close operation + * Closes the file after flushing any remaining data in the + * buffers. + * + * Note: If the file object was opened with an external file handle, + * then Close will simply flush the file. The file will remain open. + * + * @return returns 0 if successful, and a non-zero value otherwise + */ + OSCL_IMPORT_REF int32 Close(); + + + /** + * The File Flush operation + * On an output stream OSCL_FileFlush causes any buffered + * but unwritten data to be written to the file. Flush is meant for writable files. + * The behavior when calling it on read-only files is OS-dependent. + * + * @return returns 0 if successful, and a non-zero value otherwise + */ + OSCL_IMPORT_REF int32 Flush(); + + /** + * The File SetSize operation + * If the file has been opened for writing this will set the size of the file. + * The file pointer position is undefined after calling SetSize. + * If file size is increased the contents of the new section are undefined. + * @return returns 0 if successful, and a non-zero value otherwise + */ + OSCL_IMPORT_REF int32 SetSize(uint32 size); + + /** + * The File EOF(end of file) operation + * returns a nonzero value after the first read operation + * that attempts to read past the end of the file + * + * @return + */ + OSCL_IMPORT_REF int32 EndOfFile(); + + + /** + * The File Error operation + * If no error has occurred on stream, returns 0. Otherwise, + * it returns a nonzero value + * + * @return + */ + OSCL_IMPORT_REF int32 GetError(); + + /** + * Retrieve the file handle. + * + * @return file handle + */ + OsclFileHandle* Handle() + { + return iOpenFileHandle; + } + + /** + * Get the file size in bytes. + * + * @return - The size of the file, or -1 on error. + */ + OSCL_IMPORT_REF TOsclFileOffset Size(); + + /** + * SetLoggingEnable configures the PVLogger output for this file. + * This will enable full logging of each API entry and + * exit using the logger object "Oscl_File", plus full logging + * of native operation entry & exit using logger object "OsclNativeFile". + * + * @param aEnable: true to enable, false to disable logging. + */ + OSCL_IMPORT_REF void SetLoggingEnable(bool aEnable); + + /** + * SetSummaryStatsLoggingEnable configures the PVLogger output for this file. + * This will enable summary statistics logging only, using the logger + * object "OsclFileStats". + * + * @param aEnable: true to enable, false to disable stats logging. + */ + OSCL_IMPORT_REF void SetSummaryStatsLoggingEnable(bool aEnable); + + + private: + friend class OsclFileCache; + friend class OsclFileCacheBuffer; + friend class asyncfilereadwrite_test; + friend class largeasyncfilereadwrite_test; + friend class asyncfilereadcancel_test; + + void Construct(); + void OldCacheDefaults(); + void OldCacheSelect(uint32); + + //state info + bool iIsOpen; + + //For Logging + PVLogger* iLogger; + PVLogger* iStatsLogger; + PVLogger* iNativeLogger; + PVLogger* iAsyncLogger; + OsclFileStats* iFileStats; + void CreateFileStats(); + + //External file handle. + OsclFileHandle* iOpenFileHandle; + + //For PV File Cache + uint32 iPVCacheSize; + OsclFileCache* iFileCache; + Oscl_Vector iAddFixedCache; + Oscl_Vector iRemoveFixedCache; + OsclCacheObserver* iCacheObserver; + + int32 OpenFileCacheOrAsyncBuffer(const char *filename + , const oscl_wchar* wfilename + , uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv) ; + + //For native file I/O. + OsclNativeFile* iNativeFile; + int32 iNativeBufferSize; + uint32 iNativeAccessMode; + + //For async read feature + uint32 iAsyncReadBufferSize; + OsclAsyncFile* iAsyncFile; + + // These are wrappers to call the Native OS File IO calls with + // stats and logging. + + int32 CallNativeOpen(const OsclFileHandle&, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv); + int32 CallNativeOpen(const oscl_wchar *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv); + int32 CallNativeOpen(const char *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv); + uint32 CallNativeRead(OsclAny *buffer, uint32 size, uint32 numelements); + uint32 CallNativeWrite(const OsclAny *buffer, uint32 size, uint32 numelements); + int32 CallNativeSeek(TOsclFileOffset offset, Oscl_File::seek_type origin); + int32 CallNativeSetSize(uint32 size); + TOsclFileOffset CallNativeTell(); + int32 CallNativeFlush(); + int32 CallNativeEndOfFile(); + TOsclFileOffset CallNativeSize(); + int32 CallNativeClose(); + uint32 CallNativeMode(); + int32 CallNativeGetError(); + OSCL_IMPORT_REF uint32 GetAsyncFileNumOfRun(); + OSCL_IMPORT_REF uint32 GetAsyncFileNumOfRunError(); + +}; + + +//Include all public file apis for convenience here. +#include "oscl_file_server.h" +#include "oscl_file_find.h" +#include "oscl_file_dir_utils.h" +#include "oscl_file_handle.h" + +#endif // OSCL_FILE_IO_H_INCLUDED + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_manager.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_manager.cpp new file mode 100644 index 0000000..b015b90 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_manager.cpp @@ -0,0 +1,237 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \file oscl_file_man.cpp + \brief This file contains file io APIs for file management functions +*/ + +#include "oscl_file_manager.h" +#include "oscl_file_types.h" +#include "oscl_utf8conv.h" +#include "oscl_stdstring.h" +#include "oscl_int64_utils.h" +#include "oscl_file_io.h" +#include "oscl_mem_basic_functions.h" + +/////////////////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF bool OsclFileManager::OsclGetFileSize(const oscl_wchar* aFileName, uint64& aFileSize) +{ + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(aFileName, oscl_strlen(aFileName), convpathname, OSCL_IO_FILENAME_MAXLEN) && + oscl_strlen(aFileName) != 0) + { + return false; + } + return OsclGetFileSize(convpathname, aFileSize); + +} +/////////////////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF bool OsclFileManager::OsclGetFileSize(const char* aFileName, uint64& aFileSize) +{ + struct stat statbuf; + aFileSize = 0; + if (aFileName && *aFileName) + { + if (stat(aFileName, &statbuf) == 0) + { + Oscl_Int64_Utils::set_uint64(aFileSize, 0, statbuf.st_size); + return true; + } + } + return false; + +} +/////////////////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF bool OsclFileManager::OsclGetFileCreationTime(const oscl_wchar* aFileName, uint64& aFileCreationTime) +{ + + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(aFileName, oscl_strlen(aFileName), convpathname, OSCL_IO_FILENAME_MAXLEN) && + oscl_strlen(aFileName) != 0) + { + return false; + } + return OsclGetFileCreationTime(convpathname, aFileCreationTime); +} +/////////////////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF bool OsclFileManager::OsclGetFileCreationTime(const char* aFileName, uint64& aFileCreationTime) +{ + + struct stat statbuf; + aFileCreationTime = 0; + if (aFileName && *aFileName) + { + if (stat(aFileName, &statbuf) == 0) + { + Oscl_Int64_Utils::set_uint64(aFileCreationTime, 0, (statbuf.st_ctime)); + aFileCreationTime = (aFileCreationTime) * (1000000); + return true; + } + } + return false; +} + +/////////////////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF bool OsclFileManager::OsclGetFileLastAccessTime(const oscl_wchar* aFileName, uint64& aFileLastAccessTime) +{ + + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(aFileName, oscl_strlen(aFileName), convpathname, OSCL_IO_FILENAME_MAXLEN) && + oscl_strlen(aFileName) != 0) + { + return false; + } + return OsclGetFileLastAccessTime(convpathname, aFileLastAccessTime); +} +/////////////////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF bool OsclFileManager::OsclGetFileLastAccessTime(const char* aFileName, uint64& aFileLastAccessTime) +{ + struct stat statbuf; + aFileLastAccessTime = 0; + if (aFileName && *aFileName) + { + if (stat(aFileName, &statbuf) == 0) + { + Oscl_Int64_Utils::set_uint64(aFileLastAccessTime, 0, (statbuf.st_atime)); + aFileLastAccessTime = (aFileLastAccessTime) * (1000000); + return true; + } + } + return false; +} + +/////////////////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF bool OsclFileManager::OsclGetFileLastWriteTime(const oscl_wchar* aFileName, uint64& aFileLastWriteTime) +{ + + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(aFileName, oscl_strlen(aFileName), convpathname, OSCL_IO_FILENAME_MAXLEN) && + oscl_strlen(aFileName) != 0) + { + return false; + } + return OsclGetFileLastWriteTime(convpathname, aFileLastWriteTime); +} + +/////////////////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF bool OsclFileManager::OsclGetFileLastWriteTime(const char* aFileName, uint64& aFileLastWriteTime) +{ + + struct stat statbuf; + aFileLastWriteTime = 0; + if (aFileName && *aFileName) + { + if (stat(aFileName, &statbuf) == 0) + { + Oscl_Int64_Utils::set_uint64(aFileLastWriteTime, 0, (statbuf.st_mtime)); + aFileLastWriteTime = (aFileLastWriteTime) * (1000000); + + return true; + } + } + return false; +} + +/////////////////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF bool OsclFileManager::OsclGetFileAttributes(const oscl_wchar* aFileName, uint32& aFileAttributes) +{ + + char convpathname[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(aFileName, oscl_strlen(aFileName), convpathname, OSCL_IO_FILENAME_MAXLEN) && + oscl_strlen(aFileName) != 0) + { + return false; + } + return OsclGetFileAttributes(convpathname, aFileAttributes); + +} + +/////////////////////////////////////////////////////////////////////////////// +OSCL_EXPORT_REF bool OsclFileManager::OsclGetFileAttributes(const char* aFileName, uint32& aFileAttributes) +{ + + struct stat statbuf; + aFileAttributes = 0; + char* aExactFileName = NULL; + + if (aFileName && *aFileName) + { + if (stat(aFileName, &statbuf) == 0) + { + if (true == S_ISDIR(statbuf.st_mode)) + { + aFileAttributes |= OSCL_FILE_ATTRIBUTE_DIRECTORY; + } + if (!(statbuf.st_mode & S_IWUSR) && !(statbuf.st_mode & S_IWGRP) && !(statbuf.st_mode & S_IWOTH)) + { + aFileAttributes |= OSCL_FILE_ATTRIBUTE_READONLY; + } + /*This function will provide File Name from Path */ + OsclExtractFilenameFromFullpath(aFileName, aExactFileName); + if (aExactFileName && aExactFileName[0] == '.') + { + aFileAttributes |= OSCL_FILE_ATTRIBUTE_HIDDEN; + } + return true; + } + } + return false; + +} + +///////////////////////////////////////////////////////////////////////////////////// + +OSCL_EXPORT_REF void OsclFileManager::OsclExtractFilenameFromFullpath(const char* aPath, char* &aFileName) +{ + if (aPath && *aPath) + { + const char *pStrtmp = OSCL_FILE_CHAR_PATH_DELIMITER; + char *pTmp = oscl_strstr((char*)aPath, pStrtmp); + while (pTmp) + { + aPath = pTmp + oscl_strlen(pStrtmp); + pTmp = oscl_strstr((char*)aPath, pStrtmp); + } + aFileName = (char*)aPath; + } + else + { + aFileName = NULL; + } +} + +OSCL_EXPORT_REF void OsclFileManager::OsclExtractFilenameFromFullpath(const oscl_wchar* aPath, oscl_wchar* &aFileName) +{ + if (aPath && *aPath) + { + const oscl_wchar *pStrtmp = OSCL_FILE_WCHAR_PATH_DELIMITER; + oscl_wchar *pTmp = oscl_strstr((oscl_wchar*)aPath, pStrtmp); + while (pTmp) + { + aPath = pTmp + oscl_strlen(pStrtmp); + pTmp = oscl_strstr((oscl_wchar*)aPath, pStrtmp); + } + aFileName = (oscl_wchar*)aPath; + } + else + { + aFileName = NULL; + } +} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_manager.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_manager.h new file mode 100644 index 0000000..ffc3763 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_manager.h @@ -0,0 +1,230 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ F I L E _ M A N A G E R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_file_manager.h + \brief File management class + +*/ + +#ifndef OSCL_FILE_MANAGER_H_INCLUDED +#define OSCL_FILE_MANAGER_H_INCLUDED + +#include "oscl_base.h" + +class OsclFileManager +{ + public: + typedef enum + { + OSCL_FILE_ATTRIBUTE_READONLY = 0x00000001, + /* + The file or directory is read-only. Applications can read the file but cannot write to it or delete it. + For a directory, applications cannot delete it. + */ + OSCL_FILE_ATTRIBUTE_HIDDEN = 0x00000002, + /* + The file or directory is hidden. It is not included in an ordinary directory listing. + */ + OSCL_FILE_ATTRIBUTE_SYSTEM = 0x00000004, + /* + The file or directory is part of the operating system, or is used exclusively by the operating system. + */ + OSCL_FILE_ATTRIBUTE_DIRECTORY = 0x00000010, + /* + The handle identifies a directory. + */ + OSCL_FILE_ATTRIBUTE_ARCHIVE = 0x00000020, + /* + The file or directory is an archive file. Applications use this attribute to mark files for backup or removal. + */ + OSCL_FILE_ATTRIBUTE_NORMAL = 0x00000080, + /* + The file or directory does not have another attributes set. This attribute is valid only if used alone. + */ + //OSCL_FILE_ATTRIBUTE_TEMPORARY = 0x00000100, + /* + The file is being used for temporary storage. File systems avoid writing data back to mass storage + if sufficient cache memory is available, because often the application deletes the temporary file + shortly after the handle is closed. In that case, the system can entirely avoid writing the data. + Otherwise, the data is written after the handle is closed. + */ + //OSCL_FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200, + /* + The file is a sparse file. + */ + //OSCL_FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400, + /* + The file or directory has an associated reparse point. + */ + //OSCL_FILE_ATTRIBUTE_COMPRESSED = 0x00000800, + /* + The file or directory is compressed. + For a file, this means that all of the data in the file is compressed. + For a directory, this means that compression is the default for newly created files and subdirectories. + */ + + //OSCL_FILE_ATTRIBUTE_OFFLINE = 0x00001000, + /* + The data of the file is not immediately available. This attribute indicates that the file data has been + physically moved to offline storage.This attribute is used by Remote Storage, the hierarchical storage + management software. Applications should not arbitrarily change this attribute. + */ + //OSCL_FILE_ATTRIBUTE_ENCRYPTED = 0x00004000, + /* + The file or directory is encrypted. For a file, this means that all data in the file is encrypted. + For a directory, this means that encryption is the default for newly created files and subdirectories. + */ + //OSCL_FILE_ATTRIBUTE_VIRTUAL = 0x00010000 + /* + A file is a virtual file. + */ + + } OSCL_FILE_ATTRIBUTE_TYPE; + + /** + * OsclGetFileSize utility function provides the file size. + * For directory, this value is undefined. + * creation time + * @param [in] wide character path; the full path of the file or directory + * @param [out] file size in bytes + * + * @return true if successful, otherwise false. + */ + OSCL_IMPORT_REF static bool OsclGetFileSize(const oscl_wchar* aFileName, uint64& aFileSize); + + /** + * OsclGetFileSize utility function provides the file size. + * For directory, this value is undefined. + * @param [in] character path; the full path of the file or directory + * @param [out] file size in bytes. + * + * @return true if successful, otherwise false. + */ + OSCL_IMPORT_REF static bool OsclGetFileSize(const char* aFileName, uint64& aFileSize); + + /** + * OsclGetFileCreationTime utility function provides the file (or directory) + * creation time + * @note On symbian platform, this api returns last modified time. + * @param [in] wide character path; the full path of the file or directory + * @param [out] creation time in microseconds + * + * @return true if successful, otherwise false. + */ + OSCL_IMPORT_REF static bool OsclGetFileCreationTime(const oscl_wchar* aFileName, uint64& aFileCreationTime); + + /** + * OsclGetFileCreationTime utility function provides the file (or directory) + * creation time + * @note On symbian platform, this api returns last modified time. + * @param [in] character path; the full path of the file or directory + * @param [out] creation time in microseconds. + * + * @return true if successful, otherwise false. + */ + OSCL_IMPORT_REF static bool OsclGetFileCreationTime(const char* aFileName, uint64& aFileCreationTime); + + /** + * OsclGetFileLastAccessTime utility function provides the file (or directory) + * last access time, which might be different from last modified time. + * @note On symbian platform, this api returns last modified time. + * @param [in] wide character path; the full path of the file or directory + * @param [out] Last access time in microseconds + * + * @return true if successful, otherwise false. + */ + + OSCL_IMPORT_REF static bool OsclGetFileLastAccessTime(const oscl_wchar* aFileName, uint64& aFileLastAccessTime); + /** + * OsclGetFileLastAccessTime utility function provides the file (or directory) + * last access time, which might be different from last modified time. + * @note On symbian platform, this api returns last modified time. + * @param [in] character path; the full path of the file or directory + * @param [out] Last access time in microseconds. + * + * @return true if successful, otherwise false. + */ + OSCL_IMPORT_REF static bool OsclGetFileLastAccessTime(const char* aFileName, uint64& aFileLastAccessTime); + + /** + * OsclGetFileLastWriteTime utility function provides the file (or directory) + * last modified time. + * @param [in] wide character path; the full path of the file or directory + * @param [out] last modified time in microseconds + * + * @return true if successful, otherwise false. + */ + OSCL_IMPORT_REF static bool OsclGetFileLastWriteTime(const oscl_wchar* aFileName, uint64& aFileLastWriteTime); + + /** + * OsclGetFileLastWriteTime utility function provides the file (or directory) + * last modified time. + * @param [in] character path; the full path of the file or directory + * @param [out] last modified time in microseconds + * + * @return true if successful, otherwise false. + */ + OSCL_IMPORT_REF static bool OsclGetFileLastWriteTime(const char* aFileName, uint64& aFileLastWriteTime); + + /** + * OsclGetFileAttributes utility function provides the various attributes + * of file (or directory) like if it is hidden, read only etc. The uint32 value is + * to be interpreted as per the enum OSCL_FILE_ATTRIBUTE_TYPE defined in oscl_file_manager.h + * @param [in] wide character path; the full path of the file or directory + * @param [out] file attributes. + * + * @return true if successful, otherwise false. + */ + OSCL_IMPORT_REF static bool OsclGetFileAttributes(const oscl_wchar* aFileName, uint32& aFileAttributes); + + /** + * OsclGetFileAttributes utility function provides the various attributes + * of file (or directory) like if it is hidden, read only etc. The uint32 value is + * to be interpreted as per the enum OSCL_FILE_ATTRIBUTE_TYPE defined in oscl_file_manager.h + * @param [in] character path; the full path of the file or directory + * @param [out] file attributes. + * + * @return true if successful, otherwise false. + */ + OSCL_IMPORT_REF static bool OsclGetFileAttributes(const char* aFileName, uint32& aFileAttributes); + /** + * OsclExtractFilenameFromFullpath utility function provide the FileName From Path of a file. + * @param [in] character path; the full path of the file or directory + * @param [out] character FileName :file Name .It is assigned a pointer to file name in path itself. + * + * @return void for all condition + */ + OSCL_IMPORT_REF static void OsclExtractFilenameFromFullpath(const char* aPath, char* &aFileName); + OSCL_IMPORT_REF static void OsclExtractFilenameFromFullpath(const oscl_wchar* aPath, oscl_wchar* &aFileName); + +#endif // OSCL_FILE_MANAGER_H_INCLUDED + /*! @} */ + +}; diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_native.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_native.cpp new file mode 100644 index 0000000..36c78f9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_native.cpp @@ -0,0 +1,752 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \file oscl_file_native.cpp + \brief This file contains file io APIs +*/ + +#include "oscl_file_native.h" +#include "oscl_stdstring.h" +#include "oscl_utf8conv.h" +#include "oscl_int64_utils.h" + +#include "oscl_mem.h" +#include "oscl_file_types.h" +#include "oscl_file_handle.h" + +#ifdef ANDROID +struct AssethandleElementStruct +{ + FILE* assethandle; + pthread_mutex_t* mutex; + uint32 count; +}; + +static Oscl_Vector iAssethandleVector; +static pthread_mutex_t iConstruct_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +OsclNativeFile::OsclNativeFile() +#ifdef ANDROID + : + iAssethandle_mutex(NULL) +#endif +{ + iOpenFileHandle = false; + iMode = 0; + + iFile = 0; + iIsAsset = false; + iIsAssetReadOnly = false; + iAssetOffset = 0; + iAssetSize = 0; + iAssetLogicalFilePos = 0; + +#ifdef ANDROID + iFileDescriptor = 0; +#endif + +} + +OsclNativeFile::~OsclNativeFile() +{ +} + +int32 OsclNativeFile::Open(const OsclFileHandle& aHandle, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv) +{ + //open with an external file handle + + OSCL_UNUSED_ARG(fileserv); + + iMode = mode; + iOpenFileHandle = true; + + { + OSCL_UNUSED_ARG(params); + //Just save the open file handle + iFile = aHandle.Handle(); + +#ifdef ANDROID + iFileDescriptor = fileno(aHandle.Handle()); +#endif + } + + return 0; +} + +int32 OsclNativeFile::Open(const oscl_wchar* filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv) +{ + iMode = mode; + iOpenFileHandle = false; + +#ifdef ANDROID + //This feature requires standard C file handles and is currently only + //available on Android. + //Do not combine this block of code with the general HAS_ANSI case below + //since we like to debug this on Windows. + //Test for "assethandle://" URI's first before the standard file handling. + if (filename != NULL) + { + //Convert the unicode URI to ASCII. + char uri[100]; + oscl_UnicodeToUTF8(filename, oscl_strlen(filename), uri, sizeof(uri)); + if (oscl_strncmp(uri, "assethandle://", 14) == 0) + { + //Call the narrow string Open method. + return Open(uri, mode, params, fileserv); + } + } +#endif + + { + OSCL_UNUSED_ARG(fileserv); + OSCL_UNUSED_ARG(params); + + if (!filename || *filename == '\0') return -1; // Null string not supported in fopen, error out + + char openmode[4]; + uint32 index = 0; +#ifdef ANDROID + int largeFileOpenMode = FindLargeFileOpenMode(mode); +#endif + if (mode & Oscl_File::MODE_READWRITE) + { + if (mode & Oscl_File::MODE_APPEND) + { + openmode[index++] = 'a'; + openmode[index++] = '+'; + } + else + { + openmode[index++] = 'w'; + openmode[index++] = '+'; + } + } + else if (mode & Oscl_File::MODE_APPEND) + { + openmode[index++] = 'a'; + openmode[index++] = '+'; + } + else if (mode & Oscl_File::MODE_READ) + { + openmode[index++] = 'r'; + } + else if (mode & Oscl_File::MODE_READ_PLUS) + { + openmode[index++] = 'r'; + openmode[index++] = '+'; + } + + + + if (mode & Oscl_File::MODE_TEXT) + { + openmode[index++] = 't'; + } + else + { + openmode[index++] = 'b'; + } + + openmode[index++] = '\0'; + +#ifdef _UNICODE + oscl_wchar convopenmode[4]; + if (0 == oscl_UTF8ToUnicode(openmode, oscl_strlen(openmode), convopenmode, 4)) + { + return -1; + } + + if ((iFile = _wfopen(filename, convopenmode)) == NULL) + { + return -1; + } +#else + //Convert to UTF8 + char convfilename[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(filename, oscl_strlen(filename), convfilename, OSCL_IO_FILENAME_MAXLEN)) + { + return -1; + } + +#ifdef ANDROID + iFileDescriptor = open(convfilename, largeFileOpenMode, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + //Populate iFile + iFile = fdopen(iFileDescriptor, openmode); + if (iFileDescriptor == -1) + { + return -1; + } + else + return 0; +#endif + if ((iFile = fopen(convfilename, openmode)) == NULL) + { + return -1; + } + +#endif + return 0; + } + +} + +int32 OsclNativeFile::Open(const char *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv) +{ + iMode = mode; + iOpenFileHandle = false; + +#ifdef ANDROID + //This feature requires standard C file handles and is currently only + //available on Android. + //Do not combine this block of code with the general HAS_ANSI case below + //since we like to debug this on Windows. + //Test for "assethandle://" URI's first before the standard file handling. + //Parse the URI for an asset file handle, offset, and size. + const char* format = "assethandle://%ld:%ld:%ld"; + if (sizeof(TOsclFileOffset) > sizeof(long)) + { + format = "assethandle://%ld:%lld:%lld"; + } + //If the filename begins with "assethandle://", try to parse it. + if ((filename != NULL) && (strncmp(filename, format, 14) == 0)) + { + if (sscanf(filename, format, &iFile, &iAssetOffset, &iAssetSize) == 3) + { + if (iFile == NULL) return -1; //Bad handle. + iFileDescriptor = fileno(iFile); + //For this case, the file must already be open. + iIsAsset = true; + iIsAssetReadOnly = true; + + pthread_mutex_lock(&iConstruct_mutex); + + bool asset_found = false; + if (!iAssethandleVector.empty()) + { + // Vector is not empty. Search the list for the assethandle + Oscl_Vector::iterator it; + for (it = iAssethandleVector.begin(); it != iAssethandleVector.end(); it++) + { + if (it->assethandle == iFile) + { + asset_found = true; + // Assethandle found. Increment the count + it->count++; + // Use the mutex associated with it. + iAssethandle_mutex = it->mutex; + } + } + } + + // Element not found. Add it. + if (asset_found == false) + { + // Didnt find the asset... create a new vector + AssethandleElementStruct aNewAssetHandle; + aNewAssetHandle.assethandle = iFile; + aNewAssetHandle.mutex = NULL; + aNewAssetHandle.mutex = (pthread_mutex_t*)malloc(sizeof(pthread_mutex_t)); + if (aNewAssetHandle.mutex == NULL) + { + pthread_mutex_unlock(&iConstruct_mutex); + // Unable to allocate memory for mutex... return failure. + return -1; + } + // Attempt to init the mutex + if (0 != pthread_mutex_init(aNewAssetHandle.mutex, NULL)) + { + free(aNewAssetHandle.mutex); + pthread_mutex_unlock(&iConstruct_mutex); + // Failed to initalize the mutex + return -1; + } + // Init to 1 + aNewAssetHandle.count = 1; + // Use the mutex in this object + iAssethandle_mutex = aNewAssetHandle.mutex; + // Add new element to the vector + iAssethandleVector.push_back(aNewAssetHandle); + } + pthread_mutex_unlock(&iConstruct_mutex); + + //Seek to logical 0 to apply the offset. + if (0 != Seek(0, Oscl_File::SEEKSET)) + { + return -1; //Seek failed. + } + return 0; + } + else + { + //Parsing error, could not open. + return -1; + } + } +#endif + + { + OSCL_UNUSED_ARG(fileserv); + OSCL_UNUSED_ARG(params); + + if (!filename || *filename == '\0') return -1; // Null string not supported in fopen, error out + + char openmode[4]; + uint32 index = 0; +#ifdef ANDROID + int largeFileOpenMode = FindLargeFileOpenMode(mode); +#endif + if (mode & Oscl_File::MODE_READWRITE) + { + if (mode & Oscl_File::MODE_APPEND) + { + openmode[index++] = 'a'; + openmode[index++] = '+'; + } + else + { + openmode[index++] = 'w'; + openmode[index++] = '+'; + + } + } + else if (mode & Oscl_File::MODE_APPEND) + { + openmode[index++] = 'a'; + openmode[index++] = '+'; + } + else if (mode & Oscl_File::MODE_READ) + { + openmode[index++] = 'r'; + } + else if (mode & Oscl_File::MODE_READ_PLUS) + { + openmode[index++] = 'r'; + openmode[index++] = '+'; + } + + if (mode & Oscl_File::MODE_TEXT) + { + openmode[index++] = 't'; + } + else + { + openmode[index++] = 'b'; + } + + openmode[index++] = '\0'; + +#ifdef ANDROID + iFileDescriptor = open(filename, largeFileOpenMode, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + //Populate iFile + iFile = fdopen(iFileDescriptor, openmode); + if (iFileDescriptor == -1) + { + return -1; + } + else + return 0; +#endif + if ((iFile = fopen(filename, openmode)) == NULL) + { + return -1; + } + return 0; + + } + +} + +TOsclFileOffset OsclNativeFile::Size() +{ + //this is the default for platforms with no + //native size query. + //Just do seek to end, tell, then seek back. + TOsclFileOffset curPos = Tell(); + if (curPos >= 0 + && Seek(0, Oscl_File::SEEKEND) == 0) + { + TOsclFileOffset endPos = Tell(); + if (Seek(curPos, Oscl_File::SEEKSET) == 0) + { + return endPos; + } + else + { + return (-1); + } + } + return (-1); +} + +int32 OsclNativeFile::Close() +{ + int32 closeret = 0; + + //Do not close asset file's shared file handle - the owner must close it. + if (iIsAsset) + { +#ifdef ANDROID + pthread_mutex_lock(&iConstruct_mutex); + + // Assethandle vector should not be empty. + OSCL_ASSERT(!iAssethandleVector.empty()); + + if (!iAssethandleVector.empty()) + { + // Vector is not empty. Search the list for the assethandle + Oscl_Vector::iterator it; + for (it = iAssethandleVector.begin(); it != iAssethandleVector.end(); it++) + { + if (it->assethandle == iFile) + { + // Assethandle found. Dec the count + it->count--; + if (it->count == 0) + { + // Count is zero. Destroy the mutex. No longer needed + pthread_mutex_destroy(it->mutex); + free(it->mutex); + iAssethandleVector.erase(it); + } + pthread_mutex_unlock(&iConstruct_mutex); + return 0; + } + } + } + // Assethandle was not found on the list! + OSCL_ASSERT(0); + pthread_mutex_unlock(&iConstruct_mutex); + return -1; +#else + return 0; +#endif + } + + { + if (iOpenFileHandle) + closeret = Flush(); + else if (iFile != NULL) + { + closeret = fclose(iFile); + iFile = NULL; +#ifdef ANDROID + iFileDescriptor = 0; +#endif + + } + else + { + return -1; //Linux Porting : Fix 1 + } + } + + return closeret; +} + +uint32 OsclNativeFile::Read(OsclAny *buffer, uint32 size, uint32 numelements) +{ + uint32 read_ret = 0; + if (iIsAsset) + { +#ifdef ANDROID + pthread_mutex_lock(iAssethandle_mutex); + + lseek64(iFileDescriptor, (iAssetLogicalFilePos + iAssetOffset), SEEK_SET); +#else + //Asset file are opened multiple times by the source nodes, so always seek before reading. + Seek(iAssetLogicalFilePos, Oscl_File::SEEKSET); +#endif + + //If the file is an asset file, don't allow reading past the end. + //Calculate the new logical file position. + uint32 bytes = size * numelements; + iAssetLogicalFilePos += bytes; + + //If we read past the end of the asset... + if (iAssetLogicalFilePos >= iAssetSize) + { + //Calculate the number of bytes read past the end. + uint32 over = OSCL_STATIC_CAST(uint32, (iAssetLogicalFilePos - iAssetSize)); + //Calculate the number of elements that can be read. + if (!size) + { +#ifdef ANDROID + pthread_mutex_unlock(iAssethandle_mutex); +#endif + return 0; //avoid divide-by-zero + } + if (bytes < over) + { +#ifdef ANDROID + pthread_mutex_unlock(iAssethandle_mutex); +#endif + return 0; //avoid negative count + } + numelements = (bytes - over) / size; + } + } + + if (iFile) + { +#ifdef ANDROID + int32 bytesToBeRead = size * numelements; + int32 result = read(iFileDescriptor, buffer, bytesToBeRead); + if (result != -1) + { + read_ret = (uint32)(result / size); + } + else + { + read_ret = -1; + } +#else // else OSCL_HAS_LARGE_FILE_SUPPORT and NOT ANDROID + read_ret = fread(buffer, OSCL_STATIC_CAST(int32, size), OSCL_STATIC_CAST(int32, numelements), iFile); +#endif // endif ANDROID + } + +#ifdef ANDROID + if (iIsAsset) + { + pthread_mutex_unlock(iAssethandle_mutex); + } +#endif + return read_ret; +} + +bool OsclNativeFile::HasAsyncRead() +{ + return false;//not supported. +} + +int32 OsclNativeFile::ReadAsync(OsclAny*buffer, uint32 size, uint32 numelements, OsclAOStatus& status) +{ + OSCL_UNUSED_ARG(buffer); + OSCL_UNUSED_ARG(size); + OSCL_UNUSED_ARG(numelements); + OSCL_UNUSED_ARG(status); + return -1;//not supported +} + +void OsclNativeFile::ReadAsyncCancel() +{ +} + +uint32 OsclNativeFile::GetReadAsyncNumElements() +{ + return 0;//not supported +} + + + +uint32 OsclNativeFile::Write(const OsclAny *buffer, uint32 size, uint32 numelements) +{ + //Abort the write operation if the file is a read-only asset. + if (iIsAsset && iIsAssetReadOnly) + { + return 0; + } + + if (iFile) + { +#ifdef ANDROID + int32 num_bytes_written = write(iFileDescriptor, buffer, (size * numelements)); + if (num_bytes_written != -1) + { + return (uint32)(num_bytes_written / size); + } + else + return -1; +#endif + return fwrite(buffer, OSCL_STATIC_CAST(int32, size), OSCL_STATIC_CAST(int32, numelements), iFile); + } + return 0; +} + +int32 OsclNativeFile::Seek(TOsclFileOffset offset, Oscl_File::seek_type origin) +{ + int32 seek_ret = -1; + //If the file represents an individual asset from a file, + //normalize the offset. + if (iIsAsset) + { +#ifdef ANDROID + pthread_mutex_lock(iAssethandle_mutex); +#endif + switch (origin) + { + case Oscl_File::SEEKCUR: + iAssetLogicalFilePos += offset; + break; + case Oscl_File::SEEKEND: + iAssetLogicalFilePos = iAssetSize + offset; + break; + case Oscl_File::SEEKSET: + default: + iAssetLogicalFilePos = offset; + break; + } + offset = iAssetLogicalFilePos + iAssetOffset; + origin = Oscl_File::SEEKSET; + } + + { + if (iFile) + { + int32 seekmode = SEEK_CUR; + + if (origin == Oscl_File::SEEKCUR) + seekmode = SEEK_CUR; + else if (origin == Oscl_File::SEEKSET) + seekmode = SEEK_SET; + else if (origin == Oscl_File::SEEKEND) + seekmode = SEEK_END; + +#ifdef ANDROID + TOsclFileOffset seekResult = lseek64(iFileDescriptor, offset, seekmode); + + if (iIsAsset) + { + pthread_mutex_unlock(iAssethandle_mutex); + } + + if (seekResult == -1) + seek_ret = -1; + else + seek_ret = 0; + + return seek_ret; +#endif + seek_ret = fseeko(iFile, offset, seekmode); + } + } + + return seek_ret; +} + +int32 OsclNativeFile::SetSize(uint32 size) +{ + // unix leaves file position unchanged + int32 fd = fileno(iFile); + if (-1 != fd) + { + return ftruncate(fd, size); + } + return -1; +} + + +TOsclFileOffset OsclNativeFile::Tell() +{ + if (iIsAsset) return iAssetLogicalFilePos; + + TOsclFileOffset result = -1; + if (iFile) + { +#ifdef ANDROID + return lseek64(iFileDescriptor, 0, SEEK_CUR); +#endif + result = ftello(iFile); + } + return result; +} + + + +int32 OsclNativeFile::Flush() +{ + + + if (!iFile || fflush(iFile) == EOF) + return EOF; + // flush OS buffers to disk + return fsync(fileno(iFile)); + +} + + + +int32 OsclNativeFile::EndOfFile() +{ + if (iIsAsset) + { + if (Tell() >= iAssetSize) return 1; + return 0; + } + +#ifdef ANDROID + if (iFile) + { + return Tell() < Size() ? 0 : 1; + } +#endif + if (iFile) + { + return feof(iFile); + } + return 0; +} + + +int32 OsclNativeFile::GetError() +{ + if (iFile) + return ferror(iFile); + return 0; +} + +#ifdef ANDROID +int32 OsclNativeFile::FindLargeFileOpenMode(uint32 mode) +{ + int32 largeFileOpenMode = 0; + + if (mode & Oscl_File::MODE_APPEND) + { + largeFileOpenMode = O_CREAT | O_APPEND; + } + else if (mode & Oscl_File::MODE_READ) + { + largeFileOpenMode = O_RDONLY; + } + else if (mode & Oscl_File::MODE_READ_PLUS) + { + largeFileOpenMode = O_RDWR; + } + else if (mode & Oscl_File::MODE_READWRITE) + { + largeFileOpenMode = (O_RDWR | O_CREAT); + if (mode & Oscl_File::MODE_APPEND) + { + largeFileOpenMode |= O_APPEND; + } + else + { + largeFileOpenMode |= O_TRUNC; + } + } + + largeFileOpenMode |= O_LARGEFILE; + return largeFileOpenMode; +} +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_native.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_native.h new file mode 100644 index 0000000..daaeee4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_native.h @@ -0,0 +1,158 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ F I L E _ N A T I V E + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_file_native.h + \brief The file oscl_file_native.h defines the class OsclNativeFile. + This is the porting layer for basic file I/O operations. +*/ + +#ifndef OSCL_FILE_NATIVE_H_INCLUDED +#define OSCL_FILE_NATIVE_H_INCLUDED + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#include "osclconfig_io.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_AOSTATUS_H_INCLUDED +#include "oscl_aostatus.h" +#endif + +#ifndef OSCL_FILE_IO_H_INCLUDED +#include "oscl_file_io.h" +#endif + +#ifndef OSCL_FILE_TYPES_H_INCLUDED +#include "oscl_file_types.h" +#endif + + +/** + * OsclNativeFileIO defines the native file operations that must be implemented + * by every Oscl platform. + */ + +class Oscl_FileServer; +class OsclNativeFile : public HeapBase +{ + public: + OsclNativeFile(); + ~OsclNativeFile(); + + // These are the Native OS File IO calls. + int32 Open(const OsclFileHandle&, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv); + int32 Open(const oscl_wchar *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv); + int32 Open(const char *filename, uint32 mode + , const OsclNativeFileParams& params + , Oscl_FileServer& fileserv); + uint32 Read(OsclAny *buffer, uint32 size, uint32 numelements); + uint32 Write(const OsclAny *buffer, uint32 size, uint32 numelements); + int32 Seek(TOsclFileOffset offset, Oscl_File::seek_type origin); + TOsclFileOffset Tell(); + int32 Flush(); + int32 EndOfFile(); + TOsclFileOffset Size(); + int32 Close(); + int32 SetSize(uint32 size); + + //query for current open mode. + uint32 Mode() + { + return iMode; + } + + //get last filesystem error. + int32 GetError(); + + /*! + ** Asynchronous read. + ** + ** @param buffer: data buffer, must be at least size*numelements bytes + ** @param size: size of elements + ** @param numelements: number of elements to read + ** @param status: Request status for asynchronous completion + ** @returns: 0 for success. + **/ + int32 ReadAsync(OsclAny*buffer, uint32 size, uint32 numelements, OsclAOStatus& status); + /*! + ** Get the number of elements read in the last call to ReadAsync. + ** @returns: number of elements read. + **/ + uint32 GetReadAsyncNumElements(); + /*! + ** @returns: true if async read is supported natively. + **/ + bool HasAsyncRead(); + /*! + ** Cancel any pending async read. + **/ + void ReadAsyncCancel(); + + private: + +#ifdef ANDROID + int32 FindLargeFileOpenMode(uint32 mode); +#endif + + //current open mode + uint32 iMode; + + //was an open file handle passed in? + bool iOpenFileHandle; + + //native file object. + FILE* iFile; +#ifdef ANDROID + pthread_mutex_t* iAssethandle_mutex; +#endif + + //These are used for accessing individual assets that are bundled together + //into a single file, where each asset is treated as an independent file. + bool iIsAsset; + bool iIsAssetReadOnly; + TOsclFileOffset iAssetOffset; + TOsclFileOffset iAssetSize; + TOsclFileOffset iAssetLogicalFilePos; +#ifdef ANDROID + int32 iFileDescriptor; +#endif +}; + +#endif // OSCL_FILE_NATIVE_H_INCLUDED + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_server.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_server.cpp new file mode 100644 index 0000000..c6a3fab --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_server.cpp @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \file oscl_file_server.cpp + \brief This file contains file io APIs +*/ + +#include "oscl_file_server.h" +#include "oscl_file_types.h" +#include "oscl_stdstring.h" +#include "oscl_utf8conv.h" + + +OSCL_EXPORT_REF Oscl_FileServer::Oscl_FileServer() +{ +} + +OSCL_EXPORT_REF Oscl_FileServer::~Oscl_FileServer() +{ +} + +OSCL_EXPORT_REF int32 Oscl_FileServer::Connect(bool aShareSession) +{ + //default-- assume there is nothing needed. + return 0; +} + +OSCL_EXPORT_REF int32 Oscl_FileServer::Close() +{ + //default-- assume there is nothing needed. + return 0; +} + +OSCL_EXPORT_REF int32 Oscl_FileServer::Oscl_DeleteFile(const oscl_wchar* filename) +{ + { + //Convert to UTF8 + char convfilename[OSCL_IO_FILENAME_MAXLEN]; + if (0 == oscl_UnicodeToUTF8(filename, oscl_strlen(filename), convfilename, OSCL_IO_FILENAME_MAXLEN)) + return (-1); + + return unlink(convfilename); + + } +} + +OSCL_EXPORT_REF int32 Oscl_FileServer::Oscl_DeleteFile(const char* filename) +{ + { + return unlink(filename); + } +} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_server.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_server.h new file mode 100644 index 0000000..ce9276c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_server.h @@ -0,0 +1,107 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ F I L E _ SERVER + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_file_server.h + \brief The file oscl_file_server.h defines the class Oscl_FileServer. + This is the porting layer for file server implementations. +*/ + +#ifndef OSCL_FILE_SERVER_H_INCLUDED +#define OSCL_FILE_SERVER_H_INCLUDED + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#include "osclconfig_io.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +class Oscl_File; + +class Oscl_FileServer +{ + public: + /** + * Constructor + */ + OSCL_IMPORT_REF Oscl_FileServer(); + + /** + * Destructor + */ + OSCL_IMPORT_REF ~Oscl_FileServer(); + + /** + * Connects the server. This must be called before a file + * server can be used. + * + * @return returns 0 on success and a non-zero value otherwise + */ + OSCL_IMPORT_REF int32 Connect(bool aShareSession = false); + + /** + * Closes a file server. + * + * @return returns 0 on success and a non-zero value otherwise + */ + OSCL_IMPORT_REF int32 Close(); + + /** + * Deletes a file from the filesystem + * * @param filename name of the file to delete (Utf8) + * + * @return returns 0 if successful, and a non-zero value otherwise. + */ + OSCL_IMPORT_REF int32 Oscl_DeleteFile(const char *filename); + + /** + * Deletes a file from the filesystem + * + * @param filename name of the file to delete (Unicode) + * + * @return returns 0 if successful, and a non-zero value otherwise. + */ + OSCL_IMPORT_REF int32 Oscl_DeleteFile(const oscl_wchar *filename); + + + protected: + friend class Oscl_File; + friend class OsclNativeFile; + + //file server objects (if appropriate) +}; + + + +#endif // OSCL_FILE_SERVER_H_INCLUDED + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_stats.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_stats.cpp new file mode 100644 index 0000000..2ed1c14 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_stats.cpp @@ -0,0 +1,78 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_file_stats.h" +#include "oscl_tickcount.h" +#include "pvlogger.h" +#include "oscl_int64_utils.h" + +OsclFileStats::OsclFileStats(Oscl_File* c): iContainer(c) +{ + oscl_memset(iStats, 0, sizeof(iStats)); +} + +void OsclFileStats::Start(uint32& aTicks) +{ + aTicks = OsclTickCount::TickCount(); +} + +void OsclFileStats::End(TOsclFileOp aOp, uint32 aStart, uint32 aParam, TOsclFileOffset aParam2) +{ + uint32 delta = OsclTickCount::TickCount() - aStart; + + iStats[aOp].iStartTick = aStart; + iStats[aOp].iTotalTicks += delta; + iStats[aOp].iParam += aParam; + iStats[aOp].iParam2 += aParam2; + iStats[aOp].iOpCount++; +} + + +void OsclFileStats::Log(TOsclFileOp aOp, PVLogger* aLogger, uint32 aLogLevel) +{ + OSCL_UNUSED_ARG(aOp); + OSCL_UNUSED_ARG(aLogLevel); + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, aLogLevel + , (0, "OsclFileStats(0x%x): Op %s Count %d, Param hi:0x%8x lo:0x%08x, Param2 hi:0x%8x lo:0x%08x, StartTick %d TotalTick %d" + , iContainer, TOsclFileOpStr[aOp] + , iStats[aOp].iOpCount + , Oscl_Int64_Utils::get_int64_upper32((const int64)(iStats[aOp].iParam)) + , Oscl_Int64_Utils::get_int64_lower32((const int64)(iStats[aOp].iParam)) + , Oscl_Int64_Utils::get_int64_upper32((const int64)(iStats[aOp].iParam2)) + , Oscl_Int64_Utils::get_int64_lower32((const int64)(iStats[aOp].iParam2)) + , iStats[aOp].iStartTick, iStats[aOp].iTotalTicks + )); +} + +void OsclFileStats::LogAll(PVLogger* aLogger, uint32 aLogLevel) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, aLogLevel + , (0, "OsclFileStats(0x%x): +++++++++++++++++++++ Begin", iContainer)); + for (uint32 op = 0; op < EOsclFileOp_Last; op++) + { + if (iStats[op].iOpCount > 0) + { + Log((TOsclFileOp)op, aLogger, aLogLevel); + } + } + //clear all stats once they've been dumped. + oscl_memset(iStats, 0, sizeof(iStats)); + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, aLogLevel + , (0, "OsclFileStats(0x%x): +++++++++++++++++++++ End", iContainer)); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_stats.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_stats.h new file mode 100644 index 0000000..43541b2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_stats.h @@ -0,0 +1,126 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ F I L E _ STATS + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_file_stats.h + \brief File stats class + +*/ + +#ifndef OSCL_FILE_STATS_H_INCLUDED +#define OSCL_FILE_STATS_H_INCLUDED + +#include "oscl_base.h" +#include "osclconfig_io.h" + +#define OSCL_FILE_STATS_LOGGER_NODE "OsclFileStats" + +class OsclFileStatsItem +{ + public: + uint32 iOpCount; + uint64 iParam; + TOsclFileOffset iParam2; + uint32 iStartTick; + uint32 iTotalTicks; +}; + +enum TOsclFileOp +{ + EOsclFileOp_Open + , EOsclFileOp_Close + , EOsclFileOp_Read + , EOsclFileOp_Write + , EOsclFileOp_Seek + , EOsclFileOp_Tell + , EOsclFileOp_Size + , EOsclFileOp_Flush + , EOsclFileOp_EndOfFile + , EOsclFileOp_SetSize + , EOsclFileOp_NativeOpen + , EOsclFileOp_NativeClose + , EOsclFileOp_NativeRead + , EOsclFileOp_NativeWrite + , EOsclFileOp_NativeSeek + , EOsclFileOp_NativeTell + , EOsclFileOp_NativeSize + , EOsclFileOp_NativeFlush + , EOsclFileOp_NativeEndOfFile + , EOsclFileOp_NativeSetSize + , EOsclFileOp_Last +}; +static const char* const TOsclFileOpStr[] = +{ + "Open" + , "Close" + , "Read" + , "Write" + , "Seek" + , "Tell" + , "Size" + , "Flush" + , "EndOfFile" + , "SetSize" + , "NativeOpen" + , "NativeClose" + , "NativeRead" + , "NativeWrite" + , "NativeSeek" + , "NativeTell" + , "NativeSize" + , "NativeFlush" + , "NativeEndOfFile" + , "NativeSetSize" + , "???" +}; + +class PVLogger; +class Oscl_File; + +class OsclFileStats +{ + public: + OsclFileStats(Oscl_File* c); + void Start(uint32& aTicks); + void End(TOsclFileOp aOp, uint32 aStart, uint32 aParam = 0, TOsclFileOffset aParam2 = 0); + void Log(TOsclFileOp, PVLogger*, uint32); + void LogAll(PVLogger*, uint32); + + private: + Oscl_File* iContainer; + //fixed array of the max time per item. + OsclFileStatsItem iStats[EOsclFileOp_Last]; +}; + + + +#endif + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_types.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_types.h new file mode 100644 index 0000000..a6c52c7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_file_types.h @@ -0,0 +1,66 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ F I L E _ TYPES + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_file_types.h + \brief The file oscl_file_types.h defines some constants and types + for file I/O implementations. Anything that needs to be shared + across implementation modules can go here. + +*/ + +#ifndef OSCL_FILE_TYPES_H_INCLUDED +#define OSCL_FILE_TYPES_H_INCLUDED + + +#define OSCL_IO_FILENAME_MAXLEN 512 +#define OSCL_IO_EXTENSION_MAXLEN 512 + +#define OSCL_FILE_WCHAR_PATH_DELIMITER _STRLIT("/") +#define OSCL_FILE_CHAR_PATH_DELIMITER _STRLIT_CHAR("/") + +//a class for passing configuration options from Oscl_File to OsclNativeFile +class OsclNativeFileParams +{ + public: + OsclNativeFileParams(uint32 mode = 0, uint32 bufsize = 0, uint32 asyncsize = 0) + : iNativeAccessMode(mode) + , iNativeBufferSize(bufsize) + , iAsyncReadBufferSize(asyncsize) + {} + uint32 iNativeAccessMode; + uint32 iNativeBufferSize; + uint32 iAsyncReadBufferSize; +}; + + +#endif // OSCL_FILE_TYPES_H_INCLUDED + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_ip_socket.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_ip_socket.cpp new file mode 100644 index 0000000..ce0dd11 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_ip_socket.cpp @@ -0,0 +1,105 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_ip_socket.h" +#include "oscl_error.h" +#include "oscl_socket_imp.h" +#include "pvlogger.h" + +void OsclIPSocketI::ConstructL(OsclSocketObserver *aObs, OsclSocketI* aSock, OsclSocketServI* aServ, uint32 aId) +{ + if (!aObs || !aSock || !aServ) + OsclError::Leave(OsclErrGeneral); + iObserver = aObs; + iSocket = aSock; + iSocketServ = aServ; + iId = aId; + iLogger = PVLogger::GetLoggerObject("osclsocket"); +} + +void OsclIPSocketI::ThreadLogoff() +{ + iLogger = NULL; + iObserver = NULL; + iSocketServ = NULL; +} +void OsclIPSocketI::ThreadLogon(OsclSocketObserver *aObs, OsclSocketServI* aServ) +{ + iObserver = aObs; + iSocketServ = aServ; + iLogger = PVLogger::GetLoggerObject("osclsocket"); +} + +int32 OsclIPSocketI::Bind(OsclNetworkAddress &aAddress) +{ + if (iSocket) + { + iAddress.ipAddr.Set(aAddress.ipAddr.Str()); + iAddress.port = aAddress.port; + return iSocket->Bind(aAddress); + } + else + { + return OsclErrGeneral; + } +} + +int32 OsclIPSocketI::SetOptionToReuseAddress() +{ + int32 reuseAddr = 1; + return iSocket->SetSockOpt(EPVSocket, EPVSockReuseAddr, &reuseAddr, sizeof(reuseAddr)); +} + +int32 OsclIPSocketI::SetTOS(const OsclSocketTOS& aTOS) +{ + int32 tos = aTOS.GetTOS(); + return iSocket->SetSockOpt(EPVIPProtoIP, EPVIPTOS, &tos, sizeof(tos)); +} + +int32 OsclIPSocketI::GetPeerName(OsclNetworkAddress& peerName) +{ + return iSocket->GetPeerName(peerName); +} + +int32 OsclIPSocketI::Join(OsclNetworkAddress &aAddress) +{ + if (iSocket) + { + iAddress.ipAddr.Set(aAddress.ipAddr.Str()); + iAddress.port = aAddress.port; + return iSocket->Join(aAddress); + } + else + { + return OsclErrGeneral; + } +} + +int32 OsclIPSocketI::SetRecvBufferSize(uint32 size) +{ + if (iSocket) + { + return iSocket->SetRecvBufferSize(size); + } + return OsclErrGeneral; +} + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_ip_socket.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_ip_socket.h new file mode 100644 index 0000000..4a07149 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_ip_socket.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_IP_SOCKET_H_INCLUDED +#define OSCL_IP_SOCKET_H_INCLUDED + +#include "oscl_socket_types.h" +#include "oscl_vector.h" +#include "oscl_mem.h" + +/** OsclIPSocketI is the base class for UDP and TCP socket implementations. +*/ +class OsclSocketServ; +class OsclSocketI; +class OsclSocketServI; +class PVLogger; +class OsclIPSocketI +{ + public: + //Synchronous methods. + int32 Bind(OsclNetworkAddress& aAddress); + int32 Join(OsclNetworkAddress& aAddress); + int32 SetRecvBufferSize(uint32 size); + int32 SetOptionToReuseAddress(); + int32 SetTOS(const OsclSocketTOS& aTOS); + int32 GetPeerName(OsclNetworkAddress& peerName); + virtual int32 Close() = 0; + virtual uint8 *GetRecvData(int32 *aLength) = 0; + virtual uint8 *GetSendData(int32 *aLength) = 0; + virtual ~OsclIPSocketI() {} + void ThreadLogoff(); + void ThreadLogon(OsclSocketObserver *aObs, OsclSocketServI* aServ); + + OsclSocketServI* SocketServ() + { + return iSocketServ; + } + Oscl_DefAlloc& Alloc() + { + return iAlloc; + } + + protected: + Oscl_DefAlloc &iAlloc; + + OsclNetworkAddress iAddress; + uint32 iId; + OsclSocketObserver *iObserver; + OsclSocketI *iSocket; + OsclSocketServI *iSocketServ; + PVLogger* iLogger; + + friend class OsclSocketRequestAO; + friend class OsclSocketMethod; + + OsclIPSocketI(Oscl_DefAlloc& a): iAlloc(a) + , iId(0) + , iObserver(NULL) + , iSocket(NULL) + , iSocketServ(NULL) + , iLogger(NULL) + {} + + void ConstructL(OsclSocketObserver *aObs, OsclSocketI* aSock, OsclSocketServI* aServ, uint32 aId); + +}; + + + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket.cpp new file mode 100644 index 0000000..8ab21d3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket.cpp @@ -0,0 +1,358 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#include "oscl_socket.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_error.h" +#include "oscl_udp_socket.h" +#include "oscl_tcp_socket.h" + +//Socket server + +OSCL_EXPORT_REF OsclSocketServ *OsclSocketServ::NewL(Oscl_DefAlloc &alloc) +{ + OsclAny*p = alloc.ALLOCATE(sizeof(OsclSocketServ)); + OsclError::LeaveIfNull(p); + OsclSocketServ *self = OSCL_PLACEMENT_NEW(p, OsclSocketServ(alloc)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->iServ = OsclSocketServI::NewL(alloc); + OsclError::Pop(); + return self; +} + +OSCL_EXPORT_REF OsclSocketServ::~OsclSocketServ() +{ + if (iServ) + { + iServ->~OsclSocketServI(); + iAlloc.deallocate(iServ); + } +} + +OSCL_EXPORT_REF int32 OsclSocketServ::Connect(uint32 aMessageSlots, bool aShareSession) +{ + return (int32)iServ->Connect(aMessageSlots, aShareSession); +} + +OSCL_EXPORT_REF void OsclSocketServ::Close(bool aCleanup) +{ + iServ->Close(aCleanup); +} + +OSCL_EXPORT_REF OsclUDPSocket *OsclUDPSocket::NewL(Oscl_DefAlloc &alloc, + OsclSocketServ& aServ, + OsclSocketObserver *aObserver, + uint32 aId) +{ + OsclAny* p = alloc.ALLOCATE(sizeof(OsclUDPSocket)); + OsclError::LeaveIfNull(p); + OsclUDPSocket *self = OSCL_PLACEMENT_NEW(p, OsclUDPSocket(alloc)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->iUDPSocket = OsclUDPSocketI::NewL(alloc, aServ.iServ, aObserver, aId); + OsclError::Pop(); + return self; +} + +OSCL_EXPORT_REF OsclUDPSocket::~OsclUDPSocket() +{ + if (iUDPSocket) + { + iUDPSocket->~OsclUDPSocketI(); + iAlloc.deallocate(iUDPSocket); + } +} + +OSCL_EXPORT_REF int32 OsclUDPSocket::Bind(OsclNetworkAddress& aAddress) +{ + return iUDPSocket->Bind(aAddress); +} + +OSCL_EXPORT_REF int32 OsclUDPSocket::Join(OsclNetworkAddress& aAddress) +{ + return iUDPSocket->Join(aAddress); +} + +OSCL_EXPORT_REF int32 OsclUDPSocket::JoinMulticastGroup(OsclIpMReq& aMReq) +{ + return iUDPSocket->JoinMulticastGroup(aMReq); +} + +OSCL_EXPORT_REF int32 OsclUDPSocket::SetOptionToReuseAddress() +{ + return iUDPSocket->SetOptionToReuseAddress(); +} + +OSCL_EXPORT_REF int32 OsclUDPSocket::SetMulticastTTL(int32 aTTL) +{ + return iUDPSocket->SetMulticastTTL(aTTL); +} + +OSCL_EXPORT_REF int32 OsclUDPSocket::SetTOS(const OsclSocketTOS& aTOS) +{ + return iUDPSocket->SetTOS(aTOS); +} +OSCL_EXPORT_REF TPVSocketEvent OsclUDPSocket::BindAsync(OsclNetworkAddress& aAddress, int32 aTimeoutMsec) +{ + return iUDPSocket->BindAsync(aAddress, aTimeoutMsec); +} + +OSCL_EXPORT_REF void OsclUDPSocket::CancelBind() +{ + iUDPSocket->CancelBind(); +} + +OSCL_EXPORT_REF int32 OsclUDPSocket::Close() +{ + return iUDPSocket->Close(); +} + +OSCL_EXPORT_REF uint8 *OsclUDPSocket::GetRecvData(int32 *aLength) +{ + return iUDPSocket->GetRecvData(aLength); +} + +OSCL_EXPORT_REF uint8 *OsclUDPSocket::GetSendData(int32 *aLength) +{ + return iUDPSocket->GetSendData(aLength); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclUDPSocket::SendTo( + const uint8* aPtr, uint32 aLen, + OsclNetworkAddress& aAddress, + int32 aTimeoutMsec) +{ + return iUDPSocket->SendTo(aPtr, aLen, aAddress, aTimeoutMsec); +} + +OSCL_EXPORT_REF void OsclUDPSocket::CancelSendTo() +{ + iUDPSocket->CancelSendTo(); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclUDPSocket::RecvFrom( + uint8* aPtr, uint32 aMaxLen, + OsclNetworkAddress& aAddress, + int32 aTimeoutMsec, + uint32 aMultiMaxLen, + Oscl_Vector* aPacketLen, + Oscl_Vector* aPacketSource) +{ + return iUDPSocket->RecvFrom(aPtr, aMaxLen, aAddress, aTimeoutMsec, aMultiMaxLen, aPacketLen, aPacketSource); +} + +OSCL_EXPORT_REF void OsclUDPSocket::CancelRecvFrom() +{ + iUDPSocket->CancelRecvFrom(); +} + +OSCL_EXPORT_REF int32 OsclUDPSocket::SetRecvBufferSize(uint32 size) +{ + return iUDPSocket->SetRecvBufferSize(size); +} + +OSCL_EXPORT_REF int32 OsclUDPSocket::GetPeerName(OsclNetworkAddress& peerName) +{ + return iUDPSocket->GetPeerName(peerName); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclUDPSocket::ThreadLogon(OsclSocketServ& aServ, OsclSocketObserver *aObserver) +{ + return iUDPSocket->ThreadLogon(aServ.iServ, aObserver); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclUDPSocket::ThreadLogoff() +{ + return iUDPSocket->ThreadLogoff(); +} + +OSCL_EXPORT_REF OsclTCPSocket *OsclTCPSocket::NewL(Oscl_DefAlloc &alloc, + OsclSocketServ& aServ, + OsclSocketObserver *aObserver, + uint32 aId) +{ + OsclAny* p = alloc.ALLOCATE(sizeof(OsclTCPSocket)); + OsclError::LeaveIfNull(p); + OsclTCPSocket *self = OSCL_PLACEMENT_NEW(p, OsclTCPSocket(alloc)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + { + self->iTCPSocket = OsclTCPSocketI::NewL(alloc, aServ.iServ, aObserver, aId); + } + OsclError::Pop(); + return self; +} + +OsclTCPSocket *OsclTCPSocket::NewL(Oscl_DefAlloc &alloc, OsclTCPSocketI* aSocket) +{ + OsclAny* p = alloc.ALLOCATE(sizeof(OsclTCPSocket)); + OsclError::LeaveIfNull(p); + OsclTCPSocket *self = OSCL_PLACEMENT_NEW(p, OsclTCPSocket(alloc)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + { + if (!aSocket) + OsclError::Leave(OsclErrGeneral); + self->iTCPSocket = aSocket; + } + OsclError::Pop(); + return self; +} + +OSCL_EXPORT_REF OsclTCPSocket::~OsclTCPSocket() +{ + if (iTCPSocket) + { + iTCPSocket->~OsclTCPSocketI(); + iAlloc.deallocate(iTCPSocket); + } +} + +OSCL_EXPORT_REF int32 OsclTCPSocket::Bind(OsclNetworkAddress& aAddress) +{ + return iTCPSocket->Bind(aAddress); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclTCPSocket::BindAsync(OsclNetworkAddress& aAddress, int32 aTimeoutMsec) +{ + return iTCPSocket->BindAsync(aAddress, aTimeoutMsec); +} + +OSCL_EXPORT_REF void OsclTCPSocket::CancelBind() +{ + iTCPSocket->CancelBind(); +} + +OSCL_EXPORT_REF int32 OsclTCPSocket::Close() +{ + return iTCPSocket->Close(); +} + +OSCL_EXPORT_REF int32 OsclTCPSocket::Listen(int32 aQueueSize) +{ + return iTCPSocket->Listen(aQueueSize); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclTCPSocket::ListenAsync(int32 qsize, int32 aTimeoutMsec) +{ + return iTCPSocket->ListenAsync(qsize, aTimeoutMsec); +} + +OSCL_EXPORT_REF void OsclTCPSocket::CancelListen() +{ + iTCPSocket->CancelListen(); +} + +OSCL_EXPORT_REF OsclTCPSocket *OsclTCPSocket::GetAcceptedSocketL(uint32 aId) +{ + return OsclTCPSocket::NewL(iAlloc, iTCPSocket->GetAcceptedSocketL(aId)); +} + +OSCL_EXPORT_REF uint8 *OsclTCPSocket::GetRecvData(int32 *aLength) +{ + return iTCPSocket->GetRecvData(aLength); +} + +OSCL_EXPORT_REF uint8 *OsclTCPSocket::GetSendData(int32 *aLength) +{ + return iTCPSocket->GetSendData(aLength); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclTCPSocket::Connect(OsclNetworkAddress& aAddress, + int32 aTimeoutMsec) +{ + return iTCPSocket->Connect(aAddress, aTimeoutMsec); +} + +OSCL_EXPORT_REF void OsclTCPSocket::CancelConnect() +{ + iTCPSocket->CancelConnect(); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclTCPSocket::Shutdown(TPVSocketShutdown aHow, + int32 aTimeoutMsec) +{ + return iTCPSocket->Shutdown(aHow, aTimeoutMsec); +} + +OSCL_EXPORT_REF void OsclTCPSocket::CancelShutdown() +{ + iTCPSocket->CancelShutdown(); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclTCPSocket::Accept(int32 aTimeout) +{ + return iTCPSocket->Accept(aTimeout); +} + +OSCL_EXPORT_REF void OsclTCPSocket::CancelAccept() +{ + iTCPSocket->CancelAccept(); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclTCPSocket::Send( + const uint8* aPtr, uint32 aLen, + int32 aTimeoutMsec) +{ + return iTCPSocket->Send(aPtr, aLen, aTimeoutMsec); +} + +OSCL_EXPORT_REF void OsclTCPSocket::CancelSend() +{ + iTCPSocket->CancelSend(); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclTCPSocket::Recv( + uint8* aPtr, uint32 aMaxLen, + int32 aTimeoutMsec) +{ + return iTCPSocket->Recv(aPtr, aMaxLen, aTimeoutMsec); +} + +OSCL_EXPORT_REF void OsclTCPSocket::CancelRecv() +{ + iTCPSocket->CancelRecv(); +} + +OSCL_EXPORT_REF int32 OsclTCPSocket::SetOptionToReuseAddress() +{ + return iTCPSocket->SetOptionToReuseAddress(); +} + +OSCL_EXPORT_REF int32 OsclTCPSocket::SetTOS(const OsclSocketTOS& aTOS) +{ + return iTCPSocket->SetTOS(aTOS); +} + +OSCL_EXPORT_REF int32 OsclTCPSocket::GetPeerName(OsclNetworkAddress& peerName) +{ + return iTCPSocket->GetPeerName(peerName); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclTCPSocket::ThreadLogon(OsclSocketServ& aServ, OsclSocketObserver *aObserver) +{ + return iTCPSocket->ThreadLogon(aServ.iServ, aObserver); +} + +OSCL_EXPORT_REF TPVSocketEvent OsclTCPSocket::ThreadLogoff() +{ + return iTCPSocket->ThreadLogoff(); +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket.h new file mode 100644 index 0000000..dc0d6c0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket.h @@ -0,0 +1,761 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S O C K E T + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclio OSCL IO + * + * @{ + */ + + +/*! \file oscl_socket.h + \brief The file oscl_socket.h defines the OSCL Socket APIs. + +*/ +#ifndef OSCL_SOCKET_H_INCLUDED +#define OSCL_SOCKET_H_INCLUDED + +#ifndef OSCLCONFIG_IO_H_INCLUDED +#include "osclconfig_io.h" +#endif + +#ifndef OSCL_SOCKET_TYPES_H_INCLUDED +#include "oscl_socket_types.h" +#endif + +#ifndef OSCL_HEAPBASE_H_INCLUDED +#include "oscl_heapbase.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +/** +* Socket server +*/ +class OsclSocketServI; + +class OsclSocketServ : public HeapBase +{ + public: + /** + * Create a socket server. + * May leave if failure. + * + * @param alloc: Memory allocator. + * @return Returns pointer to socket server + */ + OSCL_IMPORT_REF static OsclSocketServ *NewL(Oscl_DefAlloc &alloc); + + /** + * Destructor. The server object must be deleted using + * the same allocator used in the NewL call. + */ + OSCL_IMPORT_REF ~OsclSocketServ(); + + /** + * Connect to socket server. + * This is a synchronous method. + * + * @param Number of message slots. + * @return Returns OsclErrNone for success, + * or a platform-specific code. + */ + OSCL_IMPORT_REF int32 Connect(uint32 aMessageSlots = 8, bool aShareSession = false); + + /** + * Close socket server. + * This is a synchronous method. + * @param aCleanup: cleanup the socket system? + * the socket cleanup should only be done when + * all parts of the application are done using + * sockets. + */ + OSCL_IMPORT_REF void Close(bool aCleanup = true); + + private: + OsclSocketServ(Oscl_DefAlloc &alloc): iServ(NULL), iAlloc(alloc) {} + + OsclSocketServI *iServ; + Oscl_DefAlloc &iAlloc; + + friend class OsclTCPSocket; + friend class OsclUDPSocket; + friend class OsclDNS; + +}; + + +class OsclUDPSocketI; + +/** +* The UDP Socket class +*/ + +class OsclUDPSocket : public HeapBase +{ + public: + /** + * Create a UDP Socket. + * May leave if failure. + * + * @param alloc: Memory allocator. + * @param aServ: Socket server. Must be connected. + * @param aObserver: Socket observer. + * @param aId: Socket ID. The caller must assign an ID + * to each socket. The ID is used to identify the socket + * in observer callbacks. + * @return Returns pointer to socket. + */ + OSCL_IMPORT_REF static OsclUDPSocket *NewL(Oscl_DefAlloc &alloc, + OsclSocketServ& aServ, + OsclSocketObserver *aObserver, + uint32 aId); + + /** + * Destructor. The object must be deleted using + * the same allocator used in the NewL call. + */ + OSCL_IMPORT_REF ~OsclUDPSocket(); + + /** + * Thread logoff routine. This will prepare for transfer and + * use of the socket in another thread. + * All socket requests must be complete prior to calling this + * routine. If any requests are still active, it will return + * EPVSocketFailure; + */ + OSCL_IMPORT_REF TPVSocketEvent ThreadLogoff(); + /** + * Thread logon routine. This will complete the transfer of + * a socket from another thread for use in the current thread. + * The ThreadLogoff API must be called in the original thread + * prior to calling ThreadLogon. + */ + OSCL_IMPORT_REF TPVSocketEvent ThreadLogon( + OsclSocketServ& aServ, + OsclSocketObserver *aObserver + ); + + /** + * Close a UDP socket. + * This is a synchronous method. + * + * Once it is closed a socket cannot be re-opened. + * Sockets are automatically closed when they + * are deleted. This method may be used to see + * any error code returned from the platform's + * socket close call. + * @return Returns OsclErrNone for success, or a + * platform-specific error code. + */ + OSCL_IMPORT_REF int32 Close(); + + /** + * Bind a UDP socket to an address. + * This is a synchronous method. + * + * @param aAddress: Bind address. + * @return Returns OsclErrNone for success, or a + * platform-specific error code. + */ + OSCL_IMPORT_REF int32 Bind(OsclNetworkAddress& aAddress); + + /** + * Bind a UDP socket to an address + * and Join the multicast group. + * This is a synchronous method. + * + * @param aAddress: Bind address. + * @return Returns OsclErrNone for success, or a + * platform-specific error code. + * May throw an OsclErrNotSupported Exception + */ + OSCL_IMPORT_REF int32 Join(OsclNetworkAddress& aAddress); + + /** + * Join the multicast group. + * @param aMReq: Multicast group information. + * @return Returns: OsclErrNone for success, or a + * platform-specific error code. or + * PVSOCK_ERR_NOT_SUPPORTED, if underlying OS doesn't support joining + * multicast group + * PVSOCK_ERR_BAD_PARAM, if config io file is not configured in + * accordance with underlying OS + * PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL + * for the underlying OS + */ + OSCL_IMPORT_REF int32 JoinMulticastGroup(OsclIpMReq& aMReq); + + /** + * Controls the number of intermediate systems through which a multicast + * datagram can be forwarded. + * @param aTTL:Specifies the time-to-live value for multicast datagrams + * sent through this socket. + * @return Returns: OsclErrNone for success, or a + * platform-specific error code. or + * PVSOCK_ERR_NOT_SUPPORTED, if underlying OS doesn't support joining + * multicast group + * PVSOCK_ERR_BAD_PARAM, if config io file is not configured in + * accordance with underlying OS + * PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL + * for the underlying OS + */ + OSCL_IMPORT_REF int32 SetMulticastTTL(int32 aTTL); + + /** + * Allows the server to bind to an address which is in a TIME_WAIT state. + * @return Returns: OsclErrNone for success, or a + * platform-specific error code. or + * PVSOCK_ERR_NOT_SUPPORTED, if underlying OS doesn't support joining + * multicast group + * PVSOCK_ERR_BAD_PARAM, if config io file is not configured in + * accordance with underlying OS + * PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL + * for the underlying OS + */ + OSCL_IMPORT_REF int32 SetOptionToReuseAddress(); + + /** + * Sets the Type of Service field of each outgoing IP datagram. + * @param aTOS: Specifies the type of service requested. + * @return Returns: OsclErrNone for success, or a + * platform-specific error code. or + * PVSOCK_ERR_NOT_SUPPORTED, if underlying OS doesn't support joining + * multicast group + * PVSOCK_ERR_BAD_PARAM, if config io file is not configured in + * accordance with underlying OS + * PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL + * for the underlying OS + */ + OSCL_IMPORT_REF int32 SetTOS(const OsclSocketTOS& aTOS); + + /** + * Retrieves the peer address of the socket + * @param aPeerName: This will store the peer address when API returns + * successfully. + * @return Returns OsclErrNone for success, or a + * platform-specific error code. or + * PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL + * for the underlying OS + */ + OSCL_IMPORT_REF int32 GetPeerName(OsclNetworkAddress& aPeerName); + + /** + * Bind a UDP socket to an address. + * This is an asynchronous method. + * + * @param aAddress: Bind address. + * @param aTimeoutMsec: Optional timeout. Use a negative + * value for infinite wait. + * @return Will return EPVSocketPending if successful. + * When the operation is complete, a callback to the + * observer will occur with the completion status. + * If the operation cannot be initiated, the call will + * return EPVSocketFailure and there will be no callback. + */ + OSCL_IMPORT_REF TPVSocketEvent BindAsync(OsclNetworkAddress& aAddress + , int32 aTimeoutMsec = (-1)); + + /** + * Cancel Bind + * + * This method will cancel any pending BindAsync operation + * on the current socket, causing the BindAsync to complete + * with error EPVSocketCancel. If there is no pending + * BindAsync operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelBind(); + + /** + * Retrieve the received data after a successful + * RecvFrom operation. + * This is a synchronous method. + * + * @param aLength: (output) number of bytes of data received. + * @return Returns pointer to received data, or NULL + * if none. + */ + OSCL_IMPORT_REF uint8 *GetRecvData(int32 *aLength); + + /** + * Retrieve the sent data after a successful + * SendTo operation. + * This is a synchronous method. + * + * @param aLength: (output) number of bytes of data sent. + * @return Returns pointer to sent data, or NULL + * if none. + */ + OSCL_IMPORT_REF uint8 *GetSendData(int32 *aLength); + + /** + * Send Data. + * This is an asynchronous method. + * + * @param aPtr: Data to send. + * @param aLen: Length of data to send. + * @param aAddress: Destination address. + * @param aTimeoutMsec: Timeout in milliseconds, or (-1) + * for infinite wait. + * @return Will return EPVSocketPending if successful. + * When the operation is complete, a callback to the + * observer will occur with the completion status. + * If the operation cannot be initiated, the call will + * return EPVSocketFailure and there will be no callback. + */ + OSCL_IMPORT_REF TPVSocketEvent SendTo(const uint8* aPtr, uint32 aLen, + OsclNetworkAddress& aAddress, + int32 aTimeoutMsec = -1); + /** + * Cancel SendTo + * + * This method will cancel any pending SendTo operation + * on the current socket, causing the SendTo to complete + * with error EPVSocketCancel. If there is no pending + * SendTo operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelSendTo(); + + /** + * Receive Data. + * This is an asynchronous method. + * + * @param aPtr: Buffer to receive incoming data + * @param aMaxLen: Length of buffer. + * @param aAddress: (output) Source address. + * @param aTimeoutMsec: Timeout in milliseconds, or (-1) + * for infinite wait. + * + * @param aMultiRecvLimit (optional input): Configures multiple + * packet receive mode. As long as there are packets queued at + * the socket and at least aMultiRecvLimit bytes are available + * in the buffer, recvfrom operations will continue. + * A value of zero disabled multiple packet mode. + * The individual packet lengths can be retrieved in the + * aPacketLen parameter; and the individual packet + * source addresses can be retrieved in the aPacketSource parameter. + * @param aPacketLen: (optional output) a vector of packet lengths, + * in case multiple packets were received. + * @param aPacketSource: (optional output) a vector of source addresses, + * in case multiple packets were received. + * + * @return Will return EPVSocketPending if successful. + * When the operation is complete, a callback to the + * observer will occur with the completion status. + * If the operation cannot be initiated, the call will + * return EPVSocketFailure and there will be no callback. + */ + OSCL_IMPORT_REF TPVSocketEvent RecvFrom(uint8* aPtr, uint32 aMaxLen, + OsclNetworkAddress& aAddress, + int32 aTimeoutMsec = -1, + uint32 aMultiRecvLimit = 0, + Oscl_Vector* aPacketLen = NULL, + Oscl_Vector* aPacketSource = NULL); + /** + * Cancel RecvFrom + * + * This method will cancel any pending RecvFrom operation + * on the current socket, causing the RecvFrom to complete + * with error EPVSocketCancel. If there is no pending + * RecvFrom operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelRecvFrom(); + + /** + * Set the buffer size of the socket + * This is a synchronous method. + * @param size: buffer size + * @return Returns OsclErrNone for success, or a + * platform-specific error code. + * May throw an OsclErrNotSupported Exception. + */ + + OSCL_IMPORT_REF int32 SetRecvBufferSize(uint32 size); + + private: + OsclUDPSocket(Oscl_DefAlloc &alloc): iUDPSocket(NULL), iAlloc(alloc) {} + OsclUDPSocketI *iUDPSocket; + Oscl_DefAlloc &iAlloc; +}; + +class OsclTCPSocketI; + +/** +* The TCP Socket class +*/ + +class OsclTCPSocket : public HeapBase +{ + public: + /** + * Create a TCP Socket. + * May leave if failure. + * + * @param alloc: Memory allocator. + * @param aServ: Socket server. Must be connected. + * @param aObserver: Socket observer. + * @param aId: Socket ID. The caller must assign an ID + * to each socket. The ID is used to identify the socket + * in observer callbacks. + * @return Returns pointer to socket. + */ + OSCL_IMPORT_REF static OsclTCPSocket *NewL(Oscl_DefAlloc &alloc, + OsclSocketServ& aServ, + OsclSocketObserver *aObserver, + uint32 aId); + + /** + * Destructor. The object must be deleted using + * the same allocator used in the NewL call. + */ + OSCL_IMPORT_REF ~OsclTCPSocket(); + + /** + * Thread logoff routine. This will prepare for transfer and + * use of the socket in another thread. + * All socket requests must be complete prior to calling this + * routine. If any requests are still active, it will return + * EPVSocketFailure; + */ + OSCL_IMPORT_REF TPVSocketEvent ThreadLogoff(); + /** + * Thread logon routine. This will complete the transfer of + * a socket from another thread for use in the current thread. + * The ThreadLogoff API must be called in the original thread + * prior to calling ThreadLogon. + */ + OSCL_IMPORT_REF TPVSocketEvent ThreadLogon( + OsclSocketServ& aServ, + OsclSocketObserver *aObserver + ); + + /** + * Close a TCP socket. + * This is a synchronous method. + * + * Once it is closed a socket cannot be re-opened. + * Sockets are automatically closed when they + * are deleted. This method may be used to see + * any error code returned from the platform's + * socket close call. + * @return Returns OsclErrNone for success, or a + * platform-specific error code. + */ + OSCL_IMPORT_REF int32 Close(); + + /** + * Bind a TCP socket to an address. + * This is a synchronous method. + * + * @param aAddress: Bind address. + * @return Returns OsclErrNone for success, or a + * platform-specific error code. + */ + OSCL_IMPORT_REF int32 Bind(OsclNetworkAddress& aAddress); + + /** + * Bind a TCP socket to an address. + * This is an asynchronous method. + * + * @param aAddress: Bind address. + * @param aTimeoutMsec: Optional timeout. Use a negative + * value for infinite wait. + * @return Will return EPVSocketPending if successful. + * When the operation is complete, a callback to the + * observer will occur with the completion status. + * If the operation cannot be initiated, the call will + * return EPVSocketFailure and there will be no callback. + */ + OSCL_IMPORT_REF TPVSocketEvent BindAsync(OsclNetworkAddress& aAddress + , int32 aTimeoutMsec = (-1)); + + /** + * Cancel Bind + * + * This method will cancel any pending BindAsync operation + * on the current socket, causing the BindAsync to complete + * with error EPVSocketCancel. If there is no pending + * BindAsync operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelBind(); + + /** + * Allows the server to bind to an address which is in a TIME_WAIT state. + * @return Returns: OsclErrNone for success, or a + * platform-specific error code. or + * PVSOCK_ERR_NOT_SUPPORTED, if underlying OS doesn't support joining + * multicast group + * PVSOCK_ERR_BAD_PARAM, if config io file is not configured in + * accordance with underlying OS + * PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL + * for the underlying OS + */ + OSCL_IMPORT_REF int32 SetOptionToReuseAddress(); + + /** + * Sets the Type of Service field of each outgoing IP datagram. + * @param aTOS: Specifies the type of service requested. + * @return Returns: OsclErrNone for success, or a + * platform-specific error code. or + * PVSOCK_ERR_NOT_SUPPORTED, if underlying OS doesn't support joining + * multicast group + * PVSOCK_ERR_BAD_PARAM, if config io file is not configured in + * accordance with underlying OS + * PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL + * for the underlying OS + */ + OSCL_IMPORT_REF int32 SetTOS(const OsclSocketTOS& aTOS); + + /** + * Retrieves the peer address of the socket + * @param aPeerName: This will store the peer address when API returns + * successfully. + * @return Returns OsclErrNone for success, or a + * platform-specific error code. or + * PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL + * for the underlying OS + */ + OSCL_IMPORT_REF int32 GetPeerName(OsclNetworkAddress& aPeerName); + /** + * Listen. + * This is a synchronous method. + * + * @param aQueueSize: Queue size. + * @return Returns OsclErrNone for success, or a + * platform-specific error code. + */ + OSCL_IMPORT_REF int32 Listen(int32 aQueueSize); + + /** + * ListenAsync + * This is an asynchronous method. + * + * @param aQueueSize: Queue size. + * @param aTimeoutMsec: Optional timeout. Use a negative + * value for infinite wait. + * @return Will return EPVSocketPending if successful. + * When the operation is complete, a callback to the + * observer will occur with the completion status. + * If the operation cannot be initiated, the call will + * return EPVSocketFailure and there will be no callback. + */ + OSCL_IMPORT_REF TPVSocketEvent ListenAsync(int32 aQueueSize, int32 aTimeoutMsec = (-1)); + + /** + * Cancel Async Listen + * + * This method will cancel any pending ListenAsync operation + * on the current socket, causing the Listen to complete + * with error EPVSocketCancel. If there is no pending + * Listen operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelListen(); + + /** + * Retrieve the accept socket after a successful + * Accept operation. + * This is a synchronous method. + * + * @param aId: Socket ID. The caller must assign an ID + * to each socket. The ID is used to identify the socket + * in observer callbacks. + * @return Returns pointer to socket, or NULL if error. + * Note: The caller is reponsible for deleting any accepted + * socket that it retrieves. + */ + OSCL_IMPORT_REF OsclTCPSocket *GetAcceptedSocketL(uint32 aId); + + /** + * Retrieve the received data after a successful + * Recv operation. + * This is a synchronous method. + * + * @param aLength: (output) number of bytes of data received. + * @return Returns pointer to received data, or NULL + * if none. + */ + OSCL_IMPORT_REF uint8 *GetRecvData(int32 *aLength); + + /** + * Retrieve the sent data after a successful + * Send operation. + * This is a synchronous method. + * + * @param aLength: (output) number of bytes of data sent. + * @return Returns pointer to sent data, or NULL + * if none. + */ + OSCL_IMPORT_REF uint8 *GetSendData(int32 *aLength); + + /** + * Connect to an address. + * This is an asynchronous method. + * + * @param aAddress: a network address. + * @param aTimeoutMsec: Timeout in milliseconds, or (-1) + * for infinite wait. + * @return Will return EPVSocketPending if successful. + * When the operation is complete, a callback to the + * observer will occur with the completion status. + * If the operation cannot be initiated, the call will + * return EPVSocketFailure and there will be no callback. + */ + OSCL_IMPORT_REF TPVSocketEvent Connect(OsclNetworkAddress& aAddress, + int32 aTimeoutMsec = -1); + + /** + * Cancel Connect + * + * This method will cancel any pending Connect operation + * on the current socket, causing the Connect to complete + * with error EPVSocketCancel. If there is no pending + * Connect operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelConnect(); + + /** + * Shutdown a socket. + * This is an asynchronous method. + * + * @param aHow: type of shutdown + * @param aTimeoutMsec: Timeout in milliseconds, or (-1) + * for infinite wait. + * @return Will return EPVSocketPending if successful. + * When the operation is complete, a callback to the + * observer will occur with the completion status. + * If the operation cannot be initiated, the call will + * return EPVSocketFailure and there will be no callback. + */ + OSCL_IMPORT_REF TPVSocketEvent Shutdown(TPVSocketShutdown aHow, + int32 aTimeoutMsec = -1); + + /** + * Cancel Shutdown + * + * This method will cancel any pending Shutdown operation + * on the current socket, causing the Shutdown to complete + * with error EPVSocketCancel. If there is no pending + * Shutdown operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelShutdown(); + + /** + * Accept incoming connections. + * This is an asynchronous method. + * + * @param aTimeoutMsec: Timeout in milliseconds, or (-1) + * for infinite wait. + * @return Will return EPVSocketPending if successful. + * When the operation is complete, a callback to the + * observer will occur with the completion status. + * If the operation cannot be initiated, the call will + * return EPVSocketFailure and there will be no callback. + */ + OSCL_IMPORT_REF TPVSocketEvent Accept(int32 aTimeout = -1); + + /** + * Cancel Accept + * + * This method will cancel any pending Accept operation + * on the current socket, causing the Accept to complete + * with error EPVSocketCancel. If there is no pending + * Accept operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelAccept(); + + /** + * Send Data. + * This is an asynchronous method. + * + * @param aPtr: Data to send. + * @param aLen: Length of data to send. + * @param aTimeoutMsec: Timeout in milliseconds, or (-1) + * for infinite wait. + * @return Will return EPVSocketPending if successful. + * When the operation is complete, a callback to the + * observer will occur with the completion status. + * If the operation cannot be initiated, the call will + * return EPVSocketFailure and there will be no callback. + */ + OSCL_IMPORT_REF TPVSocketEvent Send(const uint8* aPtr, uint32 aLen, + int32 aTimeoutMsec = -1); + + /** + * Cancel Send + * + * This method will cancel any pending Send operation + * on the current socket, causing the Send to complete + * with error EPVSocketCancel. If there is no pending + * Send operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelSend(); + + /** + * Receive Data. + * This is an asynchronous method. + * + * @param aPtr: Buffer for received data. + * @param aMaxLen: Length of buffer. + * @param aTimeoutMsec: Timeout in milliseconds, or (-1) + * for infinite wait. + * @return Will return EPVSocketPending if successful. + * When the operation is complete, a callback to the + * observer will occur with the completion status. + * If the operation cannot be initiated, the call will + * return EPVSocketFailure and there will be no callback. + */ + OSCL_IMPORT_REF TPVSocketEvent Recv(uint8* aPtr, uint32 aMaxLen, + int32 aTimeoutMsec = -1); + + /** + * Cancel Recv + * + * This method will cancel any pending Recv operation + * on the current socket, causing the Recv to complete + * with error EPVSocketCancel. If there is no pending + * Recv operation, this method will have no effect. + */ + OSCL_IMPORT_REF void CancelRecv(); + + private: + static OsclTCPSocket *NewL(Oscl_DefAlloc &alloc, OsclTCPSocketI* aSocket); + + private: + OsclTCPSocket(Oscl_DefAlloc &alloc): iTCPSocket(NULL), iAlloc(alloc) {} + OsclTCPSocketI *iTCPSocket; + Oscl_DefAlloc &iAlloc; +}; + +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_accept.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_accept.cpp new file mode 100644 index 0000000..f2d6ba5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_accept.cpp @@ -0,0 +1,148 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_accept.h" + +//////////// Method ///////////////////// + +OsclAcceptMethod *OsclAcceptMethod::NewL(OsclIPSocketI& c) +{ + OsclAny*p = c.Alloc().ALLOCATE(sizeof(OsclAcceptMethod)); + OsclError::LeaveIfNull(p); + OsclAcceptMethod* self = OSCL_PLACEMENT_NEW(p, OsclAcceptMethod(c)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclAcceptMethod::ConstructL() +{ + OsclAny*p = iContainer.Alloc().ALLOCATE(sizeof(OsclAcceptRequest)); + OsclError::LeaveIfNull(p); + OsclAcceptRequest* self = OSCL_PLACEMENT_NEW(p, OsclAcceptRequest(*this)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + iSocketRequestAO = self; + OsclSocketMethod::ConstructL(iSocketRequestAO); +} + +OsclAcceptMethod::~OsclAcceptMethod() +{ + if (AcceptRequest()) + { + AcceptRequest()->~OsclAcceptRequest(); + Alloc().deallocate(AcceptRequest()); + } + DiscardAcceptedSocket(); +} + +TPVSocketEvent OsclAcceptMethod::Accept(int32 aTimeout) +{ + //in case previous accepted socket was never + //retrieved... + DiscardAcceptedSocket(); + + iAcceptedSocket = OsclSocketI::NewL(Alloc()); + + if (iAcceptedSocket->Open(*SocketServ()) != OsclErrNone) + { + DiscardAcceptedSocket(); + return EPVSocketFailure; + } + + if (!StartMethod(aTimeout)) + { + DiscardAcceptedSocket(); + return EPVSocketFailure; + } + + AcceptRequest()->Accept(*iAcceptedSocket); + return EPVSocketPending; +} + +void OsclAcceptMethod::DiscardAcceptedSocket() +{ + if (iAcceptedSocket) + { + iAcceptedSocket->~OsclSocketI(); + Alloc().deallocate(iAcceptedSocket); + } + iAcceptedSocket = NULL; +} + +OsclSocketI *OsclAcceptMethod::GetAcceptedSocket() +{ + if (iAcceptedSocket) + { + //Clear accepted socket once it has been retrieved. + OsclSocketI *sock = iAcceptedSocket; + iAcceptedSocket = NULL; + return sock; + } + else + return NULL; +} + +void OsclAcceptMethod::Run() +{ + //The request timed out! + + //must discard accepted socket in addition + //to the usual timeout Run + DiscardAcceptedSocket(); + + //call the base class Run + OsclSocketMethod::Run(); +} + +//////////// Request ///////////////////// + +void OsclAcceptRequest::Accept(OsclSocketI &aSocket) +{ + OsclAny *p = NewRequest(sizeof(AcceptParam)); + if (!p) + PendComplete(OsclErrNoMemory); + else + { + iParam = OSCL_PLACEMENT_NEW(p, AcceptParam(aSocket)); + if (!iParam) + PendComplete(OsclErrNoMemory); + else + SocketI()->Accept(*Param(), *this); + } +} + +void OsclAcceptRequest::Run() +{ + //The request was completed by the socket server + + //may need to discard accepted socket in addition to + //the usual request completion. + if (Status() != OSCL_REQUEST_ERR_NONE) + ((OsclAcceptMethod*)&iContainer)->DiscardAcceptedSocket(); + + //call the base class Run + OsclSocketRequestAO::Run(); +} + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_accept.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_accept.h new file mode 100644 index 0000000..dafa5b9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_accept.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_ACCEPT_H_INCLUDED +#define OSCL_SOCKET_ACCEPT_H_INCLUDED + + +#include "oscl_socket_imp.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_socket_method.h" + +/** + Internal implementation of Accept + */ +class OsclAcceptRequest; + +class OsclAcceptMethod : public OsclSocketMethod +{ + public: + static OsclAcceptMethod *NewL(OsclIPSocketI& c); + + ~OsclAcceptMethod(); + + TPVSocketEvent Accept(int32 aTimeout); + + void DiscardAcceptedSocket(); + OsclSocketI *GetAcceptedSocket(); + + private: + + OsclAcceptMethod(OsclIPSocketI &c) + : OsclSocketMethod(c, "osclacceptmethod", EPVSocketAccept) + , iAcceptedSocket(NULL) + {} + + void ConstructL(); + + void Run(); + + OsclSocketServI *SocketServ() + { + return iContainer.SocketServ(); + } + public: + OsclAcceptRequest *AcceptRequest() + { + return (OsclAcceptRequest*)iSocketRequestAO; + } + private: + OsclSocketI *iAcceptedSocket; +}; + +/** + This is the AO that interacts with the socket server + */ +class AcceptParam; + +class OsclAcceptRequest : public OsclSocketRequestAO +{ + public: + OsclAcceptRequest(OsclSocketMethod& c) + : OsclSocketRequestAO(c, "osclacceptreq") + {} + + void Accept(OsclSocketI &aSocket); + + private: + void Run(); + + AcceptParam*Param() + { + return(AcceptParam*)iParam; + } +}; + + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_bind.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_bind.cpp new file mode 100644 index 0000000..72ebb0f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_bind.cpp @@ -0,0 +1,94 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_bind.h" + +//////////// Method ///////////////////// + +OsclBindMethod *OsclBindMethod::NewL(OsclIPSocketI& c) +{ + OsclAny*p = c.Alloc().ALLOCATE(sizeof(OsclBindMethod)); + OsclError::LeaveIfNull(p); + OsclBindMethod* self = OSCL_PLACEMENT_NEW(p, OsclBindMethod(c)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclBindMethod::ConstructL() +{ + OsclAny*p = Alloc().ALLOCATE(sizeof(OsclBindRequest)); + OsclError::LeaveIfNull(p); + OsclBindRequest* self = OSCL_PLACEMENT_NEW(p, OsclBindRequest(*this)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + iSocketRequestAO = self; + OsclSocketMethod::ConstructL(iSocketRequestAO); +} + +OsclBindMethod::~OsclBindMethod() +{ + if (BindRequest()) + { + BindRequest()->~OsclBindRequest(); + Alloc().deallocate(BindRequest()); + } +} + +TPVSocketEvent OsclBindMethod::Bind(OsclNetworkAddress& aAddress, + int32 aTimeout) +{ + if (!StartMethod(aTimeout)) + return EPVSocketFailure; + + BindRequest()->Bind(aAddress); + + return EPVSocketPending; +} + +//////////// AO ///////////////////// + + +void OsclBindRequest::Bind(OsclNetworkAddress &aAddress) +{ + OsclAny *p = NewRequest(sizeof(BindParam)); + if (!p) + PendComplete(OsclErrNoMemory); + else + { + iParam = OSCL_PLACEMENT_NEW(p, BindParam(aAddress)); + if (!iParam) + PendComplete(OsclErrNoMemory); + else + { + SocketI()->BindAsync(*Param(), *this); + } + } +} + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_bind.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_bind.h new file mode 100644 index 0000000..e9479c0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_bind.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_BIND_H_INCLUDED +#define OSCL_SOCKET_BIND_H_INCLUDED + +#include "oscl_socket_types.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_method.h" + +/** + Internal implementation of async Bind + */ +class OsclBindRequest; + +class OsclBindMethod : public OsclSocketMethod +{ + public: + static OsclBindMethod *NewL(OsclIPSocketI& c); + + ~OsclBindMethod(); + + TPVSocketEvent Bind(OsclNetworkAddress& aAddress, + int32 aTimeout); + + private: + OsclBindMethod(OsclIPSocketI& c) + : OsclSocketMethod(c, "osclbindmethod", EPVSocketBind) + {} + + void ConstructL(); + + public: + OsclBindRequest *BindRequest() + { + return (OsclBindRequest*)iSocketRequestAO; + } +}; + +/** + This is the AO that interacts with the socket server + */ +class OsclBindRequest : public OsclSocketRequestAO +{ + public: + OsclBindRequest(OsclSocketMethod& c) + : OsclSocketRequestAO(c, "osclBindRequest") + {} + + void Bind(OsclNetworkAddress &aAddress); + + private: + + BindParam*Param() + { + return(BindParam*)iParam; + } + +}; + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_connect.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_connect.cpp new file mode 100644 index 0000000..1fc7f02 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_connect.cpp @@ -0,0 +1,94 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_connect.h" + +//////////// Method ///////////////////// + +OsclConnectMethod *OsclConnectMethod::NewL(OsclIPSocketI& c) +{ + OsclAny*p = c.Alloc().ALLOCATE(sizeof(OsclConnectMethod)); + OsclError::LeaveIfNull(p); + OsclConnectMethod* self = OSCL_PLACEMENT_NEW(p, OsclConnectMethod(c)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclConnectMethod::ConstructL() +{ + OsclAny*p = Alloc().ALLOCATE(sizeof(OsclConnectRequest)); + OsclError::LeaveIfNull(p); + OsclConnectRequest* self = OSCL_PLACEMENT_NEW(p, OsclConnectRequest(*this)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + iSocketRequestAO = self; + OsclSocketMethod::ConstructL(iSocketRequestAO); +} + +OsclConnectMethod::~OsclConnectMethod() +{ + if (ConnectRequest()) + { + ConnectRequest()->~OsclConnectRequest(); + Alloc().deallocate(ConnectRequest()); + } +} + +TPVSocketEvent OsclConnectMethod::Connect(OsclNetworkAddress& aAddress, + int32 aTimeout) +{ + if (!StartMethod(aTimeout)) + return EPVSocketFailure; + + ConnectRequest()->Connect(aAddress); + + return EPVSocketPending; +} + +//////////// AO ///////////////////// + + +void OsclConnectRequest::Connect(OsclNetworkAddress &aAddress) +{ + OsclAny *p = NewRequest(sizeof(ConnectParam)); + if (!p) + PendComplete(OsclErrNoMemory); + else + { + iParam = OSCL_PLACEMENT_NEW(p, ConnectParam(aAddress)); + if (!iParam) + PendComplete(OsclErrNoMemory); + else + { + SocketI()->Connect(*Param(), *this); + } + } +} + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_connect.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_connect.h new file mode 100644 index 0000000..0ab54a9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_connect.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_CONNECT_H_INCLUDED +#define OSCL_SOCKET_CONNECT_H_INCLUDED + +#include "oscl_socket_types.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_method.h" + +/** + Internal implementation of Connect + */ +class OsclConnectRequest; + +class OsclConnectMethod : public OsclSocketMethod +{ + public: + static OsclConnectMethod *NewL(OsclIPSocketI& c); + + ~OsclConnectMethod(); + + TPVSocketEvent Connect(OsclNetworkAddress& aAddress, + int32 aTimeout); + + private: + OsclConnectMethod(OsclIPSocketI& c) + : OsclSocketMethod(c, "osclconnectmethod", EPVSocketConnect) + {} + + void ConstructL(); + + public: + OsclConnectRequest *ConnectRequest() + { + return (OsclConnectRequest*)iSocketRequestAO; + } +}; + +/** + This is the AO that interacts with the socket server + */ +class OsclConnectRequest : public OsclSocketRequestAO +{ + public: + OsclConnectRequest(OsclSocketMethod& c) + : OsclSocketRequestAO(c, "osclConnectRequest") + {} + + void Connect(OsclNetworkAddress &aAddress); + + private: + + ConnectParam*Param() + { + return(ConnectParam*)iParam; + } + +}; + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp.h new file mode 100644 index 0000000..43c2158 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp.h @@ -0,0 +1,38 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#ifndef OSCL_SOCKET_IMP_H_INCLUDED +#define OSCL_SOCKET_IMP_H_INCLUDED +/*! +** A common include file for OsclSocketI declaration +*/ + +#include "oscl_socket_tuneables.h" + +#if (PV_SOCKET_SERVER) +#include "oscl_socket_imp_pv.h" +#else +#error No implementation! +#endif + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_base.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_base.cpp new file mode 100644 index 0000000..a8f5e05 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_base.cpp @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! +** Socket implementation base class +*/ + +#include "oscl_socket_imp_base.h" + +OsclSocketIBase::OsclSocketIBase(Oscl_DefAlloc &a): iAlloc(a) +{} + +OsclSocketIBase::~OsclSocketIBase() +{ +} + +void OsclSocketIBase::CancelFxn(TPVSocketFxn aType) +{ + switch (aType) + { + case EPVSocketConnect: + CancelConnect(); + break; + case EPVSocketAccept: + CancelAccept(); + break; + case EPVSocketShutdown: + CancelShutdown(); + break; + case EPVSocketSend: + CancelSend(); + break; + case EPVSocketRecv: + CancelRecv(); + break; + case EPVSocketSendTo: + CancelSendTo(); + break; + case EPVSocketRecvFrom: + CancelRecvFrom(); + break; + case EPVSocketBind: + CancelBind(); + break; + case EPVSocketListen: + CancelListen(); + break; + default: + OSCL_ASSERT(false); + break; + } +} + +int OsclSocketIBase::GetShutdown(TPVSocketShutdown aOsclVal) +//map socket API value to platform-specific value. +{ + switch (aOsclVal) + { + case EPVSocketRecvShutdown: + return OSCL_SD_RECEIVE; + case EPVSocketSendShutdown: + return OSCL_SD_SEND; + case EPVSocketBothShutdown: + return OSCL_SD_BOTH; + default: + OSCL_ASSERT(0); + } + return 0; +} + + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_base.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_base.h new file mode 100644 index 0000000..4066242 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_base.h @@ -0,0 +1,116 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#ifndef OSCL_SOCKET_IMP_BASE_H_INCLUDED +#define OSCL_SOCKET_IMP_BASE_H_INCLUDED + +#include "oscl_socket_types.h" +#include "oscl_socket_request.h" +#include "oscl_defalloc.h" +#include "oscl_mutex.h" +#include "oscl_socket_stats.h" +#include "oscl_base.h" + +class OsclSocketServI; + +/*! Socket implementation base class +*/ +class OsclSocketIBase +{ + public: + virtual ~OsclSocketIBase(); + + //synchronous methods + virtual int32 Open(OsclSocketServI& aServer, uint32 addrFamily, uint32 sockType, uint32 protocol) = 0; + virtual int32 Open(OsclSocketServI& aServer) = 0; + virtual int32 Bind(OsclNetworkAddress& anAddr) = 0; + virtual int32 Join(OsclNetworkAddress& anAddr) = 0; + virtual int32 Close() = 0; + virtual int32 Listen(uint32 qSize) = 0; + + //asynchronous methods. + virtual void Connect(ConnectParam& , OsclSocketRequestAO&) = 0; + + virtual void Accept(AcceptParam &, OsclSocketRequestAO&) = 0; + + virtual void Shutdown(ShutdownParam &, OsclSocketRequestAO&) = 0; + + virtual void Send(SendParam &, OsclSocketRequestAO&) = 0; + virtual void SendSuccess(SendParam &) = 0; + + virtual void SendTo(SendToParam & , OsclSocketRequestAO&) = 0; + virtual void SendToSuccess(SendToParam &) = 0; + + virtual void Recv(RecvParam &, OsclSocketRequestAO&) = 0; + virtual void RecvSuccess(RecvParam &) = 0; + + virtual void RecvFrom(RecvFromParam &, OsclSocketRequestAO&) = 0; + virtual void RecvFromSuccess(RecvFromParam &) = 0; + + //optional async methods + virtual void BindAsync(BindParam&, OsclSocketRequestAO&) + {} + virtual void ListenAsync(ListenParam&, OsclSocketRequestAO&) + {} + static bool HasAsyncBind() ; + static bool HasAsyncListen() ; + + void CancelFxn(TPVSocketFxn); + + protected: + OsclSocketIBase(Oscl_DefAlloc &a); + + virtual void CancelConnect() = 0; + virtual void CancelAccept() = 0; + virtual void CancelShutdown() = 0; + virtual void CancelSend() = 0; + virtual void CancelSendTo() = 0; + virtual void CancelRecv() = 0; + virtual void CancelRecvFrom() = 0; + + //optional methods, for async bind/listen + virtual void CancelBind() + {} + virtual void CancelListen() + {} + + Oscl_DefAlloc &iAlloc; + + static int GetShutdown(TPVSocketShutdown aOsclVal); + + virtual bool IsOpen() = 0; + + //link to socket server. + OsclSocketServI *iSocketServ; + friend class OsclSocketRequest; + friend class OsclSocketMethod; + friend class OsclSocketRequestAO; + +#if(PV_OSCL_SOCKET_STATS_LOGGING) + OsclSocketStats iStats; +#endif + + friend class OsclUDPSocket; + friend class OsclTCPSocket; +}; + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_pv.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_pv.cpp new file mode 100644 index 0000000..baa5fa7 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_pv.cpp @@ -0,0 +1,586 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! +** Socket implementation for PV socket server +*/ + +#include "oscl_socket_tuneables.h" +#if(PV_SOCKET_SERVER) +#include "oscl_socket_imp_pv.h" +#include "oscl_socket_serv_imp_pv.h" +#include "oscl_socket_method.h" + +//Stats macros for use with OsclSocketI +#if(PV_OSCL_SOCKET_STATS_LOGGING) +#define ADD_STATS(x,y) iStats.Add(x,y) +#define CONSTRUCT_STATS(x,y) iStats.Construct(x,y) +#else +#define ADD_STATS(x,y) +#define CONSTRUCT_STATS(x,y) +#endif + +OsclSocketI::OsclSocketI(Oscl_DefAlloc &a) : OsclSocketIBase(a) +{ + iSocketServ = NULL; + InitSocket(false); + + iSockServAcceptRequest.iSocketI = this; + iSockServConnectRequest.iSocketI = this; + iSockServRecvRequest.iSocketI = this; + iSockServRecvFromRequest.iSocketI = this; + iSockServSendRequest.iSocketI = this; + iSockServSendToRequest.iSocketI = this; + iSockServShutdownRequest.iSocketI = this; + iLogger = PVLogger::GetLoggerObject("osclsocket"); +} + +TPVSocketEvent OsclSocketI::ThreadLogoff() +{ + iLogger = NULL; + iSocketServ = NULL; +#if(PV_OSCL_SOCKET_STATS_LOGGING) + iStats.ThreadLogoff(); +#endif + return EPVSocketSuccess; +} + +TPVSocketEvent OsclSocketI::ThreadLogon(OsclSocketServI* aServ) +{ + iLogger = PVLogger::GetLoggerObject("osclsocket"); + iSocketServ = aServ; +#if(PV_OSCL_SOCKET_STATS_LOGGING) + iStats.ThreadLogon(); +#endif + return EPVSocketSuccess; +} +OsclSocketI::~OsclSocketI() +{ + Close(); +} + +OsclSocketI* OsclSocketI::NewL(Oscl_DefAlloc &a) +{ + OsclAny*p = a.ALLOCATE(sizeof(OsclSocketI)); + OsclError::LeaveIfNull(p); + OsclSocketI *self = OSCL_PLACEMENT_NEW(p, OsclSocketI(a)); + OsclError::LeaveIfNull(self); + return self; +} + +int32 OsclSocketI::Close() +{ + int sockerr = 0; + + //cleanup the OS-level socket + if (iSocketValid) + { +#ifdef OsclCloseSocket + //call the platform socket close routine... + bool ok; + OsclCloseSocket(iSocket, ok, sockerr); +#else + sockerr = PVSOCK_ERR_NOT_IMPLEMENTED; +#endif + } + + InitSocket(false); + return sockerr; + +} + +bool OsclSocketIBase::HasAsyncBind() +{ + return false; +} + +int32 OsclSocketI::Bind(OsclNetworkAddress& anAddr) +{ +#ifdef OsclBind + TOsclSockAddr addr; + MakeAddr(anAddr, addr); + int err; + bool ok; + OsclBind(iSocket, addr, ok, err); + if (!ok) + return err; +#if (PV_OSCL_SOCKET_1MB_RECV_BUF) + int bufsize = (1024 * 1024); + OsclSetRecvBufferSize(iSocket, bufsize, ok, err); +#endif + return OsclErrNone; +#else + return PVSOCK_ERR_NOT_IMPLEMENTED; +#endif +} + +int32 OsclSocketI::GetOsclSockOptLevelName(const TPVSocketOptionLevel aOptionLevel, const TPVSocketOptionName aOptionName, int32& aOsclOptionLevel, int32& aOsclOptionName) +{ + int32 retval = OsclErrNone; + switch (aOptionLevel) + { + case EPVIPProtoIP: + { + aOsclOptionLevel = OSCL_SOL_IP; + switch (aOptionName) + { + case EPVIPMulticastTTL: + aOsclOptionName = OSCL_SOCKOPT_IP_MULTICAST_TTL; + break; + case EPVIPAddMembership: + aOsclOptionName = OSCL_SOCKOPT_IP_ADDMEMBERSHIP; + break; + case EPVIPTOS: + aOsclOptionName = OSCL_SOCKOPT_IP_TOS; + break; + default: + retval = PVSOCK_ERR_BAD_PARAM; + } + } + break; + case EPVIPProtoTCP: + { + aOsclOptionLevel = OSCL_SOL_TCP; + retval = PVSOCK_ERR_BAD_PARAM; // None of socket options at TCP level supported in OSCL presently + } + break; + case EPVSocket: + { + aOsclOptionLevel = OSCL_SOL_SOCKET; + switch (aOptionName) + { + case EPVSockReuseAddr: + aOsclOptionName = OSCL_SOCKOPT_SOL_REUSEADDR; + break; + default: + retval = PVSOCK_ERR_BAD_PARAM; + } + } + break; + default: + retval = PVSOCK_ERR_BAD_PARAM; + } + return retval; +} + +int32 OsclSocketI::SetSockOpt(TPVSocketOptionLevel aOptionLevel, TPVSocketOptionName aOptionName, OsclAny* aOptionValue, int32 aOptionLen) +{ + int32 retval = OsclErrNone; +#ifdef OsclSetSockOpt + int32 sockOptLevel, sockOptName; + if (PVSOCK_ERR_BAD_PARAM != GetOsclSockOptLevelName(aOptionLevel, aOptionName, sockOptLevel, sockOptName)) + { + if ((PVSOCK_ERR_NOT_SUPPORTED != sockOptLevel) && (PVSOCK_ERR_NOT_SUPPORTED != sockOptName)) + { + int32 err = 0; + bool ok; + OsclSetSockOpt(iSocket, sockOptLevel, sockOptName, aOptionValue, aOptionLen, ok, err); + if (!ok) + retval = err; + } + else + retval = PVSOCK_ERR_NOT_SUPPORTED; + } + else + retval = PVSOCK_ERR_BAD_PARAM; +#else + retval = PVSOCK_ERR_NOT_IMPLEMENTED; +#endif + return retval; +} + +int32 OsclSocketI::GetPeerName(OsclNetworkAddress& peerName) +{ +#ifdef OsclGetPeerName + TOsclSockAddr peerAddr; + int32 peerAddrLen = sizeof(peerAddr); + int32 err = 0; + bool ok; + OsclGetPeerName(iSocket, peerAddr, peerAddrLen, ok, err); + if (!ok) + return err; + + MakeAddr(peerAddr, peerName); + return OsclErrNone; + +#else + return PVSOCK_ERR_NOT_IMPLEMENTED; +#endif +} +int32 OsclSocketI::Join(OsclNetworkAddress& anAddr) +{ +#ifdef OsclJoin + TOsclSockAddr addr; + MakeAddr(anAddr, addr); + int err; + bool ok; + OsclJoin(iSocket, addr, ok, err); + if (!ok) + return err; + return OsclErrNone; +#else + OSCL_UNUSED_ARG(anAddr); + OSCL_LEAVE(OsclErrNotSupported); + return 0; +#endif +} + +bool OsclSocketIBase::HasAsyncListen() +{ + return false; +} + +int32 OsclSocketI::Listen(uint32 qSize) +{ +#ifdef OsclListen + //note: it's ok to do multiple listens to update the queue size + bool ok; + int err; + OsclListen(iSocket, qSize, ok, err); + if (!ok) + return err; + return OsclErrNone; +#else + OSCL_UNUSED_ARG(qSize); + return PVSOCK_ERR_NOT_IMPLEMENTED; +#endif +} + +int32 OsclSocketI::SetRecvBufferSize(uint32 size) +{ +#ifdef OsclSetRecvBufferSize + int err; + int ok; + OsclSetRecvBufferSize(iSocket, size, ok, err); + if (!ok) + return err; + return OsclErrNone; +#else + OSCL_UNUSED_ARG(size); + OSCL_LEAVE(OsclErrNotSupported); + return 0; +#endif +} + +inline void OsclSocketI::Send(SendParam ¶m, OsclSocketRequestAO& ao) +{ + if (!IsReady(ao)) + return; + //send/recv behavior is undefined when socket is + //not connected, so disallow it. + if (!IsConnected(ao)) + return ; + iSockServSendRequest.Activate(¶m, ao); +} + +inline void OsclSocketI::SendSuccess(SendParam ¶m) +{ + //nothing needed + OSCL_UNUSED_ARG(param); +} + +inline void OsclSocketI::CancelSend() +{ + iSockServSendRequest.CancelRequest(); +} + +inline void OsclSocketI::SendTo(SendToParam ¶m, OsclSocketRequestAO& ao) +{ + if (!IsReady(ao)) + return; + iSockServSendToRequest.Activate(¶m, ao); +} + +inline void OsclSocketI::SendToSuccess(SendToParam ¶m) +{ + //nothing needed + OSCL_UNUSED_ARG(param); +} + +inline void OsclSocketI::CancelSendTo() +{ + iSockServSendToRequest.CancelRequest(); +} + +inline void OsclSocketI::Recv(RecvParam& param, OsclSocketRequestAO& ao) +{ + if (!IsReady(ao)) + return; + //send/recv behavior is undefined when socket is + //not connected, so disallow it. + if (!IsConnected(ao)) + return ; + iSockServRecvRequest.Activate(¶m, ao); +} + +inline void OsclSocketI::RecvSuccess(RecvParam& param) +{ + //nothing needed + OSCL_UNUSED_ARG(param); +} + +inline void OsclSocketI::CancelRecv() +{ + iSockServRecvRequest.CancelRequest(); +} + +inline void OsclSocketI::RecvFrom(RecvFromParam ¶m, OsclSocketRequestAO& ao) +{ + if (!IsReady(ao)) + return; + iSockServRecvFromRequest.Activate(¶m, ao); +} + +inline void OsclSocketI::RecvFromSuccess(RecvFromParam& param) +{ + //nothing needed + OSCL_UNUSED_ARG(param); +} + +inline void OsclSocketI::CancelRecvFrom() +{ + iSockServRecvFromRequest.CancelRequest(); +} + +inline void OsclSocketI::Connect(ConnectParam ¶m, OsclSocketRequestAO& ao) +{ + if (!IsReady(ao)) + return; + iSockServConnectRequest.Activate(¶m, ao); +} + +inline void OsclSocketI::CancelConnect() +{ + iSockServConnectRequest.CancelRequest(); +} + +inline void OsclSocketI::Accept(AcceptParam& param, OsclSocketRequestAO& ao) +{ + if (!IsReady(ao)) + return; + iSockServAcceptRequest.Activate(¶m, ao); +} + +inline void OsclSocketI::CancelAccept() +{ + iSockServAcceptRequest.CancelRequest(); +} + +inline void OsclSocketI::Shutdown(ShutdownParam ¶m, OsclSocketRequestAO& ao) +{ + if (!IsReady(ao)) + return; + iSockServShutdownRequest.Activate(¶m, ao); +} + +inline void OsclSocketI::CancelShutdown() +{ + iSockServShutdownRequest.CancelRequest(); +} + +bool OsclSocketI::MakeAddr(OsclNetworkAddress& in, TOsclSockAddr& addr) +{ + //convert OsclNetworkAddress to TOsclSockAddr. +#ifdef OsclMakeSockAddr + bool ok; + OsclMakeSockAddr(addr, in.port, in.ipAddr.Str(), ok); + return ok; +#else + //default-- for older configurations that don't have the OsclMakeSockAddr macro. + addr.sin_family = OSCL_AF_INET; + addr.sin_port = htons(in.port); + addr.sin_addr.s_addr = inet_addr((const char*)in.ipAddr.Str()); + return (addr.sin_addr.s_addr != INADDR_NONE); +#endif +} + +void OsclSocketI::MakeAddr(TOsclSockAddr& in, OsclNetworkAddress& addr) +{ +#ifdef OsclUnMakeSockAddr + //convert TOsclSockAddrOut to OsclNetworkAddress + char* str; + OsclUnMakeSockAddr(in, str); + addr.ipAddr.Set(str); +#else + addr.ipAddr.Set(inet_ntoa(in.sin_addr)); +#endif +} + +bool OsclSocketI::MakeMulticastGroupInformation(OsclIpMReq& in, TIpMReq& addr) +{ + bool retval = true; +#ifdef OsclMakeInAddr + OsclMakeInAddr(addr.imr_interface, in.interfaceAddr.Str(), retval); + if (retval) + { + OsclMakeInAddr(addr.imr_multiaddr, in.multicastAddr.Str(), retval); + } +#else + retval = false; +#endif + return retval; +} + +void OsclSocketI::MakeMulticastGroupInformation(TIpMReq& in, OsclIpMReq& addr) +{ +#ifdef OsclUnMakeInAddr + char interfaceAddr[PVNETWORKADDRESS_LEN] = {0}; + char multicastAddr[PVNETWORKADDRESS_LEN] = {0}; + char* bufferPtr = NULL; + int32 buffLen; + OsclUnMakeInAddr(in.imr_interface, bufferPtr); + if (bufferPtr) + { + buffLen = oscl_strlen(bufferPtr); + oscl_strncpy(interfaceAddr, bufferPtr, buffLen); + interfaceAddr[buffLen] = '\0'; + } + bufferPtr = NULL; + buffLen = 0; + OsclUnMakeInAddr(in.imr_multiaddr, bufferPtr); + if (bufferPtr) + { + buffLen = oscl_strlen(bufferPtr); + oscl_strncpy(multicastAddr, bufferPtr, buffLen); + multicastAddr[buffLen] = '\0'; + } + addr.interfaceAddr.Set(interfaceAddr); + addr.multicastAddr.Set(multicastAddr); +#endif +} + +int32 OsclSocketI::Open(OsclSocketServI& aServer, uint32 addrFamily, uint32 sockType, uint32 protocol) +//used to open a new tcp or udp socket. +{ +#if(PV_OSCL_SOCKET_STATS_LOGGING) + iStats.Construct(this, &aServer); +#endif + + bool ok; + int err = 0; + + //create OS level socket. +#ifdef OsclSocket + OsclSocket(iSocket, addrFamily, sockType, protocol, ok, err); +#else + OSCL_UNUSED_ARG(addrFamily); + OSCL_UNUSED_ARG(sockType); + OSCL_UNUSED_ARG(protocol); + ok = false; + err = PVSOCK_ERR_NOT_IMPLEMENTED; +#endif + + InitSocket(ok); + if (!ok) + return err; + + if (protocol == OSCL_IPPROTO_UDP) + { + int32 bufsize = 65536; + OsclSetRecvBufferSize(iSocket, bufsize, ok, err); + } + + //set socket to non-blocking mode. +#ifdef OsclSetNonBlocking + OsclSetNonBlocking(iSocket, ok, err); +#else + ok = false; + err = PVSOCK_ERR_NOT_IMPLEMENTED; +#endif + + if (!ok) + { + Close(); + return err; + } + return Open(aServer); +} + +int32 OsclSocketI::Open(OsclSocketServI& aServer) +//used to open an accepted socket. +{ + CONSTRUCT_STATS(this, &aServer); + + iSocketServ = &aServer; + + //nothing needed-- the pv server doesn't need + //to know about the socket yet. + return OsclErrNone; +} + +inline bool OsclSocketI::IsOpen() +//see whether socket has been opened successfully. +{ + return iSocketValid; +} + +bool OsclSocketI::IsReady(OsclSocketRequestAO& ao) +//this routine does some error checks and will +//set socket error and complete the request for errors. +{ + //make sure this socket is open + if (!IsOpen()) + { + ao.iSocketError = PVSOCK_ERR_SOCK_NOT_OPEN; + ao.PendComplete(OSCL_REQUEST_ERR_GENERAL); + return false; + } + //make sure server is ok. + if (!iSocketServ) + { + ao.iSocketError = PVSOCK_ERR_SOCK_NO_SERV; + ao.PendComplete(OSCL_REQUEST_ERR_GENERAL); + return false; + } + if (!iSocketServ->IsServConnected()) + { + //report the error from the server, if any. + ao.iSocketError = iSocketServ->iServError; + if (ao.iSocketError == 0) + ao.iSocketError = PVSOCK_ERR_SERV_NOT_CONNECTED; + ao.PendComplete(OSCL_REQUEST_ERR_GENERAL); + return false; + } + return true; +} + +bool OsclSocketI::IsConnected(OsclSocketRequestAO& ao) +{ + if (!iSocketConnected) + { + ao.iSocketError = PVSOCK_ERR_SOCK_NOT_CONNECTED; + ao.PendComplete(OSCL_REQUEST_ERR_GENERAL); + return false; + } + return true; +} + +void OsclSocketI::InitSocket(bool valid) +{ + iSocketValid = valid; + iSocketConnected = false; +} + +#endif //pv socket server + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_pv.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_pv.h new file mode 100644 index 0000000..1189611 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_pv.h @@ -0,0 +1,169 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#ifndef OSCL_SOCKET_IMP_PV_H_INCLUDED +#define OSCL_SOCKET_IMP_PV_H_INCLUDED + +#include "oscl_socket_imp_base.h" + +/*! Socket implementation for PV socket server +*/ + +/** some error codes for request completion +** these are negative so they won't conflict with +** errors from the OS socket layer. +*/ +#define PVSOCK_ERR_BAD_PARAM (-1) +#define PVSOCK_ERR_SOCK_NOT_OPEN (-2) +#define PVSOCK_ERR_SOCK_NO_SERV (-3) +#define PVSOCK_ERR_SERV_NOT_CONNECTED (-4) +#define PVSOCK_ERR_SOCK_NOT_CONNECTED (-5) +#define PVSOCK_ERR_NOT_IMPLEMENTED (-6) +#define PVSOCK_ERR_NOT_SUPPORTED (-7) + + +class OsclSocketServI; +class PVLogger; +class OsclSocketServRequestQElem; + +/** Socket implementation class +*/ +class OsclSocketI: public OsclSocketIBase +{ + public: + static OsclSocketI* NewL(Oscl_DefAlloc &a); + ~OsclSocketI(); + + //synchronous methods + int32 Open(OsclSocketServI& aServer, uint32 addrFamily, uint32 sockType, uint32 protocol); + int32 Open(OsclSocketServI& aServer); + int32 Bind(OsclNetworkAddress& anAddr); + int32 SetSockOpt(TPVSocketOptionLevel aOptionLevel, TPVSocketOptionName aOptionName, OsclAny* aOptionValue, int32 aOptionLen); + int32 GetPeerName(OsclNetworkAddress& peerName); + int32 Join(OsclNetworkAddress& anAddr); + int32 Close(); + int32 Listen(uint32 qSize); + int32 SetRecvBufferSize(uint32 size); + TPVSocketEvent ThreadLogoff(); + TPVSocketEvent ThreadLogon(OsclSocketServI* aServ); + + //asynchronous methods. + + void Connect(ConnectParam& , OsclSocketRequestAO&); + + void Accept(AcceptParam &, OsclSocketRequestAO&); + + void Shutdown(ShutdownParam &, OsclSocketRequestAO&); + + void Send(SendParam &, OsclSocketRequestAO&); + void SendSuccess(SendParam &); + + void SendTo(SendToParam & , OsclSocketRequestAO&); + void SendToSuccess(SendToParam &); + + void Recv(RecvParam &, OsclSocketRequestAO&); + void RecvSuccess(RecvParam &); + + void RecvFrom(RecvFromParam &, OsclSocketRequestAO&); + void RecvFromSuccess(RecvFromParam &); + + + private: + OsclSocketI(Oscl_DefAlloc &a); + + inline void CancelConnect(); + inline void CancelAccept(); + inline void CancelShutdown(); + inline void CancelSend(); + inline void CancelSendTo(); + inline void CancelRecv(); + inline void CancelRecvFrom(); + + inline bool IsOpen(); + int32 GetOsclSockOptLevelName(const TPVSocketOptionLevel aOptionLevel, const TPVSocketOptionName aOptionName, int32& aOsclOptionLevel, int32& aOsclOptionName); + + + //PV socket server + + //the OS-level socket + TOsclSocket iSocket; + + public: + TOsclSocket Socket() + { + return iSocket; + } + static bool MakeAddr(OsclNetworkAddress& in, TOsclSockAddr& addr); + static void MakeAddr(TOsclSockAddr& in, OsclNetworkAddress& addr); + static bool MakeMulticastGroupInformation(OsclIpMReq& in, TIpMReq& addr); + static void MakeMulticastGroupInformation(TIpMReq& in, OsclIpMReq& addr); + + //routines to handle each type of socket request under the + //server thread. + void ProcessConnect(OsclSocketServRequestQElem*); + void ProcessShutdown(OsclSocketServRequestQElem*); + void ProcessAccept(OsclSocketServRequestQElem*); + void ProcessSendTo(OsclSocketServRequestQElem*); + void ProcessRecvFrom(OsclSocketServRequestQElem*); + void ProcessSend(OsclSocketServRequestQElem*); + void ProcessRecv(OsclSocketServRequestQElem*); + + private: + bool iSocketValid; + bool iSocketConnected; + void InitSocket(bool valid); + + bool IsConnected(OsclSocketRequestAO& aObject); + bool IsReady(OsclSocketRequestAO& aObject); + + //server requests + OsclSocketRequest iSockServAcceptRequest; + OsclSocketRequest iSockServConnectRequest; + OsclSocketRequest iSockServRecvRequest; + OsclSocketRequest iSockServRecvFromRequest; + OsclSocketRequest iSockServSendRequest; + OsclSocketRequest iSockServSendToRequest; + OsclSocketRequest iSockServShutdownRequest; + friend class OsclAcceptRequest; + friend class OsclConnectRequest; + friend class OsclRecvRequest; + friend class OsclRecvFromRequest; + friend class OsclSendRequest; + friend class OsclSendToRequest; + friend class OsclShutdownRequest; + + friend class OsclUDPSocket; + friend class OsclTCPSocket; + + PVLogger* iLogger; + + public: + //for logging in socket request list. + PVLogger* Logger() + { + return iLogger; + } + +}; + +#endif + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_serv.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_serv.cpp new file mode 100644 index 0000000..3442eaf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_imp_serv.cpp @@ -0,0 +1,858 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_socket_tuneables.h" + +#if(PV_SOCKET_SERVER) + +#include "oscl_socket_imp.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_scheduler_ao.h" +#include "oscl_socket_method.h" +#include "oscl_error.h" + +/** This file contains all the routines called by + * the PV Socket server ProcessSocketRequests routine to process active + * requests in the select loop. + */ + +//Logger macro for socket server logging. +#if(PV_OSCL_SOCKET_SERVER_LOGGER_OUTPUT) +#include "pvlogger.h" +#define LOGSERV(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSocketServ->iLogger,PVLOGMSG_DEBUG,m); +#else +#define LOGSERV(m) +#endif +/* +//disable this if it's too much +#undef LOGSERV +#define LOGSERV +*/ + +//Stats macros for use with OsclSocketI +#if(PV_OSCL_SOCKET_STATS_LOGGING) +#define ADD_STATS(x,y) iStats.Add(x,y) +#define ADD_STATSP(x,y,z) iStats.Add(x,y,z) +#define CONSTRUCT_STATS(x,y) iStats.Construct(x,y) +#else +#define ADD_STATS(x,y) +#define ADD_STATSP(x,y,z) +#define CONSTRUCT_STATS(x,y) +#endif + +/** + * Server calls this to process an active Connect request. + * + * This is called under the server thread or server AO during + * the select loop. + * + * This routine may complete the request, or may set flags in the + * read/write/except set to be monitored during the next select call. + * + */ +void OsclSocketI::ProcessConnect(OsclSocketServRequestQElem* aElem) +{ + bool iscomplete = false; + int sockerr = 0; + int32 complete = 0; + OsclSocketRequest *req = aElem->iSocketRequest; + if (aElem->iSelect) + { + //check for completion by examining + //writeset and exceptset + bool ok, success, fail; +#if (PV_SOCKET_SERVER_SELECT) + OsclConnectComplete(iSocket, + iSocketServ->iWriteset, + iSocketServ->iExceptset, + success, + fail, + ok, + sockerr); +#else + //since there was no select call we have to do it now. + fd_set readset, writeset, exceptset; + FD_ZERO(&writeset); + FD_ZERO(&readset); + FD_ZERO(&exceptset); + FD_SET(iSocket, &writeset); + FD_SET(iSocket, &exceptset); + timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 0; + int nfds = iSocket + 1; + int serverr; + int nhandles; + OsclSocketSelect(nfds, readset, writeset, exceptset, timeout, ok, serverr, nhandles); + if (!ok) + { + //select failed. + sockerr = serverr; + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + } + else if (!nhandles) + { + //keep waiting. + success = fail = false; + } + else + { + //examine results + OsclConnectComplete(iSocket, + writeset, + exceptset, + success, + fail, + ok, + sockerr); + } +#endif + + if (success) + { + //done, no error. + ADD_STATS(req->iParam->iFxn, EOsclSocket_Writable); + + iSocketConnected = true; + complete = OSCL_REQUEST_ERR_NONE; + iscomplete = true; + } + else if (fail) + { + //done, with error. + ADD_STATS(req->iParam->iFxn, EOsclSocket_Except); + + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + } + else + { + //keep waiting + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); + } + } + else + { + //Start connecting + ConnectParam *param = (ConnectParam*)req->iParam; + TOsclSockAddr addr; + MakeAddr(param->iAddr, addr); + bool ok, wouldblock; + ADD_STATS(req->iParam->iFxn, EOsclSocket_OS); + OsclConnect(iSocket, addr, ok, sockerr, wouldblock); + if (!ok) + { + if (wouldblock) + { + //we expect a non-blocking socket to return an error... + //start monitoring the writeset and exceptset. + aElem->iSelect = (OSCL_WRITESET_FLAG | OSCL_EXCEPTSET_FLAG); + } + else + { + //connect error. + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + } + } + else + { + //Finished. + iSocketConnected = true; + complete = OSCL_REQUEST_ERR_NONE; + iscomplete = true; + } + } + + //either keep monitoring activity, or complete the request. + if (!iscomplete) + { + LOGSERV((0, "OsclSocketI::ProcessConnect (0x%x) select=true", this)); + OSCL_ASSERT(aElem->iSelect);//should have bits set. + } + else + { + LOGSERV((0, "OsclSocketI::ProcessConnect (0x%x) request complete %d sockerr %d", this, complete, sockerr)); + req->Complete(aElem, complete, sockerr); + } +} + +/** + * Server calls this to process an active Shutdown request. + * + * This is called under the server thread or server AO during + * the select loop. + * + * This routine may complete the request, or may set flags in the + * read/write/except set to be monitored during the next select call. + * + */ +void OsclSocketI::ProcessShutdown(OsclSocketServRequestQElem* aElem) +{ + int err = 0; + int32 complete = 0; + + OsclSocketRequest *req = aElem->iSocketRequest; + { + ShutdownParam* param = (ShutdownParam*)req->iParam; + int how = GetShutdown(param->iHow); + bool ok; + ADD_STATS(req->iParam->iFxn, EOsclSocket_OS); + OsclShutdown(iSocket, how, ok, err); + if (!ok) + { + //shutdown error + complete = OSCL_REQUEST_ERR_GENERAL; + } + else + { + complete = OSCL_REQUEST_ERR_NONE; + } + } + LOGSERV((0, "OsclSocketI::ProcessShutdown (0x%x) request complete %d sockerr %d", this, complete, err)); + req->Complete(aElem, complete, err); +} + +/** + * Server calls this to process an active Accept request. + * + * This is called under the server thread or server AO during + * the select loop. + * + * This routine may complete the request, or may set flags in the + * read/write/except set to be monitored during the next select call. + * + */ +void OsclSocketI::ProcessAccept(OsclSocketServRequestQElem* aElem) +{ + bool iscomplete = false; + int sockerr = 0; + int32 complete = 0; + OsclSocketRequest *req = aElem->iSocketRequest; + if (!aElem->iSelect) + { + //start monitoring. + AcceptParam* param = (AcceptParam*)req->iParam; + if (!param->iBlankSocket) + { + //bad request. + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected + } + else + { + aElem->iSelect = (OSCL_READSET_FLAG | OSCL_EXCEPTSET_FLAG); + } + } +#if (PV_SOCKET_SERVER_SELECT) + else if (FD_ISSET(iSocket, &iSocketServ->iExceptset)) + { + ADD_STATS(req->iParam->iFxn, EOsclSocket_Except); + + bool ok; + OsclGetAsyncSockErr(iSocket, ok, sockerr); + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + } + else if (FD_ISSET(iSocket, &iSocketServ->iReadset)) + { + //socket is readable, we can do an accept call now. + ADD_STATS(req->iParam->iFxn, EOsclSocket_Readable); +#else + { + //try the accept. +#endif + TOsclSocket acceptsock; + bool ok, wouldblock; + ADD_STATS(req->iParam->iFxn, EOsclSocket_OS); + OsclAccept(iSocket, acceptsock, ok, sockerr, wouldblock); + if (!ok) + { + if (wouldblock) + { +#if (PV_SOCKET_SERVER_SELECT) + //we don't expect wouldblock when socket is readable. + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; +#else + //keep waiting for socket to be readable. + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); +#endif + } + else + { + //accept error + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + } + } + else + { + //Set accept socket to non-blocking mode. + OsclSetNonBlocking(acceptsock, ok, sockerr); + if (!ok) + { + OsclCloseSocket(acceptsock, ok, sockerr); + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + } + else + { + //Save the accept socket in the blank socket that was provided + //in the Accept command. + AcceptParam* param = (AcceptParam*)req->iParam; + param->iBlankSocket->iSocket = acceptsock; + //the blank socket is now valid and connected. + param->iBlankSocket->InitSocket(true); + param->iBlankSocket->iSocketConnected = true; + complete = OSCL_REQUEST_ERR_NONE; + iscomplete = true; + } + } + } +#if (PV_SOCKET_SERVER_SELECT) + else + { + //keep waiting for socket to be readable. + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); + } +#endif + + //either keep monitoring activity, or complete the request. + if (!iscomplete) + { + LOGSERV((0, "OsclSocketI::ProcessAccept (0x%x) select=true", this)); + OSCL_ASSERT(aElem->iSelect); + } + else + { + LOGSERV((0, "OsclSocketI::ProcessAccept (0x%x) request complete %d sockerr %d", this, complete, sockerr)); + req->Complete(aElem, complete, sockerr); + } +} + +/** + * Server calls this to process an active Send request. + * + * This is called under the server thread or server AO during + * the select loop. + * + * This routine may complete the request, or may set flags in the + * read/write/except set to be monitored during the next select call. + * + */ +void OsclSocketI::ProcessSend(OsclSocketServRequestQElem* aElem) +{ + bool iscomplete = false; + int32 complete = 0; + int sockerr = 0; + OsclSocketRequest *req = aElem->iSocketRequest; + if (!aElem->iSelect) + { + //start monitoring. + //don't monitor exceptset b/c windows reports some false errors. + SendParam *param = (SendParam*)req->iParam; + if (!param->iBufSend.iPtr) + { + //bad request + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + sockerr = PVSOCK_ERR_BAD_PARAM; + } + else + { + aElem->iSelect = (OSCL_WRITESET_FLAG); + } + } +#if (PV_SOCKET_SERVER_SELECT) + else if (FD_ISSET(iSocket, &iSocketServ->iWriteset)) + { + //socket is writable, send data + ADD_STATS(req->iParam->iFxn, EOsclSocket_Writable); +#else + { + //go ahead and try to send +#endif + SendParam *param = (SendParam*)req->iParam; + int nbytes; + bool ok, wouldblock; + ADD_STATS(req->iParam->iFxn, EOsclSocket_OS); + OsclSend(iSocket, + param->iBufSend.iPtr + param->iXferLen, + param->iBufSend.iLen - param->iXferLen, + ok, + sockerr, + nbytes, + wouldblock); + + //check send result... + if (!ok) + { + if (wouldblock) + { + //non-blocking sockets return this when there's no receiver. + //just keep waiting. + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); + } + else + { + //send error + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + } + } + else + { + //sent data. + ADD_STATSP(req->iParam->iFxn, EOsclSocket_DataSent, nbytes); + + param->iXferLen += nbytes; + + //Check for completion + if (param->iXferLen == param->iBufSend.iLen) + { + //all data sent. + complete = OSCL_REQUEST_ERR_NONE; + iscomplete = true; + } + else if (nbytes == 0) + { + //connection closed + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + //(sockerr will be zero in this case.) + } + else + { + //keep sending data. + ; + } + } + } +#if (PV_SOCKET_SERVER_SELECT) + else + { + //keep waiting for socket to be writable. + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); + } +#endif + + //either keep monitoring activity, or complete the request. + if (!iscomplete) + { + LOGSERV((0, "OsclSocketI::ProcessSend (0x%x) select=true", this)); + OSCL_ASSERT(aElem->iSelect); + } + else + { + LOGSERV((0, "OsclSocketI::ProcessSend (0x%x) request complete %d sockerr %d", this, complete, sockerr)); + req->Complete(aElem, complete, sockerr); + } +} + +/** + * Server calls this to process an active SendTo request. + * + * This is called under the server thread or server AO during + * the select loop. + * + * This routine may complete the request, or may set flags in the + * read/write/except set to be monitored during the next select call. + * + */ +void OsclSocketI::ProcessSendTo(OsclSocketServRequestQElem* aElem) +{ + bool iscomplete = false; + int32 complete = 0; + int sockerr = 0; + OsclSocketRequest *req = aElem->iSocketRequest; + if (!aElem->iSelect) + { + //start monitoring. don't monitor exceptset b/c windows reports some false errors. + SendToParam *param = (SendToParam*)req->iParam; + if (!param->iBufSend.iPtr) + { + //bad request + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected + } + else + { + aElem->iSelect = (OSCL_WRITESET_FLAG); + } + } +#if (PV_SOCKET_SERVER_SELECT) + else if (FD_ISSET(iSocket, &iSocketServ->iWriteset)) + { + //socket is writable, send data + ADD_STATS(req->iParam->iFxn, EOsclSocket_Writable); +#else + { + //go ahead and try to send +#endif + + SendToParam *param = (SendToParam*)req->iParam; + int nbytes; + bool wouldblock, ok; + TOsclSockAddr toaddr; + MakeAddr(param->iAddr, toaddr); + ADD_STATS(req->iParam->iFxn, EOsclSocket_OS); + OsclSendTo(iSocket, + param->iBufSend.iPtr + param->iXferLen, + param->iBufSend.iLen - param->iXferLen, + toaddr, + ok, + sockerr, + nbytes, + wouldblock); + + if (!ok) + { + if (wouldblock) + { + //nonblocking socket returns this error + //just keep waiting + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); + } + else + { + //sendto error + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + } + } + else + { + //sent data. + ADD_STATSP(req->iParam->iFxn, EOsclSocket_DataSent, nbytes); + + param->iXferLen += nbytes; + + //Check for completion + if (param->iXferLen == param->iBufSend.iLen) + { + //all data sent. + complete = OSCL_REQUEST_ERR_NONE; + iscomplete = true; + } + else if (nbytes == 0) + { + //connection closed + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + //(sockerr will be zero in this case) + } + else + { + //keep sending data. + ; + } + } + } +#if (PV_SOCKET_SERVER_SELECT) + else + { + //keep waiting for socket to be writable. + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); + } +#endif + + //either keep monitoring activity, or complete the request. + if (!iscomplete) + { + LOGSERV((0, "OsclSocketI::ProcessSendTo (0x%x) select=true", this)); + OSCL_ASSERT(aElem->iSelect); + } + else + { + LOGSERV((0, "OsclSocketI::ProcessSendTo (0x%x) request complete %d sockerr %d", this, complete, sockerr)); + req->Complete(aElem, complete, sockerr); + } +} + +/** + * Server calls this to process an active Recv request. + * + * This is called under the server thread or server AO during + * the select loop. + * + * This routine may complete the request, or may set flags in the + * read/write/except set to be monitored during the next select call. + * + */ +void OsclSocketI::ProcessRecv(OsclSocketServRequestQElem* aElem) +{ + bool iscomplete = false; + int sockerr = 0; + int32 complete = 0; + OsclSocketRequest *req = aElem->iSocketRequest; + if (!aElem->iSelect) + { + //start monitoring. don't monitor exceptset b/c windows reports some false errors. + RecvParam* param = (RecvParam*)req->iParam; + if (!param->iBufRecv.iPtr) + { + //bad request. + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected + } + else + { + aElem->iSelect = (OSCL_READSET_FLAG); + } + } +#if (PV_SOCKET_SERVER_SELECT) + else if (FD_ISSET(iSocket, &iSocketServ->iReadset)) + { + //socket is readable, get data. + ADD_STATS(req->iParam->iFxn, EOsclSocket_Readable); +#else + { + //try to read +#endif + RecvParam* param = (RecvParam*)req->iParam; + int nbytes; + bool ok, wouldblock; + ADD_STATS(req->iParam->iFxn, EOsclSocket_OS); + OsclRecv(iSocket, + param->iBufRecv.iPtr + param->iBufRecv.iLen, + param->iBufRecv.iMaxLen - param->iBufRecv.iLen, + ok, + sockerr, + nbytes, + wouldblock); + + //Check for completion or error. + if (!ok) + { + if (wouldblock) + { + //nonblocking sockets return this when there's no + //data. + //keep waiting for data. + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); + } + else + { + //recv error + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + } + } + else if (nbytes > 0) + { + //got some data + ADD_STATSP(req->iParam->iFxn, EOsclSocket_DataRecv, nbytes); + + param->iBufRecv.iLen += nbytes; + + complete = OSCL_REQUEST_ERR_NONE; + iscomplete = true; + } + else + { + //this usually means connection was closed. + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + //(sockerr will be zero in this case) + } + } +#if (PV_SOCKET_SERVER_SELECT) + else + { + //keep waiting for socket to be readable. + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); + } +#endif + + //either keep monitoring activity, or complete the request. + if (!iscomplete) + { + LOGSERV((0, "OsclSocketI::ProcessRecv (0x%x) select=true", this)); + OSCL_ASSERT(aElem->iSelect); + } + else + { + LOGSERV((0, "OsclSocketI::ProcessRecv (0x%x) request complete %d sockerr %d", this, complete, sockerr)); + req->Complete(aElem, complete, sockerr); + } +} + +/** + * Server calls this to process an active RecvFrom request. + * + * This is called under the server thread or server AO during + * the select loop. + * + * This routine may complete the request, or may set flags in the + * read/write/except set to be monitored during the next select call. + * + */ +void OsclSocketI::ProcessRecvFrom(OsclSocketServRequestQElem* aElem) +{ + bool iscomplete = false; + int sockerr = 0; + int32 complete = 0; + OsclSocketRequest *req = aElem->iSocketRequest; + if (!aElem->iSelect) + { + //start monitoring. don't monitor exceptset b/c windows reports some false errors. + RecvFromParam* param = (RecvFromParam*)req->iParam; + if (!param->iBufRecv.iPtr) + { + //bad request. + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected + } + else + { + aElem->iSelect = (OSCL_READSET_FLAG); + } + } +#if (PV_SOCKET_SERVER_SELECT) + else if (FD_ISSET(iSocket, &iSocketServ->iReadset)) + { + //socket is readable, get data. + ADD_STATS(req->iParam->iFxn, EOsclSocket_Readable); +#else + { + //try the read +#endif + + //we loop through multiple "recvfrom" calls and stop when + //either a byte limit is reached or else no more data is available + //without waiting. + bool loop; + uint32 loopcount; + for (loop = true, loopcount = 0; loop; loopcount++) + { + loop = false; + + RecvFromParam* param = (RecvFromParam*)req->iParam; + int nbytes; + bool ok, wouldblock; + TOsclSockAddr sourceaddr; + TOsclSockAddrLen sourceaddrlen = sizeof(sourceaddr); + ADD_STATS(req->iParam->iFxn, EOsclSocket_OS); + OsclRecvFrom(iSocket, + param->iBufRecv.iPtr + param->iBufRecv.iLen, + param->iBufRecv.iMaxLen - param->iBufRecv.iLen, + &sourceaddr, + &sourceaddrlen, + ok, + sockerr, + nbytes, + wouldblock); + + //Check for completion or error. + if (!ok) + { + if (wouldblock) + { + //nonblocking sockets will return an error when + //there's no data. + if (loopcount == 0) + { + //keep waiting for data. + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); + } + else + { + //if we already got some data, don't wait for more. + complete = OSCL_REQUEST_ERR_NONE; + iscomplete = true; + } + } + else + { + //recvfrom error + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + } + } + else if (nbytes > 0) + { + //got some data. + ADD_STATSP(req->iParam->iFxn, EOsclSocket_DataRecv, nbytes); + + param->iBufRecv.iLen += nbytes; + if (param->iPacketLen) + param->iPacketLen->push_back(nbytes); + + if (sourceaddrlen > 0) + { + //convert the source address. + MakeAddr(sourceaddr, param->iAddr); + if (param->iPacketSource) + param->iPacketSource->push_back(param->iAddr); + } + + //see whether to try and recv another packet + //when multi-packet recv is enabled, keep receiving + //as long as the free space is >= the multi recv limit. + if (param->iMultiMaxLen > 0 + && (param->iBufRecv.iMaxLen - param->iBufRecv.iLen) >= param->iMultiMaxLen) + { + loop = true; + } + else + { + complete = OSCL_REQUEST_ERR_NONE; + iscomplete = true; + } + } + else + { + //this usually means connection was closed. + complete = OSCL_REQUEST_ERR_GENERAL; + iscomplete = true; + //(sockerr will be zero in this case) + } + }//for loop + } +#if (PV_SOCKET_SERVER_SELECT) + else + { + //keep waiting for socket to be readable. + ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll); + } +#endif + + //either keep monitoring activity, or complete the request. + if (!iscomplete) + { + LOGSERV((0, "OsclSocketI::ProcessRecvFrom (0x%x) select=true", this)); + OSCL_ASSERT(aElem->iSelect); + } + else + { + LOGSERV((0, "OsclSocketI::ProcessRecvFrom (0x%x) request complete %d sockerr %d", this, complete, sockerr)); + req->Complete(aElem, complete, sockerr); + } +} + +#endif //PV_SOCKET_SERVER + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_listen.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_listen.cpp new file mode 100644 index 0000000..e0d4651 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_listen.cpp @@ -0,0 +1,94 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_listen.h" + +//////////// Method ///////////////////// + +OsclListenMethod *OsclListenMethod::NewL(OsclIPSocketI& c) +{ + OsclAny*p = c.Alloc().ALLOCATE(sizeof(OsclListenMethod)); + OsclError::LeaveIfNull(p); + OsclListenMethod* self = OSCL_PLACEMENT_NEW(p, OsclListenMethod(c)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclListenMethod::ConstructL() +{ + OsclAny*p = Alloc().ALLOCATE(sizeof(OsclListenRequest)); + OsclError::LeaveIfNull(p); + OsclListenRequest* self = OSCL_PLACEMENT_NEW(p, OsclListenRequest(*this)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + iSocketRequestAO = self; + OsclSocketMethod::ConstructL(iSocketRequestAO); +} + +OsclListenMethod::~OsclListenMethod() +{ + if (ListenRequest()) + { + ListenRequest()->~OsclListenRequest(); + Alloc().deallocate(ListenRequest()); + } +} + +TPVSocketEvent OsclListenMethod::Listen(uint32 qsize, + int32 aTimeout) +{ + if (!StartMethod(aTimeout)) + return EPVSocketFailure; + + ListenRequest()->Listen(qsize); + + return EPVSocketPending; +} + +//////////// AO ///////////////////// + + +void OsclListenRequest::Listen(uint32 qsize) +{ + OsclAny *p = NewRequest(sizeof(ListenParam)); + if (!p) + PendComplete(OsclErrNoMemory); + else + { + iParam = OSCL_PLACEMENT_NEW(p, ListenParam(qsize)); + if (!iParam) + PendComplete(OsclErrNoMemory); + else + { + SocketI()->ListenAsync(*Param(), *this); + } + } +} + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_listen.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_listen.h new file mode 100644 index 0000000..cd503c3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_listen.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_LISTEN_H_INCLUDED +#define OSCL_SOCKET_LISTEN_H_INCLUDEDd + +#include "oscl_socket_types.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_method.h" + +/** + Internal implementation of async Listen + */ +class OsclListenRequest; + +class OsclListenMethod : public OsclSocketMethod +{ + public: + static OsclListenMethod *NewL(OsclIPSocketI& c); + + ~OsclListenMethod(); + + TPVSocketEvent Listen(uint32 qsize, + int32 aTimeout); + + private: + OsclListenMethod(OsclIPSocketI& c) + : OsclSocketMethod(c, "oscllistenmethod", EPVSocketListen) + {} + + void ConstructL(); + + public: + OsclListenRequest *ListenRequest() + { + return (OsclListenRequest*)iSocketRequestAO; + } +}; + +/** + This is the AO that interacts with the socket server + */ +class OsclListenRequest : public OsclSocketRequestAO +{ + public: + OsclListenRequest(OsclSocketMethod& c) + : OsclSocketRequestAO(c, "osclListenRequest") + {} + + void Listen(uint32 qsize); + + private: + + ListenParam*Param() + { + return(ListenParam*)iParam; + } + +}; + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_method.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_method.cpp new file mode 100644 index 0000000..9d574e6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_method.cpp @@ -0,0 +1,270 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "osclconfig_io.h" +#include "oscl_scheduler_ao.h" +#include "oscl_socket_method.h" +#include "oscl_socket_imp.h" +#include "oscl_assert.h" + + +static const char* const TPVSocketFxnStr[] = +{ + "EPVSocketSend" + , "EPVSocketSendTo" + , "EPVSocketRecv" + , "EPVSocketRecvFrom" + , "EPVSocketConnect" + , "EPVSocketAccept" + , "EPVSocketShutdown" + , "EPVSocketBindUdp" + , "EPVSocketBindTcp" + , "EPVSocketListen" +} ; +static const char* const TPVSocketEventStr[] = +{ + "EPVSocketSuccess" + , "EPVSocketPending" + , "EPVSocketTimeout" + , "EPVSocketFailure" + , "EPVSocketCancel" + , "EPVSocketNotImplemented" +}; + +/** OsclSocketRequestAO is the base class for all the AOs that + interact directly with the socket server. This object + is contained within an OsclSocketMethod object + */ + +inline int OsclSocketRequestAO::GetSocketError() +{ +#if (PV_SOCKET_SERVER) + + //Errors from PV socket server are in + //iSocketError. + return iSocketError; + +#else + +#error No Implementation! + +#endif +} + +//Stats macros for use with OsclSocketRequestAO +#if(PV_OSCL_SOCKET_STATS_LOGGING) +#define ADD_STATS(a,b) SocketI()->iStats.Add(a,b) +#define LOG_STATS(a) SocketI()->iStats.Log(a) +#define CLEAR_STATS(a) SocketI()->iStats.Clear(a) +#else +#define ADD_STATS(a,b) +#define LOG_STATS(a) +#define CLEAR_STATS(a) +#endif + +#define LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iContainer.iContainer.iLogger,PVLOGMSG_DEBUG,m); + +void OsclSocketRequestAO::Run() +{ + //The server has completed the socket request. + + RequestDone(); + + + // Check the request completion status + switch (Status()) + { + case OSCL_REQUEST_ERR_NONE: + ADD_STATS(iContainer.iSocketFxn, EOsclSocket_RequestAO_Success); + Success(); + LOGINFOMED((0, "OsclSocket(0x%x): %s %s ", SocketI(), TPVSocketFxnStr[iContainer.iSocketFxn], TPVSocketEventStr[EPVSocketSuccess])); + LOG_STATS(iContainer.iSocketFxn); + CLEAR_STATS(iContainer.iSocketFxn); + SocketObserver()->HandleSocketEvent(Id(), iContainer.iSocketFxn, EPVSocketSuccess, 0); + break; + + case OSCL_REQUEST_ERR_CANCEL: + ADD_STATS(iContainer.iSocketFxn, EOsclSocket_RequestAO_Canceled); + //Request was cancelled, either due to an API call or due to the + //socket server shutting down before completing the operation. + LOGINFOMED((0, "OsclSocket(0x%x): %s %s ", SocketI(), TPVSocketFxnStr[iContainer.iSocketFxn], TPVSocketEventStr[EPVSocketCancel])); + LOG_STATS(iContainer.iSocketFxn); + CLEAR_STATS(iContainer.iSocketFxn); + SocketObserver()->HandleSocketEvent(Id(), iContainer.iSocketFxn, EPVSocketCancel, 0); + break; + + default: + ADD_STATS(iContainer.iSocketFxn, EOsclSocket_RequestAO_Error); + //Some error. + LOGINFOMED((0, "OsclSocket(0x%x): %s %s %d", SocketI(), TPVSocketFxnStr[iContainer.iSocketFxn], TPVSocketEventStr[EPVSocketFailure], GetSocketError())); + LOG_STATS(iContainer.iSocketFxn); + CLEAR_STATS(iContainer.iSocketFxn); + SocketObserver()->HandleSocketEvent(Id(), iContainer.iSocketFxn, EPVSocketFailure, GetSocketError()); + break; + } +} + +OsclAny* OsclSocketRequestAO::NewRequest(const uint32 size) +{ + //Activate the AO. The socket server will complete the request. + PendForExec(); + + bool reallocate = (!iParam || size != iParamSize); + + //Cleanup any previous parameters. + CleanupParam(reallocate); + + LOGINFOMED((0, "OsclSocket(0x%x): New Request %s", SocketI(), TPVSocketFxnStr[iContainer.iSocketFxn])); + + //Allocate space for new parameters, or recycle current space. + if (reallocate) + { + iParamSize = size; + return Alloc().ALLOCATE(size); + } + else + return iParam; +} + +void OsclSocketRequestAO::CleanupParam(bool aDeallocate) +{ + //cleanup the socket request parameters-- can't use + //virtual destructor because an allocator was used and + //destructor is called explicitly. + if (iParam) + { + switch (iContainer.iSocketFxn) + { + case EPVSocketRecvFrom: + ((RecvFromParam*)iParam)->~RecvFromParam(); + break; + case EPVSocketRecv: + ((RecvParam*)iParam)->~RecvParam(); + break; + case EPVSocketSendTo: + ((SendToParam*)iParam)->~SendToParam(); + break; + case EPVSocketSend: + ((SendParam*)iParam)->~SendParam(); + break; + case EPVSocketAccept: + ((AcceptParam*)iParam)->~AcceptParam(); + break; + case EPVSocketConnect: + ((ConnectParam*)iParam)->~ConnectParam(); + break; + case EPVSocketShutdown: + ((ShutdownParam*)iParam)->~ShutdownParam(); + break; + case EPVSocketBind: + ((BindParam*)iParam)->~BindParam(); + break; + case EPVSocketListen: + ((ListenParam*)iParam)->~ListenParam(); + break; + default: + OSCL_ASSERT(false); + break; + } + //free memory if needed. + if (aDeallocate) + { + Alloc().deallocate(iParam); + iParam = NULL; + iParamSize = 0; + } + } +} + +TPVSocketEvent OsclSocketMethod::ThreadLogoff() +{ + //make sure there's not already a request + //in progress + if (iSocketRequestAO->IsBusy() + || IsBusy()) + return EPVSocketFailure; + + if (IsAdded()) + RemoveFromScheduler(); + if (iSocketRequestAO->IsAdded()) + iSocketRequestAO->RemoveFromScheduler(); + + return EPVSocketSuccess; +} + +TPVSocketEvent OsclSocketMethod::ThreadLogon() +{ + //nothing needed here-- the individual methods will + //add themselves to scheduler as needed. + return EPVSocketSuccess; +} +/** OsclSocketMethod is the base class for all the AOs that + implement asynchronous socket requests. It implements the timeout. + */ + +bool OsclSocketMethod::StartMethod(int32 aTimeoutMsec) +{ + //make sure there's not already a request + //in progress + if (iSocketRequestAO->IsBusy() + || IsBusy()) + return false; + + if (!iSocketRequestAO->IsAdded()) + iSocketRequestAO->AddToScheduler(); + + //set the timeout if any. Timeout <= 0 indicates infinite wait. + if (aTimeoutMsec > 0) + { + if (!IsAdded()) + AddToScheduler(); + After(aTimeoutMsec*MSEC_TO_MICROSEC); + } + + iSocketRequestAO->iSocketError = 0; + + return true; +} + +//Stats macros for use with OsclSocketMethod +#undef ADD_STATS +#undef LOG_STATS +#undef CLEAR_STATS +#if(PV_OSCL_SOCKET_STATS_LOGGING) +#define ADD_STATS(a,b) iSocketRequestAO->SocketI()->iStats.Add(a,b) +#define LOG_STATS(a) iSocketRequestAO->SocketI()->iStats.Log(a) +#define CLEAR_STATS(a) iSocketRequestAO->SocketI()->iStats.Clear(a) +#else +#define ADD_STATS(a,b) +#define LOG_STATS(a) +#define CLEAR_STATS(a) +#endif + +void OsclSocketMethod::Run() +{ + ADD_STATS(iSocketFxn, EOsclSocket_RequestAO_Timeout); + //The socket request has timed out. + MethodDone(); + PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iContainer.iLogger, PVLOGMSG_DEBUG + , (0, "OsclSocket: %s %s ", TPVSocketFxnStr[iSocketFxn], TPVSocketEventStr[EPVSocketTimeout])); + LOG_STATS(iSocketFxn); + CLEAR_STATS(iSocketFxn); + iContainer.iObserver->HandleSocketEvent(iContainer.iId, iSocketFxn, EPVSocketTimeout, 0); +} + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_method.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_method.h new file mode 100644 index 0000000..273889c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_method.h @@ -0,0 +1,200 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_METHOD_H_INCLUDED +#define OSCL_SOCKET_METHOD_H_INCLUDED + +#include "osclconfig_io.h" +#include "oscl_socket_types.h" +//#include "oscl_socket_serv_imp.h" +#include "oscl_scheduler_ao.h" +#include "oscl_socket_request.h" +#include "pvlogger.h" +#include "oscl_socket_tuneables.h" +#include "oscl_ip_socket.h" + +#define MSEC_TO_MICROSEC 1000 + +class OsclSocketI; +class OsclSocketObserver; +class OsclSocketRequestAO; +class OsclIPSocketI; + +/** OsclSocketMethod is the base class for all socket methods. +* Two AOs are required for each socket operation-- one to provide +* a timeout, and one to detect request completion. The OsclSocketMethod +* class implements the timeout and contains the request completion AO. +*/ +class OsclSocketMethod : public OsclTimerObject +{ + public: + OsclSocketMethod(OsclIPSocketI& aContainer, const char *name, TPVSocketFxn fxn) + : OsclTimerObject(PV_SOCKET_REQUEST_AO_PRIORITY, name) + , iContainer(aContainer) + , iSocketFxn(fxn) + , iSocketRequestAO(NULL) + { + } + virtual ~OsclSocketMethod() + {} + + void Abort() + { + Cancel(); + } + + inline void AbortAll(); + + inline void CancelMethod(); + + OsclIPSocketI& iContainer; + + TPVSocketFxn iSocketFxn; + + Oscl_DefAlloc& Alloc() + { + return iContainer.Alloc(); + } + + TPVSocketEvent ThreadLogon(); + TPVSocketEvent ThreadLogoff(); + protected: + void ConstructL(OsclSocketRequestAO *aAO) + { + if (!aAO) + OsclError::Leave(OsclErrGeneral); + iSocketRequestAO = aAO; + } + + bool StartMethod(int32 aTimeoutMsec); + + inline void MethodDone(); + + void Run(); + + OsclSocketRequestAO *iSocketRequestAO; +}; + +#include "oscl_socket_imp.h" + +/** This is the base class for all the AOs that + interact with the socket server. + This object is contained within an OsclSocketMethod object +*/ +class OsclSocketRequestAO : public OsclActiveObject +{ + public: + void ConstructL() + { + } + protected: + + OsclSocketRequestAO(OsclSocketMethod& aContainer, const char *name) + : OsclActiveObject(PV_SOCKET_REQUEST_AO_PRIORITY, name) + , iContainer(aContainer) + , iSocketError(0) + , iParam(NULL) + , iParamSize(0) + {} + + virtual ~OsclSocketRequestAO() + { + CleanupParam(true); + } + + OsclAny* NewRequest(const uint32 size) ; + void CleanupParam(bool deallocate = false); + + + void Abort() + { + Cancel(); + } + + void RequestDone() + { + iContainer.Abort(); + } + + inline int GetSocketError(); + + void DoCancel() + { + SocketI()->CancelFxn(iContainer.iSocketFxn); + //we launch the cancellation process here. oscl scheduler + //will wait on completion of this AO request, which will + //happen in the server thread. + } + + void Run(); + + virtual void Success() + {} + + OsclSocketMethod& iContainer; + int32 iSocketError; + SocketRequestParam *iParam; + uint32 iParamSize; + + OsclSocketI *SocketI() + { + return iContainer.iContainer.iSocket; + } + + OsclSocketObserver* SocketObserver() + { + return iContainer.iContainer.iObserver; + } + uint32 Id() + { + return iContainer.iContainer.iId; + } + Oscl_DefAlloc& Alloc() + { + return iContainer.iContainer.Alloc(); + } + + friend class OsclSocketI; + friend class OsclSocketMethod; + friend class OsclSocketRequest; +}; + +inline void OsclSocketMethod::AbortAll() +{ + Abort(); + if (iSocketRequestAO) + iSocketRequestAO->Abort(); +} + +inline void OsclSocketMethod::CancelMethod() +{ + //cancel the timeout if any + Abort(); + //cancel the request to the socket server. + if (iSocketRequestAO) + iSocketRequestAO->DoCancel(); +} + +inline void OsclSocketMethod::MethodDone() +{ + if (iSocketRequestAO) + iSocketRequestAO->Abort(); +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv.cpp new file mode 100644 index 0000000..b51a013 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv.cpp @@ -0,0 +1,114 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_recv.h" + + +//////////// Method ///////////////////// + +OsclRecvMethod *OsclRecvMethod::NewL(OsclIPSocketI& c) +{ + OsclAny*p = c.Alloc().ALLOCATE(sizeof(OsclRecvMethod)); + OsclError::LeaveIfNull(p); + OsclRecvMethod* self = OSCL_PLACEMENT_NEW(p, OsclRecvMethod(c)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclRecvMethod::ConstructL() +{ + OsclAny*p = Alloc().ALLOCATE(sizeof(OsclRecvRequest)); + OsclError::LeaveIfNull(p); + OsclRecvRequest* self = OSCL_PLACEMENT_NEW(p, OsclRecvRequest(*this)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + iSocketRequestAO = self; + OsclSocketMethod::ConstructL(iSocketRequestAO); +} + +OsclRecvMethod::~OsclRecvMethod() +{ + if (RecvRequest()) + { + RecvRequest()->~OsclRecvRequest(); + Alloc().deallocate(RecvRequest()); + } +} + +TPVSocketEvent OsclRecvMethod::Recv(uint8* &aPtr, uint32 aMaxLen, + int32 aTimeout) +{ + if (!StartMethod(aTimeout)) + return EPVSocketFailure; + + RecvRequest()->Recv(aPtr, aMaxLen); + + return EPVSocketPending; +} + +uint8 *OsclRecvMethod::GetRecvData(int32 *aLength) +{ + return RecvRequest()->GetRecvData(aLength); +} + +//////////// AO ///////////////////// + +void OsclRecvRequest::Recv(uint8* &aPtr, uint32 aMaxLen) +{ + OsclAny *p = NewRequest(sizeof(RecvParam)); + if (!p) + PendComplete(OsclErrNoMemory); + else + { + iParam = OSCL_PLACEMENT_NEW(p, RecvParam(aPtr, aMaxLen, 0)); + if (!iParam) + PendComplete(OsclErrNoMemory); + else + SocketI()->Recv(*Param(), *this); + } +} +void OsclRecvRequest::Success() +{ + SocketI()->RecvSuccess(*Param()); +} + +uint8 *OsclRecvRequest::GetRecvData(int32 *aLength) +{ + if (iParam) + { + if (aLength) + *aLength = Param()->iBufRecv.iLen; + return Param()->iBufRecv.iPtr; + } + else + { + if (aLength) + *aLength = 0; + return NULL; + } +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv.h new file mode 100644 index 0000000..191d734 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_RECV_H_INCLUDED +#define OSCL_SOCKET_RECV_H_INCLUDED + +#include "oscl_socket_serv_imp.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_method.h" + + +/** + Internal implementation of Recv + */ +class OsclRecvRequest; + +class OsclRecvMethod : public OsclSocketMethod +{ + public: + static OsclRecvMethod *NewL(OsclIPSocketI& c); + + ~OsclRecvMethod(); + + TPVSocketEvent Recv(uint8* &aPtr, uint32 aMaxLen, + int32 aTimeout); + + uint8 *GetRecvData(int32 *aLength); + + private: + OsclRecvMethod(OsclIPSocketI& c) + : OsclSocketMethod(c, "osclrecvmethod", EPVSocketRecv) + {} + + void ConstructL(); + + public: + OsclRecvRequest *RecvRequest() + { + return (OsclRecvRequest*)iSocketRequestAO; + } +}; + +/** + This is the AO that interacts with the socket server + */ +class OsclRecvRequest : public OsclSocketRequestAO +{ + public: + uint8 *GetRecvData(int32 *aLength); + + OsclRecvRequest(OsclSocketMethod& c) + : OsclSocketRequestAO(c, "osclRecvRequest") + {} + + void Recv(uint8* &aPtr, uint32 aMaxLen); + void Success(); + + private: + + RecvParam*Param() + { + return(RecvParam*)iParam; + } + +}; + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv_from.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv_from.cpp new file mode 100644 index 0000000..50d5571 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv_from.cpp @@ -0,0 +1,125 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_recv_from.h" + +//////////// Method ///////////////////// + +OsclRecvFromMethod *OsclRecvFromMethod::NewL(OsclIPSocketI& c) +{ + OsclAny*p = c.Alloc().ALLOCATE(sizeof(OsclRecvFromMethod)); + OsclError::LeaveIfNull(p); + OsclRecvFromMethod* self = OSCL_PLACEMENT_NEW(p, OsclRecvFromMethod(c)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclRecvFromMethod::ConstructL() +{ + OsclAny*p = Alloc().ALLOCATE(sizeof(OsclRecvFromRequest)); + OsclError::LeaveIfNull(p); + OsclRecvFromRequest* self = OSCL_PLACEMENT_NEW(p, OsclRecvFromRequest(*this)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->OsclSocketRequestAO::ConstructL(); + OsclError::Pop(); + iSocketRequestAO = self; + OsclSocketMethod::ConstructL(iSocketRequestAO); +} + +OsclRecvFromMethod::~OsclRecvFromMethod() +{ + if (RecvFromRequest()) + { + RecvFromRequest()->~OsclRecvFromRequest(); + Alloc().deallocate(RecvFromRequest()); + } +} + +TPVSocketEvent OsclRecvFromMethod::RecvFrom(uint8* &aPtr, uint32 aMaxLen, + OsclNetworkAddress &aAddress, + int32 aTimeout, + uint32 aMultiMax, + Oscl_Vector* aPacketLen, + Oscl_Vector* aPacketSource) +{ + if (!StartMethod(aTimeout)) + return EPVSocketFailure; + + RecvFromRequest()->RecvFrom(aPtr, aMaxLen, aAddress, aMultiMax, aPacketLen, aPacketSource); + + return EPVSocketPending; +} + +uint8 *OsclRecvFromMethod::GetRecvData(int32 *aLength) +{ + return RecvFromRequest()->GetRecvData(aLength); +} + +//////////// AO ///////////////////// + +void OsclRecvFromRequest::RecvFrom(uint8* &aPtr, uint32 aMaxLen, + OsclNetworkAddress& aAddress, uint32 aMultiMax, + Oscl_Vector* aPacketLen, + Oscl_Vector* aPacketSource) +{ + OsclAny *p = NewRequest(sizeof(RecvFromParam)); + if (!p) + PendComplete(OsclErrNoMemory); + else + { + if (aPacketLen) + aPacketLen->clear(); + if (aPacketSource) + aPacketSource->clear(); + iParam = OSCL_PLACEMENT_NEW(p, RecvFromParam(aPtr, aMaxLen, aAddress, 0, aMultiMax, aPacketLen, aPacketSource)); + if (!iParam) + PendComplete(OsclErrNoMemory); + else + SocketI()->RecvFrom(*Param(), *this); + } +} +void OsclRecvFromRequest::Success() +{ + SocketI()->RecvFromSuccess(*Param()); +} + +uint8 *OsclRecvFromRequest::GetRecvData(int32 *aLength) +{ + if (iParam) + { + if (aLength) + *aLength = Param()->iBufRecv.iLen; + return Param()->iBufRecv.iPtr; + } + else + { + if (aLength) + *aLength = 0; + return NULL; + } +} + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv_from.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv_from.h new file mode 100644 index 0000000..0b351a6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_recv_from.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_RECV_FROM_H_INCLUDED +#define OSCL_SOCKET_RECV_FROM_H_INCLUDED + +#include "oscl_socket_serv_imp.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_method.h" + +/** + Internal implementation of RecvFrom + */ +class OsclRecvFromRequest; + +class OsclRecvFromMethod : public OsclSocketMethod +{ + public: + static OsclRecvFromMethod *NewL(OsclIPSocketI& c); + + ~OsclRecvFromMethod(); + + TPVSocketEvent RecvFrom(uint8* &aPtr, uint32 aMaxLen, + OsclNetworkAddress &aAddress, + int32 aTimeout, + uint32 aMultiMax, + Oscl_Vector* aPacketLen, + Oscl_Vector* aPacketSource); + + uint8 *GetRecvData(int32 *aLength); + + private: + OsclRecvFromMethod(OsclIPSocketI& c) + : OsclSocketMethod(c, "osclrecvfrommethod", EPVSocketRecvFrom) + {} + + void ConstructL(); + + public: + OsclRecvFromRequest *RecvFromRequest() + { + return (OsclRecvFromRequest*)iSocketRequestAO; + } +}; + +/** + This is the AO that interacts with the socket server + */ +class OsclRecvFromRequest : public OsclSocketRequestAO +{ + public: + uint8 *GetRecvData(int32 *aLength); + + OsclRecvFromRequest(OsclSocketMethod& c) + : OsclSocketRequestAO(c, "osclRecvFromRequest") + {} + + void RecvFrom(uint8* &aPtr, uint32 aMaxLen, + OsclNetworkAddress& aAddress, uint32 aMultiMax, + Oscl_Vector* aPacketLen, + Oscl_Vector* aPacketSource); + void Success(); + + private: + RecvFromParam*Param() + { + return(RecvFromParam*)iParam; + } +}; + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_request.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_request.cpp new file mode 100644 index 0000000..912ae92 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_request.cpp @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_socket_tuneables.h" +#if (PV_SOCKET_SERVER) +//PV Socket server interface + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_request.h" +#include "oscl_assert.h" +#include "oscl_error.h" +#include "oscl_socket_method.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_serv_imp.h" + +//Stats macros for use with OsclSocketRequest +#if(PV_OSCL_SOCKET_STATS_LOGGING) +#define ADD_STATS(a,b) iSocketRequestAO->SocketI()->iStats.Add(a,b) +#define LOG_STATS(a) iSocketRequestAO->SocketI()->iStats.Log(a) +#define CLEAR_STATS(a) iSocketRequestAO->SocketI()->iStats.Clear(a) +#else +#define ADD_STATS(a,b) +#define LOG_STATS(a) +#define CLEAR_STATS(a) +#endif + +void OsclSocketRequest::CancelRequest() +//cancel a request to the socket server. +{ + if (!iSocketRequestAO + || !iSocketRequestAO->IsBusy()) + return;//unexpected call. + + //issue request to server + ADD_STATS(iParam->iFxn, EOsclSocket_ServRequestCancelIssued); + iSocketI->iSocketServ->iSockServRequestList.StartCancel(this); +} + +void OsclSocketRequest::Activate(SocketRequestParam* p, OsclSocketRequestAO &a) +//activate a request to the socket server +{ + //save params + iSocketRequestAO = &a; + iParam = p; + + //issue request to server. + ADD_STATS(iParam->iFxn, EOsclSocket_ServRequestIssued); + iSocketI->iSocketServ->iSockServRequestList.Add(this); +} + + +void OsclSocketRequest::Complete(OsclSocketServRequestQElem* aElem, int32 aStatus, int32 aSockErr) +//called by socket server when a request is complete. +{ + ADD_STATS(iParam->iFxn, EOsclSocket_ServRequestComplete); + + //remove this request from the server's active request queue. + //note this just flags it for deletion instead of actually erasing + //from the queue, since this is generally called while iterating + //through the queue. + + //Note: It's important to make sure not to access + //anything in the socket object after completing the request, + //since at that point the app could delete the socket object + //at any time. + + OSCL_ASSERT(iSocketI->iSocketServ->IsServerThread()); + iSocketI->iSocketServ->iSockServRequestList.Remove(aElem); + + iSocketRequestAO->iSocketError = aSockErr; + iSocketRequestAO->PendComplete(aStatus); +} + +#endif //PV_SOCKET_SERVER + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_request.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_request.h new file mode 100644 index 0000000..48c0975 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_request.h @@ -0,0 +1,240 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_REQUEST_H_INCLUDED +#define OSCL_SOCKET_REQUEST_H_INCLUDED + +#include "oscl_socket_types.h" +#include "oscl_vector.h" +#include "oscl_mem.h" + +//Internal use buffer types. +class PVSockBufSend +{ + public: + PVSockBufSend(): + iPtr(NULL), + iLen(0) + {} + PVSockBufSend(const uint8* aPtr, uint32 aLen): + iPtr(aPtr), + iLen(aLen) + {} + PVSockBufSend(const PVSockBufSend& a): + iPtr(a.iPtr), + iLen(a.iLen) + {} + const uint8* iPtr; + uint32 iLen; +}; +class PVSockBufRecv +{ + public: + PVSockBufRecv(): + iPtr(NULL), + iLen(0), + iMaxLen(0) + {} + PVSockBufRecv(uint8* aPtr, uint32 aLen, uint32 aMax): + iPtr(aPtr), + iLen(aLen), + iMaxLen(aMax) + {} + PVSockBufRecv(const PVSockBufRecv& a) + : iPtr(a.iPtr) + , iLen(a.iLen) + , iMaxLen(a.iMaxLen) + {} + uint8* iPtr; + uint32 iLen; + uint32 iMaxLen; +}; + +class OsclSocketI; +class OsclSocketRequestAO; + +/**Base class for all socket method parameter sets +*/ +class SocketRequestParam +{ + public: + SocketRequestParam(TPVSocketFxn aFxn) + : iFxn(aFxn) + {} + + TPVSocketFxn iFxn; +}; + +/**Socket method parameter sets +*/ + +class SendParam: public SocketRequestParam +{ + public: + SendParam(const uint8* &aPtr, uint32 aLen, uint32 aFlags) + : SocketRequestParam(EPVSocketSend) + , iBufSend(aPtr, aLen) + , iFlags(aFlags) + , iXferLen(0) + {} + PVSockBufSend iBufSend; + uint32 iFlags; + uint32 iXferLen; +} ; + +class SendToParam: public SocketRequestParam +{ + public: + SendToParam(const uint8* &aPtr, uint32 aLen, OsclNetworkAddress& anAddr, uint32 flags) + : SocketRequestParam(EPVSocketSendTo) + , iBufSend(aPtr, aLen) + , iFlags(flags) + , iAddr(anAddr) + , iXferLen(0) + {} + ~SendToParam() + {} + PVSockBufSend iBufSend; + uint32 iFlags; + OsclNetworkAddress iAddr; + uint32 iXferLen; +} ; + +class RecvParam: public SocketRequestParam +{ + public: + RecvParam(uint8* &aPtr, uint32 aMaxLen, uint32 flags) + : SocketRequestParam(EPVSocketRecv) + , iBufRecv(aPtr, 0, aMaxLen) + , iFlags(flags) + {} + PVSockBufRecv iBufRecv; + uint32 iFlags; +} ; + +class RecvFromParam: public SocketRequestParam +{ + public: + RecvFromParam(uint8* &aPtr, uint32 aMaxLen, + OsclNetworkAddress& aAddress, uint32 flags, uint32 aMultiMax + , Oscl_Vector*aPacketLen + , Oscl_Vector* aPacketSource) + : SocketRequestParam(EPVSocketRecvFrom) + , iBufRecv(aPtr, 0, aMaxLen) + , iFlags(flags) + , iAddr(aAddress) + , iMultiMaxLen(aMultiMax) + , iPacketLen(aPacketLen) + , iPacketSource(aPacketSource) + {} + PVSockBufRecv iBufRecv; + uint32 iFlags; + OsclNetworkAddress& iAddr; + uint32 iMultiMaxLen; + Oscl_Vector* iPacketLen; + Oscl_Vector* iPacketSource; +}; + +class BindParam: public SocketRequestParam +{ + public: + BindParam(OsclNetworkAddress& anAddr) + : SocketRequestParam(EPVSocketBind) + , iAddr(anAddr) + {} + OsclNetworkAddress iAddr; +} ; + +class ListenParam: public SocketRequestParam +{ + public: + ListenParam(uint32 aSize) + : SocketRequestParam(EPVSocketListen) + , iQSize(aSize) + {} + uint32 iQSize; +} ; + +class ConnectParam: public SocketRequestParam +{ + public: + ConnectParam(OsclNetworkAddress& anAddr) + : SocketRequestParam(EPVSocketConnect) + , iAddr(anAddr) + {} + OsclNetworkAddress iAddr; +} ; + +class AcceptParam: public SocketRequestParam +{ + public: + AcceptParam(OsclSocketI& aBlankSocket) + : SocketRequestParam(EPVSocketAccept) + , iBlankSocket(&aBlankSocket) + {} + OsclSocketI *iBlankSocket; +} ; + +class ShutdownParam: public SocketRequestParam +{ + public: + ShutdownParam(TPVSocketShutdown aHow) + : SocketRequestParam(EPVSocketShutdown) + , iHow(aHow) + {} + TPVSocketShutdown iHow; +} ; + +#include "oscl_socket_tuneables.h" +#if PV_SOCKET_SERVER + +class OsclSocketServRequestQElem; + +/** This class defines the request interface to the PV socket +server. +*/ +class OsclSocketRequest +{ + public: + OsclSocketRequest() + : iSocketRequestAO(NULL) + , iParam(NULL) + , iSocketI(NULL) + {} + + TPVSocketFxn Fxn() + { + return iParam->iFxn; + } + + OsclSocketRequestAO *iSocketRequestAO; + SocketRequestParam *iParam; + OsclSocketI * iSocketI; + + void CancelRequest(); + void Activate(SocketRequestParam *iParam, OsclSocketRequestAO &a); + + void Complete(OsclSocketServRequestQElem*, int32 aStatus, int32 aSockErr = 0); + +}; + +#endif + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send.cpp new file mode 100644 index 0000000..1649b76 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send.cpp @@ -0,0 +1,116 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_send.h" +#include "oscl_socket_request.h" +#include "oscl_socket_imp.h" + +//////////// Method ///////////////////// + +OsclSendMethod *OsclSendMethod::NewL(OsclIPSocketI& c) +{ + OsclAny*p = c.Alloc().ALLOCATE(sizeof(OsclSendMethod)); + OsclError::LeaveIfNull(p); + OsclSendMethod* self = OSCL_PLACEMENT_NEW(p, OsclSendMethod(c)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclSendMethod::ConstructL() +{ + OsclAny*p = Alloc().ALLOCATE(sizeof(OsclSendRequest)); + OsclError::LeaveIfNull(p); + OsclSendRequest* self = OSCL_PLACEMENT_NEW(p, OsclSendRequest(*this)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + iSocketRequestAO = self; + OsclSocketMethod::ConstructL(iSocketRequestAO); +} + +OsclSendMethod::~OsclSendMethod() +{ + if (SendRequest()) + { + SendRequest()->~OsclSendRequest(); + Alloc().deallocate(SendRequest()); + } +} + +TPVSocketEvent OsclSendMethod::Send(const uint8* &aPtr, uint32 aLen, + int32 aTimeout) +{ + if (!StartMethod(aTimeout)) + return EPVSocketFailure; + + SendRequest()->Send(aPtr, aLen); + + return EPVSocketPending; +} + +uint8 *OsclSendMethod::GetSendData(int32 *aLength) +{ + return SendRequest()->GetSendData(aLength); +} + +//////////// AO ///////////////////// + +void OsclSendRequest::Send(const uint8* &aPtr, uint32 aLen) +{ + OsclAny *p = NewRequest(sizeof(SendParam)); + if (!p) + PendComplete(OsclErrNoMemory); + else + { + iParam = OSCL_PLACEMENT_NEW(p, SendParam(aPtr, aLen, 0)); + if (!iParam) + PendComplete(OsclErrNoMemory); + else + SocketI()->Send(*Param(), *this); + } +} + +void OsclSendRequest::Success() +{ + SocketI()->SendSuccess(*Param()); +} + +uint8 *OsclSendRequest::GetSendData(int32 *aLength) +{ + if (iParam) + { + if (aLength) + *aLength = Param()->iXferLen; + return (uint8*)Param()->iBufSend.iPtr; + } + else + { + if (aLength) + *aLength = 0; + return NULL; + } +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send.h new file mode 100644 index 0000000..1d4c300 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_SEND_H_INCLUDED +#define OSCL_SOCKET_SEND_H_INCLUDED + +#include "oscl_socket_types.h" +#include "oscl_socket_method.h" + +/** + Internal implementation of Send + */ +class OsclSendRequest; + +class OsclSendMethod : public OsclSocketMethod +{ + public: + static OsclSendMethod *NewL(OsclIPSocketI& c); + + ~OsclSendMethod(); + + TPVSocketEvent Send(const uint8* &aPtr, uint32 aLen, + int32 aTimeout); + + uint8 *GetSendData(int32 *aLength); + + private: + OsclSendMethod(OsclIPSocketI& c) + : OsclSocketMethod(c, "osclsendmethod", EPVSocketSend) + {}; + + void ConstructL(); + + public: + OsclSendRequest *SendRequest() + { + return (OsclSendRequest*)iSocketRequestAO; + } +}; + +/** + This is the AO that interacts with the socket server + */ +class SendParam; +class OsclSendRequest : public OsclSocketRequestAO +{ + public: + OsclSendRequest(OsclSocketMethod& c) + : OsclSocketRequestAO(c, "osclSendRequest") + {} + + + void Send(const uint8* &aPtr, uint32 aLen); + void Success(); + uint8 *GetSendData(int32 *aLength); + + private: + + SendParam*Param() + { + return(SendParam*)iParam; + } + +}; + + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send_to.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send_to.cpp new file mode 100644 index 0000000..97d19dc --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send_to.cpp @@ -0,0 +1,122 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_method.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_send_to.h" + +//////////// Method ///////////////////// + +OsclSendToMethod *OsclSendToMethod::NewL(OsclIPSocketI& c) +{ + OsclAny*p = c.Alloc().ALLOCATE(sizeof(OsclSendToMethod)); + OsclError::LeaveIfNull(p); + OsclSendToMethod* self = OSCL_PLACEMENT_NEW(p, OsclSendToMethod(c)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclSendToMethod::ConstructL() +{ + OsclAny*p = Alloc().ALLOCATE(sizeof(OsclSendToRequest)); + OsclError::LeaveIfNull(p); + OsclSendToRequest* self = OSCL_PLACEMENT_NEW(p, OsclSendToRequest(*this)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + iSocketRequestAO = self; + OsclSocketMethod::ConstructL(iSocketRequestAO); +} + +OsclSendToMethod::~OsclSendToMethod() +{ + if (SendToRequest()) + { + SendToRequest()->~OsclSendToRequest(); + Alloc().deallocate(SendToRequest()); + } +} + + +TPVSocketEvent OsclSendToMethod::SendTo(const uint8* &aPtr, uint32 aLen, + OsclNetworkAddress& aAddress, + int32 aTimeout) +{ + if (!StartMethod(aTimeout)) + return EPVSocketFailure; + + SendToRequest()->SendTo(aPtr, aLen, aAddress); + + return EPVSocketPending; +} + +uint8 *OsclSendToMethod::GetSendData(int32 *aLength) +{ + return SendToRequest()->GetSendData(aLength); +} + +//////////// AO ///////////////////// + +void OsclSendToRequest::SendTo(const uint8* &aPtr, uint32 aLen, OsclNetworkAddress &aAddress) +{ + OsclAny *p = NewRequest(sizeof(SendToParam)); + if (!p) + PendComplete(OsclErrNoMemory); + else + { + iParam = OSCL_PLACEMENT_NEW(p, SendToParam(aPtr, aLen, aAddress, 0)); + if (!iParam) + PendComplete(OsclErrNoMemory); + else + SocketI()->SendTo(*Param(), *this); + } +} +void OsclSendToRequest::Success() +{ + SocketI()->SendToSuccess(*Param()); +} + +uint8 *OsclSendToRequest::GetSendData(int32 *aLength) +{ + if (iParam) + { + if (aLength) + *aLength = Param()->iXferLen; + return (uint8*)Param()->iBufSend.iPtr; + } + else + { + if (aLength) + *aLength = 0; + return NULL; + } +} + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send_to.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send_to.h new file mode 100644 index 0000000..825b285 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_send_to.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_SEND_TO_H_INCLUDED +#define OSCL_SOCKET_SEND_TO_H_INCLUDED + +#include "oscl_socket_types.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_method.h" + +/** + Internal implementation of SendTo + */ +class OsclSendToRequest; + +class OsclSendToMethod : public OsclSocketMethod +{ + public: + static OsclSendToMethod *NewL(OsclIPSocketI& c); + ~OsclSendToMethod(); + + TPVSocketEvent SendTo(const uint8* &aPtr, uint32 aLen, + OsclNetworkAddress& aAddress, + int32 aTimeout); + + uint8 *GetSendData(int32 *aLength); + + private: + OsclSendToMethod(OsclIPSocketI& c) + : OsclSocketMethod(c, "osclsendtomethod", EPVSocketSendTo) + {}; + + void ConstructL(); + + public: + OsclSendToRequest *SendToRequest() + { + return (OsclSendToRequest*)iSocketRequestAO; + } +}; + +/** + This is the AO that interacts with the socket server + */ +class OsclSendToRequest : public OsclSocketRequestAO +{ + public: + OsclSendToRequest(OsclSocketMethod& c) + : OsclSocketRequestAO(c, "osclSendToRequest") + {} + + void SendTo(const uint8* &aPtr, uint32 aLen, OsclNetworkAddress &aAddress); + void Success(); + + uint8 *GetSendData(int32 *aLength); + + private: + + SendToParam*Param() + { + return(SendToParam*)iParam; + } +}; + + + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp.h new file mode 100644 index 0000000..fff0cfa --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp.h @@ -0,0 +1,37 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_SERV_IMP_H_INCLUDED +#define OSCL_SOCKET_SERV_IMP_H_INCLUDED + +/*! Common include file for OsclSocketServI declaration +*/ + +#include "osclconfig_io.h" +#include "oscl_socket_tuneables.h" +#if (PV_SOCKET_SERVER) +#include "oscl_socket_serv_imp_pv.h" +#else +#error No Implementation! +#endif + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_base.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_base.h new file mode 100644 index 0000000..d771afa --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_base.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_SERV_IMP_BASE_H_INCLUDED +#define OSCL_SOCKET_SERV_IMP_BASE_H_INCLUDED + +#include "oscl_base.h" +#include "oscl_socket_stats.h" + +class PVLogger; + +/** Socket Server implemenation +*/ + +/** Base class common to all implementations +*/ +class OsclSocketServIBase +{ + public: + virtual ~OsclSocketServIBase() + {} + + virtual int32 Connect(uint32 aMessageSlots, bool aShareSession) = 0; + virtual void Close(bool) = 0; + + protected: + OsclSocketServIBase(Oscl_DefAlloc &a) + : iAlloc(a) + { + iServError = 0; + iServState = ESocketServ_Idle; + iLogger = NULL; + } + + Oscl_DefAlloc &iAlloc; + + //server state + enum TSocketServState + { + ESocketServ_Idle + , ESocketServ_Connected + , ESocketServ_Error + }; + TSocketServState iServState; + + TSocketServState State()const + { + return iServState; + } + + bool IsServConnected()const + { + return iServState == ESocketServ_Connected; + } + int iServError; + +#if(PV_OSCL_SOCKET_STATS_LOGGING) + //server stats + OsclSocketServStats iServStats; +#endif + + public: + PVLogger* iLogger; +}; + + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.cpp new file mode 100644 index 0000000..7f91d57 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.cpp @@ -0,0 +1,1304 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "osclconfig_io.h" +#include "oscl_socket_tuneables.h" + +#if(PV_SOCKET_SERVER) + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_method.h" +#include "oscl_socket_types.h" +#include "oscl_socket_serv_imp_pv.h" +#include "oscl_error.h" +#include "oscl_socket_imp.h" +#include "oscl_assert.h" + +//Logger macro for socket server logging. +#if(PV_OSCL_SOCKET_SERVER_LOGGER_OUTPUT) +#include "pvlogger.h" +#define LOGSERV(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_DEBUG,m); +#else +#define LOGSERV(m) +#endif +/* +//disable this if it's too much +#undef LOGSERV +#define LOGSERV +*/ + +//Macros for server stats logging for use with OsclSocketServI +#if (PV_OSCL_SOCKET_STATS_LOGGING) +#define ADD_STATS(x) iServStats.Add(x) +#define ADD_STATSP(x,y) iServStats.Add(x,y) +#define CONSTRUCT_STATS(x) iServStats.Construct(x) +#define DUMP_STATS iServStats.LogAndDump(); +#else +#define ADD_STATS(x) +#define ADD_STATSP(x,y) +#define CONSTRUCT_STATS(x) +#define DUMP_STATS +#endif//PV_OSCL_SOCKET_STATS_LOGGING + + +#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET +// +//OsclSocketServI::LoopbackSocket +// + +//Macros for server stats logging for use with OsclSocketServI::LoopbackSocket +#if (PV_OSCL_SOCKET_STATS_LOGGING) +#define ADD_LOOPSTATS(a,b) iStats.Add((TPVSocketFxn)0,a,b); +#define LOG_LOOPSTATS iStats.Log(); +#define DUMP_LOOPSTATS iStats.Log();iStats.Clear((TPVSocketFxn)0); +#else +#define ADD_LOOPSTATS(a,b) +#define LOG_LOOPSTATS +#define DUMP_LOOPSTATS +#endif//PV_OSCL_SOCKET_STATS_LOGGING + +void OsclSocketServI::LoopbackSocket::Init(OsclSocketServI* aContainer) +//This will intialize the loopback socket that is used +//to wakeup a blocking select call. +{ + iContainer = aContainer; +#if PV_OSCL_SOCKET_STATS_LOGGING + iStats.Construct(NULL, this); +#endif + + //create the socket + bool ok; + int err; + OsclSocket(iSocket, OSCL_AF_INET, OSCL_SOCK_DATAGRAM, OSCL_IPPROTO_UDP, ok, err); + if (!ok) + { + ADD_LOOPSTATS(EOsclSocketServ_LoopsockError, err); + return ; + } + + //set it to non-blocking mode + OsclSetNonBlocking(iSocket, ok, err); + if (!ok) + {//set non-blocking mode failed + ADD_LOOPSTATS(EOsclSocketServ_LoopsockError, err); + OsclCloseSocket(iSocket, ok, err); + return ; + } + + //bind to any available port between 5000 and 10000. + OsclNetworkAddress myAddr("127.0.0.1", 5000); + while (myAddr.port < 10000) + { + OsclSocketI::MakeAddr(myAddr, iAddr); + OsclBind(iSocket, iAddr, ok, err); + if (!ok) + { + myAddr.port++; + } + else + { + break;//bind success! + } + } + + if (!ok) + {//bind failed + ADD_LOOPSTATS(EOsclSocketServ_LoopsockError, err); + OsclCloseSocket(iSocket, ok, err); + return ; + } + + //let's test a send & recv here just to be extra sure + //the loopsock is usable. + const char tmpBuf[2] = {0, 0}; + int nbytes; + bool wouldblock; + wouldblock = false; + ok = false; + nbytes = 0; + OsclSendTo(iSocket, tmpBuf, 1, iAddr, ok, err, nbytes, wouldblock); + if (!ok) + { + if (wouldblock) + { + //just skip the test + ok = true; + } + else + { + //send failed. + ADD_LOOPSTATS(EOsclSocketServ_LoopsockError, err); + OsclCloseSocket(iSocket, ok, err); + return ; + } + } + else + { + //send ok-- now try a recv + TOsclSockAddr sourceaddr; + TOsclSockAddrLen sourceaddrlen = sizeof(sourceaddr); + ok = false; + nbytes = 0; + OsclRecvFrom(iSocket, tmpBuf, sizeof(tmpBuf), + &sourceaddr, + &sourceaddrlen, + ok, + err, + nbytes, + wouldblock); + if (!ok) + { + if (wouldblock) + { + //just skip the test + ok = true; + } + else + {//recv failed. + ADD_LOOPSTATS(EOsclSocketServ_LoopsockError, err); + OsclCloseSocket(iSocket, ok, err); + return ; + } + } + } + + //loopsock is ready to use + ADD_LOOPSTATS(EOsclSocketServ_LoopsockOk, myAddr.port); +#if PV_OSCL_SOCKET_STATS_LOGGING + iStats.Construct((OsclAny*)iSocket, this); +#endif + iEnable = true; +} + +void OsclSocketServI::LoopbackSocket::Cleanup() +//This will intialize the loopback socket that is used +//to wakeup a blocking select call. +{ + if (iEnable) + { + //close the socket + bool ok; + int sockerr; + OsclCloseSocket(iSocket, ok, sockerr); + iEnable = false; + DUMP_LOOPSTATS; + } +} + +void OsclSocketServI::LoopbackSocket::Read() +{ + if (!iEnable) + return; + + //read all queued data on the socket + if (FD_ISSET(iSocket, &iContainer->iReadset)) + { + char tmpBuf[2] = {0, 0}; + int nbytes, err; + bool ok, wouldblock; + TOsclSockAddr sourceaddr; + TOsclSockAddrLen sourceaddrlen = sizeof(sourceaddr); + + bool recv = true; + while (recv) + { + OsclRecvFrom(iSocket, tmpBuf, sizeof(tmpBuf), + &sourceaddr, + &sourceaddrlen, + ok, + err, + nbytes, + wouldblock); + recv = (ok && nbytes > 0); + } + } +} + +void OsclSocketServI::LoopbackSocket::ProcessSelect(TOsclSocket& maxsocket) +//Do the necessary select loop processing to keep +//the loopback socket going. +{ + if (!iEnable) + return; + + //Monitor this socket whenever we will be doing a select. + if (maxsocket) + { + FD_SET(iSocket, &iContainer->iReadset); + if (iSocket > maxsocket) + maxsocket = iSocket; + } +} + +void OsclSocketServI::LoopbackSocket::Write() +//Write to the loopback socket +{ + if (!iEnable) + return; + + char tmpBuf[2] = {0, 0}; + int nbytes, err; + bool wouldblock, ok; + OsclSendTo(iSocket, tmpBuf, 1, iAddr, ok, err, nbytes, wouldblock); + + //if send failed, the select call will hang forever, so just go ahead and abort now. + OSCL_ASSERT(ok); +} +#endif //#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET + +// Socket server stats for winmobile perf investigation. +#if (PV_SOCKET_SERVI_STATS) + +//breakdown of time in the Session +enum TServiSessionStats +{ + EServiSession_All + , EServiSession_Last +}; + +//breakdown of time in the Run() call +enum TServiRunStats +{ + EServiRun_Proc = EServiSession_Last + , EServiRun_Select + , EServiRun_Reschedule + , EServiRun_Last +}; +//breakdown of time in the ProcessSocketRequests call +enum TServiProcStats +{ + EServiProc_Queue = EServiRun_Last + , EServiProc_Loop + , EServiProc_Fdset + , EServiProc_Last +}; +//breakdown of time in the ProcessXXX calls in ProcessSocketRequests +enum TServiProcLoopStats +{ + EServiProcLoop_Cancel = EServiProc_Last + , EServiProcLoop_Closed + , EServiProcLoop_Connect + , EServiProcLoop_Accept + , EServiProcLoop_Shutdown + , EServiProcLoop_Recv + , EServiProcLoop_Send + , EServiProcLoop_RecvFrom + , EServiProcLoop_SendTo + , EServiProcLoop_Last +}; +static const char* const TServiStr[] = +{ + "EServiSession_All" + , "EServiRun_Proc" + , "EServiRun_Select" + , "EServiRun_Reschedule" + , "EServiProc_Queue" + , "EServiProc_Loop" + , "EServiProc_Fdset" + , "EServiProcLoop_Cancel" + , "EServiProcLoop_Closed" + , "EServiProcLoop_Connect" + , "EServiProcLoop_Accept" + , "EServiProcLoop_Shutdown" + , "EServiProcLoop_Recv" + , "EServiProcLoop_Send" + , "EServiProcLoop_RecvFrom" + , "EServiProcLoop_SendTo" +}; + + +#define PV_SERVI_STATS_SIZE (EServiProcLoop_Last) +#include "oscl_int64_utils.h" + +class PVServiStats +{ + public: + //use oscl tick count + typedef uint32 TPVTick; + const char* Tickstr() + { + return "Ticks"; + } + void settick(TPVTick &tick) + { + tick = OsclTickCount::TickCount(); + } + int64 tickint(TPVTick& tick) + { + return tick; + } + + PVServiStats(): iCount(0), iRunningTotal(0) + {} + ~PVServiStats() + {} + + uint32 iCount; + int64 iRunningTotal; + + TPVTick _start; + + //start an interval + void Start() + { + settick(_start); + } + + //end an interval + void End() + { + TPVTick now; + settick(now); + int32 delta = tickint(now) - tickint(_start); + //winmobile clock sometimes goes backward so treat any negative delta as zero. + if (delta > 0) + iRunningTotal += delta; + iCount++; + } + //end a long interval + void LongEnd() + { + TPVTick now; + settick(now); + int64 delta = tickint(now) - tickint(_start); + //winmobile clock sometimes goes backward so treat any negative delta as zero. + if (delta > 0) + iRunningTotal += delta; + iCount++; + } + + static PVServiStats* Create() + { + _OsclBasicAllocator alloc; + OsclAny* ptr = alloc.allocate(PV_SERVI_STATS_SIZE * sizeof(PVServiStats)); + PVServiStats* ptr2 = (PVServiStats*)ptr; + for (uint32 i = 0; i < PV_SERVI_STATS_SIZE; i++) + { + new(ptr2++) PVServiStats(); + } + return (PVServiStats*)ptr; + } + + static void Destroy(PVServiStats* aStats) + { + if (aStats) + { + _OsclBasicAllocator alloc; + //don't bother with destructor since it's empty. + alloc.deallocate(aStats); + } + } + + void ShowStats(PVLogger* logger, int32 aIndex, PVServiStats& aInterval) + { + if (!iCount) + return;//don't print any that didn't run + if (aInterval.iRunningTotal == (int64)0) + return;//to avoid div by zero + + float percent = 100.0 * iRunningTotal / aInterval.iRunningTotal; + int32 fraction = (int32)percent; + float decimal = percent - fraction; + decimal *= 100.0; + + //print results + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO + , (0, " TIME PERCENT %d.%02d, Interval '%s', Count %d, TotalTicks Hi,Lo (0x%x,0x%08x)" + , (int32)percent, (int32)decimal + , TServiStr[aIndex] + , iCount + , Oscl_Int64_Utils::get_int64_upper32(iRunningTotal) + , Oscl_Int64_Utils::get_int64_lower32(iRunningTotal) + )); + } + + static void ShowSummaryStats(PVServiStats* aArray) + { + //lump this logging with Oscl scheduler perf logging. + uint32 index = 0; + PVLogger* logger = PVLogger::GetLoggerObject("OsclSchedulerPerfStats"); + + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "Session Breakdown:")); + while (index < EServiSession_Last) + { + aArray[index].ShowStats(logger, index, aArray[EServiSession_All]); + index++; + } + + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "Run Breakdown:")); + while (index < EServiRun_Last) + { + aArray[index].ShowStats(logger, index, aArray[EServiSession_All]); + index++; + } + + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "ProcessRequests Breakdown:")); + while (index < EServiProc_Last) + { + aArray[index].ShowStats(logger, index, aArray[EServiSession_All]); + index++; + } + + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "ProcessRequests Loop Breakdown:")); + while (index < EServiProcLoop_Last) + { + aArray[index].ShowStats(logger, index, aArray[EServiSession_All]); + index++; + } + } +}; +#define START_SERVI_STATS(x) iServiStats[x].Start() +#define END_SERVI_STATS(x) iServiStats[x].End() +#define LONG_END_SERVI_STATS(x) iServiStats[x].LongEnd() +//2nd level of detail-- switched off for now. +#define START_SERVI_STATS2(x) iServiStats[x].Start() +#define END_SERVI_STATS2(x) iServiStats[x].End() +#else +#define START_SERVI_STATS(x) +#define END_SERVI_STATS(x) +#define LONG_END_SERVI_STATS(x) +#define START_SERVI_STATS2(x) +#define END_SERVI_STATS2(x) +#endif //PV_SOCKET_SERVI_STATS + +// +//OsclSocketServI-- PV implementation +// + +#if(PV_SOCKET_SERVER_IS_THREAD) +OsclSocketServI::OsclSocketServI(Oscl_DefAlloc &a) + : OsclSocketServIBase(a) +{ +} +#else +OsclSocketServI::OsclSocketServI(Oscl_DefAlloc &a) + : OsclTimerObject(PV_SOCKET_SERVER_AO_PRIORITY, "OsclSocketServI") + , OsclSocketServIBase(a) +{ +} +#endif + +OsclSocketServI::~OsclSocketServI() +{ + Close(false); + CleanupServImp(); +} + +OsclSocketServI* OsclSocketServI::NewL(Oscl_DefAlloc &a) +{ + OsclAny*p = a.ALLOCATE(sizeof(OsclSocketServI)); + OsclError::LeaveIfNull(p); + OsclSocketServI *self = OSCL_PLACEMENT_NEW(p, OsclSocketServI(a)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclSocketServI::ConstructL() +{ + iSockServRequestList.iActiveRequests.reserve(6); + ConstructServImp(); + CONSTRUCT_STATS(this); +} + +int32 OsclSocketServI::Connect(uint32 aMessageSlots, bool aShareSession) +{ + CONSTRUCT_STATS(this); + +#if (PV_SOCKET_SERVI_STATS) + iServiStats = PVServiStats::Create(); + START_SERVI_STATS(EServiSession_All); +#endif + + //Connect to Oscl socket server + + OSCL_UNUSED_ARG(aMessageSlots); + OSCL_UNUSED_ARG(aShareSession); + + //should only connect once + if (iServState == ESocketServ_Connected) + { + return OsclErrGeneral; + } + +#ifdef OsclSocketStartup + //startup the socket system. + bool ok; + OsclSocketStartup(ok); + if (!ok) + { + return OsclErrGeneral; + } +#endif//OsclSocketStartup + + iServState = ESocketServ_Idle; + + //Start the server thread or AO + int32 err = StartServImp(); + if (err != OsclErrNone) + { + return err; + } + + //check state. + if (iServState != ESocketServ_Connected) + { + //cleanup after a failure. + Close(false); + return OsclErrGeneral; + } + return OsclErrNone; +} + +void OsclSocketServI::Close(bool aCleanup) +{ + //Close oscl socket server + + if (iServState == ESocketServ_Connected) + { + StopServImp(); + } + +#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET + iLoopbackSocket.Cleanup(); +#endif + +#ifdef OsclSocketCleanup + //close the socket system + if (aCleanup) + { + bool ok; + OsclSocketCleanup(ok); + } +#endif//OsclSocketCleanup + + DUMP_STATS; + +#if (PV_SOCKET_SERVI_STATS) + if (iServiStats) + { + LONG_END_SERVI_STATS(EServiSession_All); + PVServiStats::ShowSummaryStats(iServiStats); + PVServiStats::Destroy(iServiStats); + iServiStats = NULL; + } +#endif +} + +bool OsclSocketServI::IsServerThread() +{ +#if(PV_SOCKET_SERVER_IS_THREAD) + TOsclThreadId tid; + OsclThread::GetId(tid); + return tid == iThreadId; +#else + return true; +#endif +} + +/** + * Process all active socket requests. + * + * This is called under the server thread or server AO. + * + * @param aNhandles(input/output): nHandles returned by last Select call. + * @param aNfds(output): Value = 1+maximum socket handle for all sockets + * that we are monitoring with the select call. + */ +#if PV_SOCKET_SERVER_SELECT +void OsclSocketServI::ProcessSocketRequests(int& aNhandles, int &aNfds) +#else +void OsclSocketServI::ProcessSocketRequests() +#endif +{ + //process all active requests + +#if PV_SOCKET_SERVER_SELECT + //keep track of max socket handle to monitor. + TOsclSocket maxsocket = 0; + aNfds = (int)maxsocket + 1; + + //save input handle count, then clear it until the next select operation. + int nhandles = aNhandles; + aNhandles = 0; +#endif + + // Pick up new requests from the app thread. + START_SERVI_STATS2(EServiProc_Queue); + iSockServRequestList.Lock(); + { + iSockServRequestList.GetNewRequests(); + +#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET + //flush any data on the loopback socket. + iLoopbackSocket.Read(); +#endif + } + iSockServRequestList.Unlock(); + END_SERVI_STATS2(EServiProc_Queue); + + if (iSockServRequestList.iActiveRequests.empty()) + { + //nothing to do! + return; + } + + //Make a pass through the open request list and cancel or process each request. + START_SERVI_STATS2(EServiProc_Loop); + uint32 i; + for (i = 0; i < iSockServRequestList.iActiveRequests.size(); i++) + { + OsclSocketServRequestQElem* elem = &iSockServRequestList.iActiveRequests[i]; + + if (elem->iCancel) + { + //Request was canceled + START_SERVI_STATS2(EServiProcLoop_Cancel); + elem->iSocketRequest->Complete(elem, OSCL_REQUEST_ERR_CANCEL); + END_SERVI_STATS2(EServiProcLoop_Cancel); + } + else if (!IsServConnected()) + { + //Server died or was closed. + START_SERVI_STATS2(EServiProcLoop_Closed); + elem->iSocketRequest->Complete(elem, OSCL_REQUEST_ERR_GENERAL + , (iServError) ? iServError : PVSOCK_ERR_SERV_NOT_CONNECTED); + END_SERVI_STATS2(EServiProcLoop_Closed); + } +#if PV_SOCKET_SERVER_SELECT + else if (nhandles == 0 && elem->iSelect) + { + //we're monitoring this socket but there is no current + //socket activity-- just keep waiting. + ; + } +#endif + else + { + //These routines will start the request, or else process + //the results of prior select call, and also set the select + //flags for the next call. + + switch (elem->iSocketRequest->Fxn()) + { + case EPVSocketShutdown: + START_SERVI_STATS2(EServiProcLoop_Shutdown); + elem->iSocketRequest->iSocketI->ProcessShutdown(elem); + END_SERVI_STATS2(EServiProcLoop_Shutdown); + break; + + case EPVSocketConnect: + START_SERVI_STATS2(EServiProcLoop_Connect); + elem->iSocketRequest->iSocketI->ProcessConnect(elem); + END_SERVI_STATS2(EServiProcLoop_Connect); + break; + + case EPVSocketAccept: + START_SERVI_STATS2(EServiProcLoop_Accept); + elem->iSocketRequest->iSocketI->ProcessAccept(elem); + END_SERVI_STATS2(EServiProcLoop_Accept); + break; + + case EPVSocketSend: + START_SERVI_STATS2(EServiProcLoop_Send); + elem->iSocketRequest->iSocketI->ProcessSend(elem); + END_SERVI_STATS2(EServiProcLoop_Send); + break; + + case EPVSocketSendTo: + START_SERVI_STATS2(EServiProcLoop_SendTo); + elem->iSocketRequest->iSocketI->ProcessSendTo(elem); + END_SERVI_STATS2(EServiProcLoop_SendTo); + break; + + case EPVSocketRecv: + START_SERVI_STATS2(EServiProcLoop_Recv); + elem->iSocketRequest->iSocketI->ProcessRecv(elem); + END_SERVI_STATS2(EServiProcLoop_Recv); + break; + + case EPVSocketRecvFrom: + START_SERVI_STATS2(EServiProcLoop_RecvFrom); + elem->iSocketRequest->iSocketI->ProcessRecvFrom(elem); + END_SERVI_STATS2(EServiProcLoop_RecvFrom); + break; + + default: + OSCL_ASSERT(0); + break; + } + } + } + END_SERVI_STATS2(EServiProc_Loop); + + //Zero out any old select set + START_SERVI_STATS2(EServiProc_Fdset); +#if PV_SOCKET_SERVER_SELECT + FD_ZERO(&iReadset); + FD_ZERO(&iWriteset); + FD_ZERO(&iExceptset); +#endif + LOGSERV((0, "OsclSocketServI::ProcessSocketRequests Clearing select set")); + + //Now make a pass to either delete the request or collate the select flags. + for (i = 0; i < iSockServRequestList.iActiveRequests.size();) + { + OsclSocketServRequestQElem* elem = &iSockServRequestList.iActiveRequests[i]; + + if (elem->iSocketRequest) + { + //request is still active + i++; + +#if PV_SOCKET_SERVER_SELECT + if (elem->iSelect > 0) + { + //Need to do a select call for this socket + + TOsclSocket osock = elem->iSocketRequest->iSocketI->Socket(); + + if (osock > maxsocket) + { + LOGSERV((0, "OsclSocketServI::ProcessSocketRequests Setting Maxsocket to %d", osock)); + maxsocket = osock; + } + + //Add the socket to the select set. Keep in mind there can be multiple requests + //per socket, so check whether the socket is already added before adding. + + if ((elem->iSelect & OSCL_READSET_FLAG) == OSCL_READSET_FLAG + && !(FD_ISSET(osock, &iReadset))) + { + FD_SET(osock, &iReadset); + LOGSERV((0, "OsclSocketServI::ProcessSocketRequests Setting Readset for %d", osock)); + } + + if ((elem->iSelect & OSCL_WRITESET_FLAG) == OSCL_WRITESET_FLAG + && !(FD_ISSET(osock, &iWriteset))) + { + FD_SET(osock, &iWriteset); + LOGSERV((0, "OsclSocketServI::ProcessSocketRequests Setting Writeset for %d", osock)); + } + + if ((elem->iSelect & OSCL_EXCEPTSET_FLAG) == OSCL_EXCEPTSET_FLAG + && !(FD_ISSET(osock, &iExceptset))) + { + FD_SET(osock, &iExceptset); + LOGSERV((0, "OsclSocketServI::ProcessSocketRequests Setting Exceptset for %d", osock)); + } + } +#endif + } + else + { + //request is complete and can be deleted. + iSockServRequestList.iActiveRequests.erase(elem); + } + } + END_SERVI_STATS2(EServiProc_Fdset); + +#if PV_SOCKET_SERVER_SELECT + if (maxsocket) + { +#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET + //also monitor the loopback socket if we're going to call select. + iLoopbackSocket.ProcessSelect(maxsocket); +#endif + + //set Nfds to 1+maxsocket handle. + aNfds = (int)maxsocket + 1; + } + + LOGSERV((0, "OsclSocketServI::ProcessSocketRequests NFDS %d", aNfds)); +#endif + +} + +void OsclSocketServI::ServerEntry() +//Server entry processing +{ + iLogger = PVLogger::GetLoggerObject("osclsocket_serv"); + + iServError = 0; + iServState = OsclSocketServI::ESocketServ_Connected; + + iSockServRequestList.Open(this); + +#if PV_SOCKET_SERVER_SELECT + FD_ZERO(&iReadset); + FD_ZERO(&iWriteset); + FD_ZERO(&iExceptset); +#endif +} + +void OsclSocketServI::ServerExit() +//Server exit processing +{ + //change state if this was a normal exit. + if (iServState == OsclSocketServI::ESocketServ_Connected) + { + iServState = OsclSocketServI::ESocketServ_Idle; + } + + //Go through the active requests one last time. + //All the requests will complete with errors + //since the server is no longer connected. +#if PV_SOCKET_SERVER_SELECT + int nfds; + int nhandles = 0; + ProcessSocketRequests(nhandles, nfds); +#else + ProcessSocketRequests(); +#endif + + iSockServRequestList.Close(); + + //make sure sets are clear so resources get cleaned up. +#if PV_SOCKET_SERVER_SELECT + FD_ZERO(&iReadset); + FD_ZERO(&iWriteset); + FD_ZERO(&iExceptset); +#endif +} + +void OsclSocketServI::ConstructServImp() +{ +#if(PV_SOCKET_SERVER_IS_THREAD) + iClose = false; + iStart.Create(); + iExit.Create(); +#endif +} + +void OsclSocketServI::CleanupServImp() +{ +#if(PV_SOCKET_SERVER_IS_THREAD) + iStart.Close(); + iExit.Close(); +#endif +} + +#if(PV_SOCKET_SERVER_IS_THREAD) +//socket server thread routine +static TOsclThreadFuncRet OSCL_THREAD_DECL sockthreadmain(TOsclThreadFuncArg arg); +#endif + +int32 OsclSocketServI::StartServImp() +{ +#if(PV_SOCKET_SERVER_IS_THREAD) + + //setup the loopback socket and/or polling interval. +#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET + iLoopbackSocket.iEnable = false; +#endif + iSelectPollIntervalMsec = 0; + + //check the select timeout in the configuration. + int32 selectTimeoutMsec = PV_SOCKET_SERVER_SELECT_TIMEOUT_MSEC; + if (selectTimeoutMsec <= 0) + { + //non-polling option selected. + //create the select cancel pipe. +#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET + iLoopbackSocket.Init(this); + + //if loopback socket isn't available, we must poll. + if (!iLoopbackSocket.iEnable) +#endif + { + iSelectPollIntervalMsec = 10; + } + } + else + { + //polling option selected. + iSelectPollIntervalMsec = selectTimeoutMsec; +#if(PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET) + //create the loopback socket. + iLoopbackSocket.Init(this); +#endif + } + + //Start the server thread. + OsclThread thread; + OsclProcStatus::eOsclProcError err = thread.Create((TOsclThreadFuncPtr)sockthreadmain, + 1024, + (TOsclThreadFuncArg)this); + if (err != OsclErrNone) + return OsclErrGeneral; + + thread.SetPriority(PV_SOCKET_SERVER_THREAD_PRIORITY); + + //wait til thread starts + iStart.Wait(); + + return OsclErrNone; + +#else//PV_SOCKET_SERVER_IS_THREAD + + //Socket server AO startup. + +#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET + iLoopbackSocket.iEnable = false; +#endif + + ServerEntry(); + + if (!IsAdded()) + { +#if PV_SOCKET_SERVER_SELECT + iNhandles = 0; + iNfds = 0; +#endif + AddToScheduler(); + } + return OsclErrNone; + +#endif //PV_SOCKET_SERVER_IS_THREAD +} + +void OsclSocketServI::StopServImp() +{ +#if(PV_SOCKET_SERVER_IS_THREAD) + //stop the thread. + iClose = true; + iSockServRequestList.Wakeup();//wake up the thread if needed. + WakeupBlockingSelect(); + //wait til thread exits + iExit.Wait(); + +#else//PV_SOCKET_SERVER_IS_THREAD + + //Socket server AO cleanup. + if (iServState != OsclSocketServI::ESocketServ_Connected) + { + return; + } + + //cancel any active request. + if (IsAdded()) + { + Cancel(); + } + + ServerExit(); + + //remove AO from scheduler. + if (IsAdded()) + { + RemoveFromScheduler(); + } +#endif//PV_SOCKET_SERVER_IS_THREAD +} + + +#if(PV_SOCKET_SERVER_IS_THREAD) + +void OsclSocketServI::InThread() +//Socket server thread implementation. +{ + OsclThread::GetId(iThreadId); + + iClose = false; + + ServerEntry(); + + //Let server know thread is started and ready to + //process requests. + iStart.Signal(); + + //create select timeout structure + timeval timeout; + + bool ok; + int nfds; + int nhandles = 0; + + while (!iClose) + { + //process new requests and new socket activity on existing requests. + ProcessSocketRequests(nhandles, nfds); + + //Make the select call if needed. + if (nfds > 1) + { + //Set the fixed timeout. The select call may update this value + //so it needs to be set on each call. + timeout.tv_sec = 0; + + if (iSelectPollIntervalMsec == 0) + { + //wait forever + timeout.tv_usec = 0x1fffffff; + } + else + { + //poll + timeout.tv_usec = iSelectPollIntervalMsec * 1000; + } + + LOGSERV((0, "OsclSocketServI::InThread Calling select, timeout %d", iSelectPollIntervalMsec)); + OsclSocketSelect(nfds, iReadset, iWriteset, iExceptset, timeout, ok, iServError, nhandles); + LOGSERV((0, "OsclSocketServI::InThread Select call returned")); + if (!ok) + { + //select error. + iServState = OsclSocketServI::ESocketServ_Error; + break; + } + if (nhandles) + { + ADD_STATS(EOsclSocketServ_SelectActivity); + } + else + { + ADD_STATS(EOsclSocketServ_SelectNoActivity); + } + } + else + { + //wait on new requests from the app side. + LOGSERV((0, "OsclSocketServI::InThread Waiting on requests")); + iSockServRequestList.WaitOnRequests(); + LOGSERV((0, "OsclSocketServI::InThread Done Waiting on requests")); + } + + }//select loop + + ServerExit(); + + //signal close complete to caller... + if (iClose) + { + iClose = false; + iExit.Signal(); + } +} + +static TOsclThreadFuncRet OSCL_THREAD_DECL sockthreadmain2(TOsclThreadFuncArg arg); +static TOsclThreadFuncRet OSCL_THREAD_DECL sockthreadmain(TOsclThreadFuncArg arg) +//socket server thread. +{ + OSCL_ASSERT(arg); + OsclBase::Init(); + OsclErrorTrap::Init(); + + //once error trap is initialized, run everything else under a trap + int32 err; + OSCL_TRY(err, + + OsclMem::Init(); + PVLogger::Init(); + + sockthreadmain2(arg); + + PVLogger::Cleanup(); + OsclMem::Cleanup(); + ); + + OsclErrorTrap::Cleanup(); + OsclBase::Cleanup(); + + return 0; +} + + +#include "pvlogger.h" + +#if(PV_OSCL_SOCKET_SERVER_LOGGER_OUTPUT) +#include "pvlogger_time_and_id_layout.h" +#include "pvlogger_file_appender.h" +#include "pvlogger_stderr_appender.h" + +#define LOGFILENAME _STRLIT_WCHAR("pvosclsocket_serv.log"); + +template +class LogAppenderDestructDealloc : public OsclDestructDealloc +{ + public: + void destruct_and_dealloc(OsclAny *ptr) + { + delete((DestructClass*)ptr); + } +}; +#endif//PV_OSCL_SOCKET_SERVER_LOGGER_OUTPUT + + +static TOsclThreadFuncRet OSCL_THREAD_DECL sockthreadmain2(TOsclThreadFuncArg arg) +{ + OSCL_ASSERT(arg); + OsclSocketServI *serv = (OsclSocketServI*)arg; + +#if(PV_OSCL_SOCKET_SERVER_LOGGER_OUTPUT) + //create logger appenders. + PVLoggerAppender* appender; + +//File logger + //find an unused filename so we don't over-write any prior logs + Oscl_FileServer fs; + Oscl_File file; + fs.Connect(); + OSCL_wHeapString filename; + oscl_wchar fileid[2]; + fileid[1] = (oscl_wchar)'\0'; + for (char c = 'A'; c <= 'Z'; c++) + { + filename = LOGFILENAME; + fileid[0] = (oscl_wchar)c; + filename += fileid; + filename += _STRLIT_WCHAR(".txt"); + if (file.Open((oscl_wchar*)filename.get_cstr(), Oscl_File::MODE_READ, fs) != 0) + { + break;//found a nonexistent file. + } + file.Close(); + } + fs.Close(); + //create appender using the selected filename. + appender = TextFileAppender::CreateAppender((OSCL_TCHAR*)filename.get_cstr()); + OsclRefCounterSA > > *appenderRefCounter = + new OsclRefCounterSA > >(appender); + //Set logging options. + OsclSharedPtr appenderPtr(appender, appenderRefCounter); + PVLogger *rootnode = PVLogger::GetLoggerObject(""); + rootnode->AddAppender(appenderPtr); + rootnode->SetLogLevel(PVLOGMSG_DEBUG); +#endif //PV_OSCL_SOCKET_SERVER_LOGGER_OUTPUT + + serv->InThread(); + + return 0; +} + + +#else//PV_SOCKET_SERVER_IS_THREAD +//Non-threaded section + +void OsclSocketServI::Run() +//Socket server AO +{ +#if !PV_SOCKET_SERVER_SELECT + //non-select-loop implementation. + + //Process active requests. + START_SERVI_STATS(EServiRun_Proc); + ProcessSocketRequests(); + END_SERVI_STATS(EServiRun_Proc); + + //Re-schedule + START_SERVI_STATS(EServiRun_Reschedule); + if (!iSockServRequestList.iActiveRequests.empty()) + { + // Re-schedule after a delay for continued monitoring + // of active requests. + // Note: new requests will interrupt this polling interval + // and schedule ASAP. + ADD_STATS(EOsclSocketServ_SelectReschedulePoll); + RunIfNotReady(1000*PV_SOCKET_SERVER_AO_INTERVAL_MSEC); + } + END_SERVI_STATS(EServiRun_Reschedule); + +#else +//select loop implementation. + +//loop 2x so we can complete some requests in one call. +for (uint32 i = 0; i < 2; i++) +{ + //Process active requests. + START_SERVI_STATS(EServiRun_Proc); + ProcessSocketRequests(iNhandles, iNfds); + END_SERVI_STATS(EServiRun_Proc); + + //Make the select call if needed. + if (iNfds > 1) + { + START_SERVI_STATS(EServiRun_Select); + //use a delay of zero since we're essentially polling for socket activity. + //note the select call may update this value so it must be set prior to each call. + timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 0; + bool ok; + OsclSocketSelect(iNfds, iReadset, iWriteset, iExceptset, timeout, ok, iServError, iNhandles); + END_SERVI_STATS(EServiRun_Select); + if (!ok) + { + //a select error is fatal. + StopServImp();//stop the AO + iServState = OsclSocketServI::ESocketServ_Error; + return; + } + + if (iNhandles) + { + ADD_STATS(EOsclSocketServ_SelectActivity); + } + else + { + ADD_STATS(EOsclSocketServ_SelectNoActivity); + } + } +} + +//Re-schedule +START_SERVI_STATS(EServiRun_Reschedule); +if (!iSockServRequestList.iActiveRequests.empty()) +{ + if (iNhandles) + { + // Re-schedule ASAP when we have socket activity. + ADD_STATS(EOsclSocketServ_SelectRescheduleAsap); + RunIfNotReady(); + } + else + { + // Re-schedule after a delay for continued monitoring + // of active requests. + // Note: new requests will interrupt this polling interval + // and schedule ASAP. + ADD_STATS(EOsclSocketServ_SelectReschedulePoll); + RunIfNotReady(1000*PV_SOCKET_SERVER_AO_INTERVAL_MSEC); + } +} +END_SERVI_STATS(EServiRun_Reschedule); + +#endif //PV_SOCKET_SERVER_SELECT +} + +//re-schedule the AO when a new request comes in. +void OsclSocketServI::WakeupAO() +{ + if (IsAdded()) + { + // To avoid waiting for the polling period to expire, + // cancel and activate for immediate run + if (IsBusy()) + Cancel(); + + RunIfNotReady(); + } +} + + +#endif//PV_SOCKET_SERVER_IS_THREAD +#endif //PV_SOCKET_SERVER + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.h new file mode 100644 index 0000000..4b3ef01 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.h @@ -0,0 +1,159 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_SERV_IMP_PV_H_INCLUDED +#define OSCL_SOCKET_SERV_IMP_PV_H_INCLUDED + +#include "oscl_socket_serv_imp_base.h" +#include "oscl_socket_serv_imp_reqlist.h" +#include "oscl_socket_tuneables.h" + + +/** PV socket server implementation +*/ + +#if PV_SOCKET_SERVER_IS_THREAD +#include "oscl_semaphore.h" +#include "oscl_mutex.h" +#else +#include "oscl_scheduler_ao.h" +#endif + +class PVServiStats; + +/** PV socket server implementation +*/ +#if (PV_SOCKET_SERVER_IS_THREAD) +class OsclSocketServI: public HeapBase, public OsclSocketServIBase +#else +class OsclSocketServI: public OsclTimerObject, public OsclSocketServIBase +#endif +{ + public: + static OsclSocketServI* NewL(Oscl_DefAlloc &a); + int32 Connect(uint32 aMessageSlots, bool aShareSession); + void Close(bool); + + //check if calling context is server thread. + //in non-threaded implementation, will always return "true". + bool IsServerThread(); + + private: + OsclSocketServI(Oscl_DefAlloc &a); + ~OsclSocketServI(); + void ConstructL(); + + //socket request list. + OsclSocketServRequestList iSockServRequestList; + +#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET + //blocking select wakeup feature + class LoopbackSocket + { + public: + LoopbackSocket() + { + iEnable = false; + iContainer = NULL; + } + bool iEnable; + void Read(); + void ProcessSelect(TOsclSocket&); + void Init(OsclSocketServI* aContainer); + void Cleanup(); + void Write(); +#if PV_OSCL_SOCKET_STATS_LOGGING + OsclSocketStats iStats; +#endif + private: + TOsclSockAddr iAddr; + TOsclSocket iSocket; + OsclSocketServI* iContainer; + }; + LoopbackSocket iLoopbackSocket; +#endif + uint32 iSelectPollIntervalMsec; + + void WakeupBlockingSelect() + { +#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET + if (iLoopbackSocket.iEnable) + iLoopbackSocket.Write(); +#endif + } + + int32 StartServImp(); + void ConstructServImp(); + void CleanupServImp(); + void StopServImp(); + void ServerEntry(); + void ServerExit(); + +#if PV_SOCKET_SERVER_IS_THREAD + TOsclThreadId iThreadId; + //start & exit semaphores. + OsclSemaphore iStart, iExit; + //thread exit flag + bool iClose; + public: + //this needs to be public for use by the thread routine. + void InThread(); + private: +#else + //for AO implemenation. + void Run(); + void WakeupAO(); +#if PV_SOCKET_SERVER_SELECT + int iNhandles; + int iNfds; +#endif +#endif + +#if PV_SOCKET_SERVER_SELECT + //select flags. + fd_set iReadset, iWriteset, iExceptset; + void ProcessSocketRequests(int &, int &n); +#else + void ProcessSocketRequests(); +#endif + + friend class OsclSocketServRequestList; + friend class LoopbackSocket; + + friend class OsclTCPSocketI; + friend class OsclUDPSocketI; + friend class OsclSocketI; + friend class OsclDNSI; + friend class OsclSocketRequest; + friend class OsclSocketServ; + + PVServiStats* iServiStats; + +}; + +/** A bitmask for socket select operations +*/ +#define OSCL_READSET_FLAG 0x04 +#define OSCL_WRITESET_FLAG 0x02 +#define OSCL_EXCEPTSET_FLAG 0x01 + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.cpp new file mode 100644 index 0000000..40df22d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.cpp @@ -0,0 +1,196 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "osclconfig_io.h" +#include "oscl_socket_tuneables.h" + +#if(PV_SOCKET_SERVER) +#include "oscl_socket_serv_imp_reqlist.h" + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_method.h" +#include "oscl_socket_types.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_error.h" +#include "oscl_socket_imp.h" +#include "oscl_assert.h" + + + +// +//OsclSocketServRequestList +// + + +OsclSocketServRequestList::OsclSocketServRequestList() +{ + iContainer = NULL; +} + + +//Log app thread calls. +#define LOGAPP(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,obj->iSocketI->Logger(),PVLOGMSG_DEBUG,m); + +//Log server thread calls. +#define LOGSERV(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iContainer->iLogger,PVLOGMSG_DEBUG,m); + + +void OsclSocketServRequestList::Add(OsclSocketRequest *obj) +//add a socket request to the server (from the app thread) +{ + //Lock when adding requests to the input queue. + Lock(); + + bool empty = iAddRequests.empty(); + iAddRequests.push_back(obj); + + //signal the server thread anytime the queue goes from empty to non-empty. + if (empty) + Wakeup(); + + //may need to interrupt a blocking select call + iContainer->WakeupBlockingSelect(); + + Unlock(); +} + +void OsclSocketServRequestList::StartCancel(OsclSocketRequest *obj) +//Cancel a socket request to the server (from the app thread) +{ + //queue up a cancel request to the server. note: if the request is still + //in the new request queue, it might seem simpler to just complete the + //request here, but for thread safety all requests must be completed by + //the server thread. + Lock(); + iCancelRequests.push_back(obj); + Unlock(); + +#if(PV_SOCKET_SERVER_IS_THREAD) + //may need to interrupt a blocking select call + iContainer->WakeupBlockingSelect(); +#else + //for AO implementation, call the request processing routine + //so that the request will get canceled. +#if PV_SOCKET_SERVER_SELECT + iContainer->ProcessSocketRequests(iContainer->iNhandles, iContainer->iNfds); +#else + iContainer->ProcessSocketRequests(); +#endif +#endif +} + +void OsclSocketServRequestList::GetNewRequests() +//called by server to pick up new requests. +{ + Oscl_Vector::iterator it; + + //go through the new requests list and move them to the active requests list. + for (it = iAddRequests.begin(); it != iAddRequests.end(); it++) + { + OsclSocketServRequestQElem elem(*it); + iActiveRequests.push_back(elem); + } + iAddRequests.clear(); + + //now go through cancel requests and set cancel flags + //in the corresponding active requests. + for (it = iCancelRequests.begin(); it != iCancelRequests.end(); it++) + { + for (uint32 i = 0; i < iActiveRequests.size(); i++) + { + if (iActiveRequests[i].iSocketRequest == *it) + { + iActiveRequests[i].iCancel = true; + break; + } + } + } + iCancelRequests.clear(); +} + +void OsclSocketServRequestList::Wakeup() +//wakeup the server +{ +#if(PV_SOCKET_SERVER_IS_THREAD) + //signal the thread + iSem.Signal(); +#else + //wakeup the AO. + iContainer->WakeupAO(); +#endif +} + +void OsclSocketServRequestList::Open(OsclSocketServI* s) +{//implementation-specific open + iContainer = s; +#if(PV_SOCKET_SERVER_IS_THREAD) + iCrit.Create(); + iSem.Create(); +#endif +} + +void OsclSocketServRequestList::Close() +{//implementation-specific close + iActiveRequests.clear(); + iActiveRequests.destroy(); + iAddRequests.clear(); + iAddRequests.destroy(); + iCancelRequests.clear(); + iCancelRequests.destroy(); +#if(PV_SOCKET_SERVER_IS_THREAD) + iCrit.Close(); + iSem.Close(); +#endif +} + + +void OsclSocketServRequestList::WaitOnRequests() +//called by server thread to wait on requests. +{ +#if(PV_SOCKET_SERVER_IS_THREAD) + //see if there are new requests + iCrit.Lock(); + bool empty = iAddRequests.empty(); + iCrit.Unlock(); + //if no new requests. then wait. + if (empty) + iSem.Wait(); +#endif +} + +void OsclSocketServRequestList::Lock() +{ +#if(PV_SOCKET_SERVER_IS_THREAD) + iCrit.Lock(); +#endif +} + +void OsclSocketServRequestList::Unlock() +{ +#if(PV_SOCKET_SERVER_IS_THREAD) + iCrit.Unlock(); +#endif +} + +#endif//PV_SOCKET_SERVER + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.h new file mode 100644 index 0000000..7e6c56e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.h @@ -0,0 +1,96 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_SERV_IMP_REQLIST_H_INCLUDED +#define OSCL_SOCKET_SERV_IMP_REQLIST_H_INCLUDED + +#include "oscl_socket_tuneables.h" +#include "oscl_defalloc.h" +#include "oscl_vector.h" +#include "oscl_mem.h" + +#if PV_SOCKET_SERVER_IS_THREAD +#include "oscl_semaphore.h" +#include "oscl_mutex.h" +#endif + +class OsclSocketServI; +templateclass OsclSocketQueue; +class OsclSocketI; +class OsclSocketRequest; + +class OsclSocketServRequestQElem +{ + public: + OsclSocketServRequestQElem(OsclSocketRequest* r) + : iSocketRequest(r) + , iSelect(0) + , iCancel(false) + {} + + OsclSocketRequest* iSocketRequest; + uint8 iSelect; + bool iCancel; +}; + +/** PV socket server request queue +*/ +class OsclSocketServRequestList +{ + public: + OsclSocketServRequestList(); + void Add(OsclSocketRequest *); + void StartCancel(OsclSocketRequest *); + void Open(OsclSocketServI*s); + void Close(); + void Wakeup(); + void WaitOnRequests(); + void Remove(OsclSocketServRequestQElem* aElem) + { + aElem->iSocketRequest = NULL; + } + + private: + //a queue of the active sockets. + Oscl_Vector iActiveRequests; + +#if PV_SOCKET_SERVER_IS_THREAD + //thread protection + OsclMutex iCrit; + OsclSemaphore iSem; +#endif + + OsclSocketServI *iContainer; + + //input queues for requests from the app side. requests + //are picked up by server thread, so these queues need + //to be used with thread locks. + Oscl_Vector iAddRequests; + Oscl_Vector iCancelRequests; + void GetNewRequests(); + void Lock(); + void Unlock(); + + friend class OsclSocketServI; +}; + + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_shutdown.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_shutdown.cpp new file mode 100644 index 0000000..acce4aa --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_shutdown.cpp @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_scheduler_ao.h" +#include "oscl_socket_method.h" +#include "oscl_socket_serv_imp.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_shutdown.h" +#include "oscl_socket_imp.h" +#include "oscl_socket_shutdown.h" + +//////////// Method ///////////////////// + +OsclShutdownMethod *OsclShutdownMethod::NewL(OsclIPSocketI& c) +{ + OsclAny*p = c.Alloc().ALLOCATE(sizeof(OsclShutdownMethod)); + OsclError::LeaveIfNull(p); + OsclShutdownMethod* self = OSCL_PLACEMENT_NEW(p, OsclShutdownMethod(c)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + return self; +} + +void OsclShutdownMethod::ConstructL() +{ + OsclAny*p = Alloc().ALLOCATE(sizeof(OsclShutdownRequest)); + OsclError::LeaveIfNull(p); + OsclShutdownRequest* self = OSCL_PLACEMENT_NEW(p, OsclShutdownRequest(*this)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(); + OsclError::Pop(); + iSocketRequestAO = self; + OsclSocketMethod::ConstructL(iSocketRequestAO); +} + +OsclShutdownMethod::~OsclShutdownMethod() +{ + if (ShutdownRequest()) + { + ShutdownRequest()->~OsclShutdownRequest(); + Alloc().deallocate(ShutdownRequest()); + } +} + +TPVSocketEvent OsclShutdownMethod::Shutdown(TPVSocketShutdown aHow, + int32 aTimeout) +{ + if (!StartMethod(aTimeout)) + return EPVSocketFailure; + + ShutdownRequest()->Shutdown(aHow); + + return EPVSocketPending; +} + +//////////// AO ///////////////////// + +void OsclShutdownRequest::Shutdown(TPVSocketShutdown aHow) +{ + OsclAny *p = NewRequest(sizeof(ShutdownParam)); + if (!p) + PendComplete(OsclErrNoMemory); + else + { + iParam = OSCL_PLACEMENT_NEW(p, ShutdownParam(aHow)); + if (!iParam) + PendComplete(OsclErrNoMemory); + else + SocketI()->Shutdown(*Param(), *this); + } +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_shutdown.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_shutdown.h new file mode 100644 index 0000000..38f3f0e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_shutdown.h @@ -0,0 +1,74 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_SHUTDOWN_H_INCLUDED +#define OSCL_SOCKET_SHUTDOWN_H_INCLUDED + +#include "oscl_socket_types.h" +#include "oscl_socket_method.h" + +/** + Internal implementation of Shutdown + */ +class OsclShutdownRequest; + +class OsclShutdownMethod : public OsclSocketMethod +{ + public: + static OsclShutdownMethod *NewL(OsclIPSocketI& c); + + ~OsclShutdownMethod(); + + TPVSocketEvent Shutdown(TPVSocketShutdown aHow, + int32 aTimeout); + + private: + OsclShutdownMethod(OsclIPSocketI& c) + : OsclSocketMethod(c, "osclshutdownmethod", EPVSocketShutdown) + {} + + void ConstructL(); + + public: + OsclShutdownRequest *ShutdownRequest() + { + return (OsclShutdownRequest*)iSocketRequestAO; + } +}; + +/** + This is the AO that interacts with the socket server + */ +class OsclShutdownRequest : public OsclSocketRequestAO +{ + public: + OsclShutdownRequest(OsclSocketMethod& c) + : OsclSocketRequestAO(c, "osclShutdownRequest") + {} + + void Shutdown(TPVSocketShutdown aHow); + + private: + ShutdownParam*Param() + { + return (ShutdownParam*)iParam; + } +}; + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_stats.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_stats.cpp new file mode 100644 index 0000000..49fc704 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_stats.cpp @@ -0,0 +1,316 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/*! +** Socket statistics +*/ + +#include "oscl_socket_tuneables.h" +#if(PV_OSCL_SOCKET_STATS_LOGGING) +#include "oscl_socket_stats.h" +#include "oscl_tickcount.h" +#include "pvlogger.h" +#include "oscl_socket_tuneables.h" +#include "oscl_scheduler_ao.h" +#include "oscl_snprintf.h" + +#define LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_DEBUG,m); + +#define PV_SOCKET_STR_LEN 512 + +static const char* const TPVSocketFxnStrShort[] = +{ + "Send " + , "SendTo " + , "Recv " + , "RecvFrom" + , "Connect " + , "Accept " + , "Shutdown" + , "Bind" + , "Listen" +} ; + +OsclSocketStats::OsclSocketStats() +{ + iLogStr = (char*)OSCL_MALLOC(PV_SOCKET_STR_LEN); + iLogger = PVLogger::GetLoggerObject("OsclSocketStats"); + iSock = NULL; + iServ = NULL; + for (uint32 i = 0; i < OsclSocketStats_NUM_ACTIVE_REQUESTS; i++) + { + iLastCompletionTime[i] = (-1); + iExcessPollEvents[i] = 0; + } +} +OsclSocketStats::~OsclSocketStats() +{ + if (iLogStr) + OSCL_FREE(iLogStr); +} +void OsclSocketStats::Construct(OsclAny* aContainer, OsclAny*aServ) +{ + iSock = aContainer; + iServ = aServ; +} + +void OsclSocketStats::Add(TPVSocketFxn aFxn, TOsclSocketStatEvent aEvent, int32 aParam) +{ + iLock.Lock(); + if (aEvent == EOsclSocket_ServPoll) + { + if (iPollEvents[aFxn].size() >= OsclSocketStats_MAX_POLL_EVENTS) + {//to avoid having the poll events vector grow without bound + iExcessPollEvents[aFxn]++; + } + else + { + OsclSocketStatEventEntry event(aEvent, OsclTickCount::TickCount(), iEvents[aFxn].size()); + iPollEvents[aFxn].push_back(event); + } + } + else + { + OsclSocketStatEventEntry event(aEvent, OsclTickCount::TickCount(), aParam); + iEvents[aFxn].push_back(event); + } + iLock.Unlock(); +} +void OsclSocketStats::Clear(TPVSocketFxn aFxn) +{ + iLock.Lock(); + if (iEvents[aFxn].size()) + iLastCompletionTime[aFxn] = iEvents[aFxn][iEvents[aFxn].size() - 1].iTicks; + iEvents[aFxn].clear(); + iPollEvents[aFxn].clear(); + iExcessPollEvents[aFxn] = 0; + iLock.Unlock(); +} + +void OsclSocketStats::Log(TPVSocketFxn aFxn) +{ + //log events + { + int32 len = 0; + iLogStr[0] = '\0'; + for (uint32 i = 0; i < iEvents[aFxn].size(); i++) + { + if (PV_SOCKET_STR_LEN - len <= 0) + break; + if (iEvents[aFxn][i].iParam != (-1)) + { + //log event with a parameter + len += oscl_snprintf(iLogStr + len, PV_SOCKET_STR_LEN - len, "%s (n=%d) %d " + , TPVSocketStatStr[iEvents[aFxn][i].iEvent] + , iEvents[aFxn][i].iParam + , iEvents[aFxn][i].iTicks); + } + else + { + //log event with no parameter + len += oscl_snprintf(iLogStr + len, PV_SOCKET_STR_LEN - len, "%s %d " + , TPVSocketStatStr[iEvents[aFxn][i].iEvent] + , iEvents[aFxn][i].iTicks); + } + } + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x,Sock=0x%x): %s delta=%d, %s" + , iServ, iSock + , TPVSocketFxnStrShort[aFxn] + , (iLastCompletionTime[aFxn] == (-1)) ? (-1) : iEvents[aFxn][iEvents[aFxn].size() - 1].iTicks - iLastCompletionTime[aFxn] + , iLogStr)); + } + + //log polling events + { + int32 len = 0; + iLogStr[0] = '\0'; + int32 lastIndex = (-1); + for (uint32 i = 0; i < iPollEvents[aFxn].size(); i++) + { + if (PV_SOCKET_STR_LEN - len <= 0) + break; + if (iPollEvents[aFxn][i].iParam != lastIndex) + { + //log polling index plus times. + len += oscl_snprintf(iLogStr + len, PV_SOCKET_STR_LEN - len, "(%d) %d " + , iPollEvents[aFxn][i].iParam + , iPollEvents[aFxn][i].iTicks + ); + } + else + { + //log time only + len += oscl_snprintf(iLogStr + len, PV_SOCKET_STR_LEN - len, "%d " + , iPollEvents[aFxn][i].iTicks + ); + } + lastIndex = iPollEvents[aFxn][i].iParam; + } + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x,Sock=0x%x): %s Poll=%d, Times %s" + , iServ, iSock + , TPVSocketFxnStrShort[aFxn] + , iPollEvents[aFxn].size() + , iLogStr)); + if (iExcessPollEvents[aFxn] > 0) + { + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x,Sock=0x%x): %s Num ExcessPollEvents=%d" + , iServ, iSock + , TPVSocketFxnStrShort[aFxn] + , iExcessPollEvents[aFxn] + )); + } + } +} + +void OsclSocketStats::Log() +{ + //log events not related to a particular socket API + { + int32 len = 0; + iLogStr[0] = '\0'; + for (uint32 i = 0; i < iEvents[0].size(); i++) + { + if (PV_SOCKET_STR_LEN - len <= 0) + break; + if (iEvents[0][i].iParam != (-1)) + { + //log event with a parameter + len += oscl_snprintf(iLogStr + len, PV_SOCKET_STR_LEN - len, "%s (n=%d) %d " + , TPVSocketStatStr[iEvents[0][i].iEvent] + , iEvents[0][i].iParam + , iEvents[0][i].iTicks); + } + else + { + //log event with no parameter + len += oscl_snprintf(iLogStr + len, PV_SOCKET_STR_LEN - len, "%s %d " + , TPVSocketStatStr[iEvents[0][i].iEvent] + , iEvents[0][i].iTicks); + } + } + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x,Sock=0x%x): %s" + , iServ, iSock + , iLogStr)); + } +} + +void OsclSocketStats::LogAndDump() +{ + for (uint32 i = 0; i < OsclSocketStats_NUM_ACTIVE_REQUESTS; i++) + { + if (iEvents[i].size() + || iPollEvents[i].size()) + { + Log((TPVSocketFxn)i); + } + Clear((TPVSocketFxn)i); + } +} + + +OsclSocketServStats::OsclSocketServStats() +{ + iLogger = PVLogger::GetLoggerObject("OsclSocketStats"); + iServ = NULL; + Clear(); +} +OsclSocketServStats::~OsclSocketServStats() +{ +} +void OsclSocketServStats::Construct(OsclAny*aServ) +{ + iServ = aServ; +} + +void OsclSocketServStats::ShowTuneables() +{ + //Log socket server type +#if (PV_SOCKET_SERVER) + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): Socket Server: PV Socket Server", iServ)); +#else + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): Socket Server: Unknown Socket Server", iServ)); +#endif + //Log socket request AO priority + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): Socket Request AO Priority %d" + , iServ + , PV_SOCKET_REQUEST_AO_PRIORITY)); + +#if(PV_SOCKET_SERVER) + //Log pv socket server type + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): Socket Server is %s" + , iServ + , (PV_SOCKET_SERVER_IS_THREAD) ? "Threaded" : "AO-Based" + )); +#if(PV_SOCKET_SERVER_IS_THREAD) + //pv server threaded params + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): Socket Server Thread Priority %d", iServ, PV_SOCKET_SERVER_THREAD_PRIORITY)); + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): Socket Server Select Timeout (msec) %d", iServ, PV_SOCKET_SERVER_SELECT_TIMEOUT_MSEC)); +#else + //pv server AO-based params + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): Socket Server AO Priority %d", iServ, PV_SOCKET_SERVER_AO_PRIORITY)); + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): Socket Server AO Polling Interval (msec) %d", iServ, PV_SOCKET_SERVER_AO_INTERVAL_MSEC)); +#endif + + //pv Server logging + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): Socket Server Logging %s" + , iServ + , (PV_OSCL_SOCKET_SERVER_LOGGER_OUTPUT) ? "Enabled" : "Disabled")); + +#endif//PV_SOCKET_SERVER +} + +void OsclSocketServStats::Add(TOsclSocketServStatEvent aEvent) +{ + iEvents[aEvent]++; +} + +void OsclSocketServStats::Log(TOsclSocketServStatEvent aEvent) +{ + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): Event %s Count %d" + , iServ + , TPVSocketServStatStr[aEvent] + , iEvents[aEvent])); +} + +void OsclSocketServStats::Clear() +{ + for (uint32 i = 0; i < EOsclSocketServ_LastEvent; i++) + iEvents[i] = 0; +} + +void OsclSocketServStats::LogAndDump() +{ + if (!iServ) + return; + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): ---Begin Stats--------", iServ)); + ShowTuneables(); + for (uint32 i = 0; i < EOsclSocketServ_LastEvent; i++) + Log((TOsclSocketServStatEvent)i); + LOGINFOMED((0, "OsclSocketStats(Serv=0x%x): ---End Stats----------", iServ)); + Clear(); + //this acts as thread logoff + iServ = NULL; +} + +#endif + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_stats.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_stats.h new file mode 100644 index 0000000..8c91231 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_stats.h @@ -0,0 +1,163 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#ifndef OSCL_SOCKET_STATS_H_INCLUDED +#define OSCL_SOCKET_STATS_H_INCLUDED + +/*! +** Socket diagnostics. +*/ +#include "oscl_base.h" +#include "oscl_vector.h" +#include "oscl_mem.h" +#include "oscl_mutex.h" + +enum TOsclSocketStatEvent +{ + //Request/Method AO events + EOsclSocket_RequestAO_Success + , EOsclSocket_RequestAO_Canceled + , EOsclSocket_RequestAO_Error + , EOsclSocket_RequestAO_Timeout + //Server events + , EOsclSocket_ServRequestIssued + , EOsclSocket_ServPoll + , EOsclSocket_OS + , EOsclSocket_Readable + , EOsclSocket_Writable + , EOsclSocket_Except + , EOsclSocket_DataRecv + , EOsclSocket_DataSent + , EOsclSocket_ServRequestComplete + , EOsclSocket_ServRequestCancelIssued + //loop socket events + , EOsclSocketServ_LoopsockOk + , EOsclSocketServ_LoopsockError +}; +static const char* const TPVSocketStatStr[] = +{ + //Request/Method AO events + "AO_Success" + , "AO_Canceled" + , "AO_Error" + , "AO_Timeout" + //Server events + , "Serv_ReqIssued" + , "Serv_Poll" + , "Serv_OS_Op" + , "Serv_Readable" + , "Serv_Writeable" + , "Serv_Except!" + , "Serv_DataRecv'd" + , "Serv_DataSent" + , "Serv_ReqComplete" + , "Serv_ReqCancel" + //loop socket events + , "Loopsock_OK" + , "Loopsock_Err" +} ; + +enum TOsclSocketServStatEvent +{ + //select loop events + EOsclSocketServ_SelectNoActivity = 0 + , EOsclSocketServ_SelectActivity + , EOsclSocketServ_SelectRescheduleAsap + , EOsclSocketServ_SelectReschedulePoll + , EOsclSocketServ_LastEvent +}; +static const char* const TPVSocketServStatStr[] = +{ + "Select_No" + , "Select_Yes" + , "Select_Resched_Asap" + , "Select_Resched_Poll" +} ; + +#include "oscl_socket_tuneables.h" +#if(PV_OSCL_SOCKET_STATS_LOGGING) + +class PVLogger; +class OsclSocketStatEventEntry +{ + public: + OsclSocketStatEventEntry(TOsclSocketStatEvent aEvent, uint32 aTime, int32 aParam) + : iEvent(aEvent) + , iTicks(aTime) + , iParam(aParam) + {} + TOsclSocketStatEvent iEvent; + uint32 iTicks; + int32 iParam; +}; + +#include "oscl_socket_types.h" + +#define OsclSocketStats_NUM_ACTIVE_REQUESTS EPVSocket_Last + +//Define the maximum number of polling events that will be logged. +//Additional poll events will be counted but not logged individually. +#define OsclSocketStats_MAX_POLL_EVENTS 100 + +class OsclSocketStats +{ + public: + OsclSocketStats(); + ~OsclSocketStats(); + void ShowTuneables(); + void Add(TPVSocketFxn, TOsclSocketStatEvent, int32 aParam = (-1)); + void Log(TPVSocketFxn); + void Log(); + void Clear(TPVSocketFxn); + void Construct(OsclAny* aContainer, OsclAny*aServ); + void LogAndDump(); + private: + Oscl_Vector iEvents[OsclSocketStats_NUM_ACTIVE_REQUESTS]; + Oscl_Vector iPollEvents[OsclSocketStats_NUM_ACTIVE_REQUESTS]; + int32 iExcessPollEvents[OsclSocketStats_NUM_ACTIVE_REQUESTS]; + int32 iLastCompletionTime[OsclSocketStats_NUM_ACTIVE_REQUESTS]; + OsclThreadLock iLock; + char* iLogStr; + PVLogger* iLogger; + OsclAny* iSock; + OsclAny* iServ; +}; + +class OsclSocketServStats +{ + public: + OsclSocketServStats(); + ~OsclSocketServStats(); + void Add(TOsclSocketServStatEvent); + void Construct(OsclAny*aServ); + void LogAndDump(); + private: + void Log(TOsclSocketServStatEvent); + void Clear(); + void ShowTuneables(); + uint32 iEvents[EOsclSocketServ_LastEvent]; + PVLogger* iLogger; + OsclAny* iServ; +}; + +#endif +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_tuneables.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_tuneables.h new file mode 100644 index 0000000..de39543 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_tuneables.h @@ -0,0 +1,184 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_SOCKET_TUNEABLES_H_INCLUDED +#define OSCL_SOCKET_TUNEABLES_H_INCLUDED + +/*! +** This file contains default definitions of all the +** the tuning parameters for the Oscl sockets. +*/ + +/*! +** If parameters are defined in osclconfig_io.h, those definitions +** will take precedence over the ones in this file. +*/ +#include "osclconfig_io.h" +#include "osclconfig_proc.h" + +/*! +** PV_SOCKET_REQUEST_AO_PRIORITY sets the priority of the socket request +** completion AOs. +*/ +#ifndef PV_SOCKET_REQUEST_AO_PRIORITY +#define PV_SOCKET_REQUEST_AO_PRIORITY OsclActiveObject::EPriorityNominal +#endif + +/*! +** Set this to 0 or 1 to enable/disable socket stats logging +** with "OsclSocketStats" node. This feature is fairly costly so should be off in +** production code. +*/ +#ifndef PV_OSCL_SOCKET_STATS_LOGGING +#define PV_OSCL_SOCKET_STATS_LOGGING 0 +#endif + +/*! +** Enable/disable the PV socket server here. +*/ +#ifndef PV_SOCKET_SERVER +#define PV_SOCKET_SERVER 1 +#endif + +#if(PV_SOCKET_SERVER) +/*! +** PV_SOCKET_SERVER_IS_THREAD chooses either the threaded or AO-based +** implementation of the PV socket server +*/ +#ifndef PV_SOCKET_SERVER_IS_THREAD +//choose threaded implementation whenever the OS has threading support. +#define PV_SOCKET_SERVER_IS_THREAD OSCL_HAS_THREAD_SUPPORT +#endif + +/*! +** PV_SOCKET_SERVER_SELECT chooses whether to use "select" call or not. +** In threaded mode, select call is required and is forced to "1". +** In AO mode, "select" call is an option that defaults to "0". +** Avoiding any "select" call was found to greatly reduce CPU usage +** on WinMobile devices. +*/ +#if PV_SOCKET_SERVER_IS_THREAD +#undef PV_SOCKET_SERVER_SELECT +#define PV_SOCKET_SERVER_SELECT 1 +#else +#ifndef PV_SOCKET_SERVER_SELECT +#define PV_SOCKET_SERVER_SELECT 0 +#endif +#endif + +/*! +** PV_SOCKET_SERVER_THREAD_PRIORITY sets the priority of the PV socket +** server thread. +*/ +#ifndef PV_SOCKET_SERVER_THREAD_PRIORITY +#define PV_SOCKET_SERVER_THREAD_PRIORITY ThreadPriorityAboveNormal +#endif + +/*! +** PV_SOCKET_SERVER_SELECT_TIMEOUT_MSEC sets duration of the select call +** in the PV socket server thread for the polling select loop implementation. +** When the timeout is -1, the select call will block forever waiting on a new request +** and will use a loopback socket to signal a new request. +** Note: if infinite wait is selected, but loopback socket is not available, +** the implementation will poll at 10 msec intervals. +*/ +#ifndef PV_SOCKET_SERVER_SELECT_TIMEOUT_MSEC +#define PV_SOCKET_SERVER_SELECT_TIMEOUT_MSEC (-1) +#endif + +/*! +** PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET enables the feature to wakeup the select +** call by writing to a loopback socket each time a new request comes in. +** This option is required to support the blocking select loop option of threaded +** server mode. This option is forced to "0" in AO mode. +*/ +#if PV_SOCKET_SERVER_IS_THREAD + +#ifndef PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET +#define PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET 1 +#endif + + +#else +#undef PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET +#define PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET 0 +#endif + +/*! +** PV_SOCKET_SERVER_AO_PRIORITY sets priority of the PV socket server +** AO for non-threaded implementations. +*/ +#ifndef PV_SOCKET_SERVER_AO_PRIORITY +#define PV_SOCKET_SERVER_AO_PRIORITY (OsclActiveObject::EPriorityNominal) +#endif + +/*! +** PV_SOCKET_SERVER_AO_INTERVAL_MSEC sets the AO scheduling interval +** of the PV socket server AO for non-threaded implementations. +*/ +#ifndef PV_SOCKET_SERVER_AO_INTERVAL_MSEC +#define PV_SOCKET_SERVER_AO_INTERVAL_MSEC 5 +#endif + +/*! +** Set this to 0 or 1 to enable/disable PVLogger output from +** PV socket server. +** Note that socket server logging will appear in a different +** file when running threaded mode of socket server. +** This is quite a bit of logging, so it should generally be +** disabled. +*/ +#ifndef PV_OSCL_SOCKET_SERVER_LOGGER_OUTPUT +#define PV_OSCL_SOCKET_SERVER_LOGGER_OUTPUT 0 +#endif + +/*! +** Set this to 0 or 1 to enable/disable setting the socket receive +** buffer size to 1 MB in the Bind call. This setting only affects +** PV socket server implementations. +* +** When set to 1, the code will use the OsclSetRecvBufferSize macro +** to set the buffer size in the Bind call. +* +** This setting was found to improve streaming performance on +** WinMobile devices, but should not generally be used. +*/ +#ifndef PV_OSCL_SOCKET_1MB_RECV_BUF +#define PV_OSCL_SOCKET_1MB_RECV_BUF 0 +#endif + +/*! +** For detailed performance breakdown of time spend in OsclSocketServI AO. +** Output is logged under "OsclSchedulerPerfStats" node. Should be off in +** production code. This option is forced to "0" in threaded mode. +*/ +#if PV_SOCKET_SERVER_IS_THREAD +#undef PV_SOCKET_SERVI_STATS +#define PV_SOCKET_SERVI_STATS 0 +#else +#ifndef PV_SOCKET_SERVI_STATS +#define PV_SOCKET_SERVI_STATS 0 +#endif +#endif + +#endif//PV_SOCKET_SERVER + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_types.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_types.h new file mode 100644 index 0000000..bc65fa0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_socket_types.h @@ -0,0 +1,210 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#ifndef OSCL_SOCKET_TYPES_H_INCLUDED +#define OSCL_SOCKET_TYPES_H_INCLUDED + +#include "osclconfig_io.h" +#include "oscl_types.h" +#include "oscl_scheduler_types.h" +#include "oscl_namestring.h" +#include "oscl_stdstring.h" + +enum TPVSocketFxn +{ + EPVSocketSend = 0 + , EPVSocketSendTo + , EPVSocketRecv + , EPVSocketRecvFrom + , EPVSocketConnect + , EPVSocketAccept + , EPVSocketShutdown + , EPVSocketBind + , EPVSocketListen + , EPVSocket_Last //placeholder +} ; + +/** Return codes for asynchronous APIs +*/ +enum TPVSocketEvent +{ + EPVSocketSuccess + , EPVSocketPending + , EPVSocketTimeout + , EPVSocketFailure + , EPVSocketCancel + , EPVSocketNotImplemented //for unavailable features. +} ; + +enum TPVSocketShutdown +{ + EPVSocketSendShutdown + , EPVSocketRecvShutdown + , EPVSocketBothShutdown +} ; + +class OsclSocketTOS +{ + public: + enum TPVServicePrecedence + { + EPVRoutine = 0, + EPVPriority = 1, + EPVImmediate = 2, + EPVFlash = 3, + EPVOverrideFlash = 4, + EPVCritic_Ecp = 5, + EPVInetControl = 6, + EPVNetControl = 7 + }; + + enum TPVServicePriority + { + EPVNoTOS = 0x0, + EPVLDelay = (1 << 4), + EPVHiThrpt = (1 << 3), + EPVHiRel = (1 << 2) + }; + + OsclSocketTOS(): iTOSUnusedBits(2), iTOSPriorityBits(3) + { + ClearTOS(); + } + + void SetPrecedence(TPVServicePrecedence aPrecedence) + { + iPrecedence = aPrecedence; + } + + void SetPriority(bool aMinimizeDelay, bool aMaximizeThroughput, bool MaximizeReliability) + { + iPriority = (aMinimizeDelay ? EPVLDelay : EPVNoTOS) | (aMaximizeThroughput ? EPVHiThrpt : EPVNoTOS) | (MaximizeReliability ? EPVHiRel : EPVNoTOS); + } + + void ClearTOS() + { + iPrecedence = OsclSocketTOS::EPVRoutine; + iPriority = OsclSocketTOS::EPVNoTOS; + } + + uint8 GetTOS() const + { + /**Format of Ip Header's TOS field as specified in RFC 791 + * 0 1 2 3 4 5 6 7 + *+-----+-----+-----+-----+-----+-----+-----+-----+ + *| PRECEDENCE | D | T | R | 0 | 0 | + *+-----+-----+-----+-----+-----+-----+-----+-----+ + */ + return ((iPrecedence << (iTOSPriorityBits + iTOSUnusedBits) & 0xFF) || ((iPriority << iTOSUnusedBits) & 0xFF)); + } + + private: + uint8 iPrecedence; + uint8 iPriority; + const uint8 iTOSUnusedBits; + const uint8 iTOSPriorityBits; +}; + +enum TPVSocketOptionName +{ + //IP Level + EPVIPMulticastTTL + , EPVIPAddMembership + , EPVIPTOS + //Socket level + , EPVSockReuseAddr //On Symbian this option is at IP level... +} ; + +enum TPVSocketOptionLevel +{ + EPVIPProtoIP + , EPVIPProtoTCP + , EPVSocket +} ; +#define PVNETWORKADDRESS_LEN 50 + +class OsclNetworkAddress +{ + public: + OsclNetworkAddress(): port(0) + { + } + OsclNetworkAddress(const char *addr, int p) + { + ipAddr.Set(addr); + port = p; + } + + //Network address in dotted decimal string format. + OsclNameString ipAddr; + + //Port number. + int port; + //@cmember equality comparison operator + bool operator == (const OsclNetworkAddress & rhs) const + { + if (port == rhs.port) + { + if (0 == oscl_strcmp((const char*)ipAddr.Str(), (const char*)rhs.ipAddr.Str())) + return true; + } + return false; + }; + +} ; + +class OsclIpMReq +{ + public: + OsclIpMReq( + const char *intrfcAddr + , const char* multcstAddr) + { + interfaceAddr.Set(intrfcAddr); + multicastAddr.Set(multcstAddr); + } + OsclNameString interfaceAddr; + OsclNameString multicastAddr; +}; + +/** +* Socket event observer. The client implements this to get +* asynchronous command completion. +*/ +class OsclSocketObserver +{ + public: + /** + * Socket Event callback. + * + * @param aId: The ID that was supplied when + * the socket was created. + * @param aFxn: Type of socket function call. + * @param aEvent: Function completion event. Will be + * EPVSocketSuccess, EPVSocketTimeout, or EPVSocketFailure. + * @param aError: When the event is EPVSocketFailure, this + * may contain a platform-specific error code, or zero if + * none is available. + */ + OSCL_IMPORT_REF virtual void HandleSocketEvent(int32 aId, TPVSocketFxn aFxn, TPVSocketEvent aEvent, int32 aError) = 0; + virtual ~OsclSocketObserver() {} +}; + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_tcp_socket.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_tcp_socket.cpp new file mode 100644 index 0000000..70b868e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_tcp_socket.cpp @@ -0,0 +1,266 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_tcp_socket.h" +#include "oscl_error.h" +#include "oscl_scheduler_ao.h" +#include "oscl_socket_connect.h" +#include "oscl_socket_shutdown.h" +#include "oscl_socket_send.h" +#include "oscl_socket_recv.h" +#include "oscl_socket_accept.h" +#include "oscl_socket_bind.h" + +//Public methods +////////////////////////////////////////////////////////////////////////////////// +OsclTCPSocketI *OsclTCPSocketI::NewL(Oscl_DefAlloc &a, OsclSocketServI *aServ, + OsclSocketObserver *aObserver, + uint32 aId) +{ + OsclAny *p = a.ALLOCATE(sizeof(OsclTCPSocketI)); + OsclError::LeaveIfNull(p); + OsclTCPSocketI* self = OSCL_PLACEMENT_NEW(p, OsclTCPSocketI(a)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(aServ, aObserver, aId); + OsclError::Pop(); + return self; +} + +////////////////////////////////////////////////////////////////////////////////// +OsclTCPSocketI *OsclTCPSocketI::NewL(Oscl_DefAlloc &a, OsclSocketServI *aServ, + OsclSocketI *aSocket, + OsclSocketObserver *aObserver, + uint32 aId) +{ + OsclAny *p = a.ALLOCATE(sizeof(OsclTCPSocketI)); + OsclError::LeaveIfNull(p); + OsclTCPSocketI* self = OSCL_PLACEMENT_NEW(p, OsclTCPSocketI(a)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(aServ, aSocket, aObserver, aId); + OsclError::Pop(); + return self; +} + + +////////////////////////////////////////////////////////////////////////////////// +OsclTCPSocketI::~OsclTCPSocketI() +{ + //Cancel any outstanding requests. + + iConnectMethod->AbortAll(); + OSCL_ASSERT(!iConnectMethod->IsBusy()); + OSCL_ASSERT(!iConnectMethod->ConnectRequest()->IsBusy()); + + iShutdownMethod->AbortAll(); + OSCL_ASSERT(!iShutdownMethod->IsBusy()); + OSCL_ASSERT(!iShutdownMethod->ShutdownRequest()->IsBusy()); + + iAcceptMethod->AbortAll(); + OSCL_ASSERT(!iAcceptMethod->IsBusy()); + OSCL_ASSERT(!iAcceptMethod->AcceptRequest()->IsBusy()); + + iSendMethod->AbortAll(); + OSCL_ASSERT(!iSendMethod->IsBusy()); + OSCL_ASSERT(!iSendMethod->SendRequest()->IsBusy()); + + iRecvMethod->AbortAll(); + OSCL_ASSERT(!iRecvMethod->IsBusy()); + OSCL_ASSERT(!iRecvMethod->RecvRequest()->IsBusy()); + + iListenMethod->AbortAll(); + OSCL_ASSERT(!iListenMethod->IsBusy()); + OSCL_ASSERT(!iListenMethod->ListenRequest()->IsBusy()); + + iBindMethod->AbortAll(); + OSCL_ASSERT(!iBindMethod->IsBusy()); + OSCL_ASSERT(!iBindMethod->BindRequest()->IsBusy()); + + //Delete method objects. + + iConnectMethod->~OsclConnectMethod(); + iAlloc.deallocate(iConnectMethod); + + iShutdownMethod->~OsclShutdownMethod(); + iAlloc.deallocate(iShutdownMethod); + + iAcceptMethod->~OsclAcceptMethod(); + iAlloc.deallocate(iAcceptMethod); + + iSendMethod->~OsclSendMethod(); + iAlloc.deallocate(iSendMethod); + + iRecvMethod->~OsclRecvMethod(); + iAlloc.deallocate(iRecvMethod); + + iListenMethod->~OsclListenMethod(); + iAlloc.deallocate(iListenMethod); + + iBindMethod->~OsclBindMethod(); + iAlloc.deallocate(iBindMethod); + + iSocket->~OsclSocketI(); + iAlloc.deallocate(iSocket); +} + +TPVSocketEvent OsclTCPSocketI::ThreadLogoff() +{ + TPVSocketEvent result; + + result = iConnectMethod->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + result = iShutdownMethod->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + result = iAcceptMethod->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + result = iSendMethod->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + result = iRecvMethod->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + result = iListenMethod->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + result = iBindMethod->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + + result = iSocket->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + + //do this last since it makes the socket unusable, + //there wait until all other logoffs have succeeded. + OsclIPSocketI::ThreadLogoff(); + + return result; +} + +TPVSocketEvent OsclTCPSocketI::ThreadLogon(OsclSocketServI *aServ, OsclSocketObserver *aObserver) +{ + TPVSocketEvent result; + + result = iConnectMethod->ThreadLogon(); + if (result != EPVSocketSuccess) + return result; + result = iShutdownMethod->ThreadLogon(); + if (result != EPVSocketSuccess) + return result; + result = iAcceptMethod->ThreadLogon(); + if (result != EPVSocketSuccess) + return result; + result = iSendMethod->ThreadLogon(); + if (result != EPVSocketSuccess) + return result; + result = iRecvMethod->ThreadLogon(); + if (result != EPVSocketSuccess) + return result; + result = iListenMethod->ThreadLogon(); + if (result != EPVSocketSuccess) + return result; + result = iBindMethod->ThreadLogon(); + if (result != EPVSocketSuccess) + return result; + + result = iSocket->ThreadLogon(aServ); + if (result != EPVSocketSuccess) + return result; + + //do this last since it makes the socket + //usable again-- wait until all other + //logons have succeeded. + OsclIPSocketI::ThreadLogon(aObserver, aServ); + + return result; +} + +////////////////////////////////////////////////////////////////////////////////// +int32 OsclTCPSocketI::Close() +{ + if (iSocket) + { + //Cancel any outstanding requests. + iConnectMethod->AbortAll(); + iShutdownMethod->AbortAll(); + iAcceptMethod->AbortAll(); + iSendMethod->AbortAll(); + iRecvMethod->AbortAll(); + iListenMethod->AbortAll(); + iBindMethod->AbortAll(); + return iSocket->Close(); + } + else + return OsclErrGeneral; +} + + +////////////////////////////////////////////////////////////////////////////////// +OsclTCPSocketI *OsclTCPSocketI::GetAcceptedSocketL(uint32 aId) +{ + OsclSocketI *sock = iAcceptMethod->GetAcceptedSocket(); + if (!sock) + OsclError::Leave(OsclErrGeneral); + return OsclTCPSocketI::NewL(iAlloc, iSocketServ, sock, iObserver, aId); +} + + +//Private methods +////////////////////////////////////////////////////////////////////////////////// +void OsclTCPSocketI::ConstructL(OsclSocketServI *aServ, + OsclSocketObserver *aObserver, + uint32 aId) +{ + iSocket = OsclSocketI::NewL(iAlloc); + OsclIPSocketI::ConstructL(aObserver, iSocket, aServ, aId); + + //Open socket session + if (iSocket->Open(*iSocketServ, OSCL_AF_INET, OSCL_SOCK_STREAM, OSCL_IPPROTO_TCP) != OsclErrNone) + OsclError::Leave(OsclErrGeneral); + + //Allocate asynchronous method objects. + iConnectMethod = OsclConnectMethod::NewL(*this); + iShutdownMethod = OsclShutdownMethod::NewL(*this); + iAcceptMethod = OsclAcceptMethod::NewL(*this); + iSendMethod = OsclSendMethod::NewL(*this); + iRecvMethod = OsclRecvMethod::NewL(*this); + iListenMethod = OsclListenMethod::NewL(*this); + iBindMethod = OsclBindMethod::NewL(*this); +} + +////////////////////////////////////////////////////////////////////////////////// +void OsclTCPSocketI::ConstructL(OsclSocketServI *aServ, + OsclSocketI *aSocket, + OsclSocketObserver *aObserver, + uint32 aId) +{ + OsclIPSocketI::ConstructL(aObserver, aSocket, aServ, aId); + + //Allocate asynchronous method objects. + iConnectMethod = OsclConnectMethod::NewL(*this); + iShutdownMethod = OsclShutdownMethod::NewL(*this); + iAcceptMethod = OsclAcceptMethod::NewL(*this); + iSendMethod = OsclSendMethod::NewL(*this); + iRecvMethod = OsclRecvMethod::NewL(*this); + iListenMethod = OsclListenMethod::NewL(*this); + iBindMethod = OsclBindMethod::NewL(*this); +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_tcp_socket.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_tcp_socket.h new file mode 100644 index 0000000..0852311 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_tcp_socket.h @@ -0,0 +1,266 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_TCP_SOCKET_H_INCLUDED +#define OSCL_TCP_SOCKET_H_INCLUDED + +#ifndef OSCL_IP_SOCKET_H_INCLUDED +#include "oscl_ip_socket.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +class OsclBindMethod; +class OsclListenMethod; +class OsclConnectMethod; +class OsclShutdownMethod; +class OsclAcceptMethod; +class OsclSendMethod; +class OsclRecvMethod; + +/**Internal implementation class for OsclTCPSocket +*/ +class OsclTCPSocketI : public OsclIPSocketI +{ + public: + //Synchronous methods + static OsclTCPSocketI *NewL(Oscl_DefAlloc &a, + OsclSocketServI *aServ, + OsclSocketObserver *aObserver, + uint32 aId); + + virtual ~OsclTCPSocketI(); + + TPVSocketEvent ThreadLogoff(); + TPVSocketEvent ThreadLogon( + OsclSocketServI *aServ, + OsclSocketObserver *aObserver + ); + int32 Close(); + inline int32 Listen(int aQueueSize); + //the returned value is platform-specific + + OsclTCPSocketI *GetAcceptedSocketL(uint32 aId); + + inline uint8 *GetRecvData(int32 *aLength) ; + inline uint8 *GetSendData(int32 *aLength); + + //Asynchronous methods + inline TPVSocketEvent BindAsync(OsclNetworkAddress& aAddress, + int32 aTimeoutMsec = -1); + inline void CancelBind(); + + inline TPVSocketEvent ListenAsync(uint32 qsize, + int32 aTimeoutMsec = -1); + inline void CancelListen(); + + inline TPVSocketEvent Connect(OsclNetworkAddress& aAddress, + int32 aTimeoutMsec = -1); + inline void CancelConnect(); + + inline TPVSocketEvent Shutdown(TPVSocketShutdown aHow, + int32 aTimeoutMsec = -1); + inline void CancelShutdown(); + + inline TPVSocketEvent Accept(int32 aTimeout = -1); + inline void CancelAccept(); + + inline TPVSocketEvent Send(const uint8* &aPtr, uint32 aLen, + int32 aTimeoutMsec = -1); + inline void CancelSend(); + + inline TPVSocketEvent Recv(uint8* &aPtr, uint32 aMaxLen, + int32 aTimeoutMsec = -1); + inline void CancelRecv(); + + private: + static OsclTCPSocketI *NewL(Oscl_DefAlloc &a, + OsclSocketServI *aServ, + OsclSocketI *aSocket, + OsclSocketObserver *aObserver, + uint32 aId); + + OsclTCPSocketI(Oscl_DefAlloc &a) : OsclIPSocketI(a), + iConnectMethod(NULL), + iShutdownMethod(NULL), + iAcceptMethod(NULL), + iSendMethod(NULL), + iRecvMethod(NULL) + {} + + void ConstructL(OsclSocketServI *aServ, + OsclSocketObserver *aObserver, + uint32 aId); + + void ConstructL(OsclSocketServI *aServ, + OsclSocketI *aSocket, + OsclSocketObserver *aObserver, + uint32 aId); + + OsclBindMethod *iBindMethod; + OsclListenMethod *iListenMethod; + OsclConnectMethod *iConnectMethod; + OsclShutdownMethod *iShutdownMethod; + OsclAcceptMethod *iAcceptMethod; + OsclSendMethod *iSendMethod; + OsclRecvMethod *iRecvMethod; +}; + +#include "oscl_socket_listen.h" +#include "oscl_socket_recv.h" +#include "oscl_socket_send.h" +#include "oscl_socket_accept.h" +#include "oscl_socket_shutdown.h" +#include "oscl_socket_connect.h" +#include "oscl_socket_bind.h" + +////////////////////////////////////////////////////////////////////////////////// +inline int32 OsclTCPSocketI::Listen(int aQueueSize) +{ + return iSocket->Listen(aQueueSize) ; +} + +////////////////////////////////////////////////////////////////////////////////// +inline uint8 *OsclTCPSocketI::GetRecvData(int32 *aLength) +{ + return iRecvMethod->GetRecvData(aLength); +} + +////////////////////////////////////////////////////////////////////////////////// +inline uint8 *OsclTCPSocketI::GetSendData(int32 *aLength) +{ + return iSendMethod->GetSendData(aLength); +} + +////////////////////////////////////////////////////////////////////////////////// +inline TPVSocketEvent OsclTCPSocketI::BindAsync(OsclNetworkAddress& aAddress, + int32 aTimeout) +{ + if (!OsclSocketIBase::HasAsyncBind()) + return EPVSocketNotImplemented; + if (!iObserver) + return EPVSocketFailure;//not available. + + iAddress.ipAddr.Set(aAddress.ipAddr.Str()); + iAddress.port = aAddress.port; + return (iBindMethod->Bind(aAddress, aTimeout)); +} + +inline void OsclTCPSocketI::CancelBind() +{ + iBindMethod->CancelMethod(); +} + +////////////////////////////////////////////////////////////////////////////////// +inline TPVSocketEvent OsclTCPSocketI::ListenAsync(uint32 qsize, + int32 aTimeout) +{ + if (!OsclSocketIBase::HasAsyncListen()) + return EPVSocketNotImplemented; + if (!iObserver) + return EPVSocketFailure;//not available + + return (iListenMethod->Listen(qsize, aTimeout)); +} + +inline void OsclTCPSocketI::CancelListen() +{ + iListenMethod->CancelMethod(); +} + +////////////////////////////////////////////////////////////////////////////////// +inline TPVSocketEvent OsclTCPSocketI::Connect(OsclNetworkAddress& aAddress, + int32 aTimeout) +{ + if (!iObserver) + return EPVSocketFailure;//socket is logged off. + return (iConnectMethod->Connect(aAddress, aTimeout)); +} + +inline void OsclTCPSocketI::CancelConnect() +{ + iConnectMethod->CancelMethod(); +} + +////////////////////////////////////////////////////////////////////////////////// +inline TPVSocketEvent OsclTCPSocketI::Shutdown(TPVSocketShutdown aHow, + int32 aTimeout) +{ + if (!iObserver) + return EPVSocketFailure;//socket is logged off. + return (iShutdownMethod->Shutdown(aHow, aTimeout)); +} + +inline void OsclTCPSocketI::CancelShutdown() +{ + iShutdownMethod->CancelMethod(); +} + +////////////////////////////////////////////////////////////////////////////////// +inline TPVSocketEvent OsclTCPSocketI::Accept(int32 aTimeout) +{ + if (!iObserver) + return EPVSocketFailure;//socket is logged off. + return (iAcceptMethod->Accept(aTimeout)); +} + +inline void OsclTCPSocketI::CancelAccept() +{ + iAcceptMethod->CancelMethod(); +} + +////////////////////////////////////////////////////////////////////////////////// +inline TPVSocketEvent OsclTCPSocketI::Send(const uint8* &aPtr, uint32 aLen, + int32 aTimeoutMsec) +{ + if (!iObserver) + return EPVSocketFailure;//socket is logged off. + return (iSendMethod->Send(aPtr, aLen, aTimeoutMsec)); +} + +inline void OsclTCPSocketI::CancelSend() +{ + iSendMethod->CancelMethod(); +} + +////////////////////////////////////////////////////////////////////////////////// +inline TPVSocketEvent OsclTCPSocketI::Recv(uint8* &aPtr, uint32 aMaxLen, + int32 aTimeout) +{ + if (!iObserver) + return EPVSocketFailure;//socket is logged off. + return (iRecvMethod->Recv(aPtr, aMaxLen, aTimeout)); +} + +inline void OsclTCPSocketI::CancelRecv() +{ + iRecvMethod->CancelMethod(); +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_udp_socket.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_udp_socket.cpp new file mode 100644 index 0000000..52ee624 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_udp_socket.cpp @@ -0,0 +1,166 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_udp_socket.h" +#include "oscl_error.h" +#include "oscl_scheduler_ao.h" +#include "oscl_socket_send_to.h" +#include "oscl_socket_recv_from.h" +#include "oscl_socket_bind.h" + +//Public methods +////////////////////////////////////////////////////////////////////////////////// +OsclUDPSocketI *OsclUDPSocketI::NewL(Oscl_DefAlloc &a, OsclSocketServI *aServ, + OsclSocketObserver *aObserver, + uint32 aId) +{ + OsclAny*p = a.ALLOCATE(sizeof(OsclUDPSocketI)); + OsclError::LeaveIfNull(p); + OsclUDPSocketI* self = OSCL_PLACEMENT_NEW(p, OsclUDPSocketI(a)); + OsclError::LeaveIfNull(self); + OsclError::PushL(self); + self->ConstructL(aServ, aObserver, aId); + OsclError::Pop(); + return self; +} + +////////////////////////////////////////////////////////////////////////////////// +OsclUDPSocketI::~OsclUDPSocketI() +{ + //Cancel any outstanding requests. + iSendToMethod->AbortAll(); + OSCL_ASSERT(!iSendToMethod->IsBusy()); + OSCL_ASSERT(!iSendToMethod->SendToRequest()->IsBusy()); + + iRecvFromMethod->AbortAll(); + OSCL_ASSERT(!iRecvFromMethod->IsBusy()); + OSCL_ASSERT(!iRecvFromMethod->RecvFromRequest()->IsBusy()); + + iBindMethod->AbortAll(); + OSCL_ASSERT(!iBindMethod->IsBusy()); + OSCL_ASSERT(!iBindMethod->BindRequest()->IsBusy()); + + iSendToMethod->~OsclSendToMethod(); + iAlloc.deallocate(iSendToMethod); + iRecvFromMethod->~OsclRecvFromMethod(); + iAlloc.deallocate(iRecvFromMethod); + iBindMethod->~OsclBindMethod(); + iAlloc.deallocate(iBindMethod); + + iSocket->~OsclSocketI(); + iAlloc.deallocate(iSocket); +} + +TPVSocketEvent OsclUDPSocketI::ThreadLogoff() +{ + OsclIPSocketI::ThreadLogoff(); + + TPVSocketEvent result; + + result = iSendToMethod->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + result = iRecvFromMethod->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + result = iBindMethod->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + + result = iSocket->ThreadLogoff(); + if (result != EPVSocketSuccess) + return result; + + return result; + +} + +TPVSocketEvent OsclUDPSocketI::ThreadLogon(OsclSocketServI *aServ, OsclSocketObserver *aObserver) +{ + OsclIPSocketI::ThreadLogon(aObserver, aServ); + + TPVSocketEvent result; + + result = iSendToMethod->ThreadLogon(); + if (result != EPVSocketSuccess) + return result; + result = iRecvFromMethod->ThreadLogon(); + if (result != EPVSocketSuccess) + return result; + result = iBindMethod->ThreadLogon(); + if (result != EPVSocketSuccess) + return result; + + result = iSocket->ThreadLogon(aServ); + if (result != EPVSocketSuccess) + return result; + + return result; +} +////////////////////////////////////////////////////////////////////////////////// +int32 OsclUDPSocketI::Close() +{ + if (iSocket) + { + //Cancel any outstanding requests. + iSendToMethod->AbortAll(); + iRecvFromMethod->AbortAll(); + iBindMethod->AbortAll(); + return iSocket->Close(); + } + else + return OsclErrGeneral; +} + +////////////////////////////////////////////////////////////////////////////////// +int32 OsclUDPSocketI::JoinMulticastGroup(OsclIpMReq& aMReq) +{ + TIpMReq mReq; + OsclSocketI::MakeMulticastGroupInformation(aMReq, mReq); + return iSocket->SetSockOpt(EPVIPProtoIP, EPVIPAddMembership, &mReq, sizeof(mReq)); +} + +////////////////////////////////////////////////////////////////////////////////// +int32 OsclUDPSocketI::SetMulticastTTL(int32 aTTL) +{ + + return iSocket->SetSockOpt(EPVIPProtoIP, EPVIPMulticastTTL, &aTTL, sizeof(aTTL)); +} + +//Private methods +////////////////////////////////////////////////////////////////////////////////// +void OsclUDPSocketI::ConstructL(OsclSocketServI *aServ, + OsclSocketObserver *aObserver, + uint32 aId) +{ + iSocket = OsclSocketI::NewL(iAlloc); + + OsclIPSocketI::ConstructL(aObserver, iSocket, aServ, aId); + + //Allocate asynchronous method objects. + iSendToMethod = OsclSendToMethod::NewL(*this); + iRecvFromMethod = OsclRecvFromMethod::NewL(*this); + iBindMethod = OsclBindMethod::NewL(*this); + + //Open socket session + if (iSocket->Open(*iSocketServ, OSCL_AF_INET, OSCL_SOCK_DATAGRAM, OSCL_IPPROTO_UDP) != OsclErrNone) + OsclError::Leave(OsclErrGeneral); + +} + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_udp_socket.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_udp_socket.h new file mode 100644 index 0000000..7aae386 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclio/src/oscl_udp_socket.h @@ -0,0 +1,153 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_UDP_SOCKET_H_INCLUDED +#define OSCL_UDP_SOCKET_H_INCLUDED + +#include "oscl_ip_socket.h" +#include "oscl_defalloc.h" + +class OsclSendToMethod; +class OsclRecvFromMethod; +class OsclBindMethod; + +/**Internal implementation class for OsclUDPSocket +*/ +class OsclUDPSocketI : public OsclIPSocketI +{ + public: + static OsclUDPSocketI *NewL(Oscl_DefAlloc &a, + OsclSocketServI *aServ, + OsclSocketObserver *aObserver, + uint32 aId); + + virtual ~OsclUDPSocketI(); + + //Synchronous methods + int32 Close(); + int32 JoinMulticastGroup(OsclIpMReq& aMReq); + int32 SetMulticastTTL(int32 aTTL); + inline uint8 *GetRecvData(int32 *aLength); + inline uint8 *GetSendData(int32 *aLength); + TPVSocketEvent ThreadLogoff(); + TPVSocketEvent ThreadLogon( + OsclSocketServI *aServ, + OsclSocketObserver *aObserver + ); + + //Asynchronous methods + inline TPVSocketEvent BindAsync(OsclNetworkAddress& aAddress, + int32 aTimeoutMsec = -1); + inline void CancelBind(); + + inline TPVSocketEvent SendTo(const uint8* &aPtr, uint32 aLen, + OsclNetworkAddress& aAddress, + int32 aTimeoutMsec = -1); + inline void CancelSendTo(); + + inline TPVSocketEvent RecvFrom(uint8* &aPtr, uint32 aMaxLen, + OsclNetworkAddress& aAddress, + int32 aTimeoutMsec = -1, + uint32 aMultiMaxLen = 0, + Oscl_Vector* aPacketLen = NULL, + Oscl_Vector* aPacketSource = NULL); + inline void CancelRecvFrom(); + + private: + OsclUDPSocketI(Oscl_DefAlloc &a) : OsclIPSocketI(a), iSendToMethod(NULL), + iRecvFromMethod(NULL) + {} + + void ConstructL(OsclSocketServI *aServ, + OsclSocketObserver *aObserver, + uint32 aId); + + OsclBindMethod *iBindMethod; + OsclSendToMethod *iSendToMethod; + OsclRecvFromMethod *iRecvFromMethod; +}; + +#include "oscl_socket_recv_from.h" +#include "oscl_socket_send_to.h" +#include "oscl_socket_bind.h" + +////////////////////////////////////////////////////////////////////////////////// +inline uint8 *OsclUDPSocketI::GetRecvData(int32 *aLength) +{ + return iRecvFromMethod->GetRecvData(aLength); +} + +////////////////////////////////////////////////////////////////////////////////// +inline uint8 *OsclUDPSocketI::GetSendData(int32 *aLength) +{ + return iSendToMethod->GetSendData(aLength); +} + +////////////////////////////////////////////////////////////////////////////////// +inline TPVSocketEvent OsclUDPSocketI::BindAsync(OsclNetworkAddress& aAddress, + int32 aTimeoutMsec) +{ + if (!OsclSocketIBase::HasAsyncBind()) + return EPVSocketNotImplemented; + if (!iObserver) + return EPVSocketFailure;//not available. + + iAddress.ipAddr.Set(aAddress.ipAddr.Str()); + iAddress.port = aAddress.port; + return (iBindMethod->Bind(aAddress, aTimeoutMsec)); +} + +inline void OsclUDPSocketI::CancelBind() +{ + iBindMethod->CancelMethod(); +} + +////////////////////////////////////////////////////////////////////////////////// +inline TPVSocketEvent OsclUDPSocketI::SendTo(const uint8* &aPtr, uint32 aLen, + OsclNetworkAddress& aAddress, + int32 aTimeoutMsec) +{ + if (!iObserver) + return EPVSocketFailure;//socket is logged off. + return (iSendToMethod->SendTo(aPtr, aLen, aAddress, aTimeoutMsec)); +} + +inline void OsclUDPSocketI::CancelSendTo() +{ + iSendToMethod->CancelMethod(); +} + +////////////////////////////////////////////////////////////////////////////////// +inline TPVSocketEvent OsclUDPSocketI::RecvFrom(uint8* &aPtr, uint32 aMaxLen, + OsclNetworkAddress& aAddress, + int32 aTimeoutMsec, uint32 aMultiMax, + Oscl_Vector* aPacketLen, + Oscl_Vector* aPacketSource) +{ + if (!iObserver) + return EPVSocketFailure;//socket is logged off. + return (iRecvFromMethod->RecvFrom(aPtr, aMaxLen, aAddress, aTimeoutMsec, aMultiMax, aPacketLen, aPacketSource)); +} + +inline void OsclUDPSocketI::CancelRecvFrom() +{ + iRecvFromMethod->CancelMethod(); +} + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/Android.mk new file mode 100644 index 0000000..469c209 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/Android.mk @@ -0,0 +1,34 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/oscl_shared_library.cpp \ + src/oscl_configfile_list.cpp \ + src/oscl_library_list.cpp + + +LOCAL_MODULE := liboscllib + +LOCAL_CFLAGS := $(PV_CFLAGS) + + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/oscl/oscl/oscllib/src \ + $(PV_TOP)/oscl/oscl/oscllib/src \ + $(PV_TOP)/oscl/oscl/osclio/src \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + src/oscl_shared_lib_interface.h \ + src/oscl_shared_library.h \ + src/oscl_library_common.h \ + src/oscl_configfile_list.h \ + src/oscl_library_list.h + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/build/make/local.mk new file mode 100644 index 0000000..e8b4fa8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/build/make/local.mk @@ -0,0 +1,28 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + + +TARGET := oscllib + +XINCDIRS := ../../../osclio/src + +SRCDIR := ../../src +INCSRCDIR := ../../src + + +# compose final src list for actual build +SRCS := oscl_shared_library.cpp \ + oscl_configfile_list.cpp \ + oscl_library_list.cpp + +HDRS := oscl_shared_lib_interface.h \ + oscl_shared_library.h \ + oscl_library_common.h \ + oscl_configfile_list.h \ + oscl_library_list.h + + +include $(MK)/library.mk diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_configfile_list.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_configfile_list.cpp new file mode 100644 index 0000000..f154723 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_configfile_list.cpp @@ -0,0 +1,182 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_configfile_list.h" +#include "oscl_string.h" +#include "oscl_file_io.h" +#include "oscl_file_find.h" +#include "oscl_file_types.h" +#include "pvlogger.h" +#include "oscl_uuid.h" + +#define CONFIG_FILE_EXTENSION "*.cfg" +#define OSCL_NUMBER_OF_CONFIG_FILES 16 + +OSCL_EXPORT_REF OsclLibStatus OsclLibraryUtil::SetupLibraryEnv(const char* aEnvName, const char* aEnvValue) +{ + // currently only MSWIN is supported; + // Linux is not implemented since its library search path needs to be set at compilation time + OsclLibStatus aStatus = OsclLibSuccess; + + OSCL_UNUSED_ARG(aEnvName); + OSCL_UNUSED_ARG(aEnvValue); + aStatus = OsclLibNotSupported; + return aStatus; +} + + +OSCL_EXPORT_REF OsclConfigFileList::OsclConfigFileList() +{ + ipLogger = PVLogger::GetLoggerObject("oscllib"); +#if OSCL_LIBRARY_PERF_LOGGING + iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.oscllib.osclconfigfilelist"); + iCfgFileNum = 0; +#endif + int32 err = 0; + OSCL_TRY(err, + iCfgList.reserve(OSCL_NUMBER_OF_CONFIG_FILES); + ); + if (err) + { + iCfgList.clear(); + OSCL_LEAVE(err); + } +} + +OSCL_EXPORT_REF OsclConfigFileList::~OsclConfigFileList() +{ + ipLogger = NULL; +#if OSCL_LIBRARY_PERF_LOGGING + iDiagnosticsLogger = NULL; +#endif + iCfgList.clear(); +} + +// This method finds all files with extention .cfg in given directory +// using oscl_file_find and stores in a vector in iCfgList +// each cfg in iCfgList stored with whole pathname +// @Return: OsclLibSuccess if any config file found, OsclLibNotFound if not any, OsclLibFail otherwise + +OSCL_EXPORT_REF OsclLibStatus OsclConfigFileList::Populate(const OSCL_String& aConfigFileDir, OsclConfigFileList::SortType aSortType) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, + (0, "OsclConfigFileList::Populate '%s' IN", aConfigFileDir.get_cstr())); +#if OSCL_LIBRARY_PERF_LOGGING + TICK starttime; + SET_TICK(starttime); + iCfgFileNum = 0; +#endif + Oscl_FileFind aCfgFind; + OsclLibStatus status = OsclLibSuccess; + char* strbuf = (char*)OSCL_MALLOC(OSCL_IO_FILENAME_MAXLEN * sizeof(char)); + if (NULL == strbuf) + return OsclLibOutOfMemory; + if (NULL == aCfgFind.FindFirst(aConfigFileDir.get_str(), CONFIG_FILE_EXTENSION, strbuf, OSCL_IO_FILENAME_MAXLEN)) + { + OSCL_FREE(strbuf); + strbuf = NULL; + if (Oscl_FileFind::E_NO_MATCH == aCfgFind.GetLastError()) + { + status = OsclLibNotFound; + } + else + { + iCfgList.clear(); + return OsclLibFail; + } + } + else + { + //oscl_file_find return file with pathname. + iCfgList.push_front(strbuf); +#if OSCL_LIBRARY_PERF_LOGGING + iCfgFileNum++; +#endif + // found first config file, continue until Oscl_FileFind::E_NO_MATCH + while (aCfgFind.FindNext(strbuf, OSCL_IO_FILENAME_MAXLEN) && Oscl_FileFind::E_NO_MATCH != aCfgFind.GetLastError()) + { + iCfgList.push_back(strbuf); +#if OSCL_LIBRARY_PERF_LOGGING + iCfgFileNum++; +#endif + } +#if OSCL_LIBRARY_PERF_LOGGING + uint32 difftime; + DIFF_TICK(starttime, difftime); + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, "OsclConfigFileList::Populate - Searching path %s ...", aConfigFileDir.get_cstr())); + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, " Time taken = %d ticks", difftime)); + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, " Number of config files found = %d", iCfgFileNum)); +#endif + } + OSCL_FREE(strbuf); + // error if there's none config file found and loaded in the vector, + if (iCfgList.size() <= 0) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING, + (0, "OsclConfigFileList::Populate, Didn't find any config file in %s", aConfigFileDir.get_str())); + status = OsclLibNotFound; + } + // Sort the list if requested + else if (aSortType != OsclConfigFileList::ENoSort) + { + Sort(); + } + + return status; +} + +OSCL_EXPORT_REF uint32 OsclConfigFileList::Size() +{ + return iCfgList.size(); +} + +OSCL_EXPORT_REF const OSCL_String& OsclConfigFileList::GetConfigfileAt(uint32 n) +{ + return iCfgList[n]; +} + +void OsclConfigFileList::Sort() +{ + uint32 numConfigs = Size(); + uint32 ii = 0; + bool swapped = false; + + // Bubblesort iCfgList - As long as there aren't very many config files + // in the list, efficiency shouldn't be an issue. If the list gets to be + // too large (100+) then a new sort algorithm should be used. + do + { + swapped = false; + for (ii = 0; ii < numConfigs - 1; ii++) + { + if (oscl_strncmp(iCfgList[ii].get_cstr(), + iCfgList[ii + 1].get_cstr(), + oscl_strlen(iCfgList[ii].get_cstr())) > 0) + { + OSCL_StackString temp = iCfgList[ii]; + iCfgList[ii] = iCfgList[ii + 1]; + iCfgList[ii + 1] = temp; + swapped = true; + } + } + } + while (swapped); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_configfile_list.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_configfile_list.h new file mode 100644 index 0000000..598a1a9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_configfile_list.h @@ -0,0 +1,120 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCL_CONFIGFILE_LIST_H_INCLUDED +#define OSCL_CONFIGFILE_LIST_H_INCLUDED + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#include "oscl_string_containers.h" +#endif + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +#ifndef OSCL_LIBRARY_COMMON_H_INCLUDED +#include "oscl_library_common.h" +#endif + +struct OsclUuid; +class PVLogger; + +/** +* OsclConfigFileList contains the list of .cfg files found from a given directory +**/ +class OsclConfigFileList +{ + public: + enum SortType + { + ESortByName = 0, + ENoSort + }; + + /** + * Default object Constructor function + **/ + OSCL_IMPORT_REF OsclConfigFileList(); + + /** + * Object destructor function + **/ + OSCL_IMPORT_REF ~OsclConfigFileList(); + + /** + * Populate the list for the given directory. + * + * @param aConfigFileDir - directory path of the .cfg files; path can trail with or without delimiter (path prefix, e.g. '\') + * @param aSortType - Define type type of sort, if any, for the config file list. Default is not sorted + * + * @returns OsclLibStatus about whether the config file vector got populated or not + **/ + OSCL_IMPORT_REF OsclLibStatus Populate(const OSCL_String& aConfigFileDir, + OsclConfigFileList::SortType aSortType = ENoSort); + + /** + * Get the number of config file in the list. + * + * @returns Number of config file in list. + */ + OSCL_IMPORT_REF uint32 Size(); + + /** + * Returns the n'th element. + * @param n element position to return + * @returns the reference to the config file name stored in the iCfgList vector + */ + OSCL_IMPORT_REF const OSCL_String& GetConfigfileAt(uint32 n); + + + private: + Oscl_Vector, OsclMemAllocator> iCfgList; + PVLogger* ipLogger; +#if OSCL_LIBRARY_PERF_LOGGING + PVLogger* iDiagnosticsLogger; + uint32 iCfgFileNum; +#endif + + /** + * Sort iCfgList by name + */ + void Sort(void); +}; + +/** +* OsclLibraryUtil is mainly used by test app to setup library search path +**/ +class OsclLibraryUtil +{ + public: + /** + * static api sets, appends, or unset aDir to system PATH environment as the lib search folder + * + * @param aEnvName - environment name to be set or unset + * @param aEnvValue - environment value of the aEnvName to be set or unset + * + * @returns OsclLibStatus + **/ + OSCL_IMPORT_REF static OsclLibStatus SetupLibraryEnv(const char* aEnvName, const char* aEnvValue); +}; + +#endif //OSCL_LIBRARY_LIST_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_library_common.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_library_common.h new file mode 100644 index 0000000..2021b99 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_library_common.h @@ -0,0 +1,51 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCL_LIBRARY_COMMON_H_INCLUDED +#define OSCL_LIBRARY_COMMON_H_INCLUDED + +#include "oscl_tickcount.h" + + +typedef int32 OsclLibStatus; +const OsclLibStatus OsclLibSuccess = 0; +const OsclLibStatus OsclLibFail = 1; +const OsclLibStatus OsclLibNotFound = 2; +const OsclLibStatus OsclLibOutOfMemory = 3; +const OsclLibStatus OsclLibNotSupported = 4; +const OsclLibStatus OsclLibNotLoaded = 5; + +#ifndef OSCL_LIBRARY_PERF_LOGGING +//defaults for cases where the flag is not defined in the osclconfig_lib.h +#if (OSCL_RELEASE_BUILD) +//for release builds +#define OSCL_LIBRARY_PERF_LOGGING 0 +#else +//for debug builds +#define OSCL_LIBRARY_PERF_LOGGING 1 +#endif +#endif + + +#if OSCL_LIBRARY_PERF_LOGGING +#define TICK uint32 +#define SET_TICK(tick1) tick1 = OsclTickCount::TickCount() +#define DIFF_TICK(tick1,diff) TICK tick2; SET_TICK(tick2);diff = tick2 - tick1 +#endif + +#endif //OSCL_LIBRARY_COMMON_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_library_list.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_library_list.cpp new file mode 100644 index 0000000..8e3c257 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_library_list.cpp @@ -0,0 +1,296 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_library_list.h" +#include "oscl_string.h" +#include "oscl_file_io.h" +#include "oscl_file_types.h" +#include "pvlogger.h" +#include "oscl_uuid.h" +#include "oscl_uuid_utils.h" + +#define HASH '#' +#define NEWLINE '\n' +#define OPEN_PAREN '(' +#define CLOSE_PAREN ')' +#define QUOTE '"' +#define COMMA ',' +#define OSCL_NUMBER_OF_SHARED_LIBS 16 +#define BUFFER_SIZE 256 + + +OSCL_EXPORT_REF OsclLibraryList::OsclLibraryList() +{ + ipLogger = PVLogger::GetLoggerObject("oscllib"); +#if OSCL_LIBRARY_PERF_LOGGING + iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.oscllib.oscllibrarylist"); + iLinesRead = 0; + iLibHit = 0; +#endif + int32 err = 0; + OSCL_TRY(err, + iLibList.reserve(OSCL_NUMBER_OF_SHARED_LIBS); + ); + if (err) + { + iLibList.clear(); + OSCL_LEAVE(err); + } + +} + +OSCL_EXPORT_REF OsclLibraryList::~OsclLibraryList() +{ +#if OSCL_LIBRARY_PERF_LOGGING + iDiagnosticsLogger = NULL; +#endif + ipLogger = NULL; + iLibList.clear(); +} + +// This method actually parses through a dll config file, retrieving the paths +// of dlls which implement a specific OsclUuid +OSCL_EXPORT_REF OsclLibStatus OsclLibraryList::Populate(const OsclUuid& aInterfaceId, const OSCL_String& aConfigFile) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, + (0, "OsclLibraryList::Populate '%s' IN", aConfigFile.get_cstr())); + + // Open config file + Oscl_FileServer fileserver; + if (0 != fileserver.Connect()) + { + // Failed to connect to file server, return failure + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_ERR, + (0, "OsclLibraryList::Populate - Unable to connect to fileserver")); + return OsclLibFail; + } + Oscl_File configFile; + if (0 != configFile.Open(aConfigFile.get_cstr(), Oscl_File::MODE_READ, fileserver)) + { + // Failed to open config file, return failure + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_ERR, + (0, "OsclLibraryList::Populate - Unable to open configFile %s", aConfigFile.get_cstr())); + return OsclLibFail; + } + +#if OSCL_LIBRARY_PERF_LOGGING + // Start collecting stats for current config file + iLinesRead = 0; + iLibHit = 0; + TICK starttime; + SET_TICK(starttime); +#endif + + // Read in a byte at a time + uint8 buf[1]; + while (1 == configFile.Read(buf, 1, 1)) + { + if (HASH == buf[0]) + { +#if OSCL_LIBRARY_PERF_LOGGING + iLinesRead++; +#endif + // Ignore comments - begin with '#' + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, + (0, "OsclLibraryList::Populate - Found a comment, skipping")); + // Advance to end of line + while (1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE) + { + // ignore + } + } + else if (OPEN_PAREN == buf[0]) + { + // Parse UUID from line - begins with "(" + uint8 uuidBuf[BUFFER_SIZE]; + int i = 0; + uuidBuf[i++] = buf[0]; + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, + (0, "OsclLibraryList::Populate - Found a (, reading uuid")); + // Read a character at a time - stop if newline or eof is reached or buffer is filled + while (i < BUFFER_SIZE && 1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE) + { + uuidBuf[i++] = buf[0]; + if (CLOSE_PAREN == buf[0]) + { + break; + } + } + uuidBuf[i] = '\0'; + if (NEWLINE == buf[0]) + { +#if OSCL_LIBRARY_PERF_LOGGING + iLinesRead++; +#endif + // Reached the end of line but did not find the closing parentheses + // Skip this malformed line + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLibraryList::Populate - incomplete uuid, skipping line")); + } + else if (BUFFER_SIZE == i && CLOSE_PAREN != buf[0]) + { + // Buffer is filled but did not reach the end of UUID - skip this malformed line + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLibraryList::Populate - uuid too long, skipping line")); + // Advance to end of line + while (1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE) + { + // ignore + } + } + else + { + // Create an instance of OsclUuid + OsclUuid tempUuidStr; + SetOsclUuid(tempUuidStr, (char*)uuidBuf); + if (tempUuidStr == aInterfaceId) + { + // Parse path from line + bool commaFound = false; + bool quoteFound = false; + while (!(commaFound && quoteFound) && 1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE) + { + // Advance past ',' and '"' + if (COMMA == buf[0]) + { + // If already found a comma, break and skip this malformed line + if (commaFound) break; + commaFound = true; + } + else if (QUOTE == buf[0]) + { + // If already found a quote, break and skip this malformed line + if (quoteFound) break; + quoteFound = true; + } + } + if (!(commaFound && quoteFound) || NEWLINE == buf[0]) + { +#if OSCL_LIBRARY_PERF_LOGGING + iLinesRead++; +#endif + // Did not find both ',' and '"' - Skip this malformed line + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLibraryList::Populate - missing ' or \", skipping line")); + } + else + { + uint8 pathBuf[BUFFER_SIZE]; + i = 0; + // Read a character at a time - stop if newline is reached, ending quote is reached, or buffer is filled + // - leave room for terminating null character in buffer + while (1 == configFile.Read(buf, 1, 1) && buf[0] != QUOTE && buf[0] != NEWLINE && i < (BUFFER_SIZE - 1)) + { + pathBuf[i++] = buf[0]; + } + if (NEWLINE == buf[0]) + { +#if OSCL_LIBRARY_PERF_LOGGING + iLinesRead++; +#endif + // Reached the end of line but did not find the closing quote + // Skip this malformed line + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLibraryList::Populate - incomplete path, skipping line")); + } + else if ((BUFFER_SIZE - 1) == i && QUOTE != buf[0]) + { + // Buffer is filled but did not reach the end of path - skip this malformed line + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLibraryList::Populate - path too long, skipping line")); +#if OSCL_LIBRARY_PERF_LOGGING + iLinesRead++; +#endif + // Advance to end of line + while (1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE) + { + // ignore + } + } + else + { + // Read in the path, end with terminating character + pathBuf[i] = NULL_TERM_CHAR; + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_INFO, + (0, "OsclLibraryList::Populate - found a match, adding to list: %s", + (char*)pathBuf)); + // Add path to library list + iLibList.push_back((char*)pathBuf); +#if OSCL_LIBRARY_PERF_LOGGING + iLibHit++; + iLinesRead++; +#endif + } + } + } + else + { + // The UUID from this line does not match aInterfaceId - Advance to end of line + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_INFO, + (0, "OsclLibraryList::Populate - uuid not a match, skipping line")); +#if OSCL_LIBRARY_PERF_LOGGING + iLinesRead++; +#endif + while (1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE) + { + // ignore + } + } + } + } + // else continue on to next byte + }; + +#if OSCL_LIBRARY_PERF_LOGGING + // End stats for current config file + uint32 difftime; + DIFF_TICK(starttime, difftime); + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, "OsclLibraryList::Populate - Parsing configFile %s ...", aConfigFile.get_cstr())); + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, " Time taken = %d ticks", difftime)); + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, " Lines read = %d", iLinesRead)); + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, " Libraries found = %d", iLibHit)); +#endif + + //If there's atleast one library path name loaded in the vector, + //it means the parsing is successful for at least a particular OsclUuid + + if (iLibList.size() > 0) + { + return OsclLibSuccess; + } + else + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLibraryList::Populate, Didn't find any DLL for the OsclUuid")); + return OsclLibFail; + } +} + +OSCL_EXPORT_REF uint32 OsclLibraryList::Size() +{ + return iLibList.size(); +} + +OSCL_EXPORT_REF const OSCL_String& OsclLibraryList::GetLibraryPathAt(uint32 n) +{ + return iLibList[n]; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_library_list.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_library_list.h new file mode 100644 index 0000000..831384c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_library_list.h @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCL_LIBRARY_LIST_H_INCLUDED +#define OSCL_LIBRARY_LIST_H_INCLUDED + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#include "oscl_string_containers.h" +#endif + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +#ifndef OSCL_LIBRARY_COMMON_H_INCLUDED +#include "oscl_library_common.h" +#endif + +struct OsclUuid; +class PVLogger; + +/** +* OsclLibraryList contains the list of dynamically shared libraries that need to be loaded +**/ +class OsclLibraryList +{ + public: + /** + * Default object Constructor function + **/ + OSCL_IMPORT_REF OsclLibraryList(); + + /** + * Object destructor function + **/ + OSCL_IMPORT_REF ~OsclLibraryList(); + + /** + * Populate the list for the given interface ID. + * + * @param aInterfaceId ID to find the list of libraries for. + * @param aConfigFile - DLL Config file + * + * @returns OsclLibStatus about whether the librarylist vector got populated or not + **/ + OSCL_IMPORT_REF OsclLibStatus Populate(const OsclUuid& aInterfaceId, const OSCL_String& aConfigFile); + + /** + * Get the number of libraries in the list. + * + * @returns Number of libraries in list. + */ + OSCL_IMPORT_REF uint32 Size(); + + /** + * Returns the n'th element. + * @param n element position to return + * @returns the reference to the library path stored in the iLibList vector + */ + OSCL_IMPORT_REF const OSCL_String& GetLibraryPathAt(uint32 n); + + private: + Oscl_Vector, OsclMemAllocator> iLibList; + PVLogger* ipLogger; +#if OSCL_LIBRARY_PERF_LOGGING + PVLogger* iDiagnosticsLogger; + uint32 iLibHit; + uint32 iLinesRead; +#endif +}; + +#endif //OSCL_LIBRARY_LIST_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_shared_lib_interface.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_shared_lib_interface.h new file mode 100644 index 0000000..b627a8a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_shared_lib_interface.h @@ -0,0 +1,35 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCL_SHARED_LIB_INTERFACE_H_INCLUDED +#define OSCL_SHARED_LIB_INTERFACE_H_INCLUDED + +#ifndef OSCL_UUID_H_INCLUDED +#include "oscl_uuid.h" +#endif +#ifndef OSCL_TYPES_H_INCLUDED +#include "oscl_types.h" +#endif + +class OsclSharedLibraryInterface +{ + public: + virtual OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId) = 0; + virtual ~OsclSharedLibraryInterface() {} +}; +#endif // OSCL_SHARED_LIB_INTERFACE_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_shared_library.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_shared_library.cpp new file mode 100644 index 0000000..83a8131 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_shared_library.cpp @@ -0,0 +1,448 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "osclconfig_lib.h" +#include "oscl_shared_library.h" +#include "oscl_string.h" +#include "pvlogger.h" +#include "oscl_utf8conv.h" +#include "oscl_uuid.h" +#include "oscl_file_types.h" + +#define BUFFER_SIZE 256 + +typedef OsclSharedLibraryInterface*(*PVGetInterface_t)(); +typedef void (*PVReleaseInterface_t)(OsclSharedLibraryInterface*); + +OSCL_EXPORT_REF OsclSharedLibrary::OsclSharedLibrary() +{ + ipLogger = PVLogger::GetLoggerObject("oscllib"); +#if OSCL_LIBRARY_PERF_LOGGING + iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.oscllib.osclsharedlibrary"); + iLibCount = 0; + iLibLoadTime = 0; +#endif + pSharedLibInterface = NULL; + iRefCount = 0; + ipHandle = NULL; + +} + +OSCL_EXPORT_REF OsclSharedLibrary::OsclSharedLibrary(const OSCL_String& aPath) +{ + ipLogger = PVLogger::GetLoggerObject("oscllib"); +#if OSCL_LIBRARY_PERF_LOGGING + iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.oscllib.osclsharedlibrary"); + iLibCount = 0; + iLibLoadTime = 0; +#endif + pSharedLibInterface = NULL; + + iRefCount = 0; + ipHandle = NULL; + iLibPath = aPath; +} + +OSCL_EXPORT_REF OsclSharedLibrary::~OsclSharedLibrary() +{ +#if OSCL_LIBRARY_PERF_LOGGING + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, "OsclSharedLibrary - Loading %d libraries took %d ticks ...", iLibCount, iLibLoadTime)); + iDiagnosticsLogger = NULL; +#endif + ipLogger = NULL; + + if (NULL != ipHandle) + { + Close(); + } +} + +OSCL_EXPORT_REF OsclLibStatus OsclSharedLibrary::LoadLib(const OSCL_String& aPath) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, (0, "OsclSharedLibrary::LoadLib %s IN", aPath.get_cstr())); +#if OSCL_LIBRARY_PERF_LOGGING + iLibCount++; + TICK starttime; + SET_TICK(starttime); +#endif + iLibPath = aPath; + // First look for debug version of the library ending with _debug + int32 dotpos = aPath.get_size() - 1; + while (dotpos >= 0) + { + if (aPath[dotpos] == '.') + break; + dotpos--; + } + if (dotpos >= 0 && dotpos != (int32)(aPath.get_size() - 1)) + { // extension exists +#if OSCL_LIB_READ_DEBUG_LIBS + OSCL_HeapString path1(aPath.get_cstr(), dotpos); + OSCL_HeapString debugPath(path1); + debugPath += "_debug"; + debugPath += (aPath.get_cstr() + dotpos); + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, (0, "OsclSharedLibrary::LoadLib looking for Debug lib %s", debugPath.get_cstr())); + // Open the library + if (OsclLibSuccess == loadlibrary(debugPath)) + { +#if OSCL_LIBRARY_PERF_LOGGING + DIFF_TICK(starttime, delta); + iLibLoadTime += delta; + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", debugPath.get_cstr(), delta)); +#endif + return OsclLibSuccess; // debug dll loaded successfully + } + // _debug load failed, try original +#endif + if (OsclLibSuccess == loadlibrary(aPath)) + { +#if OSCL_LIBRARY_PERF_LOGGING + DIFF_TICK(starttime, delta); + iLibLoadTime += delta; + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", aPath.get_cstr(), delta)); +#endif + return OsclLibSuccess; + } + return OsclLibFail; + } + else if (dotpos == (int32)(aPath.get_size() - 1)) + { // libname ended with "." no extension + OSCL_HeapString path1(aPath.get_cstr(), dotpos); + OSCL_HeapString debugPath(path1); +#if OSCL_LIB_READ_DEBUG_LIBS + debugPath += "_debug."; + debugPath += PV_RUNTIME_LIB_FILENAME_EXTENSION; + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, (0, "OsclSharedLibrary::LoadLib looking for Debug lib %s", debugPath.get_cstr())); + // Open the library + if (OsclLibSuccess == loadlibrary(debugPath)) + { +#if OSCL_LIBRARY_PERF_LOGGING + DIFF_TICK(starttime, delta); + iLibLoadTime += delta; + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", debugPath.get_cstr(), delta)); +#endif + return OsclLibSuccess; // debug dll loaded successfully + } + // _debug load failed, try original + debugPath = path1; +#endif + debugPath += PV_RUNTIME_LIB_FILENAME_EXTENSION; + if (OsclLibSuccess == loadlibrary(debugPath)) + { +#if OSCL_LIBRARY_PERF_LOGGING + DIFF_TICK(starttime, delta); + iLibLoadTime += delta; + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", debugPath.get_cstr(), delta)); +#endif + return OsclLibSuccess; + } + return OsclLibFail; + } + else // libname without extension + { + OSCL_HeapString path1(aPath.get_cstr()); + OSCL_HeapString debugPath(path1); +#if OSCL_LIB_READ_DEBUG_LIBS + debugPath += "_debug."; + debugPath += PV_RUNTIME_LIB_FILENAME_EXTENSION; + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, (0, "OsclSharedLibrary::LoadLib looking for Debug lib %s", debugPath.get_cstr())); + // Open the library + if (OsclLibSuccess == loadlibrary(debugPath)) + { +#if OSCL_LIBRARY_PERF_LOGGING + DIFF_TICK(starttime, delta); + iLibLoadTime += delta; + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", debugPath.get_cstr(), delta)); +#endif + return OsclLibSuccess; // debug dll loaded successfully + } + // _debug load failed, try original + debugPath = path1; +#endif + debugPath += "."; + debugPath += PV_RUNTIME_LIB_FILENAME_EXTENSION; + if (OsclLibSuccess == loadlibrary(debugPath)) + { +#if OSCL_LIBRARY_PERF_LOGGING + DIFF_TICK(starttime, delta); + iLibLoadTime += delta; + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, + (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", debugPath.get_cstr(), delta)); +#endif + return OsclLibSuccess; + } + return OsclLibFail; + } + +} + +OSCL_EXPORT_REF OsclLibStatus OsclSharedLibrary::LoadLib() +{ + return LoadLib(iLibPath); +} + +OSCL_EXPORT_REF void OsclSharedLibrary::SetLibPath(const OSCL_String& aPath) +{ + iLibPath = aPath; +} + +OSCL_EXPORT_REF OsclLibStatus OsclSharedLibrary::QueryInterface(const OsclUuid& aInterfaceId, + OsclAny*& aInterfacePtr) +{ + aInterfacePtr = NULL; + // Look up the PVGetInterface method + if (NULL == ipHandle) + { + return OsclLibNotLoaded; + } + PVGetInterface_t getInterface = + (PVGetInterface_t)dlsym(ipHandle, "PVGetInterface"); + // dlsym() returns NULL if there were any issues getting the + // address of the symbol + if (NULL == getInterface) + { + // check for errors + const char* pErr = dlerror(); + if (NULL == pErr) + { + // No error reported, but no symbol was found + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLib::QueryInterface: Could not access PVGetInterface " + "symbol in library but no error reported")); + } + else + { + // Error reported + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLib::QueryInterface: Could not access PVGetInterface " + "symbol in library: %s", pErr)); + } + return OsclLibFail; + } + + // Get the OsclSharedLibraryInterface if needed. There can be multiple calls + // to query interface so check whether the interface has already been fetched. + if (!pSharedLibInterface) + { + pSharedLibInterface = (OsclSharedLibraryInterface*)getInterface(); + } + if (NULL == pSharedLibInterface) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING, + (0, "OsclSharedLibrary::QueryInterface: Could not access the " + "library pointer function")); + return OsclLibFail; + } + // Lookup the interface ID + aInterfacePtr = pSharedLibInterface->SharedLibraryLookup(aInterfaceId); + if (NULL == aInterfacePtr) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLib::QueryInterface: NO library interface found for aInterfaceId.")); + return OsclLibFail; + } + return OsclLibSuccess; +} + +OSCL_EXPORT_REF OsclLibStatus OsclSharedLibrary::Close() +{ + if (iRefCount > 0) + { + return OsclLibFail; + } + if (pSharedLibInterface) + { + PVReleaseInterface_t releaseInterface = + (PVReleaseInterface_t)dlsym(ipHandle, "PVReleaseInterface"); + // dlsym() returns NULL if there were any issues getting the + // address of the symbol + if (NULL == releaseInterface) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_ERR, + (0, "OsclLib::Close: Could not access " + "PVReleaseInterface symbol in library - Possible memory leak.")); + // check for errors + const char* pErr = dlerror(); + if (NULL == pErr) + { + // No error reported, but no symbol was found + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_INFO, + (0, "OsclLib::Close: Could not access PVReleaseInterface " + "symbol in library but no error reported")); + } + else + { + // Error reported + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_INFO, + (0, "OsclLib::Close: Could not access PVReleaseInterface " + "symbol in library: %s", pErr)); + } + } + else + { + releaseInterface(pSharedLibInterface); + pSharedLibInterface = NULL; + } + } + if (ipHandle) + { + if (0 != dlclose(ipHandle)) + { + // dlclose() returns non-zero value if close failed, check for errors + const char* pErr = dlerror(); + if (NULL != pErr) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING, + (0, "OsclSharedLibrary::Close: Error closing library: %s", pErr)); + } + else + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING, + (0, "OsclSharedLibrary::Close: Error closing library, no error reported" + "")); + } + return OsclLibFail; + } + ipHandle = NULL; + } + return OsclLibSuccess; +} + +OSCL_EXPORT_REF void OsclSharedLibrary::AddRef() +{ + ++iRefCount; +} + +OSCL_EXPORT_REF void OsclSharedLibrary::RemoveRef() +{ + --iRefCount; +} + +// +//OsclSharedLibraryList +// +#include "oscl_configfile_list.h" +#include "oscl_library_list.h" + +OSCL_EXPORT_REF OsclSharedLibraryList::OsclSharedLibraryList() +{ + iLogger = PVLogger::GetLoggerObject("oscllib"); +} + +OSCL_EXPORT_REF OsclSharedLibraryList::~OsclSharedLibraryList() +{ + CloseAll(); +} +/* +** Give a config file path, search all config files for libraries that +** support the given interface ID. +*/ +OSCL_EXPORT_REF void OsclSharedLibraryList::Populate(const OSCL_String& aPath, const OsclUuid& aInterfaceId) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, + (0, "OsclSharedLibraryList::Populate '%s' IN", aPath.get_cstr())); + + iInterfaceId = aInterfaceId; + OsclConfigFileList configFileList; + configFileList.Populate(aPath); + for (uint32 i = 0; i < configFileList.Size(); i++) + { + OsclLibraryList libList; + libList.Populate(aInterfaceId, configFileList.GetConfigfileAt(i)); + for (uint32 j = 0; j < libList.Size(); j++) + { + OsclSharedLibrary* sharedLib = OSCL_NEW(OsclSharedLibrary, (libList.GetLibraryPathAt(j))); + iList.push_back(sharedLib); + } + } +} + +/* +** Query interface for the given library. +*/ +OSCL_EXPORT_REF OsclLibStatus OsclSharedLibraryList::QueryInterfaceAt(uint32 aIndex, OsclAny*& aInterfacePtr) +{ + aInterfacePtr = NULL; + OsclLibStatus status = OsclLibFail; + + if (aIndex < iList.size()) + { + status = iList[aIndex]->QueryInterface(iInterfaceId, aInterfacePtr); + //Load lib if needed & repeat the query. + if (status == OsclLibNotLoaded) + { + status = iList[aIndex]->LoadLib(); + if (status == OsclLibSuccess) + status = iList[aIndex]->QueryInterface(iInterfaceId, aInterfacePtr); + } + } + return status; +} + +/* +** Close all open libraries +*/ +OSCL_EXPORT_REF void OsclSharedLibraryList::CloseAll() +{ + while (!iList.empty()) + { + iList.front()->Close(); + OSCL_DELETE(iList.front()); + iList.erase(&iList.front()); + } +} + +OsclLibStatus OsclSharedLibrary::loadlibrary(const OSCL_String& alib) +{ + PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, (0, "OsclSharedLibrary::loadlibrary %s IN", alib.get_cstr())); + // Clear any errors + dlerror(); + // Open the library + void* library = dlopen(alib.get_cstr(), RTLD_NOW); + // dlopen() returns NULL if there were any issues opening the library + if (NULL == library) + { + // check for errors + const char* pErr = dlerror(); + if (NULL == pErr) + { + // No error reported, but no handle to the library + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLib::loadlibrary: Error opening " + "library (%s) but no error reported", + alib.get_cstr(), pErr)); + } + else + { + // Error reported + PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING, + (0, "OsclLib::loadlibrary: Error opening " + "library (%s): %s", alib.get_cstr(), pErr)); + } + return OsclLibFail; + } + ipHandle = library; + return OsclLibSuccess; + +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_shared_library.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_shared_library.h new file mode 100644 index 0000000..510355c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/oscllib/src/oscl_shared_library.h @@ -0,0 +1,180 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCL_SHARED_LIBRARY_H_INCLUDED +#define OSCL_SHARED_LIBRARY_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#include "oscl_string_containers.h" +#endif + +#ifndef OSCL_SHARED_LIB_INTERFACE_H_INCLUDED +#include "oscl_shared_lib_interface.h" +#endif + +#ifndef OSCL_LIBRARY_COMMON_H_INCLUDED +#include "oscl_library_common.h" +#endif + +struct OsclUuid; +class PVLogger; + +/** + * OsclSharedLibrary gives access to shared libraries in the user specified location + **/ +class OsclSharedLibrary +{ + public: + + /** + * Default object Constructor function + **/ + + OSCL_IMPORT_REF OsclSharedLibrary(); + + /** + * Constructor that accepts a path to the library to load. The library + * isn't loaded at this point. It is only loaded after a call to LoadLib. + * + * @param aPath path name of a specific library to load + */ + OSCL_IMPORT_REF OsclSharedLibrary(const OSCL_String& aPath); + + /** + * Object destructor function + **/ + OSCL_IMPORT_REF ~OsclSharedLibrary(); + + /** + * Attempts to load the library specified by the pathname. + * + * @param aPath path name of a specific library to load + * @returns Returns some status information about whether the library loaded. + */ + OSCL_IMPORT_REF OsclLibStatus LoadLib(const OSCL_String& aPath); + + /** + * Attempts to load the library specified by the stored pathname (as set + * in the constructor or SetLibPath). + * + * @returns Returns some status information about whether the library loaded. + */ + OSCL_IMPORT_REF OsclLibStatus LoadLib(); + + /** + * Sets iLibPath to the pathname provided + * + * @param aPath path name of a specific library to load + */ + OSCL_IMPORT_REF void SetLibPath(const OSCL_String& aPath); + + /** + * Query for the instance of a particular interface based on the request interface ID + * + * @param aInterfaceId ID + * + * @param aInterfacePtr - output parameter filled in with the requested interface + * pointer or NULL if the interface pointer is not supported. + * @returns OsclLibStatus information about query for the interface + **/ + OSCL_IMPORT_REF OsclLibStatus QueryInterface(const OsclUuid& aInterfaceId, + OsclAny*& aInterfacePtr); + + /** + * Close the library. The library will be closed only when there are no live references + * @returns success or fail in case of closing the library + **/ + OSCL_IMPORT_REF OsclLibStatus Close(); + + /** + * Increment the reference count for tracking number of live references of node + * by the shared lib instance. + **/ + OSCL_IMPORT_REF void AddRef(); + + /** + * Decrement the reference count when done with live reference node + * by the shared lib instance. + **/ + OSCL_IMPORT_REF void RemoveRef(); + + private: + OsclLibStatus loadlibrary(const OSCL_String& alib); + + PVLogger* ipLogger; + int32 iRefCount; + OsclSharedLibraryInterface *pSharedLibInterface; +#if OSCL_LIBRARY_PERF_LOGGING + PVLogger* iDiagnosticsLogger; + uint32 iLibCount; + uint32 iLibLoadTime; + uint32 delta; +#endif + void* ipHandle; + OSCL_HeapString iLibPath; + bool iLoaded; +}; + +#include "oscl_vector.h" + +/* +** OsclSharedLibraryList is a handy class for locating and using libraries that support +** a given interface. +*/ +class OsclSharedLibraryList +{ + public: + OSCL_IMPORT_REF OsclSharedLibraryList(); + OSCL_IMPORT_REF ~OsclSharedLibraryList(); + + /* + ** Give a config file directory, locate all the libraries that support the given + ** interface ID. For each library, create a shared library object for it and add + ** it to the list. + */ + OSCL_IMPORT_REF void Populate(const OSCL_String& aPath, const OsclUuid& aInterfaceId); + + /* + ** Return the size of the list + */ + uint32 Size() + { + return iList.size(); + } + + /* + ** Query interface for the given library. This will load the library if needed. + */ + OSCL_IMPORT_REF OsclLibStatus QueryInterfaceAt(uint32 aIndex, OsclAny*& aInterfacePtr); + + /* + ** Close all open libraries and clear the list. + */ + OSCL_IMPORT_REF void CloseAll(); + + private: + Oscl_Vector iList; + OsclUuid iInterfaceId; + PVLogger* iLogger; +}; + +#endif //OSCL_SHARED_LIBRARY_H_INCLUDED + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/Android.mk new file mode 100644 index 0000000..3926f4c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/Android.mk @@ -0,0 +1,34 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/oscl_mem.cpp \ + src/oscl_mem_imp.cpp \ + src/oscl_mem_audit.cpp \ + src/oscl_mem_mempool.cpp + + +LOCAL_MODULE := libosclmemory + +LOCAL_CFLAGS := $(PV_CFLAGS) + + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/oscl/oscl/osclmemory/src \ + $(PV_TOP)/oscl/oscl/osclmemory/src \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + src/oscl_mem.h \ + src/oscl_mem_audit.h \ + src/oscl_mem_auto_ptr.h \ + src/oscl_mem_mempool.h \ + src/oscl_mem.inl + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/build/make/local.mk new file mode 100644 index 0000000..adbcee8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/build/make/local.mk @@ -0,0 +1,26 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + + +TARGET := osclmemory + + +SRCDIR := ../../src +INCSRCDIR := ../../src + +SRCS := oscl_mem.cpp \ + oscl_mem_imp.cpp \ + oscl_mem_audit.cpp \ + oscl_mem_mempool.cpp + +HDRS := oscl_mem.h \ + oscl_mem_audit.h \ + oscl_mem_auto_ptr.h \ + oscl_mem_mempool.h \ + oscl_mem.inl + +include $(MK)/library.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem.cpp new file mode 100644 index 0000000..48cd05b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem.cpp @@ -0,0 +1,32 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + +#include "oscl_mem.h" + +#if (OSCL_DISABLE_INLINES) +#include "oscl_mem.inl" +#endif + +#ifndef OSCL_COMBINED_DLL +#include "oscl_dll.h" +OSCL_DLL_ENTRY_POINT_DEFAULT() +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem.h new file mode 100644 index 0000000..e9d6b81 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem.h @@ -0,0 +1,1057 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M E M + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclmemory OSCL Memory + * + * @{ + */ + + +/*! \file oscl_mem.h + \brief This file contains basic memory definitions for common use across platforms. + + This is the main entry point header file for the OSCL memory library. It should be + the only one users directly include. Basic memory copy, compare, and move functions + are defined here as well as the allocation functions. +*/ + +#ifndef OSCL_MEM_H_INCLUDED +#define OSCL_MEM_H_INCLUDED + +#ifndef OSCLCONFIG_MEMORY_H_INCLUDED +#include "osclconfig_memory.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_TYPES_H_INCLUDE +#include "oscl_types.h" +#endif + +#ifndef OSCL_ASSERT_H_INCLUDED +#include "oscl_assert.h" +#endif + +#ifndef OSCL_MEM_BASIC_FUNCTIONS_H +#include "oscl_mem_basic_functions.h" +#endif + +#ifndef OSCL_LOCK_BASE_H_INCLUDED +#include "oscl_lock_base.h" +#endif + +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + +#ifndef OSCL_MEM_INST_H_INCLUDED +#include "oscl_mem_inst.h" +#endif + +#ifndef OSCL_HEAPBASE_H_INCLUDED +#include "oscl_heapbase.h" +#endif + +//Default for OSCL_HAS_GLOBAL_NEW_DELETE in case it is *not* defined +//in the osclconfig_memory.h +#ifndef OSCL_HAS_GLOBAL_NEW_DELETE +#if (OSCL_RELEASE_BUILD) +//Release Mode - No definition for global new and delete. +#define OSCL_HAS_GLOBAL_NEW_DELETE 0 +#else +//Debug Mode - Define global new and delete. +#define OSCL_HAS_GLOBAL_NEW_DELETE 1 +#endif //OSCL_RELEASE_BUILD +#endif //OSCL_HAS_GLOBAL_NEW_DELETE + +class OsclMem +{ + public: + /** Per-thread initialization of Oscl Memory + ** @param lock: A lock class for use with multi-threaded applications. + ** The lock is needed in use cases where memory may be allocated + ** in one thread and freed in another. In this case, there must + ** be a single lock object, and its pointer must be passed to + ** the OsclMem::Init call in each thread. + ** If no lock is provided, the memory manager will not be thread-safe. + ** @exception: Leaves on error + */ + OSCL_IMPORT_REF static void Init(); + + /** Per-thread cleanup of Oscl Memory + ** @exception: Leaves on error; + */ + OSCL_IMPORT_REF static void Cleanup(); + +}; + +/* +** Choose whether to use per-thread or singleton registry for auditing +*/ +#include "oscl_base.h" + +/* +** Audit control block +*/ +#if (OSCL_BYPASS_MEMMGT) +//empty class for compilation only +class OsclAuditCB +{ + public: +}; +#else +class OsclMemStatsNode; +class OsclMemAudit; +class OsclAuditCB +{ + public: + const OsclMemStatsNode* pStatsNode; + OsclMemAudit *pAudit; + + OsclAuditCB() : + pStatsNode(NULL), + pAudit(NULL) + {} + + OsclAuditCB(const OsclMemStatsNode* myStatsNode, + OsclMemAudit *ptr) + : + pStatsNode(myStatsNode), + pAudit(ptr) + { + } +}; +#endif//OSCL_BYPASS_MEMMGT + +/** + * Get memory-aligned size of an object. + * + * @param size size of object + * + * @returns memory-aligned size + */ +OSCL_COND_IMPORT_REF uint oscl_mem_aligned_size(uint size); + +/** + * Initialize an OsclAuditCB object. + * Sets the stats node pointer to null, and sets the + * audit pointer to the global audit object. + * + * @param auditCB memory management audit object + */ +OSCL_IMPORT_REF void OsclMemInit(OsclAuditCB & auditCB); + +/** + * Cleans up the base class of a partially-constructed + * derived class. This macro will call the destructor + * if necessary, based on the error-handling implementation. + * + * @param T: name of the base class. + */ +#define OSCL_CLEANUP_BASE_CLASS(T) _OSCL_CLEANUP_BASE_CLASS(T) + +/** ******************************************************* + * Macros for new/delete with a given allocator/deallocator. + */ + +/** + * Creates an object of type T using the given allocator to + * acquire the memory needed. + * + * @param T_allocator allocator for objects of type T, must be + * an Oscl_TAlloc, where Allocator is an Oscl_DefAlloc + * @param T type of object to create + * @param params object initialization parameters + * + * @return pointer to created object + * + * @exception none, unless thrown by the given allocator + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_ALLOC_NEW(T_allocator, T, params) new(T_allocator.allocate(1)) T params +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_ALLOC_NEW(T_allocator, T, params) new(T_allocator.allocate_fl(1,__FILE__,__LINE__)) T params +#else +#define OSCL_ALLOC_NEW(T_allocator, T, params) new(T_allocator.allocate(1)) T params +#endif + +/** + * Creates an object of type T using the given allocator to + * acquire the memory needed. + * This macro is similar to OSCL_ALLOC_NEW except that it + * handles constructors that leave. + * If the constructor leaves, the destructor will be called, + * and allocated memory will be freed before allowing the + * leave to propagate to the next level. + * + * @param T_ptr variable to hold return value-- pointer to + * new object of type T. + * @param T_allocator allocator for objects of type T, must be + * an Oscl_TAlloc, where Allocator is an + * Oscl_DefAlloc + * @param T type of object to create + * @param params object initialization parameters + * + * @return pointer to created object + * + * @exception none, unless thrown by the given allocator + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_TRAP_ALLOC_NEW(T_ptr,T_allocator,T,params) _OSCL_TRAP_NEW(T_allocator.allocate(1),T_allocator.deallocate,T_ptr,T,params) +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_TRAP_ALLOC_NEW(T_ptr,T_allocator,T,params) _OSCL_TRAP_NEW(T_allocator.allocate_fl(1,__FILE__,__LINE__),T_allocator.deallocate,T_ptr,T,params) +#else +#define OSCL_TRAP_ALLOC_NEW(T_ptr,T_allocator,T,params) _OSCL_TRAP_NEW(T_allocator.allocate(1),T_allocator.deallocate,T_ptr,T,params) +#endif + +/** + * Deletes the object of type T using the given allocator + * + * @param T_allocator allocator for objects of type T + * @param T type of object to delete + * @param ptr pointer to previously created object + * + * @exception none, unless thrown by the given allocator + */ +#define OSCL_ALLOC_DELETE(ptr, T_allocator, T) \ + {\ + ptr->~T();\ + T_allocator.deallocate(ptr);\ + } + + +/** ******************************************************* + * Macros for malloc/free with memory management. + */ + +//These are for internal use but need to be visible since they're used +//in macros. +#if(!OSCL_BYPASS_MEMMGT) +OSCL_IMPORT_REF void* _oscl_audit_malloc(size_t , OsclAuditCB & , const char * f = NULL, const int l = 0); +OSCL_IMPORT_REF void* _oscl_audit_calloc(size_t , size_t, OsclAuditCB & , const char * f = NULL, const int l = 0); +OSCL_IMPORT_REF void* _oscl_audit_realloc(void*, size_t , OsclAuditCB & , const char * f = NULL, const int l = 0); +OSCL_IMPORT_REF void* _oscl_audit_new(size_t , OsclAuditCB & , const char * f = NULL, const int l = 0) ; +OSCL_IMPORT_REF void* _oscl_default_audit_malloc(size_t , const char * f = NULL, const int l = 0); +OSCL_IMPORT_REF void* _oscl_default_audit_calloc(size_t , size_t, const char * f = NULL, const int l = 0); +OSCL_IMPORT_REF void* _oscl_default_audit_realloc(void*, size_t , const char * f = NULL, const int l = 0); +OSCL_IMPORT_REF void* _oscl_default_audit_new(size_t , const char * f = NULL, const int l = 0) ; +OSCL_IMPORT_REF void _oscl_audit_free(void *); +#else +OSCL_IMPORT_REF void* _oscl_default_new(size_t nBytes); +#endif//OSCL_BYPASS_MEMMGT + +#if (OSCL_HAS_GLOBAL_NEW_DELETE) +//Global New operator overloaded to check native new operators called + +#if(!OSCL_BYPASS_MEMMGT) +inline void * operator new(size_t aSize, const char *aFile, int aLine) +{ +#if(PVMEM_INST_LEVEL>0) + //in case NULL is passed in, record this file & line # + if (!aFile) + return _oscl_default_audit_new(aSize, __FILE__, __LINE__); +#endif + return _oscl_default_audit_new(aSize, aFile, aLine); +}; +#endif + +inline void * operator new(size_t aSize) +{ +#if(!OSCL_BYPASS_MEMMGT) +#if(PVMEM_INST_LEVEL>0) + return _oscl_default_audit_new(aSize, __FILE__, __LINE__); +#else + return _oscl_default_audit_new(aSize); +#endif +#else + return _oscl_default_new(aSize); +#endif +}; + +inline void operator delete(void *aPtr) +{ +#if(!OSCL_BYPASS_MEMMGT) + _oscl_audit_free(aPtr); +#else + _oscl_free(aPtr); +#endif +}; + +#if(!OSCL_BYPASS_MEMMGT) +inline void * operator new[](size_t aSize, const char *aFile, int aLine) +{ +#if(PVMEM_INST_LEVEL>0) + //in case NULL is passed in, record this file & line # + if (!aFile) + return _oscl_default_audit_new(aSize, __FILE__, __LINE__); +#endif + return _oscl_default_audit_new(aSize, aFile, aLine); +}; +#endif + +inline void * operator new[](size_t aSize) +{ +#if(!OSCL_BYPASS_MEMMGT) +#if(PVMEM_INST_LEVEL>0) + return _oscl_default_audit_new(aSize, __FILE__, __LINE__); +#else + return _oscl_default_audit_new(aSize); +#endif +#else + return _oscl_default_new(aSize); +#endif +}; + +inline void operator delete[](void *aPtr) +{ +#if(!OSCL_BYPASS_MEMMGT) + _oscl_audit_free(aPtr); +#else + _oscl_free(aPtr); +#endif +}; +#endif //OSCL_HAS_GLOBAL_NEW_DELETE + +/** + * Allocates a memory block using the memory management's + * global audit object. + * + * @param count number of bytes to allocate + * + * @return a void pointer to the allocated space, or NULL if there is insufficient + * memory available. + * + * @exception none + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_MALLOC(count) _oscl_malloc(count) +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_MALLOC(count) _oscl_default_audit_malloc(count,__FILE__,__LINE__) +#else +#define OSCL_MALLOC(count) _oscl_default_audit_malloc(count) +#endif + +/* +** The public oscl_malloc call has been deprecated. +** PV code should call OSCL_MALLOC. +** This macro is defined for back-compatibility. +*/ +#define oscl_malloc(a) OSCL_MALLOC(a) + +/** + * Another back-compatibility definition. + */ +#define OSCL_DEFAULT_MALLOC(x) OSCL_MALLOC(x) + +/** +* Allocates a memory block using the given audit object. +* +* @param auditCB input memory management audit object +* @param count number of bytes to allocate +* +* @return a void pointer to the allocated space, or NULL if there is insufficient +* memory available. +* +* @exception none +*/ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_AUDIT_MALLOC(auditCB, count) _oscl_malloc(count) +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_AUDIT_MALLOC(auditCB, count) _oscl_audit_malloc(count, auditCB, __FILE__, __LINE__) +#else +#define OSCL_AUDIT_MALLOC(auditCB, count) _oscl_audit_malloc(count, auditCB) +#endif + +/** + * Allocates a memory block using the memory management's + * global audit object. The block is initialized to zero. + * + * @param num number of elements + * @param size number of bytes to allocate for each element + * + * @return a void pointer to the allocated space, or NULL if there is insufficient + * memory available. + * + * @exception none + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_CALLOC(num,size) _oscl_calloc(num,size) +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_CALLOC(num,size) _oscl_default_audit_calloc(num,size,__FILE__,__LINE__) +#else +#define OSCL_CALLOC(num,size) _oscl_default_audit_calloc(num,size) +#endif + +/* +** The public oscl_calloc call has been deprecated. +** PV code should call OSCL_CALLOC. +** This macro is defined for back-compatibility. +*/ +#define oscl_calloc(a,b) OSCL_CALLOC(a,b) + +/** +* Allocates a memory block using the specified +* audit object. The block is initialized to zero. +* +* @param auditCB input memory management audit object +* @param num number of elements +* @param size number of bytes to allocate for each element +* +* @return a void pointer to the allocated space, or NULL if there is insufficient +* memory available. +* +* @exception none +*/ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_AUDIT_CALLOC(auditCB, num,size) _oscl_calloc(num,size) +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_AUDIT_CALLOC(auditCB, num,size) _oscl_audit_calloc(num,size, auditCB, __FILE__, __LINE__) +#else +#define OSCL_AUDIT_CALLOC(auditCB, num,size) _oscl_audit_calloc(num,size, auditCB) +#endif + +/** + * Re-Allocates a memory block using the memory management's + * global audit object. + * + * @param ptr original memory block + * @param new_size New size of the block + * + * @return a void pointer to the allocated space, or NULL if there is insufficient + * memory available. + * + * @exception none + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_REALLOC(ptr,new_size) _oscl_realloc(ptr,new_size) +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_REALLOC(ptr,new_size) _oscl_default_audit_realloc(ptr,new_size,__FILE__,__LINE__) +#else +#define OSCL_REALLOC(ptr,new_size) _oscl_default_audit_realloc(ptr,new_size) +#endif + +/* +** The public oscl_realloc call has been deprecated. +** PV code should call OSCL_REALLOC. This macro is +** defined for back-compatibility. +*/ +#define oscl_realloc(a,b) OSCL_REALLOC(a,b) + +/** +* Re-Allocates a memory block using the specified +* audit object. +* +* @param auditCB input memory management audit object +* @param ptr original memory block +* @param new_size New size of the block +* +* @return a void pointer to the allocated space, or NULL if there is insufficient +* memory available. +* +* @exception none +*/ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_AUDIT_REALLOC(auditCB, ptr,new_size) _oscl_realloc(ptr,new_size) +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_AUDIT_REALLOC(auditCB, ptr,new_size) _oscl_audit_realloc(ptr,new_size, auditCB, __FILE__, __LINE__) +#else +#define OSCL_AUDIT_REALLOC(auditCB, ptr,new_size) _oscl_audit_realloc(ptr,new_size, auditCB) +#endif + +/** + * Deallocates or frees a memory block. + * + * @param ptr pointer to previously allocated memory block using the given audit object + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_FREE(ptr) _oscl_free(ptr) +#else +#define OSCL_FREE(ptr) _oscl_audit_free(ptr) +#endif + +/* +** The public oscl_free call has been deprecated. +** PV code should call OSCL_FREE. +** This macro is defined for back-compatibility. +*/ +#define oscl_free(x) OSCL_FREE(x) + +/** + * Another back-compatibility definition. + */ +#define OSCL_DEFAULT_FREE(x) OSCL_FREE(x) + +/** ******************************************************* + * Macros for new/delete with memory management. + */ + +/** + * Oscl "new" operator. This uses the global memory + * audit object. + * + * @param T data type for 'new' operation + * @param params object initialization parameters + * + * @return pointer to the newly created object of type T + * + * @exception may leave with code = bad alloc + * + * + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_NEW( T, params) new T params +#elif!(OSCL_HAS_GLOBAL_NEW_DELETE) +#define OSCL_NEW( T, params) new T params +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_NEW( T, params) new(__FILE__,__LINE__) T params +#else +#define OSCL_NEW( T, params) new T params +#endif + +/******************************************************** + * Macro for placement new + * + * @param ptr pointer to an object + * + * @param constructor constructor of the class for the object + * +********************************************************/ +#define OSCL_PLACEMENT_NEW(ptr, constructor) new(ptr) constructor + +/** + * Oscl "new" operator. This uses the global memory + * audit object. This operator is similar to OSCL_NEW + * except that it will handle constructors that leave. + * If the constructor leaves, the destructor will be called, + * and allocated memory will be freed before allowing the + * leave to propagate to the next level. + * + * @param T_ptr variable to hold return value-- pointer to + * new object of type T. + * @param T data type for 'new' operation + * @param params object initialization parameters + * + * @return pointer to the newly created object of type T + * + * @exception may leave with code = bad alloc + * + * + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_new(sizeof(T)),_oscl_free,T_ptr,T,params) +#elif!(OSCL_HAS_GLOBAL_NEW_DELETE) +#define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_audit_new(sizeof(T)),_oscl_audit_free,T_ptr,T,params) +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_audit_new(sizeof(T),__FILE__,__LINE__),_oscl_audit_free,T_ptr,T,params) +#else +#define OSCL_TRAP_NEW(T_ptr,T,params) _OSCL_TRAP_NEW(_oscl_default_audit_new(sizeof(T)),_oscl_audit_free,T_ptr,T,params) +#endif + + +/** + * Oscl "new" operator. This uses the specified memory + * audit object. + * + * @param auditCB input memory management audit object + * @param T data type for 'new' operation + * @param params object initialization parameters + * + * @return pointer to the newly created object of type T + * + * @exception may leave with code = bad alloc + * + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_default_new(sizeof(T))) T params +#elif!(OSCL_HAS_GLOBAL_NEW_DELETE) +#define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_audit_new(sizeof(T),auditCB)) T params +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_audit_new(sizeof(T),auditCB,__FILE__,__LINE__)) T params +#else +#define OSCL_AUDIT_NEW(auditCB, T, params) new(_oscl_audit_new(sizeof(T),auditCB)) T params +#endif + +/** + * Oscl "new" operator. This uses the specified memory + * audit object. This macro is similar to OSCL_AUDIT_NEW + * except that it will handle constructors that leave. + * If the constructor leaves, the destructor will be called, + * and allocated memory will be freed before allowing the + * leave to propagate to the next level. + * + * @param T_ptr variable to hold return value-- pointer to + * new object of type T. + * @param auditCB input memory management audit object + * @param T data type for 'new' operation + * @param params object initialization parameters + * + * @return pointer to the newly created object of type T + * + * @exception may leave with code = bad alloc + * + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_TRAP_AUDIT_NEW(T_ptr,auditCB,T,params) _OSCL_TRAP_NEW(_oscl_default_new(sizeof(T)),_oscl_free,T_ptr,T,params) +#elif!(OSCL_HAS_GLOBAL_NEW_DELETE) +#define OSCL_TRAP_AUDIT_NEW(T_ptr,auditCB,T,params) _OSCL_TRAP_NEW(_oscl_audit_new(sizeof(T),auditCB),_oscl_audit_free,T_ptr,T,params) +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_TRAP_AUDIT_NEW(T_ptr,auditCB,T,params) _OSCL_TRAP_NEW(_oscl_audit_new(sizeof(T),auditCB,__FILE__,__LINE__),_oscl_audit_free,T_ptr,T,params) +#else +#define OSCL_TRAP_AUDIT_NEW(T_ptr,auditCB,T,params) _OSCL_TRAP_NEW(_oscl_audit_new(sizeof(T),auditCB),_oscl_audit_free,T_ptr,T,params) +#endif + +/** + * Oscl "delete" operator. + * + * @param ptr pointer to memory block previously allocated with OSCL_NEW + * + * @return void + */ +#define OSCL_DELETE(ptr) {\ + if(ptr){delete(ptr);}\ +} + + +/** ******************************************************* + * Macros for array new/delete with memory management. + * These only work for simple array types and cannot + * be used for class types with constructor/destructors. + * + * Note: some compilers do not support placement array + * new operator, so these macros don't use it. + */ + +/** + * Oscl array "new" operator. This uses the input memory + * audit object. + * + * @param auditCB input memory management audit object + * @param T data type for 'new' operation + * @param count number of elements to create + * + * @return pointer to the newly created object array of type T + * + * @exception may leave with code = bad alloc + * + * + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_default_new(sizeof(T)*(count))) T +#elif!(OSCL_HAS_GLOBAL_NEW_DELETE) +#define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_audit_new(sizeof(T)*(count),auditCB)) T +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_audit_new(sizeof(T)*(count),auditCB,__FILE__,__LINE__)) T +#else +#define OSCL_AUDIT_ARRAY_NEW(auditCB, T, count) new(_oscl_audit_new(sizeof(T)*(count),auditCB)) T +#endif + +/** + * Oscl array "new" operator. This uses the global memory + * audit object. + * + * @param T data type for 'new' operation + * @param count number of elements to create + * + * @return pointer to the newly created object array of type T + * + * @exception may leave with code = bad alloc + * + * + */ +#if(OSCL_BYPASS_MEMMGT) +#define OSCL_ARRAY_NEW(T, count) new T[count] +#elif!(OSCL_HAS_GLOBAL_NEW_DELETE) +#define OSCL_ARRAY_NEW(T, count) new T[count] +#elif(PVMEM_INST_LEVEL>0) +#define OSCL_ARRAY_NEW(T, count) new(__FILE__,__LINE__) T[count] +#else +#define OSCL_ARRAY_NEW(T, count) new T[count] +#endif + +/** + * Oscl array delete operator.. + * + * @param ptr pointer to memory block previously allocated with OSCL_ARRAY_NEW + * + * @return void + */ +#define OSCL_ARRAY_DELETE(ptr) delete [] ptr + + +/** +* Previously this was in oscl_mem_imp.h +*/ + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_REFCOUNTER_H_INCLUDED +#include "oscl_refcounter.h" +#endif + +#ifndef OSCL_MEM_BASIC_FUNCTIONS_H_INCLUDED +#include "oscl_mem_basic_functions.h" +#endif + +#ifndef OSCL_ERROR_H_INCLUDED +#include "oscl_error.h" +#endif + +#ifndef OSCL_EXCEPTION_H_INCLUDED +#include "oscl_exception.h" +#endif + +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + +/** \class OsclMemAllocator +** A simple allocator class. Configurable as to whether +** this goes through the memory manager or not. +** +*/ +class OsclMemAllocator : public Oscl_DefAlloc +{ + public: + /** This API throws an exception when malloc returns NULL. + * n must be greater than 0. + * + * @return pointer (or Leave with OsclErrNoMemory ) + * + */ + OsclAny* allocate(const uint32 n) + { +#if(OSCL_BYPASS_MEMMGT) + OsclAny* p = _oscl_malloc(n); + if (!p) + OsclError::LeaveIfNull(p); +#if OSCL_MEM_FILL_WITH_PATTERN + oscl_memset(p, 0x55, n); +#endif + return (p); +#elif (PVMEM_INST_LEVEL>0) + //this is really a usage error-- caller should provide file & line. + //set a debug breakpoint here... + return allocate_fl(n, __FILE__, __LINE__); +#else + return allocate_fl(n, NULL, 0); +#endif + } + +#if(!OSCL_BYPASS_MEMMGT) + OsclAny* allocate_fl(const uint32 n, const char * file_name, const int line_num) + { + OsclAny* p = _oscl_default_audit_malloc(n, file_name, line_num); + if (!p) + OsclError::LeaveIfNull(p); +#if OSCL_MEM_FILL_WITH_PATTERN + oscl_memset(p, 0x55, n); +#endif + return (p); + } +#endif + + void deallocate(OsclAny* p) + { + if (p) + OSCL_FREE(p); + } +}; + + +/** \class OsclMemBasicAllocator +** A simple allocator class that does not use the memory management. +** +** Note: this allocator is for internal use by Oscl only. Higher +** level code should use OsclMemAllocator. +** +*/ +class OsclMemBasicAllocator : public Oscl_DefAlloc +{ + public: + /** This API throws an exception when malloc returns NULL. + * n must be greater than 0. + * + * @return pointer (or Leave with OsclErrNoMemory ) + * + */ + OsclAny* allocate(const uint32 n) + { + OsclAny* p = _oscl_malloc(n); + OsclError::LeaveIfNull(p); +#if OSCL_MEM_FILL_WITH_PATTERN + oscl_memset(p, 0x55, n); +#endif + return (p); + } + + void deallocate(OsclAny* p) + { + if (p) + _oscl_free(p); + } +}; + +/** \class OsclMemAllocDestructDealloc +** An OsclAllocDestructDealloc class that uses +** OsclMemAllocator. +*/ +template class OsclMemAllocDestructDealloc : public OsclAllocDestructDealloc +{ + public: +#if !(OSCL_BYPASS_MEMMGT) + OsclAny* allocate_fl(const uint32 size, const char * file_name, const int line_num) + { + return alloc.allocate_fl(size, file_name, line_num); + } +#endif + OsclAny* allocate(const uint32 size) + { +#if(OSCL_BYPASS_MEMMGT) + return alloc.allocate(size); +#elif(PVMEM_INST_LEVEL>0) + //this is really a usage error-- caller should provide file & line. + //set a debug breakpoint here... + return allocate_fl(size, __FILE__, __LINE__); +#else + return allocate_fl(size, NULL, 0); +#endif + } + void deallocate(OsclAny* p) + { + alloc.deallocate(p); + } + void destruct_and_dealloc(OsclAny* p) + { + T* ptr = reinterpret_cast(p); + ptr->~T(); + deallocate(p); + OSCL_UNUSED_ARG(ptr); // removes warning on some compilers + } + private: + OsclMemAllocator alloc; +}; + +/** \class OsclMemBasicAllocDestructDealloc +** An OsclAllocDestructDealloc class that uses +** OsclMemBasicAllocator. +*/ +template class OsclMemBasicAllocDestructDealloc : public OsclAllocDestructDealloc +{ + public: + OsclAny* allocate(const uint32 size) + { +#if(OSCL_BYPASS_MEMMGT) + return alloc.allocate(size); +#else + return alloc.allocate_fl(size, NULL, 0); +#endif + } + void deallocate(OsclAny* p) + { + alloc.deallocate(p); + } + void destruct_and_dealloc(OsclAny* p) + { + T* ptr = reinterpret_cast(p); + ptr->~T(); + deallocate(p); + OSCL_UNUSED_ARG(ptr); // removes warning on some compilers + } + private: + OsclMemBasicAllocator alloc; +}; + +/** + * This class is used to get a pointer to the global audit object. + */ + +class OsclMemAudit; +class OsclMemGlobalAuditObject +{ + public: + typedef OsclMemAudit audit_type; + /** + * returns the global audit object. For use + * in macros only-- not a public API. + */ + OSCL_IMPORT_REF static audit_type* getGlobalMemAuditObject(); + + private: + /** + * creates the global audit object + */ + static void createGlobalMemAuditObject(); + + /** + * deletes the global audit object + */ + static void deleteGlobalMemAuditObject(); + + friend class OsclMem; +}; + +/** +* HeapBase is the base class for all classes that allocates memory. +* +* HeapBase has overloaded new and delete operators. +* +* Derived from _OsclHeapBase providing CBase* alike pointer and virtual destructor for cleanupstack +* to Push and Pop for cleanup when leave occurs. +* +* HeapBase has a virtual destructor which calls the destructor of all the derived classes. +*/ + +class HeapBase : public _OsclHeapBase +{ + public: +#if (OSCL_HAS_HEAP_BASE_SUPPORT) + +#if(!OSCL_BYPASS_MEMMGT) + static void* operator new(size_t aSize, const char *aFile = NULL, const int aLine = 0) + { +#if(PVMEM_INST_LEVEL>0) + //in case NULL is passed in, record this file & line # + if (!aFile) + return _oscl_default_audit_new(aSize, __FILE__, __LINE__); +#endif + return _oscl_default_audit_new(aSize, aFile, aLine); + } +#else + static void* operator new(size_t aSize) + { + return _oscl_default_new(aSize); + } +#endif + + static void* operator new[](size_t aSize) + { +#if(!OSCL_BYPASS_MEMMGT) + return _oscl_default_audit_new(aSize); +#else + return _oscl_default_new(aSize); +#endif + } + + static void* operator new[](size_t aSize, const char *aFile = NULL, const int aLine = 0) + { +#if(!OSCL_BYPASS_MEMMGT) +#if(PVMEM_INST_LEVEL>0) + //in case NULL is passed in, record this file & line # + if (!aFile) + return _oscl_default_audit_new(aSize, __FILE__, __LINE__); +#endif + return _oscl_default_audit_new(aSize, aFile, aLine); +#else + OSCL_UNUSED_ARG(aFile); + OSCL_UNUSED_ARG(aLine); + return _oscl_default_new(aSize); +#endif + } + + static void* operator new(size_t aSize, void *aPtr) + { + return aPtr; + } + + static void operator delete(void* aPtr) + { +#if(!OSCL_BYPASS_MEMMGT) + _oscl_audit_free(aPtr); +#else + _oscl_free(aPtr); +#endif + } + + static void operator delete[](void* aPtr) + { +#if(!OSCL_BYPASS_MEMMGT) + _oscl_audit_free(aPtr); +#else + _oscl_free(aPtr); +#endif + } +#endif //OSCL_HAS_HEAP_BASE_SUPPORT + HeapBase() {}; + virtual ~HeapBase() {}; +}; + +/** Internal-use macro to catch leaves +*in constructors. If the constructor leaves, +*this will free the memory +*before allowing the leave to propagate to the next +*level. It is the constructor's responsibility to +*cleanup any memory in the partially constructed +*object before leaving. This cleanup may include +*cleaning up the base class using the OSCL_CLEANUP_BASE_CLASS +*macro. +* +* @param exp: expression to allocate memory. +* @param Tptr:variable to hold result. +* @param T: type +* @param params: constructor arg list +* @param freeFunc: delete or free function. +*/ +#define _OSCL_TRAP_NEW(exp,freeFunc,T_ptr,T,params)\ +{\ + int32 __err;\ + OsclAny*__ptr=exp;\ + OSCL_TRY(__err,T_ptr=new(__ptr) T params;);\ + if(__err){\ + freeFunc(__ptr);\ + T_ptr=NULL;\ + OsclError::Leave(__err);\ + }\ +} + +/** + * This macro is used to cleanup the + * base class in a derived-class constructor + * just before a leave occurs. + * + * @param T: base class name. + */ +#ifdef PVERROR_IMP_CPP_EXCEPTIONS +//when using C++ exceptions, base class cleanup is automatic +#define _OSCL_CLEANUP_BASE_CLASS(T) +#else +//otherwise the destructor needs to be called explicitly. +#define _OSCL_CLEANUP_BASE_CLASS(T) this->T::~T() +#endif + + +/*! @} */ + + +#if (!OSCL_DISABLE_INLINES) +#include "oscl_mem.inl" +#endif + +#endif // OSCL_MEM_H_INCLUDED + + + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem.inl new file mode 100644 index 0000000..4dcd304 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem.inl @@ -0,0 +1,39 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// Basic memory manipulation functions +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + + +OSCL_INLINE OSCL_COND_EXPORT_REF uint oscl_mem_aligned_size(uint x) +{ + uint y; + + if (x & 0x7) + { + y = x & (~0x7); + y += 8; + } + else + { + y = x; + } + + return y; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_audit.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_audit.cpp new file mode 100644 index 0000000..8e95173 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_audit.cpp @@ -0,0 +1,1485 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/*! \file oscl_mem_audit.cpp + \brief This file contains the implementation of MM_Audit class +*/ +#include "osclconfig_memory.h" + +#if (!OSCL_BYPASS_MEMMGT) + +#include "oscl_types.h" +#include "oscl_mem.h" +#include "oscl_mem_audit.h" +#include "oscl_mem_audit_internals.h" +#include "oscl_assert.h" +#include "oscl_stdstring.h" + + +#if MM_AUDIT_FENCE_SUPPORT +const uint32 PRE_PAD_SIZE = sizeof(MM_AllocBlockFence); +const uint32 POST_FENCE_SIZE = sizeof(MM_AllocBlockFence); +#else +const uint32 PRE_PAD_SIZE = 0; +const uint32 POST_FENCE_SIZE = 0; +#endif + +const uint32 CONTROL_HEADER_SIZE = sizeof(MM_AllocBlockHdr); +const uint32 BLOCK_HDR_SIZE = CONTROL_HEADER_SIZE + PRE_PAD_SIZE; +const uint32 BLOCK_OVERHEAD_SIZE = BLOCK_HDR_SIZE + POST_FENCE_SIZE; + + +/** + * MM_Audit_Imp constructor and descontructor + */ + +/* ======================================================================== */ +/* Function : MM_Audit() */ +/* Date : 10/08/2002 */ +/* Purpose : Constructor, create the root node in statistics table */ +/* In/out : */ +/* Return : */ +/* Modified : */ +/* ======================================================================== */ + +const char root_tag[] = ""; + +MM_Audit_Imp::MM_Audit_Imp() +{ + mpCurrAllocNode = mpAllocNode = NULL; + mNumAllocNodes = 0; + + prefill_pattern = DEFAULT_PREFILL_PATTERN; + postfill_pattern = DEFAULT_POSTFILL_PATTERN; + + mpStatsNode = NULL; + mnAllocNum = 0; + mnMaxTagLevel = 10; + + mm_audit_per_block_overhead = 0; + mm_audit_stats_overhead = 0; + + mode = DEFAULT_MM_AUDIT_MODE; + + /* create root node in memory statistics table */ + mpStatsNode = createStatsNode(root_tag); +} + +/* ======================================================================== */ +/* Function : ~MM_Audit() */ +/* Date : 10/08/2002 */ +/* Purpose : destructor, remove all the nodes in allocation and */ +/* statistics table */ +/* In/out : */ +/* Return : */ +/* Modified : */ +/* ======================================================================== */ + +MM_Audit_Imp::~MM_Audit_Imp() +{ + +#if MM_AUDIT_ALLOC_NODE_SUPPORT + /** + * Delete all the allocation nodes + */ + removeALLAllocNodes(); + mpAllocNode = mpCurrAllocNode = NULL; + mnAllocNum = 0; +#endif + + /** + * Delete all the statistics nodes + */ + mpStatsNode = NULL; + + mTagTree.clear(); +} + + +/* +* ===================== API FUNCTIONS: MM_xxx() ================================== +*/ + +/* ============================================================================ */ +/* Function : MM_allocate() */ +/* Date : 10/08/2002 */ +/* Purpose : API for a memory allocation attempt: create a new node in */ +/* allocation table and update/create the corresponding node in */ +/* statistics table */ +/* In/out : all parameters are input */ +/* Return : memory pointer, if something is wrong, the pointer will be NULL */ +/* Modified : */ +/* ============================================================================ */ + +OSCL_EXPORT_REF void* MM_Audit_Imp::MM_allocate(const OsclMemStatsNode* pInStatsNode, + uint32 sizeIn, + const char *pFileName, + uint32 lineNumber, + bool allocNodeTracking) +{ + +#if defined(DEBUG_ENABLE) + PVUStackTrace(); + if (pFileName) + { + printf("In MM_allocate, nBytes %d, file_name is %s, line_num is %d\n", sizeIn, pFileName, lineNumber); + } + else + { + printf("In MM_allocate with tag %s operator, nBytes %d\n", sizeIn); + } +#endif + + MMAuditUint8AutoPtr pMem; + void *pMem_out = NULL; + +#if (MM_AUDIT_ALLOC_NODE_SUPPORT && MM_AUDIT_INCLUDE_ALL_HEAP_VALIDATION) + if (mode & MM_AUDIT_VALIDATE_ALL_HEAP_FLAG) + { + validate_all_heap(); + } +#endif + + OsclMemStatsNode* pStatsNode; + if (pInStatsNode) + { + // remove "constness" of the stats node so it can be updated. + pStatsNode = const_cast(pInStatsNode); + } + else + { + pStatsNode = mpStatsNode; // set to the root node. + } + + uint32 full_size = sizeIn + BLOCK_OVERHEAD_SIZE; + +#if MM_AUDIT_FAILURE_SIMULATION_SUPPORT + if (!isSetFailure(pStatsNode)) + { + pMem.allocate(full_size); + } +#else + if (full_size > sizeIn) + { + pMem.allocate(full_size); + } +#endif + + if (!pMem.get()) + { + updateStatsNodeInFailure(pStatsNode); + return NULL; + } + + + MM_AllocNode* pAllocNode = NULL; +#if MM_AUDIT_ALLOC_NODE_SUPPORT + + if ((mode & MM_AUDIT_ALLOC_NODE_ENABLE_FLAG) || allocNodeTracking || + (sizeIn & MM_AllocBlockHdr::ALLOC_NODE_FLAG)) + { + if ((pAllocNode = addAllocNode((void *)pMem.get(), sizeIn, pStatsNode, pFileName, lineNumber)) == NULL) + { + updateStatsNodeInFailure(pStatsNode); + return NULL; + } + } +#endif + + // now write the header to the block + MM_AllocBlockHdr *block_hdr = + static_cast(static_cast(pMem.get())); + block_hdr->size = sizeIn; + if (pAllocNode) + { + block_hdr->setAllocNodeFlag(); + block_hdr->pNode = pAllocNode; + } + else + { + block_hdr->pNode = pStatsNode; + } + + /** + * Save the root audit node pointer in the header. + * This pointer will be used when the block is deallocated. + */ + OsclAuditCB audit; + OsclMemInit(audit); + block_hdr->pRootNode = audit.pAudit; + +#if MM_AUDIT_FILL_SUPPORT + if ((mode & MM_AUDIT_PREFILL_FLAG)) + { + oscl_memset(pMem.get() + BLOCK_HDR_SIZE, prefill_pattern, sizeIn); + } +#endif + + +#if MM_AUDIT_FENCE_SUPPORT + /* fill the pre-fence */ + MM_AllocBlockFence *pFence = + static_cast(static_cast(pMem.get() + + CONTROL_HEADER_SIZE)); + pFence->fill_fence(); + + /* fill the post-fence */ + uint32 post_fence_offset = sizeIn + BLOCK_HDR_SIZE; + pFence = + static_cast(static_cast(pMem.get() + + post_fence_offset)); + pFence->fill_fence(); +#endif + + + /* 8-byte alignment */ + pMem_out = pMem.get() + BLOCK_HDR_SIZE; + MM_Stats_t delta; + delta.numBytes = sizeIn; + delta.numAllocs = 1; + delta.numAllocFails = 0; + updateStatsNode(pStatsNode, delta, true); + + pMem.release(); // release so it doesn't free up memory on exit + + // account for the per-block overhead + mm_audit_per_block_overhead += BLOCK_OVERHEAD_SIZE; + return pMem_out; + +} + +/* ============================================================================ */ +/* Function : MM_deallocate() */ +/* Date : 10/08/2002 */ +/* Purpose : API for a memory de-allocation attempt: remove a node in */ +/* allocation table and update the corresponding node in */ +/* statistics table */ +/* In/out : all parameters are input */ +/* Return : */ +/* Modified : */ +/* ============================================================================ */ + +OSCL_EXPORT_REF bool MM_Audit_Imp::MM_deallocate(void *pMemBlockIn) +{ + if (!pMemBlockIn) return false; + + if (mpStatsNode == NULL || + (mpStatsNode && mpStatsNode->pMMStats && mpStatsNode->pMMStats->peakNumBytes == 0)) /* No actual allocation happens */ + { + return true; + } + +#if (MM_AUDIT_ALLOC_NODE_SUPPORT && MM_AUDIT_INCLUDE_ALL_HEAP_VALIDATION) + if (mode & MM_AUDIT_VALIDATE_ALL_HEAP_FLAG) + { + validate_all_heap(); + } +#endif + + bool status = true; +#if MM_AUDIT_VALIDATE_BLOCK + if (mode & MM_AUDIT_VALIDATE_ON_FREE_FLAG) + { + if (!validate(pMemBlockIn)) + { + return false; + } + } +#endif + + uint8 *pMem = static_cast(pMemBlockIn); + pMem -= BLOCK_HDR_SIZE; + + OsclMemStatsNode *pStatsNode = NULL; + MM_AllocBlockHdr *pMemBlockHdr = + static_cast(static_cast(pMem)); + uint32 size = pMemBlockHdr->size; + +#if MM_AUDIT_ALLOC_NODE_SUPPORT + if (size & MM_AllocBlockHdr::ALLOC_NODE_FLAG) + { + pStatsNode = removeAllocNode((void *)pMem, size); + OSCL_ASSERT(pStatsNode); + } +#endif + + if (!pStatsNode) + { + pStatsNode = static_cast(pMemBlockHdr->pNode); + } + /** + * 3/1. update the node in memory statistics table + */ + MM_Stats_t delta; + delta.numAllocs = 1; + delta.numBytes = size; + delta.numAllocFails = 0; + status = updateStatsNode(pStatsNode, delta, false); + +#if MM_AUDIT_FILL_SUPPORT + if ((mode & MM_AUDIT_POSTFILL_FLAG)) + { + oscl_memset(pMem + BLOCK_HDR_SIZE, postfill_pattern, size); + } +#endif + + + MMAuditUint8AutoPtr::deallocate(pMem); + + // account for the per-block overhead + mm_audit_per_block_overhead -= BLOCK_OVERHEAD_SIZE; + + + return status; +} + + +/* ============================================================================ */ +/* Function : MM_GetTreeNodes() */ +/* Date : 10/31/2002 */ +/* Purpose : API to get the number of tree nodes including the tag node and */ +/* its subtree */ +/* In/out : all parameters are input */ +/* Return : 0 means no tag node ; >0 means the number of tree nodes */ +/* Modified : */ +/* ============================================================================ */ + +OSCL_EXPORT_REF uint32 MM_Audit_Imp::MM_GetTreeNodes(const char * tagIn) +{ + int32 count = 0; + + MMAuditCharAutoPtr tag; + makeValidTag(tagIn, tag); //tagIn = NULL means root tag + OsclTagTreeType::iterator iter = mTagTree.find(tag.get()); + + if (iter != mTagTree.end()) + { + count++; //to account for the parent + count = iter->children.size(); + } + return ((uint32)count); +} + + + +/* ================================================================================ */ +/* Function : MM_GetStats() */ +/* Date : 10/08/2002 */ +/* Purpose : API to get memory statistics through context string(tag) */ +/* In/out : all parameters are input */ +/* Return : the statistics (pointer) for the current tag node */ +/* if something is wrong, return NULL */ +/* Modified : */ +/* ================================================================================ */ + + +OSCL_EXPORT_REF MM_Stats_t* MM_Audit_Imp::MM_GetStats(const char * const tagIn) +{ + MM_Stats_t *pMMStats = NULL; + MMAuditCharAutoPtr tag; + makeValidTag(tagIn, tag); //tagIn = NULL means root tag + OsclTagTreeType::iterator iter = mTagTree.find(tag.get()); + + if (iter != mTagTree.end()) + { + /* Got it! */ + OsclMemStatsNode *pStatsNode = (iter->value).get(); + if (pStatsNode) + { + pMMStats = pStatsNode->pMMStats; + } + } + return pMMStats; +} + + +OSCL_EXPORT_REF uint32 MM_Audit_Imp::MM_GetStatsInDepth(const char *tagIn, + MM_Stats_CB *array_ptr, + uint32 max_nodes) +{ + uint32 curr_array_index = 0; + populateChildren(tagIn, array_ptr, curr_array_index, max_nodes); + return (curr_array_index); +} + + +/* ============================================================================ */ +/* Function : getNodeChildren() */ +/* Date : 10/08/2002 */ +/* Purpose : recursive function to go throught each child node for the */ +/* current node and counter it */ +/* In/out : all parameters are input */ +/* Return : */ +/* Modified : */ +/* ============================================================================ */ + +void MM_Audit_Imp::populateChildren(const char *tagIn, + MM_Stats_CB *array_ptr, + uint32 &curr_array_index, + uint32 max_nodes) +{ + MMAuditCharAutoPtr tag; + makeValidTag(tagIn, tag); //tagIn = NULL means root tag + OsclTagTreeType::iterator miter = mTagTree.find(tag.get()); + + if (curr_array_index > max_nodes) + { + return; + } + + if (miter != mTagTree.end() && max_nodes > 0) + { + uint32 num_children = miter->children.size(); + + miter->sort_children(); + + array_ptr[curr_array_index].num_child_nodes = num_children; + + for (uint32 i = 0; i < num_children; i++) + { + array_ptr[curr_array_index].tag = (miter->tag).tag; + + OsclMemStatsNode *pStatsNode = (miter->value).get(); + if (pStatsNode) + { + array_ptr[curr_array_index].pStats = pStatsNode->pMMStats; + } + curr_array_index++; + + if (curr_array_index > max_nodes) + { + return; + } + } + + /* access its children nodes */ + if (!miter->children.empty()) + { + /* recursive search */ + for (uint32 i = 0; i < num_children; i++) + { + populateChildren((miter->children[i]->tag).tag, + array_ptr, + curr_array_index, + max_nodes); + } + } + } + + return; +} + +/* ============================================================================ */ +/* Function : MM_GetTag() */ +/* Date : 10/08/2002 */ +/* Purpose : API to get an StatsNode or creates one if it doesn't exist */ +/* In/out : all parameters are input */ +/* Return : pointer to OsclMemStatsNode if operation succeeds, NULL otherwise */ +/* Modified : */ +/* ============================================================================ */ + +OSCL_EXPORT_REF const OsclMemStatsNode* MM_Audit_Imp::MM_GetTagNode(const char * tagIn) +{ + MMAuditCharAutoPtr tag; + makeValidTag(tagIn, tag); //tagIn = NULL means root tag + OsclTagTreeType::iterator iter = mTagTree.find(tag.get()); + if (iter != mTagTree.end()) + return ((iter->value).get()); + else + return createStatsNode(tag.get()); /* create a new empty node */ +} + +/* ============================================================================ */ +/* Function : MM_GetTag() */ +/* Date : 10/08/2002 */ +/* Purpose : API to get an existing node */ +/* In/out : all parameters are input */ +/* Return : pointer to OsclMemStatsNode if operation succeeds, NULL otherwise */ +/* Modified : */ +/* ============================================================================ */ + +OSCL_EXPORT_REF const OsclMemStatsNode* MM_Audit_Imp::MM_GetExistingTag(const char * tagIn) +{ + MMAuditCharAutoPtr tag; + makeValidTag(tagIn, tag); //tagIn = NULL means root tag + OsclTagTreeType::iterator iter = mTagTree.find(tag.get()); + if (iter != mTagTree.end()) + return ((iter->value).get()); + else + return NULL; +} + + + + +/* ============================================================================ */ +/* Function : MM_Validate() */ +/* Date : 10/08/2002 */ +/* Purpose : API to check the input pointer is a valid pointer to a chunk of */ +/* memory */ +/* In/out : all parameters are input */ +/* Return : */ +/* Modified : */ +/* ============================================================================ */ + +OSCL_EXPORT_REF bool MM_Audit_Imp::MM_Validate(const void *ptrIn) +{ + bool status = validate(const_cast(ptrIn)); + return status; +} + +/* ============================================================================ */ +/* Function : MM_SetTagLevel() */ +/* Date : 10/08/2002 */ +/* Purpose : API to set the maximum tag level,i.e. tag level for a.b.c.d = 4 */ +/* In/out : all parameters are input */ +/* Return : */ +/* Modified : */ +/* ============================================================================ */ + +OSCL_EXPORT_REF void MM_Audit_Imp::MM_SetTagLevel(uint32 level) +{ + if (level >= 1) mnMaxTagLevel = level; +} + + +OSCL_EXPORT_REF void MM_Audit_Imp::MM_SetMode(uint32 in_mode) +{ + mode = in_mode; +} + + +OSCL_EXPORT_REF void MM_Audit_Imp::MM_SetPrefillPattern(uint8 pattern) +{ + prefill_pattern = pattern; +} + + +OSCL_EXPORT_REF void MM_Audit_Imp::MM_SetPostfillPattern(uint8 pattern) +{ + postfill_pattern = pattern; +} + +OSCL_EXPORT_REF MM_AllocQueryInfo* MM_Audit_Imp::MM_CreateAllocNodeInfo(uint32 array_size) +{ + return(MM_AllocQueryInfo*)_oscl_malloc(array_size*sizeof(MM_AllocQueryInfo)); +} + +OSCL_EXPORT_REF void MM_Audit_Imp::MM_ReleaseAllocNodeInfo(MM_AllocQueryInfo* output_array) +{ + _oscl_free(output_array); +} + +OSCL_EXPORT_REF uint32 MM_Audit_Imp::MM_GetAllocNodeInfo(MM_AllocQueryInfo* output_array, + uint32 max_array_size, uint32 offset) +{ + uint32 num_nodes = 0; + + if (!output_array) + { + return 0; + }; + + + if (offset >= mNumAllocNodes) + { + return 0; + } + + MM_AllocNode *pAllocNode = mpAllocNode; + + // skip the leading nodes + uint32 ii; + for (ii = 0; pAllocNode && ii < offset; ++ii, pAllocNode = pAllocNode->pNext) + { + } + + if (ii != offset) + { + return 0; + } + + MM_AllocQueryInfo* pOutNode = output_array; + + while (pAllocNode && (num_nodes < max_array_size)) + { + + pOutNode->allocNum = pAllocNode->pAllocInfo->allocNum; + pOutNode->lineNo = pAllocNode->pAllocInfo->lineNo; + pOutNode->size = pAllocNode->pAllocInfo->size; + pOutNode->pMemBlock = pAllocNode->pAllocInfo->pMemBlock; + pOutNode->size = pAllocNode->pAllocInfo->size; + + if (pAllocNode->pAllocInfo->pFileName) + { + oscl_strncpy(pOutNode->fileName, pAllocNode->pAllocInfo->pFileName, + oscl_strlen(pAllocNode->pAllocInfo->pFileName) + 1); + pOutNode->fileName[MM_ALLOC_MAX_QUERY_FILENAME_LEN-1] = '\0'; + } + else + { + pOutNode->fileName[0] = '\0'; + } + + if (pAllocNode->pAllocInfo->pStatsNode->tag) + { + oscl_strncpy(pOutNode->tag, pAllocNode->pAllocInfo->pStatsNode->tag, + oscl_strlen(pAllocNode->pAllocInfo->pStatsNode->tag) + 1); + pOutNode->tag[MM_ALLOC_MAX_QUERY_TAG_LEN-1] = '\0'; + } + else + { + pOutNode->tag[0] = '\0'; + } + + ++num_nodes; + ++pOutNode; + pAllocNode = pAllocNode->pNext; + } + return num_nodes; +} + +/* ============================================================================ */ +/* Function : MM_SetFailurePoint() */ +/* Date : 11/05/2002 */ +/* Purpose : API to insert allocation failure deterministically according to */ +/* allocation number associated with tag */ +/* In/out : all parameters are input */ +/* Return : true if operation succeeds */ +/* Modified : */ +/* ============================================================================ */ + +OSCL_EXPORT_REF bool MM_Audit_Imp::MM_SetFailurePoint(const char * tagIn, uint32 alloc_number) +{ + if (alloc_number == 0) return false; + + bool status = true; + MMAuditCharAutoPtr tag; + makeValidTag(tagIn, tag); //tagIn = NULL means root tag + OsclTagTreeType::iterator miter = mTagTree.find(tag.get()); + + if (miter != mTagTree.end()) + { + /* found */ + OsclMemStatsNode *pStatsNode = (miter->value).get(); + + if (pStatsNode == NULL || pStatsNode->pMMFIParam == NULL) + { + return false; + } + pStatsNode->pMMFIParam->nAllocNum = alloc_number; + } + else + { + /* Needs to create a new node */ + OsclMemStatsNode *pStatsNode = createStatsNode(tag.get()); + if (pStatsNode == NULL || pStatsNode->pMMFIParam == NULL) + { + return false; + } + pStatsNode->pMMFIParam->nAllocNum = alloc_number; + } + + return status; +} + + +/* ============================================================================ */ +/* Function : MM_UnsetFailurePoint() */ +/* Date : 11/05/2002 */ +/* Purpose : API to cancel the allocation failure point associated with tag */ +/* In/out : all parameters are input */ +/* Return : */ +/* Modified : */ +/* ============================================================================ */ + +OSCL_EXPORT_REF void MM_Audit_Imp::MM_UnsetFailurePoint(const char * tagIn) +{ + MMAuditCharAutoPtr tag; + makeValidTag(tagIn, tag); //tagIn = NULL means root tag + OsclTagTreeType::iterator miter = mTagTree.find(tag.get()); + + if (miter != mTagTree.end()) + { + /* found */ + OsclMemStatsNode *pStatsNode = (miter->value).get(); + if (pStatsNode && pStatsNode->pMMFIParam) + { + pStatsNode->pMMFIParam->nAllocNum = 0; + } + } +} + + +/* +* ===================== PRIVATE (SUPPORTING) FUNCTIONS =========================== +*/ + + +#if MM_AUDIT_ALLOC_NODE_SUPPORT +/* ============================================================================ */ +/* Function : addAllocNode() */ +/* Date : 10/08/2002 */ +/* Purpose : add a node in memory allocation table triggered by an allocation */ +/* attempt, i.e. MM_allocate(); then update/creat the corresponding */ +/* node in memory statistics table */ +/* In/out : all parameters are input */ +/* Return : true if operation succeeds */ +/* Modified : */ +/* ============================================================================ */ + +MM_AllocNode* MM_Audit_Imp::addAllocNode(void *pMemBlockIn, uint32 sizeIn, + OsclMemStatsNode *pStatsNode, + const char *pFileName, uint32 lineNumber + ) +{ + uint32 tmp_overhead_size = 0; + + /** + * 1. allocate memory for a new node + */ + + MM_AllocNodeAutoPtr currAllocAutoPtr(new MM_AllocNode); + if (! currAllocAutoPtr.get()) + { + return NULL; + } + tmp_overhead_size += sizeof(MM_AllocNode); + + MM_AllocInfo* pAllocInfo = currAllocAutoPtr->pAllocInfo = new MM_AllocInfo; + if (pAllocInfo == NULL) + { + return NULL; + } + tmp_overhead_size += sizeof(MM_AllocInfo); + + // allocate space for the filename in AllocInfo + if (pFileName) + { + int len = oscl_strlen(pFileName); + Oscl_TAlloc charAlloc; + if ((pAllocInfo->pFileName = + charAlloc.allocate(len + 1)) == NULL) + { + return NULL; + } + oscl_strncpy(const_cast(pAllocInfo->pFileName), pFileName, oscl_strlen(pFileName) + 1); + tmp_overhead_size += len + 1; + } + + pAllocInfo->allocNum = mnAllocNum; + + //To find memory leaks by allocation number, put a debug breakpoint here, like this: + //if(mnAllocNum==113) + //{ + // mnAllocNum++; + // mnAllocNum--; + //} + + //To find allocations with a NULL filename, put a debug breakpoint here, like this: + //if(pFileName==NULL) + //{ + // mnAllocNum++; + // mnAllocNum--; + //} + + mnAllocNum++; + + pAllocInfo->pMemBlock = pMemBlockIn; + pAllocInfo->size = sizeIn; + pAllocInfo->lineNo = lineNumber; + pAllocInfo->pStatsNode = pStatsNode; + + if (!mpCurrAllocNode) /* First node */ + { + /* mpAllocNode always represents the very first node */ + mpAllocNode = mpCurrAllocNode = currAllocAutoPtr.release(); + } + else + { + OSCL_ASSERT(!mpCurrAllocNode->pNext); + mpCurrAllocNode->pNext = currAllocAutoPtr.release(); + currAllocAutoPtr->pPrev = mpCurrAllocNode; + mpCurrAllocNode = mpCurrAllocNode->pNext; + } + + + /* increment the list counter */ + ++mNumAllocNodes; + + mm_audit_per_block_overhead += tmp_overhead_size; + return mpCurrAllocNode; + +} + +/* ============================================================================ */ +/* Function : removeAllocNode() */ +/* Date : 10/08/2002 */ +/* Purpose : remove a node in memory allocation table triggered by an */ +/* de-allocationattempt, i.e. MM_deallocate() */ +/* In/out : all parameters are input */ +/* Return : true if operation succeeds */ +/* Modified : */ +/* ============================================================================ */ + +OsclMemStatsNode* MM_Audit_Imp::removeAllocNode(void *pMemBlockIn, uint32& size) +{ + + if (pMemBlockIn == NULL) + return NULL; + + OsclMemStatsNode *pStatsNode = NULL; + + OSCL_ASSERT(mpAllocNode); + OSCL_ASSERT(mpCurrAllocNode); + OSCL_ASSERT(mNumAllocNodes); + + /* take the allocation node pointer from the control info header */ + MM_AllocBlockHdr *pMemBlockHdr = static_cast(pMemBlockIn); + MM_AllocNode *pAllocNode = static_cast(pMemBlockHdr->pNode); + if (!pAllocNode) return NULL; + + /* + * 1. remove the current node from the list + */ + if (pAllocNode == mpAllocNode) + { + /* head of the list*/ + mpAllocNode = mpAllocNode->pNext; + if (mpAllocNode) + { + mpAllocNode->pPrev = NULL; + } + else + { + // list is empty + mpCurrAllocNode = mpAllocNode = NULL; + } + } + else if (pAllocNode == mpCurrAllocNode) /* end of the list */ + { + mpCurrAllocNode = mpCurrAllocNode->pPrev; + if (mpCurrAllocNode) + { + mpCurrAllocNode->pNext = NULL; + } + else + { + // list is empty + mpCurrAllocNode = mpAllocNode = NULL; + } + } + else /* somewhere in the list */ + { + MM_AllocNode *pPrevNode = pAllocNode->pPrev; + MM_AllocNode *pNextNode = pAllocNode->pNext; + + OSCL_ASSERT(pPrevNode && pNextNode); + + pPrevNode->pNext = pNextNode; + pNextNode->pPrev = pPrevNode; + } + + /** + * 2. free the memory for the current node + */ + OSCL_ASSERT(pAllocNode->pAllocInfo); + pStatsNode = pAllocNode->pAllocInfo->pStatsNode; + size = pAllocNode->pAllocInfo->size; + + // adjust the overhead accounting + uint32 filename_len = (pAllocNode->pAllocInfo->pFileName) ? oscl_strlen(pAllocNode->pAllocInfo->pFileName) + 1 : 0; + mm_audit_per_block_overhead -= sizeof(MM_AllocNode) + sizeof(MM_AllocInfo) + + filename_len; + + + OSCL_DELETE(pAllocNode); + + + + /* + * decrement the list counter + */ + --mNumAllocNodes; + + + + + return pStatsNode; + +} + +/* ============================================================================ */ +/* Function : removeALLAllocNodes() */ +/* Date : 10/08/2002 */ +/* Purpose : remove all the nodes in memory allocation table needed in */ +/* destructor */ +/* In/out : */ +/* Return : */ +/* Modified : */ +/* ============================================================================ */ + +void MM_Audit_Imp::removeALLAllocNodes() +{ + + while (mpCurrAllocNode) + { + MM_AllocNode *pTmpNode = mpCurrAllocNode; + mpCurrAllocNode = mpCurrAllocNode->pPrev; + if (mpCurrAllocNode) + mpCurrAllocNode->pNext = NULL; + --mNumAllocNodes; + OSCL_DELETE(pTmpNode); + } +} + + +bool MM_Audit_Imp::validate_all_heap() +{ + + // walk the list of allocated nodes + MM_AllocNode *ptr = mpAllocNode; + + if (!ptr) + { + OSCL_ASSERT(mNumAllocNodes == 0); + return true; + } + + uint32 counter; + + OSCL_ASSERT(ptr->pPrev == NULL); + for (counter = 0; ptr; ptr = ptr->pNext, ++counter) + { + MM_AllocBlockHdr *pMemBlockHdr = static_cast(ptr->pAllocInfo->pMemBlock); + + OSCL_ASSERT(pMemBlockHdr->pNode == (void *)ptr); + if (ptr->pNext) + { + OSCL_ASSERT(ptr->pNext->pPrev == ptr); + } + else + { + OSCL_ASSERT(ptr == mpCurrAllocNode); + } + + uint8* pMem = static_cast(static_cast(pMemBlockHdr)); + pMem += BLOCK_HDR_SIZE; + bool status = validate(pMem); + OSCL_ASSERT(status); + if (!status) + { + return false; + } + } + + OSCL_ASSERT(counter == mNumAllocNodes); + + return true; + +} + + +#endif // #if MM_AUDIT_ALLOC_NODE_SUPPORT + +/* ============================================================================ */ +/* Function : validate() */ +/* Date : 11/05/2002 */ +/* Purpose : validate the input pointer to a chunk of memory */ +/* In/out : input the memory pointer */ +/* Return : true if operation succeeds */ +/* Modified : */ +/* ============================================================================ */ + +bool MM_Audit_Imp::validate(void *ptrIn) +{ + if (!ptrIn) return false; + + uint8 *pMem = static_cast(const_cast(ptrIn)); + + pMem -= BLOCK_HDR_SIZE; + + MM_AllocBlockHdr *pMemBlockHdr = + static_cast((void *)pMem); + + OSCL_ASSERT(pMemBlockHdr->pNode); + if (!pMemBlockHdr->pNode) + { + return false; + } + + + OsclMemStatsNode *pStatsNode = NULL; +#if MM_AUDIT_ALLOC_NODE_SUPPORT +#if MM_AUDIT_FENCE_SUPPORT + uint32 size = pMemBlockHdr->size; +#endif + if (pMemBlockHdr->isAllocNodePtr()) + { + MM_AllocNode *pAllocNode = NULL; + pAllocNode = static_cast(pMemBlockHdr->pNode); + OSCL_ASSERT(pAllocNode->pAllocInfo); +#if MM_AUDIT_FENCE_SUPPORT + OSCL_ASSERT(((size ^ pAllocNode->pAllocInfo->size) & (~MM_AllocBlockHdr::ALLOC_NODE_FLAG)) == 0); + size = pAllocNode->pAllocInfo->size; +#endif + pStatsNode = pAllocNode->pAllocInfo->pStatsNode; + } +#endif + + if (!pStatsNode) + { + // must be a stats node + pStatsNode = static_cast(pMemBlockHdr->pNode); + } + + OSCL_ASSERT(pStatsNode->pMMStats); + +#if MM_AUDIT_FENCE_SUPPORT + bool status; + + // check the pre-fence + MM_AllocBlockFence *fence = + static_cast(static_cast(pMem + + CONTROL_HEADER_SIZE)); + status = fence->check_fence(); + if (!status) + { + OSCL_ASSERT(status); + return status; + } + + // check the post fence + fence = + static_cast(static_cast(pMem + + BLOCK_HDR_SIZE + + size)); + status = fence->check_fence(); + if (!status) + { + OSCL_ASSERT(status); + return status; + } +#endif + + return true; +} + +/** Retrieve the audit root pointer from within an allocation block*/ +OsclMemAudit * MM_Audit_Imp::getAuditRoot(void *ptrIn) +{ + if (!ptrIn) return false; + + uint8 *pMem = static_cast(const_cast(ptrIn)); + + pMem -= BLOCK_HDR_SIZE; + + MM_AllocBlockHdr *pMemBlockHdr = + static_cast((void *)pMem); + + return (OsclMemAudit*)pMemBlockHdr->pRootNode; +} + +uint32 MM_Audit_Imp::getSize(void *ptrIn) +{//get original allocation size. + + if (!ptrIn) + return 0; + + uint8 *pMem = static_cast(const_cast(ptrIn)); + + pMem -= BLOCK_HDR_SIZE; + + MM_AllocBlockHdr *pMemBlockHdr = static_cast((void *)pMem); + + //if it's an alloc node we have to strip out the alloc node bit + //from the size field. + if (pMemBlockHdr->isAllocNodePtr()) + { + return pMemBlockHdr->size & ~MM_AllocBlockHdr::ALLOC_NODE_FLAG; + } + else + { + return pMemBlockHdr->size; + } +} + + +/* ============================================================================ */ +/* Function : createStatsNode() */ +/* Date : 10/08/2002 */ +/* Purpose : creat a new node in memory statistics table triggered by an */ +/* allocation attempt, */ +/* In/out : all parameters are input */ +/* Return : true if operation succeeds */ +/* Modified : */ +/* ============================================================================ */ + + +OsclMemStatsNode* MM_Audit_Imp::createStatsNode(const char * tagIn) +{ + OsclTagTreeType::iterator iter; + MMAuditCharAutoPtr currentTag; + OsclMemStatsNode* statsNode; + + /* If the input tag already exists in the tagtree, it should have a pointer value of NULL */ + OSCL_ASSERT((mTagTree.find(const_cast(tagIn)) == mTagTree.end()) || + (mTagTree.find(const_cast(tagIn)))->value.get() == 0); + + statsNode = new OsclMemStatsNode; + if (statsNode == NULL) return NULL; + + currentTag.allocate(oscl_strlen(tagIn) + 1); + if (!currentTag.get()) return NULL; + oscl_strncpy(currentTag.get(), tagIn, oscl_strlen(tagIn) + 1); + statsNode->tag = currentTag.release(); + + if ((statsNode->pMMStats = new MM_Stats_t) == NULL) return NULL; + + if ((statsNode->pMMFIParam = new MM_FailInsertParam) == NULL) return NULL; + + OsclMemStatsNodeAutoPtr statsNodeAutoPtr(statsNode); + + // reassign ownership of the StatsNode to the tag tree + mTagTree[statsNodeAutoPtr->tag] = statsNodeAutoPtr; + + // account for the overhead memory + mm_audit_stats_overhead += sizeof(MM_Stats_t) + + sizeof(MM_FailInsertParam) + + sizeof(OsclMemStatsNode) + + oscl_strlen(currentTag.get()) + 1; + + // how many levels deep is the node we just inserted? + iter = mTagTree.find(statsNodeAutoPtr->tag); + uint32 depth = iter->depth(); + + // the tag tree will automatically create the parent, grandparent, etc. + // make sure each ancestor's stats node is initialized, i.e. initialize each ancestor + // until you reach one that is already initialized. + OsclTagTreeType::node_ptr parent = iter->parent; + for (uint32 ii = 0; ii < depth; ii++) + { + + OSCL_ASSERT(parent != 0); + + // if initialized then we're done + OsclMemStatsNode* tmpStatsNode = (parent->value).get(); + if (tmpStatsNode != NULL) break; + + // create new stats node + tmpStatsNode = new OsclMemStatsNode; + if (tmpStatsNode == NULL) return NULL; + + // copy tag already created by the tag tree + currentTag.allocate(oscl_strlen(parent->tag.tag) + 1); + if (!currentTag.get()) return NULL; + oscl_strncpy(currentTag.get(), parent->tag.tag, oscl_strlen(parent->tag.tag) + 1); + tmpStatsNode->tag = currentTag.release(); + + if ((tmpStatsNode->pMMStats = new MM_Stats_t) == NULL) return NULL; + + if ((tmpStatsNode->pMMFIParam = new MM_FailInsertParam) == NULL) return NULL; + + // set the new stats node to be held by the tag tree + parent->value.takeOwnership(tmpStatsNode); + + // account for the overhead memory + mm_audit_stats_overhead += sizeof(OsclMemStatsNode) + + oscl_strlen(currentTag.get()) + 1 + + sizeof(MM_Stats_t) + + sizeof(MM_FailInsertParam); + + parent = parent->parent; + } + + return statsNode; +} + + +/* ============================================================================ */ +/* Function : updateStatsNode() */ +/* Date : 10/08/2002 */ +/* Purpose : update the node in memory statistics table triggered by an */ +/* allocation/de-alocation attempt, */ +/* In/out : all parameters are input */ +/* Return : true if operation succeeds */ +/* Modified : */ +/* ============================================================================ */ + + +bool MM_Audit_Imp::updateStatsNode(OsclMemStatsNode *pCurrStatsNode, const MM_Stats_t& delta, bool add) +{ + MMAuditCharAutoPtr tag; + makeValidTag((const char*)(pCurrStatsNode->tag), tag); + + //Update + if (!pCurrStatsNode->pMMStats) return false; + pCurrStatsNode->pMMStats->update(delta, add); + + OsclTagTreeType::iterator miter = mTagTree.find(tag.get()); + + uint32 depth = miter->depth(); + + OsclTagTreeType::node_ptr parent = miter->parent; + + for (uint32 i = 0; i < depth; i++) + { + if (!parent->value->pMMStats) return false; + parent->value->pMMStats->update(delta, add); + parent = miter->parent; + } + + return true; +} + + +/* ============================================================================ */ +/* Function : updateStatsNodeInFailure() */ +/* Date : 11/05/2002 */ +/* Purpose : update "pMMStats->numAllocFails" for the current tag node with */ +/* its parent tag nodes */ +/* In/out : all parameters are input */ +/* Return : true if operation succeeds */ +/* Modified : */ +/* ============================================================================ */ +bool MM_Audit_Imp::updateStatsNodeInFailure(const char * tagIn) +{ + MMAuditCharAutoPtr tag; + makeValidTag(tagIn, tag); + OsclTagTreeType::iterator miter = mTagTree.find(tag.get()); + OsclMemStatsNode *pStatsNode; + if (miter != mTagTree.end()) + {/* found */ + pStatsNode = (miter->value).get(); + } + else + { + pStatsNode = mpStatsNode; // update the root node + } + + return updateStatsNodeInFailure(pStatsNode); +} + +bool MM_Audit_Imp::updateStatsNodeInFailure(OsclMemStatsNode * pStatsNode) +{ + MMAuditCharAutoPtr tag; + + if (!pStatsNode) return false; + + makeValidTag((const char*)(pStatsNode->tag), tag); + + if (!pStatsNode->pMMStats) return false; + pStatsNode->pMMStats->numAllocFails++; + + OsclTagTreeType::iterator miter = mTagTree.find(tag.get()); + + uint32 depth = miter->depth(); + + OsclTagTreeType::node_ptr parent = miter->parent; + + for (uint32 i = 0; i < depth; i++) + { + if (!parent->value->pMMStats) return false; + parent->value->pMMStats->numAllocFails++; + parent = miter->parent; + } + + return true; +} + +/* ============================================================================ */ +/* Function : isSetFailure() */ +/* Date : 11/05/2002 */ +/* Purpose : do allocation failure check */ +/* In/out : all parameters are input */ +/* Return : true if operation succeeds */ +/* Modified : */ +/* ============================================================================ */ + +bool MM_Audit_Imp::isSetFailure(const char * tagIn) +{ + MMAuditCharAutoPtr tag; + makeValidTag(tagIn, tag); + OsclTagTreeType::iterator miter = mTagTree.find(tag.get()); + if (miter != mTagTree.end()) /* found */ + { + OsclMemStatsNode *pStatsNode = (miter->value).get(); + return isSetFailure(pStatsNode); + } + + return false; +} + +bool MM_Audit_Imp::isSetFailure(OsclMemStatsNode* pStatsNode) +{ + if (pStatsNode == NULL) return false; + + if (pStatsNode->pMMFIParam == NULL) return false; + + /* decision for deterministic failure insertion */ + if (pStatsNode->pMMFIParam->nAllocNum > 0) + { + /* the "+ 1" term in the computation of total_allocs is to + * count the current allocation + */ + uint32 total_allocs = pStatsNode->pMMStats->peakNumAllocs + 1 + + pStatsNode->pMMStats->numAllocFails ; + + if (total_allocs == pStatsNode->pMMFIParam->nAllocNum) + return true; + } + + return false; +} +/* ========================================================================================== */ +/* Function : retrieveParentTagLength() */ +/* Date : 10/16/2002 */ +/* Purpose : get the length of the parent tag(i.e."a.b.c") of the input tag(i.e. "a.b.c.d") */ +/* current node and counter it */ +/* In/out : all parameters are input */ +/* Return : length of the parent tag(sub-string) of an input tag */ +/* Modified : */ +/* ========================================================================================== */ + +int32 MM_Audit_Imp::retrieveParentTagLength(const char *tag, int32 bound) +{ + if (!tag) return 0; + +#define PV_MIN(a,b) ((a)<(b)? (a):(b)) + + int count = 0; + int len = PV_MIN((int32)(oscl_strlen(tag)), bound); + if (len <= 0) + return 0; + else + { + bool bFound = false; + for (count = len - 1; count >= 0; count--) + { + if (tag[count] == '.') + { + bFound = true; + break; + } + } + if (!bFound) count = 0; + } + + return count + 1; +} + +void MM_Audit_Imp::retrieveParentTag(char *tag) +{ + if (!tag) return; + + int32 len = oscl_strlen(tag); + if (len == 1) + tag[0] = '\0'; + else + { + bool bFound = false; + for (int32 i = len - 1; i >= 0; i--) + { + if (tag[i] == '.') + { + tag[i] = '\0'; + bFound = true; + break; + } + } + if (!bFound) + tag[0] = '\0'; + } +} + +/* ========================================================================================== */ +/* Function : makeValidTag() */ +/* Date : 10/25/2002 */ +/* Purpose : check the input tag and make sure its level would be bounded in maximum tag */ +/* level, if its level is larger, then truncate it */ +/* Note that level of "a.b.c.d" = 4 */ +/* In/out : In: tagIn ; Out: *bFree */ +/* Return : a valid tag within the maximum tag level constraint */ +/* Modified : */ +/* ========================================================================================== */ + +void MM_Audit_Imp::makeValidTag(const char * tagIn, MMAuditCharAutoPtr& autoptr) +{ + + if (tagIn == NULL) + { + //tagIn = NULL means root tag + autoptr.setWithoutOwnership(const_cast(root_tag)); + } + + else + { + uint32 len = getTagActualSize(tagIn); + if (len == 0) + { + /* len = 0 meaning no need of truncation */ + autoptr.setWithoutOwnership(const_cast(tagIn)); + } + + else + { + autoptr.allocate(len + 1); + oscl_strncpy(autoptr.get(), tagIn, len); + *(autoptr.get() + len) = '\0'; + } + } +} + +/* ========================================================================================== */ +/* Function : getTagActualSize() */ +/* Date : 10/25/2002 */ +/* Purpose : get the actual size of an input tag within the maximum tag level constraint */ +/* Note that level of "a.b.c.d" = 4 */ +/* In/out : In: tagIn ; Out: *bFree */ +/* Return : 0 means no truncation ; >0 means truncated size */ +/* Modified : */ +/* ========================================================================================== */ + +uint32 MM_Audit_Imp::getTagActualSize(const char * tagIn) +{ + uint32 i, len; + uint32 level = 0, count = 0; + + len = oscl_strlen(tagIn); + if (len <= 2*mnMaxTagLevel - 1) + return 0; /* no truncation */ + + for (i = 0; i < len; i++) + { + if (tagIn[i] == '.') + { + if (++level == mnMaxTagLevel) + { + count = i; + break; + } + } + } + return count; +} + + +#endif //if OSCL_BYPASS_MEMMGT + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_audit.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_audit.h new file mode 100644 index 0000000..4790a52 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_audit.h @@ -0,0 +1,1286 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M E M _ A U D I T + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclmemory OSCL Memory + * + * @{ + */ + + +/*! \file oscl_mem_audit.h + \brief This file contains the definition and partial implementation of MM_Audit class +*/ + +#ifndef OSCL_MEM_AUDIT_H_INCLUDED +#define OSCL_MEM_AUDIT_H_INCLUDED + +#ifndef OSCL_LOCK_BASE_H_INCLUDED +#include "oscl_lock_base.h" +#endif + +#ifndef OSCL_BASE_ALLOC_H_INCLUDED +#include "oscl_base_alloc.h" +#endif + +#ifndef OSCL_TAGTREE_H_INCLUDED +#include "oscl_tagtree.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#ifndef OSCL_MEM_AUTO_PTR_H_INCLUDED +#include "oscl_mem_auto_ptr.h" +#endif + +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + + +/* DATA TYPES */ +struct MM_Stats_t +{ + uint32 numBytes; + uint32 peakNumBytes; + uint32 numAllocs; + uint32 peakNumAllocs; + uint32 numAllocFails; + uint32 totalNumAllocs; + uint32 totalNumBytes; + + MM_Stats_t() + { + oscl_memset(this, 0, sizeof(MM_Stats_t)); + }; + MM_Stats_t(uint32 sizeIn) + { + numBytes = peakNumBytes = sizeIn; + peakNumAllocs = numAllocs = 1; + numAllocFails = 0; + totalNumAllocs = 1; + totalNumBytes = sizeIn; + }; + + void reset() + { + oscl_memset(this, 0, sizeof(MM_Stats_t)); + }; + + void update(const MM_Stats_t& delta, bool add) + { + if (add) + { + numBytes += delta.numBytes; + numAllocs += delta.numAllocs; + numAllocFails += delta.numAllocFails; + if (numBytes > peakNumBytes) + { + peakNumBytes = numBytes; + } + if (numAllocs > peakNumAllocs) + { + peakNumAllocs = numAllocs; + } + + totalNumAllocs += delta.numAllocs; + totalNumBytes += delta.numBytes; + + } + else + { + numBytes -= delta.numBytes; + numAllocs -= delta.numAllocs; + numAllocFails -= delta.numAllocFails; + } + } + + void *operator new(oscl_memsize_t size) + { + OSCL_UNUSED_ARG(size); + Oscl_TAlloc statsAlloc; + MM_Stats_t *ptr = statsAlloc.allocate(1); + return ptr; + }; + + void *operator new(oscl_memsize_t size, MM_Stats_t* ptr) + { + OSCL_UNUSED_ARG(size); + return ptr; + }; + + + void operator delete(void *ptr) throw() + { + Oscl_TAlloc statsAlloc; + statsAlloc.deallocate((MM_Stats_t*)ptr); + }; + + /* won't build on ADS + void operator delete(void *ptr, MM_Stats_t* mptr) { + OSCL_UNUSED_ARG(ptr); + OSCL_UNUSED_ARG(mptr); + }; + */ +}; + +struct MM_FailInsertParam +{ + uint32 nAllocNum; + uint16 xsubi[3]; + MM_FailInsertParam(): nAllocNum(0) + { + oscl_memset(xsubi, 0, 3*sizeof(xsubi[0])); + } + + void reset() + { + nAllocNum = 0; + oscl_memset(xsubi, 0, 3*sizeof(xsubi[0])); + }; + + void *operator new(oscl_memsize_t size) + { + OSCL_UNUSED_ARG(size); + Oscl_TAlloc failAlloc; + MM_FailInsertParam *ptr = failAlloc.allocate(1); + return ptr; + }; + + void *operator new(oscl_memsize_t size, MM_FailInsertParam* ptr) + { + OSCL_UNUSED_ARG(size); + return ptr; + }; + + + void operator delete(void *ptr) throw() + { + Oscl_TAlloc failAlloc; + failAlloc.deallocate((MM_FailInsertParam*)ptr); + }; + + /* won't build on ADS + void operator delete(void *ptr, MM_FailInsertParam* mptr) { + OSCL_UNUSED_ARG(ptr); + OSCL_UNUSED_ARG(mptr); + };*/ +}; + +class OsclMemStatsNode +{ + public: + + MM_Stats_t *pMMStats; + MM_FailInsertParam *pMMFIParam; + + /* set a link to map, especially for getting the tags of children nodes */ + char *tag; + + OsclMemStatsNode() + { + pMMStats = NULL; + pMMFIParam = NULL; + tag = NULL; + } + + void reset() + { + if (pMMStats) pMMStats->reset(); + if (pMMFIParam) pMMFIParam->reset(); + }; + + ~OsclMemStatsNode() + { + OSCL_DELETE(pMMStats); + OSCL_DELETE(pMMFIParam); + Oscl_TAlloc charAlloc; + charAlloc.deallocate(tag); + } + + void *operator new(oscl_memsize_t size) + { + OSCL_UNUSED_ARG(size); + Oscl_TAlloc statsNodeAlloc; + OsclMemStatsNode *ptr = statsNodeAlloc.allocate(1); + return ptr; + }; + + void *operator new(oscl_memsize_t size, OsclMemStatsNode* ptr) + { + OSCL_UNUSED_ARG(size); + return ptr; + }; + + + void operator delete(void *ptr) throw() + { + Oscl_TAlloc statsNodeAlloc; + statsNodeAlloc.deallocate((OsclMemStatsNode*)ptr); + }; + + /* won't build on ADS + void operator delete(void *ptr, OsclMemStatsNode* mptr) { + OSCL_UNUSED_ARG(ptr); + OSCL_UNUSED_ARG(mptr); + };*/ +}; + +struct MM_Stats_CB +{ + const char *tag; + const MM_Stats_t *pStats; + uint32 num_child_nodes; + + MM_Stats_CB() + { + oscl_memset(this, 0, sizeof(MM_Stats_CB)); + } + + void *operator new(oscl_memsize_t size) + { + OSCL_UNUSED_ARG(size); + Oscl_TAlloc statsCBAlloc; + MM_Stats_CB *ptr = statsCBAlloc.allocate(1); + return ptr; + }; + + void *operator new(oscl_memsize_t size, MM_Stats_CB* ptr) + { + OSCL_UNUSED_ARG(size); + return ptr; + }; + + + void operator delete(void *ptr) throw() + { + Oscl_TAlloc statsCBAlloc; + statsCBAlloc.deallocate((MM_Stats_CB*)ptr); + }; + + /* won't build on ADS + void operator delete(void *ptr, MM_Stats_CB* mptr) { + OSCL_UNUSED_ARG(ptr); + OSCL_UNUSED_ARG(mptr); + };*/ +}; + +#define MM_ALLOC_MAX_QUERY_FILENAME_LEN 128 +#define MM_ALLOC_MAX_QUERY_TAG_LEN 64 + +struct MM_AllocQueryInfo +{ + uint32 allocNum; + char fileName[MM_ALLOC_MAX_QUERY_FILENAME_LEN]; + uint32 lineNo; + uint32 size; + const void *pMemBlock; + char tag[MM_ALLOC_MAX_QUERY_TAG_LEN]; +}; + + +struct MM_AllocInfo +{ + uint32 allocNum; + char *pFileName; + uint32 lineNo; + uint32 size; + void *pMemBlock; + OsclMemStatsNode *pStatsNode; + bool bSetFailure; + + MM_AllocInfo() + { + oscl_memset(this, 0, sizeof(MM_AllocInfo)); + } + + ~MM_AllocInfo() + { + Oscl_TAlloc charAlloc; + charAlloc.deallocate(pFileName); + } + + + void *operator new(oscl_memsize_t size) + { + OSCL_UNUSED_ARG(size); + Oscl_TAlloc allocInfoAlloc; + MM_AllocInfo *ptr = allocInfoAlloc.allocate(1); + return ptr; + }; + + void *operator new(oscl_memsize_t size, MM_AllocInfo* ptr) + { + OSCL_UNUSED_ARG(size); + return ptr; + }; + + + void operator delete(void *ptr) throw() + { + Oscl_TAlloc allocInfoAlloc; + allocInfoAlloc.deallocate((MM_AllocInfo*)ptr); + }; + + /* won't build on ADS + void operator delete(void *ptr, MM_AllocInfo* mptr) { + OSCL_UNUSED_ARG(ptr); + OSCL_UNUSED_ARG(mptr); + };*/ +}; + + +struct MM_AllocNode +{ + MM_AllocInfo *pAllocInfo; + + MM_AllocNode *pPrev; + MM_AllocNode *pNext; + MM_AllocNode() + { + oscl_memset(this, 0, sizeof(MM_AllocNode)); + } + + ~MM_AllocNode() + { + OSCL_DELETE(pAllocInfo); + } + + void *operator new(oscl_memsize_t size) + { + OSCL_UNUSED_ARG(size); + Oscl_TAlloc allocNodeAlloc; + MM_AllocNode *ptr = allocNodeAlloc.allocate(1); + return ptr; + }; + + void *operator new(oscl_memsize_t size, MM_AllocNode* ptr) + { + OSCL_UNUSED_ARG(size); + return ptr; + }; + + + void operator delete(void *ptr) throw() + { + Oscl_TAlloc allocNodeAlloc; + allocNodeAlloc.deallocate((MM_AllocNode*)ptr); + }; + + /* won't build on ADS + void operator delete(void *ptr, MM_AllocNode* mptr) { + OSCL_UNUSED_ARG(ptr); + OSCL_UNUSED_ARG(mptr); + };*/ +}; + + +/* Define internal auto ptr classes that don't go through mem mgmt */ +typedef OSCLMemAutoPtr > MMAuditCharAutoPtr; +typedef OSCLMemAutoPtr > MMAuditUint8AutoPtr; +typedef OSCLMemAutoPtr > MM_AllocNodeAutoPtr; + +typedef OSCLMemAutoPtr > MM_StatsNodeTagTreeType; +typedef OSCLMemAutoPtr > OsclMemStatsNodeAutoPtr; +typedef Oscl_TAlloc TagTree_Allocator; +typedef Oscl_TagTree OsclTagTreeType; + + +#define MM_AUDIT_VALIDATE_BLOCK 1 +#define MM_AUDIT_PREFILL_FLAG 0x1 +#define MM_AUDIT_POSTFILL_FLAG 0x2 +#define MM_AUDIT_VALIDATE_ALL_HEAP_FLAG 0x4 +#define MM_AUDIT_VALIDATE_ON_FREE_FLAG 0x8 +#define MM_AUDIT_ALLOC_NODE_ENABLE_FLAG 0x10 +#define MM_AUDIT_SUPPRESS_FILENAME_FLAG 0x20 + +#if(PVMEM_INST_LEVEL>0) +#define DEFAULT_MM_AUDIT_MODE (MM_AUDIT_PREFILL_FLAG | \ + MM_AUDIT_POSTFILL_FLAG | \ + MM_AUDIT_VALIDATE_ON_FREE_FLAG | \ + MM_AUDIT_ALLOC_NODE_ENABLE_FLAG ) + + + +#else +#define DEFAULT_MM_AUDIT_MODE 0 +#endif + + +struct MM_AuditOverheadStats +{ + uint32 per_allocation_overhead; + uint32 stats_overhead; +}; + +#if OSCL_BYPASS_MEMMGT +//an empty class for compilation only +class MM_Audit_Imp +{ + public: +}; +#else +class MM_Audit_Imp +{ + public: + + /** + * Constructor, create the root node in statistics table + */ + MM_Audit_Imp(); + + /** + * A destructor, remove all the nodes in allocation andstatistics table + */ + ~MM_Audit_Imp(); + + /** + * The following are APIs + t __nothrow_/ + * const __nothrow_ + * @returns the memory pointer if operation succeeds. + */ + OSCL_IMPORT_REF void *MM_allocate(const OsclMemStatsNode* statsNode, + uint32 sizeIn, + const char *pFileName, + uint32 lineNumber, + bool allocNodeTracking = false); + + /** + * @returns true if operation succeeds; + */ + OSCL_IMPORT_REF bool MM_deallocate(void *pMemBlockIn); + + /** + * API to get memory statistics through context string(tag) + * @returns statistics pointer if operation succeeds + */ + OSCL_IMPORT_REF MM_Stats_t * MM_GetStats(const char * const tagIn); + + /** + * API to get memory statistics in detail through context string(tag) including its subtree + * @returns statistics pointer array and actual number of nodes if operation succeeds + */ + OSCL_IMPORT_REF uint32 MM_GetStatsInDepth(const char * tagIn, MM_Stats_CB *array_ptr, uint32 max_nodes); + + /** + * API to get the number of tree nodes including the tag node and its subtree + * @param tagIn input tag + * @returns the number of tree nodes ; 0 means no tag node + */ + OSCL_IMPORT_REF uint32 MM_GetTreeNodes(const char * tagIn); + + /** + * API to add a node and zero out its counters; Note that this tag should be re-used + * @param tagIn input tag + * @returns true if operation succeeds; + */ + OSCL_IMPORT_REF bool MM_AddTag(const char * tagIn) + { + return (MM_GetTagNode(tagIn) != NULL); + }; + + /** + * API to add a node and zero out its counters; + * Note that this tag should be re-used + * @param tagIn input tag + * @returns pointer to OsclMemStatsNode which should be passed to MM_allocate + */ + OSCL_IMPORT_REF const OsclMemStatsNode* MM_GetTagNode(const char * tagIn); + + + /** + * API to add a node and zero out its counters; + * Note that this tag should be re-used + * @param tagIn input tag + * @returns true if operation succeeds; + */ + OSCL_IMPORT_REF const OsclMemStatsNode* MM_GetExistingTag(const char * tagIn); + + + OSCL_IMPORT_REF const OsclMemStatsNode* MM_GetRootNode() + { + return mpStatsNode; + }; + + /** + ** These APIs will allocate and release space for alloc node info, to be + ** used with the MM_GetAllocNodeInfo API. + */ + OSCL_IMPORT_REF MM_AllocQueryInfo* MM_CreateAllocNodeInfo(uint32 max_array_size); + OSCL_IMPORT_REF void MM_ReleaseAllocNodeInfo(MM_AllocQueryInfo* info); + + /** + * API to query the list of alloc nodes. It copies the information + * into the provided output array. + * @param output_array the array where the data will be written + * @param max_array_size the max number of output array elements + * @param offset the offset into the alloc node list from which the + * data should begin. + * @returns the number of valid nodes in the output array + */ + OSCL_IMPORT_REF uint32 MM_GetAllocNodeInfo(MM_AllocQueryInfo* output_array, + uint32 max_array_size, uint32 offset); + + /** + * API to check the input pointer is a valid pointer to a chunk of memory + * @param ptrIn input pointer to be validated + * @returns true if operation succeeds; + */ + OSCL_IMPORT_REF bool MM_Validate(const void *ptrIn); + + /** + * API to get the current allocation number + * @returns the current allocation number + */ + uint32 MM_GetAllocNo(void) + { + return mnAllocNum; + } + + /** + * API to get the overhead statistics for the + * memory used by the mm_audit class. + */ + void MM_GetOverheadStats(MM_AuditOverheadStats& stats) + { + stats.per_allocation_overhead = mm_audit_per_block_overhead; + stats.stats_overhead = mm_audit_stats_overhead; + } + + /** + * API to get the number of allocation nodes (records) + * for allocations that are being tracked individually. + */ + uint32 MM_GetNumAllocNodes() + { + return mNumAllocNodes; + }; + + /** + * API to get the operating mode of the mm_audit class. + */ + uint32 MM_GetMode(void) + { + return mode; + } + + /** + * API to get the prefill pattern. The pattern is used + * to fill the memory before returning it to the caller. + */ + uint8 MM_GetPrefillPattern(void) + { + return prefill_pattern; + } + + /** + * API to get the postfill pattern. The pattern is used + * to fill the memory before freeing it. + */ + uint32 MM_GetPostfillPattern(void) + { + return postfill_pattern; + } + + /** + * API to set the operating mode of the mm_audit class. + */ + OSCL_IMPORT_REF void MM_SetMode(uint32 inMode); + + /** + * API to set the prefill pattern. + */ + OSCL_IMPORT_REF void MM_SetPrefillPattern(uint8 pattern); + + /** + * API to set the postfill pattern. + */ + OSCL_IMPORT_REF void MM_SetPostfillPattern(uint8 pattern); + + /** + * API to set the maximum tag level,i.e. tag level for a.b.c.d = 4 + * @param level input tag level to be set + */ + OSCL_IMPORT_REF void MM_SetTagLevel(uint32 level); + + /** + * API to insert allocation failure deterministically according to allocation number associated with tag + * @param tagIn input tag + * @param alloc_number allocation number associated with tag + * @returns true if operation succeeds; + */ + OSCL_IMPORT_REF bool MM_SetFailurePoint(const char * tagIn, uint32 alloc_number); + + /** + * API to cancel the allocation failure point associated with tag + * @param tagIn input tag + */ + OSCL_IMPORT_REF void MM_UnsetFailurePoint(const char * tagIn); + + + /* + * The following are private member functions + */ + + + /** + * @returns true if operation succeeds; + */ + MM_AllocNode* addAllocNode(void *pMem, uint32 sizeIn, OsclMemStatsNode* pStatsNode, const char *pFileName, uint32 lineNumber); + /** + * @returns true if operation succeeds; + */ + OsclMemStatsNode* removeAllocNode(void *pMemBlockIn, uint32& size); + void removeALLAllocNodes(); + + /** + * @returns true if operation succeeds; + */ + OsclMemStatsNode* createStatsNode(const char * tagIn); + /** + * @returns true if operation succeeds; + */ + bool updateStatsNode(OsclMemStatsNode *pCurrStatsNode, + const MM_Stats_t& pDelta, bool bAdd); + /** + * @returns true if operation succeeds; + */ + bool updateStatsNodeInFailure(const char * tagIn); + bool updateStatsNodeInFailure(OsclMemStatsNode * pStatsNode); + /** + * @returns true if operation succeeds; + */ + bool pruneSubtree(OsclMemStatsNode *pNode); + bool pruneSubtree(const char * tagIn); + + void retrieveParentTag(char *tag); + /** + * @returns the length of a immediate parent tag for the input tag + */ + int32 retrieveParentTagLength(const char *tag, int32 bound); + /** + * @returns a valid tag; NULL will be converted into root tag + */ + void makeValidTag(const char * tagIn, MMAuditCharAutoPtr& autoptr); + /** + * @returns the size of the truncated tag; 0 means NO truncation + */ + uint32 getTagActualSize(const char * tagIn); + /** + * @returns true if operation succeeds; + */ + /** + * @returns true if operation succeeds; + */ + bool isSetFailure(const char * tagIn); + + bool isSetFailure(OsclMemStatsNode * statsNode); + /** + * @returns true if operation succeeds; + */ + static bool validate(void *ptrIn); + + /** + * @returns audit root pointer. + */ + static OsclMemAudit* getAuditRoot(void *ptrIn); + + /** + * @returns original block size. leaves if bad pointer. + */ + static uint32 getSize(void *ptrIn); + + /** + * @returns true if operation succeeds; + */ + bool validate_all_heap(); + + private: + + void populateChildren(const char *tagIn, + MM_Stats_CB *array_ptr, + uint32 &curr_array_index, + uint32 max_nodes); + + /* + * The following are private data members + */ + + /** + * mpAllocNode is for the head of the linked list tracking allocated + * nodes. mpCurrAllocNode is the tail of the list. + */ + MM_AllocNode *mpAllocNode, *mpCurrAllocNode; + + /** + * mNumAllocNodes is for the number of allocated nodes on the + * linked list. + */ + uint32 mNumAllocNodes; + + /** + * mpStatsNode is for storing memory statistics table + */ + OsclMemStatsNode *mpStatsNode; + /** + * a MAP container, mTagTree (key=Tag, value=node addr), + * is for fast search in memory statistics table given the input Tag + */ + OsclTagTreeType mTagTree; + /** + * tag for the root node in memory statistics table + */ + uint32 mnAllocNum; + uint32 mnMaxTagLevel; + uint32 mode; + + uint32 mm_audit_per_block_overhead; + uint32 mm_audit_stats_overhead; + + uint8 prefill_pattern; + uint8 postfill_pattern; + +}; +#endif + +#if OSCL_BYPASS_MEMMGT +//an empty class for compilation only. +class OsclMemAudit +{ + public: +}; +#else +class OsclMemAudit +{ + public: + /** + * Constructor, create the root node in statistics table + */ + OsclMemAudit() + { + void * p = _oscl_malloc(sizeof(MM_Audit_Imp)); + OsclError::LeaveIfNull(p); + + // this will invoke system placement new operator + _pMM_Audit_Imp = OSCL_PLACEMENT_NEW(p, MM_Audit_Imp()); + iLock = &iSingletonLock; + iRefCount = 1; + }; + + /** + * A destructor, remove all the nodes in allocation andstatistics table + */ + ~OsclMemAudit() + { + _pMM_Audit_Imp->~MM_Audit_Imp(); + _oscl_free((void *) _pMM_Audit_Imp); + }; + + /** + * The following are APIs + t __nothrow_/ + * const __nothrow_ + * @returns the memory pointer if operation succeeds. + */ + void *MM_allocate(const OsclMemStatsNode* statsNode, + uint32 sizeIn, + const char *pFileName, + uint32 lineNumber, + bool allocNodeTracking = false) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + void* result = _pMM_Audit_Imp->MM_allocate(statsNode, sizeIn, pFileName, lineNumber, allocNodeTracking); + + iLock->Unlock(); + return result; + }; + + /** + * @returns true if operation succeeds; + */ + bool MM_deallocate(void *pMemBlockIn) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + bool result = _pMM_Audit_Imp->MM_deallocate(pMemBlockIn); + + iLock->Unlock(); + return result; + }; + + /** + * API to get memory statistics through context string(tag) + * @returns statistics pointer if operation succeeds + */ + MM_Stats_t * MM_GetStats(const char * const tagIn) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + MM_Stats_t* result = (_pMM_Audit_Imp->MM_GetStats(tagIn)); + + iLock->Unlock(); + return result; + }; + + /** + * API to get memory statistics in detail through context string(tag) including its subtree + * @returns statistics pointer array and actual number of nodes if operation succeeds + */ + uint32 MM_GetStatsInDepth(const char * tagIn, MM_Stats_CB *array_ptr, uint32 max_nodes) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + uint32 result = (_pMM_Audit_Imp->MM_GetStatsInDepth(tagIn, array_ptr, max_nodes)); + + iLock->Unlock(); + return result; + }; + + /** + * API to get the number of tree nodes including the tag node and its subtree + * @param tagIn input tag + * @returns the number of tree nodes ; 0 means no tag node + */ + uint32 MM_GetTreeNodes(const char * tagIn) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + uint32 result = (_pMM_Audit_Imp->MM_GetTreeNodes(tagIn)); + + iLock->Unlock(); + return result; + }; + + /** + * API to add a node and zero out its counters; Note that this tag should be re-used + * @param tagIn input tag + * @returns true if operation succeeds; + */ + bool MM_AddTag(const char * tagIn) + { + return (MM_GetTagNode(tagIn) != NULL); + }; + + /** + * API to add a node and zero out its counters; + * Note that this tag should be re-used + * @param tagIn input tag + * @returns pointer to OsclMemStatsNode which should be passed to MM_allocate + */ + const OsclMemStatsNode* MM_GetTagNode(const char * tagIn) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + const OsclMemStatsNode* result = (_pMM_Audit_Imp->MM_GetTagNode(tagIn)); + + iLock->Unlock(); + return result; + }; + + + /** + * API to add a node and zero out its counters; + * Note that this tag should be re-used + * @param tagIn input tag + * @returns true if operation succeeds; + */ + const OsclMemStatsNode* MM_GetExistingTag(const char * tagIn) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + const OsclMemStatsNode* result = (_pMM_Audit_Imp->MM_GetExistingTag(tagIn)); + + iLock->Unlock(); + return result; + }; + + + const OsclMemStatsNode* MM_GetRootNode() + { + return (_pMM_Audit_Imp->MM_GetRootNode()); + }; + + /** + * API to query the list of alloc nodes. It copies the information + * into the provided output array. + * @param output_array the array where the data will be written + * @param max_array_size the max number of output array elements + * @param offset the offset into the alloc node list from which the + * data should begin. + * @returns the number of valid nodes in the output array + */ + uint32 MM_GetAllocNodeInfo(MM_AllocQueryInfo* output_array, + uint32 max_array_size, uint32 offset) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + uint32 result = (_pMM_Audit_Imp->MM_GetAllocNodeInfo(output_array, max_array_size, offset)); + + iLock->Unlock(); + return result; + }; + + MM_AllocQueryInfo* MM_CreateAllocNodeInfo(uint32 max_array_size) + { + return _pMM_Audit_Imp->MM_CreateAllocNodeInfo(max_array_size); + } + void MM_ReleaseAllocNodeInfo(MM_AllocQueryInfo* info) + { + _pMM_Audit_Imp->MM_ReleaseAllocNodeInfo(info); + } + + /** + * API to check the input pointer is a valid pointer to a chunk of memory + * @param ptrIn input pointer to be validated + * @returns true if operation succeeds; + */ + bool MM_Validate(const void *ptrIn) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + bool result = (_pMM_Audit_Imp->MM_Validate(ptrIn)); + + iLock->Unlock(); + return result; + }; + + /** + * API to get the current allocation number + * @returns the current allocation number + */ + uint32 MM_GetAllocNo(void) + { + return (_pMM_Audit_Imp->MM_GetAllocNo()); + }; + + /** + * API to get the overhead statistics for the + * memory used by the mm_audit class. + */ + void MM_GetOverheadStats(MM_AuditOverheadStats& stats) + { + _pMM_Audit_Imp->MM_GetOverheadStats(stats); + }; + + /** + * API to get the number of allocation nodes (records) + * for allocations that are being tracked individually. + */ + uint32 MM_GetNumAllocNodes() + { + return (_pMM_Audit_Imp->MM_GetNumAllocNodes()); + }; + + /** + * API to get the operating mode of the mm_audit class. + */ + uint32 MM_GetMode(void) + { + return (_pMM_Audit_Imp->MM_GetMode()); + }; + + /** + * API to get the prefill pattern. The pattern is used + * to fill the memory before returning it to the caller. + */ + uint8 MM_GetPrefillPattern(void) + { + return (_pMM_Audit_Imp->MM_GetPrefillPattern()); + }; + + /** + * API to get the postfill pattern. The pattern is used + * to fill the memory before freeing it. + */ + uint32 MM_GetPostfillPattern(void) + { + return (_pMM_Audit_Imp->MM_GetPostfillPattern()); + }; + + /** + * API to set the operating mode of the mm_audit class. + */ + void MM_SetMode(uint32 inMode) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + _pMM_Audit_Imp->MM_SetMode(inMode); + + iLock->Unlock(); + }; + + /** + * API to set the prefill pattern. + */ + void MM_SetPrefillPattern(uint8 pattern) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + _pMM_Audit_Imp->MM_SetPrefillPattern(pattern); + + iLock->Unlock(); + }; + + /** + * API to set the postfill pattern. + */ + void MM_SetPostfillPattern(uint8 pattern) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + _pMM_Audit_Imp->MM_SetPostfillPattern(pattern); + + iLock->Unlock(); + }; + + /** + * API to set the maximum tag level,i.e. tag level for a.b.c.d = 4 + * @param level input tag level to be set + */ + void MM_SetTagLevel(uint32 level) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + _pMM_Audit_Imp->MM_SetTagLevel(level); + + iLock->Unlock(); + }; + + /** + * API to insert allocation failure deterministically according to allocation number associated with tag + * @param tagIn input tag + * @param alloc_number allocation number associated with tag + * @returns true if operation succeeds; + */ + bool MM_SetFailurePoint(const char * tagIn, uint32 alloc_number) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + bool result = (_pMM_Audit_Imp->MM_SetFailurePoint(tagIn, alloc_number)); + + iLock->Unlock(); + return result; + }; + + + /** + * API to cancel the allocation failure point associated with tag + * @param tagIn input tag + */ + void MM_UnsetFailurePoint(const char * tagIn) + { + // make sure lock is acquired and freed up upon return + iLock->Lock(); + + _pMM_Audit_Imp->MM_UnsetFailurePoint(tagIn); + + iLock->Unlock(); + }; + + int32 MM_GetRefCount() + { + int32 count; + iLock->Lock(); + count = iRefCount; + iLock->Unlock(); + return count; + } + + /** + * API to obtain mem lock ptr + * + */ + + OsclLockBase* GetLock() + { + return iLock; + }; + + /* + * The following are private member functions + */ + + private: + /** + * @returns true if operation succeeds; + */ + MM_AllocNode* addAllocNode(void *pMem, uint32 sizeIn, OsclMemStatsNode* pStatsNode, + const char *pFileName, uint32 lineNumber) + { + return (_pMM_Audit_Imp->addAllocNode(pMem, sizeIn, pStatsNode, pFileName, lineNumber)); + } + + /** + * @returns true if operation succeeds; + */ + OsclMemStatsNode* removeAllocNode(void *pMemBlockIn, uint32& size) + { + return (_pMM_Audit_Imp->removeAllocNode(pMemBlockIn, size)); + } + + void removeALLAllocNodes() + { + _pMM_Audit_Imp->removeALLAllocNodes(); + } + + /** + * @returns true if operation succeeds; + */ + OsclMemStatsNode* createStatsNode(const char * tagIn) + { + return (_pMM_Audit_Imp->createStatsNode(tagIn)); + } + + /** + * @returns true if operation succeeds; + */ + bool updateStatsNode(OsclMemStatsNode *pCurrStatsNode, + const MM_Stats_t& pDelta, bool bAdd) + { + return (_pMM_Audit_Imp->updateStatsNode(pCurrStatsNode, pDelta, bAdd)); + } + + /** + * @returns true if operation succeeds; + */ + bool updateStatsNodeInFailure(const char * tagIn) + { + return (_pMM_Audit_Imp->updateStatsNodeInFailure(tagIn)); + } + + bool updateStatsNodeInFailure(OsclMemStatsNode * pStatsNode) + { + return (_pMM_Audit_Imp->updateStatsNodeInFailure(pStatsNode)); + } + + /** + * @returns true if operation succeeds; + */ + bool pruneSubtree(OsclMemStatsNode *pNode) + { + return (_pMM_Audit_Imp->pruneSubtree(pNode)); + } + + bool pruneSubtree(const char * tagIn) + { + return (_pMM_Audit_Imp->pruneSubtree(tagIn)); + } + + void retrieveParentTag(char *tag) + { + (_pMM_Audit_Imp->retrieveParentTag(tag)); + } + + /** + * @returns the length of a immediate parent tag for the input tag + */ + int32 retrieveParentTagLength(const char *tag, int32 bound) + { + return (_pMM_Audit_Imp->retrieveParentTagLength(tag, bound)); + } + + /** + * @returns a valid tag; NULL will be converted into root tag + */ + void makeValidTag(const char * tagIn, MMAuditCharAutoPtr& autoptr) + { + (_pMM_Audit_Imp->makeValidTag(tagIn, autoptr)); + } + + /** + * @returns the size of the truncated tag; 0 means NO truncation + */ + uint32 getTagActualSize(const char * tagIn) + { + return (_pMM_Audit_Imp->getTagActualSize(tagIn)); + } + + /** + * @returns true if operation succeeds; + */ + bool isSetFailure(const char * tagIn) + { + return (_pMM_Audit_Imp->isSetFailure(tagIn)); + } + + bool isSetFailure(OsclMemStatsNode * statsNode) + { + return (_pMM_Audit_Imp->isSetFailure(statsNode)); + } + + /** + * @returns true if operation succeeds; + */ + bool validate(void *ptrIn) + { + return (_pMM_Audit_Imp->validate(ptrIn)); + } + + /** + * @returns true if operation succeeds; + */ + bool validate_all_heap() + { + return (_pMM_Audit_Imp->validate_all_heap()); + } + + + private: + + /* + * The following are private data members + */ + + MM_Audit_Imp *_pMM_Audit_Imp; + OsclLockBase *iLock; + + /** + * Use OSCL singleton version + */ + _OsclBasicLock iSingletonLock; + int32 iRefCount; + friend class OsclMemGlobalAuditObject; + +}; +#endif + +#endif //OSCL_MEM_AUDIT_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_audit_internals.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_audit_internals.h new file mode 100644 index 0000000..73d278f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_audit_internals.h @@ -0,0 +1,145 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* -*- c++ -*- */ +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M E M _ A U D I T _ I N T E R N A L S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclmemory OSCL Memory + * + * @{ + */ + + +/*! \file oscl_mem_audit_internals.h + \brief This file contains the internal definitions for the mem audit library +*/ + + +#ifndef OSCL_MEM_AUDIT_INTERNALS_H +#define OSCL_MEM_AUDIT_INTERNALS_H + + +#include "oscl_base.h" +#include "oscl_mem_audit.h" +#include "oscl_mem_inst.h" + +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#include "osclconfig_compiler_warnings.h" + +#if(PVMEM_INST_LEVEL>0) +#define MM_AUDIT_ALLOC_NODE_SUPPORT 1 +#define MM_AUDIT_FENCE_SUPPORT 1 +#define MM_AUDIT_INCLUDE_ALL_HEAP_VALIDATION 1 +#define MM_AUDIT_FILL_SUPPORT 1 +#define MM_AUDIT_FAILURE_SIMULATION_SUPPORT 1 +#else +#define MM_AUDIT_ALLOC_NODE_SUPPORT 1 +#define MM_AUDIT_FENCE_SUPPORT 0 +#define MM_AUDIT_INCLUDE_ALL_HEAP_VALIDATION 1 +#define MM_AUDIT_FILL_SUPPORT 0 +#define MM_AUDIT_FAILURE_SIMULATION_SUPPORT 1 +#endif + +#define FENCE_PATTERN 0xAA +#define MIN_FENCE_SIZE 4 + +#ifdef MEM_ALIGN_4 +#define MEM_ALIGN_SIZE 4 +#else +#define MEM_ALIGN_SIZE 8 +#endif + + + +/* CURRENTLY THIS STRUCTURE IS A MULTIPLE OF 8 BYTES. MAKE SURE IT + * MAINTAINS A SIZE THAT IS AN INTEGER MULTIPLE OF THE ALIGNMENT SIZE + * FOR THE PLATFORM IN QUESTION. ADD PAD BYTES TO THE STRUCTURE + * IF NECESSARY + */ +struct MM_AllocBlockHdr +{ + void *pNode; //pointer to either a stats node or an alloc node. + uint32 size; + + void *pRootNode; //pointer to root node, to use when de-allocating. + uint32 pad;//to maintain 8-byte alignment + + /* windows compiler assumes the the assignment + * is a pure-virtual declaration and does not allow + * it to be non-zero. We actually set the value below. + */ + static const uint32 ALLOC_NODE_FLAG; // = 0x80000000; + + bool isAllocNodePtr() + { + return ((size & ALLOC_NODE_FLAG) != 0); + }; + void setAllocNodeFlag() + { + size |= ALLOC_NODE_FLAG; + }; + + MM_AllocBlockHdr(): pNode(0), size(0), pRootNode(0), pad(0) {}; + MM_AllocBlockHdr(void* ptr, uint32 inSize): pNode(ptr), size(inSize), pRootNode(0), pad(0) {}; +}; + +// actually set the value here. +const uint32 MM_AllocBlockHdr::ALLOC_NODE_FLAG = 0x80000000; + +#define COMPUTE_MEM_ALIGN_SIZE(x,y,z) (y+(((x+y)%z) ? (z - (x+y)%z) : 0)) + +struct MM_AllocBlockFence +{ + + uint8 pad[COMPUTE_MEM_ALIGN_SIZE(sizeof(MM_AllocBlockHdr), MIN_FENCE_SIZE, MEM_ALIGN_SIZE)]; + MM_AllocBlockFence() + { + fill_fence(); + }; + + void fill_fence() + { + oscl_memset(pad, FENCE_PATTERN, sizeof(pad)); + }; + + bool check_fence() + { + for (uint ii = 0; ii < sizeof(pad); ++ii) + { + if (pad[ii] != FENCE_PATTERN) return false; + } + return true; + }; +}; + + + + +#define DEFAULT_PREFILL_PATTERN 0x96 +#define DEFAULT_POSTFILL_PATTERN 0x5A + + + + + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_auto_ptr.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_auto_ptr.h new file mode 100644 index 0000000..82f6925 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_auto_ptr.h @@ -0,0 +1,261 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* -*- c++ -*- */ +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M E M _ A U T O _ P T R + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclmemory OSCL Memory + * + * @{ + */ + + +/** + * @file oscl_mem_auto_ptr.h + * @brief This file defines the oscl_mem_auto_ptr template class. This class is + * used to avoid any potential memory leaks that may arise while returning + * from methods in case of error. + * + */ + +#ifndef OSCL_MEM_AUTO_PTR_H +#define OSCL_MEM_AUTO_PTR_H + +#ifndef OSCLCONFIG_MEMORY_H_INCLUDED +#include "osclconfig_memory.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE +#define OSCL_DISABLE_WARNING_RETURN_TYPE_NOT_UDT +#include "osclconfig_compiler_warnings.h" +/** + * @brief The oscl_auto_ptr class is a template class that defines a pointer + * like object intended to be assigned an address obtanined (directly or + * or indirectly) by new. When the oscl_auto_ptr expires, its destructor + * uses delete to free the memory. + * + * The purpose of this class is to provide a way to prevent accidental memory + * leaks in a class or a method, due to "not remembering to delete" variables + * allocated on the heap. Thus if you assign an address returned by new to an + * oscl_auto_ptr object, you don't have to remember to free the memory later, + * it will be freed automatically when the object goes out of scope. + * The oscl_auto_ptr is an example of a smart pointer, an object that acts like + * a pointer, but with additional features. The class is defined so that it acts + * like a regular pointer in most respects + * + */ + +template < class T, class _Allocator = Oscl_TAlloc > class OSCLMemAutoPtr +{ + private: + T* _Ptr; + + + public: + bool _Ownership; + + + /** + * @brief Default constructor + * Initializes the pointer and takes ownership. + */ + explicit OSCLMemAutoPtr(T* inPtr = 0) : _Ptr(inPtr), _Ownership(inPtr != 0) {}; + + /** + * @brief Copy constructor + * + * Initializes the pointer and takes ownership from another oscl_auto_ptr. + * Note that the other class does NOT own the pointer any longer, and + * hence it is NOT its responsibility to free it. + */ + OSCLMemAutoPtr(const OSCLMemAutoPtr& _Y): _Ownership(_Y._Ownership), + _Ptr(_Y.release()) {}; + + + /** + * @brief Assignment operator from an another oscl_auto_ptr + * + * @param _Y The value parameter should be another oscl_auto_ptr + * @returns Returns a reference to this oscl_auto_ptr instance with + * pointer initialized. + * @pre The input class should be non-null and should point to + * a valid pointer. + * + * This assignment operator initializes the class to the contents + * of the oscl_auto_ptr given as the input parameter. The ownership + * of the pointer is transferred. + */ + OSCLMemAutoPtr& operator=(const OSCLMemAutoPtr& _Y) + { + if (this != &_Y) + { + if (_Ptr != _Y.get()) + { + if (_Ownership) + { + _Allocator alloc; + alloc.destroy(_Ptr); + alloc.deallocate(_Ptr, 1); + } + _Ownership = _Y._Ownership; + } + else if (_Y._Ownership) + { + _Ownership = true; + } + _Ptr = _Y.release(); + } + return (*this); + } + + /** + * @brief Destructor + * + * The pointer is deleted in case this class still has ownership + */ + ~OSCLMemAutoPtr() + { + if (_Ownership) + { + _Allocator alloc; + alloc.destroy(_Ptr); + alloc.deallocate(_Ptr, 1); + } + } + + /** + * @brief The indirection operator (*) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OSCLMemAutoPtr can be used like the + * regular pointer that it was initialized with. + */ + T& operator*() const + { + return (*get()); + } + + /** + * @brief The indirection operator (->) accesses a value indirectly, + * through a pointer + * + * This operator ensures that the OSCLMemAutoPtr can be used like the + * regular pointer that it was initialized with. + */ + T *operator->() const + { + return (get()); + } + + + /** + * @brief The takeOwnership function assigns the value with ownership. + * + * + */ + void takeOwnership(T* ptr) + { + if (_Ptr != ptr) + { + if (_Ownership) + { + _Allocator alloc; + alloc.destroy(_Ptr); + alloc.deallocate(_Ptr, 1); + } + _Ptr = ptr; + } + + if (_Ptr) + { + _Ownership = true; + } + } + + static void deallocate(T* ptr) + { + _Allocator alloc; + alloc.destroy(ptr); + alloc.deallocate(ptr, 1); + } + + void allocate(oscl_memsize_t size) + { + _Allocator alloc; + if (_Ptr && _Ownership) + { + alloc.destroy(_Ptr); + alloc.deallocate(_Ptr, 1); + } + _Ptr = alloc.ALLOCATE(size); + _Ownership = true; + } + + /** + * @brief The takeOwnership function assigns the value with ownership. + * + * + */ + void setWithoutOwnership(T* ptr) + { + if (_Ptr != ptr) + { + if (_Ownership) + { + _Allocator alloc; + alloc.destroy(_Ptr); + alloc.deallocate(_Ptr, 1); + } + _Ptr = ptr; + } + + _Ownership = false; + } + + /** + * @brief get() method returns the pointer, currently owned by the class. + * + */ + T *get() const + { + return (_Ptr); + } + + /** + * @brief release() method releases ownership of the pointer, currently owned + * by the class. It returns the pointer as well. + * + */ + T *release() const + { + ((OSCLMemAutoPtr *)this)->_Ownership = false; + return (_Ptr); + } + +}; + +#endif //OSCL_MEM_AUTO_PTR_H + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_imp.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_imp.cpp new file mode 100644 index 0000000..e313523 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_imp.cpp @@ -0,0 +1,246 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \file oscl_mem_imp.cpp + \brief This file contains the implementation of advanced memory APIs +*/ + +#include "oscl_mem.h" + + +////////////////////// +// OsclMem +////////////////////// + + +OSCL_EXPORT_REF void OsclMem::Init() +{ +#if(!OSCL_BYPASS_MEMMGT) + OsclMemGlobalAuditObject::createGlobalMemAuditObject(); +#endif +} + +OSCL_EXPORT_REF void OsclMem::Cleanup() +{ +#if(!OSCL_BYPASS_MEMMGT) + OsclMemGlobalAuditObject::deleteGlobalMemAuditObject(); +#endif +} + + + +////////////////////// +// OsclMemInit +////////////////////// + +OSCL_EXPORT_REF void OsclMemInit(OsclAuditCB & auditCB) +{ +#if(!OSCL_BYPASS_MEMMGT) + auditCB.pStatsNode = NULL; + auditCB.pAudit = (OsclMemGlobalAuditObject::getGlobalMemAuditObject()); +#else + OSCL_UNUSED_ARG(auditCB); +#endif +} + +#if(!OSCL_BYPASS_MEMMGT) + +#include "oscl_mem_audit.h" + +#include "oscl_singleton.h" + +////////////////////// +// OsclMemGlobalAuditObject +////////////////////// + +OSCL_EXPORT_REF OsclMemGlobalAuditObject::audit_type* OsclMemGlobalAuditObject::getGlobalMemAuditObject() +{ + return (audit_type*)OsclSingletonRegistryEx::getInstance(OSCL_SINGLETON_ID_OSCLMEM); +} + +void OsclMemGlobalAuditObject::createGlobalMemAuditObject() +{ + audit_type* audit = (audit_type*)OsclSingletonRegistryEx::lockAndGetInstance(OSCL_SINGLETON_ID_OSCLMEM); + if (audit) + { + audit->iRefCount++; + } + else + { + OsclAny *ptr = _oscl_malloc(sizeof(audit_type)); + if (!ptr) + { + OsclSingletonRegistryEx::registerInstanceAndUnlock(audit, OSCL_SINGLETON_ID_OSCLMEM); + OsclError::Leave(OsclErrNoMemory); + return; + } + audit = OSCL_PLACEMENT_NEW(ptr, audit_type()); + } + OsclSingletonRegistryEx::registerInstanceAndUnlock(audit, OSCL_SINGLETON_ID_OSCLMEM); +} + +void OsclMemGlobalAuditObject::deleteGlobalMemAuditObject() +{ + audit_type* audit = (audit_type*)OsclSingletonRegistryEx::lockAndGetInstance(OSCL_SINGLETON_ID_OSCLMEM); + if (!audit) + { + OsclSingletonRegistryEx::registerInstanceAndUnlock(audit, OSCL_SINGLETON_ID_OSCLMEM); + OsclError::Leave(OsclErrNotInstalled); + return; + } + audit->iRefCount--; + if (audit->iRefCount == 0) + { + audit->~OsclMemAudit(); + _oscl_free(audit); + audit = NULL; + } + OsclSingletonRegistryEx::registerInstanceAndUnlock(audit, OSCL_SINGLETON_ID_OSCLMEM); +} + +////////////////////// +// Default new/malloc +////////////////////// +OSCL_EXPORT_REF void* _oscl_default_audit_new(size_t nBytes, const char * file_name, const int line_num) +{ + //get global mem audit object. + OsclAuditCB audit; + OsclMemInit(audit); + return _oscl_audit_new(nBytes, audit, file_name, line_num); +} + +OSCL_EXPORT_REF void* _oscl_default_audit_malloc(size_t nBytes, const char * file_name, const int line_num) +{ + //get global mem audit object. + OsclAuditCB audit; + OsclMemInit(audit); + return _oscl_audit_malloc(nBytes, audit, file_name, line_num); +} + + +OSCL_EXPORT_REF void* _oscl_default_audit_calloc(size_t num, size_t nBytes, const char * file_name, const int line_num) +{ + //get global mem audit object. + OsclAuditCB audit; + OsclMemInit(audit); + return _oscl_audit_calloc(num, nBytes, audit, file_name, line_num); +} + +OSCL_EXPORT_REF void* _oscl_default_audit_realloc(void* in_ptr, size_t nBytes, const char * file_name, const int line_num) +{ + //get global mem audit object. + OsclAuditCB audit; + OsclMemInit(audit); + return _oscl_audit_realloc(in_ptr, nBytes, audit, file_name, line_num); +} + +////////////////////// +// Audit new/malloc +////////////////////// + +OSCL_EXPORT_REF void* _oscl_audit_new(size_t nBytes, OsclAuditCB & auditCB, const char * file_name, const int line_num) +{ + void * pTmp = auditCB.pAudit->MM_allocate(auditCB.pStatsNode, nBytes, file_name, line_num); + if (!pTmp) + OsclError::LeaveIfNull(pTmp); + return pTmp; +} + +OSCL_EXPORT_REF void* _oscl_audit_malloc(size_t nBytes, OsclAuditCB & auditCB, const char * file_name, const int line_num) +{ + return auditCB.pAudit->MM_allocate(auditCB.pStatsNode, nBytes, file_name, line_num); +} + +OSCL_EXPORT_REF void* _oscl_audit_calloc(size_t num, size_t nBytes, OsclAuditCB & auditCB, const char * file_name, const int line_num) +{ + size_t size = num * nBytes; + void* ptr = _oscl_audit_malloc(size, auditCB, file_name, line_num); + if (ptr) + oscl_memset(ptr, 0, size); + //note: return pointer can be null. + return ptr; +} + +OSCL_EXPORT_REF void* _oscl_audit_realloc(void* in_ptr, size_t nBytes, OsclAuditCB & auditCB, const char * file_name, const int line_num) +{ + if (nBytes > 0) + { + //allocate new space + void* ptr = _oscl_audit_malloc(nBytes, auditCB, file_name, line_num); + if (in_ptr && ptr) + { + //copy current contents to new space. + //note: the getSize call leaves if it's a bad pointer. + //just propagate the leave to the caller. + if (MM_Audit_Imp::getSize(in_ptr) > MM_Audit_Imp::getSize(ptr)) + { + oscl_memcpy(ptr, in_ptr, MM_Audit_Imp::getSize(ptr)); + } + else + { + oscl_memcpy(ptr, in_ptr, MM_Audit_Imp::getSize(in_ptr)); + } + //free original space. + _oscl_audit_free(in_ptr); + } + else if (in_ptr) + { + return in_ptr; + } + //note: return pointer can be null. + return ptr; + } + else + { + _oscl_audit_free(in_ptr); + return NULL; + } +} + +////////////// +// Free +////////////// +OSCL_EXPORT_REF void _oscl_audit_free(void *p) +{ + //always free from the root node-- global audit object. + //Get the audit root from within the alloc block rather + //than from TLS, since we can't be sure this call is + //in the same thread as the allocation. + OsclMemAudit *pAuditRoot = MM_Audit_Imp::getAuditRoot(p) ; + if (pAuditRoot) + { + pAuditRoot->MM_deallocate(p); + } + else + {//bad or corrupt block? + OSCL_LEAVE(OsclErrArgument); + } +} + +#else + +OSCL_EXPORT_REF void* _oscl_default_new(size_t nBytes) +{ + void * pTmp = _oscl_malloc(nBytes); + if (!pTmp) + OsclError::LeaveIfNull(pTmp); + return pTmp; +} + +#endif //OSCL_BYPASS_MEMMGT + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp new file mode 100644 index 0000000..9ba4bd5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp @@ -0,0 +1,1566 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_mem_mempool.h" + +#define ENABLE_OSCL_MEM_POOL_RESIZEABLE_ALLOCATOR_DEBUG_LOG 0 + +#if ENABLE_OSCL_MEM_POOL_RESIZEABLE_ALLOCATOR_DEBUG_LOG +#ifndef PVLOGGER_H_INCLUDED +#include "pvlogger.h" +#endif + +#define PVMF_POOLALLOC_LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m); + +class OsclMemPoolResizableAllocatorLogger +{ + public: + + OsclMemPoolResizableAllocatorLogger() + { + iLogger = PVLogger::GetLoggerObject("OsclMemPoolResizableAllocator"); + iAllocCount = 0; + iMemPoolUsedBlockList.clear(); + } + + ~OsclMemPoolResizableAllocatorLogger() + { + while (iMemPoolUsedBlockList.empty() == false) + { + iMemPoolUsedBlockList.erase(iMemPoolUsedBlockList.begin()); + } + iLogger = NULL; + } + + void logInitialPool(Oscl_Vector& aMemPoolBufferList) + { + PVMF_POOLALLOC_LOGERROR((0, "*******")) + PVMF_POOLALLOC_LOGERROR((0, "OsclMemPoolResizableAllocatorLogger::logInitialPool() this 0x%x", this)); + PVMF_POOLALLOC_LOGERROR((0, "Free list: aMemPoolBufferList length %d", aMemPoolBufferList.size())); + for (uint32 i = 0; i < aMemPoolBufferList.size(); ++i) + { + OsclMemPoolResizableAllocator::MemPoolBufferInfo* bufferinfo = aMemPoolBufferList[i]; + PVMF_POOLALLOC_LOGERROR((0, "aMemPoolBufferList[%d] MemPoolBufferInfo 0x%x", i, bufferinfo)); + OsclMemPoolResizableAllocator::MemPoolBlockInfo* blockinfo = bufferinfo->iNextFreeBlock; + while (blockinfo != NULL) + { + PVMF_POOLALLOC_LOGERROR((0, "aMemPoolBufferList[%d] MemPoolBlockInfo 0x%x size %d (last byte 0x%x)", + i, blockinfo, blockinfo->iBlockSize, (uint32)blockinfo + blockinfo->iBlockSize - 1)); + // Go to the next free block + blockinfo = blockinfo->iNextFreeBlock; + } + } + PVMF_POOLALLOC_LOGERROR((0, "*******")) + } + + void logFreeAndUsedBlocks(Oscl_Vector& aMemPoolBufferList, uint32 aMemPoolPrevAllocBufferIndex, bool aPeriodic) + { + bool logOK = false; + if (aPeriodic) + { + /* + ((iAllocCount == 5) || (iAllocCount == 10) || (iAllocCount == 15) || + (iAllocCount == 20) || (iAllocCount == 25) || (iAllocCount == 30) || + (iAllocCount == 35) || (iAllocCount == 40) || (iAllocCount == 45) || + (iAllocCount % 50 == 0))) + */ + // log every 10th alloc + if (iAllocCount % 10 == 0) + { + logOK = true; + } + } + else + { + logOK = true; + } + + // MBDS holds onto many used blocks, thus we can isolate MBDS usecase by checking the vector size + if (logOK /* && (iMemPoolUsedBlockList.size() > 4) */) + { + PVMF_POOLALLOC_LOGERROR((0, "@@@@@@@")) + if (aPeriodic) + { + PVMF_POOLALLOC_LOGERROR((0, "OsclMemPoolResizableAllocatorLogger::logFreeAndUsedBlocks() alloc count %d this 0x%x", iAllocCount, this)); + } + else + { + PVMF_POOLALLOC_LOGERROR((0, "OsclMemPoolResizableAllocatorLogger::logFreeAndUsedBlocks() NO FREE BLOCKS alloc count %d this 0x%x", iAllocCount, this)); + + } + PVMF_POOLALLOC_LOGERROR((0, "Free list: aMemPoolBufferList length %d aMemPoolPrevAllocBufferIndex %d", + aMemPoolBufferList.size(), aMemPoolPrevAllocBufferIndex)); + for (uint32 i = 0; i < aMemPoolBufferList.size(); ++i) + { + OsclMemPoolResizableAllocator::MemPoolBufferInfo* bufferinfo = aMemPoolBufferList[i]; + PVMF_POOLALLOC_LOGERROR((0, "aMemPoolBufferList[%d] MemPoolBufferInfo 0x%x iPrevAllocBlock 0x%x", + i, bufferinfo, bufferinfo->iPrevAllocBlock)); + if (bufferinfo) + { + OsclMemPoolResizableAllocator::MemPoolBlockInfo* blockinfo = bufferinfo->iNextFreeBlock; + while (blockinfo != NULL) + { + PVMF_POOLALLOC_LOGERROR((0, "aMemPoolBufferList[%d] MemPoolBlockInfo 0x%x size %d (next free block 0x%x)", + i, blockinfo, blockinfo->iBlockSize, (uint32)blockinfo + blockinfo->iBlockSize)); + // Go to the next free block + blockinfo = blockinfo->iNextFreeBlock; + } + } + } + PVMF_POOLALLOC_LOGERROR((0, "Used list: iMemPoolUsedBlockList length %d", iMemPoolUsedBlockList.size())); + OsclMemPoolResizableAllocator::MemPoolBlockInfo* nextblock = NULL; + uint32 gapCount = 0; + for (i = 0; i < iMemPoolUsedBlockList.size(); ++i) + { + OsclMemPoolResizableAllocator::MemPoolBlockInfo* blockinfo = iMemPoolUsedBlockList[i]; + if ((nextblock != NULL) && (blockinfo != nextblock)) + { + PVMF_POOLALLOC_LOGERROR((0, "Gap between iMemPoolUsedBlockList[%d] 0x%x and iMemPoolUsedBlockList[%d] 0x%x", + i - 1, nextblock, i, blockinfo)); + } + PVMF_POOLALLOC_LOGERROR((0, "iMemPoolUsedBlockList[%d] MemPoolBlockInfo 0x%x size %d (next block 0x%x)", + i, blockinfo, blockinfo->iBlockSize, (uint32)blockinfo + blockinfo->iBlockSize)); + + nextblock = (OsclMemPoolResizableAllocator::MemPoolBlockInfo*)((uint32)blockinfo + blockinfo->iBlockSize); + } + PVMF_POOLALLOC_LOGERROR((0, "@@@@@@@")) + } + + } + + void addUsedBlockToList(OsclMemPoolResizableAllocator::MemPoolBlockInfo* aUsedBlock) + { + // add to used list + iMemPoolUsedBlockList.push_back(aUsedBlock); + } + + void removeUsedBlockToList(OsclMemPoolResizableAllocator::MemPoolBlockInfo* aUsedBlock) + { + // remove from used list + for (uint32 i = 0; i < iMemPoolUsedBlockList.size(); ++i) + { + OsclMemPoolResizableAllocator::MemPoolBlockInfo* blockinfo = iMemPoolUsedBlockList[i]; + if (iMemPoolUsedBlockList[i] == aUsedBlock) + { + // remove from list + iMemPoolUsedBlockList.erase(&iMemPoolUsedBlockList[i]); + break; + } + } + } + + void incrementAllocCount() + { + // update count + iAllocCount++; + } + + private: + Oscl_Vector iMemPoolUsedBlockList; + PVLogger *iLogger; + uint32 iAllocCount; +}; + +#endif + +/** + * OsclMemPoolFixedChunkAllocator section + **/ + +OSCL_EXPORT_REF OsclMemPoolFixedChunkAllocator::OsclMemPoolFixedChunkAllocator(const uint32 numchunk, const uint32 chunksize, Oscl_DefAlloc* gen_alloc, const uint32 chunkalignment) : + iNumChunk(1), iChunkSize(0), iChunkSizeMemAligned(0), iChunkAlignment(chunkalignment), + iMemPoolAllocator(gen_alloc), iMemPool(NULL), iMemPoolAligned(NULL), + iCheckNextAvailableFreeChunk(false), iObserver(NULL), + iNextAvailableContextData(NULL), + iRefCount(1), + iEnableNullPtrReturn(false) +{ + iNumChunk = numchunk; + iChunkSize = chunksize; + iChunkAlignment = chunkalignment; + + if (iNumChunk == 0) + { + iNumChunk = 1; + } + + // if alignment paramater is used - set it to the nearest larger power of 2 + if ((iChunkAlignment > 0) && (iChunkAlignment < 0x80000000)) + { + uint32 align = 1; + while (align < iChunkAlignment) + { + align <<= 1; + } + iChunkAlignment = align; + } + + // 8 byte alignment is the default. It shouldn't be larger than 1k + if ((iChunkAlignment < 8) || (iChunkAlignment > 1024)) + { + iChunkAlignment = 0; + } + + if (iChunkSize > 0) + { + createmempool(); + } +} + +OSCL_EXPORT_REF OsclMemPoolFixedChunkAllocator::~OsclMemPoolFixedChunkAllocator() +{ + // Decrement the ref count + --iRefCount; + + // If ref count reaches 0 then destroy this object + if (iRefCount <= 0) + { + destroymempool(); + } +} + +OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::enablenullpointerreturn() +{ + iEnableNullPtrReturn = true; +} + +OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::addRef() +{ + // Just increment the ref count + ++iRefCount; +} + +OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::removeRef() +{ + // Decrement the ref count + --iRefCount; + + // If ref count reaches 0 then destroy this object automatically + if (iRefCount <= 0) + { + OSCL_DELETE(this); + } +} + +OSCL_EXPORT_REF OsclAny* OsclMemPoolFixedChunkAllocator::allocate(const uint32 n) +{ + // Create the memory pool if it hasn't been created yet. + // Use the allocation size, n, as the chunk size for memory pool + if (iChunkSize == 0) + { + iChunkSize = n; + createmempool(); + } + else if (n > iChunkSize) + { + OSCL_LEAVE(OsclErrArgument); + // OSCL_UNUSED_RETURN(NULL); This statement was removed to avoid compiler warning for Unreachable Code + + } + + if (iFreeMemChunkList.empty()) + { + // No free chunk is available + if (iEnableNullPtrReturn) + { + return NULL; + } + else + { + OSCL_LEAVE(OsclErrNoResources); + } + } + + // Return the next available chunk from the pool + OsclAny* freechunk = iFreeMemChunkList.back(); + // Remove the chunk from the free list + iFreeMemChunkList.pop_back(); + addRef(); + return freechunk; +} + + +OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::deallocate(OsclAny* p) +{ + if (iMemPool == NULL) + { + // Memory pool hasn't been allocated yet so error + OSCL_LEAVE(OsclErrNotReady); + } + + uint8* ptmp = (uint8*)p; + uint8* mptmp = (uint8*)iMemPoolAligned; + + if ((ptmp < mptmp) || ptmp >= (mptmp + iNumChunk*iChunkSizeMemAligned)) + { + // Returned memory is not part of this memory pool + OSCL_LEAVE(OsclErrArgument); + } + + if (((ptmp - mptmp) % iChunkSizeMemAligned) != 0) + { + // Returned memory is not aligned to the chunk. + OSCL_LEAVE(OsclErrArgument); + } + +#if(!OSCL_BYPASS_MEMMGT) + // check if the same chunk was deallocated multiple times in a row + uint32 ii; + for (ii = 0; ii < iFreeMemChunkList.size(); ii++) + { + if (iFreeMemChunkList[ii] == p) + { + OSCL_LEAVE(OsclErrArgument); + } + } +#endif + + // Put the returned chunk in the free pool + iFreeMemChunkList.push_back(p); + + // Notify the observer about free chunk available if waiting for such callback + if (iCheckNextAvailableFreeChunk) + { + iCheckNextAvailableFreeChunk = false; + if (iObserver) + { + iObserver->freechunkavailable(iNextAvailableContextData); + } + } + + // Decrement the refcount since deallocating succeeded + removeRef(); +} + + +OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::notifyfreechunkavailable(OsclMemPoolFixedChunkAllocatorObserver& obs, OsclAny* aContextData) +{ + iCheckNextAvailableFreeChunk = true; + iObserver = &obs; + iNextAvailableContextData = aContextData; +} + +OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::CancelFreeChunkAvailableCallback() +{ + iCheckNextAvailableFreeChunk = false; + iObserver = NULL; + iNextAvailableContextData = NULL; +} + +OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::createmempool() +{ + if (iChunkSize == 0 || iNumChunk == 0) + { + OSCL_LEAVE(OsclErrArgument); + } + + if (iChunkAlignment > 0) + { + uint32 temp = iChunkAlignment - 1; + iChunkSizeMemAligned = ((iChunkSize + temp) & (~temp)); + } + else + { + // Create one block of memory for the memory pool + iChunkSizeMemAligned = oscl_mem_aligned_size(iChunkSize); + } + + int32 leavecode = 0; + if (iMemPoolAllocator) + { + OSCL_TRY(leavecode, iMemPool = iMemPoolAllocator->ALLOCATE((iNumChunk * iChunkSizeMemAligned) + iChunkAlignment)); + } + else + { + iMemPool = OSCL_MALLOC((iNumChunk * iChunkSizeMemAligned) + iChunkAlignment); + } + + if (leavecode || iMemPool == NULL) + { + OSCL_LEAVE(OsclErrNoMemory); + } + +#if OSCL_MEM_FILL_WITH_PATTERN + oscl_memset(iMemPool, 0x55, (iNumChunk*iChunkSizeMemAligned) + iChunkAlignment); +#endif + + // Set up the free mem chunk list vector + iFreeMemChunkList.reserve(iNumChunk); + uint8* chunkptr = (uint8*)iMemPool; + + // do the alignment if necessary + if (iChunkAlignment > 0) + { + + uint32 chunkptrAddr = (uint32) chunkptr; + uint32 tempAlign = (iChunkAlignment - 1); + uint32 difference = ((chunkptrAddr + tempAlign) & (~tempAlign)) - chunkptrAddr; + + chunkptr = chunkptr + difference; + iMemPoolAligned = (OsclAny*) chunkptr; + } + else + { + iMemPoolAligned = iMemPool; + } + + for (uint32 i = 0; i < iNumChunk; ++i) + { + iFreeMemChunkList.push_back((OsclAny*)chunkptr); + chunkptr += iChunkSizeMemAligned; + } +} + + +OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::destroymempool() +{ + // If ref count reaches 0 then destroy this object + if (iRefCount <= 0) + { +#if OSCL_MEM_CHECK_ALL_MEMPOOL_CHUNKS_ARE_RETURNED + // Assert if all of the chunks were not returned + OSCL_ASSERT(iFreeMemChunkList.size() == iNumChunk); +#endif + + iFreeMemChunkList.clear(); + + if (iMemPool) + { + if (iMemPoolAllocator) + { + iMemPoolAllocator->deallocate(iMemPool); + } + else + { + OSCL_FREE(iMemPool); + } + + iMemPool = NULL; + iMemPoolAligned = NULL; + } + } +} + + + +/** + * OsclMemPoolResizableAllocator section + **/ + +#define OSCLMEMPOOLRESIZABLEALLOCATOR_DEFAULT_NUMBLOCKPERBUFFER 10 +#define OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN 0x55 +#define OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN 0xAA +#define OSCLMEMPOOLRESIZABLEALLOCATOR_MIN_BUFFERSIZE 8 + +OSCL_EXPORT_REF OsclMemPoolResizableAllocator::OsclMemPoolResizableAllocator(uint32 aMemPoolBufferSize, uint32 aMemPoolBufferNumLimit, uint32 aExpectedNumBlocksPerBuffer, Oscl_DefAlloc* gen_alloc) : + iMemPoolBufferSize(aMemPoolBufferSize), + iMemPoolBufferNumLimit(aMemPoolBufferNumLimit), + iExpectedNumBlocksPerBuffer(aExpectedNumBlocksPerBuffer), + iMemPoolBufferAllocator(gen_alloc), + iMemPoolPrevAllocBufferIndex(0xFFFFFFFF), + iCheckNextAvailable(false), + iRequestedNextAvailableSize(0), + iNextAvailableContextData(NULL), + iObserver(NULL), + iCheckFreeMemoryAvailable(false), + iRequestedAvailableFreeMemSize(0), + iFreeMemContextData(NULL), + iFreeMemPoolObserver(NULL), + iRefCount(1), + iEnableNullPtrReturn(false), + iDebugLogger(NULL) +{ + OSCL_ASSERT(aMemPoolBufferSize > OSCLMEMPOOLRESIZABLEALLOCATOR_MIN_BUFFERSIZE); + + iMaxNewMemPoolBufferSz = 0; + // Calculate and save the mem aligned size of buffer and block info header structures + iBufferInfoAlignedSize = oscl_mem_aligned_size(sizeof(MemPoolBufferInfo)); + iBlockInfoAlignedSize = oscl_mem_aligned_size(sizeof(MemPoolBlockInfo)); + + // Pre-allocate memory for vector + if (iMemPoolBufferNumLimit > 0) + { + iMemPoolBufferList.reserve(iMemPoolBufferNumLimit); + } + else + { + iMemPoolBufferList.reserve(2); + } + + // Determine the size of memory pool buffer and create one + uint32 buffersize = oscl_mem_aligned_size(iMemPoolBufferSize) + iBufferInfoAlignedSize; + if (iExpectedNumBlocksPerBuffer > 0) + { + buffersize += (iExpectedNumBlocksPerBuffer * iBlockInfoAlignedSize); + } + else + { + buffersize += (OSCLMEMPOOLRESIZABLEALLOCATOR_DEFAULT_NUMBLOCKPERBUFFER * iBlockInfoAlignedSize); + } + + addnewmempoolbuffer(buffersize); + +#if ENABLE_OSCL_MEM_POOL_RESIZEABLE_ALLOCATOR_DEBUG_LOG + iDebugLogger = OSCL_NEW(OsclMemPoolResizableAllocatorLogger, ()); + // log pool info + if (NULL != iDebugLogger) + { + iDebugLogger->logInitialPool(iMemPoolBufferList); + } +#endif +} + +OsclMemPoolResizableAllocator::~OsclMemPoolResizableAllocator() +{ + destroyallmempoolbuffers(); + +#if ENABLE_OSCL_MEM_POOL_RESIZEABLE_ALLOCATOR_DEBUG_LOG + if (NULL != iDebugLogger) + { + OSCL_DELETE(iDebugLogger); + } +#endif +} + + +OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::enablenullpointerreturn() +{ + iEnableNullPtrReturn = true; +} + +OSCL_EXPORT_REF OsclAny* OsclMemPoolResizableAllocator::allocate(const uint32 aNumBytes) +{ + MemPoolBlockInfo* freeblock = NULL; + uint32 alignednumbytes = oscl_mem_aligned_size(aNumBytes); + + if (aNumBytes == 0) + { + OSCL_LEAVE(OsclErrArgument); + // OSCL_UNUSED_RETURN(NULL); This statement was removed to avoid compiler warning for Unreachable Code + } + + // Find a free block that would accomodate the requested size with a block info header + freeblock = findfreeblock(alignednumbytes + iBlockInfoAlignedSize); + if (freeblock == NULL) + { + //We could not find a free buffer of requested size. This could be due to: + //1) We have not created even a single parent chunk (or in other words this is the first allocation) + //2) We are out of memory and might need to expand + + + // Check if the requested size is bigger than the specified buffer size + // Some of the users of this allocator, count on the allocator to expand beyond the original size + // specified in the constructor. These users do NOT use setMaxSzForNewMemPoolBuffer to control expansion size. + // If they did then it is wrong usage and we fail the allocation. + // For example the allocator was intialized with 200KB size, + // and overtime a request is made for say 300KB. Users of the allocator expect the allocator to do one of the following: + // 1) If iMemPoolBufferNumLimit has been set and it has been reached then see + // if one of older blocks can be freed up and we allocate a new block of 300KB. If we cannot then alloc will fail. + // 2) If iMemPoolBufferNumLimit has not set then simply allocate a new block of 300 KB. Note that if iMemPoolBufferNumLimit + // is not set allocator expands indefinitely. + if (alignednumbytes > iMemPoolBufferSize) + { + if (iMaxNewMemPoolBufferSz != 0) + { + //wrong usage - fail allocation + if (iEnableNullPtrReturn) + { + return NULL; + } + else + { + // Leave with resource limitation + OSCL_LEAVE(OsclErrNoResources); + } + } + // Would need to create a new buffer to accomodate this request + // Check if another buffer can be created + if (iMemPoolBufferNumLimit > 0 && iMemPoolBufferList.size() >= iMemPoolBufferNumLimit) + { + // Check if there is a memory pool buffer that has no outstanding buffers + // If present then remove it so a new one can be added + bool emptybufferfound = false; + for (uint32 j = 0; j < iMemPoolBufferList.size(); ++j) + { + if (iMemPoolBufferList[j]->iNumOutstanding == 0) + { + // Free the memory + if (iMemPoolBufferAllocator) + { + iMemPoolBufferAllocator->deallocate((OsclAny*)iMemPoolBufferList[j]); + } + else + { + OSCL_FREE((OsclAny*)iMemPoolBufferList[j]); + } + + // Remove the mempool buffer from the list + iMemPoolBufferList.erase(iMemPoolBufferList.begin() + j); + emptybufferfound = true; + break; + } + } + // Need to leave and return if empty buffer not found + if (!emptybufferfound) + { + if (iEnableNullPtrReturn) + { + return NULL; + } + else + { + // Leave with resource limitation + OSCL_LEAVE(OsclErrNoResources); + } + } + // Continue on to create a new buffer + OSCL_ASSERT(iMemPoolBufferList.size() < iMemPoolBufferNumLimit); + } + // Determine the size of memory pool buffer and create one + uint32 buffersize = alignednumbytes + iBufferInfoAlignedSize; + if (iExpectedNumBlocksPerBuffer > 0) + { + buffersize += (iExpectedNumBlocksPerBuffer * iBlockInfoAlignedSize); + } + else + { + buffersize += (OSCLMEMPOOLRESIZABLEALLOCATOR_DEFAULT_NUMBLOCKPERBUFFER * iBlockInfoAlignedSize); + } + + MemPoolBufferInfo* newbuffer = addnewmempoolbuffer(buffersize); + OSCL_ASSERT(newbuffer != NULL); + OSCL_ASSERT(newbuffer->iNextFreeBlock != NULL); + freeblock = (MemPoolBlockInfo*)(newbuffer->iNextFreeBlock); + OSCL_ASSERT(freeblock != NULL); + OSCL_ASSERT(freeblock->iBlockSize >= alignednumbytes); + } + else + { + // Check if another buffer can be created + if (iMemPoolBufferNumLimit > 0 && iMemPoolBufferList.size() >= iMemPoolBufferNumLimit) + { + if (iEnableNullPtrReturn) + { + return NULL; + } + else + { + // Leave with resource limitation + OSCL_LEAVE(OsclErrNoResources); + } + } + // Determine the size of memory pool buffer and create one + // By default this allocator expands by iMemPoolBufferSize. + // iMaxNewMemPoolBufferSz could specify the amount by which this allocator expands. + // setMaxSzForNewMemPoolBuffer API can be used to control the expansion size. + uint32 expansion_size = iMemPoolBufferSize; + if (iMaxNewMemPoolBufferSz != 0) + { + expansion_size = iMaxNewMemPoolBufferSz; + } + //if alignednumbytes is larger than expansion_size, we cannot satisfy the request, so fail the allocation + if (alignednumbytes > expansion_size) + { + if (iEnableNullPtrReturn) + { + return NULL; + } + else + { + // Leave with resource limitation + OSCL_LEAVE(OsclErrNoResources); + } + } + uint32 buffersize = oscl_mem_aligned_size(expansion_size) + iBufferInfoAlignedSize; + if (iExpectedNumBlocksPerBuffer > 0) + { + buffersize += (iExpectedNumBlocksPerBuffer * iBlockInfoAlignedSize); + } + else + { + buffersize += (OSCLMEMPOOLRESIZABLEALLOCATOR_DEFAULT_NUMBLOCKPERBUFFER * iBlockInfoAlignedSize); + } + + MemPoolBufferInfo* newbuffer = addnewmempoolbuffer(buffersize); + OSCL_ASSERT(newbuffer != NULL); + OSCL_ASSERT(newbuffer->iNextFreeBlock != NULL); + freeblock = (MemPoolBlockInfo*)(newbuffer->iNextFreeBlock); + OSCL_ASSERT(freeblock != NULL); + OSCL_ASSERT(freeblock->iBlockSize >= alignednumbytes); + } + + } + + // Use the free block and return the buffer pointer + OsclAny* bufptr = allocateblock(*freeblock, alignednumbytes); + if (bufptr) + { +#if ENABLE_OSCL_MEM_POOL_RESIZEABLE_ALLOCATOR_DEBUG_LOG + // add to used list + if (NULL != iDebugLogger) + { + iDebugLogger->addUsedBlockToList(freeblock); + } +#endif + addRef(); + ++(freeblock->iParentBuffer->iNumOutstanding); + } + return bufptr; +} + + +OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::deallocate(OsclAny* aPtr) +{ + // Check that the returned pointer is from the memory pool + if (validateblock(aPtr) == false) + { + OSCL_LEAVE(OsclErrArgument); + } + + // Retrieve the block info header and validate the info + uint8* byteptr = (uint8*)aPtr; + MemPoolBlockInfo* retblock = (MemPoolBlockInfo*)(byteptr - iBlockInfoAlignedSize); + OSCL_ASSERT(retblock != NULL); + OSCL_ASSERT(retblock->iBlockPreFence == OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN); + OSCL_ASSERT(retblock->iBlockPostFence == OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN); + +#if ENABLE_OSCL_MEM_POOL_RESIZEABLE_ALLOCATOR_DEBUG_LOG + // remove from used list + if (NULL != iDebugLogger) + { + iDebugLogger->removeUsedBlockToList(retblock); + } +#endif + + // Return the block to the memory pool buffer + deallocateblock(*retblock); + --(retblock->iParentBuffer->iNumOutstanding); + + // Check if user needs to be notified when block becomes available + if (iCheckNextAvailable) + { + // Check if user is waiting for certain size + if (iRequestedNextAvailableSize == 0) + { + // No so just make the callback + iCheckNextAvailable = false; + if (iObserver) + { + iObserver->freeblockavailable(iNextAvailableContextData); + } + } + else + { + // Check if the requested size is available now + if (findfreeblock(iRequestedNextAvailableSize + iBlockInfoAlignedSize) != NULL) + { + iCheckNextAvailable = false; + if (iObserver) + { + iObserver->freeblockavailable(iNextAvailableContextData); + } + } + else if (iRequestedNextAvailableSize > iMemPoolBufferSize) + { + // The requested size is bigger than the set buffer size + + // Check if there is space to grow the buffer, + if (iMemPoolBufferNumLimit == 0 || iMemPoolBufferList.size() < iMemPoolBufferNumLimit) + { + // Available + iCheckNextAvailable = false; + if (iObserver) + { + iObserver->freeblockavailable(iNextAvailableContextData); + } + } + else + { + // Not available so see if there is a buffer with + // no outstanding buffers which can be destroyed + // in the next allocate() call. + bool emptybufferfound = false; + for (uint32 j = 0; j < iMemPoolBufferList.size(); ++j) + { + if (iMemPoolBufferList[j]->iNumOutstanding == 0) + { + emptybufferfound = true; + break; + } + } + + if (emptybufferfound) + { + iCheckNextAvailable = false; + if (iObserver) + { + iObserver->freeblockavailable(iNextAvailableContextData); + } + } + } + } + } + } + if (iCheckFreeMemoryAvailable) + { + if (iRequestedAvailableFreeMemSize == 0) + { + // No so just make the callback + iCheckFreeMemoryAvailable = false; + if (iFreeMemPoolObserver) + { + iFreeMemPoolObserver->freememoryavailable(iFreeMemContextData); + } + } + else + { + // Check if the requested size is available now + if (getAvailableSize() >= iRequestedAvailableFreeMemSize) + { + iCheckFreeMemoryAvailable = false; + if (iFreeMemPoolObserver) + { + iFreeMemPoolObserver->freememoryavailable(iFreeMemContextData); + } + } + } + } + + // Decrement the refcount since deallocating succeeded + removeRef(); +} + + +OSCL_EXPORT_REF bool OsclMemPoolResizableAllocator::trim(OsclAny* aPtr, uint32 aBytesToFree) +{ + // Amount to free has to be aligned + uint32 alignedbytestofree = oscl_mem_aligned_size(aBytesToFree); + if (alignedbytestofree > aBytesToFree) + { + // Not aligned so decrease amount to free by one alignment size + alignedbytestofree -= 8; + } + OSCL_ASSERT(alignedbytestofree <= aBytesToFree); + + // Check that the returned pointer is from the memory pool + if (validateblock(aPtr) == false) + { + OSCL_LEAVE(OsclErrArgument); + // OSCL_UNUSED_RETURN(false); This statement was removed to avoid compiler warning for Unreachable Code + } + + // Retrieve the block info header and validate the info + uint8* byteptr = (uint8*)aPtr; + MemPoolBlockInfo* resizeblock = (MemPoolBlockInfo*)(byteptr - iBlockInfoAlignedSize); + OSCL_ASSERT(resizeblock != NULL); + OSCL_ASSERT(resizeblock->iBlockPreFence == OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN); + OSCL_ASSERT(resizeblock->iBlockPostFence == OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN); + + if ((resizeblock->iBlockSize - iBlockInfoAlignedSize) < alignedbytestofree) + { + // The bytes to free in the resize is bigger than the original buffer size + OSCL_LEAVE(OsclErrArgument); + // OSCL_UNUSED_RETURN(false); This statement was removed to avoid compiler warning for Unreachable Code + } + + if (alignedbytestofree < (iBlockInfoAlignedSize + OSCLMEMPOOLRESIZABLEALLOCATOR_MIN_BUFFERSIZE)) + { + // The resizing cannot be done since the amount to free doesn't have + // enough space to put in a block info header plus the minimum buffer for the new free block + // So don't do anything and return + return false; + } + + // Create and fill in a block info header for the memory being freed back to memory pool + MemPoolBlockInfo* freeblock = (MemPoolBlockInfo*)((uint8*)resizeblock + resizeblock->iBlockSize - alignedbytestofree); + freeblock->iBlockPreFence = OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN; + freeblock->iNextFreeBlock = NULL; + freeblock->iPrevFreeBlock = NULL; + freeblock->iBlockSize = alignedbytestofree; + freeblock->iBlockBuffer = (uint8*)freeblock + iBlockInfoAlignedSize; + freeblock->iParentBuffer = resizeblock->iParentBuffer; + freeblock->iBlockPostFence = OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN; + + // Return the free block to the memory pool buffer + deallocateblock(*freeblock); + + // Adjust the block info for the block being resized + resizeblock->iBlockSize -= alignedbytestofree; + return true; +} + + +OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::notifyfreeblockavailable(OsclMemPoolResizableAllocatorObserver& aObserver, uint32 aRequestedSize, OsclAny* aContextData) +{ + // Save the parameters for the next deallocate() call + iCheckNextAvailable = true; + iObserver = &aObserver; + iRequestedNextAvailableSize = oscl_mem_aligned_size(aRequestedSize); + iNextAvailableContextData = aContextData; +} + +OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::CancelFreeChunkAvailableCallback() +{ + iCheckNextAvailable = false; + iObserver = NULL; + iRequestedNextAvailableSize = 0; + iNextAvailableContextData = NULL; +} + +OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::notifyfreememoryavailable(OsclMemPoolResizableAllocatorMemoryObserver& aObserver, uint32 aRequestedSize, OsclAny* aContextData) +{ + // Save the parameters for the next deallocate() call + iCheckFreeMemoryAvailable = true; + iFreeMemPoolObserver = &aObserver; + iRequestedAvailableFreeMemSize = oscl_mem_aligned_size(aRequestedSize); + iFreeMemContextData = aContextData; +} + +OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::CancelFreeMemoryAvailableCallback() +{ + iCheckFreeMemoryAvailable = false; + iFreeMemPoolObserver = NULL; + iRequestedAvailableFreeMemSize = 0; + iFreeMemContextData = NULL; +} + +OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::addRef() +{ + // Just increment the ref count + ++iRefCount; +} + + +OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::removeRef() +{ + // Decrement the ref count + --iRefCount; + + // If ref count reaches 0 then destroy this object automatically + if (iRefCount <= 0) + { + OSCL_DELETE(this); + } +} + +OsclMemPoolResizableAllocator::MemPoolBufferInfo* OsclMemPoolResizableAllocator::addnewmempoolbuffer(uint32 aBufferAlignedSize) +{ + OSCL_ASSERT(aBufferAlignedSize > 0); + OSCL_ASSERT(aBufferAlignedSize == oscl_mem_aligned_size(aBufferAlignedSize)); + + // Allocate memory for one buffer + uint8* newbuffer = NULL; + if (iMemPoolBufferAllocator) + { + // Use the outside allocator + newbuffer = (uint8*)iMemPoolBufferAllocator->ALLOCATE(aBufferAlignedSize); + } + else + { + // Allocate directly from heap + newbuffer = (uint8*)OSCL_MALLOC(aBufferAlignedSize); + } + + if (newbuffer == NULL) + { + OSCL_LEAVE(OsclErrNoMemory); + // OSCL_UNUSED_RETURN(NULL); This statement was removed to avoid compiler warning for Unreachable Code + } + +#if OSCL_MEM_FILL_WITH_PATTERN + oscl_memset(newbuffer, 0x55, aBufferAlignedSize); +#endif + + // Fill in the buffer info header + MemPoolBufferInfo* newbufferinfo = (MemPoolBufferInfo*)newbuffer; + newbufferinfo->iBufferPreFence = OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN; + newbufferinfo->iStartAddr = (OsclAny*)(newbuffer + iBufferInfoAlignedSize); + newbufferinfo->iEndAddr = (OsclAny*)(newbuffer + aBufferAlignedSize - 1); + newbufferinfo->iBufferSize = aBufferAlignedSize; + newbufferinfo->iNumOutstanding = 0; + newbufferinfo->iNextFreeBlock = (MemPoolBlockInfo*)(newbufferinfo->iStartAddr); + newbufferinfo->iAllocatedSz = 0; + newbufferinfo->iBufferPostFence = OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN; + newbufferinfo->iPrevAllocBlock = NULL; + + // Put in one free block in the new buffer + MemPoolBlockInfo* freeblockinfo = (MemPoolBlockInfo*)(newbufferinfo->iStartAddr); + freeblockinfo->iBlockPreFence = OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN; + freeblockinfo->iNextFreeBlock = NULL; + freeblockinfo->iPrevFreeBlock = NULL; + freeblockinfo->iBlockSize = aBufferAlignedSize - iBufferInfoAlignedSize; + freeblockinfo->iBlockBuffer = (uint8*)freeblockinfo + iBlockInfoAlignedSize; + freeblockinfo->iParentBuffer = newbufferinfo; + freeblockinfo->iBlockPostFence = OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN; + + // Add the new buffer to the end of list + iMemPoolBufferList.push_back(newbufferinfo); + + iMemPoolPrevAllocBufferIndex = iMemPoolBufferList.size() - 1; + + return newbufferinfo; +} + + +void OsclMemPoolResizableAllocator::destroyallmempoolbuffers() +{ + while (iMemPoolBufferList.empty() == false) + { + MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[0]; + // Check the buffer + OSCL_ASSERT(bufferinfo != NULL); + OSCL_ASSERT(bufferinfo->iBufferPreFence == OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN); + OSCL_ASSERT(bufferinfo->iBufferPostFence == OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN); + OSCL_ASSERT(bufferinfo->iNumOutstanding == 0); + + // Free the memory + if (iMemPoolBufferAllocator) + { + iMemPoolBufferAllocator->deallocate((OsclAny*)bufferinfo); + } + else + { + OSCL_FREE((OsclAny*)bufferinfo); + } + + iMemPoolBufferList.erase(iMemPoolBufferList.begin()); + } +} + + +OsclMemPoolResizableAllocator::MemPoolBlockInfo* OsclMemPoolResizableAllocator::findfreeblock(uint32 aBlockAlignedSize) +{ + OSCL_ASSERT(aBlockAlignedSize > 0); + OSCL_ASSERT(aBlockAlignedSize == oscl_mem_aligned_size(aBlockAlignedSize)); + + // Treat the mem pool of as if it is one circular buffer + // to prevent fragmentation of the pool + // In most cases, the caller deallocates the blocks in the order that they were allocated + // If we skip around in the mem pool during allocation, because of resizable nature, + // we will be leaving holes if different sizes in the mem pool. + // The deallocated blocks are put back into the pool in address order. + // iMemPoolPrevAllocBuffer keeps track of which buffer the previous allocation was made + // MemPoolBufferInfo field iPrevAllocBlock keeps track of which block the previous allocation was made + // Start from iMemPoolPrevAllocBuffer + iPrevAllocBlock for the next allocate + +#if ENABLE_OSCL_MEM_POOL_RESIZEABLE_ALLOCATOR_DEBUG_LOG + // free list and used list info periodically + if (NULL != iDebugLogger) + { + iDebugLogger->logFreeAndUsedBlocks(iMemPoolBufferList, iMemPoolPrevAllocBufferIndex, true); + } +#endif + + // Go through each mempool buffer and return the first free block that + // is bigger than the specified size + + if (aBlockAlignedSize == 0) + { + // Request should be non-zero + OSCL_LEAVE(OsclErrArgument); + // OSCL_UNUSED_RETURN(NULL); This statement was removed to avoid compiler warning for Unreachable Code + } + + // the free blocks in each buffer are linked together in ascending order, + // starting from the beginning of the buffer to end of the buffer + uint32 numBuffers = iMemPoolBufferList.size(); + uint32 index = iMemPoolPrevAllocBufferIndex; + while (numBuffers > 0) + { + MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[index]; + + MemPoolBlockInfo* freeblockinfo = bufferinfo->iNextFreeBlock; + MemPoolBlockInfo* prevblockinfo = bufferinfo->iPrevAllocBlock; + // look first at the free blocks from iPrevAllocBlock to the end of the buffer + // but note if there is a block that will fit somewhere + bool blockFits = false; + MemPoolBlockInfo* firstFreeBlock = NULL; + while (freeblockinfo != NULL) + { + if ((freeblockinfo->iBlockSize/* - iBlockInfoAlignedSize*/) >= aBlockAlignedSize) + { + if (freeblockinfo > prevblockinfo) + { +#if ENABLE_OSCL_MEM_POOL_RESIZEABLE_ALLOCATOR_DEBUG_LOG + // update count + if (NULL != iDebugLogger) + { + iDebugLogger->incrementAllocCount(); + } +#endif + // This free block fits the request + // remember where this block is allocated from + // so the mem pool can be treated as a circular buffer + // to prevent fragmentation + bufferinfo->iPrevAllocBlock = freeblockinfo; + return freeblockinfo; + } + else if (firstFreeBlock == NULL) + { + // save this block ptr + blockFits = true; + firstFreeBlock = freeblockinfo; + } + } + // Go to the next free block + freeblockinfo = freeblockinfo->iNextFreeBlock; + } + + // did not find a free block from iPrevAllocBlock to end of buffer, + // if we know there is a block that will fit, + // look then from the beginning of the buffer + // otherwise move on to the next buffer + if (blockFits) + { + // remember where this block is allocated from + // so the mem pool can be treated as a circular buffer + // to prevent fragmentation + bufferinfo->iPrevAllocBlock = firstFreeBlock; + return firstFreeBlock; + } + + // did not find anything in this buffer + // look at the next buffer + numBuffers--; + index++; + if (index >= iMemPoolBufferList.size()) + { + // wrap around to the first buffer if needed + index = 0; + } + } + +#if ENABLE_OSCL_MEM_POOL_RESIZEABLE_ALLOCATOR_DEBUG_LOG + // free list and used list info + if (NULL != iDebugLogger) + { + iDebugLogger->logFreeAndUsedBlocks(iMemPoolBufferList, iMemPoolPrevAllocBufferIndex, false); + } +#endif + return NULL; +} + + +OsclAny* OsclMemPoolResizableAllocator::allocateblock(MemPoolBlockInfo& aBlockPtr, uint32 aNumAlignedBytes) +{ + OSCL_ASSERT(aNumAlignedBytes > 0); + OSCL_ASSERT(aNumAlignedBytes == oscl_mem_aligned_size(aNumAlignedBytes)); + + if (aNumAlignedBytes == 0) + { + OSCL_LEAVE(OsclErrArgument); + // OSCL_UNUSED_RETURN(NULL); This statement was removed to avoid compiler warning for Unreachable Code + } + + // Remove the free block from the double linked list + if (aBlockPtr.iPrevFreeBlock == NULL && aBlockPtr.iNextFreeBlock != NULL) + { + // Removing from the beginning of the free list + aBlockPtr.iNextFreeBlock->iPrevFreeBlock = NULL; + aBlockPtr.iParentBuffer->iNextFreeBlock = aBlockPtr.iNextFreeBlock; + } + else if (aBlockPtr.iPrevFreeBlock != NULL && aBlockPtr.iNextFreeBlock == NULL) + { + // Removing from the end of the free list + aBlockPtr.iPrevFreeBlock->iNextFreeBlock = NULL; + } + else if (aBlockPtr.iPrevFreeBlock == NULL && aBlockPtr.iNextFreeBlock == NULL) + { + // Free list becomes empty so update the parent buffer's link + aBlockPtr.iParentBuffer->iNextFreeBlock = NULL; + } + else + { + // Removing from middle of the free list + aBlockPtr.iPrevFreeBlock->iNextFreeBlock = aBlockPtr.iNextFreeBlock; + aBlockPtr.iNextFreeBlock->iPrevFreeBlock = aBlockPtr.iPrevFreeBlock; + } + + aBlockPtr.iNextFreeBlock = NULL; + aBlockPtr.iPrevFreeBlock = NULL; + + aBlockPtr.iParentBuffer->iAllocatedSz += aBlockPtr.iBlockSize; + + // Resize the block if too large + uint32 extraspace = aBlockPtr.iBlockSize - iBlockInfoAlignedSize - aNumAlignedBytes; + if (extraspace > (iBlockInfoAlignedSize + OSCLMEMPOOLRESIZABLEALLOCATOR_MIN_BUFFERSIZE)) + { + trim(aBlockPtr.iBlockBuffer, extraspace); + } + +#if OSCL_MEM_FILL_WITH_PATTERN + oscl_memset(aBlockPtr.iBlockBuffer, 0x55, (aBlockPtr.iBlockSize - iBlockInfoAlignedSize)); +#endif + return aBlockPtr.iBlockBuffer; +} + + +void OsclMemPoolResizableAllocator::deallocateblock(MemPoolBlockInfo& aBlockPtr) +{ + OSCL_ASSERT(aBlockPtr.iParentBuffer); + + MemPoolBufferInfo* bufferinfo = aBlockPtr.iParentBuffer; + MemPoolBlockInfo* rightblockinfo = bufferinfo->iNextFreeBlock; + MemPoolBlockInfo* leftblockinfo = NULL; + + // Go through the free block list and find the free block which would + // become the right neighbor of the block being freed + while (rightblockinfo != NULL) + { + if (&aBlockPtr < rightblockinfo) + { + break; + } + leftblockinfo = rightblockinfo; + rightblockinfo = rightblockinfo->iNextFreeBlock; + } + + // Check where the newly freed block is in the list + if (leftblockinfo == NULL && rightblockinfo == NULL) + { + // The free block list is empty. + // Trivial case so add to list and return to list without merge + bufferinfo->iNextFreeBlock = &aBlockPtr; + aBlockPtr.iNextFreeBlock = NULL; + aBlockPtr.iPrevFreeBlock = NULL; + aBlockPtr.iParentBuffer->iAllocatedSz -= aBlockPtr.iBlockSize; + return; + } + else if (leftblockinfo != NULL && rightblockinfo == NULL) + { + // Adding to the end of the list + OSCL_ASSERT(leftblockinfo->iNextFreeBlock == NULL); + + // Check that the newly freed block doesn't overlap with an existing free block + if (((uint8*)leftblockinfo + leftblockinfo->iBlockSize) > (uint8*)&aBlockPtr) + { + OSCL_LEAVE(OsclErrArgument); + } + + leftblockinfo->iNextFreeBlock = &aBlockPtr; + aBlockPtr.iPrevFreeBlock = leftblockinfo; + aBlockPtr.iNextFreeBlock = NULL; + } + else if (leftblockinfo == NULL && rightblockinfo != NULL) + { + // Adding to the beginning of the list + OSCL_ASSERT(rightblockinfo->iPrevFreeBlock == NULL); + + // Check that the newly freed block doesn't overlap with an existing free block + if (((uint8*)&aBlockPtr + aBlockPtr.iBlockSize) > (uint8*)rightblockinfo) + { + OSCL_LEAVE(OsclErrArgument); + } + + bufferinfo->iNextFreeBlock = &aBlockPtr; + rightblockinfo->iPrevFreeBlock = &aBlockPtr; + aBlockPtr.iPrevFreeBlock = NULL; + aBlockPtr.iNextFreeBlock = rightblockinfo; + } + else + { + // Adding to the middle of the list + OSCL_ASSERT(leftblockinfo->iNextFreeBlock == rightblockinfo); + OSCL_ASSERT(rightblockinfo->iPrevFreeBlock == leftblockinfo); + + // Check that the newly freed block doesn't overlap with the existing free blocks + if (((uint8*)&aBlockPtr + aBlockPtr.iBlockSize) > (uint8*)rightblockinfo || + ((uint8*)leftblockinfo + leftblockinfo->iBlockSize) > (uint8*)&aBlockPtr) + { + OSCL_LEAVE(OsclErrArgument); + } + + leftblockinfo->iNextFreeBlock = &aBlockPtr; + rightblockinfo->iPrevFreeBlock = &aBlockPtr; + aBlockPtr.iPrevFreeBlock = leftblockinfo; + aBlockPtr.iNextFreeBlock = rightblockinfo; + } + aBlockPtr.iParentBuffer->iAllocatedSz -= aBlockPtr.iBlockSize; + + // Merge the newly freed block with neighbors if contiguous + // Check which neighbors are contiguous in memory space + bool rightadj = false; + bool leftadj = false; + if (aBlockPtr.iPrevFreeBlock) + { + MemPoolBlockInfo* leftnb = aBlockPtr.iPrevFreeBlock; + if (((uint8*)leftnb + leftnb->iBlockSize) == (uint8*)&aBlockPtr) + { + leftadj = true; + } + } + if (aBlockPtr.iNextFreeBlock) + { + MemPoolBlockInfo* rightnb = aBlockPtr.iNextFreeBlock; + if (((uint8*)&aBlockPtr + aBlockPtr.iBlockSize) == (uint8*)rightnb) + { + rightadj = true; + } + } + + // Do the merge based on the check + if (leftadj == false && rightadj == true) + { + // Merge the right neighbor with the newly freed block + // Update newly freed block's size and remove the right neighbor from the list + MemPoolBlockInfo* midblock = &aBlockPtr; + MemPoolBlockInfo* rightblock = aBlockPtr.iNextFreeBlock; + // Size update + midblock->iBlockSize += rightblock->iBlockSize; + // Right neighbor removal + if (rightblock->iNextFreeBlock) + { + rightblock->iNextFreeBlock->iPrevFreeBlock = midblock; + } + midblock->iNextFreeBlock = rightblock->iNextFreeBlock; + } + else if (leftadj == true && rightadj == false) + { + // Merge the newly freed block with the left neighbor + // Update the left neighbor's block size to include the newly freed block and + // remove the newly freed block from the list + MemPoolBlockInfo* midblock = &aBlockPtr; + MemPoolBlockInfo* leftblock = aBlockPtr.iPrevFreeBlock; + // Size update + leftblock->iBlockSize += midblock->iBlockSize; + // Newly freed block removal + if (midblock->iNextFreeBlock) + { + midblock->iNextFreeBlock->iPrevFreeBlock = leftblock; + } + leftblock->iNextFreeBlock = midblock->iNextFreeBlock; + } + else if (leftadj == true && rightadj == true) + { + // Merge the newly freed block and right neighbor with the left neighbor + // and remove the newly freed block and right neighbor from the list + MemPoolBlockInfo* midblock = &aBlockPtr; + MemPoolBlockInfo* leftblock = aBlockPtr.iPrevFreeBlock; + MemPoolBlockInfo* rightblock = aBlockPtr.iNextFreeBlock; + // Size update + leftblock->iBlockSize += (midblock->iBlockSize + rightblock->iBlockSize); + // Newly freed and right neighbor block removal + if (rightblock->iNextFreeBlock) + { + rightblock->iNextFreeBlock->iPrevFreeBlock = leftblock; + } + leftblock->iNextFreeBlock = rightblock->iNextFreeBlock; + } +} + + +bool OsclMemPoolResizableAllocator::validateblock(OsclAny* aBlockBufPtr) +{ + uint32 i = 0; + + if (aBlockBufPtr == NULL) + { + // Invalid pointer + return false; + } + + // Check if the pointer falls within one of the memory pool buffer's memory address + for (i = 0; i < iMemPoolBufferList.size(); ++i) + { + MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[i]; + if (aBlockBufPtr > bufferinfo->iStartAddr && aBlockBufPtr < bufferinfo->iEndAddr) + { + break; + } + } + if (i >= iMemPoolBufferList.size()) + { + // Parent buffer is not part of this memory pool instance + return false; + } + + // Retrieve the block info header + MemPoolBlockInfo* chkblock = (MemPoolBlockInfo*)((uint8*)aBlockBufPtr - iBlockInfoAlignedSize); + + if (chkblock->iBlockPreFence != OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN || + chkblock->iBlockPostFence != OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN) + { + // Memory fence checking failed + return false; + } + + // Check the parent buffer is one in the list + MemPoolBufferInfo* parentbuffer = chkblock->iParentBuffer; + if (parentbuffer == NULL) + { + return false; + } + for (i = 0; i < iMemPoolBufferList.size(); ++i) + { + if (parentbuffer == iMemPoolBufferList[i]) + { + break; + } + } + if (i >= iMemPoolBufferList.size()) + { + // Parent buffer is not part of this memory pool instance + return false; + } + + if (aBlockBufPtr < parentbuffer->iStartAddr || aBlockBufPtr > parentbuffer->iEndAddr) + { + // The address of the buffer is not part of the parent buffer + return false; + } + + if ((OsclAny*)((uint8*)chkblock + chkblock->iBlockSize - 1) > (parentbuffer->iEndAddr)) + { + // The block size is too big + return false; + } + + return true; +} + + +OSCL_EXPORT_REF uint32 OsclMemPoolResizableAllocator::getBufferSize() const +{ + if (iMemPoolBufferNumLimit == 0) + OSCL_LEAVE(OsclErrNotSupported); + + uint32 bufferSize = 0; + for (uint32 i = 0; i < iMemPoolBufferList.size(); ++i) + { + MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[i]; + bufferSize += getMemPoolBufferSize(bufferinfo); + } + + return bufferSize; +} + +OSCL_EXPORT_REF uint32 OsclMemPoolResizableAllocator::getAllocatedSize() const +{ + //const uint32 expectedNumBlocksPerBuffer = iExpectedNumBlocksPerBuffer > 0 ? iExpectedNumBlocksPerBuffer : OSCLMEMPOOLRESIZABLEALLOCATOR_DEFAULT_NUMBLOCKPERBUFFER; + uint32 allocatedSz = 0; + for (uint32 i = 0; i < iMemPoolBufferList.size(); ++i) + { + MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[i]; + allocatedSz += getMemPoolBufferAllocatedSize(bufferinfo); + } + return allocatedSz; +} + +OSCL_EXPORT_REF uint32 OsclMemPoolResizableAllocator::getAvailableSize() const +{ + if (iMemPoolBufferNumLimit == 0) + OSCL_LEAVE(OsclErrNotSupported); + + uint32 availableSize = 0; + for (uint32 i = 0; i < iMemPoolBufferList.size(); ++i) + { + MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[i]; + uint32 memPoolBufferAvailableSz = 0; + memPoolBufferAvailableSz = (getMemPoolBufferSize(bufferinfo) - getMemPoolBufferAllocatedSize(bufferinfo)); + availableSize += memPoolBufferAvailableSz; + } + + return availableSize; +} + +OSCL_EXPORT_REF uint32 OsclMemPoolResizableAllocator::getLargestContiguousFreeBlockSize() const +{ + uint32 blockSz = 0; + + if (iMemPoolBufferNumLimit > 0) + { + for (uint32 i = 0; i < iMemPoolBufferList.size(); ++i) + { + MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[i]; + if (bufferinfo) + { + MemPoolBlockInfo* blockinfo = bufferinfo->iNextFreeBlock; + while (blockinfo != NULL) + { + if (blockinfo->iBlockSize > blockSz) blockSz = blockinfo->iBlockSize; + blockinfo = blockinfo->iNextFreeBlock; + } + } + } + } + else + OSCL_LEAVE(OsclErrNotSupported); + + if (blockSz > iBlockInfoAlignedSize) blockSz -= iBlockInfoAlignedSize; + else blockSz = 0; + + return blockSz; +} + +OSCL_EXPORT_REF bool OsclMemPoolResizableAllocator::setMaxSzForNewMemPoolBuffer(uint32 aMaxNewMemPoolBufferSz) +{ + bool retval = true; + if (iMemPoolBufferNumLimit > 0) + iMaxNewMemPoolBufferSz = aMaxNewMemPoolBufferSz; + else + retval = false; + return retval; +} + +uint32 OsclMemPoolResizableAllocator::getMemPoolBufferSize(MemPoolBufferInfo* aBufferInfo) const +{ + uint32 memPoolBufferSz = 0; + + if (aBufferInfo) + memPoolBufferSz = aBufferInfo->iBufferSize; + + return memPoolBufferSz; +} + +uint32 OsclMemPoolResizableAllocator::getMemPoolBufferAllocatedSize(MemPoolBufferInfo* aBufferInfo) const +{ + return aBufferInfo->iAllocatedSz; + /* + uint32 allocatedSz = 0; + const uint32 expectedNumBlocksPerBuffer = iExpectedNumBlocksPerBuffer > 0 ? iExpectedNumBlocksPerBuffer : OSCLMEMPOOLRESIZABLEALLOCATOR_DEFAULT_NUMBLOCKPERBUFFER; + + if (aBufferInfo) + { + if (aBufferInfo->iNumOutstanding > expectedNumBlocksPerBuffer) + { + allocatedSz = (aBufferInfo->iAllocatedSz - (expectedNumBlocksPerBuffer * iBlockInfoAlignedSize)); + } + else + { + allocatedSz = (aBufferInfo->iAllocatedSz - (aBufferInfo->iNumOutstanding * iBlockInfoAlignedSize)); + } + } + return allocatedSz; + */ +} + +uint32 OsclMemPoolResizableAllocator::memoryPoolBufferMgmtOverhead() const +{ + uint32 overheadBytes = iBufferInfoAlignedSize; + if (iExpectedNumBlocksPerBuffer > 0) + { + overheadBytes += (iExpectedNumBlocksPerBuffer * iBlockInfoAlignedSize); + } + else + { + overheadBytes += (OSCLMEMPOOLRESIZABLEALLOCATOR_DEFAULT_NUMBLOCKPERBUFFER * iBlockInfoAlignedSize); + } + return overheadBytes; +} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_mempool.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_mempool.h new file mode 100644 index 0000000..b93e26b --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclmemory/src/oscl_mem_mempool.h @@ -0,0 +1,377 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M E M _ M E M P O O L + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclmemory OSCL Memory + * + * @{ + */ + + +/*! \file oscl_mem_mempool.h + \brief This file contains the definition of memory pool allocators +*/ + + +#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED +#define OSCL_MEM_MEMPOOL_H_INCLUDED + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +class OsclMemPoolResizableAllocatorLogger; + +/** \class allocator +** A memory allocator class which allocates and deallocates from a fixed size memory pool; +** The memory pool is a multiple of fixed chunk size and does not grow. All allocation size must be the same as this chunk size. +** +*/ + +class OsclMemPoolFixedChunkAllocatorObserver +{ + public: + virtual void freechunkavailable(OsclAny* aContextData) = 0; + virtual ~OsclMemPoolFixedChunkAllocatorObserver() {} +}; + +class OsclMemPoolFixedChunkAllocator : public Oscl_DefAlloc +{ + public: + /** This API throws an exception when the memory allocation for pool fails + * If numchunk and chunksize parameters are not set, memory pool of 1 chunk will be created in the first call to allocate. + * The chunk size will be set to the n passed in for allocate(). + * If numchunk parameter is set to 0, the memory pool will use 1 for numchunk. + * If chunkalignment is set to 0, memory pool will use default allocator alignment (8-byte) + * If chunkalignment is > 0, memory pool will align all buffers in the mempool to the specified alignment. Alignment should be a power of 2 + * + * @return void + * + */ + OSCL_IMPORT_REF OsclMemPoolFixedChunkAllocator(const uint32 numchunk = 1, const uint32 chunksize = 0, Oscl_DefAlloc* gen_alloc = NULL, const uint32 chunkalignment = 0); + + /** This API will disable exceptions in case the memory pool runs out of memory + * Instead of doing "OSCL_LEAVE(OsclErrNoResources)" allocate API will return + * NULL. + * + * @return void + * + */ + OSCL_IMPORT_REF virtual void enablenullpointerreturn(); + + /** The destructor for the memory pool + */ + OSCL_IMPORT_REF virtual ~OsclMemPoolFixedChunkAllocator(); + + /** This API throws an exception when n is greater than the fixed chunk size or there are no free chunk available in the pool, + * if "enablenullpointerreturn" has not been called. + * If the memory pool hasn't been created yet, the pool will be created with chunk size equal to n so n must be greater than 0. + * Exception will be thrown if memory allocation for the memory pool fails. + * + * @return pointer to available chunk from memory pool + * + */ + OSCL_IMPORT_REF virtual OsclAny* allocate(const uint32 n); + + /** This API throws an exception when the pointer p passed in is not part of the memory pool. + * Exception will be thrown if the memory pool is not set up yet. + * + * @return void + * + */ + OSCL_IMPORT_REF virtual void deallocate(OsclAny* p); + + /** This API will set the flag to send a callback via specified observer object when the + * next memory chunk is deallocated by deallocate() call.. + * + * @return void + * + */ + OSCL_IMPORT_REF virtual void notifyfreechunkavailable(OsclMemPoolFixedChunkAllocatorObserver& obs, OsclAny* aContextData = NULL); + + /** This API will cancel any past callback requests.. + * + * @return void + * + */ + OSCL_IMPORT_REF virtual void CancelFreeChunkAvailableCallback(); + + /** Increments the reference count for this memory pool allocator + * + * @return void + * + */ + OSCL_IMPORT_REF void addRef(); + + /** Decrements the reference count for this memory pool allocator + * When the reference count goes to 0, this instance of the memory pool object is deleted + * + * @return void + * + */ + OSCL_IMPORT_REF void removeRef(); + + protected: + OSCL_IMPORT_REF virtual void createmempool(); + OSCL_IMPORT_REF virtual void destroymempool(); + + uint32 iNumChunk; + uint32 iChunkSize; + uint32 iChunkSizeMemAligned; + uint32 iChunkAlignment; + Oscl_DefAlloc* iMemPoolAllocator; + OsclAny* iMemPool; + OsclAny* iMemPoolAligned; + + Oscl_Vector iFreeMemChunkList; + + bool iCheckNextAvailableFreeChunk; + OsclMemPoolFixedChunkAllocatorObserver* iObserver; + OsclAny* iNextAvailableContextData; + + int32 iRefCount; + bool iEnableNullPtrReturn; +}; + + +/** \class allocator +** A memory allocator class which allocates and deallocates from a fixed size memory pool; +** The memory pool is one block of memory and allocations are not fixed in size. The memory pool +** also has the capability of growing by allocating more block one at a time. This memory pool +** also provides the capability of returning the tail end of memory previously allocated from +** the memory pool +** +*/ + +class OsclMemPoolResizableAllocatorObserver +{ + public: + virtual void freeblockavailable(OsclAny* aContextData) = 0; + virtual ~OsclMemPoolResizableAllocatorObserver() {} +}; + +class OsclMemPoolResizableAllocatorMemoryObserver +{ + public: + virtual void freememoryavailable(OsclAny* aContextData) = 0; + virtual ~OsclMemPoolResizableAllocatorMemoryObserver() {} +}; + +class OsclMemPoolResizableAllocator : public Oscl_DefAlloc +{ + public: + /** Create the memory pool allocator with resizing functionality. + * The size of the memory pool buffer needs to be passed-in. The maximum number of + * memory pool buffers, expected number of blocks in a memory pool buffer, and outside allocator are optional. + * This API throws an exception when the memory allocation for the pool buffer fails. + * If memory pool buffer number limit parameter is not set, the assumption is that + * there is no limit and memory pool will grow as needed. + * If the expected number of blocks is not set or not known, the memory pool will use + * a default value to 10 to allocate extra memory for the block info header. + * + * @return void + * + */ + OSCL_IMPORT_REF OsclMemPoolResizableAllocator(uint32 aMemPoolBufferSize, uint32 aMemPoolBufferNumLimit = 0, uint32 aExpectedNumBlocksPerBuffer = 0, Oscl_DefAlloc* gen_alloc = NULL); + + /** This API will disable exceptions in case the memory pool runs out of memory + * Instead of doing "OSCL_LEAVE(OsclErrNoResources)" allocate API will return + * NULL. + * + * @return void + * + */ + OSCL_IMPORT_REF virtual void enablenullpointerreturn(); + + /** Allocates a block from the memory pool that is at least in size requested + * This API throws an exception if there isn't enough memory (if "enablenullpointerreturn" has not been called) + * for the requested amount in the pool or if the extra pool buffer cannot be allocated. + * + * @return Pointer to memory buffer from memory pool + * + */ + OSCL_IMPORT_REF virtual OsclAny* allocate(const uint32 aNumBytes); + + /** Deallocates and returns a block back to the memory pool + * This API throws an exception if the pointer passed in is not part of the memory pool, aligned, or has corrupted block header. + * + * @return void + * + */ + OSCL_IMPORT_REF virtual void deallocate(OsclAny* aPtr); + + /** Returns a tail segment of a previously allocated memory block back to the memory pool. The passed-in + * pointer to the memory buffer is still valid after the call completes but the buffer size is smaller by + * by specified amount that was freed. + * This function allows the user to allocate a larger size block initially when the amount needed is unknown + * and then return the unused portion of the block when the amount becomes known. + * This API throws an exception if the pointer passed in is not part of the memory pool or the + * size to return is bigger than the size of the passed-in block. + * Exception will be thrown if the memory pool is not set up yet. + * + * @return bool True if trim operation successful. False if the block wasn't trimmed + * + */ + OSCL_IMPORT_REF virtual bool trim(OsclAny* aPtr, uint32 aBytesToFree); + + /** Returns the size of the buffer + */ + OSCL_IMPORT_REF uint32 getBufferSize() const; + + /** Returns the number of bytes allocated from the buffer + */ + OSCL_IMPORT_REF virtual uint32 getAllocatedSize() const; + + /** Returns the number of bytes available with the buffer + */ + OSCL_IMPORT_REF virtual uint32 getAvailableSize() const; + + /** Returns the size of the largest available chunk in the memory. + */ + OSCL_IMPORT_REF virtual uint32 getLargestContiguousFreeBlockSize() const; + + OSCL_IMPORT_REF virtual bool setMaxSzForNewMemPoolBuffer(uint32 aMaxNewMemPoolBufferSz); + + /** This API will set the flag to send a callback via specified observer object when the + * next memory block is deallocated by deallocate() call. If the optional requested size + * parameter is set, the callback is sent when a free memory space of requested size becomes available. + * The optional context data is returned with the callback and can be used by the user to + * differentiate.between different instances of memory pool objects. + * This memory pool only allows one notify to be queued. Another call to this function will just overwrite + * the previous call. + * + * @return void + * + */ + OSCL_IMPORT_REF virtual void notifyfreeblockavailable(OsclMemPoolResizableAllocatorObserver& aObserver, uint32 aRequestedSize = 0, OsclAny* aContextData = NULL); + + /** This API will cancel any past callback requests.. + * + * @return void + * + */ + OSCL_IMPORT_REF virtual void CancelFreeChunkAvailableCallback(); + + OSCL_IMPORT_REF virtual void notifyfreememoryavailable(OsclMemPoolResizableAllocatorMemoryObserver& aObserver, uint32 aRequestedSize = 0, OsclAny* aContextData = NULL); + OSCL_IMPORT_REF void CancelFreeMemoryAvailableCallback(); + + /** Increments the reference count for this memory pool allocator + * + * @return void + * + */ + OSCL_IMPORT_REF void addRef(); + + /** Decrements the reference count for this memory pool allocator + * When the reference count goes to 0, this instance of the memory pool object is deleted + * + * @return void + * + */ + OSCL_IMPORT_REF void removeRef(); + + struct MemPoolBlockInfo; + + struct MemPoolBufferInfo + { + uint32 iBufferPreFence; // Pre-fence to check for memory corruption + OsclAny* iStartAddr; // Starting memory address of the memory pool buffer after the buffer info + OsclAny* iEndAddr; // Ending memory address of the memory pool buffer + uint32 iBufferSize; // Total size of the memory pool buffer including the buffer info header + uint32 iNumOutstanding; // Number of outstanding blocks from this memory pool buffer + MemPoolBlockInfo* iNextFreeBlock; // Pointer to the next free memory block + MemPoolBlockInfo* iPrevAllocBlock; // Pointer to the previouly allocated memory block + uint32 iAllocatedSz; //Number of butes allocated from the mempool + uint32 iBufferPostFence; // Post-fence to check for memory corruption + }; + + struct MemPoolBlockInfo + { + uint32 iBlockPreFence; // Pre-fence to check for memory corruption + MemPoolBlockInfo* iNextFreeBlock; // Pointer to the next (right neighbor) free block in the buffer. NULL if none. + MemPoolBlockInfo* iPrevFreeBlock; // Pointer to the previous (left neighbor) free block in the buffer. NULL if first free block + uint32 iBlockSize; // Total size of the block including the block info header + uint8* iBlockBuffer; // Pointer to the buffer area of the block + MemPoolBufferInfo* iParentBuffer; // Pointer to the block's parent memory pool buffer + uint32 iBlockPostFence; // Post-fence to check for memory corruption + }; + + + protected: + + /** The destructor for the memory pool. Should not be called directly. Use removeRef() instead. + */ + virtual ~OsclMemPoolResizableAllocator(); + + MemPoolBufferInfo* addnewmempoolbuffer(uint32 aBufferSize); + void destroyallmempoolbuffers(); + MemPoolBlockInfo* findfreeblock(uint32 aBlockSize); + OsclAny* allocateblock(MemPoolBlockInfo& aBlockPtr, uint32 aNumBytes); + void deallocateblock(MemPoolBlockInfo& aBlockPtr); + bool validateblock(OsclAny* aBlockBufPtr); + + uint32 iMemPoolBufferSize; + uint32 iMemPoolBufferNumLimit; + uint32 iExpectedNumBlocksPerBuffer; + uint32 iMaxNewMemPoolBufferSz; + Oscl_DefAlloc* iMemPoolBufferAllocator; + Oscl_Vector iMemPoolBufferList; + uint32 iMemPoolPrevAllocBufferIndex; + + uint32 iBufferInfoAlignedSize; + uint32 iBlockInfoAlignedSize; + + bool iCheckNextAvailable; + uint32 iRequestedNextAvailableSize; + OsclAny* iNextAvailableContextData; + OsclMemPoolResizableAllocatorObserver* iObserver; + + bool iCheckFreeMemoryAvailable; + uint32 iRequestedAvailableFreeMemSize; + OsclAny* iFreeMemContextData; + OsclMemPoolResizableAllocatorMemoryObserver* iFreeMemPoolObserver; + + int32 iRefCount; + bool iEnableNullPtrReturn; + //To compute the size of the buffer, excluding the extra memory in the buffer for its management + uint32 getMemPoolBufferSize(MemPoolBufferInfo* aBufferInfo) const; + //To compute the number of bytes allocated from the buffer + uint32 getMemPoolBufferAllocatedSize(MemPoolBufferInfo* aBufferInfo) const; + //To compute the addition bytes which were allocated while createing the memory pool for the buffer. + uint32 memoryPoolBufferMgmtOverhead() const; + + OsclMemPoolResizableAllocatorLogger* iDebugLogger; +}; + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/Android.mk new file mode 100644 index 0000000..91077e6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/Android.mk @@ -0,0 +1,54 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/oscl_execschedulerbase.cpp \ + src/oscl_scheduler.cpp \ + src/oscl_scheduler_ao.cpp \ + src/oscl_scheduler_readyq.cpp \ + src/oscl_scheduler_threadcontext.cpp \ + src/oscl_double_list.cpp \ + src/oscl_timer.cpp \ + src/oscl_timerbase.cpp \ + src/oscl_mutex.cpp \ + src/oscl_semaphore.cpp \ + src/oscl_thread.cpp \ + src/oscl_init.cpp + + +LOCAL_MODULE := libosclproc + +LOCAL_CFLAGS := $(PV_CFLAGS) + + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/oscl/oscl/osclproc/src \ + $(PV_TOP)/oscl/oscl/osclproc/src \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + src/oscl_aostatus.h \ + src/oscl_aostatus.inl \ + src/oscl_scheduler.h \ + src/oscl_scheduler_aobase.h \ + src/oscl_scheduler_ao.h \ + src/oscl_scheduler_readyq.h \ + src/oscl_scheduler_threadcontext.h \ + src/oscl_scheduler_types.h \ + src/oscl_scheduler_tuneables.h \ + src/oscl_double_list.h \ + src/oscl_double_list.inl \ + src/oscl_timer.h \ + src/oscl_mutex.h \ + src/oscl_semaphore.h \ + src/oscl_thread.h \ + src/oscl_procstatus.h \ + src/oscl_init.h + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/build/make/local.mk new file mode 100644 index 0000000..2d8dd59 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/build/make/local.mk @@ -0,0 +1,45 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + +TARGET := osclproc + + +SRCDIR := ../../src +INCSRCDIR := ../../src + +SRCS := oscl_execschedulerbase.cpp \ + oscl_scheduler.cpp \ + oscl_scheduler_ao.cpp \ + oscl_scheduler_readyq.cpp \ + oscl_scheduler_threadcontext.cpp \ + oscl_double_list.cpp \ + oscl_timer.cpp \ + oscl_timerbase.cpp \ + oscl_mutex.cpp \ + oscl_semaphore.cpp \ + oscl_thread.cpp \ + oscl_init.cpp + +HDRS := oscl_aostatus.h \ + oscl_aostatus.inl \ + oscl_scheduler.h \ + oscl_scheduler_aobase.h \ + oscl_scheduler_ao.h \ + oscl_scheduler_readyq.h \ + oscl_scheduler_threadcontext.h \ + oscl_scheduler_types.h \ + oscl_scheduler_tuneables.h \ + oscl_double_list.h \ + oscl_double_list.inl \ + oscl_timer.h \ + oscl_mutex.h \ + oscl_semaphore.h \ + oscl_thread.h \ + oscl_procstatus.h \ + oscl_init.h + +include $(MK)/library.mk + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_aostatus.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_aostatus.h new file mode 100644 index 0000000..15d7941 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_aostatus.h @@ -0,0 +1,73 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/*! \addtogroup osclproc OSCL Proc + * + * @{ + */ + +/** \file oscl_aostatus.h + \brief Some basic types used with active objects. +*/ +#ifndef OSCL_AOSTATUS_H_INCLUDED +#define OSCL_AOSTATUS_H_INCLUDED + +#ifndef OSCLCONFIG_PROC_H_INCLUDED +#include "osclconfig_proc.h" +#endif + + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +//Request status values. These are negative so that +//they won't conflict with system error codes. +const int32 OSCL_REQUEST_ERR_NONE = 0; +const int32 OSCL_REQUEST_PENDING = (-0x7fffffff); +const int32 OSCL_REQUEST_ERR_CANCEL = (-1); +const int32 OSCL_REQUEST_ERR_GENERAL = (-2); + + +//Request status type +class OsclAOStatus +{ + public: + OSCL_INLINE OsclAOStatus(); + OSCL_INLINE OsclAOStatus(int32 aStatus); + OSCL_INLINE int32 operator=(int32 aStatus); + OSCL_INLINE int32 operator==(int32 aStatus) const; + OSCL_INLINE int32 operator!=(int32 aStatus) const; + OSCL_INLINE int32 operator>=(int32 aStatus) const; + OSCL_INLINE int32 operator<=(int32 aStatus) const; + OSCL_INLINE int32 operator>(int32 aStatus) const; + OSCL_INLINE int32 operator<(int32 aStatus) const; + OSCL_INLINE int32 Value() const; + private: + int32 iStatus; +}; + + +#if !(OSCL_DISABLE_INLINES) +#include "oscl_aostatus.inl" +#endif + + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_aostatus.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_aostatus.inl new file mode 100644 index 0000000..71683fb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_aostatus.inl @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/** \file oscl_aostatus.inl + \brief Inline functions for oscl_aostatus.h +*/ + + +OSCL_INLINE OsclAOStatus::OsclAOStatus() +{} +OSCL_INLINE OsclAOStatus::OsclAOStatus(int32 aVal) + : iStatus(aVal) +{} +OSCL_INLINE int32 OsclAOStatus::operator=(int32 aVal) +{ + return(iStatus = aVal); +} +OSCL_INLINE int32 OsclAOStatus::operator==(int32 aVal) const +{ + return(iStatus == aVal); +} +OSCL_INLINE int32 OsclAOStatus::operator!=(int32 aVal) const +{ + return(iStatus != aVal); +} +OSCL_INLINE int32 OsclAOStatus::operator>=(int32 aVal) const +{ + return(iStatus >= aVal); +} +OSCL_INLINE int32 OsclAOStatus::operator<=(int32 aVal) const +{ + return(iStatus <= aVal); +} +OSCL_INLINE int32 OsclAOStatus::operator>(int32 aVal) const +{ + return(iStatus > aVal); +} +OSCL_INLINE int32 OsclAOStatus::operator<(int32 aVal) const +{ + return(iStatus < aVal); +} +OSCL_INLINE int32 OsclAOStatus::Value() const +{ + return(iStatus); +} + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_double_list.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_double_list.cpp new file mode 100644 index 0000000..59ba9c2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_double_list.cpp @@ -0,0 +1,164 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "osclconfig_proc.h" + +//Doubly-linked list implementation + +#include "oscl_scheduler.h" +#include "oscl_error.h" +#include "oscl_assert.h" + +#if (OSCL_DISABLE_INLINES) +//#include "oscl_aostatus.inl" +#endif + +////////////////////////////////// +// OsclDoubleLink +////////////////////////////////// + +void OsclDoubleLink::InsertAfter(OsclDoubleLink *aLink) +//add this item after aLink +{ + iPrev = aLink; + if (aLink) + { + iNext = aLink->iNext; + aLink->iNext = this; + if (iNext) + iNext->iPrev = this; + } +} + +void OsclDoubleLink::InsertBefore(OsclDoubleLink *aLink) +//add this item before aLink +{ + iNext = aLink; + if (aLink) + { + iPrev = aLink->iPrev; + aLink->iPrev = this; + if (iPrev) + iPrev->iNext = this; + } +} + +void OsclDoubleLink::Remove() +//remove this item. +{ + if (iNext) + { + iNext->iPrev = iPrev; + if (iPrev) + iPrev->iNext = iNext; + } + iNext = iPrev = NULL; +} + + +////////////////////////////////// +// OsclDoubleListBase +////////////////////////////////// +OsclDoubleListBase::OsclDoubleListBase() +{ + iOffset = (-1);//invalid. + iHead.iNext = iHead.iPrev = &iHead; +} + +bool OsclDoubleListBase::IsEmpty()const +{ + return ((void*)iHead.iNext == (void*)&iHead); +} + +void OsclDoubleListBase::SetOffset(int32 aOffset) +//offset contains the offset into the TAny item of its TDblQueLinkBase item. +{ + //offset should not be negative. + OSCL_ASSERT(aOffset >= 0); + + //just save it for later. + iOffset = aOffset; +} + +void OsclDoubleListBase::InsertHead(OsclAny* aPtr) +{ + //offset must be set before calling this + OSCL_ASSERT(iOffset >= 0); + + //find the item link + OsclDoubleLink * link = (OsclDoubleLink *)OsclPtrAdd(aPtr, iOffset); + if (IsEmpty()) + { + //make the head of the que point to this item link + iHead.iNext = link; + iHead.iPrev = link; + + //make the item link point back to the head + link->iPrev = &iHead; + link->iNext = &iHead; + } + else + { + link->InsertBefore(iHead.iNext); + } +} + +void OsclDoubleListBase::InsertTail(OsclAny* aPtr) +{ + //offset must be set before calling this + OSCL_ASSERT(iOffset >= 0); + + //find the item link + OsclDoubleLink * link = (OsclDoubleLink *)OsclPtrAdd(aPtr, iOffset); + + if (IsEmpty()) + InsertHead(aPtr); + else + link->InsertAfter(iHead.iPrev); +} + +void OsclDoubleListBase::Insert(OsclAny* aPtr) +//sorted queue insert. This inserts an item at the +//end of its priority group. +{ + //offset must be set before calling this + OSCL_ASSERT(iOffset >= 0); + if (IsEmpty()) + InsertHead(aPtr); + else + { + //find the item link + OsclPriorityLink* link = (OsclPriorityLink*)OsclPtrAdd(aPtr, iOffset); + + OsclPriorityLink* itemlink = (OsclPriorityLink*)iHead.iNext; + while (itemlink) + { + //add before first item with lower priority. + if (link->iPriority > itemlink->iPriority) + { + link->InsertBefore(itemlink); + return; + } + + if (itemlink->iNext == &iHead) + break; + itemlink = (OsclPriorityLink*)itemlink->iNext; + } + //no lower pri items-- add to end. + link->InsertAfter(iHead.iPrev); + } +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_double_list.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_double_list.h new file mode 100644 index 0000000..8b342b3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_double_list.h @@ -0,0 +1,223 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/*! \addtogroup osclproc OSCL Proc + * + * @{ + */ + +/** \file oscl_double_list.h + \brief Internal use types for scheduler +*/ +#ifndef OSCL_DOUBLE_LIST_H_INCLUDED +#define OSCL_DOUBLE_LIST_H_INCLUDED + +#ifndef OSCLCONFIG_PROC_H_INCLUDED +#include "osclconfig_proc.h" +#endif + + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_ASSERT_H_INCLUDED +#include "oscl_assert.h" +#endif + + +//OsclDoubleList and OsclPriorityList are used in the internal scheduler implementation. +//All the IMPORT_C was removed so they're not available as +//public APIs. + +template +inline T* OsclPtrAdd(T* aPtr, S aVal) +{ + return((T*)(((uint8*)aPtr) + aVal)); +} + +template +inline T* OsclPtrSub(T* aPtr, S aVal) +{ + return((T*)(((uint8*)aPtr) - aVal)); +} + +class OsclDoubleLink +{ + public: + OsclDoubleLink() : iNext(NULL) {} + void Remove(); + void InsertAfter(OsclDoubleLink* aLink); + void InsertBefore(OsclDoubleLink* aLink); + public: + OsclDoubleLink* iNext; + OsclDoubleLink* iPrev; +}; + + +class OsclReadyQ; +class OsclPriorityLink : public OsclDoubleLink +{ + public: + int32 iPriority; +}; + +class OsclDoubleListBase +{ + public: + bool IsEmpty() const; + void SetOffset(int32 anOffset); + void Reset(); + OsclDoubleLink* getHead() + { + return &iHead; + } + int32 getOffset() + { + return iOffset; + } + protected: + OsclDoubleListBase(); + OsclDoubleListBase(int32 anOffset); + void InsertHead(OsclAny* aPtr); + void InsertTail(OsclAny* aPtr); + void Insert(OsclAny* aPtr); + protected: + OsclDoubleLink iHead; + int32 iOffset; + private: + OsclDoubleListBase(const OsclDoubleListBase& aList); + OsclDoubleListBase& operator=(const OsclDoubleListBase& aList); +}; + + + +template +class OsclDoubleList : public OsclDoubleListBase +{ + public: + OSCL_INLINE OsclDoubleList(); + OSCL_INLINE OsclDoubleList(int32 anOffset); + OSCL_INLINE void InsertHead(T& aRef); + OSCL_INLINE void InsertTail(T& aRef); + OSCL_INLINE bool IsHead(const T* aPtr) const; + OSCL_INLINE bool IsTail(const T* aPtr) const; + OSCL_INLINE T* Head() const; + OSCL_INLINE T* Tail() const; +}; + +template +class OsclPriorityList : public OsclDoubleListBase +{ + public: + OSCL_INLINE OsclPriorityList(); + OSCL_INLINE OsclPriorityList(int32 anOffset); + OSCL_INLINE void Insert(T& aRef); + OSCL_INLINE bool IsHead(const T* aPtr) const; + OSCL_INLINE bool IsTail(const T* aPtr) const; + OSCL_INLINE T* Head() const; + OSCL_INLINE T* Tail() const; +}; + +// +class OsclDoubleListBase; + +template +class OsclDoubleRunner +{ + public: + OsclDoubleRunner(OsclDoubleListBase& aQue) + { + //save the queue information. + iOffset = aQue.getOffset(); + iHead = aQue.getHead(); + iNext = NULL; + } + + void Set(T& aLink) + { + iNext = (OsclDoubleLink*)OsclPtrAdd(aLink, iOffset); + } + + //This was inline but ADS 1.2 compiler gets a link error from it... + operator T*() + { + if (iNext) + return ((T *)OsclPtrSub(iNext, iOffset)); + return NULL; + } + + T* operator++(int) + { + //get current. + OsclAny* p = NULL; + if (iNext) + p = ((OsclAny *)OsclPtrSub(iNext, iOffset)); + + //advance. + if (iNext) + iNext = iNext->iNext; + //return current. + return ((T *)p); + } + + T* operator--(int); + + public: + void SetToHead() + { + iNext = iHead->iNext; + } + void SetToTail() + { + iNext = iHead->iPrev; + } + protected: + int32 iOffset; + OsclDoubleLink* iHead; + OsclDoubleLink* iNext; +}; + + + + +//#if !(OSCL_DISABLE_INLINES) +#include "oscl_double_list.inl" +//#endif + + + +//Some handy macros +#define QUE_ITER_BEGIN(_type,_qname)\ + if (!_qname.IsEmpty())\ + {\ + OsclDoubleRunner <_type> iter(_qname);\ + _type *item;\ + for (iter.SetToHead(); ;iter++)\ + {\ + item=iter;\ + +#define QUE_ITER_END(_qname)\ + if (_qname.IsTail(item))\ + break;\ + }\ + } + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_double_list.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_double_list.inl new file mode 100644 index 0000000..70fb84d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_double_list.inl @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// Class OsclDoubleList +template +OSCL_INLINE OsclDoubleList::OsclDoubleList() +{} +template +OSCL_INLINE OsclDoubleList::OsclDoubleList(int32 anOffset) + : OsclDoubleListBase(anOffset) +{} +template +OSCL_INLINE void OsclDoubleList::InsertHead(T &aRef) +{ + OsclDoubleListBase::InsertHead(&aRef); +} +template +OSCL_INLINE void OsclDoubleList::InsertTail(T &aRef) +{ + OsclDoubleListBase::InsertTail(&aRef); +} +template +OSCL_INLINE bool OsclDoubleList::IsHead(const T *aPtr) const +{ + return(OsclPtrAdd(aPtr, iOffset) == (T *)&iHead); +} +template +OSCL_INLINE bool OsclDoubleList::IsTail(const T *aPtr) const +{ + return(OsclPtrAdd(aPtr, iOffset) == (T *)iHead.iPrev); +} +template +OSCL_INLINE T *OsclDoubleList::Head() const +{ + OSCL_ASSERT(!IsEmpty()); + return(OsclPtrSub((T *)iHead.iNext, iOffset)); +} +template +OSCL_INLINE T *OsclDoubleList::Tail() const +{ + OSCL_ASSERT(!IsEmpty()); + return(OsclPtrSub((T *)iHead.iPrev, iOffset)); +} + +// Class OsclPriorityList +template +OSCL_INLINE OsclPriorityList::OsclPriorityList() +{} +template +OSCL_INLINE OsclPriorityList::OsclPriorityList(int32 anOffset) + : OsclDoubleListBase(anOffset) +{} +template +OSCL_INLINE void OsclPriorityList::Insert(T &aRef) +{ + OsclDoubleListBase::Insert(&aRef); +} +template +OSCL_INLINE bool OsclPriorityList::IsHead(const T *aPtr) const +{ + return(OsclPtrAdd(aPtr, iOffset) == (T *)&iHead); +} +template +OSCL_INLINE bool OsclPriorityList::IsTail(const T *aPtr) const +{ + return(OsclPtrAdd(aPtr, iOffset) == (T *)iHead.iPrev); +} +template +OSCL_INLINE T *OsclPriorityList::Head() const +{ + OSCL_ASSERT(!IsEmpty()); + return(OsclPtrSub((T *)iHead.iNext, iOffset)); +} +template +OSCL_INLINE T *OsclPriorityList::Tail() const +{ + OSCL_ASSERT(!IsEmpty()); + return(PtrSub((T *)iHead.iPrev, iOffset)); +} + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_execschedulerbase.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_execschedulerbase.cpp new file mode 100644 index 0000000..68d17bf --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_execschedulerbase.cpp @@ -0,0 +1,64 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "osclconfig_proc.h" + +//The OsclExecSchedulerBase class provides a subset of Symbian +//CActiveScheduler functionality. + +#include "oscl_scheduler.h" +#include "oscl_error.h" +#include "oscl_error_imp.h" + +OsclExecSchedulerBase::OsclExecSchedulerBase() +//constructor +{ +} + +OsclExecSchedulerBase::~OsclExecSchedulerBase() +//destructor +{ +} + +void OsclExecSchedulerBase::Error(int32 anError) const +//virtual method--default error handler. +{ + OSCL_UNUSED_ARG(anError); + //"The default method raises E32User Cbase 47 panic + OsclError::Leave(OsclErrNoHandler);//EExecObjectLeave +} + +void OsclExecSchedulerBase::OnStarting() +//virtual method +{ + //"The default method does nothing" +} + +void OsclExecSchedulerBase::OnStopping() +//virtual method +{ + //"The default method does nothing" +} + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_init.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_init.cpp new file mode 100644 index 0000000..7f56b41 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_init.cpp @@ -0,0 +1,226 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_init.h" +#include "oscl_base.h" +#include "oscl_mem.h" +#include "oscl_scheduler.h" +#include "oscl_error.h" +#include "pvlogger.h" + +static void _OsclInit2(const OsclSelect &aSelect) +//do all init after error trap... +{ + if (aSelect.iOsclMemory) + { + OsclMem::Init(); + } + if (aSelect.iOsclLogger) + { + PVLogger::Init(); + } + if (aSelect.iOsclScheduler) + { + OsclScheduler::Init( + (aSelect.iSchedulerName) ? aSelect.iSchedulerName : "OsclScheduler" + , aSelect.iSchedulerAlloc + , aSelect.iSchedulerReserve); + } +} + +//need this routine to avoid a longjmp clobber warning. +static void _OsclInit2(int32 &aErr, const OsclSelect &aSelect) +{ + OSCL_TRY(aErr, _OsclInit2(aSelect);); +} + +OSCL_EXPORT_REF void OsclInit::Init( + int32 &err + , const OsclSelect *p +) +{ + err = OsclErrNone; + + //Use default parameters if none were input. + OsclSelect defaultselect; + const OsclSelect* select = (p) ? p : &defaultselect; + +#if defined( OSCL_MEM_HEAPMARK) + if (select->iHeapCheck) + { + OSCL_MEM_HEAPMARK; + } +#endif + + if (select->iOsclBase) + { + err = OsclBase::Init(); + if (err) + return; + } + + bool trapit = false; + if (select->iOsclErrorTrap) + { + err = OsclErrorTrap::Init(select->iErrAlloc); + if (err) + { + OsclBase::Cleanup(); + return; + } + trapit = true; + } + + //Do remaining init under a trap, if available. + if (trapit) + { + _OsclInit2(err, *select); + } + else + { + _OsclInit2(*select); + } +} + + +//Note: need these routines to avoid longjmp clobber warnings from some compilers. +static void _OsclSchedulerCleanup(int32 &aErr) +{ + OSCL_TRY(aErr, OsclScheduler::Cleanup();); +} + +static void _OsclLoggerCleanup(int32 &aErr) +{ + OSCL_TRY(aErr, PVLogger::Cleanup();); +} + +#include "oscl_mem_audit.h" + +static void _OsclMemCleanup(FILE* aFile) +{ +#if (OSCL_BYPASS_MEMMGT) + OSCL_UNUSED_ARG(aFile); +#else + if (aFile) + { + //Check for memory leaks before cleaning up OsclMem. + OsclAuditCB auditCB; + OsclMemInit(auditCB); + if (auditCB.pAudit + && auditCB.pAudit->MM_GetRefCount() == 1) + { + MM_Stats_t* stats = auditCB.pAudit->MM_GetStats(""); + if (stats) + { + fprintf(aFile, "Memory Stats:\n"); + fprintf(aFile, " peakNumAllocs %d\n", stats->peakNumAllocs); + fprintf(aFile, " peakNumBytes %d\n", stats->peakNumBytes); + fprintf(aFile, " numAllocFails %d\n", stats->numAllocFails); + if (stats->numAllocs) + { + fprintf(aFile, " ERROR: Memory Leaks! numAllocs %d, numBytes %d\n", stats->numAllocs, stats->numBytes); + } + } + uint32 leaks = auditCB.pAudit->MM_GetNumAllocNodes(); + if (leaks != 0) + { + fprintf(aFile, "ERROR: %d Memory leaks detected!\n", leaks); + MM_AllocQueryInfo*info = auditCB.pAudit->MM_CreateAllocNodeInfo(leaks); + uint32 leakinfo = auditCB.pAudit->MM_GetAllocNodeInfo(info, leaks, 0); + if (leakinfo != leaks) + { + fprintf(aFile, "ERROR: Leak info is incomplete.\n"); + } + for (uint32 i = 0; i < leakinfo; i++) + { + fprintf(aFile, "Leak Info:\n"); + fprintf(aFile, " allocNum %d\n", info[i].allocNum); + fprintf(aFile, " fileName %s\n", info[i].fileName); + fprintf(aFile, " lineNo %d\n", info[i].lineNo); + fprintf(aFile, " size %d\n", info[i].size); + fprintf(aFile, " pMemBlock 0x%x\n", (uint32)info[i].pMemBlock); + fprintf(aFile, " tag %s\n", info[i].tag); + } + auditCB.pAudit->MM_ReleaseAllocNodeInfo(info); + } + } + } +#endif + OsclMem::Cleanup(); +} + +static void _OsclMemCleanup(int32 &aErr, FILE* aFile) +{ + OSCL_TRY(aErr, _OsclMemCleanup(aFile);); +} + +OSCL_EXPORT_REF void OsclInit::Cleanup(int32 &aErr, const OsclSelect *p) +{ + aErr = OsclErrNone; + + //Use default parameters if none were input. + OsclSelect defaultselect; + const OsclSelect* select = (p) ? p : &defaultselect; + + //Note: we continue cleanup despite errors and return the last error encoutered. + + int32 err; + + if (select->iOsclScheduler) + { + _OsclSchedulerCleanup(err); + if (err) + aErr = err; + } + + if (select->iOsclLogger) + { + _OsclLoggerCleanup(err); + if (err) + aErr = err; + } + + if (select->iOsclMemory) + { + _OsclMemCleanup(err, select->iOutputFile); + if (err) + aErr = err; + } + + if (select->iOsclErrorTrap) + { + err = OsclErrorTrap::Cleanup(); + if (err) + aErr = err; + } + + if (select->iOsclBase) + { + err = OsclBase::Cleanup(); + if (err) + aErr = err; + } + +#if defined(OSCL_MEM_HEAPMARKEND) + if (select->iHeapCheck) + { + OSCL_MEM_HEAPMARKEND; + } +#endif +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_init.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_init.h new file mode 100644 index 0000000..f2ef3f6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_init.h @@ -0,0 +1,140 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \addtogroup osclinit OSCL Init + * + * @{ + */ + + + +/** \file oscl_init.h + \brief Global oscl initialization +*/ + + +#ifndef OSCL_INIT_H_INCLUDED +#define OSCL_INIT_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +//For logging memory leaks, this module relies directly on fprintf to FILE. +#include + +class Oscl_DefAlloc; + +/** +* Oscl Module selection and Init/Cleanup options. +*/ +class OsclSelect +{ + public: + OsclSelect() + : iOsclBase(true) + , iOsclMemory(true) + , iOsclErrorTrap(true) + , iOsclLogger(true) + , iOsclScheduler(true) + , iErrAlloc(NULL) + , iSchedulerAlloc(NULL) + , iSchedulerName(NULL) + , iSchedulerReserve(10) + , iHeapCheck(false) + , iOutputFile(NULL) + {} + + //this constructor is mainly for back-compatibility with the old OsclInit argument list. + OsclSelect(Oscl_DefAlloc* erralloc + , Oscl_DefAlloc* schedalloc + , const char*name + , int32 reserve = 10 + , bool heapcheck = false + , FILE* output = NULL) + : iOsclBase(true) + , iOsclMemory(true) + , iOsclErrorTrap(true) + , iOsclLogger(true) + , iOsclScheduler(true) + , iErrAlloc(erralloc) + , iSchedulerAlloc(schedalloc) + , iSchedulerName(name) + , iSchedulerReserve(reserve) + , iHeapCheck(heapcheck) + , iOutputFile(output) + {} + + bool iOsclBase; //Init/Cleanup OsclBase? + bool iOsclMemory; //Init/Cleanup OsclMemory? + bool iOsclErrorTrap; //Init/Cleanup OsclErrorTrap? + bool iOsclLogger; //Init/Cleanup PVLogger? + bool iOsclScheduler; //Init/Cleanup OsclScheduler? + + Oscl_DefAlloc *iErrAlloc; //Allocator for OsclErrorTrap::Init + Oscl_DefAlloc *iSchedulerAlloc; //Allocator for OsclScheduler::Init + const char *iSchedulerName; //Name for OsclScheduler::Init + int32 iSchedulerReserve; //Queue reserve for OsclScheduler::Init + + bool iHeapCheck; //Do Symbian heap checks? + + FILE* iOutputFile; //Output file for memory leak report. +}; + +/** + * Per-thread oscl initialization and cleanup. + */ +class OsclInit +{ + public: + /** + * This routine initializes the Oscl modules in the calling thread. + * + * @param err: (output) error code of any leave that occurs in + * initialization. + * + * @param config: (input param) optional set of initialization parameters. + * If null, then full initialization with default parameters will be performed. + * + */ + OSCL_IMPORT_REF static void Init( + int32& aError + , const OsclSelect *aSelect = NULL + ); + + /** + * This routine cleans up the Oscl modules in the calling thread. + * + * @param err: (output) error code of any leave that occurs in + * initialization. + * @param config: (input param) optional set of initialization parameters. + * If null, then full initialization with default parameters will be performed. + * For proper cleanup, the parameters should match the ones used during + * the Init call. + * + */ + OSCL_IMPORT_REF static void Cleanup( + int32& aError + , const OsclSelect *aSelect = NULL + ); +}; + + +#endif + + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_mutex.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_mutex.cpp new file mode 100644 index 0000000..99b7a3c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_mutex.cpp @@ -0,0 +1,214 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// OSCL_MUTEX (M U T E X I M P L E M E N T A T I O N) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +/*! \file oscl_mutex.cpp .This file provides MUTEX implementation that can be ported +to three OS LINUX, SYMBIAN & WIN32 +*/ + +#include "oscl_mutex.h" + + +#include "oscl_assert.h" + +OSCL_EXPORT_REF OsclMutex::OsclMutex() +{ + bCreated = false; +} + +OSCL_EXPORT_REF OsclMutex::~OsclMutex() +{ + //make sure it's closed + if (bCreated) + Close(); +} + +/* + * Creates the Mutex + * + * @param MutexName NULL terminated string. + * + * @return Returns the Error whether it is success or failure + *incase of failure it will return what is the specific error + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclMutex::Create() +{ + if (bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + + int result = pthread_mutex_init(&ObjMutex, NULL); + if (result == 0) + { + bCreated = true; + return OsclProcStatus::SUCCESS_ERROR; + } + else + return ErrorMapping(result); + + +} + + +/** + * Locks the Mutex + * + * @param It wont take any parameters + * + * @return Returns the Error whether it is success or failure + *incase of failure it will return what is the specific error + */ +OSCL_EXPORT_REF void OsclMutex::Lock() +{ + //verify the mutex is created. + OSCL_ASSERT(bCreated); + + + pthread_mutex_lock(&ObjMutex); + +} + + +/** + * Try to lock the mutex,if the Mutex is already locked calling thread + * immediately returns with out blocking + * @param It wont take any parameters + * + * @return Returns the Error whether it is success or failure + *incase of failure it will return what is the specific error + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclMutex::TryLock() +{ + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + + int result = pthread_mutex_trylock(&ObjMutex); + switch (result) + { + case 0: + return OsclProcStatus::SUCCESS_ERROR; + case EBUSY: + return OsclProcStatus::MUTEX_LOCKED_ERROR; + default: + return ErrorMapping(result); + } + +} + +/** + * Releases the Mutex + * + * @param It wont take any parameters + * + * @return Returns the Error whether it is success or failure + *incase of failure it will return what is the specific error + */ +OSCL_EXPORT_REF void OsclMutex::Unlock() +{ + //verify the mutex is created. + OSCL_ASSERT(bCreated); + + + pthread_mutex_unlock(&ObjMutex); + +} + + + +/** + * Closes the Mutex + * + * @param It wont take any prameters + * + * @return Returns the Error whether it is success or failure + *incase of failure it will return what is the specific error + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclMutex::Close() +{ + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + + int result = pthread_mutex_destroy(&ObjMutex); + if (result == 0) + { + bCreated = false; + return OsclProcStatus::SUCCESS_ERROR; + } + else + return ErrorMapping(result); + +} + + + +/** + * Error Mapping + * + * @param It will take error returned by OS specific API + * + * @return Returns specific error + */ +OsclProcStatus::eOsclProcError OsclMutex::ErrorMapping(int32 Error) +{ + + + switch (Error) + { + case 0: + return OsclProcStatus::SUCCESS_ERROR; + case EAGAIN : + return OsclProcStatus::SYSTEM_RESOURCES_UNAVAILABLE_ERROR; + case EINVAL : + return OsclProcStatus::INVALID_ARGUMENT_ERROR; + case ENOMEM : + return OsclProcStatus::NOT_ENOUGH_MEMORY_ERROR; + case EFAULT : + return OsclProcStatus::INVALID_POINTER_ERROR; + case EBUSY: + return OsclProcStatus::MUTEX_LOCKED_ERROR; + default: + return OsclProcStatus::OTHER_ERROR; + } + +} + +OSCL_EXPORT_REF OsclThreadLock::OsclThreadLock() +{ + iMutex.Create(); +} +OSCL_EXPORT_REF OsclThreadLock::~OsclThreadLock() +{ + iMutex.Close(); +} +OSCL_EXPORT_REF void OsclThreadLock::Lock() +{ + iMutex.Lock(); +} +OSCL_EXPORT_REF void OsclThreadLock::Unlock() +{ + iMutex.Unlock(); +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_mutex.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_mutex.h new file mode 100644 index 0000000..2d24fdb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_mutex.h @@ -0,0 +1,302 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M U T E X + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/** + * @file oscl_mutex.h + * @brief This file provides implementation of mutex + * + */ + +#ifndef OSCL_MUTEX_H_INCLUDED +#define OSCL_MUTEX_H_INCLUDED + +#ifndef OSCLCONFIG_PROC_H_INCLUDED +#include "osclconfig_proc.h" +#endif +#ifndef OSCL_TYPES_H_INCLUDED +#include "oscl_types.h" +#endif +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif +#ifndef OSCL_THREAD_H_INCLUDED +#include "oscl_thread.h" +#endif +#ifndef OSCL_LOCK_BASE_H_INCLUDED +#include "oscl_lock_base.h" +#endif + + +/** + * Class OsclMutex + */ +class OsclMutex : public OsclLockBase +{ + public: + + /** + * Class constructor + */ + OSCL_IMPORT_REF OsclMutex(); + + /** + * Class destructor + */ + OSCL_IMPORT_REF virtual ~OsclMutex(); + + /** + * Creates the Mutex + * + * @param No input arguments + * + * @return Returns the Error whether it is success or failure. + * Incase of failure it will return what is the specific error + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Create(void); + + + /** + * Locks the Mutex + * + * @param It wont take any parameters + * + * @return Returns nothing + */ + OSCL_IMPORT_REF void Lock(); + + /** + * Try to lock the mutex,if the Mutex is already locked calling thread + * immediately returns with out blocking + * @param It wont take any parameters + * + * @return Returns SUCCESS_ERROR if the mutex was acquired, + * MUTEX_LOCKED_ERROR if the mutex cannot be acquired without waiting, + * or an error code if the operation failed. + * Note: this function may not be supported on all platforms, and + * may return NOT_IMPLEMENTED. + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError TryLock(); + + + /** + * Releases the Mutex + * + * @param It wont take any parameters + * + * @return Returns nothing + */ + OSCL_IMPORT_REF void Unlock(); + + + /** + * Closes the Mutex + * + * @param It wont take any prameters + * + * @return Returns the Error whether it is success or failure. + * Incase of failure it will return what is the specific error + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Close(void); + + private: + + /** + * Error Mapping + * + * @param It will take error returned by OS specific API + * + * @return Returns specific error + */ + OsclProcStatus::eOsclProcError ErrorMapping(int32 Error); + + TOsclMutexObject ObjMutex; + bool bCreated; + +}; + +/** + * Class OsclNoYieldMutex can be used in use cases where there will be + * no CPU-yielding operation done while the Mutex is locked. + * + * CPU-yielding operations include OsclMutex::Lock, OsclSemphore::Wait, + * OsclThread::Sleep, and OsclBrewThreadUtil::BThreadYield. + * + * The behavior of OsclNoYieldMutex depends on whether the threading model + * is pre-emptive or not. When threading is pre-emptive, it is identical + * to OsclMutex. When threading is non-pre-emptive, it is a NO-OP. + * + * An example of this type of use case is for simple data protection. + * + */ +#if !OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT +//In pre-emptive threading, OsclNoYieldMutex is identical to OsclMutex +typedef OsclMutex OsclNoYieldMutex; +#else +//In non-pre-emptive threading, OsclNoYieldMutex is a NO-OP. +class OsclNoYieldMutex : public OsclLockBase +{ + public: + + /** + * Class constructor + */ + OsclNoYieldMutex() + { +#if (!OSCL_RELEASE_BUILD) + iNumLock = 0; + bCreated = false; +#endif + } + + /** + * Class destructor + */ + virtual ~OsclNoYieldMutex() + {} + + /** + * Creates the Mutex + * + * @param No input arguments + * + * @return Returns the Error whether it is success or failure. + * Incase of failure it will return what is the specific error + */ + OsclProcStatus::eOsclProcError Create(void) + { +#if (!OSCL_RELEASE_BUILD) + if (bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + bCreated = true; +#endif + return OsclProcStatus::SUCCESS_ERROR; + } + + + /** + * Locks the Mutex + * + * @param It wont take any parameters + * + * @return Returns nothing + */ + void Lock() + { +#if (!OSCL_RELEASE_BUILD) + OSCL_ASSERT(bCreated); + OSCL_ASSERT(iNumLock == 0);//detect deadlock condition. + iNumLock++; +#endif + } + + /** + * Try to lock the mutex,if the Mutex is already locked calling thread + * immediately returns with out blocking + * @param It wont take any parameters + * + * @return Returns SUCCESS_ERROR if the mutex was acquired, + * MUTEX_LOCKED_ERROR if the mutex cannot be acquired without waiting, + * or an error code if the operation failed. + * Note: this function may not be supported on all platforms, and + * may return NOT_IMPLEMENTED. + */ + OsclProcStatus::eOsclProcError TryLock() + { +#if (!OSCL_RELEASE_BUILD) + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + if (iNumLock) + return OsclProcStatus::MUTEX_LOCKED_ERROR; + else + Lock(); + return OsclProcStatus::SUCCESS_ERROR; +#endif + } + + + /** + * Releases the Mutex + * + * @param It wont take any parameters + * + * @return Returns nothing + */ + void Unlock() + { +#if (!OSCL_RELEASE_BUILD) + OSCL_ASSERT(bCreated); + OSCL_ASSERT(iNumLock); + if (iNumLock > 0) + iNumLock--; +#endif + } + + + /** + * Closes the Mutex + * + * @param It wont take any prameters + * + * @return Returns the Error whether it is success or failure. + * Incase of failure it will return what is the specific error + */ + OsclProcStatus::eOsclProcError Close(void) + { +#if (!OSCL_RELEASE_BUILD) + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + bCreated = false; +#endif + return OsclProcStatus::SUCCESS_ERROR; + } + + private: + +#if (!OSCL_RELEASE_BUILD) + uint32 iNumLock; + bool bCreated; +#endif + +}; +#endif //OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT + +/** +** An implementation of OsclLockBase using a mutex +**/ +class OsclThreadLock: public OsclLockBase +{ + public: + OSCL_IMPORT_REF OsclThreadLock(); + OSCL_IMPORT_REF virtual ~OsclThreadLock(); + OSCL_IMPORT_REF void Lock(); + OSCL_IMPORT_REF void Unlock(); + private: + OsclMutex iMutex; +}; + +#endif + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_procstatus.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_procstatus.h new file mode 100644 index 0000000..44f258a --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_procstatus.h @@ -0,0 +1,121 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + + +// OSCL_T H R E A D (T H R E A D I M P L E M E N T A T I O N) + + + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + + +/*! \file oscl_thread.h .This file provides THREAD implementation that can be ported + +to three OS LINUX, SYMBIAN, WIN32 + +*/ + + + + + +#ifndef OSCL_PROCSTATUS_H_INCLUDED + +#define OSCL_PROCSTATUS_H_INCLUDED + + + +/** + + * Class OsclProcStatus + + */ + +class OsclProcStatus +{ + + + + + + public: + + + +// Enumerated Error values + + + + /** + + * List of enums which contain error codes + + */ + + enum eOsclProcError + { + SUCCESS_ERROR = 0, // Function returned succesfully + OTHER_ERROR, // Function returned some error + TOO_MANY_THREADS_ERROR, // Cannot create another thread + BAD_THREADID_ADDR_ERROR, // The address for the thread id is not correct + MAX_THRDS_REACHED_ERROR, // No more threads can be created in the system + INVALID_THREAD_ID_ERROR, // Invalid thread identifier + NOT_ENOUGH_MEMORY_ERROR, // Not enough storage is available to process this command + OUTOFMEMORY_ERROR, // Not enough storage is available to complete this operation + NOT_ENOUGH_RESOURCES_ERROR, // Not Enough resources available + THREAD_1_INACTIVE_ERROR, // The signal handler cannot be set + ALREADY_SUSPENDED_ERROR, // Thread is already suspended + NOT_SUSPENDED_ERROR, // Thread cannot be suspended + INVALID_THREAD_ERROR, // Referring to invalid thread + INVALID_PARAM_ERROR, // Invalid parameter passed in the API + NO_PERMISSION_ERROR, // Operation not permitted + INVALID_PRIORITY_ERROR, // Priority is not a valid OSCL priority + PSHARED_NOT_ZERO_ERROR, // Trying to create global semaphore + EXCEED_MAX_COUNT_VARIABLE_ERROR, // Exceeding maximum possible value for semaphore count + THREAD_BLOCK_ERROR, // Thread is blocked + EXCEED_MAX_SEM_COUNT_ERROR, // Out of range of semaphore count + INVALID_HANDLE_ERROR, // Invalid handle + INVALID_OPERATION_ERROR, // Invalid operation + INVALID_FUNCTION_ERROR, + INVALID_ACCESS_ERROR, + INVALID_ARGUMENT_ERROR, + SYSTEM_RESOURCES_UNAVAILABLE_ERROR, + INVALID_POINTER_ERROR, + RELOCK_MUTEX_ERROR, + THREAD_NOT_OWN_MUTEX_ERROR, + MUTEX_LOCKED_ERROR, + WAIT_ABANDONED_ERROR,//thread terminated while waiting + WAIT_TIMEOUT_ERROR, //timed wait expired without acquiring + SEM_NOT_SIGNALED_ERROR, //trywait returned without acquiring + PSHARED_ATTRIBUTE_SETTING_ERROR, // Error at setting pthread attributes + NOT_IMPLEMENTED //function not implemented on this platform. + } ; + + + +}; + + + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler.cpp new file mode 100644 index 0000000..c08bb67 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler.cpp @@ -0,0 +1,1444 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#include "oscl_scheduler.h" + + +#include "oscl_error.h" +#include "oscl_tickcount.h" +#include "pvlogger.h" +#include "oscl_error_trapcleanup.h" +#include "pvlogger.h" +#include "oscl_tls.h" +#include "oscl_int64_utils.h" + +#define OSCL_DISABLE_WARNING_CONDITIONAL_IS_CONSTANT +#include "osclconfig_compiler_warnings.h" + + +#include "oscl_scheduler_tuneables.h" + + +///////////////////////////////////// +// Logger Macros +///////////////////////////////////// + +//LOGERROR is for scheduler errors. +//This logging also goes to stderr on platforms with ANSI stdio. +#define LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m); + +//LOGNOTICE is for scheduler start/stop, install/uninstall notices. +#define LOGNOTICE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,iLogger,PVLOGMSG_NOTICE,m); + +#if(PV_SCHED_ENABLE_PERF_LOGGING) +//LOGSTATS is for logging the AO summary statistics. These are loggged either +//when the AO is deleted, or when the scheduling ends. +#define LOGSTATS(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF,iLogger,PVLOGMSG_INFO,m); +//LOGPERF is for detailed performance logging. +#define LOGPERF_LEVEL PVLOGMSG_INFO +#define LOGPERF(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF,iLogger,LOGPERF_LEVEL,m); +//LOGPERF2 is for highest detail on scheduler activity. +#define LOGPERF2_LEVEL PVLOGMSG_INFO+1 +#define LOGPERF2(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF,iLogger,LOGPERF2_LEVEL,m); +//max perf log string length +#define LOGPERFMAXSTR 64 +#define RESET_LOG_PERF(m)\ + ResetLogPerf();\ + LOGPERF(m); +#else +#define LOGSTATS(m) +#define LOGPERF(m) +#define LOGPERF2(m) +#define LOGPERFMAXSTR 64 +#define RESET_LOG_PERF(m) +#endif//(PV_SCHED_ENABLE_PERF_LOGGING) + +///////////////////////////////////// +// DLL Entry +///////////////////////////////////// +#ifndef OSCL_COMBINED_DLL +#include "oscl_dll.h" +OSCL_DLL_ENTRY_POINT_DEFAULT() +#endif + +///////////////////////////////////// +// OsclScheduler +///////////////////////////////////// + +OSCL_EXPORT_REF void OsclScheduler::Init(const char *name, Oscl_DefAlloc *alloc, int nreserve) +//Init the scheduler for this thread. +{ + int32 err; + OSCL_TRY(err, + OsclExecScheduler *sched = OsclExecScheduler::NewL(name, alloc, nreserve); + sched->InstallScheduler();); + if (err != OsclErrNone) + OsclError::Leave(OsclErrNotInstalled); +} + + + +OSCL_EXPORT_REF void OsclScheduler::Cleanup() +//Cleanup the scheduler for this thread. +{ + OsclExecSchedulerCommonBase *sched = OsclExecSchedulerCommonBase::GetScheduler(); + if (!sched) + OsclError::Leave(OsclErrNotInstalled); + sched->UninstallScheduler(); + Oscl_DefAlloc *alloc = sched->iAlloc; + bool default_alloc = (sched->iAlloc == &sched->iDefAlloc); + sched->~OsclExecSchedulerCommonBase(); + if (default_alloc) + { + OsclMemAllocator defalloc; + defalloc.deallocate(sched); + } + else + { + alloc->deallocate(sched); + } +} + +///////////////////////////////////// +// OsclExecSchedulerCommonBase +///////////////////////////////////// + +///////////////////////////////////// +// OsclExecScheduler +///////////////////////////////////// + +//use the TLS registry, or the singleton registry if no TLS. +//Note: singleton registry only works for single-threaded +//scenarios, since this implementation assumes a per-thread registry. +#include "oscl_error.h" +#define PVSCHEDULER_REGISTRY OsclTLSRegistryEx +#define PVSCHEDULER_REGISTRY_ID OSCL_TLS_ID_PVSCHEDULER + + +///////////////////////////////////// +//For AO statistics. +///////////////////////////////////// + +#if !(PV_SCHED_ENABLE_AO_STATS) +//no stats +#define PVTICK uint32 +#define PVTICK_INT uint32 +#define INIT_TICK(tick) +#define SET_TICK(tick) +#define GET_TICKFREQ(tick) +#define TICK_INT(tick1) +#define TICKSTR "" +#define TICK_INT_STR "" +#define TICK_INT_EXPR(x) +#else +//else use the oscl timer. +#define PVTICK uint32 +#define PVTICK_INT uint32 +#define INIT_TICK(tick) tick=0 +#define SET_TICK(tick) tick=OsclTickCount::TickCount() +#define GET_TICKFREQ(tick) tick=OsclTickCount::TickCountFrequency() +#define TICK_INT(tick1) tick1 +#define TICKSTR "Ticks" +#define TICK_INT_STR "%u" +#define TICK_INT_EXPR(x) x +#endif + +#if !(PV_SCHED_ENABLE_AO_STATS) +#define DIFF_TICK(tick1,diff) +#define UPDATE_RUNERROR_TIME(x,y) +#define UPDATE_RUNL_TIME(x,y) +#define UPDATE_LEAVE_CODE(x,err) +#else +#define DIFF_TICK(tick1,diff) PVTICK _now;SET_TICK(_now);diff=TICK_INT(_now)-TICK_INT(tick1) +#define UPDATE_RUNERROR_TIME(stats,delta)\ + if(stats->i64Valid) stats->i64TotalTicksInRun+=delta;\ + else stats->iTotalTicksInRun+=delta;\ + if(delta>stats->iMaxTicksInRun) stats->iMaxTicksInRun=delta;\ + stats->iNumRunError++ +#define UPDATE_RUNL_TIME(stats,delta)\ + if(stats->i64Valid) stats->i64TotalTicksInRun+=delta;\ + else stats->iTotalTicksInRun+=delta;\ + if(delta>stats->iMaxTicksInRun) stats->iMaxTicksInRun=delta;\ + stats->iNumRun++; +#define UPDATE_LEAVE_CODE(stats,err)if (err!=OsclErrNone)stats->iLeave=err +#endif + +#if (PV_SCHED_ENABLE_LOOP_STATS) +#define DECLARE_LOOP_STATS int64 loopdelta = 0; PVTICK looptime; + +#define START_LOOP_STATS(stats)SET_TICK(looptime); + +#define START_WAIT_LOOP_STATS(rc,stats)\ + if (rc<1)\ + SET_TICK(looptime); + +#define END_LOOP_STATS(stats)\ + {\ + DIFF_TICK(looptime,loopdelta);\ + if(stats->i64Valid) stats->i64TotalTicksInRun+=loopdelta;\ + else stats->iTotalTicksInRun+=Oscl_Int64_Utils::get_int64_lower32(loopdelta);\ + stats->iNumRun++;\ + LOGPERF((0,"PVSCHED: Run %d %s AO %s",(int32)loopdelta,TICKSTR,stats->iAOName.get_cstr()));\ + } + +#define END_WAIT_LOOP_STATS(rc,stats)\ + if (rc<1)\ + {\ + DIFF_TICK(looptime,loopdelta);\ + if(stats->i64Valid) stats->i64TotalTicksInRun+=loopdelta;\ + else stats->iTotalTicksInRun+=Oscl_Int64_Utils::get_int64_lower32(loopdelta);\ + stats->iNumRun++;\ + LOGPERF((0,"PVSCHED: Run %d %s AO %s",(int32)loopdelta,TICKSTR,stats->iAOName.get_cstr()));\ + } + +#else +#define DECLARE_LOOP_STATS +#define START_LOOP_STATS(stats) +#define START_WAIT_LOOP_STATS(rc,stats) +#define END_LOOP_STATS(stats) +#define END_WAIT_LOOP_STATS(rc,stats) + +#endif + +#if(PV_SCHED_ENABLE_PERF_LOGGING) +void OsclExecSchedulerCommonBase::ResetLogPerf() +{ + //print total time spend in prior interval of continuous Run calls. + if (iLogPerfTotal > 0) + { + LOGPERF((0, "PVSCHED: Prior Interval %d %s", iLogPerfTotal, TICKSTR)); + } + //reset interval. + iLogPerfTotal = 0; + //reset indentation to zero. + iLogPerfIndentStrLen = 0; + if (iLogPerfIndentStr) + iLogPerfIndentStr[iLogPerfIndentStrLen] = '\0'; +} + +void OsclExecSchedulerCommonBase::IncLogPerf(uint32 delta) +{ + //add to total interval time. + iLogPerfTotal += delta; + //add a space to the indent string up to the max. + if (iLogPerfIndentStr + && iLogPerfIndentStrLen < LOGPERFMAXSTR) + { + iLogPerfIndentStr[iLogPerfIndentStrLen++] = ' '; + iLogPerfIndentStr[iLogPerfIndentStrLen] = '\0'; + } +} +#endif//(PV_SCHED_ENABLE_PERF_LOGGING) + +OsclExecSchedulerCommonBase* OsclExecSchedulerCommonBase::GetScheduler() +//static function to get currently installed scheduler +//for this thread. +{ + OsclExecSchedulerCommonBase *current = (OsclExecSchedulerCommonBase*)PVSCHEDULER_REGISTRY::getInstance(PVSCHEDULER_REGISTRY_ID); + return current; +} + +OsclExecSchedulerCommonBase* OsclExecSchedulerCommonBase::SetScheduler(OsclExecSchedulerCommonBase *a) +//static function to set currently installed scheduler +//for this thread. return previous scheduler, if any. +{ + OsclExecSchedulerCommonBase* temp = GetScheduler(); + PVSCHEDULER_REGISTRY::registerInstance(a, PVSCHEDULER_REGISTRY_ID); + return temp; +} + +OSCL_EXPORT_REF OsclNameString *OsclExecSchedulerCommonBase::GetName() +//static function to get scheduler name for this thread. +{ + OsclExecSchedulerCommonBase *sched = GetScheduler(); + if (sched) + return &sched->iName; + else + return NULL; +} + +OSCL_EXPORT_REF uint32 OsclExecSchedulerCommonBase::GetId() +{ + return PVThreadContext::Id(); +} + +OsclExecScheduler * OsclExecScheduler::NewL(const char *name, Oscl_DefAlloc *alloc, int nreserve) +{ + OsclExecScheduler *self; + OsclMemAllocator defalloc; + OsclAny* ptr = (alloc) ? alloc->ALLOCATE(sizeof(OsclExecScheduler)) + : defalloc.ALLOCATE(sizeof(OsclExecScheduler)); + OsclError::LeaveIfNull(ptr); + self = OSCL_PLACEMENT_NEW(ptr, OsclExecScheduler(alloc)); + OsclError::PushL(self); + self->ConstructL(name, nreserve); + OsclError::Pop(); + return self; +} + +OsclExecSchedulerCommonBase::~OsclExecSchedulerCommonBase() +{ + //make sure scheduler is not currently installed in + //any thread. + if (IsInstalled()) + OsclError::Leave(OsclErrInvalidState);//scheduler not stopped + + if (iStopper) + { + iStopper->~PVSchedulerStopper(); + iAlloc->deallocate(iStopper); + } +#if(PV_SCHED_ENABLE_PERF_LOGGING) + if (iLogPerfIndentStr) + _oscl_free(iLogPerfIndentStr); +#endif +} + +OsclExecScheduler::~OsclExecScheduler() +{ +} + +OsclExecSchedulerCommonBase::OsclExecSchedulerCommonBase(Oscl_DefAlloc *alloc) +{ + iAlloc = (alloc) ? alloc : &iDefAlloc; +#if(PV_SCHED_ENABLE_PERF_LOGGING) + iLogPerfIndentStr = NULL; + iLogPerfTotal = 0; +#endif +} + +OsclExecScheduler::OsclExecScheduler(Oscl_DefAlloc *alloc) + : OsclExecSchedulerCommonBase(alloc) +{ +} + +void OsclExecSchedulerCommonBase::ConstructL(const char *name, int nreserve) +{ + iNumAOAdded = 1; + + OsclAny* ptr = iAlloc->ALLOCATE(sizeof(PVSchedulerStopper)); + OsclError::LeaveIfNull(ptr); + iStopper = new(ptr) PVSchedulerStopper; + +#if(PV_SCHED_ENABLE_AO_STATS) + ConstructStatQ(); +#endif + + InitExecQ(nreserve); + + iBlockingMode = false; + iNativeMode = false; + iName.Set(name); + iLogger = PVLogger::GetLoggerObject("pvscheduler"); + +#if (PV_SCHED_ENABLE_PERF_LOGGING) + iLogPerfIndentStr = (char*)_oscl_malloc(LOGPERFMAXSTR + 1); + OsclError::LeaveIfNull(iLogPerfIndentStr); + ResetLogPerf(); +#endif +} + +void OsclExecScheduler::ConstructL(const char *name, int nreserve) +{ + OsclExecSchedulerCommonBase::ConstructL(name, nreserve); +} + +void OsclExecSchedulerCommonBase::InstallScheduler() +{ + //make sure this scheduler is not installed in + //any thread. + if (IsInstalled()) + OsclError::Leave(OsclErrAlreadyInstalled); + //make sure no scheduler is installed in this thread. + if (GetScheduler()) + OsclError::Leave(OsclErrAlreadyInstalled); + + SetScheduler(this); + + iThreadContext.EnterThreadContext(); + + iErrorTrapImp = OsclErrorTrap::GetErrorTrapImp(); + if (!iErrorTrapImp) + OsclError::Leave(OsclErrNotInstalled);//error trap not installed. + + if (iStopperCrit.Create() != OsclProcStatus::SUCCESS_ERROR) + OsclError::Leave(OsclErrSystemCallFailed);//mutex error + + iResumeSem.Create(); + iDoStop = iDoSuspend = iSuspended = false; + + iReadyQ.ThreadLogon(); + + LOGNOTICE((0, "PVSCHED:Scheduler '%s', Thread 0x%x: Installed", iName.Str(), PVThreadContext::Id())); + +#if (PV_SCHED_ENABLE_PERF_LOGGING) + //print tick frequencies that will show up in the perf log. + PVTICK f; + GET_TICKFREQ(f); + PVTICK_INT tickint = TICK_INT(f); + LOGPERF((0, "PVSCHED: %s frequency %s", TICKSTR, TICK_INT_STR, TICK_INT_EXPR(tickint))); + OSCL_UNUSED_ARG(tickint); +#endif +} + +void OsclExecSchedulerCommonBase::UninstallScheduler() +{ + //make sure this scheduler is currently installed in + //this thread. + if (!IsInstalled() || GetScheduler() != this) + OsclError::Leave(OsclErrNotInstalled); + + + if (iBlockingMode) + { + //in case a thread error happened, go ahead and end + //scheduling. + OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap(); + if (trap + && trap->iLeave != OsclErrNone) + EndScheduling(); + //make sure scheduler is stopped. If not, leave instead. + if (IsStarted()) + OsclError::Leave(OsclErrInvalidState);//scheduler not stopped + } + else if (IsStarted()) + { + //end non-blocking scheduling + EndScheduling(); + } + + SetScheduler(NULL); + + iThreadContext.ExitThreadContext(); + + CleanupExecQ(); + + //Cleanup the stat queue. +#if(PV_SCHED_ENABLE_AO_STATS) + CleanupStatQ(); +#endif + + if (iStopperCrit.Close() != OsclProcStatus::SUCCESS_ERROR) + OsclError::Leave(OsclErrSystemCallFailed);//mutex error + + iReadyQ.ThreadLogoff(); + iResumeSem.Close(); + + LOGNOTICE((0, "PVSCHED:Scheduler '%s', Thread 0x%x: Uninstalled", iName.Str(), PVThreadContext::Id())); +} + +OSCL_EXPORT_REF OsclExecScheduler* OsclExecScheduler::Current() +//static routine to get current scheduler. +{ + return (OsclExecScheduler*)GetScheduler(); +} + +bool OsclExecSchedulerCommonBase::IsStarted() +{ + iStopperCrit.Lock(); + bool val = (iStopper->IsAdded()) ? true : false; + iStopperCrit.Unlock(); + return val; +} + +inline bool OsclExecSchedulerCommonBase::IsInstalled() +{ + return iThreadContext.iOpen; +} + +void OsclExecSchedulerCommonBase::BeginScheduling(bool blocking, bool native) +//called before entering scheduling loop. +{ + //make sure scheduler is installed... + if (!IsInstalled() || GetScheduler() != this) + OsclError::Leave(OsclErrNotInstalled); + + //make sure scheduler is idle... + if (IsStarted()) + OsclError::Leave(OsclErrInvalidState); + + iBlockingMode = blocking; + iNativeMode = native; + + //Add stopper AO to scheduler. + iStopperCrit.Lock(); + { + iStopper->AddToScheduler(); + iStopper->PendForExec(); + } + iStopperCrit.Unlock(); + +#if(PV_SCHED_ENABLE_PERF_LOGGING) + ResetLogPerf(); +#endif +#if(PV_SCHED_ENABLE_AO_STATS) + BeginStats(); +#endif +} + + +void OsclExecSchedulerCommonBase::EndScheduling() +//called after exiting scheduling loop. +{ + //see if it's already stopped.. + if (!IsStarted()) + return; + + //remove stopper AO. + iStopperCrit.Lock(); + iStopper->RemoveFromScheduler(); + iStopperCrit.Unlock(); + +#if(PV_SCHED_ENABLE_AO_STATS) + EndStats(); +#endif +} + +#if(PV_SCHED_ENABLE_AO_STATS) +void OsclExecSchedulerCommonBase::ConstructStatQ() +{ + //create a placeholder for summary stats for + //all AOs that are not PVActiveBase. + for (uint32 i = 0; i < EOtherExecStats_Last; i++) + iOtherExecStats[i] = NULL; + + OsclAny* ptr = iAlloc->ALLOCATE(sizeof(PVActiveStats)); + OsclError::LeaveIfNull(ptr); + iOtherExecStats[EOtherExecStats_NativeOS] = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(this, "Sched_TotalNativeOS", NULL)); + //init the stat queue offset. + { + int offset = (int) & (iOtherExecStats[EOtherExecStats_NativeOS])->iPVStatQLink - (int)(iOtherExecStats[EOtherExecStats_NativeOS]); + iPVStatQ.SetOffset(offset); + } + +#if(PV_SCHED_ENABLE_LOOP_STATS) + //create nodes for summary stats for scheduler loop time + + ptr = iAlloc->ALLOCATE(sizeof(PVActiveStats)); + OsclError::LeaveIfNull(ptr); + iOtherExecStats[EOtherExecStats_QueueTime] = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(this, "Sched_QueueTime", NULL)); + + ptr = iAlloc->ALLOCATE(sizeof(PVActiveStats)); + OsclError::LeaveIfNull(ptr); + iOtherExecStats[EOtherExecStats_WaitTime] = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(this, "Sched_WaitTime", NULL)); + +#endif + //add the non-AO stats nodes to the stat Q. + { + for (uint32 i = 0; i < EOtherExecStats_Last; i++) + { + if (iOtherExecStats[i]) + iPVStatQ.InsertTail(*iOtherExecStats[i]); + } + } +} + +void OsclExecSchedulerCommonBase::CleanupStatQ() +{ + while (!iPVStatQ.IsEmpty()) + { + PVActiveStats* first = iPVStatQ.Head(); + first->iPVStatQLink.Remove(); + first->~PVActiveStats(); + first->iScheduler->iAlloc->deallocate(first); + } +} + +void OsclExecSchedulerCommonBase::ShowStats(PVActiveStats *active) +//static routine to print stats for a PV AO. +{ + if (!active) + return; + + //don't print any AOs that never ran. + if ((active->iNumRun + active->iNumCancel) == 0) + return; + + PVLogger* iLogger = PVLogger::GetLoggerObject("pvscheduler"); + if (active->i64Valid) + { + int64 avgTicksPerRun = (active->iNumRun == 0) ? 0 : active->i64TotalTicksInRun / (int64)active->iNumRun; + + LOGSTATS((0, "PVSCHED:Scheduler '%s', AO '%s': Pri %d NumRun %d, MaxTicksInRun 0x%x, AvgTicksPerRun (hi,lo) (0x%x,0x%08x) Units %s, NumCancel %d, NumError %d, LeaveCode %d" + , active->iScheduler->iName.Str() + , active->iAOName.get_cstr() + , active->iPriority + , active->iNumRun + , active->iMaxTicksInRun + , Oscl_Int64_Utils::get_int64_upper32(avgTicksPerRun) + , Oscl_Int64_Utils::get_int64_lower32(avgTicksPerRun) + , TICKSTR + , active->iNumCancel + , active->iNumRunError + , active->iLeave + )); + } + else + { + uint32 avgTicksPerRun = (active->iNumRun == 0) ? 0 : active->iTotalTicksInRun / active->iNumRun; + LOGSTATS((0, "PVSCHED:Scheduler '%s', AO '%s': Pri %d NumRun %d, MaxTicksInRun %d, AvgTicksPerRun %d Units %s, NumCancel %d, NumError %d, LeaveCode %d" + , active->iScheduler->iName.Str() + , active->iAOName.get_cstr() + , active->iPriority + , active->iNumRun + , active->iMaxTicksInRun + , avgTicksPerRun + , TICKSTR + , active->iNumCancel + , active->iNumRunError + , active->iLeave + )); + } +} + +void OsclExecSchedulerCommonBase::ShowSummaryStats(PVActiveStats *active, PVLogger*logger, int64 total, int64& aGrandTotal, float& aTotalPercent) +//static routine to print stats for a PV AO. +{ + if (total == (int64)0) + return;//to avoid divide by zero + + if (!active) + return; + + //don't print any AO's that never ran. + if ((active->iNumRun + active->iNumCancel) == 0) + return; + + //calculate percent of the total time that was spent in this AO. + if (active->i64Valid) + { + active->iPercent = 100.0 * active->i64TotalTicksInRun / total; + aGrandTotal += active->i64TotalTicksInRun; + } + else + { + active->iPercent = 100.0 * active->iTotalTicksInRun / total; + aGrandTotal += active->iTotalTicksInRun; + } + aTotalPercent += active->iPercent; + + int32 fraction = (int32)active->iPercent; + float decimal = active->iPercent - fraction; + decimal *= 100.0; + + //print results + if (active->i64Valid) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO + , (0, " TIME PERCENT %d.%02d, AO '%s', Pri %d NumRun %d, MaxTicksInRun 0x%x, TotalTicksInRun Hi,Lo (0x%x,0x%08x), NumCancel %d, NumError %d, LeaveCode %d, NumInstance %d" + , (int32)active->iPercent, (int32)decimal + , active->iAOName.get_cstr() + , active->iPriority + , active->iNumRun + , active->iMaxTicksInRun + , Oscl_Int64_Utils::get_int64_upper32(active->i64TotalTicksInRun) + , Oscl_Int64_Utils::get_int64_lower32(active->i64TotalTicksInRun) + , active->iNumCancel + , active->iNumRunError + , active->iLeave + , active->iNumInstances + )); + } + else + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO + , (0, " TIME PERCENT %d.%02d, AO '%s', Pri %d NumRun %d, MaxTicksInRun 0x%x, TotalTicksInRun 0x%x, NumCancel %d, NumError %d, LeaveCode %d, NumInstance %d" + , (int32)active->iPercent, (int32)decimal + , active->iAOName.get_cstr() + , active->iPriority + , active->iNumRun + , active->iMaxTicksInRun + , (int32)active->iTotalTicksInRun + , active->iNumCancel + , active->iNumRunError + , active->iLeave + , active->iNumInstances + )); + } +} + +void OsclExecSchedulerCommonBase::BeginStats() +//Begin stats for all AOs. +{ + iTotalTicksTemp = (uint8*)OSCL_MALLOC(sizeof(PVTICK)); + SET_TICK(*((PVTICK*)iTotalTicksTemp)); +} + +void OsclExecSchedulerCommonBase::EndStats() +//End stats for all AOs. +{ + //get the end time for the scheduler run. + int64 total; + DIFF_TICK((*((PVTICK*)iTotalTicksTemp)), total); + OSCL_FREE(iTotalTicksTemp); + + //there may be multiple entries per AO in the stats table, so combine them now. + if (!iPVStatQ.IsEmpty()) + { + OsclDoubleRunner iter(iPVStatQ); + PVActiveStats *item; + for (iter.SetToHead(); ; iter++) + { + item = iter; + //find all subsequent entries in the list that have + //the same AO name as this entry. + if (item->iNumInstances > 0 + && !iPVStatQ.IsTail(item)) + { + OsclDoubleRunner iter2(iPVStatQ); + PVActiveStats* item2; + for (iter2 = iter, iter2++; ; iter2++) + { + item2 = iter2; + if (item2->iAOName == item->iAOName) + { + item->Combine(*item2); + //mark this entry to ignore in further processing. + item2->iNumInstances = 0; + } + if (iPVStatQ.IsTail(item2)) + break; + } + } + if (iPVStatQ.IsTail(item)) + break; + } + } + //end of multiple-instance combine. + + QUE_ITER_BEGIN(PVActiveStats, iPVStatQ) + { + if (item + && item->iNumInstances > 0) + OsclExecScheduler::ShowStats(item); + } + QUE_ITER_END(iPVStatQ) + + //Show summary stats + + PVLogger* logger = PVLogger::GetLoggerObject("OsclSchedulerPerfStats"); + + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, + (0, "OSCL SCHEDULER SUMMARY STATISTICS FOR SCHEDULER '%s'", iName.Str()) + ) + + iGrandTotalTicks = 0; + iTotalPercent = 0.0; + QUE_ITER_BEGIN(PVActiveStats, iPVStatQ) + { + if (item + && item->iNumInstances > 0) + OsclExecScheduler::ShowSummaryStats(item, logger, total, iGrandTotalTicks, iTotalPercent); + } + QUE_ITER_END(iPVStatQ) + + //split total percent into whole & decimal parts. + int32 fraction = (int32)iTotalPercent; + float decimal = iTotalPercent - fraction; + decimal *= 100.0; + + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, + (0, " Total Time (hi,lo): (0x%x,0x%08x) Units: %s", Oscl_Int64_Utils::get_int64_upper32(total), Oscl_Int64_Utils::get_int64_lower32(total), TICKSTR) + ) + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, + (0, " Total Time Accounted (hi,lo): (0x%x,0x%08x) Units: %s", Oscl_Int64_Utils::get_int64_upper32(iGrandTotalTicks), Oscl_Int64_Utils::get_int64_lower32(iGrandTotalTicks), TICKSTR) + ) + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, + (0, " Total Percent Accounted: %d.%02d", (int32)iTotalPercent, (int32)decimal) + ) + + PVTICK f; + GET_TICKFREQ(f); + PVTICK_INT tickint = TICK_INT(f); + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, + (0, " Tick Units: %s Frequency: %s", TICKSTR, TICK_INT_STR, TICK_INT_EXPR(tickint)) + ) + + PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, + (0, "END OSCL SCHEDULER SUMMARY STATISTICS FOR SCHEDULER '%s'", iName.Str()) + ) + +} +#endif //PV_SCHED_ENABLE_AO_STATS + + +void OsclExecSchedulerCommonBase::Error(int32 anError) const +//call this when any AO leaves and its error handler does not handle the error. +{ + LOGERROR((0, "PVSCHED:Scheduler '%s', Thread 0x%x: Error! Reason %d", iName.Str(), PVThreadContext::Id(), anError)); + fprintf(stderr, "PVSCHED:Scheduler '%s', Thread 0x%x: Error! Reason %d\n", iName.Str(), PVThreadContext::Id(), anError); + + //propagate the leave + OsclError::Leave(anError); +} + +OSCL_EXPORT_REF void OsclExecSchedulerCommonBase::StartScheduler(OsclSemaphore *aSignal) +//blocking call to start PV scheduler. +//Will leave if any AO leaves. +{ + + BeginScheduling(true, false);//blocking, non-native + if (aSignal) + aSignal->Signal(); + + + LOGNOTICE((0, "PVSCHED:Scheduler '%s', Thread 0x%x: Starting PV Scheduling Loop", iName.Str(), PVThreadContext::Id())); + + int32 err; + OSCL_TRY(err, BlockingLoopL();); + + LOGNOTICE((0, "PVSCHED:Scheduler '%s', Thread 0x%x: Exited PV Scheduling Loop", iName.Str(), PVThreadContext::Id())); + + EndScheduling(); + + if (err) + OsclError::Leave(err); + +} + +OSCL_EXPORT_REF void OsclExecSchedulerCommonBase::StartNativeScheduler() +//blocking call to start native scheduler. +//Will leave if any AO leaves. +{ + OsclError::Leave(OsclErrNotSupported);//native scheduler not supported. +} + +//scheduler stopper request status codes. +#define STOPPER_REQUEST_STOP_NATIVE 0 +#define STOPPER_REQUEST_STOP_PV 1 +#define STOPPER_REQUEST_SUSPEND 2 + +OSCL_EXPORT_REF void OsclExecSchedulerCommonBase::StopScheduler() +//any thread can use this to stop the blocking scheduler. +{ + if (!IsInstalled()) + OsclError::Leave(OsclErrNotInstalled); + + if (!iBlockingMode) + OsclError::Leave(OsclErrNotReady); + if (!IsStarted()) + return ; + + if (iStopper->iStatus != OSCL_REQUEST_PENDING) + OsclError::Leave(OsclErrNotReady); + + //in case scheduler is in the suspend loop... + if (iDoSuspend || iSuspended) + iResumeSem.Signal(); + + if (iNativeMode) + iStopper->PendComplete(STOPPER_REQUEST_STOP_NATIVE); + else + iStopper->PendComplete(STOPPER_REQUEST_STOP_PV); + +} + +OSCL_EXPORT_REF void OsclExecSchedulerCommonBase::SuspendScheduler() +//any thread can use this to suspend the blocking scheduler. +{ + if (!IsInstalled()) + OsclError::Leave(OsclErrNotInstalled); + + if (iNativeMode) + OsclError::Leave(OsclErrNotSupported); + + if (!iBlockingMode) + OsclError::Leave(OsclErrNotSupported); + + if (!IsStarted()) + return; + + if (iStopper->iStatus != OSCL_REQUEST_PENDING) + OsclError::Leave(OsclErrNotReady); + + iStopper->PendComplete(STOPPER_REQUEST_SUSPEND); + +} + +OSCL_EXPORT_REF void OsclExecSchedulerCommonBase::ResumeScheduler() +//any thread can use this to resume the blocking scheduler. +{ + if (!IsInstalled()) + OsclError::Leave(OsclErrNotInstalled); + + if (iDoSuspend || iSuspended) + { + iResumeSem.Signal(); + return ; + } + else + OsclError::Leave(OsclErrNotReady); //not suspended. +} + +OSCL_EXPORT_REF void OsclExecScheduler::RunSchedulerNonBlocking(int32 aCount, int32 &aReady, uint32 &aShortestDelay) +//run scheduler in non-blocking mode. +//Will leave if any AO leaves. +{ + + + aReady = 0; + aShortestDelay = 0; + + //make sure this scheduler is installed. + if (!IsInstalled()) + OsclError::Leave(OsclErrNotInstalled); + +#if !(OSCL_RELEASE_BUILD) + //make sure this scheduler is really installed in this + //thread. + if (GetScheduler() != this) + OsclError::Leave(OsclErrNotInstalled); +#endif + + //start scheduling if needed. + if (!IsStarted()) + { + BeginScheduling(false, false);//nonblocking, non-native + } + else if (iBlockingMode || iNativeMode) + OsclError::Leave(OsclErrInvalidState);//not stopped + + //Process timers. All ready timers will get + //moved to the ready queue. + UpdateTimersMsec(aShortestDelay); + + //Run until the requested count is reached, or there + //aren't any AOs ready. + for (int32 count = 0; count < aCount;) + { + //find highest pri ready AO. + PVActiveBase* pvactive = iReadyQ.PopTop(); + if (pvactive) + { + //run it + count++; + CallRunExec(pvactive); + + //re-evaluate timers + UpdateTimersMsec(aShortestDelay); + } + else + break;//nothing ready + } + + //at this point, either nothing else is ready or the target count was reached. + + aReady = iReadyQ.Depth(); + +} + +OSCL_EXPORT_REF void OsclExecScheduler::RegisterForCallback(OsclSchedulerObserver* aCallback, OsclAny* aCallbackContext) +{ + //Update the callback pointers. + iReadyQ.RegisterForCallback(aCallback, aCallbackContext); +} + +//////////////////////////////////////// +// Queue Management +//////////////////////////////////////// + + +PVActiveBase * OsclExecSchedulerCommonBase::FindPVBase(PVActiveBase *active, OsclDoubleList &q) +//Search a PVActiveBase queue, given a PVActiveBase ptr. +{ + QUE_ITER_BEGIN(PVActiveBase, q) + { + if (item == active) + return item; + } + QUE_ITER_END(q) + return NULL; +} + +void OsclExecSchedulerCommonBase::CleanupExecQ() +{ + //Cleanup timers. + { + PVActiveBase *top; + while ((top = iExecTimerQ.PopTop())) + top->RemoveFromScheduler(); + } + //Cleanup ready AOs. + PVActiveBase* top = iReadyQ.Top(); + while (top) + { + top->RemoveFromScheduler(); + top = iReadyQ.Top(); + } +} + +void OsclExecSchedulerCommonBase::InitExecQ(int nreserve) +//init the pvactive queues. +{ + iExecTimerQ.Construct(nreserve); + iReadyQ.Construct(nreserve); +} + +//////////////////////////////////////// +// Non-Symbian queue management +//////////////////////////////////////// + +void OsclExecSchedulerCommonBase::AddToExecTimerQ(PVActiveBase* anActive, uint32 aDelayMicrosec) +//timer implementation. +//Add an AO to the pending timer queue. +{ + OSCL_ASSERT(anActive);//EExecNull + + //make sure this AO is not already added. + if (anActive->IsInAnyQ()) + OsclError::Leave(OsclErrInvalidState);//EExecAlreadyAdded + + //Set time in ticks when AO should run. + + uint32 tickperiod = OsclTickCount::TickCountPeriod(); + OSCL_ASSERT(tickperiod != 0); + + //Round to the nearest integer with the computation: + //floor((2*Interval_usec/ticks_per_usec + 1)/2) + // + //The computed time may rollover the 32-bit value-- that's OK, because + //the tick count will also rollover. + uint32 timenow = OsclTickCount::TickCount(); + anActive->iPVReadyQLink.iTimeToRunTicks = timenow + (aDelayMicrosec * 2 / tickperiod + 1) / 2; + + if (aDelayMicrosec > 0) + { + LOGPERF2((0, "PVSCHED:%s AO %s Timer delay %d TimeToRunTicks %d Timenow %d" + , iLogPerfIndentStr, anActive->iName.Str() + , aDelayMicrosec, anActive->iPVReadyQLink.iTimeToRunTicks + , timenow)); + } + + //queue it + iExecTimerQ.Add(anActive); + + //if this AO is in the front of the queue now, we need to do a + //callback, because the shortest delay interval has changed. + if (iReadyQ.Callback() + && anActive == iExecTimerQ.Top()) + { + iReadyQ.TimerCallback(aDelayMicrosec); + } +} + +//For 32-bit time comparisons with rollover handling. +//This value is (2^31)-1 +const uint32 OsclExecSchedulerCommonBase::iTimeCompareThreshold = 0x7fffffff; + +PVActiveBase* OsclExecSchedulerCommonBase::UpdateTimers(uint32 &aShortestDelay) +//timer processing. +//Complete requests for all timers that are ready now, +//then return the pending timer with the shortest delay if any. +//If any pending timer is returned it's the top of the queue so +//it can be discarded later with Pop. +{ + aShortestDelay = 0; + + PVActiveBase *top = iExecTimerQ.Top(); + + if (!top) + return NULL; + + uint32 timenow = OsclTickCount::TickCount(); + + //Find all timers that are ready, and the first + //timer that isn't. The list is sorted by + //time then priority. + for (; top; top = iExecTimerQ.Top()) + { + //calculate time to run <= timenow, taking possible rollover into account + uint32 deltaTicks = timenow - top->iPVReadyQLink.iTimeToRunTicks; + if (deltaTicks <= iTimeCompareThreshold) + { + //this timer is ready + iExecTimerQ.Pop(top); + + PendComplete(top, OSCL_REQUEST_ERR_NONE, EPVThreadContext_InThread); + } + else + { + //we found the pending timer with the shortest delay. + //get the delay value + int32 delayTicks = deltaTicks; + if (delayTicks < 0) + delayTicks = (-delayTicks); + aShortestDelay = delayTicks; + return top; + } + } + + return NULL;//no pending timers. +} + +PVActiveBase* OsclExecSchedulerCommonBase::UpdateTimersMsec(uint32 &aShortestDelay) +//Identical to UpdateTimers except the delay returned is milliseconds instead +//of ticks. +{ + aShortestDelay = 0; + + PVActiveBase *top = iExecTimerQ.Top(); + + if (!top) + return NULL; + + uint32 timenow = OsclTickCount::TickCount(); + + //Find all timers that are ready, and the first + //timer that isn't. The list is sorted by + //time then priority. + for (; top; top = iExecTimerQ.Top()) + { + //calculate time to run <= timenow, taking possible rollover into account + uint32 deltaTicks = timenow - top->iPVReadyQLink.iTimeToRunTicks; + if (deltaTicks <= iTimeCompareThreshold) + { + //this timer is ready + iExecTimerQ.Pop(top); + + PendComplete(top, OSCL_REQUEST_ERR_NONE, EPVThreadContext_InThread); + } + else + { + //we found the pending timer with the shortest delay. + //get the delay value + int32 delayTicks = deltaTicks; + if (delayTicks < 0) + delayTicks = (-delayTicks); + aShortestDelay = OsclTickCount::TicksToMsec(delayTicks); + + //if delay became zero after the conversion from ticks to msec, + //then just consider this timer to be ready now. + if (aShortestDelay == 0) + { + //this timer is ready + iExecTimerQ.Pop(top); + + PendComplete(top, OSCL_REQUEST_ERR_NONE, EPVThreadContext_InThread); + } + else + { + return top; + } + } + } + + return NULL;//no pending timers. +} + +void OsclExecSchedulerCommonBase::PendComplete(PVActiveBase *pvbase, int32 aReason, TPVThreadContext aThreadContext) +//complete a request for this scheduler. +//Calling context can be any thread. +{ + //During timer cancellation, the AO may still be in the ExecTimerQ. + //Remove it now, since it won't get removed by the scheduler loop. + //Check thread context first, to accessing timer queue from out-of-thread. + if (aThreadContext == EPVThreadContext_InThread) + { + LOGPERF2((0, "PVSCHED: %s AO %s Request complete", iLogPerfIndentStr, pvbase->iName.Str())); + + if (iExecTimerQ.IsIn(pvbase)) + iExecTimerQ.Remove(pvbase); + } + + //Pass this to the ReadyQ so it can do appropriate queue locks + int32 err = iReadyQ.PendComplete(pvbase, aReason); + + OsclError::LeaveIfError(err); +} + +void OsclExecSchedulerCommonBase::RequestCanceled(PVActiveBase* pvbase) +{ + LOGPERF2((0, "PVSCHED: %s AO %s Request canceled", iLogPerfIndentStr, pvbase->iName.Str())); + + //This gets called right after the AO's DoCancel was + //called. It must wait on the request to cancel, and remove it + //from the ready Q. + + //Calling context is always in-thread, since Cancel context is always + //in-thread. + + //See if the request was completed by the DoCancel. + bool complete = iReadyQ.IsIn(pvbase); + + DECLARE_LOOP_STATS; + + if (!complete) + { + //If request is still pending after DoCancel is called, it + //means some other thread will complete the request cancellation. + //If the AO does not have a proper DoCancel, this wait will hang up. + + //reset the perf indent when scheduler gives up CPU... + RESET_LOG_PERF((0, "PVSCHED: Waiting on cancel... AO '%s'", pvbase->iName.Str())); + +#if (PV_SCHED_ENABLE_PERF_LOGGING) + uint32 ticks = OsclTickCount::TickCount(); +#endif + START_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]); + int32 err = iReadyQ.WaitForRequestComplete(pvbase); + END_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]); + +#if (PV_SCHED_ENABLE_PERF_LOGGING) + LOGPERF((0, "PVSCHED: ...Cancel took %d Ticks", OsclTickCount::TickCount() - ticks)); +#endif + + OsclError::LeaveIfError(err); + } + + //Set request idle and remove from ready Q. + //The AO will not run + pvbase->iBusy = false; + + START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]); + iReadyQ.Remove(pvbase); + END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]); +} + + + + +//////////////////////////////////////// +// PV Scheduling Loop Implementation +//////////////////////////////////////// + + +void OsclExecSchedulerCommonBase::CallRunExec(PVActiveBase *pvactive) +//Run a PV AO. +{ + //Set this AO inactive. This AO may be from the + //ready Q or the pending Timer Q. + //The dequeing is done by the caller. + pvactive->iBusy = false; + + //start stats +#if (PV_SCHED_ENABLE_AO_STATS) + iPVStats = pvactive->iPVActiveStats;//save value now since it may change in the Run call. + iDelta = 0; + INIT_TICK(iTime); +#endif + + SET_TICK(iTime); + + //Call the Run under a trap harness. + //Pass the ErrorTrapImp pointer to reduce overhead of the Try call. + //We already did a null ptr check on iErrorTrapImp so it's safe to de-ref here. + int32 err; + OSCL_TRY_NO_TLS(iErrorTrapImp, err, pvactive->Run();); + + //end stats + DIFF_TICK(iTime, iDelta); + UPDATE_RUNL_TIME(iPVStats, iDelta); + UPDATE_LEAVE_CODE(iPVStats, err); + +#if(PV_SCHED_ENABLE_PERF_LOGGING) + //show AO time. + IncLogPerf(iDelta); + LOGPERF((0, "PVSCHED: %s Run %d %s AO %s", iLogPerfIndentStr, (int32)iDelta, TICKSTR, pvactive->iName.Str())); +#endif + + //check for a leave in the Run... + if (err != OsclErrNone) + { + //start stats + SET_TICK(iTime); + + //call the AO error handler + err = pvactive->RunError(err); + + //end stats + DIFF_TICK(iTime, iDelta); + UPDATE_RUNERROR_TIME(iPVStats, iDelta); + + //If the AO did not handle the error, indicated by returning + //ErrNone, then call the scheduler error handler. + if (err != OsclErrNone) + { + LOGERROR((0, "PVSCHED:Scheduler '%s', Thread 0x%x: Error! AO %s Error %d not handled" + , iName.Str(), PVThreadContext::Id() + , pvactive->iName.Str(), err)); + fprintf(stderr, "PVSCHED:Scheduler '%s', Thread 0x%x: Error! AO %s Error %d not handled\n" + , iName.Str(), PVThreadContext::Id() + , pvactive->iName.Str(), err); + + Error(err); + } + } + +} + + +void OsclExecSchedulerCommonBase::BlockingLoopL() +//Blocking scheduling loop. +//Will leave if any AO leaves. +{ + + PVActiveBase* pvactive; + + + while (!iDoStop) + { + //Get the next AO to run. This call may block until an AO is ready. + pvactive = WaitForReadyAO(); + + if (pvactive) + { + CallRunExec(pvactive); + } + else + { + OsclError::Leave(OsclErrCorrupt);//EExecStrayEvent + } + + //check for a suspend signal.. + if (iDoSuspend) + { + iSuspended = true; + iDoSuspend = false; + iResumeSem.Wait(); + iSuspended = false; + } + + }//while !dostop + + iDoStop = false; +} + + +PVActiveBase* OsclExecSchedulerCommonBase::WaitForReadyAO() +//Find the next AO to run-- non-Symbian version. +{ + DECLARE_LOOP_STATS; + + //First process timers. + //All ready timers will get moved to the run Q. + uint32 waitTicks; + START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]); + PVActiveBase* pvtimer = UpdateTimers(waitTicks); + END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]); + + //Check for a ready AO. + START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]); + PVActiveBase* pvactive = iReadyQ.PopTop(); + END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]); + + if (pvactive) + { + //An AO is ready. + return pvactive; + } + else if (pvtimer) + { + //No AO is ready, but at least one timer is pending. + //Wait on shortest timer expiration or a new request. + + //reset the perf logging indent each time scheduler gives up CPU. + RESET_LOG_PERF((0, "PVSCHED: Waiting on timer... Ticks %d AO %s", waitTicks, pvtimer->iName.Str())); + + START_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]); + pvactive = iReadyQ.WaitAndPopTop(OsclTickCount::TicksToMsec(waitTicks)); + END_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]); + + if (pvactive) + { + //Another AO's request completed while we were waiting. + //Run that one instead of the timer. + return pvactive; + } + else + { + //It's time to complete this timer's request and run it. + //To save overhead, don't move it to the ReadyQ, just pop it + //from its current location on the top of the timer queue. + + pvtimer->iStatus = OSCL_REQUEST_ERR_NONE; + + START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]); + iExecTimerQ.Pop(pvtimer); + END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]); + + return pvtimer; + } + } + else + { + //Nothing is ready and no timer is pending. + //Wait on a request to be completed by another thread. + + //reset the perf logging indent each time scheduler gives up CPU. + RESET_LOG_PERF((0, "PVSCHED: Waiting on any request...")); + + START_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]); + pvactive = iReadyQ.WaitAndPopTop(); + END_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]); + + return pvactive; + } +} + +//////////////////////////////////////// +// PVSchedulerStopper +//////////////////////////////////////// +PVSchedulerStopper::PVSchedulerStopper() + : OsclActiveObject((int32)OsclActiveObject::EPriorityHighest, "Stopper") +{ +} + +PVSchedulerStopper::~PVSchedulerStopper() +{ +} + +void PVSchedulerStopper::Run() +//This AO just waits for a signal to suspend or stop the scheduler. +{ + //Stop + switch (Status()) + { + case STOPPER_REQUEST_STOP_NATIVE: + break; + case STOPPER_REQUEST_STOP_PV: + { + //stop my scheduling loop + OsclExecSchedulerCommonBase* myscheduler = OsclExecScheduler::GetScheduler(); + if (myscheduler) + myscheduler->iDoStop = true; + } + break; + case STOPPER_REQUEST_SUSPEND: + { + //suspend my scheduling loop + OsclExecSchedulerCommonBase* myscheduler = OsclExecScheduler::GetScheduler(); + if (myscheduler) + myscheduler->iDoSuspend = true; + + //re-schedule ourself + PendForExec(); + } + break; + default: + break; + } +} + +//////////////////////////////////////// +// Symbian Coe Scheduler +//////////////////////////////////////// + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler.h new file mode 100644 index 0000000..340172c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler.h @@ -0,0 +1,405 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \addtogroup osclproc OSCL Proc + * + * @{ + */ + + + +/** \file pvscheduler.h + \brief Main include file for Oscl Scheduler +*/ + + +#ifndef OSCL_SCHEDULER_H_INCLUDED +#define OSCL_SCHEDULER_H_INCLUDED + +#ifndef OSCL_SCHEDULER_TYPES_H_INCLUDED +#include "oscl_scheduler_types.h" +#endif + +#ifndef OSCL_SCHEDULER_AO_H_INCLUDED +#include "oscl_scheduler_ao.h" +#endif + +#ifndef OSCL_SCHEDULER_THREADCONTEXT_H_INCLUDED +#include "oscl_scheduler_threadcontext.h" +#endif + +#ifndef OSCL_MUTEX_H_INCLUDED +#include "oscl_mutex.h" +#endif + +#ifndef OSCL_SEMAPHORE_H_INCLUDED +#include "oscl_semaphore.h" +#endif + +#ifndef OSCL_SCHEDULER_READYQ_H_INCLUDED +#include "oscl_scheduler_readyq.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +class Oscl_DefAlloc; +class OsclCoeActiveScheduler; + + +/** + * Per-thread scheduler initialization and cleanup. + */ +class OsclScheduler +{ + public: + /** + * This routine creates and installs a scheduler in + * the calling thread. + * @param name: (input param) scheduler name. + * @param alloc: (input param) optional allocator to use for + * the internal implementation. + * @param nreserve: (input param) optional value for ready queue + * reserve size. + */ + OSCL_IMPORT_REF static void Init(const char *name, Oscl_DefAlloc *alloc = NULL, int nreserve = 20); + + + /** + * This routine uninstalls and destroys Oscl scheduler + * for the calling thread. + */ + OSCL_IMPORT_REF static void Cleanup(); +}; + + +/** + * PV Scheduler class + */ + +#define PVSCHEDNAMELEN 30 + +class PVSchedulerStopper; +class PVJump; +class PVLogger; + +/** + * OsclSchedulerObserver is an observer class for use when running scheduler + * in non-blocking mode. + * The scheduler observer can register for callbacks so it + * will be notified when it is necessary to run scheduler again. + * Note: non-blocking mode and scheduler callbacks are not supported on Symbian. + */ +class OsclSchedulerObserver +{ + public: + /** + * OsclSchedulerTimerCallback is called when the front of the timer queue + * is updated. This means the minimum delay has changed and scheduler needs + * to be run again after aDelayMsec. Calling context is in-thread. + * + * The current observer is cleared before making the callback, so the + * observer must call RegisterForCallback again if it wants further + * notifications. + */ + virtual void OsclSchedulerTimerCallback(OsclAny* aContext, uint32 aDelayMsec) = 0; + + /** + * OsclSchedulerReadyCallback is called when the ready queue is updated, meaning + * an AO is ready to run. Scheduler needs to be run ASAP. + * Calling context may be any thread, so be careful! + * + * The current observer is cleared before making the callback, so the + * observer must call RegisterForCallback again if it wants further + * notifications. + */ + virtual void OsclSchedulerReadyCallback(OsclAny* aContext) = 0; + + virtual ~OsclSchedulerObserver() {} +}; + + +/* +** A common base class for variations of OsclExecScheduler +**/ + +class OsclExecSchedulerCommonBase +{ + public: + /** + * Start scheduling. This call blocks until scheduler + * is stopped or an error occurs. + * @param sem: optional startup semaphore. If provied, + * the scheduler will signal this semaphore when + * the startup has progressed to the point that it's + * safe to call StopScheduler or SuspendScheduler + * from another thread. + */ + OSCL_IMPORT_REF void StartScheduler(OsclSemaphore *sem = NULL); + + /** + * Stop scheduling. This API may be called from the + * scheduling thread or some other thread. + */ + OSCL_IMPORT_REF void StopScheduler(); + + /** + * Suspend scheduling when the current Run is complete. + * This API only applies to a blocking loop scheduler. + */ + OSCL_IMPORT_REF void SuspendScheduler(); + + /** + * Resume scheduling immediately. + * This API only applies to a blocking loop scheduler. + */ + OSCL_IMPORT_REF void ResumeScheduler(); + + /** + * Start the OS native scheduling loop. This is an alternative + * to the PV scheduling loop. + * To stop the native scheduler, use the StopScheduler API. + */ + OSCL_IMPORT_REF void StartNativeScheduler(); + + /** + * Get name of scheduler for current thread. + */ + OSCL_IMPORT_REF static OsclNameString *GetName(); + + /** + * Get numeric ID of current thread. + */ + OSCL_IMPORT_REF static uint32 GetId(); + + + protected: + /* + static OsclExecScheduler *NewL(const char *name,Oscl_DefAlloc *a,int nreserve); + */ + virtual ~OsclExecSchedulerCommonBase(); + void InstallScheduler(); + void UninstallScheduler(); + friend class OsclScheduler; + + protected: + void Error(int32 anError) const; + + protected: + static OsclExecSchedulerCommonBase* GetScheduler(); + static OsclExecSchedulerCommonBase* SetScheduler(OsclExecSchedulerCommonBase*); + friend class PVThreadContext; + friend class OsclCoeActiveScheduler; + + protected: + OsclExecSchedulerCommonBase(Oscl_DefAlloc*); + virtual void ConstructL(const char *name, int); + + void BeginScheduling(bool blocking, bool native); + void EndScheduling(); + + void BlockingLoopL(); + + bool iBlockingMode;//current blocking mode setting. + bool iNativeMode;//current native mode setting. + + bool IsStarted(); + inline bool IsInstalled(); + + //Stopper AO is a special PV AO used to implement + //the StopScheduler and SuspendScheduler functions. + PVSchedulerStopper *iStopper; + OsclNoYieldMutex iStopperCrit; + + //Scheduler thread context + PVThreadContext iThreadContext; + + //Scheduler name + OsclNameString iName; + + //For stop, suspend, and resume commands. + bool iDoStop; + bool iDoSuspend; + bool iSuspended; + OsclSemaphore iResumeSem; + + OsclErrorTrapImp* iErrorTrapImp; + + //Ready AO queue. The AOs in this queue are ready to run. + OsclReadyQ iReadyQ; + + //Pending Timer AO queue. The AOs in this queue are OsclTimerObjects + //and have a timeout pending. + OsclTimerQ iExecTimerQ; + void AddToExecTimerQ(PVActiveBase *active, uint32); + + void PendComplete(PVActiveBase *, int32 aReason, TPVThreadContext aContext); + void RequestCanceled(PVActiveBase*); + + //Scheduling loop implementation. + PVActiveBase* UpdateTimers(uint32 &aDelay); + PVActiveBase* UpdateTimersMsec(uint32 &aDelay); + PVActiveBase* WaitForReadyAO(); + void CallRunExec(PVActiveBase*); + + static const uint32 iTimeCompareThreshold; + friend class OsclTimerCompare; + friend class OsclReadyQ; + + friend class OsclError; + + + + uint32 iNumAOAdded;//for non-fair-scheduling sorts. + + //For statistics +#if (PV_SCHED_ENABLE_AO_STATS) + OsclDoubleList iPVStatQ;//queue of all PV ExecObjs. + enum TOtherExecStats + { + EOtherExecStats_WaitTime //scheduler wait time + , EOtherExecStats_QueueTime //scheduler queue operation time + , EOtherExecStats_NativeOS //time in symbian native ExecObjs, not added by PV code (symbian only) + , EOtherExecStats_ReleaseTime //thread release time (Brew only) + , EOtherExecStats_Last + }; + PVActiveStats* iOtherExecStats[EOtherExecStats_Last];//placeholder for stats of all ExecObjs. + void ConstructStatQ(); + void BeginStats(); + void EndStats(); + static void ShowStats(PVActiveStats *active); + static void ShowSummaryStats(PVActiveStats *active, PVLogger*, int64, int64&, float&); + void CleanupStatQ(); + uint8* iTotalTicksTemp; + int64 iGrandTotalTicks; + float iTotalPercent; + friend class PVActiveStats; + uint32 iTime; + int32 iDelta; + PVActiveStats* iPVStats; +#endif //PV_SCHED_ENABLE_AO_STATS + + //Queue utils. + PVActiveBase *FindPVBase(PVActiveBase *active, OsclDoubleList &); + void CleanupExecQ(); + void InitExecQ(int); + + PVLogger *iLogger; + PVLogger* iDebugLogger; + +#if(PV_SCHED_ENABLE_PERF_LOGGING) + //for perf logging + char* iLogPerfIndentStr; + int32 iLogPerfIndentStrLen; + uint32 iLogPerfTotal; + void ResetLogPerf(); + void IncLogPerf(uint32); +#endif + + Oscl_DefAlloc *iAlloc;//allocator for scheduler. + OsclMemAllocator iDefAlloc;//default allocator + + friend class OsclActiveObject; + friend class OsclTimerObject; + friend class PVActiveBase; + friend class PVSchedulerStopper; + + + friend class OsclExecScheduler; +}; + +class OsclErrorTrapImp; + +class OsclExecScheduler: public OsclExecSchedulerCommonBase + , public OsclExecSchedulerBase +{ + public: + /** + * Get currently installed scheduler for calling thread, + * or NULL if no scheduler is installed. + */ + OSCL_IMPORT_REF static OsclExecScheduler* Current(); + + /** + * Non-Blocking scheduler APIs. + */ + + /** + * Run PV scheduler in non-blocking mode. This call returns + * when the desired number of Run calls have been made, + * or when there are no more active objects that are ready + * to run. + * + * @param aTargetCount: (input param) the maximum number of Run calls to make. + * @param aReady: (output param) tells the number of active objects that + * are currently ready to run. + * @param aDelayMsec: (output param) If no active objects are ready to + * run, but one or more active objects are waiting on timers, this + * parameter will tell the time interval from the current time until the + * first of the pending timer objects will be ready to run, in milliseconds. + * + * Note: On Symbian, non-blocking mode is not supported and this call will + * leave. + * + */ + OSCL_IMPORT_REF void RunSchedulerNonBlocking(int32 aTargetCount, int32 &aReady, uint32 &aDelayMsec); + + /** + * Register for a notification when non-blocking scheduler needs to run + * again. + * + * Note: On Symbian, non-blocking mode is not supported and this call will + * leave. + */ + OSCL_IMPORT_REF void RegisterForCallback(OsclSchedulerObserver* aCallback, OsclAny* aCallbackContext); + + + private: + static OsclExecScheduler *NewL(const char *name, Oscl_DefAlloc *a, int nreserve); + ~OsclExecScheduler(); + friend class OsclScheduler; + + + OsclExecScheduler(Oscl_DefAlloc*); + void ConstructL(const char *name, int); + +}; + + +/** + * Scheduler stopper AO class, for internal use + * by scheduler. + */ +class PVSchedulerStopper: public OsclActiveObject +{ + public: + PVSchedulerStopper(); + ~PVSchedulerStopper(); + private: + void Run(); +}; + + +#endif + + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_ao.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_ao.cpp new file mode 100644 index 0000000..6c1d581 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_ao.cpp @@ -0,0 +1,445 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#include "oscl_scheduler_ao.h" +#include "oscl_error.h" +#include "oscl_scheduler.h" +#include "pvlogger.h" +#include "oscl_tickcount.h" + +#define OSCL_DISABLE_WARNING_THIS_USED_IN_BASE_CLASS +#define OSCL_DISABLE_WARNING_TYPEDEF_USED_AS_SYNONYM +#include "osclconfig_compiler_warnings.h" + +#include "oscl_scheduler_tuneables.h" + +///////////////////// +// PVActiveBase +///////////////////// + +PVActiveBase::PVActiveBase(const char name[], + int32 pri) +{ + iName.Set(name); +#if(PV_SCHED_ENABLE_AO_STATS) + iPVActiveStats = NULL; +#endif + iPVReadyQLink.iAOPriority = pri; + iBusy = false; + iStatus = OSCL_REQUEST_ERR_NONE; +} + +PVActiveBase::~PVActiveBase() +{ + if (iBusy) + OsclError::Leave(OsclErrInvalidState);//EExecStillReadyOnDestruct +} + +#if(PV_SCHED_ENABLE_AO_STATS) +PVActiveStats::PVActiveStats(OsclExecSchedulerCommonBase* aScheduler, const char* aAOName, PVActiveBase* aActiveBase) +{ + OSCL_ASSERT(aScheduler); + + iPVActiveBase = aActiveBase; + iAOName = aAOName; + iScheduler = aScheduler; + + iNumRun = 0; + iNumRunError = 0; + iMaxTicksInRun = 0; + iTotalTicksInRun = 0; + i64Valid = true;//make 64-bit the default. + i64TotalTicksInRun = 0; + iPercent = 0.0; + iLeave = OsclErrNone; + iNumCancel = 0; + iNumInstances = 1; + iPriority = (aActiveBase) ? aActiveBase->iPVReadyQLink.iAOPriority : 0; +} +PVActiveStats::~PVActiveStats() +{ + iPVStatQLink.Remove(); + + //destroy the link from the AO to this object + if (iPVActiveBase) + iPVActiveBase->iPVActiveStats = NULL; +} +void PVActiveStats::Combine(PVActiveStats& aStats) +{ + iNumRun += aStats.iNumRun; + iNumRunError += aStats.iNumRunError; + iTotalTicksInRun += aStats.iTotalTicksInRun; + OSCL_ASSERT(i64Valid == aStats.i64Valid); + i64TotalTicksInRun += aStats.i64TotalTicksInRun; + iNumCancel += aStats.iNumCancel; + if (aStats.iLeave != OsclErrNone) + iLeave = aStats.iLeave; + iNumInstances++; +} +#endif //#if(PV_SCHED_ENABLE_AO_STATS) + + +void PVActiveBase::AddToScheduler() +{ + iThreadContext.EnterThreadContext(); + if (iThreadContext.iScheduler) + { + iAddedNum = iThreadContext.iScheduler->iNumAOAdded++; + +#if(PV_SCHED_ENABLE_AO_STATS) + //add to PV stat Q + if (!iPVActiveStats) + { + OsclAny* ptr = iThreadContext.iScheduler->iAlloc->allocate(sizeof(PVActiveStats)); + OsclError::LeaveIfNull(ptr); + iPVActiveStats = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(iThreadContext.iScheduler, (char*)iName.Str(), this)); + iThreadContext.iScheduler->iPVStatQ.InsertTail(*iPVActiveStats); + //note: this memory is cleaned up in CleanupStatQ when the scheduler + //exits. + } +#endif + } +} + +void PVActiveBase::RemoveFromScheduler() +{ + if (IsAdded()) + { + if (iBusy) + Cancel(); + //no additional de-queueing is needed-- once AOs are + //canceled they're not in any queues. + } + + iThreadContext.ExitThreadContext(); + +#if(PV_SCHED_ENABLE_AO_STATS) + //destroy the link from the stats object back to this object. + //this means that a new stats object will be created if this AO + //is added to this or another scheduler again. + if (iPVActiveStats) + { + iPVActiveStats->iPVActiveBase = NULL; + //since we've unlinked this to the PVActiveStats object, + //we must prevent accessing the object again since it could + //get deleted. + iPVActiveStats = NULL; + } +#endif +} + +void PVActiveBase::Destroy() +//common AO cleanup. +{ + RemoveFromScheduler(); +} + +void PVActiveBase::Activate() +//Activate an AO's request. This only does the portion of the +//activation that is common to both timers and non-timers. +{ + + //mimic standard symbian panics. + if (iBusy) + OsclError::Leave(OsclErrInvalidState);//EExecAlreadyActive + if (!iThreadContext.iOpen) + OsclError::Leave(OsclErrInvalidState);//EExecNotAdded + +#if PV_SCHED_ENABLE_THREAD_CONTEXT_CHECKS + PVThreadContext::LeaveIfWrongThread(iThreadContext); +#endif + + iBusy = true; + + //caller will activate the timer. For + //non-timers, nothing else is needed. + +} + +OSCL_EXPORT_REF bool PVActiveBase::IsAdded() const +{ + return iThreadContext.iOpen; +} + + +void PVActiveBase::Cancel() +{ + if (iBusy) + { +#if PV_SCHED_ENABLE_THREAD_CONTEXT_CHECKS + //require same thread context for cancel calls, + //since we'll be calling the DoCancel routine. + PVThreadContext::LeaveIfWrongThread(iThreadContext); +#endif + + //call the cancel handler-- this should + //complete the request if needed. + //Note: symbian calls the DoCancel even + //if the request is already complete, so + //I do the same in order to get the same + //behavior. +#if(PV_SCHED_ENABLE_AO_STATS) + iPVActiveStats->iNumCancel++; +#endif + DoCancel(); + + //wait for request to cancel. + iThreadContext.iScheduler->RequestCanceled(this); + } +} + +///////////////////// +// OsclActiveObject +///////////////////// + +OSCL_EXPORT_REF OsclActiveObject::OsclActiveObject(int32 aPriority, const char name[]): + PVActiveBase(name, aPriority) +{ + iStatus = OSCL_REQUEST_ERR_NONE; +} + +OSCL_EXPORT_REF OsclActiveObject::~OsclActiveObject() +{ + //"typically, a derived class calls Cancel in its + //destructor" + Cancel(); + PVActiveBase::Destroy(); +} + +OSCL_EXPORT_REF void OsclActiveObject::PendComplete(int32 aStatus) +{ + iThreadContext.PendComplete(this, aStatus, EPVThreadContext_Undetermined); +} + +OSCL_EXPORT_REF void OsclActiveObject::AddToScheduler() +{ + PVActiveBase::AddToScheduler(); +} + + +OSCL_EXPORT_REF void OsclActiveObject::RemoveFromScheduler() +{ + PVActiveBase::RemoveFromScheduler(); +} + +OSCL_EXPORT_REF void OsclActiveObject::SetBusy() +//Need this overload to prevent anyone from using +//OsclActiveObject::SetActive directly on systems that have +//that method (eg Symbian) +{ + Activate(); + //nothing else needed. +} + +OSCL_EXPORT_REF bool OsclActiveObject::IsBusy() const +//On systems with OsclActiveObj::IsActive, this function +//allows us to convert the return type to bool +{ + return iBusy; +} + + +OSCL_EXPORT_REF void OsclActiveObject::Cancel() +//Need this overload to prevent anyone from using +//OsclActiveObject::Cancel on systems that have that method (Symbian). +{ + PVActiveBase::Cancel(); +} + +OSCL_EXPORT_REF int32 OsclActiveObject::Priority() const +{ + return iPVReadyQLink.iAOPriority; +} + +OSCL_EXPORT_REF int32 OsclActiveObject::Status() const +//get the AO status value. +{ + return iStatus.Value(); +} + +OSCL_EXPORT_REF OsclAOStatus& OsclActiveObject::StatusRef() +//get a ref to the AO status object. +{ + return iStatus; +} + +OSCL_EXPORT_REF void OsclActiveObject::SetStatus(int32 s) +//set the AO status value. +{ + iStatus = s; +} + +OSCL_EXPORT_REF void OsclActiveObject::PendForExec() +//activate the AO request. +{ + SetBusy(); + iStatus = OSCL_REQUEST_PENDING; +} + +OSCL_EXPORT_REF void OsclActiveObject::RunIfNotReady() +//If the AO request is not active, activate and complete it. +{ + if (!IsBusy()) + { + PendForExec(); + PendComplete(OSCL_REQUEST_ERR_NONE); + } +} + +OSCL_EXPORT_REF void OsclActiveObject::DoCancel() +//default request canceler for AOs +{ + if (iStatus == OSCL_REQUEST_PENDING) + iThreadContext.PendComplete(this, OSCL_REQUEST_ERR_CANCEL, EPVThreadContext_InThread); +} + +OSCL_EXPORT_REF int32 OsclActiveObject::RunError(int32 aError) +//default error handler for active objects. +{ + return aError; +} + + +///////////////////// +// OsclTimerObject +///////////////////// + +OSCL_EXPORT_REF OsclTimerObject::OsclTimerObject(int32 aPriority, const char name[]): + PVActiveBase(name, aPriority) +{ + SetStatus(OSCL_REQUEST_ERR_NONE); +} + +OSCL_EXPORT_REF OsclTimerObject::~OsclTimerObject() +{ + //"typically, a derived class calls Cancel in its + //destructor" + Cancel(); + PVActiveBase::Destroy(); +} + +OSCL_EXPORT_REF void OsclTimerObject::AddToScheduler() +{ + iPVReadyQLink.iTimeToRunTicks = 0; + + PVActiveBase::AddToScheduler(); +} + + +OSCL_EXPORT_REF void OsclTimerObject::RemoveFromScheduler() +{ + PVActiveBase::RemoveFromScheduler(); + +} + +OSCL_EXPORT_REF void OsclTimerObject::After(int32 aDelayMicrosec) +//like CTimer::After. +{ + PVActiveBase::Activate(); + + + //Just put this AO in the scheduler timer queue-- the scheduler + //will complete the request at the correct time. + iStatus = OSCL_REQUEST_PENDING; + iThreadContext.iScheduler->AddToExecTimerQ(this, aDelayMicrosec); + +} + +OSCL_EXPORT_REF void OsclTimerObject::RunIfNotReady(uint32 aDelayMicrosec) +//If the AO is not ready, start its timeout for completion. +{ + if (!IsBusy()) + + { + if (aDelayMicrosec > 0) + { + OsclTimerObject::After(aDelayMicrosec); + } + else + { + // If delay is 0, make ready and complete pend immediately, to avoid going through the timer queue + SetBusy(); + SetStatus(OSCL_REQUEST_PENDING); + if (IsAdded()) + { + iThreadContext.PendComplete(this, OSCL_REQUEST_ERR_NONE, EPVThreadContext_InThread); + } + } + } +} + +OSCL_EXPORT_REF void OsclTimerObject::SetBusy() +//Need this overload to prevent anyone from using +//OsclActiveObject::SetActive on Symbian. +{ + PVActiveBase::Activate(); + +} + +OSCL_EXPORT_REF bool OsclTimerObject::IsBusy() const +//needed to prevent using OsclActiveObject::IsActive, just to +//get correct return type bool instead of TBool. +{ + return iBusy; +} + + +OSCL_EXPORT_REF void OsclTimerObject::Cancel() +//Need this overload to prevent anyone from using +//OsclActiveObject::Cancel on Symbian. +{ + PVActiveBase::Cancel(); +} + +OSCL_EXPORT_REF int32 OsclTimerObject::Priority() const +{ + return iPVReadyQLink.iAOPriority; +} + +OSCL_EXPORT_REF int32 OsclTimerObject::Status() const +{ + return iStatus.Value(); +} + +OSCL_EXPORT_REF OsclAOStatus& OsclTimerObject::StatusRef() +{ + return iStatus; +} + +OSCL_EXPORT_REF void OsclTimerObject::SetStatus(int32 s) +{ + iStatus = s; +} + +OSCL_EXPORT_REF void OsclTimerObject::DoCancel() +//default request canceler for timer objects. +{ + //cancel the pending timeout. + if (iStatus == OSCL_REQUEST_PENDING) + iThreadContext.iScheduler->PendComplete(this, OSCL_REQUEST_ERR_CANCEL, EPVThreadContext_InThread); +} + +OSCL_EXPORT_REF int32 OsclTimerObject::RunError(int32 aError) +//default error handler for timer objects. +{ + return aError; +} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_ao.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_ao.h new file mode 100644 index 0000000..5f9f8c6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_ao.h @@ -0,0 +1,326 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \addtogroup osclproc OSCL Proc + * + * @{ + */ + + +/** \file oscl_scheduler_ao.h + \brief Oscl Scheduler user execution object classes. +*/ + + +#ifndef OSCL_SCHEDULER_AO_H_INCLUDED +#define OSCL_SCHEDULER_AO_H_INCLUDED + +#ifndef OSCL_SCHEDULER_TYPES_H_INCLUDED +#include "oscl_scheduler_types.h" +#endif + +#ifndef OSCL_SCHEDULER_AOBASE_H_INCLUDED +#include "oscl_scheduler_aobase.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +/** + * User base class for execution objects. + * OsclActiveObject defines an execution object without any timer. + * This AO can be used across threads, i.e. the request + * can be activated in one thread and completed in another. + */ +class OsclActiveObject: + public HeapBase, + public PVActiveBase +{ + public: + /** + * Scheduling priorities. + */ + enum OsclActivePriority + { + /** + A low priority, useful for execution objects representing + background processing. + */ + EPriorityIdle = -100, + /** + A priority higher than EPriorityIdle but lower than EPriorityNominal. + */ + EPriorityLow = -20, + /** + Most exec objects will have this priority. + */ + EPriorityNominal = 0, + /** + A priority higher than EPriorityNominal; useful for execution objects + handling user input. + */ + EPriorityHigh = 10, + /** + A priority higher than EPriorityHighest. + */ + EPriorityHighest = 20, + }; + + /** + * Constructor. + * @param aPriority (input param): scheduling priority + * @param name (inpup param): optional name for this AO. + */ + OSCL_IMPORT_REF OsclActiveObject(int32 aPriority, const char name[]); + + /** + * Destructor. + */ + OSCL_IMPORT_REF virtual ~OsclActiveObject(); + + + /** + * Set object ready for this AO, + * additionally sets the request status to OSCL_REQUEST_PENDING. + * Will leave if the request is already readied, + * or the execution object is not added to any scheduler, + * or the calling thread context does not match + * the scheduler thread. + */ + OSCL_IMPORT_REF void SetBusy(); + + /** + * Return true if this AO is pending, + * false otherwise. + */ + OSCL_IMPORT_REF bool IsBusy() const; + + /** + * Set request active for this AO and set the status to pending. + * PendForExec is identical to SetActive, but it + * additionally sets the request status to OSCL_REQUEST_PENDING. + */ + OSCL_IMPORT_REF void PendForExec(); + + /** + * Complete the active request for the AO. + * This API is thread-safe. + * If the request is not pending, this call will leave. + * @param aStatus: request completion status. + */ + OSCL_IMPORT_REF void PendComplete(int32 aStatus); + + /** + * Add this exec object to the current thread's scheduler. + */ + OSCL_IMPORT_REF void AddToScheduler(); + + /** + * Remove this AO from its scheduler. + * Will leave if the calling thread context does + * not match the scheduling thread. + * Cancels any readied request before removing. + */ + OSCL_IMPORT_REF void RemoveFromScheduler(); + + + /** + * Complete this AO's request immediately. + * If the AO is already active, this will do nothing. + * Will leave if the AO is not added to any scheduler, + * or if the calling thread context does not match the + * scheduling thread. + */ + OSCL_IMPORT_REF void RunIfNotReady(); + + /** + * Cancel any pending request. + * If the request is readied, this will call the DoCancel + * routine, wait for the request to cancel, then set the + * request idle. The AO will not run. + * If the request is not readied, it does nothing. + * Request must be canceled from the same thread + * in which it is scheduled. + */ + OSCL_IMPORT_REF void Cancel(); + + + /** + * Return scheduling priority of this exec object. + */ + OSCL_IMPORT_REF int32 Priority() const; + + /** + * Request status access + */ + OSCL_IMPORT_REF int32 Status()const; + OSCL_IMPORT_REF void SetStatus(int32); + OSCL_IMPORT_REF OsclAOStatus& StatusRef(); + + protected: + /** + * Cancel request handler. + * This gets called by scheduler when the request + * is cancelled. The default routine will complete + * the request. If any additional action is needed, + * the derived class may override this. If the derived class + * does override DoCancel, it must complete the request. + */ + OSCL_IMPORT_REF virtual void DoCancel(); + + /** + * Run Error handler. + * This gets called by scheduler when the Run routine leaves. + * The default implementation simply returns the leave code. + * If the derived class wants to handle errors from Run, + * it may override this. The RunError should return OsclErrNone + * if it handles the error, otherwise it should return the + * input error code. + * @param aError: the leave code generated by the Run. + */ + OSCL_IMPORT_REF virtual int32 RunError(int32 aError); + +}; + +/** + * User base class for execution objects. + * OsclTimerObject defines an exec object with a timer. + + */ +class OsclTimerObject: public HeapBase + , public PVActiveBase +{ + public: + /** + * Constructor. + * @param aPriority (input param): scheduling priority + * @param name (input param): optional name for this AO. + */ + OSCL_IMPORT_REF OsclTimerObject(int32 aPriority, const char name[]); + + /** + * Destructor. + */ + OSCL_IMPORT_REF virtual ~OsclTimerObject(); + + /** + * Add this AO to the current thread's scheduler. + */ + OSCL_IMPORT_REF void AddToScheduler(); + + + /** + * Remove this AO from its scheduler. + * Will leave if the calling thread context does + * not match the scheduling thread. + * Cancels any pending request before removing. + */ + OSCL_IMPORT_REF void RemoveFromScheduler(); + + + /** + * 'After' sets the request ready, with request status + * OSCL_REQUEST_STATUS_PENDING, and starts a timer. + * When the timer expires, the request will complete with + * status OSCL_REQUEST_ERR_NONE. + * Must be called from the same thread in which the + * active object is scheduled. + * Will leave if the request is already readied, the object + * is not added to any scheduler, or the calling thread + * does not match the scheduling thread. + * @param anInterval: timeout interval in microseconds. + */ + OSCL_IMPORT_REF void After(int32 aDelayMicrosec); + + /** + * Complete the request after a time interval. + * RunIfNotReady is identical to After() except that it + * first checks the request status, and if it is already + * readied, it does nothing. + * + * @param aDelayMicrosec (input param): delay in microseconds. + */ + OSCL_IMPORT_REF void RunIfNotReady(uint32 aDelayMicrosec = 0); + + /** + * Set request ready for this AO. + * Will leave if the request is already readied, + * or the exec object is not added to any scheduler, + * or the calling thread context does not match + * the scheduler thread. + */ + OSCL_IMPORT_REF void SetBusy(); + + /** + * Return true if this AO is active, + * false otherwise. + */ + OSCL_IMPORT_REF bool IsBusy() const; + + /** + * Cancel any active request. + * If the request is pending, this will call the DoCancel + * routine, wait for the request to cancel, then set the + * request idle. The AO will not run. + * If the request is not active, it does nothing. + * Request must be canceled from the same thread + * in which it is scheduled. + */ + OSCL_IMPORT_REF void Cancel(); + + /** + * Return scheduling priority of this exec object. + */ + OSCL_IMPORT_REF int32 Priority() const; + /** + * Request status access + */ + OSCL_IMPORT_REF int32 Status()const; + OSCL_IMPORT_REF void SetStatus(int32); + OSCL_IMPORT_REF OsclAOStatus& StatusRef(); + + protected: + /** + * Cancel request handler. + * This gets called by scheduler when the request + * is cancelled. The default routine will cancel + * the timer. If any additional action is needed, + * the derived class may override this. If the + * derived class does override this, it should explicitly + * call OsclTimerObject::DoCancel in its own DoCancel + * routine. + */ + OSCL_IMPORT_REF virtual void DoCancel(); + + /** + * Run Leave handler. + * This gets called by scheduler when the Run routine leaves. + * The default implementation simply returns the leave code. + * If the derived class wants to handle errors from Run, + * it may override this. The ExecError should return OsclErrNone + * if it handles the error, otherwise it should return the + * input error code. + * @param aError: the leave code generated by the Run. + */ + OSCL_IMPORT_REF virtual int32 RunError(int32 aError); +}; + + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_aobase.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_aobase.h new file mode 100644 index 0000000..a03b6b6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_aobase.h @@ -0,0 +1,279 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \addtogroup osclproc OSCL Proc + * + * @{ + */ + + +/** \file oscl_scheduler_aobase.h + \brief Oscl Scheduler internal active object classes. +*/ + +/** This file defines the PVActiveBase class, which is a common base for + All PV ExecObjs on all platforms. + */ + +#ifndef OSCL_SCHEDULER_AOBASE_H_INCLUDED +#define OSCL_SCHEDULER_AOBASE_H_INCLUDED + +#ifndef OSCL_SCHEDULER_TYPES_H_INCLUDED +#include "oscl_scheduler_types.h" +#endif + +#ifndef OSCL_NAMESTRING_H_INCLUDED +#include "oscl_namestring.h" +#endif + +#ifndef OSCL_SCHEDULER_THREAD_CONTEXT_H_INCLUDED +#include "oscl_scheduler_threadcontext.h" +#endif + +#ifndef OSCL_SCHEDULER_READYQ_H_INCLUDED +#include "oscl_scheduler_readyq.h" +#endif + +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#include "oscl_string_containers.h" +#endif + +/* + * Macro for zeroizing the memory of a newly created object + * + * @param ptr pointer to the newly created object + * + * @param size size of the memory + */ + +#define OSCL_ZEROIZE(ptr, size) oscl_memset(ptr, 0, size) + +/* +** Max length for scheduler and AO names. +*/ +#define PVEXECNAMELEN 30 + +#if (PV_SCHED_ENABLE_AO_STATS) +/** PV AO statistics +*/ +class PVActiveStats +{ + private: + //should be constructed only when AO is added to scheduler. + PVActiveStats(OsclExecSchedulerCommonBase* aScheduler, const char* aAOName, PVActiveBase* aActiveBase); + ~PVActiveStats(); + + void Combine(PVActiveStats&); + + //Queue link for scheduler iPVStatQ + OsclDoubleLink iPVStatQLink; + + //this AO's scheduler + OsclExecSchedulerCommonBase* iScheduler; + //AO name + OSCL_HeapString iAOName; + //pointer to original container object. + PVActiveBase* iPVActiveBase; + + uint32 iNumRun;//how many Run calls + uint32 iNumRunError;//how many RunError calls + int32 iMaxTicksInRun;//max time in any one Run call + + uint32 iTotalTicksInRun; + + bool i64Valid;//use 64-bit stats instead of 32-bit + int64 i64TotalTicksInRun;//avg number of clock ticks per Run + + //for internal computation-- percent of total time in this Run + float iPercent; + + int32 iLeave;//last leave code from a Run call + uint32 iNumCancel;//how many DoCancel calls. + + uint32 iNumInstances;//number of scheduler instances of this AO. + int32 iPriority;//scheduler priority + + friend class PVActiveBase; + friend class OsclExecScheduler; + friend class OsclExecSchedulerCommonBase; + friend class OsclActiveObject; + friend class OsclTimerObject; + friend class OsclReadyQ; +}; +#endif //(PV_SCHED_ENABLE_AO_STATS) + + +/** + * PV Scheduler internal AO base class. Both OsclActiveObject + * and OsclTimerObject derive from this class. For Symbian, this + * just container has the desired additions to the basic CTimer or OsclActiveObj + * functionality. + * For non-Symbian, this class contains the entire AO implementation. + */ +class PVActiveBase +{ + public: + uint32 iAddedNum; + +//iStatus, AddToScheduler(), RemoveFromScheduler etc are needed in PVSchedulerStopper (which is publically derived from OsclActiveObject and OsclActiveObject is publically derived from PVActiveBase ) +//protected: + + PVActiveBase(const char name[], int32 pri); + + virtual ~PVActiveBase(); + + /* + ** Each AO has a name, to aid in statistics reporting and debugging. + */ + OsclNameString iName; + + /* + ** Each AO knows its thread context, including a pointer to the scheduler + ** that it is in. + */ + PVThreadContext iThreadContext; + +#if (PV_SCHED_ENABLE_AO_STATS) + /* + ** AO statistics + */ + PVActiveStats *iPVActiveStats; + friend class PVActiveStats; +#endif + + + /* + ** Non-Symbian AO implementation. + */ + + /* + ** Queue link for scheduler iExecTimerQ or iReadyQ. + */ + TReadyQueLink iPVReadyQLink; + + /* + ** Return true if this AO is in any queue. + */ + bool IsInAnyQ() + { + return(iPVReadyQLink.iIsIn != NULL); + } + + /* + ** The executing flag is set whenever a request is active (pending + ** or complete). The AO is de-activated by scheduler just before + ** calling the Run. + */ + bool iBusy; + + /** + The request status associated with an asynchronous request. + + This is passed as a parameter to all asynchronous service providers. + + The active scheduler uses this to check whether the active object's request + has completed. + + The function can use the completion code to judge the success or otherwise + of the request. + + Request status contains one of the values + OSCL_REQUEST_ERR_NONE: request completed with no error, + or request is not active. + OSCL_REQUEST_PENDING: request is active & pending + OSCL_REQUEST_ERR_CANCEL: request was canceled before completion. + or any user-defined value. + */ + OsclAOStatus iStatus; + + /** + * Virtual routine that gets called if the active object's + * Run routine leaves. + * @param aError: the leave code generated by the Run. + * @return :returns OsclErrNone if the error was handled, + * or returns the input aError value if not handled. + */ + virtual int32 RunError(int32 aError) = 0; + + /** + Handles an active object's request completion event. + + A derived class must provide an implementation to handle the + completed request. If appropriate, it may issue another request. + + The function is called by the active scheduler when a request + completion event occurs, i.e. after the active scheduler's + WaitForAnyRequest() function completes. + + Before calling this active object's Run() function, the active scheduler + has: + + 1. decided that this is the highest priority active object with + a completed request + + 2. marked this active object's request as complete (i.e. the request is no + longer outstanding) + + Run() runs under a trap harness in the active scheduler. If it leaves, + then the active scheduler calls ExecError() to handle the leave. + + Note that once the active scheduler's Start() function has been called, + all user code is run under one of the program's active object's Run() or + RunError() functions. + */ + virtual void Run() = 0; + + /** + Implements cancellation of an outstanding request. + + This function is called as part of the active object's Cancel(). + + It must call the appropriate cancel function offered by the active object's + asynchronous service provider. The asynchronous service provider's cancel + is expected to act immediately. + + DoCancel() must not wait for event completion; this is handled by Cancel(). + */ + virtual void DoCancel() = 0; + + /* + ** Common methods to support OsclActiveObject and OsclTimerObject APIs + */ + void AddToScheduler(); + void RemoveFromScheduler(); + void Destroy(); + void Activate(); + OSCL_IMPORT_REF bool IsAdded()const; + void Cancel(); + + friend class OsclSchedulerCommonBase; + friend class OsclActiveObject; + friend class OsclTimerObject; + friend class OsclReadyQ; + friend class OsclReadyCompare; + friend class OsclReadySetPosition; + friend class OsclExecScheduler; + +}; + +#endif + + + + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_readyq.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_readyq.cpp new file mode 100644 index 0000000..eb04392 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_readyq.cpp @@ -0,0 +1,415 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#include "oscl_scheduler_readyq.h" + + +#include "oscl_scheduler_ao.h" +#include "oscl_scheduler.h" +#include "oscl_tickcount.h" +#include "oscl_scheduler_tuneables.h" + +//////////////////////////////////////// +// Ready Queue & Timer Queue Support +//////////////////////////////////////// + +//scheduler has an allocator but there's no way to use +//it here since this allocator must be a template argument +//to oscl priority queue. +OsclAny* OsclReadyAlloc::allocate_fl(const uint32 size, const char * file_name, const int line_num) +{ + OsclAny*p = iBasicAlloc.allocate_fl(size, file_name, line_num); + OsclError::LeaveIfNull(p); + return p; +} +OsclAny* OsclReadyAlloc::allocate(const uint32 size) +{ + OsclAny*p = iBasicAlloc.ALLOCATE(size); + OsclError::LeaveIfNull(p); + return p; +} +void OsclReadyAlloc::deallocate(OsclAny* p) +{ + iBasicAlloc.deallocate(p); +} + +//evalute "priority of a is less than priority of b" +int OsclTimerCompare::compare(TOsclReady& a, TOsclReady& b) +{ + //Sort by time to run. Earlier "time to run" has precedence. + if (a->iPVReadyQLink.iTimeToRunTicks != b->iPVReadyQLink.iTimeToRunTicks) + { + //calculate a>b, taking possible rollover into account. + uint32 delta = b->iPVReadyQLink.iTimeToRunTicks - a->iPVReadyQLink.iTimeToRunTicks; + return (delta > OsclExecScheduler::iTimeCompareThreshold); + } + + //Now sort by priority + return OsclReadyCompare::compare(a, b); +} + +//evalute "priority of a is less than priority of b" +int OsclReadyCompare::compare(TOsclReady& a, TOsclReady& b) +{ + //Sort by AO priority. Higher priority has precedence. + if (a->iPVReadyQLink.iAOPriority != b->iPVReadyQLink.iAOPriority) + return (a->iPVReadyQLink.iAOPriority < b->iPVReadyQLink.iAOPriority); + + //if there was a priority tie, impose a FIFO order. + + //This section allows switching between "fair scheduling" and linear + //behavior. We always use fair scheduling, but for testing it can be helpful to + //swap in the linear behavior. +#if PV_SCHED_FAIR_SCHEDULING + //Sort by FIFO order, to create fair scheduling. + //AOs that have been queued the longest have precedence. + return (a->iPVReadyQLink.iSeqNum >= b->iPVReadyQLink.iSeqNum); +#else + //Sort by the order when AO was added to scheduler, to simulate + //Symbian native ActiveScheduler behavior. + //AOs that were added earlier have precedence. + return (a->iAddedNum > b->iAddedNum); +#endif + +} + +//////////////////////////////////////// +//OsclReadyQ +//////////////////////////////////////// +void OsclReadyQ::Construct(int nreserve) +{ + iSeqNumCounter = 0; + if (nreserve > 0) + c.reserve(nreserve); + iCallback = NULL; +} + +void OsclReadyQ::ThreadLogon() +{ + iSem.Create(); + iCrit.Create(); +} + +void OsclReadyQ::ThreadLogoff() +{ + iSem.Close(); + iCrit.Close(); +} + +// +//Note: all semaphore errors are fatal, since they can cause +// scheduler to spin or hang. +// + +PVActiveBase* OsclReadyQ::WaitAndPopTop() +//block until an AO is ready and pop the highest pri AO. +{ + switch (iSem.Wait()) + { + case OsclProcStatus::SUCCESS_ERROR: + return PopTopAfterWait(); + + default: + OsclError::Leave(OsclErrSystemCallFailed); + return NULL; + } +} + +PVActiveBase* OsclReadyQ::WaitAndPopTop(uint32 aTimeoutVal) +//block until an AO is ready or timeout is reached. +{ + switch (iSem.Wait(aTimeoutVal)) + { + case OsclProcStatus::WAIT_TIMEOUT_ERROR: + //timeout reached, no AO ready. + return NULL; + + case OsclProcStatus::SUCCESS_ERROR: + //an AO is ready-- pop it. + return PopTopAfterWait(); + + default: + //no timeout and no AO. + OsclError::Leave(OsclErrSystemCallFailed); + return NULL; + } +} + +bool OsclReadyQ::IsIn(TOsclReady b) +//tell if elemement is in this q +{ + iCrit.Lock(); + bool isin = (b->iPVReadyQLink.iIsIn == this); + iCrit.Unlock(); + return isin; +} + +PVActiveBase* OsclReadyQ::PopTop() +//deque and return highest pri element. +{ + iCrit.Lock(); + + PVActiveBase*elem = (size() > 0) ? top() : NULL; + if (elem) + { + elem->iPVReadyQLink.iIsIn = NULL; + + pop(); + + //this call won't block-- it will just decrement the sem. + if (iSem.Wait() != OsclProcStatus::SUCCESS_ERROR) + OsclError::Leave(OsclErrSystemCallFailed); + } + + iCrit.Unlock(); + return elem; +} + +PVActiveBase* OsclReadyQ::PopTopAfterWait() +//deque and return highest pri element. used when we have +//already done a sem wait prior to this call, so there is no sem +//decrement here. +{ + iCrit.Lock(); + + PVActiveBase*elem = (size() > 0) ? top() : NULL; + + if (elem) + { + elem->iPVReadyQLink.iIsIn = NULL; + pop(); + } + else + {//there should always be an element available after a sem wait. + OSCL_ASSERT(0); + } + + iCrit.Unlock(); + + return elem; +} + +PVActiveBase* OsclReadyQ::Top() +//return highest pri element without removing. +{ + iCrit.Lock(); + PVActiveBase* elem = (size() > 0) ? top() : NULL; + iCrit.Unlock(); + return elem; +} + +void OsclReadyQ::Remove(TOsclReady a) +//remove the given element +{ + iCrit.Lock(); + + a->iPVReadyQLink.iIsIn = NULL; + + int32 nfound = remove(a); + + if (nfound > 0) + { + //this call won't block-- it will just decrement the sem. + if (iSem.Wait() != OsclProcStatus::SUCCESS_ERROR) + OsclError::Leave(OsclErrSystemCallFailed); + } + + iCrit.Unlock(); +} + +int32 OsclReadyQ::PendComplete(PVActiveBase *pvbase, int32 aReason) +//Complete an AO request +{ + iCrit.Lock(); + + //make sure this AO is not already queued. + int32 err; + if (pvbase->IsInAnyQ()) + { + err = OsclErrInvalidState;//EExecAlreadyAdded + } + //make sure the AO has a request active + else if (!pvbase->iBusy + || pvbase->iStatus != OSCL_REQUEST_PENDING) + { + err = OsclErrCorrupt;//EExecStrayEvent; + } + else + { + //Add to pri queue + pvbase->iPVReadyQLink.iIsIn = this; + pvbase->iPVReadyQLink.iTimeQueuedTicks = OsclTickCount::TickCount(); + pvbase->iPVReadyQLink.iSeqNum = ++iSeqNumCounter;//for the FIFO sort + push(pvbase); + + //increment the sem + if (iSem.Signal() != OsclProcStatus::SUCCESS_ERROR) + { + err = OsclErrSystemCallFailed; + } + else + { + //update the AO status + pvbase->iStatus = aReason; + + //make scheduler callback if needed. + //note: this needs to happen under the lock since we're updating + //the callback pointer. + if (iCallback) + { + iCallback->OsclSchedulerReadyCallback(iCallbackContext); + iCallback = NULL; + } + err = OsclErrNone; + } + } + + iCrit.Unlock(); + return err; +} + +int32 OsclReadyQ::WaitForRequestComplete(PVActiveBase* pvbase) +//Wait on a particular request to complete +{ + int32 nwait = 0;//count the number of request sem waits. + + for (bool complete = false; !complete;) + { + //Wait on any request to complete. + if (iSem.Wait() != OsclProcStatus::SUCCESS_ERROR) + return OsclErrSystemCallFailed; + + nwait++; + + //Some request was complete but it might not be the one of interest, + //so check for completion again. + complete = IsIn(pvbase); + } + + //Restore the request semaphore value since we may have decremented it without + //removing anything from the ReadyQ. + while (nwait > 0) + { + if (iSem.Signal() != OsclProcStatus::SUCCESS_ERROR) + return OsclErrSystemCallFailed; + + nwait--; + } + + return OsclErrNone; +} + +void OsclReadyQ::RegisterForCallback(OsclSchedulerObserver* aCallback, OsclAny* aCallbackContext) +{ + //Use the Q lock to avoid thread contention over + //callback pointer. + iCrit.Lock(); + + //Callback right away if ready Q is non-empty. + if (size() && aCallback) + { + iCallback = NULL; + aCallback->OsclSchedulerReadyCallback(aCallbackContext); + } + else + { + //save the new pointers. Callback will happen when timer Q or ready Q is + //updated. + iCallback = aCallback; + iCallbackContext = aCallbackContext; + } + iCrit.Unlock(); +} + +void OsclReadyQ::TimerCallback(uint32 aDelayMicrosec) +//Inform scheduler observer of a change in the shortest timer interval +{ + //lock when updating callback pointer. + iCrit.Lock(); + OsclSchedulerObserver* callback = iCallback; + iCallback = NULL; + iCrit.Unlock(); + + //Timer callback happens outside the lock, to allow code + //to register for additional callback. + if (callback) + callback->OsclSchedulerTimerCallback(iCallbackContext, aDelayMicrosec / 1000); +} + +//////////////////////////////////////// +//OsclTimerQ +//////////////////////////////////////// +void OsclTimerQ::Construct(int nreserve) +{ + iSeqNumCounter = 0; + if (nreserve > 0) + c.reserve(nreserve); +} + +bool OsclTimerQ::IsIn(TOsclReady b) +//tell if element is in this q +{ + return (b->iPVReadyQLink.iIsIn == this); +} + +PVActiveBase* OsclTimerQ::PopTop() +//deque and return highest pri element. +{ + PVActiveBase*elem = (size() > 0) ? top() : NULL; + if (elem) + Pop(elem); + + return elem; +} + +PVActiveBase* OsclTimerQ::Top() +//return highest pri element without removing. +{ + return (size() > 0) ? top() : NULL; +} + +void OsclTimerQ::Pop(TOsclReady b) +//remove queue top. +{ + b->iPVReadyQLink.iIsIn = NULL; + pop(); +} + +void OsclTimerQ::Remove(TOsclReady a) +{ + a->iPVReadyQLink.iIsIn = NULL; + remove(a); +} + +void OsclTimerQ::Add(TOsclReady b) +{ + b->iPVReadyQLink.iIsIn = this; + b->iPVReadyQLink.iTimeQueuedTicks = OsclTickCount::TickCount(); + b->iPVReadyQLink.iSeqNum = ++iSeqNumCounter;//for the FIFO sort + + push(b); +} + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_readyq.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_readyq.h new file mode 100644 index 0000000..ccd5f64 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_readyq.h @@ -0,0 +1,188 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \addtogroup osclproc OSCL Proc + * + * @{ + */ + + + +/** \file oscl_scheduler_readyq.h + \brief ready q types for oscl scheduler +*/ + + +#ifndef OSCL_SCHEDULER_READYQ_H_INCLUDED +#define OSCL_SCHEDULER_READYQ_H_INCLUDED + +#ifndef OSCL_SCHEDULER_TYPES_H_INCLUDED +#include "oscl_scheduler_types.h" +#endif +#ifndef OSCL_SCHEDULER_TUNEABLES_H_INCLUDED +#include "oscl_scheduler_tuneables.h" +#endif + + +#ifndef OSCL_PRIQUEUE_H_INCLUDED +#include "oscl_priqueue.h" +#endif +#ifndef OSCL_BASE_ALLOC_H_INCLUDED +#include "oscl_base_alloc.h" +#endif +#ifndef OSCL_SEMAPHORE_H_INCLUDED +#include "oscl_semaphore.h" +#endif +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif +#ifndef OSCL_MUTEX_H_INCLUDED +#include "oscl_mutex.h" +#endif +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#include "oscl_string_containers.h" +#endif + +class PVActiveBase; + +class OsclReadyAlloc: public Oscl_DefAlloc +{ + public: + OsclAny* allocate(const uint32 size) ; + OsclAny* allocate_fl(const uint32 size, const char * file_name, const int line_num); + void deallocate(OsclAny* p) ; + private: + OsclMemAllocator iBasicAlloc; +}; + +typedef PVActiveBase* TOsclReady; + +class OsclReadyCompare +{ + public: + static int compare(TOsclReady& a, TOsclReady& b) ; +}; +class OsclTimerCompare +{ + public: + static int compare(TOsclReady& a, TOsclReady& b) ; +}; + +/** This is a thread-safe priority queue for holding the + active objects that are ready to run. + This queue also contains the request semaphore and the + queue observer callback logic. +*/ +class PVLogger; +class OsclSchedulerObserver; +class OsclReadyQ + : public OsclPriorityQueue, OsclReadyCompare> +{ + public: + void Construct(int); + void ThreadLogon(); + void ThreadLogoff(); + + void Remove(TOsclReady); + + bool IsIn(TOsclReady); + + uint32 Depth() + { + return size(); + } + + TOsclReady PopTop(); + TOsclReady Top(); + + TOsclReady WaitAndPopTop(); + TOsclReady WaitAndPopTop(uint32); + + int32 PendComplete(PVActiveBase *pvbase, int32 aReason); + int32 WaitForRequestComplete(PVActiveBase*); + + //For non-blocking scheduler observer support + void RegisterForCallback(OsclSchedulerObserver* aCallback, OsclAny* aCallbackContext); + void TimerCallback(uint32 aDelayMicrosec); + OsclSchedulerObserver* Callback() + { + return iCallback; + } + + private: + TOsclReady PopTopAfterWait(); + + //mutex for thread protection + OsclNoYieldMutex iCrit; + + //this semaphore tracks the queue size. it is used to + //regulate the scheduling loop when running in blocking mode. + OsclSemaphore iSem; + + //a sequence number needed to maintain FIFO sorting order in oscl pri queue. + uint32 iSeqNumCounter; + + //For non-blocking scheduler observer support + OsclSchedulerObserver* iCallback; + OsclAny* iCallbackContext; +}; + +/* +** A non-thread-safe queue for holding pending timers. +*/ +class OsclTimerQ + : public OsclPriorityQueue, OsclTimerCompare> +{ + public: + void Construct(int); + void Add(TOsclReady); + void Remove(TOsclReady); + TOsclReady PopTop(); + TOsclReady Top(); + void Pop(TOsclReady); + bool IsIn(TOsclReady); + private: + //a sequence number needed to maintain FIFO sorting order in oscl pri queue. + uint32 iSeqNumCounter; +}; + +/** This class defines the queue link, which is common to both ready Q and timer Q. + Each AO contains its own queue link object. +*/ +class TReadyQueLink +{ + public: + TReadyQueLink() + { + iAOPriority = 0; + iTimeToRunTicks = 0; + iSeqNum = 0; + iIsIn = NULL; + } + + int32 iAOPriority;//scheduling priority + uint32 iTimeToRunTicks;//for timers, this is the time to run in ticks. + uint32 iTimeQueuedTicks;//the time when the AO was queued, in ticks. + uint32 iSeqNum;//sequence number for oscl pri queue. + OsclAny* iIsIn;//pointer to the queue we're in, cast as a void* + +}; + +#endif + + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.cpp new file mode 100644 index 0000000..18adc93 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.cpp @@ -0,0 +1,127 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#include "osclconfig_proc.h" +#include "oscl_scheduler_threadcontext.h" +#include "oscl_scheduler.h" +#include "oscl_error.h" +#include "oscl_error_imp.h" +#include "oscl_thread.h" + +OSCL_EXPORT_REF PVThreadContext::PVThreadContext() +{ + iOpen = false; + iScheduler = NULL; +} + +OSCL_EXPORT_REF PVThreadContext::~PVThreadContext() +{ +} + +void PVThreadContext::LeaveIfWrongThread(PVThreadContext &a) +//static routine to verify thread context. +{ + if (!a.IsSameThreadContext()) + OsclError::Leave(OsclErrThreadContextIncorrect); +} + +OSCL_EXPORT_REF bool PVThreadContext::IsSameThreadContext() +{ + if (!iOpen) + return false;//unknown + + //check calling thread context against + //this one. + TOsclThreadId id; + int32 result = OsclThread::GetId(id); + if (result != OsclProcStatus::SUCCESS_ERROR) + OsclError::Leave(OsclErrSystemCallFailed); + + return OsclThread::CompareId(id, iThreadId); +} + +OSCL_EXPORT_REF void PVThreadContext::EnterThreadContext() +{ + //Save thread ID. + int32 result = OsclThread::GetId(iThreadId); + if (result != OsclProcStatus::SUCCESS_ERROR) + OsclError::Leave(OsclErrSystemCallFailed); + + + //Set current thread scheduler. + iScheduler = OsclExecScheduler::GetScheduler(); + + if (!iScheduler) + { + //There must be a pv scheduler. + OsclError::Leave(OsclErrNotInstalled); + } + + iOpen = true; +} + +OSCL_EXPORT_REF void PVThreadContext::ExitThreadContext() +{ + iScheduler = NULL; + iOpen = false; +} + +void PVThreadContext::PendComplete(PVActiveBase *pvbase, int32 aReason, TPVThreadContext aCallingContext) +{ + //request can be completed from any thread. + if (!iOpen) + OsclError::Leave(OsclErrInvalidState);//thread context unknown + //status can be anything but 'pending' + if (aReason == OSCL_REQUEST_PENDING) + OsclError::Leave(OsclErrInvalidState);//bad request status + + + //use PV scheduler mechanism to complete requests. + + //first determine the calling context if possible. + if (aCallingContext == EPVThreadContext_Undetermined && IsSameThreadContext()) + iScheduler->PendComplete(pvbase, aReason, EPVThreadContext_InThread); + else + iScheduler->PendComplete(pvbase, aReason, aCallingContext); + +} + +OSCL_EXPORT_REF uint32 PVThreadContext::Id() +//static routine to get current context. +{ + TOsclThreadId id; + int32 result = OsclThread::GetId(id); + if (result != OsclProcStatus::SUCCESS_ERROR) + OsclError::Leave(OsclErrSystemCallFailed); + return (uint32)id; +} + +/** +// a static utility to tell whether the calling +// thread has any scheduler-- either Oscl scheduler +// or native scheduler. +*/ +OSCL_EXPORT_REF bool PVThreadContext::ThreadHasScheduler() +{ + if (OsclExecScheduler::Current() != NULL) + return true; + return false; +} + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.h new file mode 100644 index 0000000..27b6900 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.h @@ -0,0 +1,133 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \addtogroup osclproc OSCL Proc + * + * @{ + */ + + + +/** \file oscl_scheduler_threadcontext.h + \brief Thread context functions needed by oscl scheduler. +*/ + +#ifndef OSCL_SCHEDULER_THREAD_CONTEXT_H_INCLUDED +#define OSCL_SCHEDULER_THREAD_CONTEXT_H_INCLUDED + +#ifndef OSCL_AOSTATUS_H_INCLUDED +#include "oscl_aostatus.h" +#endif + +#ifndef OSCL_DOUBLE_LIST_H_INCLUDED +#include "oscl_double_list.h" +#endif + +#ifndef OSCL_MUTEX_H_INCLUDED +#include "oscl_mutex.h" +#endif + +/** +//Thread context type +*/ +enum TPVThreadContext +{ + EPVThreadContext_InThread //context is in-thread + , EPVThreadContext_OsclThread //some other thread that has Oscl initialized + , EPVThreadContext_NonOsclThread //some thread that does not have Oscl initialized + , EPVThreadContext_Undetermined +}; + +/** +// +// Thread context class. +// +*/ +class OsclExecSchedulerCommonBase; +class PVActiveBase; +class OsclBrewThreadYield; +class PVThreadContext +{ + public: + + OSCL_IMPORT_REF PVThreadContext(); + OSCL_IMPORT_REF ~PVThreadContext(); + /** + //compare caller's thread context to this one. + */ + OSCL_IMPORT_REF bool IsSameThreadContext(); + + /** + //static routine to get a unique thread ID for + //caller's thread context. + */ + OSCL_IMPORT_REF static uint32 Id(); + + /** + //enter and exit thread context. + */ + OSCL_IMPORT_REF void EnterThreadContext(); + OSCL_IMPORT_REF void ExitThreadContext(); + + /** + // a static utility to tell whether the calling + // thread has any scheduler-- either Oscl scheduler + // or native scheduler. + */ + OSCL_IMPORT_REF static bool ThreadHasScheduler(); + + private: + + /** + //leave if caller's thread doesn't match + //given thread. + */ + static void LeaveIfWrongThread(PVThreadContext &a); + + + bool iOpen; + + /** + //complete & cancel requests for this thread context. + */ + void PendComplete(PVActiveBase*, int32 aReason, TPVThreadContext aCallingContext); + + + OsclExecSchedulerCommonBase *iScheduler; + + /** + //the thread ID is OS-specific. + */ + TOsclThreadId iThreadId; + + friend class PVActiveBase; + friend class OsclActiveObject; + friend class OsclTimerObject; + friend class OsclExecScheduler; + friend class OsclCoeActiveScheduler; + friend class OsclExecSchedulerCommonBase; + friend class OsclExecSchedulerBase; + friend class OsclCoeActiveSchedulerBase; +}; + + + + +#endif // + + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_tuneables.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_tuneables.h new file mode 100644 index 0000000..94edada --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_tuneables.h @@ -0,0 +1,149 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \addtogroup osclproc OSCL Proc + * + * @{ + */ + + + +/** \file oscl_scheduler_tuneables.h + \brief Tuneable settings for Oscl Scheduler +*/ + + +#ifndef OSCL_SCHEDULER_TUNEABLES_H_INCLUDED +#define OSCL_SCHEDULER_TUNEABLES_H_INCLUDED + +#include "osclconfig_proc.h" + +//Enable/disable scheduler stats gathering for Run times. +//This data gathering is fairly expensive so should only be used +//for debug and profiling. +#ifndef PV_SCHED_ENABLE_AO_STATS +//defaults for cases where the flag is not defined in the osclconfig_proc.h +#if (OSCL_RELEASE_BUILD) +//for release builds +#define PV_SCHED_ENABLE_AO_STATS 0 +#else +//for debug builds +#define PV_SCHED_ENABLE_AO_STATS 1 +#endif +#endif + +//Enable this to track time spent in scheduling loop in addition to Run times. +//This data gathering is fairly expensive so should only be used +//for debug and profiling. +#ifndef PV_SCHED_ENABLE_LOOP_STATS +//defaults for cases where the flag is not defined in the osclconfig_proc.h +#if (OSCL_RELEASE_BUILD) +//for release builds +#define PV_SCHED_ENABLE_LOOP_STATS 0 +#else +//for debug builds +#define PV_SCHED_ENABLE_LOOP_STATS 0 +#endif +#endif + +//Note: loop stats requires PV_SCHED_ENABLE_AO_STATS +#if(PV_SCHED_ENABLE_LOOP_STATS) && !(PV_SCHED_ENABLE_AO_STATS) +#error Invalid Config! +#endif + +//Enable this to do detailed logging for all Run calls. +//This logging is very expensive so should only be used +//for debug and profiling. +#ifndef PV_SCHED_ENABLE_PERF_LOGGING +//defaults for cases where the flag is not defined in the osclconfig_proc.h +#if (OSCL_RELEASE_BUILD) +//for release builds +#define PV_SCHED_ENABLE_PERF_LOGGING 0 +#else +//for debug builds +#define PV_SCHED_ENABLE_PERF_LOGGING 1 +#endif +#endif + +//Note: Perf logging requires PV_SCHED_ENABLE_AO_STATS +#if(PV_SCHED_ENABLE_PERF_LOGGING) && !(PV_SCHED_ENABLE_AO_STATS) +#error Invalid Config! +#endif + +//Enable/disable thread context checking here. Context checks are important during +//development but may be costly depending on the OS thread ID retrieval efficiency. +#if (OSCL_RELEASE_BUILD) +//for release builds +#define PV_SCHED_ENABLE_THREAD_CONTEXT_CHECKS 0 +#else +//for debug builds +#define PV_SCHED_ENABLE_THREAD_CONTEXT_CHECKS 1 +#endif + +//Set LOG_Q to 1 to enable extensive Queue logging for non-symbian scheduler. +//the code will log the entire queue every time any AO is added or removed, +//for both timer queue and ready queue. It is expensive so should be off in +//production code. +#define PV_SCHED_LOG_Q 0 + +//Set CHECK_Q to enable Q integrity checks. Should be off in production code. +#define PV_SCHED_CHECK_Q 0 + +//This allows switching between "fair scheduling" and Symbian native scheduler +//behavior in the non-symbian scheduler implementation. +//We always use fair scheduling, but for testing it can be helpful to +//swap in the symbian native behavior. +#define PV_SCHED_FAIR_SCHEDULING 1 + +//OSCL_PERF_SUMMARY_LOGGING is a master switch to configure scheduler +//for full performance data gathering with minimal summary logging at +//the end. The data gathering is fairly expensive so should only be +//used for profiling tests. The logging itself is fairly nonintrusive +//since it only happens at scheduler exit. +//------------------------------------ +// logger node: "OsclSchedulerPerfStats" +// instrumentation level: PVLOGMSG_INST_PROF +// logger level: PVLOGMSG_INFO +//------------------------------------ +#ifndef OSCL_PERF_SUMMARY_LOGGING +//defaults for cases where the flag is not defined in the osclconfig_proc.h +#if (OSCL_RELEASE_BUILD) +//release builds +#define OSCL_PERF_SUMMARY_LOGGING 0 +#else +//other debug builds +#define OSCL_PERF_SUMMARY_LOGGING 0 +#endif +#endif + +//Settings for minimal stats logging +#if(OSCL_PERF_SUMMARY_LOGGING) +//enable AO stats +#undef PV_SCHED_ENABLE_AO_STATS +#define PV_SCHED_ENABLE_AO_STATS 1 +//enable loop stats +#undef PV_SCHED_ENABLE_LOOP_STATS +#define PV_SCHED_ENABLE_LOOP_STATS 1 +//disable perf logging because it skews the results +#undef PV_SCHED_ENABLE_PERF_LOGGING +#define PV_SCHED_ENABLE_PERF_LOGGING 0 +#endif //OSCL_PERF_SUMMARY_LOGGING + +#endif + + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_types.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_types.h new file mode 100644 index 0000000..5d25451 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_scheduler_types.h @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*! \addtogroup osclproc OSCL Proc + * + * @{ + */ + + +/** \file oscl_scheduler_types.h + \brief Scheduler common types include file. +*/ + +/** This file defines the OsclExecBase, OsclTimerBase, and OsclExecSchedulerBase + classes. These are the base classes for PV AOs and PV Scheduler. + We want the PV exec objects to be usable with either a PV scheduler + or a non-PV native Symbian scheduler. We also want the PV scheduler to be + usable with non-PV exec objects. Therefore, the PV scheduler and AO classes + derived from Symbian classes on Symbian platforms. On non-Symbian platforms, + the PV classes derive from classes with a similar API to the Symbian classes. + */ + +#ifndef OSCL_SCHEDULER_TYPES_H_INCLUDED +#define OSCL_SCHEDULER_TYPES_H_INCLUDED + +#ifndef OSCLCONFIG_PROC_H_INCLUDED +#include "osclconfig_proc.h" +#endif + + +//Non-Symbian + +#ifndef OSCL_AOSTATUS_H_INCLUDED +#include "oscl_aostatus.h" +#endif + +#ifndef OSCL_HEAPBASE_H_INCLUDED +#include "oscl_heapbase.h" +#endif + + +/** OsclActiveSchedulerBase is the base for OsclExecScheduler. + The non-Symbian OsclActiveSchedulerBase class is functionally similar to + a subset of Symbian CActiveScheduler class. +*/ +class OsclExecSchedulerBase : public _OsclHeapBase +{ + private: + virtual void Error(int32 anError) const; + virtual void OnStarting(); + virtual void OnStopping(); + OsclExecSchedulerBase(); + ~OsclExecSchedulerBase(); + friend class OsclExecScheduler; + friend class OsclCoeActiveScheduler; + friend class PVActiveBase; +}; + + + + +#endif // + + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_semaphore.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_semaphore.cpp new file mode 100644 index 0000000..db33e51 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_semaphore.cpp @@ -0,0 +1,268 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + + +// OSCL_S E M A P H O R E (S E M A P H O R E I M P L E M E N T A T I O N) + + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \file oscl_semaphore.cpp .This file provides SEMAPHORE implementation that can be ported +to three OS LINUX, SYMBIAN, WIN32 +*/ + +// Implementation file for OSCL Semaphores +#include "oscl_semaphore.h" +#include "oscl_assert.h" + + + +// Class contructor +OSCL_EXPORT_REF OsclSemaphore::OsclSemaphore() +{ + bCreated = false; +} + +OSCL_EXPORT_REF OsclSemaphore::~OsclSemaphore() +{ + //make sure it was closed + + OSCL_ASSERT(!bCreated); + +} + + +/** + * Creates the Semaphore + * + * @param Intialcount & Maximum count + * + * @return Returns the Error whether it is success or failure. + * Incase of failure it will return what is the specific error + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclSemaphore::Create(uint32 InitialCount) +{ + if (bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + + iCount = InitialCount; + if (pthread_cond_init(&ObjCondition, NULL) == 0 + && pthread_mutex_init(&ObjMutex, NULL) == 0) + { + bCreated = true; + return OsclProcStatus::SUCCESS_ERROR; + } + return OsclProcStatus::OTHER_ERROR; + +} + + +/** + * Closes the Semaphore + * + * @param It wont take any parameters + * + * @return Returns the Error whether it is success or failure. + * Incase of failure it will return what is the specific error + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclSemaphore::Close(void) +{ + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + bCreated = false; + return OsclProcStatus::SUCCESS_ERROR; + +} + + + +/** + * Waits for access to the Semaphore + * + * @param It wont take any parameters + * + * @return Returns the Error whether it is success or failure + * Incase of failure it will return what is the specific error + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclSemaphore::Wait() +{ + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + + int res = pthread_mutex_lock(&ObjMutex); + if (res != 0) + return OsclProcStatus::OTHER_ERROR; + while (iCount == 0 && res == 0) + { // wait till the semaphore is signaled + // or an error has occurred + res = pthread_cond_wait(&ObjCondition, &ObjMutex); + } + if (res == 0) + { // signaled + iCount--; + } + pthread_mutex_unlock(&ObjMutex); + if (res != 0) + { // error occurred + // invalid condition or mutex + return OsclProcStatus::OTHER_ERROR; + } + return OsclProcStatus::SUCCESS_ERROR; + +} + +#include "osclconfig_time.h" +static void getAbsTime(struct timespec &abs, uint32 timeout_msec) +{ + //convert timeout msec to sec + usec. + uint32 timeout_sec = timeout_msec / 1000; + uint32 timeout_usec = (timeout_msec % 1000) * 1000; + + //compute target time = time now plus timeout. + + struct timeval timenow; + gettimeofday(&timenow, NULL); + + uint32 targ_sec = timenow.tv_sec + timeout_sec; + uint32 targ_usec = timenow.tv_usec + timeout_usec; + while (targ_usec >= 1000000) + { + targ_sec++; + targ_usec -= 1000000; + } + + //convert target time to timespec. + abs.tv_sec = targ_sec; + abs.tv_nsec = targ_usec * 1000; +} + +/** + * Makes the thread to wait on the Semaphore, with a timeout. + * + * @param timeout in milliseconds. + * + * @return Returns WAIT_TIMEOUT_ERROR if the timeout expires, + * SUCCESS_ERROR if the semaphore is obtained, or in + * case of failure it will return what is the specific error + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclSemaphore::Wait(uint32 timeout_msec) +{ + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + + int res = pthread_mutex_lock(&ObjMutex); + if (res != 0) + return OsclProcStatus::OTHER_ERROR; + if (iCount > 0) + { + iCount--; + pthread_mutex_unlock(&ObjMutex); + return OsclProcStatus::SUCCESS_ERROR; + } + + struct timespec abs; + getAbsTime(abs, timeout_msec); + + while ((iCount == 0) && (res == 0)) + { // wait till semaphore is signaled + // or time runs out + res = pthread_cond_timedwait(&ObjCondition, &ObjMutex, &abs); + } + if (res == 0) + { // signalied + iCount--; + } + pthread_mutex_unlock(&ObjMutex); + if (res == ETIMEDOUT) + { // timeour occurred + return OsclProcStatus::WAIT_TIMEOUT_ERROR; + } + else if (res != 0) + { // error occurred + return OsclProcStatus::OTHER_ERROR; + } + return OsclProcStatus::SUCCESS_ERROR; + +} + +/** + * Try to acquire semaphore, if the semaphore is already acquired by another thread, + * calling thread immediately returns with out blocking + * + * @param It wont take any parameters + * + * @return Returns the Error whether it is success or failure + * Incase of failure it will return what is the specific error + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclSemaphore::TryWait() +{ + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + + int res = pthread_mutex_lock(&ObjMutex); + if (res != 0) + return OsclProcStatus::OTHER_ERROR; + if (iCount > 0) + {//take it + iCount--; + pthread_mutex_unlock(&ObjMutex); + return OsclProcStatus::SUCCESS_ERROR; + } + else + {//can't take it now so don't block. + pthread_mutex_unlock(&ObjMutex); + return OsclProcStatus::SEM_NOT_SIGNALED_ERROR; + } + +} + + +/** + * Signals that the thread is finished with the Semaphore + * + * @param It wont take any parameters + * + * @return Returns the Error whether it is success or failure + * Incase of failure it will return what is the specific error + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclSemaphore::Signal() +{ + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + + int res = pthread_mutex_lock(&ObjMutex); + if (res != 0) + return OsclProcStatus::OTHER_ERROR; + iCount++; + res = pthread_cond_signal(&ObjCondition); + pthread_mutex_unlock(&ObjMutex); + if (res != 0) + return OsclProcStatus::OTHER_ERROR; + return OsclProcStatus::SUCCESS_ERROR; + + +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_semaphore.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_semaphore.h new file mode 100644 index 0000000..3cdd2d6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_semaphore.h @@ -0,0 +1,146 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S E M A P H O R E + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/** + * @file oscl_semaphore.h + * @brief This file provides implementation of mutex + * + */ + +// Definition file for OSCL Semaphore +#ifndef OSCL_SEMAPHORE_H_INCLUDED +#define OSCL_SEMAPHORE_H_INCLUDED + +#ifndef OSCLCONFIG_PROC_H_INCLUDED +#include "osclconfig_proc.h" +#endif + +#ifndef OSCL_THREAD_H_INCLUDED +#include "oscl_thread.h" +#endif + + +/** + * Class Semaphore + */ +class OsclSemaphore +{ + public: + + /** + * Class constructor + */ + OSCL_IMPORT_REF OsclSemaphore(); + + /** + * Class destructor + */ + OSCL_IMPORT_REF ~OsclSemaphore(); + + /** + * Creates the Semaphore + * + * @param Intialcount + * + * @return Returns the Error whether it is success or failure + *incase of failure it will return what is the specific error + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Create(uint32 initVal = 0); + + /** + * Closes the Semaphore + * + * @param It wont take any parameters + * + * @return Returns the Error whether it is success or failure + *incase of failure it will return what is the specific error + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Close(); + + /** + * Makes the thread to wait on the Semaphore + * + * @param It wont take any parameters + * + * @return Returns the Error whether it is success or failure + *incase of failure it will return what is the specific error + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Wait(); + + /** + * Makes the thread to wait on the Semaphore, with a timeout. + * + * @param timeout in milliseconds. + * + * @return Returns SUCCESS_ERROR if the semaphore was aquired, + * WAIT_TIMEOUT_ERROR if the timeout expired without acquiring the + * semaphore, or an error code if the operation failed. + * Note: this function may not be supported on all platforms, and + * may return NOT_IMPLEMENTED. + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Wait(uint32 timeout_msec); + + /** + * Try to acquire semaphore ,if the semaphore is already acquired by another thread, + * calling thread immediately returns with out blocking + * + * @param It wont take any parameters + * + * @return Returns SUCCESS_ERROR if the semaphore was acquired, + * SEM_LOCKED_ERROR if the semaphore cannot be acquired without waiting, + * or an error code if the operation failed. + * Note: this function may not be supported on all platforms, and + * may return NOT_IMPLEMENTED. + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError TryWait(); + + /** + * Signals that the thread is finished with the Semaphore + * + * @param It wont take any parameters + * + * @return Returns the Error whether it is success or failure + *incase of failure it will return what is the specific error + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Signal(); + + private: + + + + bool bCreated; + //for pthreads implementations without sem timedwait support. + TOsclMutexObject ObjMutex; + TOsclConditionObject ObjCondition; + uint32 iCount; + + +}; + + + + + +#endif // END OF File + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_thread.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_thread.cpp new file mode 100644 index 0000000..2814859 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_thread.cpp @@ -0,0 +1,476 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// OSCL_T H R E A D (T H R E A D I M P L E M E N T A T I O N) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \file oscl_thread.cpp .This file provides THREAD implementation that can be ported +to three OS LINUX, SYMBIAN, WIN32 +*/ + + + +// Implementation file for OSCL threads +#include "oscl_thread.h" + + + +/* + * Class contructor + */ +OSCL_EXPORT_REF OsclThread::OsclThread() +{ + bCreated = false; + bJoinable = false; +} + + + +/* + * Class destructor + */ +OSCL_EXPORT_REF OsclThread::~OsclThread() +{ + + ; + +} + + +/** + * OSCL Proc layer function + * Input Argument: + * function_name = Name of the thread Function + * stack_size = Size of the thread stack + * argument = Argument to be passed to thread function + * Thread_State = Enumeration which specifies the state of the thread on creation + * with values Running and Suspend + * Return value : eOsclProcError + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclThread::Create(TOsclThreadFuncPtr function_name, + int32 stack_size, + TOsclThreadFuncArg argument, + OsclThread_State state, + bool oIsJoinable) +{ + if (stack_size < 0) + return OsclProcStatus::INVALID_PARAM_ERROR; + + if (function_name == NULL) + return OsclProcStatus::INVALID_PARAM_ERROR; + + + //Reset thread creation state, since the thread may + //have exited. + if (bCreated) + bCreated = false; + + + switch (state) + { + case Start_on_creation: + break; + case Suspend_on_creation: + //can't create suspended pthread. + return OsclProcStatus::INVALID_PARAM_ERROR; + } + pthread_attr_t attr; + pthread_attr_init(&attr); + if (stack_size != 0) + pthread_attr_setstacksize(&attr, stack_size); + + // Default detachstate attribute to PTHREAD_CREATE_DETACHED state + int detach_ret; + if (oIsJoinable) + { + detach_ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + bJoinable = true; + } + else + { + detach_ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + bJoinable = false; + } + switch (detach_ret) + { + case 0: // successful, continue thread creation + break; + case EINVAL: + default: + return OsclProcStatus::PSHARED_ATTRIBUTE_SETTING_ERROR; + } + + int result = pthread_create( + (pthread_t*) & ObjThread, + &attr, + function_name, + (void*)argument); + + switch (result) + { + case 0: + bCreated = true; + return OsclProcStatus::SUCCESS_ERROR; + case EAGAIN: + return OsclProcStatus::NOT_ENOUGH_RESOURCES_ERROR; + default: + return OsclProcStatus::OTHER_ERROR; + } + + +} + + +/** + * OSCL Proc layer function + * ExitThread is a static function which is used to end the current thread. When called it + * just ends the execution of the current thread. + * Input Argument: + * exitcode = Exitcode of the thread. This can be used by other threads to know the + * exit status of this thread. + * Return value : None +*/ +OSCL_EXPORT_REF void OsclThread::Exit(OsclAny* exitcode) +{ + //intentionally not implemented. + OSCL_UNUSED_ARG(exitcode); + +} + + +/** + * OSCL Proc layer function + * Suspend current thread execution for specified time. + * @param msec, t2: sleep time in milliseconds. + */ +OSCL_EXPORT_REF void OsclThread::SleepMillisec(const int32 msec) +{ + struct timespec reqt, remt; + reqt.tv_sec = msec / 1000; + reqt.tv_nsec = 1000000 * (msec % 1000); + nanosleep(&reqt, &remt) ; + + +} + +OSCL_EXPORT_REF TOsclThreadTerminate OsclThread::CanTerminate() +{ + + return (bJoinable) ? EOsclThreadTerminate_Join : EOsclThreadTerminate_NOP; + +} + + +/** + + * OSCL Proc layer function + + * This is used to terminate a thread other than the current thread. + + * Input Argument: + + * exitcode = Exitcode of the thread. This can be used by other threads to know the + + * exit status of this thread. + + * Return value : Error code + + */ + +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclThread::Terminate(OsclAny* oscl_ExitCode) +{ + + + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + { + OSCL_UNUSED_ARG(oscl_ExitCode); + + bCreated = false; + if (bJoinable) + { + if (pthread_join(ObjThread, NULL) == 0) + { + return OsclProcStatus::SUCCESS_ERROR; + } + else + { + return OsclProcStatus::OTHER_ERROR; + } + } + return OsclProcStatus::NOT_IMPLEMENTED; + } + +} + + + + + + + +/** + + * OSCL Proc layer function + + * This API suspends the thread being referred. The thread can later be brought into execution + + * by calling OSCL_ResumeThread() on it. + + * Input Argument: None + + * Return value : Error code + + */ + +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclThread::Suspend() + +{ + + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + + + + { + //pthread doesn't support suspend/resume + return OsclProcStatus::NOT_IMPLEMENTED; + + } + + + +} + + + + + + + +/** + + * OSCL Proc layer function + + * ResumeThread resumes the suspended thread and brings it into execution. + + * Input Argument: None + + * Return value : Error code + + */ + +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclThread::Resume() + +{ + + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + + + + { + + //pthread doesn't support suspend/resume + return OsclProcStatus::NOT_IMPLEMENTED; + + } + + + +} + + + + + +/** + + * OSCL Proc layer function + + * GetThreadPriority gets the priority of the thread. It takes reference of the input argument + + * and assigns priority to it from one of the already defined priorities. + + * Input Argument: + + * int16& refThreadPriority : Output Priority value + + * Return value : Error code + + */ + +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclThread::GetPriority(OsclThreadPriority& refThreadPriority) + +{ + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + struct sched_param schedparam; + int sched_policy = 0; + int pri; + int result; + result = pthread_getschedparam(ObjThread, &sched_policy, &schedparam); + if (result != 0) + { + switch (result) + { + case ESRCH: + return OsclProcStatus::INVALID_THREAD_ERROR; + case EFAULT: + return OsclProcStatus::INVALID_PARAM_ERROR; + default: + return OsclProcStatus::OTHER_ERROR; + } + } + + pri = schedparam.sched_priority; + + switch (sched_policy) + { + case SCHED_RR: + case SCHED_FIFO: + { + //static priority is 1..99 + if (pri < 1) + return OsclProcStatus::OTHER_ERROR; + else if (pri == 1) + refThreadPriority = ThreadPriorityLowest; + else if (pri <= 20) + refThreadPriority = ThreadPriorityLow; + else if (pri <= 40) + refThreadPriority = ThreadPriorityBelowNormal; + else if (pri <= 55) + refThreadPriority = ThreadPriorityNormal; + else if (pri <= 75) + refThreadPriority = ThreadPriorityAboveNormal; + else if (pri <= 98) + refThreadPriority = ThreadPriorityHighest; + else if (pri == 99) + refThreadPriority = ThreadPriorityTimeCritical; + else if (pri > 99) + return OsclProcStatus::OTHER_ERROR; + return OsclProcStatus::SUCCESS_ERROR; + } + break; + + case SCHED_OTHER: + { + //static priority is always zero. + if (pri != 0) + return OsclProcStatus::OTHER_ERROR; + refThreadPriority = ThreadPriorityNormal; + return OsclProcStatus::SUCCESS_ERROR; + } + break; + + default: + return OsclProcStatus::OTHER_ERROR; + } +} + + + +/** + * OSCL Proc layer function + * SetThreadPriority sets the priority of the thread. It takes priority as the input argument + * and assigns it to the thread referred. + * Input Argument: + * ePriorityLevel : Input Priority value + * Return value : Error code + */ +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclThread::SetPriority(OsclThreadPriority ePriority) +{ + if (!bCreated) + return OsclProcStatus::INVALID_OPERATION_ERROR; + + //not supported. + OSCL_UNUSED_ARG(ePriority); + return OsclProcStatus::NOT_IMPLEMENTED; + + + +} + + + +/** + + * OSCL Proc layer function + + * This is used to compare whether the thread ID's are equal. + + * @param Thread ID passed by the application + + * @return Error code + + */ + +OSCL_EXPORT_REF OsclProcStatus::eOsclProcError OsclThread::GetId(TOsclThreadId& refThreadId) + +{ + + + + + refThreadId = pthread_self(); + + return OsclProcStatus::SUCCESS_ERROR; + + + + +} + + +OSCL_EXPORT_REF bool OsclThread::CompareId(TOsclThreadId &t1, TOsclThreadId &t2) +//static routine +{ + return (pthread_equal(t1, t2) != 0); +} + + + + + + +/** + + * Helper Function + + * Map the Operating system errors to OSCL defined erros + + * Input Argument: + + * error : Input error as one of the OS errors + + * Return value : Error code ( User defined ) + + */ + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_thread.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_thread.h new file mode 100644 index 0000000..88127d1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_thread.h @@ -0,0 +1,243 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// OSCL_T H R E A D (T H R E A D I M P L E M E N T A T I O N) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \file oscl_thread.h .This file provides THREAD implementation that can be ported +to three OS LINUX, SYMBIAN, WIN32 +*/ + + +// Definition file for OSCL Threads +#ifndef OSCL_THREAD_H_INCLUDED +#define OSCL_THREAD_H_INCLUDED + +#ifndef OSCLCONFIG_PROC_H_INCLUDED +#include "osclconfig_proc.h" +#endif + +#ifndef OSCL_PROCSTATUS_H_INCLUDED +#include "oscl_procstatus.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + + +// Thread state on creation +enum OsclThread_State +{ + Start_on_creation + , Suspend_on_creation +}; + +// Enumerated Priority Values +enum OsclThreadPriority +{ + ThreadPriorityLowest + , ThreadPriorityLow + , ThreadPriorityBelowNormal + , ThreadPriorityNormal + , ThreadPriorityAboveNormal + , ThreadPriorityHighest + , ThreadPriorityTimeCritical +}; + +// Thread termiante options +enum TOsclThreadTerminate +{ + EOsclThreadTerminate_Join, + EOsclThreadTerminate_Kill, + EOsclThreadTerminate_NOP +}; + + +//thread function pointer type. +typedef TOsclThreadFuncRet(OSCL_THREAD_DECL *TOsclThreadFuncPtr)(TOsclThreadFuncArg); + +/** + * Thread Class. A subset of Thread APIs. + * It implements platform independendent APIs for thread creation, exiting, suspend, resume, priority + * and termination. With the use of proper defines it implements the basic thread festures. + * It provides an opaque layer through which user doesn't need to worry about OS specific data. + */ +class OsclThread +{ + + public: + + /** + * Class constructor + */ + OSCL_IMPORT_REF OsclThread(); + + /** + * Class destructor + */ + OSCL_IMPORT_REF ~OsclThread(); + + /** + * This routine will create a thread. The thread may be + * launched immediately or may be created in a suspended + * state and launched with a Resume call. + * + * @param + * func = Name of the thread Function + * stack_size = Size of the thread stack. If zero, then the + * platform-specific default stack size will be used. + * argument = Argument to be passed to thread function + * state = Enumeration which specifies the state of the thread on creation + * with values Running and Suspend. Note: the Suspend option + * may not be available on all platforms. If it is not supported, + * the Create call will return INVALID_PARAM_ERROR. + * oIsJoinable = A boolean, which when set to true, creates a Joinable thread. + * The default value for this is false, which creates a + * Detached thread. + * Note 1: When a joinable thread is created, it is imperative + * to call thread Terminate. Otherwise, it would cause + * a memory leak. + * Note 2: This is currently available only for platforms that + * have support for pthreads. + * @return eOsclProcError + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Create(TOsclThreadFuncPtr func, + int32 stack_size, + TOsclThreadFuncArg argument, + OsclThread_State state = Start_on_creation, + bool oIsJoinable = false); + + /** + * Exit is a static function which is used to end the current thread. When called it + * just ends the execution of the current thread. + * Note: on some platforms this may be a NOP. + * @param + * exitcode = Exitcode of the thread. This can be used by other threads to know the + * exit status of this thread. + * @return None + */ + OSCL_IMPORT_REF static void Exit(OsclAny* exitcode); + + /** + * GetThreadPriority gets the priority of the thread. It takes reference of the input argument + * and assigns priority to it from one of the already defined priorities. + * @param + * int16& refThreadPriority : Output Priority value + * @return Error code + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError GetPriority(OsclThreadPriority& refThreadPriority); + + /** + * SetThreadPriority sets the priority of the thread. It takes priority as the input argument + * and assigns it to the thread referred. + * @param + * ePriorityLevel : Input Priority value + * @return Error code + * Note: this function may not be supported on all platforms, and + * may return NOT_IMPLEMENTED. + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError SetPriority(OsclThreadPriority ePriority); + + /** + * This API suspends the thread being referred. The thread can later be brought into execution + * by calling OSCL_ResumeThread() on it. + * @param None + * @return Error code + * Note: this function may not be supported on all platforms, and + * may return NOT_IMPLEMENTED. + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Suspend(); + + /** + * ResumeThread resumes the suspended thread and brings it into execution. + * @param None + * @return Error code + * Note: this function may not be supported on all platforms, and + * may return NOT_IMPLEMENTED. + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Resume(); + + /** + * Terminate a thread other than the calling thread. + * + * This API may have multiple behaviors. It may do a hard kill, + * a "join" operation, or a do-nothing. Caller can use CanTerminate + * option to tell the behavior in advance. + * + * @param + * exitcode = Exitcode of the thread. + * @return Error code + */ + OSCL_IMPORT_REF OsclProcStatus::eOsclProcError Terminate(OsclAny* exitcode); + + /** + * Tell if thread terminate will do join, immediate hard kill, or NOP. + * @return Terminate behavior. + */ + OSCL_IMPORT_REF TOsclThreadTerminate CanTerminate(); + + + /** + * Static routine to retrieve ID of calling thread. + * @param Thread ID passed by the application + * @return Error code + */ + OSCL_IMPORT_REF static OsclProcStatus::eOsclProcError GetId(TOsclThreadId& refThreadId); + + /** + * Static routine to compare whether two thread ID's are equal. + * @param t1, t2: thread ID passed by the application + * @return true if equal. + */ + OSCL_IMPORT_REF static bool CompareId(TOsclThreadId &t1, TOsclThreadId &t2); + + /** + * Suspend current thread execution for specified time. + * @param msec, t2: sleep time in milliseconds. + */ + OSCL_IMPORT_REF static void SleepMillisec(const int32 msec); + + private: + + /** + * Helper Function + * Map the Operating system errors to OSCL defined erros + * @param + * error : Input error as one of the OS errors + * @return Error code ( User defined ) + */ + OsclProcStatus::eOsclProcError MapOsclError(int16 error); + + + TOsclMutexObject mutex; + TOsclConditionObject condition; + uint8 suspend; + bool bJoinable; + + + + TOsclThreadObject ObjThread; + bool bCreated; +}; + +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_timer.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_timer.cpp new file mode 100644 index 0000000..03c2a86 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_timer.cpp @@ -0,0 +1,20 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +//#include "oscl_timer.h" + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_timer.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_timer.h new file mode 100644 index 0000000..c33cb64 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_timer.h @@ -0,0 +1,445 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#ifndef OSCL_TIMER_H_INCLUDED +#define OSCL_TIMER_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCLCONFIG_UTIL_H_INCLUDED +#include "osclconfig_util.h" +#endif + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +#ifndef OSCL_TICKCOUNT_H_INCLUDED +#include "oscl_tickcount.h" +#endif + +#ifndef OSCL_RAND_H_INCLUDED +#include "oscl_rand.h" +#endif + +#ifndef OSCL_SCHEDULER_AO_H_INCLUDED +#include "oscl_scheduler_ao.h" +#endif + + +/** + * The observer class to receive timeout callbacks + */ +class OsclTimerObserver +{ + public: + /** + * This function will be called when the timer associated + * with this observer is executed + * + * @param timerID The ID given at timer request. + * @param timeoutInfo + * Any extra info given at timer request. + */ + virtual void TimeoutOccurred(int32 timerID, int32 timeoutInfo) = 0; + + virtual ~OsclTimerObserver() {} +}; + +/** + * A timer class for scheduling one or more timeout events. + * The timeout event will trigger a callback to an observer + * class. + */ +template +class OsclTimer ; + +class CallbackTimerObserver +{ + public: + virtual void TimerBaseElapsed() = 0; + virtual ~CallbackTimerObserver() {} +}; + +template +class CallbackTimer: public OsclTimerObject +{ + public: + CallbackTimer(CallbackTimerObserver& aContainer, const char *name, int32 aPriority = OsclActiveObject::EPriorityNominal) + : OsclTimerObject(aPriority, name) + { + iContainer = &aContainer; + AddToScheduler(); + } + ~CallbackTimer() + { + RemoveFromScheduler(); + } + void Run() + { + if (Status() == OSCL_REQUEST_ERR_NONE) + iContainer->TimerBaseElapsed(); + } + private: + CallbackTimerObserver *iContainer; +}; + + +template +class OsclTimer : public CallbackTimerObserver +{ + public: + + typedef CallbackTimer callback_timer_type; + + /** + * Constructor + * + * @param frequency The frequency of the timer in cycles/second. A value of + * 1 means the timer will cycle in 1 second intervals. + */ + OsclTimer(const char *name, uint32 frequency = 1, int32 priority = OsclActiveObject::EPriorityNominal); + virtual ~OsclTimer(); + + /** + * Set the global observer. Each timer can request a local + * observer, which if set overrides the global observer. + * + * @param obs observer object. + */ + void SetObserver(OsclTimerObserver *obs) + { + iObserver = obs; + } + /** + * Set the frequency of the timer in cycles/second. + * + * @param frequency A value of 1 means the timer will cycle in one second + * intervals, 1000 means millisecond intervals, etc. + */ + void SetFrequency(uint32 frequency); + + /** + * Set the exact frequency of the timer in microsecond. + * + * @param frequency A value of 1 means the timer will cycle in one microsecond + * intervals, 1000 means millisecond intervals, etc. + */ + void SetExactFrequency(uint32 frequency); + + /** + * Request a timer + * + * @param timerID used to identify the timer for cancellation. This value + * will be returned as part of the timeout event. + * @param timeoutInfo + * for user info. Returned to the observer on a timeout event + * @param cycles the number of cycles to wait before a timeout event. If + * the timer frequency is 1 and the cycles are set to 2, then + * the timeout event will occur in 2 seconds. + * @param obs a local observer object to be called on a timeout event. + * This observer overides the global observer if set. + */ + void Request(int32 timerID, int32 timeoutInfo, int32 cycles, OsclTimerObserver *obs = 0, bool recurring = 0); + /** + * Cancel a timer + * + * @param timerID used to identify the timer to cancel. + * @param timeoutInfo + * if not set to -1, this value will be used as additional + * matching criteria to cancel a timer. + */ + void Cancel(int32 timerID, int32 timeoutInfo = -1); + /** + * Cancel all pending timers. + */ + void Clear(); + + private: + //Note: the timer needs to be a new'd object so that + //the CBase construction zeros the memory. + callback_timer_type *iTimer; + + typedef struct _TimerEntry + { + int32 iCounter ; + int32 iTimerID ; + int32 iParam ; + OsclTimerObserver *iObserver; + bool iRecurring; + int32 iOrigCounter; + } TimerEntry; + + typedef TimerEntry entry_type; + typedef Oscl_Vector entries_type; + typedef typename entries_type::iterator entries_type_iterator; + + OsclTimerObserver *iObserver; + entries_type iEntries; + entries_type iEntriesWaitingToAdd; + entries_type iEntriesWaitingToCancel; + Oscl_TAlloc iEntryAllocator; + + bool iInCallback; + + uint32 iCyclePeriod; + uint32 iTickCountPeriod; + uint32 iExpectedTimeout; + + protected: + void TimerBaseElapsed(); + friend class CallbackTimer; +}; + +template +OsclTimer::OsclTimer(const char *name, uint32 frequency, int32 priority) : + iObserver(0) + , iInCallback(false) + , iTickCountPeriod(0) + , iExpectedTimeout(0) +{ + if (frequency == 0) + { + OSCL_LEAVE(OsclErrArgument); + } + else + { + //use the allocator with placement 'new' + Alloc alloc; + iTimer = OSCL_PLACEMENT_NEW(alloc.ALLOCATE(sizeof(CallbackTimer)), CallbackTimer(*this, name, priority)); + SetFrequency(frequency); + } +} + +template +OsclTimer::~OsclTimer() +{ + // Make sure we're cancelled + if (iTimer) + iTimer->Cancel(); + if (iTimer) + { + iTimer->OSCL_TEMPLATED_DESTRUCTOR_CALL(callback_timer_type, CallbackTimer); + Alloc alloc; + alloc.deallocate(iTimer); + } + iTimer = NULL; + + for (entries_type_iterator it = iEntries.begin(); it != iEntries.end(); it++) + { + iEntryAllocator.deallocate(*it); + } +} + +template +void OsclTimer::SetFrequency(uint32 frequency) +{ + // timer takes microseconds + iCyclePeriod = 1000000 / frequency; + // get tick count period + iTickCountPeriod = OsclTickCount::TickCountPeriod(); +} + +template +void OsclTimer::SetExactFrequency(uint32 frequency) +{ + // timer takes microseconds + iCyclePeriod = frequency; + // get tick count period + iTickCountPeriod = OsclTickCount::TickCountPeriod(); +} + +// Request a timer +template +void OsclTimer::Request(int32 timerID, int32 param, int32 cycles, OsclTimerObserver *obs, bool recurring) +{ + + // add to list of timers + entry_type *entry = iEntryAllocator.ALLOCATE(1); + entry->iTimerID = timerID; + entry->iParam = param; + entry->iCounter = cycles; + entry->iObserver = obs; + entry->iRecurring = recurring; + entry->iOrigCounter = entry->iCounter; + + // if the request is called inside of a callback, then we must add it later + if (iInCallback) + { + iEntriesWaitingToAdd.push_back(entry); + return; + } + + iEntries.push_back(entry); + + if (iTimer) + { + iTimer->RunIfNotReady(iCyclePeriod); + } + + if (iExpectedTimeout == 0) + { + iExpectedTimeout = (OsclTickCount::TickCount() * iTickCountPeriod) + iCyclePeriod; + } +} + +// Cancel a timer +template +void OsclTimer::Cancel(int32 timerID, int32 param) +{ + + if (iInCallback) + { + // add to list of timers + entry_type *entry = iEntryAllocator.ALLOCATE(1); + entry->iTimerID = timerID; + entry->iParam = param; + + iEntriesWaitingToCancel.push_back(entry); + return; + } + + // remove from list of timers + for (entries_type_iterator it = iEntries.begin(); it != iEntries.end(); it++) + { + if ((*it)->iTimerID == timerID) + { + // make sure the param matches unless it is not specified (-1) + if ((*it)->iParam == param || param == -1) + { + iEntryAllocator.deallocate(*it); + iEntries.erase(it); + return; + } + } + } +} + +// Clear all waiting timers +template +void OsclTimer::Clear() +{ + for (entries_type_iterator it = iEntries.begin(); it != iEntries.end(); it++) + { + iEntryAllocator.deallocate(*it); + } + iEntries.clear(); +} + +template +void OsclTimer::TimerBaseElapsed() +{ + uint8 expiredFound = 0; + + { + // call all whose timers have expired + for (entries_type_iterator it = iEntries.begin(); it != iEntries.end(); it++) + { + entry_type *entry = (*it); + if (--(entry->iCounter) <= 0) + { + if (!entry->iRecurring) expiredFound = 1; + if (entry->iRecurring) entry->iCounter = entry->iOrigCounter; + + // use local observer if it exists, otherwise use global observer + OsclTimerObserver *obs = (entry->iObserver ? entry->iObserver : iObserver); + if (obs) + { + iInCallback = true; + obs->TimeoutOccurred(entry->iTimerID, entry->iParam); + iInCallback = false; + } + } + } + } + + // remove from list all whose timers have expired + while (expiredFound) + { + expiredFound = 0; + for (entries_type_iterator it = iEntries.begin(); it != iEntries.end(); it++) + { + entry_type *entry = (*it); + if (entry->iCounter <= 0) + { + expiredFound = 1; + iEntryAllocator.deallocate(entry); + iEntries.erase(it); + break; + } + } + } + + { + // if any timers were cancelled in the callback, process them now + for (entries_type_iterator it = iEntriesWaitingToCancel.begin(); it != iEntriesWaitingToCancel.end(); it++) + { + entry_type *entry = (*it); + Cancel(entry->iTimerID, entry->iParam); + iEntryAllocator.deallocate(entry); + } + iEntriesWaitingToCancel.clear(); + } + + { + // if any timers were requested in the callback, process them now + for (entries_type_iterator it = iEntriesWaitingToAdd.begin(); it != iEntriesWaitingToAdd.end(); it++) + { + entry_type *entry = (*it); + Request(entry->iTimerID, entry->iParam, entry->iCounter, entry->iObserver); + iEntryAllocator.deallocate(entry); + } + iEntriesWaitingToAdd.clear(); + } + + if (!iEntries.empty()) + { + // adjust for the jitter + uint32 time = OsclTickCount::TickCount() * iTickCountPeriod; + int32 jitter = time - iExpectedTimeout; + int32 waitperiod = iCyclePeriod - jitter; + + // currently there is some problem on the phone if we send + // in real-time rather than with a slower (growing delay) H.223 mux output + // if jitter is too large in either direction, start over + if ((uint)OSCL_ABS(jitter) > iCyclePeriod) + { + iExpectedTimeout = time; + } + else + { + iExpectedTimeout += iCyclePeriod; + } + + waitperiod = OSCL_MAX(waitperiod, 0); + + if (iTimer) + { + iTimer->RunIfNotReady(waitperiod); + } + } + else + { + iExpectedTimeout = 0; + } +} + + + +#endif diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_timerbase.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_timerbase.cpp new file mode 100644 index 0000000..12a8ce2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclproc/src/oscl_timerbase.cpp @@ -0,0 +1,36 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "osclconfig_proc.h" + + + + + + + + + + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/Android.mk new file mode 100644 index 0000000..f216630 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/Android.mk @@ -0,0 +1,31 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/oscl_registry_access_client.cpp \ + src/oscl_registry_client.cpp \ + src/oscl_registry_client_impl.cpp + + +LOCAL_MODULE := libosclregcli + +LOCAL_CFLAGS := $(PV_CFLAGS) + + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/oscl/oscl/osclregcli/src \ + $(PV_TOP)/oscl/oscl/osclregcli/src \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + src/oscl_registry_access_client.h \ + src/oscl_registry_client.h \ + src/oscl_registry_types.h + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/build/make/local.mk new file mode 100644 index 0000000..b63a945 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/build/make/local.mk @@ -0,0 +1,22 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + +TARGET := osclregcli + + +SRCDIR := ../../src +INCSRCDIR := ../../src + +SRCS := oscl_registry_access_client.cpp \ + oscl_registry_client.cpp \ + oscl_registry_client_impl.cpp + + +HDRS := oscl_registry_access_client.h \ + oscl_registry_client.h \ + oscl_registry_types.h + +include $(MK)/library.mk diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_access_client.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_access_client.cpp new file mode 100644 index 0000000..a24d1d9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_access_client.cpp @@ -0,0 +1,110 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_registry_access_client.h" +#include "oscl_registry_client_impl.h" +#include "oscl_error.h" + + +OSCL_EXPORT_REF OsclRegistryAccessClient::OsclRegistryAccessClient() +{ + iGlobalImpl = NULL; + iTlsImpl = NULL; +} + + +OSCL_EXPORT_REF OsclRegistryAccessClient::~OsclRegistryAccessClient() +{ + Close(); +} + +OSCL_EXPORT_REF int32 OsclRegistryAccessClient::Connect() +{ + //Decide whether to use TLS-based or global registry + //If there is anything in the TLS-based registry then use + //TLS-based. + if (OsclTLSRegistryEx::getInstance(OSCL_TLS_ID_OSCLREGISTRY) != NULL) + { + //avoid mixing session types + if (iGlobalImpl) + return OsclErrInvalidState; + + if (!iTlsImpl) + { + int32 err; + OSCL_TRY(err, iTlsImpl = OSCL_NEW(OsclRegistryAccessClientTlsImpl, ());); + if (err != OsclErrNone) + return err; + } + return iTlsImpl->Connect(); + } + else + { + if (!iGlobalImpl) + { + int32 err; + OSCL_TRY(err, iGlobalImpl = OSCL_NEW(OsclRegistryAccessClientImpl, ());); + if (err != OsclErrNone) + return err; + } + return iGlobalImpl->Connect(); + } +} + +OSCL_EXPORT_REF void OsclRegistryAccessClient::Close() +{ + if (iTlsImpl) + { + iTlsImpl->Close(); + OSCL_DELETE(iTlsImpl); + iTlsImpl = NULL; + } + else if (iGlobalImpl) + { + iGlobalImpl->Close(); + OSCL_DELETE(iGlobalImpl); + iGlobalImpl = NULL; + } +} + +OSCL_EXPORT_REF OsclComponentFactory OsclRegistryAccessClient::GetFactory(OSCL_String& aReg) +{ + if (iTlsImpl) + return iTlsImpl->GetFactory(aReg); + + else if (iGlobalImpl) + return iGlobalImpl->GetFactory(aReg); + + else + return NULL; +} + +OSCL_EXPORT_REF void OsclRegistryAccessClient::GetFactories(OSCL_String& aReg, Oscl_Vector& aVec) +{ + if (iTlsImpl) + iTlsImpl->GetFactories(aReg, aVec); + + else if (iGlobalImpl) + iGlobalImpl->GetFactories(aReg, aVec); + +} + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_access_client.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_access_client.h new file mode 100644 index 0000000..4bf5cee --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_access_client.h @@ -0,0 +1,98 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// Oscl Registry Access Client + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/*! + * \file oscl_registry_access_client.h + * \brief Client-side implementation Registry Access implementation. + * + */ + + +#ifndef OSCL_REGISTRY_ACCESS_CLIENT_H_INCLUDED +#define OSCL_REGISTRY_ACCESS_CLIENT_H_INCLUDED + + +#ifndef OSCL_REGISTRY_TYPES_H_INCLUDED +#include "oscl_registry_types.h" +#endif +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#include "oscl_string_containers.h" +#endif +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +class OsclRegistryAccessClientImpl; +class OsclRegistryAccessClientTlsImpl; + +class OsclRegistryAccessClient +{ + public: + OSCL_IMPORT_REF OsclRegistryAccessClient(); + OSCL_IMPORT_REF ~OsclRegistryAccessClient(); + + /*! + ** Create a session. + ** @return OsclErrNone on success. + */ + OSCL_IMPORT_REF int32 Connect(); + + /*! + ** Lookup a factory by registry and component mime type. + ** @param aComponent: registry+component MIME type + ** @return Factory. Factory will be NULL if not found. + */ + OSCL_IMPORT_REF OsclComponentFactory GetFactory(OSCL_String& aComponent); + + + /*! + ** Get all factories for a given registry type. + ** @param aRegistry: registry MIME type + ** @param aVec: output component factory + mimestring vector. + */ + OSCL_IMPORT_REF void GetFactories(OSCL_String& aRegistry, Oscl_Vector& aVec); + + /*! + ** Close and cleanup session. + */ + OSCL_IMPORT_REF void Close(); + + private: + OsclRegistryAccessClientImpl* iGlobalImpl; + OsclRegistryAccessClientTlsImpl* iTlsImpl; +}; + + +#endif // OSCL_STRING_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client.cpp new file mode 100644 index 0000000..36beac9 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client.cpp @@ -0,0 +1,116 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + + +#include "oscl_registry_client.h" +#include "oscl_registry_client_impl.h" + +#ifndef OSCL_COMBINED_DLL +#include "oscl_dll.h" +OSCL_DLL_ENTRY_POINT_DEFAULT() +#endif + +OSCL_EXPORT_REF OsclRegistryClient::OsclRegistryClient() +{ + iGlobalImpl = NULL; + iTlsImpl = NULL; +} + +OSCL_EXPORT_REF OsclRegistryClient::~OsclRegistryClient() +{ + Close(); +} + +OSCL_EXPORT_REF int32 OsclRegistryClient::Connect(bool aPerThread) +{ + if (aPerThread) + { + //Prevent mixing session types. + if (iGlobalImpl) + return OsclErrInvalidState; + + //Create TLS-based session. + if (!iTlsImpl) + { + int32 err; + OSCL_TRY(err, iTlsImpl = OSCL_NEW(OsclRegistryClientTlsImpl, ());); + if (err != OsclErrNone) + return err; + } + return iTlsImpl->Connect(); + } + else + { + //Prevent mixing session types. + if (iTlsImpl) + return OsclErrInvalidState; + + //Create global session + if (!iGlobalImpl) + { + int32 err; + OSCL_TRY(err, iGlobalImpl = OSCL_NEW(OsclRegistryClientImpl, ());); + if (err != OsclErrNone) + return err; + } + return iGlobalImpl->Connect(); + } +} + +OSCL_EXPORT_REF int32 OsclRegistryClient::Register(OSCL_String& aComp, OsclComponentFactory aFac) +{ + if (iTlsImpl) + return iTlsImpl->Register(aComp, aFac); + + else if (iGlobalImpl) + return iGlobalImpl->Register(aComp, aFac); + + else + return OsclErrInvalidState; +} + +OSCL_EXPORT_REF int32 OsclRegistryClient::UnRegister(OSCL_String& aComp) +{ + if (iTlsImpl) + return iTlsImpl->UnRegister(aComp); + + else if (iGlobalImpl) + return iGlobalImpl->UnRegister(aComp); + + else + return OsclErrInvalidState; +} + +OSCL_EXPORT_REF void OsclRegistryClient::Close() +{ + if (iTlsImpl) + { + iTlsImpl->Close(); + OSCL_DELETE(iTlsImpl); + iTlsImpl = NULL; + } + else if (iGlobalImpl) + { + iGlobalImpl->Close(); + OSCL_DELETE(iGlobalImpl); + iGlobalImpl = NULL; + } +} + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client.h new file mode 100644 index 0000000..5061213 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// Oscl Registry Client + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + +/*! + * \file oscl_registry_client.h + * \brief Client-side implementation of OsclRegistry + * + */ + +#ifndef OSCL_REGISTRY_CLIENT_H_INCLUDED +#define OSCL_REGISTRY_CLIENT_H_INCLUDED + +#ifndef OSCL_REGISTRY_TYPES_H_INCLUDED +#include "oscl_registry_types.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#ifndef OSCL_STRING_H_INCLUDED +#include "oscl_string.h" +#endif + +class OsclRegistryClientImpl; +class OsclRegistryClientTlsImpl; + +class OsclRegistryClient : public HeapBase +{ + public: + OSCL_IMPORT_REF OsclRegistryClient(); + OSCL_IMPORT_REF ~OsclRegistryClient(); + + /*! + ** Create a session. + ** @param aPerThread: Select per-thread registry instead of global registry. + ** @return OsclErrNone on success. + */ + OSCL_IMPORT_REF int32 Connect(bool aPerThread = false); + + /*! + ** Register a component factory by registry ID and component ID. + ** + ** @param aComponentID: registry + component mime-string. + ** @param aFactory: factory function pointer. + ** @param aParam: component Create param. + ** @return OsclErrNone on success. + */ + OSCL_IMPORT_REF int32 Register(OSCL_String& aComponentID, OsclComponentFactory aFactory); + + /*! + ** Unregister a previously registered component. + ** @return OsclErrNone on success. + */ + OSCL_IMPORT_REF int32 UnRegister(OSCL_String& aComponentID); + + /*! + ** Close and cleanup. All components registered in this session are + ** are automatically unregistered. + */ + OSCL_IMPORT_REF void Close(); + + private: + OsclRegistryClientImpl* iGlobalImpl; + OsclRegistryClientTlsImpl* iTlsImpl; + +}; + + +#endif //OSCL_REGISTRY_CLIENT_H_INCLUDED +/*! @} */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client_impl.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client_impl.cpp new file mode 100644 index 0000000..f63e890 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client_impl.cpp @@ -0,0 +1,40 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_base.h" +#include "oscl_registry_client_impl.h" + +#include "oscl_error_codes.h" + +#include "osclconfig_proc.h" +#if (OSCL_HAS_SINGLETON_SUPPORT) +//1st choice implementation-- uses Oscl Singleton + +//nothing needed. client goes directly to server impl. + +#else //OSCL_HAS_ ... +//3rd choice implementation + +//non-functional stubs are implemented in the header-- nothing needed here. + +#endif //oscl config + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client_impl.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client_impl.h new file mode 100644 index 0000000..85df568 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_client_impl.h @@ -0,0 +1,116 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// Oscl Registry Client Impl + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + +/*! + * \file oscl_registry_client_impl.h + * \brief Client-side implementation of OsclRegistryInterface + * + */ + +#ifndef OSCL_REGISTRY_CLIENT_IMPL_H_INCLUDED +#define OSCL_REGISTRY_CLIENT_IMPL_H_INCLUDED + +#include "oscl_base.h" +#include "osclconfig_proc.h" +#if (OSCL_HAS_SINGLETON_SUPPORT) +//1st choice implementation-- uses Oscl singleton + +#include "oscl_registry_serv_impl_global.h" + +//client is the same as server +class OsclRegistryClientImpl: public OsclRegistryServImpl +{ +}; + +//access client is also the same as server +class OsclRegistryAccessClientImpl: public OsclRegistryServImpl +{ +}; + +#else //OSCL_HAS_ ... +//3rd choice implementation -- Non-functional stubs. + +#include "oscl_vector.h" +#include "oscl_string.h" +#include "oscl_registry_types.h" + +class OsclRegistryClientImpl +{ + protected: + + int32 Connect() + { + return OsclErrNotSupported; + } + void Close() {} + + int32 Register(OSCL_String& , OsclComponentFactory) + { + return OsclErrNotSupported; + } + int32 UnRegister(OSCL_String&) + { + return OsclErrNotSupported; + } + + //for access client. + OsclComponentFactory GetFactory(OSCL_String&) + { + return NULL; + } + void GetFactories(OSCL_String& , Oscl_Vector&) {} + + friend class OsclRegistryClient; + friend class OsclRegistryAccessClient; +}; + +class OsclRegistryAccessClientImpl: public OsclRegistryClientImpl +{ +}; + +#endif //OSCL_HAS_ ... + + +//TLS-based registry +#include "oscl_registry_serv_impl_tls.h" + +//client is the same as server +class OsclRegistryClientTlsImpl: public OsclRegistryServTlsImpl +{ +}; + +//access client is also the same as server +class OsclRegistryAccessClientTlsImpl: public OsclRegistryServTlsImpl +{ +}; + +#endif //OSCL_REGISTRY_IMPL_H_INCLUDED +/*! @} */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_types.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_types.h new file mode 100644 index 0000000..1c72ec3 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregcli/src/oscl_registry_types.h @@ -0,0 +1,68 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// Oscl Registry Types + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/*! + * \file oscl_registry_types.h + * \brief Common types used in Oscl registry interfaces. + * + */ + + +#ifndef OSCL_REGISTRY_TYPES_H_INCLUDED +#define OSCL_REGISTRY_TYPES_H_INCLUDED + + +#ifndef OSCL_TYPES_H_INCLUDED +#include "oscl_types.h" +#endif +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#include "oscl_string_containers.h" +#endif + +/*! + * OsclComponentFactory is an opaque pointer. + */ +typedef OsclAny* OsclComponentFactory; + +/*! + * A class used to access the registry data + */ +class OsclRegistryAccessElement +{ + public: + OsclComponentFactory iFactory; + OSCL_HeapString iMimeString; +}; + + + +#endif // OSCL_REGISTRY_TYPES_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/Android.mk new file mode 100644 index 0000000..ea3f6a1 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/Android.mk @@ -0,0 +1,31 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/oscl_registry_serv_impl.cpp \ + src/oscl_registry_serv_impl_global.cpp \ + src/oscl_registry_serv_impl_tls.cpp + + +LOCAL_MODULE := libosclregserv + +LOCAL_CFLAGS := $(PV_CFLAGS) + + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/oscl/oscl/osclregserv/src \ + $(PV_TOP)/oscl/oscl/osclregserv/src \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + src/oscl_registry_serv_impl.h \ + src/oscl_registry_serv_impl_global.h \ + src/oscl_registry_serv_impl_tls.h + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/build/make/local.mk new file mode 100644 index 0000000..cea7739 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/build/make/local.mk @@ -0,0 +1,22 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + +TARGET := osclregserv + + +SRCDIR := ../../src +INCSRCDIR := ../../src + +SRCS := oscl_registry_serv_impl.cpp \ + oscl_registry_serv_impl_global.cpp \ + oscl_registry_serv_impl_tls.cpp + + +HDRS := oscl_registry_serv_impl.h \ + oscl_registry_serv_impl_global.h \ + oscl_registry_serv_impl_tls.h + +include $(MK)/library.mk diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.cpp new file mode 100644 index 0000000..c8a5d33 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.cpp @@ -0,0 +1,246 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_registry_serv_impl.h" + +#include "osclconfig_proc.h" + +#include "oscl_registry_types.h" +/*! +** OS-independent server-side implementation. This part works +** for either global var or symbian server implementation. +*/ + +OsclComponentRegistryElement::OsclComponentRegistryElement(OSCL_String& compid, OsclComponentFactory fac) + : iId(NULL) + , iFactory(fac) +{ + iId = OSCL_NEW(OSCL_HeapString, (compid)); +} + +OsclComponentRegistryElement::~OsclComponentRegistryElement() +{ + if (iId) + { + OSCL_HeapString* id = (OSCL_HeapString*)iId; + OSCL_DELETE(id); + } +} + +OsclComponentRegistryElement::OsclComponentRegistryElement(const OsclComponentRegistryElement&v) + : iId(NULL) + , iFactory(v.iFactory) + , iComponentId(v.iComponentId) +{ + iId = OSCL_NEW(OSCL_HeapString, (*v.iId)); +} + +OsclComponentRegistryElement& OsclComponentRegistryElement::operator=(const OsclComponentRegistryElement & src) +{ + if (iId) + { + OSCL_HeapString* id = (OSCL_HeapString*)iId; + OSCL_DELETE(id); + iId = NULL; + } + iId = OSCL_NEW(OSCL_HeapString, (*src.iId)); + iFactory = src.iFactory; + iComponentId = src.iComponentId; + return *this; +} + +bool OsclComponentRegistryElement::Match(OSCL_String& id, bool aExact) +{ + if (aExact) + { + if (id == *iId) + return true; + } + else + { + //hierarchical string match. + //tells whether "id" is a prefix of the component ID (or an exact match). + if (iId->get_size() >= id.get_size() + && oscl_CIstrncmp(id.get_cstr(), iId->get_cstr(), id.get_size()) == 0 + && (iId->get_cstr()[id.get_size()] == '/' + || iId->get_cstr()[id.get_size()] == '\0')) + { + return true; + } + } + return false; +} + + +OsclComponentRegistryElement* OsclComponentRegistryData::Find(OSCL_String& id, bool aExact) +{ + for (uint32 i = 0; i < iVec.size(); i++) + { + if (iVec[i].Match(id, aExact)) + return &iVec[i]; + } + return NULL; +} + +OsclComponentRegistry::OsclComponentRegistry() +{ + iMutex.Create(); + iComponentIdCounter = 0; + iNumSessions = 0; +} + +OsclComponentRegistry::~OsclComponentRegistry() +{ + //need to be careful not to do any cleanup that isn't valid + //for a global variable destructor here, such as anything that + //relies on memory manager. + iMutex.Close(); +} + +void OsclComponentRegistry::OpenSession() +{ + iMutex.Lock(); + iNumSessions++; + iMutex.Unlock(); +} + +void OsclComponentRegistry::CloseSession() +{ + //when the number of sessions is zero, cleanup all dynamically allocated + //data. + //This is necessary to avoid trying to use memory manager after it's + //cleaned up, in the global variable implementation. + iMutex.Lock(); + iNumSessions--; + if (iNumSessions <= 0) + { + iData.iVec.clear(); + iData.iVec.destroy(); + } + iMutex.Unlock(); +} + +int32 OsclComponentRegistry::Register(uint32&aId, OSCL_String&compId, OsclComponentFactory fac) +{ + int32 err = OsclErrNone;; + iMutex.Lock(); + //try to find existing component (use exact match). + if (iData.Find(compId, true)) + { + err = OsclErrAlreadyExists; + } + else + { + //create new component. + OsclComponentRegistryElement elem(compId, fac); + elem.iComponentId = ++iComponentIdCounter; + aId = elem.iComponentId; + OSCL_TRY(err, iData.iVec.push_back(elem);); + } + iMutex.Unlock(); + return err; +} + +OsclComponentFactory OsclComponentRegistry::FindExact(OSCL_String& compId) +{ + OsclComponentRegistryElement*comp = NULL; + OsclComponentFactory fac = NULL; + + iMutex.Lock(); + comp = iData.Find(compId, true);//exact + if (comp) + fac = comp->iFactory; + iMutex.Unlock(); + + return fac; +} + +void OsclComponentRegistry::FindHierarchical(OSCL_String& aReg, Oscl_Vector& aVec) +{ + iMutex.Lock(); + + //compare target string against all components, using + //heirarchical match. + + //note: the push_back call may leave. if so, just exit + //gracefully. + int32 err; + OSCL_TRY(err, + for (uint32 i = 0; i < iData.iVec.size(); i++) +{ + if (iData.iVec[i].Match(aReg, false))//hierarchical match. + { + OsclRegistryAccessElement element; + element.iFactory = iData.iVec[i].iFactory; + element.iMimeString = *(iData.iVec[i].iId); + aVec.push_back(element); + } + } + ); + + iMutex.Unlock(); +} + +int32 OsclComponentRegistry::Unregister(OSCL_String& compId) +{ + OsclComponentRegistryElement*comp = NULL; + + iMutex.Lock(); + comp = iData.Find(compId, true); + if (!comp) + { + iMutex.Unlock(); + return OsclErrArgument;//non existent. + } + iData.iVec.erase(comp); + //also cleanup reserve + if (iData.iVec.empty()) + iData.iVec.destroy(); + iMutex.Unlock(); + return 0; +} + +int32 OsclComponentRegistry::Unregister(uint32 aId) +{ + //no choice but to search all registries... + + iMutex.Lock(); + for (uint32 i = 0; i < iData.iVec.size(); i++) + { + if (iData.iVec[i].iComponentId == aId) + { + iData.iVec.erase(&iData.iVec[i]); + //also cleanup reserve + if (iData.iVec.empty()) + iData.iVec.destroy(); + break; + } + } + iMutex.Unlock(); + return 0; +} + + + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.h new file mode 100644 index 0000000..b4619c2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.h @@ -0,0 +1,111 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// Oscl Registry Serv Impl + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ +/*! + * \file oscl_registry_serv_impl.h + * \brief Server-side implementation of OsclRegistry interfaces. + * + */ + + +#ifndef OSCL_REGISTRY_SERV_IMPL_H_INCLUDED +#define OSCL_REGISTRY_SERV_IMPL_H_INCLUDED + +#include "oscl_base.h" +#include "osclconfig_proc.h" + +#include "oscl_registry_types.h" + +/*! +** OS-independent declarations. +*/ + +#include "oscl_string.h" +#include "oscl_vector.h" +#include "oscl_mem.h" + +/*! +** Data for each registered component. +*/ +class OsclComponentRegistryElement +{ + public: + OsclComponentRegistryElement(OSCL_String&, OsclComponentFactory); + OsclComponentRegistryElement(const OsclComponentRegistryElement&); + OsclComponentRegistryElement& operator=(const OsclComponentRegistryElement& src); + ~OsclComponentRegistryElement(); + + bool Match(OSCL_String& aStr, bool aExact); + + OSCL_String* iId;//use a pointer here instead of a container for efficiency + //since this element is used in an oscl vector. + OsclComponentFactory iFactory; + uint32 iComponentId; +}; + + +/*! +** Registry +*/ +class OsclComponentRegistryData +{ + public: + OsclComponentRegistryElement* Find(OSCL_String&, bool aExact); + Oscl_Vector iVec; +}; + +/*! +** Thread-safe singleton registry object. +*/ +#include "oscl_mutex.h" +class OsclComponentRegistry +{ + public: + OsclComponentRegistry(); + ~OsclComponentRegistry(); + int32 Register(uint32& aId, OSCL_String&, OsclComponentFactory); + int32 Unregister(OSCL_String&); + int32 Unregister(uint32); + OsclComponentFactory FindExact(OSCL_String&); + void FindHierarchical(OSCL_String& , Oscl_Vector&); + void OpenSession(); + void CloseSession(); + + OsclComponentRegistryData iData; + OsclMutex iMutex; + + uint32 iComponentIdCounter; + + uint32 iNumSessions; +}; + + +#endif //OSCL_REGISTRY_IMPL_H_INCLUDED +/*! @} */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.cpp new file mode 100644 index 0000000..d71a802 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.cpp @@ -0,0 +1,146 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_registry_serv_impl_global.h" + +#include "osclconfig_proc.h" +#include "oscl_base.h" +#if (OSCL_HAS_SINGLETON_SUPPORT) + +//Global variable implementation. + +#include "oscl_singleton.h" +#include "oscl_registry_serv_impl.h" + +OsclComponentRegistry* OsclRegistryServImpl::GetOsclComponentRegistry() +{ + return (OsclComponentRegistry*)OsclSingletonRegistryEx::getInstance(OSCL_SINGLETON_ID_OSCLREGISTRY); +} + +OsclRegistryServImpl::OsclRegistryServImpl() +{ + iIsOpen = false; +} + +OsclRegistryServImpl::~OsclRegistryServImpl() +{ + if (iIsOpen) + Close(); +} + +int32 OsclRegistryServImpl::Connect() +{ + if (iIsOpen) + return OsclErrInvalidState; + //Create the registry on the first session. + if (!GetOsclComponentRegistry()) + { + OsclComponentRegistry* reg = NULL; + int32 err; + OSCL_TRY(err, reg = OSCL_NEW(OsclComponentRegistry, ())); + if (err != OsclErrNone) + return err; + + OsclSingletonRegistryEx::registerInstance(reg, OSCL_SINGLETON_ID_OSCLREGISTRY); + } + iIsOpen = true; + GetOsclComponentRegistry()->OpenSession(); + return OsclErrNone; +} + +void OsclRegistryServImpl::Close() +{ + //session cleanup + if (!iIdVec.empty()) + { + //unregister all comps that were registered by this session + for (uint32 i = 0; i < iIdVec.size(); i++) + GetOsclComponentRegistry()->Unregister(iIdVec[i]); + //clear our comp list. + iIdVec.destroy(); + } + + if (iIsOpen) + { + GetOsclComponentRegistry()->CloseSession(); + iIsOpen = false; + //Delete the registry when the session count goes to zero. + if (GetOsclComponentRegistry()->iNumSessions == 0) + { + OSCL_DELETE(GetOsclComponentRegistry()); + OsclSingletonRegistryEx::registerInstance(NULL, OSCL_SINGLETON_ID_OSCLREGISTRY); + } + } +} + +int32 OsclRegistryServImpl::Register(OSCL_String& aComp, OsclComponentFactory aFac) +{ + if (!IsOpen()) + return OsclErrInvalidState; + + int32 err; + OSCL_TRY(err, iIdVec.reserve(iIdVec.size() + 1);); + if (err != OsclErrNone) + return err; + + uint32 id; + int32 result = GetOsclComponentRegistry()->Register(id, aComp, aFac); + + //save all comp IDs in our session data + if (result == OsclErrNone) + iIdVec.push_back(id);//can't leave, already reserved space. + + return result; +} + +int32 OsclRegistryServImpl::UnRegister(OSCL_String& aComp) +{ + if (!IsOpen()) + return OsclErrInvalidState; + + return GetOsclComponentRegistry()->Unregister(aComp); +} + +OsclComponentFactory OsclRegistryServImpl::GetFactory(OSCL_String& aComp) +{ + if (!IsOpen()) + { + return NULL; + } + + return GetOsclComponentRegistry()->FindExact(aComp); +} + +void OsclRegistryServImpl::GetFactories(OSCL_String& aReg, Oscl_Vector& aVec) +{ + if (!IsOpen()) + return; + + GetOsclComponentRegistry()->FindHierarchical(aReg, aVec); +} + +#endif //oscl config + + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.h new file mode 100644 index 0000000..5fa2023 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// Oscl Registry Serv Impl + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ +/*! + * \file oscl_registry_serv_impl.h + * \brief Server-side implementation of OsclRegistry interfaces. + * + */ + + +#ifndef OSCL_REGISTRY_SERV_IMPL_GLOBAL_H_INCLUDED +#define OSCL_REGISTRY_SERV_IMPL_GLOBAL_H_INCLUDED + +#include "osclconfig_proc.h" +#include "oscl_base.h" +#if (OSCL_HAS_SINGLETON_SUPPORT) + +#include "oscl_registry_serv_impl.h" +#include "oscl_registry_types.h" +#include "oscl_vector.h" +#include "oscl_mem.h" + +//global-variable-based implementation. +//this handles both the registration client and the access client +//interfaces. +class OsclRegistryServImpl +{ + protected: + OsclRegistryServImpl(); + virtual ~OsclRegistryServImpl(); + + int32 Connect(); + void Close(); + + //for registration client + int32 Register(OSCL_String& aComponentID, OsclComponentFactory aFactory); + int32 UnRegister(OSCL_String& aComponentID); + + //for access client. + OsclComponentFactory GetFactory(OSCL_String& aComponent); + void GetFactories(OSCL_String& aRegistry, Oscl_Vector& aVec); + + friend class OsclRegistryClient; + friend class OsclRegistryAccessClient; + private: + bool IsOpen() const + { + return iIsOpen; + } + bool iIsOpen; + //server data. + OsclComponentRegistry* GetOsclComponentRegistry(); + //session data. + Oscl_Vector iIdVec; + +}; + +#endif //oscl config + +#endif //OSCL_REGISTRY_IMPL_GLOBAL_H_INCLUDED +/*! @} */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.cpp new file mode 100644 index 0000000..a759022 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.cpp @@ -0,0 +1,141 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_registry_serv_impl_tls.h" + +#include "osclconfig_proc.h" + +#include "oscl_error.h" +#include "oscl_registry_serv_impl.h" + +OsclComponentRegistry* OsclRegistryServTlsImpl::GetOsclComponentRegistry() +{ + return (OsclComponentRegistry*)OsclTLSRegistryEx::getInstance(OSCL_TLS_ID_OSCLREGISTRY); +} + +OsclRegistryServTlsImpl::OsclRegistryServTlsImpl() +{ + iIsOpen = false; +} + +OsclRegistryServTlsImpl::~OsclRegistryServTlsImpl() +{ + if (iIsOpen) + Close(); +} + +int32 OsclRegistryServTlsImpl::Connect() +{ + if (iIsOpen) + return OsclErrInvalidState; + //Create the registry on the first session. + if (!GetOsclComponentRegistry()) + { + OsclComponentRegistry* reg = NULL; + int32 err; + OSCL_TRY(err, reg = OSCL_NEW(OsclComponentRegistry, ())); + if (err != OsclErrNone) + return err; + + OsclTLSRegistryEx::registerInstance(reg, OSCL_TLS_ID_OSCLREGISTRY); + } + iIsOpen = true; + GetOsclComponentRegistry()->OpenSession(); + return OsclErrNone; +} + +void OsclRegistryServTlsImpl::Close() +{ + //session cleanup + if (!iIdVec.empty()) + { + //unregister all comps that were registered by this session + for (uint32 i = 0; i < iIdVec.size(); i++) + GetOsclComponentRegistry()->Unregister(iIdVec[i]); + //clear our comp list. + iIdVec.destroy(); + } + + if (iIsOpen) + { + GetOsclComponentRegistry()->CloseSession(); + iIsOpen = false; + //Delete the registry when the session count goes to zero. + if (GetOsclComponentRegistry()->iNumSessions == 0) + { + OSCL_DELETE(GetOsclComponentRegistry()); + OsclTLSRegistryEx::registerInstance(NULL, OSCL_TLS_ID_OSCLREGISTRY); + } + } +} + +int32 OsclRegistryServTlsImpl::Register(OSCL_String& aComp, OsclComponentFactory aFac) +{ + if (!IsOpen()) + return OsclErrInvalidState; + + int32 err; + OSCL_TRY(err, iIdVec.reserve(iIdVec.size() + 1);); + if (err != OsclErrNone) + return err; + + uint32 id; + int32 result = GetOsclComponentRegistry()->Register(id, aComp, aFac); + + //save all comp IDs in our session data + if (result == OsclErrNone) + iIdVec.push_back(id);//can't leave, already reserved space. + + return result; +} + +int32 OsclRegistryServTlsImpl::UnRegister(OSCL_String& aComp) +{ + if (!IsOpen()) + return OsclErrInvalidState; + + return GetOsclComponentRegistry()->Unregister(aComp); +} + +OsclComponentFactory OsclRegistryServTlsImpl::GetFactory(OSCL_String& aComp) +{ + if (!IsOpen()) + { + return NULL; + } + + return GetOsclComponentRegistry()->FindExact(aComp); +} + +void OsclRegistryServTlsImpl::GetFactories(OSCL_String& aReg, Oscl_Vector& aVec) +{ + if (!IsOpen()) + return; + + GetOsclComponentRegistry()->FindHierarchical(aReg, aVec); +} + + + + + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.h new file mode 100644 index 0000000..1a2d392 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// Oscl Registry Serv Impl + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ +/*! + * \file oscl_registry_serv_impl.h + * \brief Server-side implementation of OsclRegistry interfaces. + * + */ + + +#ifndef OSCL_REGISTRY_SERV_IMPL_TLS_H_INCLUDED +#define OSCL_REGISTRY_SERV_IMPL_TLS_H_INCLUDED + +#include "osclconfig_proc.h" + +#include "oscl_registry_serv_impl.h" +#include "oscl_registry_types.h" +#include "oscl_vector.h" +#include "oscl_mem.h" + +//TLS-based implementation. +//this handles both the registration client and the access client +//interfaces. +class OsclRegistryServTlsImpl +{ + protected: + OsclRegistryServTlsImpl(); + virtual ~OsclRegistryServTlsImpl(); + + int32 Connect(); + void Close(); + + //for registration client + int32 Register(OSCL_String& aComponentID, OsclComponentFactory aFactory); + int32 UnRegister(OSCL_String& aComponentID); + + //for access client. + OsclComponentFactory GetFactory(OSCL_String& aComponent); + void GetFactories(OSCL_String& aRegistry, Oscl_Vector& aVec); + + friend class OsclRegistryClient; + friend class OsclRegistryAccessClient; + private: + bool IsOpen() const + { + return iIsOpen; + } + bool iIsOpen; + //server data. + OsclComponentRegistry* GetOsclComponentRegistry(); + //session data. + Oscl_Vector iIdVec; +}; + + +#endif //OSCL_REGISTRY_IMPL_TLS_H_INCLUDED +/*! @} */ + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/Android.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/Android.mk new file mode 100644 index 0000000..99be62c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/Android.mk @@ -0,0 +1,58 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + src/oscl_bin_stream.cpp \ + src/oscl_string.cpp \ + src/oscl_string_containers.cpp \ + src/oscl_str_ptr_len.cpp \ + src/oscl_string_utf8.cpp \ + src/oscl_tickcount.cpp \ + src/oscl_utf8conv.cpp \ + src/oscl_snprintf.cpp \ + src/oscl_math.cpp \ + src/oscl_rand.cpp \ + src/oscl_string_uri.cpp \ + src/oscl_string_xml.cpp \ + src/oscl_priqueue.cpp + + +LOCAL_MODULE := libosclutil + +LOCAL_CFLAGS := $(PV_CFLAGS) + + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := + +LOCAL_C_INCLUDES := \ + $(PV_TOP)/oscl/oscl/osclutil/src \ + $(PV_TOP)/oscl/oscl/osclutil/src \ + $(PV_INCLUDES) + +LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO) + +LOCAL_COPY_HEADERS := \ + src/oscl_bin_stream.h \ + src/oscl_bin_stream.inl \ + src/oscl_media_data.h \ + src/oscl_media_status.h \ + src/oscl_priqueue.h \ + src/oscl_rand.h \ + src/oscl_rand.inl \ + src/oscl_snprintf.h \ + src/oscl_string.h \ + src/oscl_string_containers.h \ + src/oscl_string_rep.h \ + src/oscl_string_utf8.h \ + src/oscl_str_ptr_len.h \ + src/oscl_tickcount.h \ + src/oscl_tickcount.inl \ + src/oscl_utf8conv.h \ + src/oscl_math.h \ + src/oscl_math.inl \ + src/oscl_string_uri.h \ + src/oscl_string_xml.h + +include $(BUILD_STATIC_LIBRARY) diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/build/make/local.mk b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/build/make/local.mk new file mode 100644 index 0000000..3da22a5 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/build/make/local.mk @@ -0,0 +1,53 @@ +# Get the current local path as the first operation +LOCAL_PATH := $(call get_makefile_dir) + +# Clear out the variables used in the local makefiles +include $(MK)/clear.mk + + +TARGET := osclutil + + +SRCDIR := ../../src +INCSRCDIR := ../../src + + +SRCS := oscl_bin_stream.cpp \ + oscl_string.cpp \ + oscl_string_containers.cpp \ + oscl_str_ptr_len.cpp \ + oscl_string_utf8.cpp \ + oscl_tickcount.cpp \ + oscl_utf8conv.cpp \ + oscl_snprintf.cpp \ + oscl_math.cpp \ + oscl_rand.cpp \ + oscl_string_uri.cpp \ + oscl_string_xml.cpp \ + oscl_priqueue.cpp + + +HDRS := oscl_bin_stream.h \ + oscl_bin_stream.inl \ + oscl_media_data.h \ + oscl_media_status.h \ + oscl_priqueue.h \ + oscl_rand.h \ + oscl_rand.inl \ + oscl_snprintf.h \ + oscl_string.h \ + oscl_string_containers.h \ + oscl_string_rep.h \ + oscl_string_utf8.h \ + oscl_str_ptr_len.h \ + oscl_tickcount.h \ + oscl_tickcount.inl \ + oscl_utf8conv.h \ + oscl_math.h \ + oscl_math.inl \ + oscl_string_uri.h \ + oscl_string_xml.h + +include $(MK)/library.mk + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_bin_stream.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_bin_stream.cpp new file mode 100644 index 0000000..87e5d82 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_bin_stream.cpp @@ -0,0 +1,25 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#include "oscl_bin_stream.h" + +#if (OSCL_DISABLE_INLINES) +#include "oscl_bin_stream.inl" +#endif + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_bin_stream.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_bin_stream.h new file mode 100644 index 0000000..4c5b4c0 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_bin_stream.h @@ -0,0 +1,459 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ B I N _ S T R E A M + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/*! + * \file oscl_bin_stream.h + * \brief Defines a set of binary stream classes which handle portable input / output of binary data regardless of the native byte order. + * + */ + + +/* +** File: oscl_bin_stream.h +** +** Description: +** This module defines a set of binary stream classes to provide portability of code accross +** different platforms and compilers. Output and input stream classes are defined both for +** little endian and big endian byte orders. These classes should be used when sharing +** information across platforms (e.g. sending messages) instead of C structures. The classes +** will read/write in the correct byte order regardless of the platform you are running on. +** The classes are: +** OsclBinIStreamBigEndian - Input stream for big endian byte order. +** OsclBinIStreamLittleEndian - Input stream for little endian byte order. +** OsclBinOStreamBigEndian - Output stream for big endian byte order. +** OsclBinIStreamLittleEndian - Input stream for little endian byte order. +** +** The preprocessor defined constants BYTE_ORDER_BIG_ENDIAN, BYTE_ORDER_LITTLE_ENDIAN are defined +** in oscl_base.h and tell this module the byte order used by the native platform. This is used +** to decide if we can do a straight copy or we need to manipulate the field one byte at a time. +** The preprocessor defined constant INTEGERS_BYTE_ALIGNED tells us if the platform supports +** accessing integers at any address. +*/ +#ifndef OSCL_BIN_STREAM_H_INCLUDED +#define OSCL_BIN_STREAM_H_INCLUDED + +/* +** Includes +*/ +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + + + +/* +** Classes +*/ + +class OsclBinStream +{ + public: + OsclBinStream() + : state(GOOD_STATE), + pBasePosition(0), + pPosition(0) + { + } + + //! This method determines if the stream is ok. + /*! + \return true if stream is ok. + */ + bool good(); + + //! This method determines if end of stream has been reached + /*! + \return true if end of stream has been reached. + */ + bool eof(); + + //! This method determines if an error has occured in the stream + /*! + ** \return true if an error occured in the stream. + */ + bool fail(); + + + //! This methods specifies the data buffer to attach to the stream. + /*! + \param buffer will provide the input + \param length of the buffer + */ + void Attach(void * buffer, uint32 l_length); + + //! This method specifies the memory fragment array to use for input. + /*! + This array should remain static while the stream refers to it. + \param numFragments is the number of elements in the array + \param fragPtr is the pointer to the MemoryFragment array + */ + void Attach(const uint32 numFragments, const OsclMemoryFragment * fragPtr); + + + //! This method returns the current stream position + /*! + This method is to be used if the input stream is a pointer to the MemoryFragment array + ** \return Stream position. + */ + uint32 tellg(); + + //! This method seeks to the specified stream position. + /*! + \return Stream position. + */ + void Seek(uint32 absPosition); + + //! This method returns the current stream position. + /*! + \returns stream position. + */ + uint32 PositionInBlock(); + + + //! This method seeks to the specified offset from the current location + /*! + \param offset from current stream location + */ + void seekFromCurrentPosition(int32 offset); + + + + protected: + + /* + ** Description: + ** Reserves space for storing/reading. If no space is available it sets the stream state + ** to fail and returns false. If the end of the stream has been reached, it sets the state + ** to end of stream. + ** + ** Returns: true if space was successfully reserved. + ** Side effects: None. + */ + bool ReserveSpace(uint32 size); + + bool HaveRoomInCurrentBlock(uint32 size); + + typedef enum + { + GOOD_STATE, + EOF_STATE, + FAIL_STATE + } state_t; + + state_t state; + + /* Position of the beginning of the data buffer */ + uint8 * pBasePosition; + + /* Current data buffer position */ + uint8 * pPosition; + + /* length of data buffer */ + uint32 length; + + const OsclMemoryFragment * nextFragPtr; + int fragsLeft; + + const OsclMemoryFragment * firstFragPtr; + int numFrags; + OsclMemoryFragment specialFragBuffer; + +}; + +/* +** Class OsclBinIStream +** This class implements the basic stream functions for an input stream. +*/ +class OsclBinIStream : public OsclBinStream +{ + private: + public: + /* + ** Description: + ** Constructor. + ** + ** Returns: None. + ** Side effects: None. + */ + OsclBinIStream() + { + } + + /* + ** Description: + ** Destructor. + ** + ** Returns: None. + ** Side effects: None. + */ + ~OsclBinIStream() + { + } + + //! This method reads an unsigned short from the stream. + /*! + ** \returns Unsigned short read from the stream. + */ + uint8 Read_uint8(); + + //! This method reads 'length' number of bytes from the stream and places them in 'data'. + /*! + \param data is a pointer to the place to store the bytes read + \param size is the number of bytes to read + */ + OsclBinIStream & get( + int8 * data, + int32 size + ); + + protected: + + +}; + +/* +** Class OsclBinIStreamLittleEndian +** This class implements a binary input stream using little endian byte ordering +*/ +class OsclBinIStreamLittleEndian : public OsclBinIStream +{ + public: + OsclBinIStreamLittleEndian() + { + } + + //! This method reads a int8 from the stream and stores it in 'data'. + OsclBinIStreamLittleEndian & operator>>(int8 & data); + + //!This method reads a uint8 from the stream and stores it in 'data'. + OsclBinIStreamLittleEndian & operator>>(uint8 & data); + + //! This method reads a int16 from the stream and stores it in 'data'. + OsclBinIStreamLittleEndian & operator>>(int16 & data); + + //! This method reads a uint16 from the stream and stores it in 'data'. + OsclBinIStreamLittleEndian & operator>>(uint16 & data); + + //! This method reads a int32 from the stream and stores it in 'data'. + OsclBinIStreamLittleEndian & operator>>(int32 & data); + + //! This method reads a uint32 from the stream and stores it in 'data'. + OsclBinIStreamLittleEndian & operator>>(uint32 & data); + + protected: + + /* + ** Description: + ** Reads an unsigned short from the stream. + ** + ** Returns: Unsigned short read from the stream. + ** Side effects: None. + */ + uint16 Read_uint16(); + /* + ** Description: + ** Reads an unsigned long from the stream. + ** + ** Returns: Unsigned long read from the stream. + ** Side effects: None. + */ + uint32 Read_uint32(); +}; + + +/* +** Class OsclBinIStreamBigEndian +** This class implements a binary input stream using big endian byte ordering +*/ +class OsclBinIStreamBigEndian : public OsclBinIStream +{ + public: + OsclBinIStreamBigEndian() + { + } + + void Read(int8 & data); + + void Read(uint8 & data); + + void Read(int16 & data); + + void Read(uint16 & data); + + void Read(int32 & data); + + void Read(uint32 & data); + + //! This method reads a int8 from the stream and stores it in 'data'. + OsclBinIStreamBigEndian & operator>>(int8 & data); + + //! This method reads a uint8 from the stream and stores it in 'data'. + OsclBinIStream & operator>>(uint8 & data); + + //! This method reads a int16 from the stream and stores it in 'data'. + OsclBinIStreamBigEndian & operator>>(int16 & data); + + //! This method reads a uint16 from the stream and stores it in 'data'. + OsclBinIStreamBigEndian & operator>>(uint16 & data); + + //! This method reads a int32 from the stream and stores it in 'data'. + OsclBinIStreamBigEndian & operator>>(int32 & data); + + //! This method reads a uint32 from the stream and stores it in 'data'. + OsclBinIStreamBigEndian & operator>>(uint32 & data); + + //! This method reads an unsigned short from the stream. + /*! + \return Unsigned short read from the stream. + */ + uint16 Read_uint16(); + + //! This method reads an unsigned long from the stream. + /*! + \return unsigned long read from the stream. + */ + uint32 Read_uint32(); + protected: + +}; + + +//! Class OsclBinOStream implements the basic stream functions for an output stream. +class OsclBinOStream : public OsclBinStream +{ + public: + OsclBinOStream() + { + } + + virtual ~OsclBinOStream() + { + } + + //! This method writes 'length' number of bytes stored in 'data' to the stream. + OsclBinOStream & write( + const int8 * data, /* data to store */ + int32 size /* length of data to store */ + ); + + protected: +}; + +//! Class OsclBinOStreamLittleEndian implements a binary output stream using little endian byte ordering +class OsclBinOStreamLittleEndian : public OsclBinOStream +{ + public: + OsclBinOStreamLittleEndian() + { + } + + //! This method writes a int8 from 'data' to the stream. + OsclBinOStreamLittleEndian & operator<<(const int8 & data); + + //!This method writes a uint8 from 'data' to the stream. + OsclBinOStreamLittleEndian & operator<<(const uint8 & data); + + //! This method writes a int16 from 'data' to the stream. + OsclBinOStreamLittleEndian & operator<<(const int16 & data); + + //! This method writes a uint16 from 'data' to the stream. + OsclBinOStreamLittleEndian & operator<<(const uint16 & data); + + //! This method writes a int32 from 'data' to the stream. + OsclBinOStreamLittleEndian & operator<<(const int32 & data); + + //! This method writes a uint32 from 'data' to the stream. + OsclBinOStreamLittleEndian & operator<<(const uint32 & data); + + protected: + + //! This method writes 'data' (unsigned short) to the stream. + void WriteUnsignedShort(const uint16 data); + + //! This method writes 'data' (unsigned long) to the stream. + void WriteUnsignedLong(const uint32 data); + +}; + + +//! Class OsclBinOStreamBigEndian implements a binary output stream using big endian byte ordering +class OsclBinOStreamBigEndian : public OsclBinOStream +{ + public: + OsclBinOStreamBigEndian() + { + } + + //! This method writes a int8 from 'data' to the stream. + OsclBinOStreamBigEndian & operator<<(const int8 & data); + + //! This method writes a uint8 from 'data' to the stream. + OsclBinOStreamBigEndian & operator<<(const uint8 & data); + + //! This method writes a int16 from 'data' to the stream. + OsclBinOStreamBigEndian & operator<<(const int16 & data); + + //! This method writes a uint16 from 'data' to the stream. + OsclBinOStreamBigEndian & operator<<(const uint16 & data); + + //! This method writes a int32 from 'data' to the stream. + OsclBinOStreamBigEndian & operator<<(const int32 & data); + + //! This method writes a uint32 from 'data' to the stream. + OsclBinOStreamBigEndian & operator<<(const uint32 & data); + + protected: + + /* + ** Description: + ** Writes 'data' (unsigned short) to the stream. + ** + ** Returns: None. + ** Side effects: None. + */ + void WriteUnsignedShort(const uint16 data); + + /* + ** Description: + ** Writes 'data' (unsigned long) to the stream. + ** + ** Returns: None. + ** Side effects: None. + */ + void WriteUnsignedLong(const uint32 data); +}; + +#if (!OSCL_DISABLE_INLINES) +#include "oscl_bin_stream.inl" +#endif + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_bin_stream.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_bin_stream.inl new file mode 100644 index 0000000..bcd29bb --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_bin_stream.inl @@ -0,0 +1,689 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ B I N _ S T R E A M + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/* +** Constants +*/ + +const static int16 NO_BITS_IN_BYTE = 8; +const static uint8 BYTE_MASK = 0xff; + +#include "oscl_mem_basic_functions.h" + +OSCL_INLINE bool OsclBinStream::good() +{ + return state == GOOD_STATE; +} + +OSCL_INLINE bool OsclBinStream::eof() +{ + return state == EOF_STATE; +} + +OSCL_INLINE bool OsclBinStream::fail() +{ + return state == FAIL_STATE; +} + +OSCL_INLINE void OsclBinStream::Attach(void * buffer, uint32 l_length) +{ + fragsLeft = 0; + pBasePosition = (uint8 *)buffer; + pPosition = pBasePosition; + length = l_length; + state = GOOD_STATE; + specialFragBuffer.ptr = buffer; + specialFragBuffer.len = l_length; + numFrags = 1; + firstFragPtr = &specialFragBuffer; +} + +OSCL_INLINE void OsclBinStream::Attach(const uint32 numFragments, const OsclMemoryFragment * fragPtr) +{ + pBasePosition = (uint8 *)fragPtr->ptr; + pPosition = pBasePosition; + numFrags = numFragments; + firstFragPtr = fragPtr; + length = fragPtr->len; + if (numFragments > 1) + { + fragsLeft = numFragments - 1; + nextFragPtr = fragPtr + 1; + } + else + { + fragsLeft = 0; + } + state = GOOD_STATE; +} + +OSCL_INLINE uint32 OsclBinStream::tellg() +{ + uint32 pos = 0; + for (int ii = 0; ii < numFrags - fragsLeft - 1; ii++) + { + pos += firstFragPtr[ii].len; + } + pos += PositionInBlock(); + + return pos; +} + +OSCL_INLINE void OsclBinStream::Seek(uint32 absPosition) +{ + uint32 pos = 0; + int fragIndex; + + for (fragIndex = 0; + fragIndex < numFrags && absPosition >= pos + firstFragPtr[fragIndex].len; + fragIndex++) + { + pos += firstFragPtr[fragIndex].len; + } + + if (fragIndex >= numFrags) + { + fragsLeft = 0; + pBasePosition = (uint8 *)firstFragPtr[numFrags-1].ptr; + length = firstFragPtr[numFrags-1].len; + pPosition = pBasePosition + length; + if (absPosition == pos) + { + state = EOF_STATE; + } + else + { + state = FAIL_STATE; + } + return; + } + + // otherwise there is more data + nextFragPtr = &firstFragPtr[fragIndex + 1]; + fragsLeft = numFrags - fragIndex - 1; + pBasePosition = (uint8 *)firstFragPtr[fragIndex].ptr; + length = firstFragPtr[fragIndex].len; + uint32 reqBytes = absPosition - pos; + if (reqBytes <= length) + { + pPosition = pBasePosition + reqBytes; + } + else + { + pPosition = pBasePosition + length; + state = FAIL_STATE; + } +} + +OSCL_INLINE uint32 OsclBinStream::PositionInBlock() +{ + return pPosition - pBasePosition; +} + +OSCL_INLINE void OsclBinStream::seekFromCurrentPosition(int32 offset) +{ + Seek(tellg() + offset); +} + +OSCL_INLINE bool OsclBinStream::ReserveSpace(uint32 size) +{ + if (fail()) + { + return false; + } + uint32 newSize = PositionInBlock() + size; + if (newSize > length) + { + state = FAIL_STATE; + return false; + } + if (newSize == length) + { + state = EOF_STATE; + } + return true; +} + +OSCL_INLINE bool OsclBinStream::HaveRoomInCurrentBlock(uint32 size) +{ + uint32 pos = PositionInBlock() + size; + if (pos < length) + { + return true; + } + if (pos == length && fragsLeft == 0) + { + state = EOF_STATE; + } + return (pos <= length); +} + +/* +** Class OsclBinIStream +** This class implements the basic stream functions for an input stream. +*/ +OSCL_INLINE uint8 OsclBinIStream::Read_uint8() +{ + if (HaveRoomInCurrentBlock(sizeof(uint8))) + { + return (*pPosition++); + } + if (fragsLeft) + { + pBasePosition = (uint8 *)nextFragPtr->ptr; + pPosition = pBasePosition; + length = nextFragPtr->len; + fragsLeft--; + nextFragPtr++; + return (*pPosition++); + } + state = FAIL_STATE; + return 0; +} + +OSCL_INLINE OsclBinIStream & OsclBinIStream::get( + int8 * data, /* Pointer to the place to store the bytes read */ + int32 size /* Number of bytes to read */ +) +{ + if (HaveRoomInCurrentBlock(size)) + { + oscl_memcpy(data, pPosition, size); + pPosition += size; + } + else + { + uint32 pos = PositionInBlock(); + uint32 bytesToCopy = length - pos; + oscl_memcpy(data, pPosition, bytesToCopy); + data += bytesToCopy; + uint32 bytesLeft = size - bytesToCopy; + while (bytesLeft > 0 && fragsLeft) + { + pBasePosition = (uint8 *)nextFragPtr->ptr; + pPosition = pBasePosition; + length = nextFragPtr->len; + fragsLeft--; + nextFragPtr++; + + if (bytesLeft <= length) + { + bytesToCopy = bytesLeft; + } + else + { + bytesToCopy = length; + } + + oscl_memcpy(data, pPosition, bytesToCopy); + data += bytesToCopy; + pPosition += bytesToCopy; + bytesLeft -= bytesToCopy; + } + } + return *this; +} + +/* +** Class OsclBinIStreamLittleEndian +** This class implements a binary input stream using little endian byte ordering +*/ +OSCL_INLINE OsclBinIStreamLittleEndian & OsclBinIStreamLittleEndian::operator>>(int8 & data) +{ + data = int8(Read_uint8()); + return *this; +} + +OSCL_INLINE OsclBinIStreamLittleEndian & OsclBinIStreamLittleEndian::operator>>(uint8 & data) +{ + data = Read_uint8(); + return *this; +} + +OSCL_INLINE OsclBinIStreamLittleEndian & OsclBinIStreamLittleEndian::operator>>(int16 & data) +{ + data = int16(Read_uint16()); + + return *this; +} + +OSCL_INLINE OsclBinIStreamLittleEndian & OsclBinIStreamLittleEndian::operator>>(uint16 & data) +{ + data = Read_uint16(); + + return *this; +} + +OSCL_INLINE OsclBinIStreamLittleEndian & OsclBinIStreamLittleEndian::operator>>(int32 & data) +{ + data = int32(Read_uint32()); + return *this; +} + +OSCL_INLINE OsclBinIStreamLittleEndian & OsclBinIStreamLittleEndian::operator>>(uint32 & data) +{ + data = Read_uint32(); + return *this; +} + +OSCL_INLINE uint16 OsclBinIStreamLittleEndian::Read_uint16() +{ + if (HaveRoomInCurrentBlock(sizeof(uint16))) + { +#if defined(BYTE_ORDER_LITTLE_ENDIAN) && !defined(INTEGERS_WORD_ALIGNED) + uint16 *ptr = (uint16 *)pPosition; + pPosition += sizeof(uint16); + return *ptr; +#else + uint16 byteB = *pPosition++; + uint16 byteA = *pPosition++; + + return ((byteA << NO_BITS_IN_BYTE) | byteB); +#endif + } + else + { + uint16 byteB = Read_uint8(); + uint16 byteA = Read_uint8(); + return ((byteA << NO_BITS_IN_BYTE) | byteB); + } +} + +OSCL_INLINE uint32 OsclBinIStreamLittleEndian::Read_uint32() +{ + if (HaveRoomInCurrentBlock(sizeof(uint32))) + { +#if defined(BYTE_ORDER_LITTLE_ENDIAN) && !defined(INTEGERS_WORD_ALIGNED) + uint32 *ptr = (uint32 *)pPosition; + pPosition += sizeof(uint32); + return *ptr; +#else + uint32 result; + uint8 byteD = *pPosition++; + uint8 byteC = *pPosition++; + uint8 byteB = *pPosition++; + uint8 byteA = *pPosition++; + + result = byteA; + result = (result << NO_BITS_IN_BYTE) | byteB; + result = (result << NO_BITS_IN_BYTE) | byteC; + result = (result << NO_BITS_IN_BYTE) | byteD; + + return result; +#endif + } + else + { + uint32 result; + uint8 byteD = Read_uint8(); + uint8 byteC = Read_uint8(); + uint8 byteB = Read_uint8(); + uint8 byteA = Read_uint8(); + + result = byteA; + result = (result << NO_BITS_IN_BYTE) | byteB; + result = (result << NO_BITS_IN_BYTE) | byteC; + result = (result << NO_BITS_IN_BYTE) | byteD; + + return result; + } +} + + + +/* +** Class OsclBinIStreamBigEndian +** This class implements a binary input stream using big endian byte ordering +*/ +OSCL_INLINE void OsclBinIStreamBigEndian::Read(int8 & data) +{ + data = int8(Read_uint8()); +} + +OSCL_INLINE void OsclBinIStreamBigEndian::Read(uint8 & data) +{ + data = Read_uint8(); +} + +OSCL_INLINE void OsclBinIStreamBigEndian::Read(int16 & data) +{ + data = int16(Read_uint16()); +} + +OSCL_INLINE void OsclBinIStreamBigEndian::Read(uint16 & data) +{ + data = Read_uint16(); +} + +OSCL_INLINE void OsclBinIStreamBigEndian::Read(int32 & data) +{ + data = int32(Read_uint32()); +} + +OSCL_INLINE void OsclBinIStreamBigEndian::Read(uint32 & data) +{ + data = Read_uint32(); +} + +OSCL_INLINE OsclBinIStreamBigEndian & OsclBinIStreamBigEndian::operator>>(int8 & data) +{ + data = int8(Read_uint8()); + return *this; +} + +OSCL_INLINE OsclBinIStream & OsclBinIStreamBigEndian::operator>>(uint8 & data) +{ + data = Read_uint8(); + return *this; +} + +OSCL_INLINE OsclBinIStreamBigEndian & OsclBinIStreamBigEndian::operator>>(int16 & data) +{ + data = int16(Read_uint16()); + return *this; +} + +OSCL_INLINE OsclBinIStreamBigEndian & OsclBinIStreamBigEndian::operator>>(uint16 & data) +{ + data = Read_uint16(); + return *this; +} + +OSCL_INLINE OsclBinIStreamBigEndian & OsclBinIStreamBigEndian::operator>>(int32 & data) +{ + data = int32(Read_uint32()); + return *this; +} + +OSCL_INLINE OsclBinIStreamBigEndian & OsclBinIStreamBigEndian::operator>>(uint32 & data) +{ + data = Read_uint32(); + return *this; +} + +OSCL_INLINE uint16 OsclBinIStreamBigEndian::Read_uint16() +{ + if (HaveRoomInCurrentBlock(sizeof(uint16))) + { +#if defined(BYTE_ORDER_BIG_ENDIAN) && !defined(INTEGERS_WORD_ALIGNED) + uint16 *ptr = (uint16 *)pPosition; + pPosition += sizeof(uint16); + return *ptr; +#else + uint16 byteA = *pPosition++; + uint16 byteB = *pPosition++; + + return ((byteA << NO_BITS_IN_BYTE) | byteB); +#endif + } + else + { + uint16 byteA = Read_uint8(); + uint16 byteB = Read_uint8(); + + return ((byteA << NO_BITS_IN_BYTE) | byteB); + } +} + +OSCL_INLINE uint32 OsclBinIStreamBigEndian::Read_uint32() +{ + if (HaveRoomInCurrentBlock(sizeof(uint32))) + { +#if defined(BYTE_ORDER_BIG_ENDIAN) && !defined(INTEGERS_WORD_ALIGNED) + uint32 *ptr = (uint32 *)pPosition; + pPosition += sizeof(uint32); + return *ptr; +#else + uint32 result; + + result = *pPosition++; + result = (result << NO_BITS_IN_BYTE) | *pPosition++; + result = (result << NO_BITS_IN_BYTE) | *pPosition++; + result = (result << NO_BITS_IN_BYTE) | *pPosition++; + + return result; +#endif + } + else + { + uint32 result; + + result = Read_uint8(); + result = (result << NO_BITS_IN_BYTE) | Read_uint8(); + result = (result << NO_BITS_IN_BYTE) | Read_uint8(); + result = (result << NO_BITS_IN_BYTE) | Read_uint8(); + + return result; + } +} + + +/* +** Class OsclBinOStream +** This class implements the basic stream functions for an output stream. +*/ + +OSCL_INLINE OsclBinOStream & OsclBinOStream::write( + const int8 * data, /* data to store */ + int32 size /* length of data to store */ +) +{ + if (ReserveSpace(size)) + { + oscl_memcpy(pPosition, data, size); + pPosition += size; + } + return *this; +} + +/* +** Class OsclBinOStreamLittleEndian +** This class implements a binary output stream using little endian byte ordering +*/ +OSCL_INLINE OsclBinOStreamLittleEndian & OsclBinOStreamLittleEndian::operator<<(const int8 & data) +{ + if (ReserveSpace(sizeof(data))) + { + *((int8 *)pPosition) = data; + pPosition++; + } + return *this; +} + +OSCL_INLINE OsclBinOStreamLittleEndian & OsclBinOStreamLittleEndian::operator<<(const uint8 & data) +{ + if (ReserveSpace(sizeof(data))) + { + *pPosition++ = data; + } + return *this; +} + +OSCL_INLINE OsclBinOStreamLittleEndian & OsclBinOStreamLittleEndian::operator<<(const int16 & data) +{ + if (ReserveSpace(sizeof(data))) + { + WriteUnsignedShort((uint16)data); + } + + return *this; +} + +OSCL_INLINE OsclBinOStreamLittleEndian & OsclBinOStreamLittleEndian::operator<<(const uint16 & data) +{ + if (ReserveSpace(sizeof(data))) + { + WriteUnsignedShort(data); + } + return *this; +} + +OSCL_INLINE OsclBinOStreamLittleEndian & OsclBinOStreamLittleEndian::operator<<(const int32 & data) +{ + if (ReserveSpace(sizeof(data))) + { + WriteUnsignedLong(uint32(data)); + } + + return *this; +} + +OSCL_INLINE OsclBinOStreamLittleEndian & OsclBinOStreamLittleEndian::operator<<(const uint32 & data) +{ + if (ReserveSpace(sizeof(data))) + { + WriteUnsignedLong(data); + } + + return *this; +} + +OSCL_INLINE void OsclBinOStreamLittleEndian::WriteUnsignedShort(const uint16 data) +{ +#if defined(BYTE_ORDER_LITTLE_ENDIAN) && !defined(INTEGERS_WORD_ALIGNED) + uint16 *ptr = (uint16 *)pPosition; + pPosition += sizeof(uint16); + *ptr = data; +#else + uint8 byteB = (uint8)data; + uint8 byteA = data >> NO_BITS_IN_BYTE; + + *pPosition++ = byteB; + *pPosition++ = byteA; +#endif +} + +OSCL_INLINE void OsclBinOStreamLittleEndian::WriteUnsignedLong(const uint32 data) +{ +#if defined(BYTE_ORDER_LITTLE_ENDIAN) && !defined(INTEGERS_WORD_ALIGNED) + uint32 *ptr = (uint32 *)pPosition; + pPosition += sizeof(uint32); + *ptr = data; +#else + uint32 temp = data; + *pPosition++ = (uint8)temp; + temp >>= NO_BITS_IN_BYTE; + *pPosition++ = (uint8)temp; + temp >>= NO_BITS_IN_BYTE; + *pPosition++ = (uint8)temp; + temp >>= NO_BITS_IN_BYTE; + *pPosition++ = (uint8)temp; +#endif +} + + +OSCL_INLINE OsclBinOStreamBigEndian & OsclBinOStreamBigEndian::operator<<(const int8 & data) +{ + if (ReserveSpace(sizeof(data))) + { + *((int8 *)pPosition) = data; + pPosition++; + } + + return *this; +} + +OSCL_INLINE OsclBinOStreamBigEndian & OsclBinOStreamBigEndian::operator<<(const uint8 & data) +{ + if (ReserveSpace(sizeof(data))) + { + *pPosition++ = data; + } + return *this; +} + +OSCL_INLINE OsclBinOStreamBigEndian & OsclBinOStreamBigEndian::operator<<(const int16 & data) +{ + if (ReserveSpace(sizeof(data))) + { + WriteUnsignedShort((uint16)data); + } + return *this; +} + +OSCL_INLINE OsclBinOStreamBigEndian & OsclBinOStreamBigEndian::operator<<(const uint16 & data) +{ + if (ReserveSpace(sizeof(data))) + { + WriteUnsignedShort(data); + } + return *this; +} + +OSCL_INLINE OsclBinOStreamBigEndian & OsclBinOStreamBigEndian::operator<<(const int32 & data) +{ + if (ReserveSpace(sizeof(data))) + { + WriteUnsignedLong(uint32(data)); + } + return *this; +} + +OSCL_INLINE OsclBinOStreamBigEndian & OsclBinOStreamBigEndian::operator<<(const uint32 & data) +{ + if (ReserveSpace(sizeof(data))) + { + WriteUnsignedLong(data); + } + + return *this; +} + +OSCL_INLINE void OsclBinOStreamBigEndian::WriteUnsignedShort(const uint16 data) +{ +#if defined(BYTE_ORDER_BIG_ENDIAN) && !defined(INTEGERS_WORD_ALIGNED) + uint16 *ptr = (uint16 *)pPosition; + pPosition += sizeof(uint16); + *ptr = data; +#else + uint8 byteB = (uint8)data; + uint8 byteA = data >> NO_BITS_IN_BYTE; + + *pPosition++ = byteA; + *pPosition++ = byteB; +#endif +} + +OSCL_INLINE void OsclBinOStreamBigEndian::WriteUnsignedLong(const uint32 data) +{ +#if defined(BYTE_ORDER_BIG_ENDIAN) && !defined(INTEGERS_WORD_ALIGNED) + uint32 *ptr = (uint32 *)pPosition; + pPosition += sizeof(uint32); + *ptr = data; +#else + uint32 temp = data; + uint8 byteD = (uint8)temp; + temp >>= NO_BITS_IN_BYTE; + uint8 byteC = (uint8)temp; + temp >>= NO_BITS_IN_BYTE; + uint8 byteB = (uint8)temp; + temp >>= NO_BITS_IN_BYTE; + uint8 byteA = (uint8)temp; + + *pPosition++ = byteA; + *pPosition++ = byteB; + *pPosition++ = byteC; + *pPosition++ = byteD; +#endif +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_math.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_math.cpp new file mode 100644 index 0000000..16ab22e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_math.cpp @@ -0,0 +1,23 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_math.h" + +#if (OSCL_DISABLE_INLINES) +#include "oscl_math.inl" +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_math.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_math.h new file mode 100644 index 0000000..20f0229 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_math.h @@ -0,0 +1,129 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M A T H + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/*! + * \file oscl_math.h + * \brief Provides math functions. + * + */ + +#ifndef OSCL_MATH_H_INCLUDED +#define OSCL_MATH_H_INCLUDED + +#ifndef OSCLCONFIG_UTIL_H_INCLUDED +#include "osclconfig_util.h" +#endif + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +/** + * Calculates the natural log of a number + * + * @param value source value + */ +OSCL_COND_IMPORT_REF double oscl_log(double value); +/** + * Calculates tthe logarithm to base 10 of a number + * + * @param value source value + */ +OSCL_COND_IMPORT_REF double oscl_log10(double value); +/** + * Calculates the square root of a number + * + * @param value source value + */ +OSCL_COND_IMPORT_REF double oscl_sqrt(double value); +/** + * Calculates the value of x to the power of y + * + * @param x base value + * @param y power + */ +OSCL_COND_IMPORT_REF double oscl_pow(double x, double y); +/** + * Calculates the exponential of e for a number + * + * @param value source value + */ +OSCL_COND_IMPORT_REF double oscl_exp(double value); + +/** + * Calculates the sine of a number + * + * @param value source value + */ +OSCL_COND_IMPORT_REF double oscl_sin(double value); + +/** + * Calculates the cosine of a number + * + * @param value source value + */ +OSCL_COND_IMPORT_REF double oscl_cos(double value); + +/** + * Calculates the tangential of a number + * + * @param value source value + */ +OSCL_COND_IMPORT_REF double oscl_tan(double value); + +/** + * Calculates the arc since of a number + * + * @param value source value + */ +OSCL_COND_IMPORT_REF double oscl_asin(double value); + +/** + * Calculates the arc tangent of a number + * + * @param value source value + */ +OSCL_COND_IMPORT_REF double oscl_atan(double value); + +/** + * Calculates the floor of a number + * + * @param value source value + */ +OSCL_COND_IMPORT_REF double oscl_floor(double value); + +#if (!OSCL_DISABLE_INLINES) +#include "oscl_math.inl" +#endif + +#endif + +/*! @} */ + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_math.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_math.inl new file mode 100644 index 0000000..a93143e --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_math.inl @@ -0,0 +1,72 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_log(double value) +{ + return (double) log(value); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_log10(double value) +{ + return (double) log10(value); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_sqrt(double value) +{ + return (double) sqrt(value); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_pow(double x, double y) +{ + return (double) pow(x, y); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_exp(double value) +{ + return (double) exp(value); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_sin(double value) +{ + return (double) sin(value); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_cos(double value) +{ + return (double) cos(value); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_tan(double value) +{ + return (double) tan(value); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_asin(double value) +{ + return (double) asin(value); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_atan(double value) +{ + return (double) atan(value); +} + +OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_floor(double value) +{ + return (double) floor(value); +} diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_media_data.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_media_data.h new file mode 100644 index 0000000..17863ba --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_media_data.h @@ -0,0 +1,457 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M E D I A _ D A T A + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/** \file oscl_media_data.h + \brief Defines a container class for media data made up of a collection of memory fragments. +*/ + +#ifndef OSCL_MEDIA_DATA_H +#define OSCL_MEDIA_DATA_H + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_MEM_BASIC_FUNCTIONS_H_INCLUDED +#include "oscl_mem_basic_functions.h" +#endif + +#ifndef OSCL_MEDIA_STATUS_H_INCLUDED +#include "oscl_media_status.h" +#endif + +typedef void (*BufferFreeFuncPtr)(void *); + +typedef uint32 MediaTimestamp; + +template class MemAllocator +{ + public: + typedef T* pointer; + // virtual pointer allocate(size_t size, void *hint = 0) = 0; + virtual pointer allocate(void * hint = 0, const int num_reserved_frags = 1) = 0; + virtual void deallocate(pointer p) = 0; + virtual ~MemAllocator() {} +}; + +class BufferState; +/* Buffer referee (how about the "whistle blower" ?*/ +class BufferMgr +{ + public: + virtual void BufferReleased(void* ptr, BufferState* state = NULL) = 0; + virtual ~BufferMgr() {} +}; + + +class BufferState +{ + public: + BufferState(BufferFreeFuncPtr the_free_function, void *bufptr = 0) : + refcount(0), ptr(bufptr), free_function(the_free_function), buf_mgr(0) {}; + + BufferState(BufferMgr* the_buf_mgr = 0, void *bufptr = 0) : + refcount(0), ptr(bufptr), free_function(0), buf_mgr(the_buf_mgr) {}; + + void increment_refcnt() + { + ++refcount; + }; + void decrement_refcnt() + { + if (!(--refcount)) + { + if (buf_mgr) buf_mgr->BufferReleased(ptr, this); + else if (free_function) + { + free_function(ptr); + ptr = 0; + } + } + }; + + void bind(void *in_ptr, BufferFreeFuncPtr in_free_function) + { + refcount = 0; + ptr = in_ptr, free_function = in_free_function; + + }; + void bind(void *in_ptr, BufferMgr* in_buf_mgr) + { + refcount = 0; + ptr = in_ptr, buf_mgr = in_buf_mgr; + }; + + void *get_ptr() + { + return ptr; + }; + int32 get_refcount() + { + return refcount; + }; + + BufferFreeFuncPtr get_free_function() + { + return free_function; + }; + BufferMgr* get_buf_mgr() + { + return buf_mgr; + }; + + void reset() + { + refcount = 0; + ptr = 0; + }; + + private: + int32 refcount; + void *ptr; + BufferFreeFuncPtr free_function; // called to free the buffer + BufferMgr* buf_mgr; // called to free the buffer +}; + + +// BufferFragment is a special case of a memory +// fragment since it refers to fragments of a reference +// counted memory. The name is used to make this explicit. +class BufferFragment : public OsclMemoryFragment {}; + + +template class BufFragGroup +{ + public: + + + BufFragGroup(): next(0), num_fragments(0), length(0) + { + oscl_memset(fragments, 0, sizeof(fragments)); + oscl_memset(buffer_states, 0, sizeof(buffer_states)); + }; + + virtual ~BufFragGroup() {} + + int32 GetMaxFrags() const + { + return max_frags; + }; + int32 GetNumFrags() const + { + return num_fragments; + }; + uint32 GetLength() const + { + return length; + }; + + BufferFragment * GetFragment(const int32 idx); + + BufferState * GetBufferState(const int32 idx); + + void AppendNext(ChainClass* next_ptr) + { + next = next_ptr; + }; + ChainClass* GetNext() const + { + return next; + }; + + // make fragment array accessible to allow usage within socket + // send functions. + + protected: + + + // BufferFragment * GetFragment(const uint32 idx) const; + + + + virtual void Clear() + { + for (uint ii = 0 ; ii < num_fragments; ++ii) + { + if (buffer_states[ii]) + { + buffer_states[ii]->decrement_refcnt(); + } + } + num_fragments = length = 0; + oscl_memset(buffer_states, 0, sizeof(buffer_states)); + oscl_memset(fragments, 0, sizeof(fragments)); + }; + + BufFragStatusClass::status_t AddFragment(const BufferFragment& frag, BufferState* in_buffer_state, + int32 location_offset = max_frags) + { + if (num_fragments >= max_frags) + { + return BufFragStatusClass::TOO_MANY_FRAGS; + } + if (frag.ptr == NULL) + { + return BufFragStatusClass::EMPTY_FRAGMENT; + } + + if (location_offset >= 0 && location_offset < (int32) num_fragments) + { + if (fragments[location_offset].ptr) + { + // make room for the new fragment + oscl_memmove(fragments + location_offset + 1, fragments + location_offset, + (num_fragments - location_offset)*sizeof(BufferFragment)); + oscl_memmove(buffer_states + location_offset + 1, buffer_states + location_offset, + (num_fragments - location_offset)*sizeof(BufferState*)); + ++num_fragments; /* increment the number of fragments if a move + * is necessary. If the location was empty, then + * has already been reserved and counted. + */ + } + fragments[location_offset] = frag; + buffer_states[location_offset] = in_buffer_state; + if (in_buffer_state) in_buffer_state->increment_refcnt(); + length += frag.len; + return BufFragStatusClass::BFG_SUCCESS; + } + + // append the new fragment to the end + fragments[num_fragments] = frag; + buffer_states[num_fragments++] = in_buffer_state; + length += frag.len; + if (in_buffer_state) in_buffer_state->increment_refcnt(); + return BufFragStatusClass::BFG_SUCCESS; + }; + + BufferFragment fragments[max_frags]; + BufferState* buffer_states[max_frags]; + ChainClass* next; + uint32 num_fragments; + uint32 length; +}; + +template inline BufferFragment * BufFragGroup :: GetFragment(const int32 idx) +{ + if (idx < (int)num_fragments && idx >= 0) + { + return & fragments[idx]; + } + else + { + return NULL; + } +} + +template inline BufferState * BufFragGroup :: GetBufferState(const int32 idx) +{ + if (idx < (int)num_fragments && idx >= 0) + { + return buffer_states[idx]; + } + else + { + return NULL; + } +} + + +template class MediaData : + public BufFragGroup +{ + + public: + MediaData(): timestamp(0), available_localbuf(local_bufsize), num_reserved_fragments(0) {}; + + virtual ~MediaData() {} + + uint32 GetLocalBufsize() const + { + return local_bufsize; + }; + MediaTimestamp GetTimestamp() const + { + return timestamp; + }; + void SetTimestamp(MediaTimestamp in_timestamp) + { + timestamp = in_timestamp; + }; + uint32 GetAvailableBufferSize() const + { + return available_localbuf; + }; + + + + // The input should be initialized so that the fragment length is the + // request size. The returned value will have a non-NULL pointer if the + // request could be fulfilled. + MediaStatusClass::status_t GetLocalFragment(BufferFragment& fragment) + { + if (fragment.len > available_localbuf) + { + fragment.ptr = NULL; + fragment.len = available_localbuf; + return MediaStatusClass::NOT_ENOUGH_SPACE; + } + + fragment.ptr = localbuf + (local_bufsize - available_localbuf); + available_localbuf -= fragment.len; + return MediaStatusClass::BFG_SUCCESS; + }; + + virtual void Clear() + { + for (uint ii = 0 ; ii < this->num_fragments; ++ii) + { + if (this->buffer_states[ii]) + { + this->buffer_states[ii]->decrement_refcnt(); + } + } + this->num_fragments = 0; + this->length = 0; + oscl_memset(this->buffer_states, 0, sizeof(this->buffer_states)); + oscl_memset(this->fragments, 0, sizeof(this->fragments)); + this->available_localbuf = local_bufsize; + }; + + + bool IsLocalData(const OsclMemoryFragment& frag) const + { + if (frag.ptr == NULL) + return true; + if ((uint8 *)frag.ptr >= localbuf) + { + if (((uint8 *)frag.ptr) + frag.len < localbuf + local_bufsize) + { + return true; + } + return false; + } + return false; + } + + int GetMediaSize() const + { + int num_reserved = 0; + for (int ii = 0; ii < num_reserved_fragments; ii++) + num_reserved += this->fragments[ii].len; + + return (this->length - num_reserved); + } + + BufferFragment * GetMediaFragment(const uint32 idx) + { + uint32 tmp = idx + this->num_reserved_fragments; + if (tmp > this->num_fragments) + { + return NULL; + } + else + { + return & this->fragments[tmp]; + } + } + + uint32 GetNumMediaFrags(const uint32 idx) const + { + if (this->num_fragments >= this->num_reserved_fragments) + return this->num_fragments - this->num_reserved_fragments; + else return 0; + } + + protected: + // This function copies the fragment data to the local buffer + MediaStatusClass::status_t AddLocalFragment(const BufferFragment& frag, + int32 location_offset) + { + + if (this->num_fragments >= max_frags) + { + return MediaStatusClass::TOO_MANY_FRAGS; + } + + if (frag.ptr == NULL || frag.len == 0) + { + return MediaStatusClass::EMPTY_FRAGMENT; + } + + // see if there is enough room in the local buffer + if (frag.len > available_localbuf) + { + return MediaStatusClass::NOT_ENOUGH_SPACE; + } + + // get the fragment + BufferFragment local_fragment; + local_fragment.len = frag.len; + local_fragment.ptr = localbuf + (local_bufsize - available_localbuf); + available_localbuf -= frag.len; + this->length += frag.len; + + oscl_memcpy(local_fragment.ptr, frag.ptr, frag.len*sizeof(uint8)); + + if (location_offset >= 0 && location_offset < (int32) this->num_fragments) + { + if (this->fragments[location_offset].ptr) + { + // make room for the new fragment + oscl_memmove(this->fragments + location_offset + 1, this->fragments + location_offset, + (this->num_fragments - location_offset)*sizeof(BufferFragment)); + oscl_memmove(this->buffer_states + location_offset + 1, this->buffer_states + location_offset, + (this->num_fragments - location_offset)*sizeof(BufferState*)); + ++this->num_fragments; /* increment the number of fragments if a move + * is necessary. If the location was empty, then + * has already been reserved and counted. + */ + } + this->fragments[location_offset] = local_fragment; + this->buffer_states[location_offset] = NULL; + return MediaStatusClass::BFG_SUCCESS; + } + + // append the new fragment to the end + this->fragments[this->num_fragments] = local_fragment; + this->buffer_states[this->num_fragments++] = NULL; + return MediaStatusClass::BFG_SUCCESS; + }; + + MediaTimestamp timestamp; + uint8 localbuf[local_bufsize]; + uint32 available_localbuf; + + int num_reserved_fragments; +}; + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_media_status.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_media_status.h new file mode 100644 index 0000000..9297e68 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_media_status.h @@ -0,0 +1,61 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ M E D I A _ S T A T U S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/** \file oscl_media_status.h + \brief Defines a status values for the MediaData containers. +*/ + +#ifndef OSCL_MEDIA_STATUS_H +#define OSCL_MEDIA_STATUS_H + + +const int32 APPEND_MEDIA_AT_END = -1; + +class BufFragStatusClass +{ + public: + typedef enum + { + BFG_SUCCESS = 0, + TOO_MANY_FRAGS = 1, + NOT_ENOUGH_SPACE = 2, + EMPTY_FRAGMENT = 3, + NULL_INPUT = 4, + FIXED_FRAG_LOC_FULL = 5, + INTERNAL_ERROR, + INVALID_ID + } status_t; +}; + +class MediaStatusClass : public BufFragStatusClass {}; + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_priqueue.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_priqueue.cpp new file mode 100644 index 0000000..eb4cff6 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_priqueue.cpp @@ -0,0 +1,133 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/*! + * \file oscl_priqueue.cpp + * \brief Implements a priority queue data structure similar to STL. + * + * + */ + +#include "oscl_priqueue.h" + + +OSCL_EXPORT_REF void OsclPriorityQueueBase::push_heap(OsclAny* first, OsclAny* last) +{ + /* + * The task of the push_heap function is to take the last + * entry and continue to swap it with its parent until + * the heap property is statisfied (i.e., all children are not + * greater than the parent). It is assumed that the new value + * has already been pushed on the end of the container. The + * first and last arguments should be the begin() and end() iterators + * of the container. + */ + + int index = delta_T(first, last) - 1; + int parent_index = (index - 1) / 2; + while (index > 0 && pOpaqueType->compare_LT(pVec->increment_T(first, parent_index), pVec->increment_T(first, index))) + { + // swap the current index and the parent + pOpaqueType->swap(pVec->increment_T(first, index), pVec->increment_T(first, parent_index)); + index = parent_index; + parent_index = (index - 1) / 2; + } +} + +OSCL_EXPORT_REF void OsclPriorityQueueBase::pop_heap(OsclAny* first, OsclAny* last) +{ + + /* This function works by swapping the first and last values in + * the container and then pushes down the top element until the + * parent-child relationship is satisfied (i.e., parent not less than + * either of its children + */ + + // swap the first and last values + pOpaqueType->swap(first, pVec->increment_T(last, -1)); + + int index = 0; + int child = 2 * index + 1; + int new_last_index = delta_T(first, last) - 1; + + while (child < new_last_index) + { + if (((child + 1) < new_last_index) + && (pOpaqueType->compare_LT(pVec->increment_T(first, child), pVec->increment_T(first, child + 1)))) + { + // make certain the child index is ordered according the comparison + child += 1; + } + + if (pOpaqueType->compare_LT(pVec->increment_T(first, index), pVec->increment_T(first, child))) + { + // swap them + pOpaqueType->swap(pVec->increment_T(first, index), pVec->increment_T(first, child)); + index = child; + child = 2 * index + 1; + } + else + { + break; + } + } +} + +OSCL_EXPORT_REF OsclAny* OsclPriorityQueueBase::find_heap(const OsclAny* input, OsclAny* first, OsclAny* last) +{ + /* + * Find iterator pointing to the input element. + * It is assumed that the input element is present. + * If not present, it will return NULL. + */ + for (OsclAny* pos = first; pos < last; pos = pVec->increment_T(pos, 1)) + { + if (pOpaqueType->compare_EQ(pos, input)) + return pos; + } + return NULL; +} + +//Remove an arbitrary element, by value. +//If there are multiple matches, this removes the first one it finds. +//Returns number of items removed(either 0 or 1). +OSCL_EXPORT_REF int OsclPriorityQueueBase::remove(const OsclAny* input) +{ + //First find the element to remove + OsclAny* pos = find_heap(input, pVec->begin(), pVec->end()); + if (pos) + { + if (pVec->increment_T(pos, 1) == pVec->end()) + { + // It's the last element-- just remove it without any re-ordering. + pVec->pop_back(); + } + else + { + // Move the element to the end & remove. + pop_heap(pos, pVec->end()); + pVec->pop_back(); + // Re-order the front part of the queue. + push_heap(pVec->begin(), pVec->increment_T(pos, 1)); + } + return 1; + } + return 0; +} + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_priqueue.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_priqueue.h new file mode 100644 index 0000000..12f5099 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_priqueue.h @@ -0,0 +1,249 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ P R I Q U E U E ( P R I O R I T Y Q U E U E ) + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +#ifndef OSCL_PRIQUEUE_H_INCLUDED +#define OSCL_PRIQUEUE_H_INCLUDED + + + +/*! + * \file oscl_priqueue.h + * \brief Implements a priority queue data structure similar to STL. + * + * Implements a priority queue data structure similar to the STL class. + * The properties of the class include O(Log_2(N)) + * insertion and deletion complexity and O(1) complexity + * to access the top priority item. + * + */ + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + + +#ifndef OSCL_VECTOR_H_INCLUDED +#include "oscl_vector.h" +#endif + +/** + * OsclPriorityQueueBase is a non-templatized base class for OsclPriorityQueue. + * The purpose of this base class is to avoid large inline routines + * in the OsclPriorityQueue implementation. + * This class is not intended for direct instantiation except by + * OsclPriorityQueue. + */ +class OsclPriorityQueueBase +{ + protected: + virtual ~OsclPriorityQueueBase() + {} + + OSCL_IMPORT_REF void push_heap(OsclAny* first, OsclAny* last) ; + + OSCL_IMPORT_REF void pop_heap(OsclAny* first, OsclAny* last) ; + + OSCL_IMPORT_REF OsclAny* find_heap(const OsclAny* input, OsclAny* first, OsclAny* last) ; + + OSCL_IMPORT_REF int remove(const OsclAny* input) ; + + void construct(Oscl_Opaque_Type_Compare* ot, Oscl_Vector_Base* vec) + { + pOpaqueType = ot; + pVec = vec; + } + + private: + + //return delta from "first" to "last" expressed as a number of T elements. + int delta_T(OsclAny*first, OsclAny*last) + { + return ((int)last - (int)first) / pVec->sizeof_T; + } + + Oscl_Opaque_Type_Compare* pOpaqueType; + Oscl_Vector_Base* pVec; +}; + +template < class T> class OsclCompareLess +{ + public: + int compare(T& a, T& b) const + { + return (a < b); + } +}; + + + + + + + + +template < class Qelem, class Alloc, +class Container = Oscl_Vector, +class Compare = OsclCompareLess > + +class OsclPriorityQueue : public OsclPriorityQueueBase + , public Oscl_Opaque_Type_Compare +{ + + public: + typedef typename Container::value_type value_type; + typedef Container container_type; + typedef typename Container::iterator iterator; + typedef typename Container::const_reference const_reference; + + bool empty() const + { + return c.empty(); + }; + uint32 size() const + { + return c.size(); + }; + void reserve(uint32 n) + { + c.reserve(n); + }; + const_reference top() const + { + return c.front(); + }; + const Container & vec() + { + return c; + } + + void push(const value_type& input) + { + c.push_back(input); + push_heap(c.begin(), c.end()); + } + + //remove top element + void pop() + { + pop_heap(c.begin(), c.end()); + c.pop_back(); + } + + //Remove an arbitrary element, by value. + //If there are multiple matches, this removes the first one it finds. + //Returns number of items removed(either 0 or 1). + int remove(const value_type& input) + { + return OsclPriorityQueueBase::remove(&input); + } + + //Constructor + OsclPriorityQueue(): OsclPriorityQueueBase(), Oscl_Opaque_Type_Compare() + , c() + { + OsclPriorityQueueBase::construct(this, &c); + } + + virtual ~OsclPriorityQueue() + {} + + protected: + Container c; + Compare comp; + + + void push_heap(iterator first, iterator last) + { + OsclPriorityQueueBase::push_heap(first, last); + } + + void pop_heap(iterator first, iterator last) + { + OsclPriorityQueueBase::pop_heap(first, last); + } + + iterator find_heap(const value_type& input, iterator first, iterator last) + { + return OsclPriorityQueueBase::find_heap(&input, first, last); + } + + //a debug routine for validating the current sort. + int validate() + { + unsigned int ch; + for (unsigned int par = 0; par < c.size(); par++) + { + ch = 2 * par + 1; + if (ch < c.size() && comp.compare(c[par], c[ch])) + return par;//error-- parent, April 1999. + * + * Copyright 1999, Mark Martinec. All rights reserved. + * + * TERMS AND CONDITIONS + * This program is free software; you can redistribute it and/or modify + * it under the terms of the "Frontier Artistic License" which comes + * with this Kit. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Frontier Artistic License for more details. + * + * You should have received a copy of the Frontier Artistic License + * with this Kit in the file named LICENSE.txt . + * If not, I'll be glad to provide one. + * + * FEATURES + * - careful adherence to specs regarding flags, field width and precision; + * - good performance for large string handling (large format, large + * argument or large paddings). Performance is similar to system's sprintf + * and in several cases significantly better (make sure you compile with + * optimizations turned on, tell the compiler the code is strict ANSI + * if necessary to give it more freedom for optimizations); + * - return value semantics per ISO/IEC 9899:1999 ("ISO C99"); + * - written in standard ISO/ANSI C - requires an ANSI C compiler. + * + * SUPPORTED CONVERSION SPECIFIERS AND DATA TYPES + * + * This snprintf only supports the following conversion specifiers: + * s, c, d, u, o, x, X, p (and synonyms: i, D, U, O - see below) + * with flags: '-', '+', ' ', '0' and '#'. + * An asterisk is supported for field width as well as precision. + * + * Length modifiers 'h' (short int), 'l' (long int), + * and 'll' (long long int) are supported. + * NOTE: + * If macro SNPRINTF_LONGLONG_SUPPORT is not defined (default) the + * length modifier 'll' is recognized but treated the same as 'l', + * which may cause argument value truncation! Defining + * SNPRINTF_LONGLONG_SUPPORT requires that your system's sprintf also + * handles length modifier 'll'. long long int is a language extension + * which may not be portable. + * + * Conversion of numeric data (conversion specifiers d, u, o, x, X, p) + * with length modifiers (none or h, l, ll) is left to the system routine + * sprintf, but all handling of flags, field width and precision as well as + * c and s conversions is done very carefully by this portable routine. + * If a string precision (truncation) is specified (e.g. %.8s) it is + * guaranteed the string beyond the specified precision will not be referenced. + * + * Length modifiers h, l and ll are ignored for c and s conversions (data + * types wint_t and wchar_t are not supported). + * + * The following common synonyms for conversion characters are supported: + * - i is a synonym for d + * - D is a synonym for ld, explicit length modifiers are ignored + * - U is a synonym for lu, explicit length modifiers are ignored + * - O is a synonym for lo, explicit length modifiers are ignored + * The D, O and U conversion characters are nonstandard, they are supported + * for backward compatibility only, and should not be used for new code. + * + * The following is specifically NOT supported: + * - flag ' (thousands' grouping character) is recognized but ignored + * - numeric conversion specifiers: f, e, E, g, G and synonym F, + * as well as the new a and A conversion specifiers + * - length modifier 'L' (long double) and 'q' (quad - use 'll' instead) + * - wide character/string conversions: lc, ls, and nonstandard + * synonyms C and S + * - writeback of converted string length: conversion character n + * - the n$ specification for direct reference to n-th argument + * - locales + * + * It is permitted for str_m to be zero, and it is permitted to specify NULL + * pointer for resulting string argument if str_m is zero (as per ISO C99). + * + * The return value is the number of characters which would be generated + * for the given input, excluding the trailing null. If this value + * is greater or equal to str_m, not all characters from the result + * have been stored in str, output bytes beyond the (str_m-1) -th character + * are discarded. If str_m is greater than zero it is guaranteed + * the resulting string will be null-terminated. + * + * NOTE that this matches the ISO C99, OpenBSD, and GNU C library 2.1, + * but is different from some older and vendor implementations, + * and is also different from XPG, XSH5, SUSv2 specifications. + * For historical discussion on changes in the semantics and standards + * of snprintf see printf(3) man page in the Linux programmers manual. + * + * Routines asprintf and vasprintf return a pointer (in the ptr argument) + * to a buffer sufficiently large to hold the resulting string. This pointer + * should be passed to free(3) to release the allocated storage when it is + * no longer needed. If sufficient space cannot be allocated, these functions + * will return -1 and set ptr to be a NULL pointer. These two routines are a + * GNU C library extensions (glibc). + * + * Routines asnprintf and vasnprintf are similar to asprintf and vasprintf, + * yet, like snprintf and vsnprintf counterparts, will write at most str_m-1 + * characters into the allocated output string, the last character in the + * allocated buffer then gets the terminating null. If the formatted string + * length (the return value) is greater than or equal to the str_m argument, + * the resulting string was truncated and some of the formatted characters + * were discarded. These routines present a handy way to limit the amount + * of allocated memory to some sane value. + * + * AVAILABILITY + * http://www.ijs.si/software/snprintf/ + * + * REVISION HISTORY + * 1999-04 V0.9 Mark Martinec + * - initial version, some modifications after comparing printf + * man pages for Digital Unix 4.0, Solaris 2.6 and HPUX 10, + * and checking how Perl handles sprintf (differently!); + * 1999-04-09 V1.0 Mark Martinec + * - added main test program, fixed remaining inconsistencies, + * added optional (long long int) support; + * 1999-04-12 V1.1 Mark Martinec + * - support the 'p' conversion (pointer to void); + * - if a string precision is specified + * make sure the string beyond the specified precision + * will not be referenced (e.g. by strlen); + * 1999-04-13 V1.2 Mark Martinec + * - support synonyms %D=%ld, %U=%lu, %O=%lo; + * - speed up the case of long format string with few conversions; + * 1999-06-30 V1.3 Mark Martinec + * - fixed runaway loop (eventually crashing when str_l wraps + * beyond 2^31) while copying format string without + * conversion specifiers to a buffer that is too short + * (thanks to Edwin Young for + * spotting the problem); + * - added macros PORTABLE_SNPRINTF_VERSION_(MAJOR|MINOR) + * to snprintf.h + * 2000-02-14 V2.0 (never released) Mark Martinec + * - relaxed license terms: The Artistic License now applies. + * You may still apply the GNU GENERAL PUBLIC LICENSE + * as was distributed with previous versions, if you prefer; + * - changed REVISION HISTORY dates to use ISO 8601 date format; + * - added vsnprintf (patch also independently proposed by + * Caolan McNamara 2000-05-04, and Keith M Willenson 2000-06-01) + * 2000-06-27 V2.1 Mark Martinec + * - removed POSIX check for str_m<1; value 0 for str_m is + * allowed by ISO C99 (and GNU C library 2.1) - (pointed out + * on 2000-05-04 by Caolan McNamara, caolan@ csn dot ul dot ie). + * Besides relaxed license this change in standards adherence + * is the main reason to bump up the major version number; + * - added nonstandard routines asnprintf, vasnprintf, asprintf, + * vasprintf that dynamically allocate storage for the + * resulting string; these routines are not compiled by default, + * see comments where NEED_V?ASN?PRINTF macros are defined; + * - autoconf contributed by Caolan McNamara + * 2000-10-06 V2.2 Mark Martinec + * - BUG FIX: the %c conversion used a temporary variable + * that was no longer in scope when referenced, + * possibly causing incorrect resulting character; + * - BUG FIX: make precision and minimal field width unsigned + * to handle huge values (2^31 <= n < 2^32) correctly; + * also be more careful in the use of signed/unsigned/size_t + * internal variables - probably more careful than many + * vendor implementations, but there may still be a case + * where huge values of str_m, precision or minimal field + * could cause incorrect behaviour; + * - use separate variables for signed/unsigned arguments, + * and for short/int, long, and long long argument lengths + * to avoid possible incompatibilities on certain + * computer architectures. Also use separate variable + * arg_sign to hold sign of a numeric argument, + * to make code more transparent; + * - some fiddling with zero padding and "0x" to make it + * Linux compatible; + * - systematically use macros fast_memcpy and fast_memset + * instead of case-by-case hand optimization; determine some + * breakeven string lengths for different architectures; + * - terminology change: 'format' -> 'conversion specifier', + * 'C9x' -> 'ISO/IEC 9899:1999 ("ISO C99")', + * 'alternative form' -> 'alternate form', + * 'data type modifier' -> 'length modifier'; + * - several comments rephrased and new ones added; + * - make compiler not complain about 'credits' defined but + * not used; + */ + + +/* Define HAVE_SNPRINTF if your system already has snprintf and vsnprintf. + * + * If HAVE_SNPRINTF is defined this module will not produce code for + * snprintf and vsnprintf, unless PREFER_PORTABLE_SNPRINTF is defined as well, + * causing this portable version of snprintf to be called portable_snprintf + * (and portable_vsnprintf). + */ +/* #define HAVE_SNPRINTF */ + +/* Define PREFER_PORTABLE_SNPRINTF if your system does have snprintf and + * vsnprintf but you would prefer to use the portable routine(s) instead. + * In this case the portable routine is declared as portable_snprintf + * (and portable_vsnprintf) and a macro 'snprintf' (and 'vsnprintf') + * is defined to expand to 'portable_v?snprintf' - see file snprintf.h . + * Defining this macro is only useful if HAVE_SNPRINTF is also defined, + * but does does no harm if defined nevertheless. + */ +/* #define PREFER_PORTABLE_SNPRINTF */ + +/* Define SNPRINTF_LONGLONG_SUPPORT if you want to support + * data type (long long int) and length modifier 'll' (e.g. %lld). + * If undefined, 'll' is recognized but treated as a single 'l'. + * + * If the system's sprintf does not handle 'll' + * the SNPRINTF_LONGLONG_SUPPORT must not be defined! + * + * This is off by default as (long long int) is a language extension. + */ + +#ifndef OSCLCONFIG_UTIL_H_INCLUDED +#include "osclconfig_util.h" +#endif + +#if(OSCL_HAS_SNPRINTF_LONGLONG_SUPPORT) +#define SNPRINTF_LONGLONG_SUPPORT +#endif + +/* Define NEED_SNPRINTF_ONLY if you only need snprintf, and not vsnprintf. + * If NEED_SNPRINTF_ONLY is defined, the snprintf will be defined directly, + * otherwise both snprintf and vsnprintf routines will be defined + * and snprintf will be a simple wrapper around vsnprintf, at the expense + * of an extra procedure call. + */ +/* #define NEED_SNPRINTF_ONLY */ + +/* Define NEED_V?ASN?PRINTF macros if you need library extension + * routines asprintf, vasprintf, asnprintf, vasnprintf respectively, + * and your system library does not provide them. They are all small + * wrapper routines around portable_vsnprintf. Defining any of the four + * NEED_V?ASN?PRINTF macros automatically turns off NEED_SNPRINTF_ONLY + * and turns on PREFER_PORTABLE_SNPRINTF. + * + * Watch for name conflicts with the system library if these routines + * are already present there. + * + * NOTE: vasprintf and vasnprintf routines need va_copy() from stdarg.h, as + * specified by C99, to be able to traverse the same list of arguments twice. + * I don't know of any other standard and portable way of achieving the same. + * With some versions of gcc you may use __va_copy(). You might even get away + * with "ap2 = ap", in this case you must not call va_end(ap2) ! + * #define va_copy(ap2,ap) ap2 = ap + */ +/* #define NEED_ASPRINTF */ +/* #define NEED_ASNPRINTF */ +/* #define NEED_VASPRINTF */ +/* #define NEED_VASNPRINTF */ + + +/* Define the following macros if desired: + * SOLARIS_COMPATIBLE, SOLARIS_BUG_COMPATIBLE, + * HPUX_COMPATIBLE, HPUX_BUG_COMPATIBLE, LINUX_COMPATIBLE, + * DIGITAL_UNIX_COMPATIBLE, DIGITAL_UNIX_BUG_COMPATIBLE, + * PERL_COMPATIBLE, PERL_BUG_COMPATIBLE, + * + * - For portable applications it is best not to rely on peculiarities + * of a given implementation so it may be best not to define any + * of the macros that select compatibility and to avoid features + * that vary among the systems. + * + * - Selecting compatibility with more than one operating system + * is not strictly forbidden but is not recommended. + * + * - 'x'_BUG_COMPATIBLE implies 'x'_COMPATIBLE . + * + * - 'x'_COMPATIBLE refers to (and enables) a behaviour that is + * documented in a sprintf man page on a given operating system + * and actually adhered to by the system's sprintf (but not on + * most other operating systems). It may also refer to and enable + * a behaviour that is declared 'undefined' or 'implementation specific' + * in the man page but a given implementation behaves predictably + * in a certain way. + * + * - 'x'_BUG_COMPATIBLE refers to (and enables) a behaviour of system's sprintf + * that contradicts the sprintf man page on the same operating system. + * + * - I do not claim that the 'x'_COMPATIBLE and 'x'_BUG_COMPATIBLE + * conditionals take into account all idiosyncrasies of a particular + * implementation, there may be other incompatibilities. + */ + + + +/* ============================================= */ +/* NO USER SERVICABLE PARTS FOLLOWING THIS POINT */ +/* ============================================= */ +#include "oscl_snprintf.h" + +#ifndef OSCLCONFIG_UTIL_H_INCLUDED +#include "osclconfig_util.h" +#endif + +#ifndef OSCL_STRING_UTILS_H +#include "oscl_string_utils.h" +#endif + +#ifndef OSCL_STDSTRING_H_INCLUDED +#include "oscl_stdstring.h" +#endif + +#ifndef OSCL_STRING_UTILS_H_INCLUDED +#include "oscl_string_utils.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +#define PORTABLE_SNPRINTF_VERSION_MAJOR 2 +#define PORTABLE_SNPRINTF_VERSION_MINOR 2 + +#define NUMERIC_CONV_BUF_SIZE 32 + +// configure the portable sprintf code +#define PREFER_PORTABLE_SNPRINTF +#define NEED_SNPRINTF_ONLY + +#if defined(NEED_ASPRINTF) || defined(NEED_ASNPRINTF) || defined(NEED_VASPRINTF) || defined(NEED_VASNPRINTF) +# if defined(NEED_SNPRINTF_ONLY) +# undef NEED_SNPRINTF_ONLY +# endif +# if !defined(PREFER_PORTABLE_SNPRINTF) +# define PREFER_PORTABLE_SNPRINTF +# endif +#endif + +#if defined(SOLARIS_BUG_COMPATIBLE) && !defined(SOLARIS_COMPATIBLE) +#define SOLARIS_COMPATIBLE +#endif + +#if defined(HPUX_BUG_COMPATIBLE) && !defined(HPUX_COMPATIBLE) +#define HPUX_COMPATIBLE +#endif + +#if defined(DIGITAL_UNIX_BUG_COMPATIBLE) && !defined(DIGITAL_UNIX_COMPATIBLE) +#define DIGITAL_UNIX_COMPATIBLE +#endif + +#if defined(PERL_BUG_COMPATIBLE) && !defined(PERL_COMPATIBLE) +#define PERL_COMPATIBLE +#endif + +#if defined(LINUX_BUG_COMPATIBLE) && !defined(LINUX_COMPATIBLE) +#define LINUX_COMPATIBLE +#endif + + + +//An implementation of swprintf for platforms that have native sprintf, but not swprintf. +//Note this routine converts input oscl_wchar strings to single-wide without any +//Unicode-to-UTF8 conversion. This is sufficient for the usage in this module, since +//we know that format strings are ASCII character only, and there are no string arguments +//in the argument list passed to this routine. +static int32 oscl_default_swprintf(oscl_wchar *buffer, int32 bufferlen, const oscl_wchar *format, ...) +{ + OSCL_UNUSED_ARG(bufferlen); + + int32 result; + int32 nformat = oscl_strlen(format); + char* sformat = (char*)format; + char* sbuffer = (char*)buffer; + + //Compress the format-string to single-wide. + int32 i; + for (i = 0; i < nformat; i++) + sformat[i] = (char)format[i]; + sformat[nformat] = '\0'; + + va_list args; + va_start(args, format); + result = vsprintf(sbuffer, sformat, args); + va_end(args); + + //Restore the original format string. Probably unnecessary. + oscl_wchar* oformat = (oscl_wchar*)format; + oformat[nformat] = '\0'; + for (i = 0; i < nformat; i++) + oformat[nformat-i-1] = (oscl_wchar)sformat[nformat-i-1]; + + //Stretch the result string from single-wide to wide. + int32 nsbuffer = oscl_strlen(sbuffer); + buffer[nsbuffer] = '\0'; + for (i = 0; i < nsbuffer; i++) + buffer[nsbuffer-i-1] = (oscl_wchar)sbuffer[nsbuffer-i-1]; + + return result; +} + +OSCL_IMPORT_REF int32 oscl_UnicodeToUTF8(const oscl_wchar *input, int32 inLength, char *output, int32 outLength); + +OsclAny * oscl_memchr(const OsclAny * str, int32 c, int32 count) +{ + uint8* p = (uint8 *)str; + int32 j = 1; + while (j <= count) + { + if (*p == c) + { + return p; + } + j++; + p++; + } + return NULL; +} + +/* prototypes */ + +#if defined(NEED_ASPRINTF) +int asprintf(char **ptr, const char *fmt, /*args*/ ...); +#endif +#if defined(NEED_VASPRINTF) +int vasprintf(char **ptr, const char *fmt, va_list ap); +#endif +#if defined(NEED_ASNPRINTF) +int asnprintf(char **ptr, size_t str_m, const char *fmt, /*args*/ ...); +#endif +#if defined(NEED_VASNPRINTF) +int vasnprintf(char **ptr, size_t str_m, const char *fmt, va_list ap); +#endif + +//#if defined(HAVE_SNPRINTF) +/* declare our portable snprintf routine under name portable_snprintf */ +/* declare our portable vsnprintf routine under name portable_vsnprintf */ +//#else +/* declare our portable routines under names snprintf and vsnprintf */ +//#define portable_snprintf snprintf +//#if !defined(NEED_SNPRINTF_ONLY) +//#define portable_vsnprintf vsnprintf +//#endif +//#endif + +//#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF) +//int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...); +//#if !defined(NEED_SNPRINTF_ONLY) +//int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap); +//#endif +//#endif + +/* declarations */ + +/* +static char credits[] = "\n\ +@(#)snprintf.c, v2.2: Mark Martinec, \n\ +@(#)snprintf.c, v2.2: Copyright 1999, Mark Martinec. Frontier Artistic License applies.\n\ +@(#)snprintf.c, v2.2: http://www.ijs.si/software/snprintf/\n"; +*/ + +#if defined(NEED_ASPRINTF) +int asprintf(char **ptr, const char *fmt, /*args*/ ...) +{ + va_list ap; + size_t str_m; + int str_l; + + *ptr = NULL; + va_start(ap, fmt); /* measure the required size */ + str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap); + va_end(ap); + OSCL_ASSERT(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ + *ptr = (char *) malloc(str_m = (size_t)str_l + 1); + if (*ptr == NULL) + { + errno = ENOMEM; + str_l = -1; + } + else + { + int str_l2; + va_start(ap, fmt); + str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); + va_end(ap); + OSCL_ASSERT(str_l2 == str_l); + } + return str_l; +} +#endif + +#if defined(NEED_VASPRINTF) +int vasprintf(char **ptr, const char *fmt, va_list ap) +{ + size_t str_m; + int str_l; + + *ptr = NULL; + { + va_list ap2; + va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */ + str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap2);/*get required size*/ + va_end(ap2); + } + OSCL_ASSERT(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ + *ptr = (char *) malloc(str_m = (size_t)str_l + 1); + if (*ptr == NULL) + { + errno = ENOMEM; + str_l = -1; + } + else + { + int str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); + OSCL_ASSERT(str_l2 == str_l); + } + return str_l; +} +#endif + +#if defined(NEED_ASNPRINTF) +int asnprintf(char **ptr, size_t str_m, const char *fmt, /*args*/ ...) +{ + va_list ap; + int str_l; + + *ptr = NULL; + va_start(ap, fmt); /* measure the required size */ + str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap); + va_end(ap); + OSCL_ASSERT(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ + if ((size_t)str_l + 1 < str_m) str_m = (size_t)str_l + 1; /* truncate */ + /* if str_m is 0, no buffer is allocated, just set *ptr to NULL */ + if (str_m == 0) /* not interested in resulting string, just return size */ + { + } + else + { + *ptr = (char *) malloc(str_m); + if (*ptr == NULL) + { + errno = ENOMEM; + str_l = -1; + } + else + { + int str_l2; + va_start(ap, fmt); + str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); + va_end(ap); + OSCL_ASSERT(str_l2 == str_l); + } + } + return str_l; +} +#endif + +#if defined(NEED_VASNPRINTF) +int vasnprintf(char **ptr, size_t str_m, const char *fmt, va_list ap) +{ + int str_l; + + *ptr = NULL; + { + va_list ap2; + va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */ + str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap2);/*get required size*/ + va_end(ap2); + } + OSCL_ASSERT(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ + if ((size_t)str_l + 1 < str_m) str_m = (size_t)str_l + 1; /* truncate */ + /* if str_m is 0, no buffer is allocated, just set *ptr to NULL */ + if (str_m == 0) /* not interested in resulting string, just return size */ + { + } + else + { + *ptr = (char *) malloc(str_m); + if (*ptr == NULL) + { + errno = ENOMEM; + str_l = -1; + } + else + { + int str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); + OSCL_ASSERT(str_l2 == str_l); + } + } + return str_l; +} +#endif + +/* + * If the system does have snprintf and the portable routine is not + * specifically required, this module produces no code for snprintf/vsnprintf. + */ +#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF) + +#if defined(NEED_SNPRINTF_ONLY) +int32 portable_snprintf(char *str, size_t str_m, const char *fmt, va_list ap) // changed elipsis to va_list-jg +{ +#else +int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) +{ +#endif + +#if defined(NEED_SNPRINTF_ONLY) + //va_list ap; jg +#endif + size_t str_l = 0; + const char *p = fmt; + + /* In contrast with POSIX, the ISO C99 now says + * that str can be NULL and str_m can be 0. + * This is more useful than the old: if (str_m < 1) return -1; */ + +#if defined(NEED_SNPRINTF_ONLY) + //va_start(ap, fmt); jg +#endif + if (!p) p = ""; + while (*p) + { + if (*p != '%') + { + /* if (str_l < str_m) str[str_l++] = *p++; -- this would be sufficient */ + /* but the following code achieves better performance for cases + * where format string is long and contains few conversions */ + const char *q = oscl_strchr(p + 1, '%'); + size_t n = !q ? oscl_strlen(p) : (q - p); + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strncpy(str + str_l, p, (n > avail ? avail : n)); + } + p += n; + str_l += n; + } + else + { +#if defined(PERL_COMPATIBLE) || defined(LINUX_COMPATIBLE) + const char *starting_p; +#endif + size_t min_field_width = 0, precision = 0; + int zero_padding = 0, precision_specified = 0, justify_left = 0; + int alternate_form = 0, force_sign = 0; + int space_for_positive = 1; /* If both the ' ' and '+' flags appear, + the ' ' flag should be ignored. */ + char length_modifier = '\0'; /* allowed values: \0, h, l, L */ + char tmp[NUMERIC_CONV_BUF_SIZE];/* temporary buffer for simple numeric->string conversion */ + + const char *str_arg; /* string address in case of string argument */ + size_t str_arg_l; /* natural field width of arg without padding + and sign */ + unsigned char uchar_arg; + /* unsigned char argument value - only defined for c conversion. + N.B. standard explicitly states the char argument for + the c conversion is unsigned */ + + size_t number_of_zeros_to_pad = 0; + /* number of zeros to be inserted for numeric conversions + as required by the precision or minimal field width */ + + size_t zero_padding_insertion_ind = 0; + /* index into tmp where zero padding is to be inserted */ + + char fmt_spec = '\0'; + /* current conversion specifier character */ + + str_arg = NULL; +#if defined(PERL_COMPATIBLE) || defined(LINUX_COMPATIBLE) + starting_p = p; +#endif + p++; /* skip '%' */ + + /* parse flags */ + while (*p == '0' || *p == '-' || *p == '+' || + *p == ' ' || *p == '#' || *p == '\'') + { + switch (*p) + { + case '0': + zero_padding = 1; + break; + case '-': + justify_left = 1; + break; + case '+': + force_sign = 1; + space_for_positive = 0; + break; + case ' ': + force_sign = 1; + /* If both the ' ' and '+' flags appear, the ' ' flag should be ignored */ +#ifdef PERL_COMPATIBLE + /* ... but in Perl the last of ' ' and '+' applies */ + space_for_positive = 1; +#endif + break; + case '#': + alternate_form = 1; + break; + case '\'': + break; + } + p++; + } + /* If the '0' and '-' flags both appear, the '0' flag should be ignored. */ + + /* parse field width */ + if (*p == '*') + { + int j; + p++; + j = va_arg(ap, int); + if (j >= 0) min_field_width = j; + else + { + min_field_width = -j; + justify_left = 1; + } + } + else if (oscl_isdigit((int)(*p))) + { + /* size_t could be wider than unsigned int; + make sure we treat argument like common implementations do */ + unsigned int uj = *p++ - '0'; + while (oscl_isdigit((int)(*p))) uj = 10 * uj + (unsigned int)(*p++ - '0'); + min_field_width = uj; + } + /* parse precision */ + if (*p == '.') + { + p++; + precision_specified = 1; + if (*p == '*') + { + int j = va_arg(ap, int); + p++; + if (j >= 0) precision = j; + else + { + precision_specified = 0; + precision = 0; + /* NOTE: + * Solaris 2.6 man page claims that in this case the precision + * should be set to 0. Digital Unix 4.0, HPUX 10 and BSD man page + * claim that this case should be treated as unspecified precision, + * which is what we do here. + */ + } + } + else if (oscl_isdigit((int)(*p))) + { + /* size_t could be wider than unsigned int; + make sure we treat argument like common implementations do */ + unsigned int uj = *p++ - '0'; + while (oscl_isdigit((int)(*p))) uj = 10 * uj + (unsigned int)(*p++ - '0'); + precision = uj; + } + } + /* parse 'h', 'l' and 'll' length modifiers */ + if (*p == 'h' || *p == 'l') + { + length_modifier = *p; + p++; + if (length_modifier == 'l' && *p == 'l') /* double l = long long */ + { +#ifdef SNPRINTF_LONGLONG_SUPPORT + length_modifier = '2'; /* double l encoded as '2' */ +#else + length_modifier = 'l'; /* treat it as a single 'l' */ +#endif + p++; + } + } + fmt_spec = *p; + /* common synonyms: */ + switch (fmt_spec) + { + case 'i': + fmt_spec = 'd'; + break; + case 'D': + fmt_spec = 'd'; + length_modifier = 'l'; + break; + case 'U': + fmt_spec = 'u'; + length_modifier = 'l'; + break; + case 'O': + fmt_spec = 'o'; + length_modifier = 'l'; + break; + default: + break; + } + /* get parameter value, do initial processing */ + switch (fmt_spec) + { + case '%': /* % behaves similar to 's' regarding flags and field widths */ + case 'c': /* c behaves similar to 's' regarding flags and field widths */ + case 's': + length_modifier = '\0'; /* wint_t and wchar_t not supported */ + /* the result of zero padding flag with non-numeric conversion specifier*/ + /* is undefined. Solaris and HPUX 10 does zero padding in this case, */ + /* Digital Unix and Linux does not. */ +#if !defined(SOLARIS_COMPATIBLE) && !defined(HPUX_COMPATIBLE) + zero_padding = 0; /* turn zero padding off for string conversions */ +#endif + str_arg_l = 1; + switch (fmt_spec) + { + case '%': + str_arg = p; + break; + case 'c': + { + int j = va_arg(ap, int); + uchar_arg = (unsigned char) j; /* standard demands unsigned char */ + str_arg = (const char *) & uchar_arg; + break; + } + case 's': + str_arg = va_arg(ap, const char *); + if (!str_arg) str_arg_l = 0; + /* make sure not to address string beyond the specified precision !!! */ + else if (!precision_specified) str_arg_l = oscl_strlen(str_arg); + /* truncate string if necessary as requested by precision */ + else if (precision == 0) str_arg_l = 0; + else + { + /* oscl_memchr on HP does not like n > 2^31 !!! */ // cast on memchar - jg + const char *q = (const char*)oscl_memchr(str_arg, '\0', + precision <= 0x7fffffff ? precision : 0x7fffffff); + str_arg_l = !q ? precision : (q - str_arg); + } + break; + default: + break; + } + break; + case 'd': + case 'u': + case 'o': + case 'x': + case 'X': + case 'p': + { + /* NOTE: the u, o, x, X and p conversion specifiers imply + the value is unsigned; d implies a signed value */ + + int arg_sign = 0; + /* 0 if numeric argument is zero (or if pointer is NULL for 'p'), + +1 if greater than zero (or nonzero for unsigned arguments), + -1 if negative (unsigned argument is never negative) */ + + int int_arg = 0; + unsigned int uint_arg = 0; + /* only defined for length modifier h, or for no length modifiers */ + + long int long_arg = 0; + unsigned long int ulong_arg = 0; + /* only defined for length modifier l */ + + void *ptr_arg = NULL; + /* pointer argument value -only defined for p conversion */ + +#ifdef SNPRINTF_LONGLONG_SUPPORT + long long int long_long_arg = 0; + unsigned long long int ulong_long_arg = 0; + /* only defined for length modifier ll */ +#endif + if (fmt_spec == 'p') + { + /* HPUX 10: An l, h, ll or L before any other conversion character + * (other than d, i, u, o, x, or X) is ignored. + * Digital Unix: + * not specified, but seems to behave as HPUX does. + * Solaris: If an h, l, or L appears before any other conversion + * specifier (other than d, i, u, o, x, or X), the behavior + * is undefined. (Actually %hp converts only 16-bits of address + * and %llp treats address as 64-bit data which is incompatible + * with (void *) argument on a 32-bit system). + */ +#ifdef SOLARIS_COMPATIBLE +# ifdef SOLARIS_BUG_COMPATIBLE + /* keep length modifiers even if it represents 'll' */ +# else + if (length_modifier == '2') length_modifier = '\0'; +# endif +#else + length_modifier = '\0'; +#endif + ptr_arg = va_arg(ap, void *); + if (ptr_arg != NULL) arg_sign = 1; + } + else if (fmt_spec == 'd') /* signed */ + { + switch (length_modifier) + { + case '\0': + case 'h': + /* It is non-portable to specify a second argument of char or short + * to va_arg, because arguments seen by the called function + * are not char or short. C converts char and short arguments + * to int before passing them to a function. + */ + int_arg = va_arg(ap, int); + if (int_arg > 0) arg_sign = 1; + else if (int_arg < 0) arg_sign = -1; + break; + case 'l': + long_arg = va_arg(ap, long int); + if (long_arg > 0) arg_sign = 1; + else if (long_arg < 0) arg_sign = -1; + break; +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': + long_long_arg = va_arg(ap, long long int); + if (long_long_arg > 0) arg_sign = 1; + else if (long_long_arg < 0) arg_sign = -1; + break; +#endif + } + } + else /* unsigned */ + { + switch (length_modifier) + { + case '\0': + case 'h': + uint_arg = va_arg(ap, unsigned int); + if (uint_arg) arg_sign = 1; + break; + case 'l': + ulong_arg = va_arg(ap, unsigned long int); + if (ulong_arg) arg_sign = 1; + break; +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': + ulong_long_arg = va_arg(ap, unsigned long long int); + if (ulong_long_arg) arg_sign = 1; + break; +#endif + } + } + str_arg = tmp; + str_arg_l = 0; + /* NOTE: + * For d, i, u, o, x, and X conversions, if precision is specified, + * the '0' flag should be ignored. This is so with Solaris 2.6, + * Digital UNIX 4.0, HPUX 10, Linux, FreeBSD, NetBSD; but not with Perl. + */ +#ifndef PERL_COMPATIBLE + if (precision_specified) zero_padding = 0; +#endif + if (fmt_spec == 'd') + { + if (force_sign && arg_sign >= 0) + tmp[str_arg_l++] = space_for_positive ? ' ' : '+'; + /* leave negative numbers for sprintf to handle, + to avoid handling tricky cases like (short int)(-32768) */ +#ifdef LINUX_COMPATIBLE + } + else if (fmt_spec == 'p' && force_sign && arg_sign > 0) + { + tmp[str_arg_l++] = space_for_positive ? ' ' : '+'; +#endif + } + else if (alternate_form) + { + if (arg_sign != 0 && (fmt_spec == 'x' || fmt_spec == 'X')) + { + tmp[str_arg_l++] = '0'; + tmp[str_arg_l++] = fmt_spec; + } + /* alternate form should have no effect for p conversion, but ... */ +#ifdef HPUX_COMPATIBLE + else if (fmt_spec == 'p' + /* HPUX 10: for an alternate form of p conversion, + * a nonzero result is prefixed by 0x. */ +#ifndef HPUX_BUG_COMPATIBLE + /* Actually it uses 0x prefix even for a zero value. */ + && arg_sign != 0 +#endif + ) + { + tmp[str_arg_l++] = '0'; + tmp[str_arg_l++] = 'x'; + } +#endif + } + zero_padding_insertion_ind = str_arg_l; + if (!precision_specified) precision = 1; /* default precision is 1 */ + if (precision == 0 && arg_sign == 0 +#if defined(HPUX_BUG_COMPATIBLE) || defined(LINUX_COMPATIBLE) + && fmt_spec != 'p' + /* HPUX 10 man page claims: With conversion character p the result of + * converting a zero value with a precision of zero is a null string. + * Actually HP returns all zeroes, and Linux returns "(nil)". */ +#endif + ) + { + /* converted to null string */ + /* When zero value is formatted with an explicit precision 0, + the resulting formatted string is empty (d, i, u, o, x, X, p). */ + } + else + { + char f[5]; + int f_l = 0; + f[f_l++] = '%'; /* construct a simple format string for sprintf */ + if (!length_modifier) { } + else if (length_modifier == '2') + { + f[f_l++] = 'l'; + f[f_l++] = 'l'; + } +#if defined(EKA2) + else + { + if (length_modifier == 'l') + { + // ignore this because there is a mismatch because symbian + // treats "%ld" as TInt64, and will expect 8 bytes of + // data as the argument when we only give it 4. + } + else + { + f[f_l++] = length_modifier; + } + } +#else + else f[f_l++] = length_modifier; +#endif + f[f_l++] = fmt_spec; + f[f_l++] = '\0'; + if (fmt_spec == 'p') + str_arg_l += sprintf(tmp + str_arg_l, f, ptr_arg); + else if (fmt_spec == 'd') /* signed */ + { + switch (length_modifier) + { + case '\0': + case 'h': + str_arg_l += sprintf(tmp + str_arg_l, f, int_arg); + break; + case 'l': + str_arg_l += sprintf(tmp + str_arg_l, f, long_arg); + break; +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': + str_arg_l += sprintf(tmp + str_arg_l, f, long_long_arg); + break; +#endif + } + } + else /* unsigned */ + { + switch (length_modifier) + { + case '\0': + case 'h': + str_arg_l += sprintf(tmp + str_arg_l, f, uint_arg); + break; + case 'l': + str_arg_l += sprintf(tmp + str_arg_l, f, ulong_arg); + break; +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': + str_arg_l += sprintf(tmp + str_arg_l, f, ulong_long_arg); + break; +#endif + } + } + /* include the optional minus sign and possible "0x" + in the region before the zero padding insertion point */ + if (zero_padding_insertion_ind < str_arg_l && + tmp[zero_padding_insertion_ind] == '-') + { + zero_padding_insertion_ind++; + } + if (zero_padding_insertion_ind + 1 < str_arg_l && + tmp[zero_padding_insertion_ind] == '0' && + (tmp[zero_padding_insertion_ind+1] == 'x' || + tmp[zero_padding_insertion_ind+1] == 'X')) + { + zero_padding_insertion_ind += 2; + } + } + { + size_t num_of_digits = str_arg_l - zero_padding_insertion_ind; + if (alternate_form && fmt_spec == 'o' +#ifdef HPUX_COMPATIBLE /* ("%#.o",0) -> "" */ + && (str_arg_l > 0) +#endif +#ifdef DIGITAL_UNIX_BUG_COMPATIBLE /* ("%#o",0) -> "00" */ +#else + /* unless zero is already the first character */ + && !(zero_padding_insertion_ind < str_arg_l + && tmp[zero_padding_insertion_ind] == '0') +#endif + ) /* assure leading zero for alternate-form octal numbers */ + { + if (!precision_specified || precision < num_of_digits + 1) + { + /* precision is increased to force the first character to be zero, + except if a zero value is formatted with an explicit precision + of zero */ + precision = num_of_digits + 1; + precision_specified = 1; + } + } + /* zero padding to specified precision? */ + if (num_of_digits < precision) + number_of_zeros_to_pad = precision - num_of_digits; + } + /* zero padding to specified minimal field width? */ + if (!justify_left && zero_padding) + { + size_t n = min_field_width - (str_arg_l + number_of_zeros_to_pad); + if (n > 0) number_of_zeros_to_pad += n; + } + break; + } + default: /* unrecognized conversion specifier, keep format string as-is*/ + zero_padding = 0; /* turn zero padding off for non-numeric convers. */ +#ifndef DIGITAL_UNIX_COMPATIBLE + justify_left = 1; + min_field_width = 0; /* reset flags */ +#endif +#if defined(PERL_COMPATIBLE) || defined(LINUX_COMPATIBLE) + /* keep the entire format string unchanged */ + str_arg = starting_p; + str_arg_l = p - starting_p; + /* well, not exactly so for Linux, which does something inbetween, + * and I don't feel an urge to imitate it: "%+++++hy" -> "%+y" */ +#else + /* discard the unrecognized conversion, just keep * + * the unrecognized conversion character */ + str_arg = p; + str_arg_l = 0; +#endif + if (*p) str_arg_l++; /* include invalid conversion specifier unchanged + if not at end-of-string */ + break; + } + if (*p) p++; /* step over the just processed conversion specifier */ + /* insert padding to the left as requested by min_field_width; + this does not include the zero padding in case of numerical conversions*/ + if (!justify_left) /* left padding with blank or zero */ + { + int n = min_field_width - (str_arg_l + number_of_zeros_to_pad); + if (n > 0) + { + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strset(str + str_l, (zero_padding ? '0' : ' '), (n > (int)avail ? avail : n)); + } + str_l += n; + } + } + /* zero padding as requested by the precision or by the minimal field width + * for numeric conversions required? */ + if (number_of_zeros_to_pad <= 0) + { + /* will not copy first part of numeric right now, * + * force it to be copied later in its entirety */ + zero_padding_insertion_ind = 0; + } + else + { + /* insert first part of numerics (sign or '0x') before zero padding */ + int n = zero_padding_insertion_ind; + if (n > 0) + { + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strncpy(str + str_l, str_arg, (n > (int)avail ? avail : n)); + } + str_l += n; + } + /* insert zero padding as requested by the precision or min field width */ + n = number_of_zeros_to_pad; + if (n > 0) + { + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strset(str + str_l, '0', (n > (int)avail ? avail : n)); + } + str_l += n; + } + } + /* insert formatted string + * (or as-is conversion specifier for unknown conversions) */ + { + int n = str_arg_l - zero_padding_insertion_ind; + if (n > 0) + { + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strncpy(str + str_l, str_arg + zero_padding_insertion_ind, + (n > (int)avail ? avail : n)); + } + str_l += n; + } + } + /* insert right padding */ + if (justify_left) /* right blank padding to the field width */ + { + int n = min_field_width - (str_arg_l + number_of_zeros_to_pad); + if (n > 0) + { + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strset(str + str_l, ' ', (n > (int)avail ? avail : n)); + } + str_l += n; + } + } + } + } +#if defined(NEED_SNPRINTF_ONLY) + //va_end(ap); jg +#endif + if (str_m > 0) + { /* make sure the string is null-terminated + even at the expense of overwriting the last character + (shouldn't happen, but just in case) */ + str[str_l <= str_m-1 ? str_l : str_m-1] = '\0'; + } + /* Return the number of characters formatted (excluding trailing null + * character), that is, the number of characters that would have been + * written to the buffer if it were large enough. + * + * The value of str_l should be returned, but str_l is of unsigned type + * size_t, and snprintf is int, possibly leading to an undetected + * integer overflow, resulting in a negative return value, which is illegal. + * Both XSH5 and ISO C99 (at least the draft) are silent on this issue. + * Should errno be set to EOVERFLOW and EOF returned in this case??? + */ + return (int) str_l; +} +#endif + +OSCL_EXPORT_REF int32 oscl_snprintf(char *str, uint32 count, const char *fmt, /*args*/ ...) +{ + int str_l; + va_list args; + va_start(args, fmt); + str_l = portable_snprintf(str, count, fmt, args); + return str_l; +} + +OSCL_EXPORT_REF int32 oscl_vsnprintf(char *str, uint32 count, const char *fmt, va_list args) +{ + int str_l; + str_l = portable_snprintf(str, count, fmt, args); + return str_l; +} + +/* + * If the system does have snprintf and the portable routine is not + * specifically required, this module produces no code for snprintf/vsnprintf. + */ +#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF) + +#if defined(NEED_SNPRINTF_ONLY) +int32 portable_swprintf(oscl_wchar *str, size_t str_m, const oscl_wchar *fmt, va_list ap) // changed elipsis to va_list-jg +{ +#else +int portable_vswprintf(oscl_wchar *str, size_t str_m, const oscl_wchar *fmt, va_list ap) +{ +#endif + +#if defined(NEED_SNPRINTF_ONLY) + //va_list ap; jg +#endif + size_t str_l = 0; + const oscl_wchar *p = fmt; + + /* In contrast with POSIX, the ISO C99 now says + * that str can be NULL and str_m can be 0. + * This is more useful than the old: if (str_m < 1) return -1; */ + +#if defined(NEED_SNPRINTF_ONLY) + //va_start(ap, fmt); jg +#endif + oscl_wchar nullstr[1]; + nullstr[0] = 0; + if (!p) + p = &nullstr[0]; + while (*p) + { + if (*p != '%') + { + /* if (str_l < str_m) str[str_l++] = *p++; -- this would be sufficient */ + /* but the following code achieves better performance for cases + * where format string is long and contains few conversions */ + const oscl_wchar *q = oscl_strchr(p + 1, '%'); + size_t n = !q ? oscl_strlen(p) : (q - p); + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strncpy(str + str_l, p, (n > avail ? avail : n)); + } + p += n; + str_l += n; + } + else + { +#if defined(PERL_COMPATIBLE) || defined(LINUX_COMPATIBLE) + const oscl_wchar *starting_p; +#endif + size_t min_field_width = 0, precision = 0; + int zero_padding = 0, precision_specified = 0, justify_left = 0; + int alternate_form = 0, force_sign = 0; + int space_for_positive = 1; /* If both the ' ' and '+' flags appear, + the ' ' flag should be ignored. */ + oscl_wchar length_modifier = '\0'; /* allowed values: \0, h, l, L */ + oscl_wchar tmp[NUMERIC_CONV_BUF_SIZE];/* temporary buffer for simple numeric->string conversion */ + + const oscl_wchar *str_arg; /* string address in case of string argument */ + size_t str_arg_l; /* natural field width of arg without padding + and sign */ + oscl_wchar uchar_arg; + /* unsigned char argument value - only defined for c conversion. + N.B. standard explicitly states the char argument for + the c conversion is unsigned */ + + size_t number_of_zeros_to_pad = 0; + /* number of zeros to be inserted for numeric conversions + as required by the precision or minimal field width */ + + size_t zero_padding_insertion_ind = 0; + /* index into tmp where zero padding is to be inserted */ + + oscl_wchar fmt_spec = '\0'; + /* current conversion specifier character */ + + str_arg = NULL; +#if defined(PERL_COMPATIBLE) || defined(LINUX_COMPATIBLE) + starting_p = p; +#endif + p++; /* skip '%' */ + + /* parse flags */ + while (*p == '0' || *p == '-' || *p == '+' || + *p == ' ' || *p == '#' || *p == '\'') + { + switch (*p) + { + case '0': + zero_padding = 1; + break; + case '-': + justify_left = 1; + break; + case '+': + force_sign = 1; + space_for_positive = 0; + break; + case ' ': + force_sign = 1; + /* If both the ' ' and '+' flags appear, the ' ' flag should be ignored */ +#ifdef PERL_COMPATIBLE + /* ... but in Perl the last of ' ' and '+' applies */ + space_for_positive = 1; +#endif + break; + case '#': + alternate_form = 1; + break; + case '\'': + break; + } + p++; + } + /* If the '0' and '-' flags both appear, the '0' flag should be ignored. */ + + /* parse field width */ + if (*p == '*') + { + int j; + p++; + j = va_arg(ap, int); + if (j >= 0) min_field_width = j; + else + { + min_field_width = -j; + justify_left = 1; + } + } + else if (oscl_isdigit((int)(*p))) + { + /* size_t could be wider than unsigned int; + make sure we treat argument like common implementations do */ + unsigned int uj = *p++ - '0'; + while (oscl_isdigit((int)(*p))) uj = 10 * uj + (unsigned int)(*p++ - '0'); + min_field_width = uj; + } + /* parse precision */ + if (*p == '.') + { + p++; + precision_specified = 1; + if (*p == '*') + { + int j = va_arg(ap, int); + p++; + if (j >= 0) precision = j; + else + { + precision_specified = 0; + precision = 0; + /* NOTE: + * Solaris 2.6 man page claims that in this case the precision + * should be set to 0. Digital Unix 4.0, HPUX 10 and BSD man page + * claim that this case should be treated as unspecified precision, + * which is what we do here. + */ + } + } + else if (oscl_isdigit((int)(*p))) + { + /* size_t could be wider than unsigned int; + make sure we treat argument like common implementations do */ + unsigned int uj = *p++ - '0'; + while (oscl_isdigit((int)(*p))) uj = 10 * uj + (unsigned int)(*p++ - '0'); + precision = uj; + } + } + /* parse 'h', 'l' and 'll' length modifiers */ + if (*p == 'h' || *p == 'l') + { + length_modifier = *p; + p++; + if (length_modifier == 'l' && *p == 'l') /* double l = long long */ + { +#ifdef SNPRINTF_LONGLONG_SUPPORT + length_modifier = '2'; /* double l encoded as '2' */ +#else + length_modifier = 'l'; /* treat it as a single 'l' */ +#endif + p++; + } + } + fmt_spec = *p; + /* common synonyms: */ + switch (fmt_spec) + { + case 'i': + fmt_spec = 'd'; + break; + case 'D': + fmt_spec = 'd'; + length_modifier = 'l'; + break; + case 'U': + fmt_spec = 'u'; + length_modifier = 'l'; + break; + case 'O': + fmt_spec = 'o'; + length_modifier = 'l'; + break; + default: + break; + } + /* get parameter value, do initial processing */ + switch (fmt_spec) + { + case '%': /* % behaves similar to 's' regarding flags and field widths */ + case 'c': /* c behaves similar to 's' regarding flags and field widths */ + case 's': + length_modifier = '\0'; /* wint_t and wchar_t not supported */ + /* the result of zero padding flag with non-numeric conversion specifier*/ + /* is undefined. Solaris and HPUX 10 does zero padding in this case, */ + /* Digital Unix and Linux does not. */ +#if !defined(SOLARIS_COMPATIBLE) && !defined(HPUX_COMPATIBLE) + zero_padding = 0; /* turn zero padding off for string conversions */ +#endif + str_arg_l = 1; + switch (fmt_spec) + { + case '%': + str_arg = p; + break; + case 'c': + { + int j = va_arg(ap, int); + uchar_arg = (oscl_wchar) j; /* standard demands unsigned char */ + str_arg = (const oscl_wchar *) & uchar_arg; + break; + } + case 's': + str_arg = va_arg(ap, const oscl_wchar *); + if (!str_arg) str_arg_l = 0; + /* make sure not to address string beyond the specified precision !!! */ + else if (!precision_specified) str_arg_l = oscl_strlen(str_arg); + /* truncate string if necessary as requested by precision */ + else if (precision == 0) str_arg_l = 0; + else + { + /* oscl_memchr on HP does not like n > 2^31 !!! */ // cast on memchar - jg + const oscl_wchar *q = (const oscl_wchar*)oscl_memchr(str_arg, '\0', + precision <= 0x7fffffff ? precision : 0x7fffffff); + str_arg_l = !q ? precision : (q - str_arg); + } + break; + default: + break; + } + break; + case 'd': + case 'u': + case 'o': + case 'x': + case 'X': + case 'p': + { + /* NOTE: the u, o, x, X and p conversion specifiers imply + the value is unsigned; d implies a signed value */ + + int arg_sign = 0; + /* 0 if numeric argument is zero (or if pointer is NULL for 'p'), + +1 if greater than zero (or nonzero for unsigned arguments), + -1 if negative (unsigned argument is never negative) */ + + int int_arg = 0; + unsigned int uint_arg = 0; + /* only defined for length modifier h, or for no length modifiers */ + + long int long_arg = 0; + unsigned long int ulong_arg = 0; + /* only defined for length modifier l */ + + void *ptr_arg = NULL; + /* pointer argument value -only defined for p conversion */ + +#ifdef SNPRINTF_LONGLONG_SUPPORT + long long int long_long_arg = 0; + unsigned long long int ulong_long_arg = 0; + /* only defined for length modifier ll */ +#endif + if (fmt_spec == 'p') + { + /* HPUX 10: An l, h, ll or L before any other conversion character + * (other than d, i, u, o, x, or X) is ignored. + * Digital Unix: + * not specified, but seems to behave as HPUX does. + * Solaris: If an h, l, or L appears before any other conversion + * specifier (other than d, i, u, o, x, or X), the behavior + * is undefined. (Actually %hp converts only 16-bits of address + * and %llp treats address as 64-bit data which is incompatible + * with (void *) argument on a 32-bit system). + */ +#ifdef SOLARIS_COMPATIBLE +# ifdef SOLARIS_BUG_COMPATIBLE + /* keep length modifiers even if it represents 'll' */ +# else + if (length_modifier == '2') length_modifier = '\0'; +# endif +#else + length_modifier = '\0'; +#endif + ptr_arg = va_arg(ap, void *); + if (ptr_arg != NULL) arg_sign = 1; + } + else if (fmt_spec == 'd') /* signed */ + { + switch (length_modifier) + { + case '\0': + case 'h': + /* It is non-portable to specify a second argument of char or short + * to va_arg, because arguments seen by the called function + * are not char or short. C converts char and short arguments + * to int before passing them to a function. + */ + int_arg = va_arg(ap, int); + if (int_arg > 0) arg_sign = 1; + else if (int_arg < 0) arg_sign = -1; + break; + case 'l': + long_arg = va_arg(ap, long int); + if (long_arg > 0) arg_sign = 1; + else if (long_arg < 0) arg_sign = -1; + break; +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': + long_long_arg = va_arg(ap, long long int); + if (long_long_arg > 0) arg_sign = 1; + else if (long_long_arg < 0) arg_sign = -1; + break; +#endif + } + } + else /* unsigned */ + { + switch (length_modifier) + { + case '\0': + case 'h': + uint_arg = va_arg(ap, unsigned int); + if (uint_arg) arg_sign = 1; + break; + case 'l': + ulong_arg = va_arg(ap, unsigned long int); + if (ulong_arg) arg_sign = 1; + break; +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': + ulong_long_arg = va_arg(ap, unsigned long long int); + if (ulong_long_arg) arg_sign = 1; + break; +#endif + } + } + str_arg = tmp; + str_arg_l = 0; + /* NOTE: + * For d, i, u, o, x, and X conversions, if precision is specified, + * the '0' flag should be ignored. This is so with Solaris 2.6, + * Digital UNIX 4.0, HPUX 10, Linux, FreeBSD, NetBSD; but not with Perl. + */ +#ifndef PERL_COMPATIBLE + if (precision_specified) zero_padding = 0; +#endif + if (fmt_spec == 'd') + { + if (force_sign && arg_sign >= 0) + tmp[str_arg_l++] = space_for_positive ? ' ' : '+'; + /* leave negative numbers for sprintf to handle, + to avoid handling tricky cases like (short int)(-32768) */ +#ifdef LINUX_COMPATIBLE + } + else if (fmt_spec == 'p' && force_sign && arg_sign > 0) + { + tmp[str_arg_l++] = space_for_positive ? ' ' : '+'; +#endif + } + else if (alternate_form) + { + if (arg_sign != 0 && (fmt_spec == 'x' || fmt_spec == 'X')) + { + tmp[str_arg_l++] = '0'; + tmp[str_arg_l++] = fmt_spec; + } + /* alternate form should have no effect for p conversion, but ... */ +#ifdef HPUX_COMPATIBLE + else if (fmt_spec == 'p' + /* HPUX 10: for an alternate form of p conversion, + * a nonzero result is prefixed by 0x. */ +#ifndef HPUX_BUG_COMPATIBLE + /* Actually it uses 0x prefix even for a zero value. */ + && arg_sign != 0 +#endif + ) + { + tmp[str_arg_l++] = '0'; + tmp[str_arg_l++] = 'x'; + } +#endif + } + zero_padding_insertion_ind = str_arg_l; + if (!precision_specified) precision = 1; /* default precision is 1 */ + if (precision == 0 && arg_sign == 0 +#if defined(HPUX_BUG_COMPATIBLE) || defined(LINUX_COMPATIBLE) + && fmt_spec != 'p' + /* HPUX 10 man page claims: With conversion character p the result of + * converting a zero value with a precision of zero is a null string. + * Actually HP returns all zeroes, and Linux returns "(nil)". */ +#endif + ) + { + /* converted to null string */ + /* When zero value is formatted with an explicit precision 0, + the resulting formatted string is empty (d, i, u, o, x, X, p). */ + } + else + { + oscl_wchar f[5]; + int f_l = 0; + f[f_l++] = '%'; /* construct a simple format string for sprintf */ + if (!length_modifier) { } + else if (length_modifier == '2') + { + f[f_l++] = 'l'; + f[f_l++] = 'l'; + } + else f[f_l++] = length_modifier; + f[f_l++] = fmt_spec; + f[f_l++] = '\0'; + if (fmt_spec == 'p') + { + str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, ptr_arg); + } + else if (fmt_spec == 'd') /* signed */ + { + switch (length_modifier) + { + case '\0': + case 'h': + str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, int_arg); + break; + + case 'l': + str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, long_arg); + break; + +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': + str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, long_long_arg); + break; +#endif //snprintf_longlong_support + + } + } + else /* unsigned */ + { + switch (length_modifier) + { + case '\0': + case 'h': + str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, uint_arg); + break; + + case 'l': + str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, ulong_arg); + break; + +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': + str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, ulong_long_arg); + break; +#endif //snprintf_longlong_support + + } + } + /* include the optional minus sign and possible "0x" + in the region before the zero padding insertion point */ + if (zero_padding_insertion_ind < str_arg_l && + tmp[zero_padding_insertion_ind] == '-') + { + zero_padding_insertion_ind++; + } + if (zero_padding_insertion_ind + 1 < str_arg_l && + tmp[zero_padding_insertion_ind] == '0' && + (tmp[zero_padding_insertion_ind+1] == 'x' || + tmp[zero_padding_insertion_ind+1] == 'X')) + { + zero_padding_insertion_ind += 2; + } + } + { + size_t num_of_digits = str_arg_l - zero_padding_insertion_ind; + if (alternate_form && fmt_spec == 'o' +#ifdef HPUX_COMPATIBLE /* ("%#.o",0) -> "" */ + && (str_arg_l > 0) +#endif +#ifdef DIGITAL_UNIX_BUG_COMPATIBLE /* ("%#o",0) -> "00" */ +#else + /* unless zero is already the first character */ + && !(zero_padding_insertion_ind < str_arg_l + && tmp[zero_padding_insertion_ind] == '0') +#endif + ) /* assure leading zero for alternate-form octal numbers */ + { + if (!precision_specified || precision < num_of_digits + 1) + { + /* precision is increased to force the first character to be zero, + except if a zero value is formatted with an explicit precision + of zero */ + precision = num_of_digits + 1; + precision_specified = 1; + } + } + /* zero padding to specified precision? */ + if (num_of_digits < precision) + number_of_zeros_to_pad = precision - num_of_digits; + } + /* zero padding to specified minimal field width? */ + if (!justify_left && zero_padding) + { + size_t n = min_field_width - (str_arg_l + number_of_zeros_to_pad); + if (n > 0) number_of_zeros_to_pad += n; + } + break; + } + default: /* unrecognized conversion specifier, keep format string as-is*/ + zero_padding = 0; /* turn zero padding off for non-numeric convers. */ +#ifndef DIGITAL_UNIX_COMPATIBLE + justify_left = 1; + min_field_width = 0; /* reset flags */ +#endif +#if defined(PERL_COMPATIBLE) || defined(LINUX_COMPATIBLE) + /* keep the entire format string unchanged */ + str_arg = starting_p; + str_arg_l = p - starting_p; + /* well, not exactly so for Linux, which does something inbetween, + * and I don't feel an urge to imitate it: "%+++++hy" -> "%+y" */ +#else + /* discard the unrecognized conversion, just keep * + * the unrecognized conversion character */ + str_arg = p; + str_arg_l = 0; +#endif + if (*p) str_arg_l++; /* include invalid conversion specifier unchanged + if not at end-of-string */ + break; + } + if (*p) p++; /* step over the just processed conversion specifier */ + /* insert padding to the left as requested by min_field_width; + this does not include the zero padding in case of numerical conversions*/ + if (!justify_left) /* left padding with blank or zero */ + { + int n = min_field_width - (str_arg_l + number_of_zeros_to_pad); + if (n > 0) + { + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strset(str + str_l, (zero_padding ? '0' : ' '), (n > (int)avail ? avail : n)); + } + str_l += n; + } + } + /* zero padding as requested by the precision or by the minimal field width + * for numeric conversions required? */ + if (number_of_zeros_to_pad <= 0) + { + /* will not copy first part of numeric right now, * + * force it to be copied later in its entirety */ + zero_padding_insertion_ind = 0; + } + else + { + /* insert first part of numerics (sign or '0x') before zero padding */ + int n = zero_padding_insertion_ind; + if (n > 0) + { + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strncpy(str + str_l, str_arg, (n > (int)avail ? avail : n)); + } + str_l += n; + } + /* insert zero padding as requested by the precision or min field width */ + n = number_of_zeros_to_pad; + if (n > 0) + { + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strset(str + str_l, '0', (n > (int)avail ? avail : n)); + } + str_l += n; + } + } + /* insert formatted string + * (or as-is conversion specifier for unknown conversions) */ + { + int n = str_arg_l - zero_padding_insertion_ind; + if (n > 0) + { + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strncpy(str + str_l, str_arg + zero_padding_insertion_ind, + (n > (int)avail ? avail : n)); + } + str_l += n; + } + } + /* insert right padding */ + if (justify_left) /* right blank padding to the field width */ + { + int n = min_field_width - (str_arg_l + number_of_zeros_to_pad); + if (n > 0) + { + if (str_l < str_m) + { + size_t avail = str_m - str_l; + oscl_strset(str + str_l, ' ', (n > (int)avail ? avail : n)); + } + str_l += n; + } + } + } + } +#if defined(NEED_SNPRINTF_ONLY) + //va_end(ap); jg +#endif + if (str_m > 0) + { /* make sure the string is null-terminated + even at the expense of overwriting the last character + (shouldn't happen, but just in case) */ + str[str_l <= str_m-1 ? str_l : str_m-1] = '\0'; + } + /* Return the number of characters formatted (excluding trailing null + * character), that is, the number of characters that would have been + * written to the buffer if it were large enough. + * + * The value of str_l should be returned, but str_l is of unsigned type + * size_t, and snprintf is int, possibly leading to an undetected + * integer overflow, resulting in a negative return value, which is illegal. + * Both XSH5 and ISO C99 (at least the draft) are silent on this issue. + * Should errno be set to EOVERFLOW and EOF returned in this case??? + */ + return (int) str_l; +} + +#endif + +OSCL_EXPORT_REF int32 oscl_snprintf(oscl_wchar *str, uint32 count, const oscl_wchar *fmt, /*args*/ ...) +{ + int str_l; + va_list args; + va_start(args, fmt); + str_l = portable_swprintf(str, count, fmt, args); + return str_l; +} + +OSCL_EXPORT_REF int32 oscl_vsnprintf(oscl_wchar *str, uint32 count, const oscl_wchar *fmt, va_list args) +{ + int str_l; + str_l = portable_swprintf(str, count, fmt, args); + return str_l; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_snprintf.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_snprintf.h new file mode 100644 index 0000000..d9923aa --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_snprintf.h @@ -0,0 +1,60 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L_ S N P R I N T F + +// This is a portable implementation of snprintf() for use on all +// platforms supported by oscl. + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/*! + * \file oscl_snprintf.h + * \brief Provides a portable implementation of snprintf + * + */ + + +#ifndef OSCL_SNPRINTF_H_INCLUDED +#define OSCL_SNPRINTF_H_INCLUDED + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCLCONFIG_UTIL_H_INCLUDED +#include "osclconfig_util.h" +#endif + +OSCL_IMPORT_REF int32 oscl_snprintf(char *str, uint32 count, const char *fmt, /*args*/ ...); +OSCL_IMPORT_REF int32 oscl_snprintf(oscl_wchar *str, uint32 count, const oscl_wchar *fmt, /*args*/ ...); +OSCL_IMPORT_REF int32 oscl_vsnprintf(char *str, uint32 count, const char *fmt, va_list args); +OSCL_IMPORT_REF int32 oscl_vsnprintf(oscl_wchar *str, uint32 count, const oscl_wchar *fmt, va_list args); +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_str_ptr_len.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_str_ptr_len.cpp new file mode 100644 index 0000000..68be82f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_str_ptr_len.cpp @@ -0,0 +1,54 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S T R _ P T R _ L E N + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - +#ifndef OSCL_STR_PTR_LEN_H_INCLUDED +#include "oscl_str_ptr_len.h" +#endif + +#define OSCL_DISABLE_WARNING_CONV_POSSIBLE_LOSS_OF_DATA +#include "osclconfig_compiler_warnings.h" +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// This function calculates the checksum of the string. +// Note that this function should be case insensitive! (i.e. checksums for +// "I love pizza" and "I LoVe PiZzA" should be the same) +OSCL_EXPORT_REF void StrCSumPtrLen::setCheckSum() +{ + checkSum = 0; + + for (int32 i = 0; i < len; ++i) + { + //checkSum = (CheckSumType)(checkSum << 3); + if (isLetter(ptr[i])) + { + checkSum = (CheckSumType)(checkSum + (ptr[i] | OSCL_ASCII_CASE_MAGIC_BIT)); + } + else + { + checkSum = (CheckSumType)(checkSum + ptr[i]); + } + } +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_str_ptr_len.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_str_ptr_len.h new file mode 100644 index 0000000..8b834a4 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_str_ptr_len.h @@ -0,0 +1,384 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S T R _ P T R _ L E N + +// This file contains C-based data structure definitions for string +// manipulations. + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/** \file oscl_str_ptr_len.h + \brief Defines a data structure for string containment/manipulations where the storage for the string is maintained externally. +*/ + + +#ifndef OSCL_STR_PTR_LEN_H_INCLUDED +#define OSCL_STR_PTR_LEN_H_INCLUDED + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_STDSTRING_H_INCLUDED +#include "oscl_stdstring.h" +#endif + +//#ifndef OSCL_TYPES_H_INCLUDED +//#include "oscl_types.h" +//#endif + +// - - Definitions - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// this is the XOR difference between any two ascii letters, 32 +const uint8 OSCL_ASCII_CASE_MAGIC_BIT = 0x20; + +//! This data structure encapsulates a set of functions used to perform +/*! standard string operations. It should be used for null-terminated constant + (non-modifiable) strings of char type. +*/ +typedef struct StrPtrLen +{ +protected: + const char* ptr; + int32 len; + + bool isLetter(const char c) const + { + return ((c >= 65 && c <= 90) || (c >= 97 && c <= 122)); + } + +public: + + StrPtrLen(const char* newPtr) + : ptr(newPtr) + { + len = oscl_strlen(newPtr); + } + + StrPtrLen(const char* newPtr, uint32 newLen) + : ptr(newPtr), len(newLen) + {} + + StrPtrLen() + : ptr(""), len(0) + {} + + StrPtrLen(const StrPtrLen& rhs) + : ptr(rhs.ptr), len(rhs.len) + {} + + const char* c_str() const + { + return ptr; + } + + int32 length() const + { + return len; + } + + int32 size() const + { + return len; + } + + void setPtrLen(const char* newPtr, uint32 newLen) + { + ptr = newPtr; + len = newLen; + } + + c_bool isCIEquivalentTo(const StrPtrLen& rhs) const + { + if (len != rhs.len) + { + return false; + } + // since they are the same length just check for the prefix condition + return isCIPrefixOf(rhs); + } + + c_bool isCIPrefixOf(const StrPtrLen& rhs) const + { + if (len > rhs.len) + { + return false; + } + + for (int32 ii = 0; ii < len; ++ii) + { + if (ptr[ii] != rhs.ptr[ii]) + { + if (!isLetter(ptr[ii]) || + (OSCL_ASCII_CASE_MAGIC_BIT != ((ptr[ii] ^ rhs.ptr[ii]) | OSCL_ASCII_CASE_MAGIC_BIT))) + { + return false; + } + } + } + return true; + } + + int32 operator==(const StrPtrLen& rhs) const + { + if (len != rhs.len) + { + //return (!(len-rhs.len)); + return false; + } + + return(!oscl_strncmp(ptr, rhs.ptr, rhs.len)); + } + + int32 operator!=(const StrPtrLen& rhs) const + { + return !(*this == rhs); + } + + StrPtrLen &operator=(const StrPtrLen& rhs) + { + this->ptr = rhs.ptr; + this->len = rhs.len; + return *this; + } + + StrPtrLen &operator=(const char* rhs) + { + this->ptr = rhs; + this->len = oscl_strlen(rhs); + return *this; + } + +} StrPtrLen; + +//! This data structure encapsulates a set of functions used to perform +/*! standard string operations. It should be used for null-terminated constant + strings (non-modifiable) of wchar type. +*/ +typedef struct WStrPtrLen +{ +protected: + const oscl_wchar* ptr; + int32 len; + +public: + + WStrPtrLen(const oscl_wchar* newPtr) + : ptr(newPtr) + { + len = oscl_strlen(newPtr); + } + + WStrPtrLen(const oscl_wchar* newPtr, uint32 newLen) + : ptr(newPtr), len(newLen) + {} + + WStrPtrLen() + : ptr(NULL), len(0) + {} + + WStrPtrLen(const WStrPtrLen& rhs) + : ptr(rhs.ptr), len(rhs.len) + {} + + const oscl_wchar* c_str() const + { + return ptr; + } + + int32 length() const + { + return len; + } + + int32 size() const + { + return len; + } + + void setPtrLen(const oscl_wchar* newPtr, uint32 newLen) + { + ptr = newPtr; + len = newLen; + } + + c_bool isCIEquivalentTo(const WStrPtrLen& rhs) const + { + if (len != rhs.len) + { + return false; + } + + for (int32 ii = 0; ii < len; ++ii) + { + if (OSCL_ASCII_CASE_MAGIC_BIT != ((ptr[ii] ^ rhs.ptr[ii]) | OSCL_ASCII_CASE_MAGIC_BIT)) + { + return false; + } + } + + return true; + } + + int32 operator==(const WStrPtrLen& rhs) const + { + if (len != rhs.len) + { + return (len - rhs.len); + } + return(!oscl_strncmp(ptr, rhs.ptr, rhs.len)); + } + + int32 operator!=(const WStrPtrLen& rhs) const + { + return !(*this == rhs); + } + + WStrPtrLen& operator=(const WStrPtrLen& rhs) + { + this->ptr = rhs.ptr; + this->len = rhs.len; + return *this; + } + + WStrPtrLen& operator=(const oscl_wchar* rhs) + { + this->ptr = rhs; + this->len = oscl_strlen(rhs); + return *this; + } + +} WStrPtrLen; + +//! same as StrPtrLen, but includes checksum field and method to speed up querying +typedef struct StrCSumPtrLen : public StrPtrLen +{ +public: + typedef int16 CheckSumType; + +protected: + CheckSumType checkSum; + +public: + + void setPtrLen(const char* newPtr, uint32 newLen) + { + StrPtrLen::setPtrLen(newPtr, newLen); + setCheckSum(); + } + + CheckSumType getCheckSum() const + { + return checkSum; + } + + OSCL_IMPORT_REF void setCheckSum(); + + StrCSumPtrLen() + : checkSum(0) + {} + + StrCSumPtrLen(const char* newPtr) + : StrPtrLen(newPtr) + { + setCheckSum(); + } + + StrCSumPtrLen(const char* newPtr, uint32 newLen) + : StrPtrLen(newPtr, newLen) + { + setCheckSum(); + } + + StrCSumPtrLen(const StrCSumPtrLen& rhs) + : StrPtrLen(rhs), checkSum(rhs.checkSum) + {} + + StrCSumPtrLen(const StrPtrLen & rhs) + : StrPtrLen(rhs) + { + setCheckSum(); + } + + + c_bool isCIEquivalentTo(const StrCSumPtrLen& rhs) const + { + if (getCheckSum() != rhs.getCheckSum()) + { + return false; + } + + return static_cast(*this).isCIEquivalentTo( + static_cast(rhs)); + } + + c_bool operator==(const StrCSumPtrLen& rhs) const + { + if (getCheckSum() != rhs.getCheckSum()) + { + return false; + } + + return (static_cast(*this) + == static_cast(rhs)); + } + + c_bool operator!=(const StrCSumPtrLen& rhs) const + { + return !(*this == rhs); + } + + StrCSumPtrLen& operator=(const StrCSumPtrLen& rhs) + { + StrPtrLen::operator=(rhs); + this->checkSum = rhs.checkSum; + return *this; + } + + StrCSumPtrLen& operator=(const StrPtrLen& rhs) + { + StrPtrLen::operator=(rhs); + setCheckSum(); + return *this; + } + + StrCSumPtrLen& operator=(const char* rhs) + { + StrPtrLen::operator=(rhs); + setCheckSum(); + return *this; + } + +} StrCSumPtrLen; + +// Set character code to UNICODE +typedef WStrPtrLen OSCL_TStrPtrLen; + +#endif // OSCL_STR_PTR_LEN_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string.cpp new file mode 100644 index 0000000..34d7ab8 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string.cpp @@ -0,0 +1,485 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S T R I N G C L A S S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#include "oscl_string.h" +#include "oscl_error.h" +#include "oscl_stdstring.h" +#include "oscl_utf8conv.h" + +#ifndef OSCL_COMBINED_DLL +#include "oscl_dll.h" +OSCL_DLL_ENTRY_POINT_DEFAULT() +#endif + +// ************************************************************** +// OSCL_String Implementation +// OSCL_wString Implementation +// ************************************************************** + +OSCL_EXPORT_REF OSCL_String::OSCL_String() +{} + +OSCL_EXPORT_REF OSCL_wString::OSCL_wString() +{} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_String::~OSCL_String() +{} + +OSCL_EXPORT_REF OSCL_wString::~OSCL_wString() +{} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_String::chartype OSCL_String::read(uint32 index) const +//default implementation-- may be replaced by derived class +{ + //allow reading entire string incl null terminator. + if (index > get_size()) + OsclError::Leave(OsclErrGeneral);//invalid index. + return get_cstr()[index]; +} + +OSCL_EXPORT_REF OSCL_wString::chartype OSCL_wString::read(uint32 index) const +//default implementation-- may be replaced by derived class +{ + //allow reading entire string incl null terminator. + if (index > get_size()) + OsclError::Leave(OsclErrGeneral);//invalid index. + return get_cstr()[index]; +} + +// ************************************************************** +OSCL_EXPORT_REF bool OSCL_String::operator==(const OSCL_String& a) const +{ + return (get_size() == a.get_size() + && oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) == 0); +} + +OSCL_EXPORT_REF bool OSCL_wString::operator==(const OSCL_wString& a) const +{ + return (get_size() == a.get_size() + && oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) == 0); +} + +// ************************************************************** +OSCL_EXPORT_REF bool OSCL_String::operator==(const chartype* a) const +{ + uint32 len = (a) ? oscl_strlen(a) : 0; + return (get_size() == len + && oscl_strncmp(get_cstr(), a, len) == 0); +} + +OSCL_EXPORT_REF bool OSCL_wString::operator==(const chartype* a) const +{ + uint32 len = (a) ? oscl_strlen(a) : 0; + return (get_size() == len + && oscl_strncmp(get_cstr(), a, len) == 0); +} + +// ************************************************************** +OSCL_EXPORT_REF bool OSCL_String::operator!=(const OSCL_String& a) const +{ + return (get_size() != a.get_size() + || oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) != 0); +} + +OSCL_EXPORT_REF bool OSCL_wString::operator!=(const OSCL_wString& a) const +{ + return (get_size() != a.get_size() + || oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) != 0); +} + +// ************************************************************** +OSCL_EXPORT_REF bool OSCL_String::operator>(const OSCL_String& a) const +{ + return (oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) > 0); +} + +OSCL_EXPORT_REF bool OSCL_wString::operator>(const OSCL_wString& a) const +{ + return (oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) > 0); +} + +// ************************************************************** +OSCL_EXPORT_REF bool OSCL_String::operator>=(const OSCL_String& a) const +{ + return (oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) >= 0); +} + +OSCL_EXPORT_REF bool OSCL_wString::operator>=(const OSCL_wString& a) const +{ + return (oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) >= 0); +} + +// ************************************************************** +OSCL_EXPORT_REF bool OSCL_String::operator<=(const OSCL_String& a) const +{ + return (oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) <= 0); +} + +OSCL_EXPORT_REF bool OSCL_wString::operator<=(const OSCL_wString& a) const +{ + return (oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) <= 0); +} + +// ************************************************************** +OSCL_EXPORT_REF bool OSCL_String::operator<(const OSCL_String& a) const +{ + return (oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) < 0); +} + +OSCL_EXPORT_REF bool OSCL_wString::operator<(const OSCL_wString& a) const +{ + return (oscl_strncmp(get_cstr(), a.get_cstr(), a.get_size()) < 0); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_String::chartype OSCL_String::operator[](uint32 index) const +{ + if (index > get_size()) + OsclError::Leave(OsclErrGeneral);//invalid index. + return get_cstr()[index]; +} + +OSCL_EXPORT_REF OSCL_wString::chartype OSCL_wString::operator[](uint32 index) const +{ + if (index > get_size()) + OsclError::Leave(OsclErrGeneral);//invalid index. + return get_cstr()[index]; +} + +// ************************************************************** +OSCL_EXPORT_REF bool OSCL_String::is_writable() const +//default implementation-- may be replaced by derived class +{ + return (get_str() != NULL); +} + +OSCL_EXPORT_REF bool OSCL_wString::is_writable() const +//default implementation-- may be replaced by derived class +{ + return (get_str() != NULL); +} + +// ************************************************************** +OSCL_EXPORT_REF void OSCL_String::write(uint32 index, chartype c) +//default implementation-- may be replaced by derived class +{ + chartype* curbuf = get_str(); + if (!curbuf) + OsclError::Leave(OsclErrGeneral);//not writable. + + if (c == '\0') + { + if (index > get_size()) + OsclError::Leave(OsclErrGeneral);//invalid index. + curbuf[index] = c; + set_len(index); + } + else + { + if (index >= get_size()) + OsclError::Leave(OsclErrGeneral);//invalid index. + curbuf[index] = c; + } +} + +OSCL_EXPORT_REF void OSCL_wString::write(uint32 index, chartype c) +//default implementation-- may be replaced by derived class +{ + chartype* curbuf = get_str(); + if (!curbuf) + OsclError::Leave(OsclErrGeneral);//not writable. + + if (c == '\0') + { + if (index > get_size()) + OsclError::Leave(OsclErrGeneral);//invalid index. + curbuf[index] = c; + set_len(index); + } + else + { + if (index >= get_size()) + OsclError::Leave(OsclErrGeneral);//invalid index. + curbuf[index] = c; + } +} + +// ************************************************************** +OSCL_EXPORT_REF void OSCL_String::write(uint32 offset, uint32 length, const chartype* ptr) +//default implementation-- may be replaced by derived class +{ + if (!ptr || length == 0) + return; + + chartype* curbuf = get_str(); + if (!curbuf) + OsclError::Leave(OsclErrGeneral);//not writable. + + if (offset > get_size()) + OsclError::Leave(OsclErrGeneral);//invalid offset. + + if (length + offset > get_size()) + { + //extend length... + uint32 ncopy = length; + if (length + offset > get_maxsize()) + ncopy = get_maxsize() - offset;//truncate + oscl_strncpy(curbuf + offset, ptr, ncopy); + curbuf[offset+ncopy] = '\0'; + set_len(oscl_strlen(curbuf)); + } + else + { + //write within current length + oscl_strncpy(curbuf + offset, ptr, length); + } +} + +OSCL_EXPORT_REF void OSCL_wString::write(uint32 offset, uint32 length, const chartype* ptr) +//default implementation-- may be replaced by derived class +{ + if (!ptr || length == 0) + return; + + chartype* curbuf = get_str(); + if (!curbuf) + OsclError::Leave(OsclErrGeneral);//not writable. + + if (offset > get_size()) + OsclError::Leave(OsclErrGeneral);//invalid offset. + + if (length + offset > get_size()) + { + //extend length... + uint32 ncopy = length; + if (length + offset > get_maxsize()) + ncopy = get_maxsize() - offset;//truncate + oscl_strncpy(curbuf + offset, ptr, ncopy); + curbuf[offset+ncopy] = '\0'; + set_len(oscl_strlen(curbuf)); + } + else + { + //write within current length + oscl_strncpy(curbuf + offset, ptr, length); + } +} + +// ************************************************************** +OSCL_EXPORT_REF uint32 OSCL_String::setrep_to_char(const oscl_wchar* src, + uint32 len, TOSCL_StringOp op, Oscl_DefAlloc* aAlloc) +//default implementation-- may be replaced by derived class +{ + // utf8 can occupy up to MAX_NUMBER_OF_BYTE_PER_UTF8 bytes per char + uint maxutf8len = (len + 1) * MAX_NUMBER_OF_BYTE_PER_UTF8; + char* ptr = NULL; + if (aAlloc) + ptr = (char*) aAlloc->allocate(maxutf8len); + else + ptr = (char*) OSCL_MALLOC(maxutf8len); + uint32 i = 0; + if (!ptr) + return 0; + if (op == EOSCL_StringOp_CompressASCII) + { //casting from wide-character to single-wide without conversion + for (; i < len ; i++) + ptr[i] = (char)src[i]; + ptr[i] = '\0'; + } + else if (op == EOSCL_StringOp_UTF16ToUTF8) + i = oscl_UnicodeToUTF8(src, len, ptr, maxutf8len); + if (i || len == 0) // len==0 case always successes even in utf8conv + set_rep(ptr); + if (aAlloc) + aAlloc->deallocate(ptr); + else + OSCL_FREE(ptr); + if (len > 0 && i == 0) + OsclError::Leave(OsclErrNoMemory);//utf8conv failure. + return i; +} + +// ************************************************************** +OSCL_EXPORT_REF uint32 OSCL_wString::setrep_to_wide_char(const char* src, + uint32 len, TOSCL_wStringOp op, Oscl_DefAlloc* aAlloc) +//default implementation-- may be replaced by derived class +{ + oscl_wchar* ptr = NULL; + if (aAlloc) + ptr = (oscl_wchar*) aAlloc->allocate(sizeof(oscl_wchar) * (len + 1)); + else + ptr = (oscl_wchar*) OSCL_MALLOC(sizeof(oscl_wchar) * (len + 1)); + if (!ptr) + return 0; + uint32 i = 0; + if (op == EOSCL_wStringOp_ExpandASCII) + { //casting from single-wide to wide-character without conversion + for (; i < len; i++) + ptr[i] = (oscl_wchar)src[i]; + ptr[i] = '\0'; + } + else if (op == EOSCL_wStringOp_UTF8ToUTF16) + i = oscl_UTF8ToUnicode(src, len, ptr, len + 1); + if (i || len == 0) // len==0 case always successes even in utf8conv + set_rep(ptr); + if (aAlloc) + aAlloc->deallocate(ptr); + else + OSCL_FREE(ptr); + if (len > 0 && i == 0) + OsclError::Leave(OsclErrNoMemory);//utf8conv failure. + return i; +} + +// ************************************************************** +OSCL_EXPORT_REF int8 OSCL_String::hash() const +//default implementation-- may be replaced by derived class +{ + if (!get_str()) + OsclError::Leave(OsclErrGeneral);//not writable. + + uint32 h = 0; + int8 uc = 0; + uint32 ii; + chartype* ptr; + + for (ii = 0, ptr = get_str() ; ii < get_size(); ++ii, ++ptr) + { + h = 5 * h + *ptr; + } + + for (ii = 0; ii < 4; ++ii) + { + uc ^= h & 0xFF; + h >>= 8; + } + + return (uc); +} + +OSCL_EXPORT_REF int8 OSCL_wString::hash() const +//default implementation-- may be replaced by derived class +{ + if (!get_str()) + OsclError::Leave(OsclErrGeneral);//not writable. + + uint32 h = 0; + int8 uc = 0; + uint32 ii; + chartype* ptr; + + for (ii = 0, ptr = get_str() ; ii < get_size(); ++ii, ++ptr) + { + h = 5 * h + *ptr; + } + + for (ii = 0; ii < 4; ++ii) + { + uc ^= h & 0xFF; + h >>= 8; + } + + return (uc); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_String& OSCL_String::operator=(const OSCL_String & src) +{ + set_rep(src); + return *this; +} + +OSCL_EXPORT_REF OSCL_wString& OSCL_wString::operator=(const OSCL_wString & src) +{ + set_rep(src); + return *this; +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_String& OSCL_String::operator=(const chartype * cp) +{ + set_rep(cp); + return *this; +} + +OSCL_EXPORT_REF OSCL_wString& OSCL_wString::operator=(const chartype * cp) +{ + set_rep(cp); + return *this; +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_String& OSCL_String::operator+=(const OSCL_String & src) +{ + append_rep(src); + return (*this); +} + +OSCL_EXPORT_REF OSCL_wString& OSCL_wString::operator+=(const OSCL_wString & src) +{ + append_rep(src); + return (*this); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_String& OSCL_String::operator+=(const chartype c) +{ + chartype tmp_str[2]; + tmp_str[0] = c; + tmp_str[1] = '\0'; + append_rep(&tmp_str[0]); + return (*this); +} + +OSCL_EXPORT_REF OSCL_wString& OSCL_wString::operator+=(const chartype c) +{ + chartype tmp_str[2]; + tmp_str[0] = c; + tmp_str[1] = '\0'; + append_rep(&tmp_str[0]); + return (*this); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_String& OSCL_String::operator+=(const chartype * cp) +{ + append_rep(cp); + return (*this); +} + +OSCL_EXPORT_REF OSCL_wString& OSCL_wString::operator+=(const chartype * cp) +{ + append_rep(cp); + return (*this); +} + + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string.h new file mode 100644 index 0000000..9ebe18f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string.h @@ -0,0 +1,322 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L_ S T R I N G C L A S S + +// This file contains a standardized set of string containers that +// can be used in place of character arrays. + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/*! + * \file oscl_string.h + * \brief Provides a standardized set of string containers that + * can be used in place of character arrays. + * + */ + + +#ifndef OSCL_STRING_H_INCLUDED +#define OSCL_STRING_H_INCLUDED + + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +/** Conversion operations for OSCL_String classes +*/ +enum TOSCL_StringOp +{ + //Compress from wide-character to single-wide without any conversion. + //This operation is only appropriate for ASCII strings. + EOSCL_StringOp_CompressASCII + //Compress from wide-character to single-side with UTF-16 to UTF-8 conversion + , EOSCL_StringOp_UTF16ToUTF8 +}; + +/** Conversion operations for OSCL_wString classes +*/ +enum TOSCL_wStringOp +{ + //Expand from single-wide to wide-character without any conversion. + //This operation is only appropriate for ASCII strings. + EOSCL_wStringOp_ExpandASCII + //Expand from single-wide to wide-character with UTF-8 to UTF-16 conversion. + , EOSCL_wStringOp_UTF8ToUTF16 +}; + +/** + A common base class for string classes with + "char" character format +*/ +class OSCL_IMPORT_REF OSCL_String : public HeapBase + +{ + public: + typedef char chartype; + + /** + This function returns the string size not including + the null-terminator. + */ + virtual uint32 get_size() const = 0; + + /** + This function returns the maximum available storage size, + not including null terminator. The maximum size may be + larger than the current string size. + */ + virtual uint32 get_maxsize() const = 0; + + /** + This function returns the C-style string for read access. + */ + virtual const chartype* get_cstr() const = 0; + + /** + This function returns true if the string is writable. + */ + virtual bool is_writable() const; + + /** + This function returns the C-style string for write access. + If the string is not writable it returns NULL. + */ + virtual chartype* get_str() const = 0; + + /** Assignment operator + */ + OSCL_String& operator=(const OSCL_String& src); + + /** Assignment operator + @param: null-terminated string + */ + OSCL_String& operator=(const chartype* cstr); + + /** Append operator. + This operator appends the input string to this object. + The string may be truncated to fit available storage. + */ + OSCL_String& operator+=(const OSCL_String& src); + + /** Append operator. + This operator appends the input string to this object. + The string may be truncated to fit available storage. + @param: null-terminated string + */ + OSCL_String& operator+=(const chartype* cstr); + + /** Append operator. + This operator appends the input character to this object. + The string may be truncated to fit available storage. + */ + OSCL_String& operator+=(const chartype c); + + /** Comparison operators + */ + bool operator== (const OSCL_String& src) const; + bool operator!= (const OSCL_String& src) const; + bool operator< (const OSCL_String& src) const; + bool operator<= (const OSCL_String& src) const; + bool operator> (const OSCL_String& src) const; + bool operator>= (const OSCL_String& src) const; + + /** Comparison operator + @param: null-terminated string + */ + bool operator== (const chartype* cstr) const; + + /** + This is subscript notation to access a character + at the given position. + If the index is outside the current size range then the + function leaves. + */ + chartype operator[](uint32 index) const; + + /** + This function returns the character at the given position. + If the index is outside the current size range then the + function leaves. + */ + virtual chartype read(uint32 index)const; + + /** + This function allocates a temp storage for performing one of + the following operations based on TOSCL_StringOp + - compress src string from oscl_wchar to utf8. + - convert src string from oscl_wchar to utf8. + call parent set_rep() to copy resulting string. + @param src: reference input string + @param len: length of string to operate on + @param op: type operation mentioned above + @param aAlloc: optional, memory allocator if available + @return length of compressed or converted string exclude terminated '\0'. + */ + virtual uint32 setrep_to_char(const oscl_wchar* src, uint32 len, + TOSCL_StringOp op, Oscl_DefAlloc* aAlloc); + /** + This function performs a hash operation on the string. + If the string is not writable, the function leaves. + */ + virtual int8 hash() const; + + /** + This function stores a character at the specified position. + If the string is not writable, the function leaves. + If the index is outside the current size range then the + function leaves. + */ + virtual void write(uint32 index, chartype c); + + /** + This function replaces characters at the specified offset + within the current string. + If the string is not writable, the function leaves. + The characters may be truncted to fit the current storage. + @param offset: the offset into the existing string buffer + @param length: number of characters to copy. + @param ptr: character buffer, not necessarily null-terminated. + */ + virtual void write(uint32 offset, uint32 length, const chartype* buf); + +#ifdef T_ARM +//ADS 1.2 compiler doesn't interpret "protected" correctly for templates. +//so the constructor/destructor need to be public. + public: +#else + protected: +#endif + OSCL_String(); + virtual ~OSCL_String(); + + protected: + /** Each representation class must implement these pure virtuals. + */ + + /** Set string representation to input + null-terminated string. + */ + virtual void set_rep(const chartype* cstr) = 0; + + /** Append the input null-terminated string to the current + string. The string may be truncated to fit the available + storage. + */ + virtual void append_rep(const chartype* cstr) = 0; + + /** Set string representation to input string. + */ + virtual void set_rep(const OSCL_String& src) = 0; + + /** Append the input string to the current string. + The string may be truncated to fit the available storage. + */ + virtual void append_rep(const OSCL_String& src) = 0; + + /** Update the length of the string. This function + will only be called when the string is writable. + */ + virtual void set_len(uint32 len) = 0; +}; + +/** + A common base class for string classes with + wide character (oscl_wchar) format. + OSCL_wString and OSCL_String are identical except + for the character format. + For descriptions, see OSCL_String. +*/ +class OSCL_IMPORT_REF OSCL_wString +{ + public: + typedef oscl_wchar chartype; + + virtual uint32 get_size() const = 0; + + virtual uint32 get_maxsize() const = 0; + + virtual const chartype* get_cstr() const = 0; + + virtual bool is_writable() const; + + virtual chartype* get_str() const = 0; + + OSCL_wString& operator=(const OSCL_wString& src); + OSCL_wString& operator=(const chartype* cstr); + + OSCL_wString& operator+=(const OSCL_wString& src); + OSCL_wString& operator+=(const chartype* cstr); + OSCL_wString& operator+=(const chartype c); + + bool operator== (const OSCL_wString& src) const; + bool operator!= (const OSCL_wString& src) const; + bool operator< (const OSCL_wString& src) const; + bool operator<= (const OSCL_wString& src) const; + bool operator> (const OSCL_wString& src) const; + bool operator>= (const OSCL_wString& src) const; + bool operator== (const chartype* cstr) const; + + chartype operator[](uint32 index) const; + + virtual chartype read(uint32 index)const; + + virtual uint32 setrep_to_wide_char(const char* src, uint32 len, + TOSCL_wStringOp op, Oscl_DefAlloc* aAlloc); + + virtual int8 hash() const; + + virtual void write(uint32 index, chartype c); + virtual void write(uint32 offset, uint32 length, const chartype* buf); + +#ifdef T_ARM +//ADS 1.2 compiler doesn't interpret "protected" correctly for templates. +//so the constructor/destructor need to be public. + public: +#else + protected: +#endif + OSCL_wString(); + virtual ~OSCL_wString(); + + protected: + virtual void set_rep(const chartype* cstr) = 0; + virtual void append_rep(const chartype* cstr) = 0; + + virtual void set_rep(const OSCL_wString& src) = 0; + virtual void append_rep(const OSCL_wString& src) = 0; + + virtual void set_len(uint32 len) = 0; +}; + +#endif // OSCL_STRING_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_containers.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_containers.cpp new file mode 100644 index 0000000..ead54b2 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_containers.cpp @@ -0,0 +1,1080 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S T R I N G C L A S S + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#include "oscl_string_containers.h" +#include "oscl_stdstring.h" +#include "oscl_error.h" +#include "oscl_utf8conv.h" + +// ************************************************************** +// CHeapRep Implementation +// ************************************************************** + +OSCL_EXPORT_REF void CHeapRep::set_rep(CHeapRep*& aRep, Oscl_DefAlloc& aAlloc, const char* cp, uint32 len) +//set heap rep to new string. +{ + CHeapRep*newrep = New(aAlloc); + if (newrep + && newrep->set(len, cp, aAlloc)) + { + CHeapRep::assign(aRep, newrep, aAlloc); + } + else + { + //could not allocate newrep or could not allocate buffer. + if (newrep) + aAlloc.deallocate(newrep); + OsclError::Leave(OsclErrNoMemory);//no memory + } +} + +// ************************************************************** +OSCL_EXPORT_REF void CHeapRep::set_rep(CHeapRep*& aRep, Oscl_DefAlloc& aAlloc, const oscl_wchar* cp, uint32 len) +//set heap rep to new string. +{ + CHeapRep*newrep = New(aAlloc); + if (newrep + && newrep->set(len, cp, aAlloc)) + { + CHeapRep::assign(aRep, newrep, aAlloc); + } + else + { + //could not allocate newrep or could not allocate buffer. + if (newrep) + aAlloc.deallocate(newrep); + OsclError::Leave(OsclErrNoMemory);//no memory + } +} + +// ************************************************************** +OSCL_EXPORT_REF void CHeapRep::append_rep(CHeapRep*& aRep, Oscl_DefAlloc& aAlloc, const char* cp, uint32 len) +//set heap rep to current string plus new string. +{ + CHeapRep*newrep = New(aAlloc); + if (newrep + && newrep->append((aRep) ? aRep->size : 0, (char*)((aRep) ? aRep->buffer : NULL), len, cp, aAlloc)) + { + CHeapRep::assign(aRep, newrep, aAlloc); + } + else + { + //could not allocate newrep or could not allocate buffer. + if (newrep) + aAlloc.deallocate(newrep); + OsclError::Leave(OsclErrNoMemory);//no memory + } +} + +// ************************************************************** +OSCL_EXPORT_REF void CHeapRep::append_rep(CHeapRep*& aRep, Oscl_DefAlloc& aAlloc, const oscl_wchar* cp, uint32 len) +//set heap rep to current string plus new string. +{ + CHeapRep*newrep = New(aAlloc); + if (newrep + && newrep->append((aRep) ? aRep->size : 0, (oscl_wchar*)((aRep) ? aRep->buffer : NULL), len, cp, aAlloc)) + { + CHeapRep::assign(aRep, newrep, aAlloc); + } + else + { + //could not allocate newrep or could not allocate buffer. + if (newrep) + aAlloc.deallocate(newrep); + OsclError::Leave(OsclErrNoMemory);//no memory + } +} + +// ************************************************************** +OSCL_EXPORT_REF void CHeapRep::assign(CHeapRep*& dest, CHeapRep* src, Oscl_DefAlloc &alloc) +{ + if (src) + src->add_ref(); + if (dest) + dest->remove_ref(alloc); + dest = src; +} + +// ************************************************************** +CHeapRep* CHeapRep::New(Oscl_DefAlloc &alloc) +{ + OsclAny *ptr = alloc.ALLOCATE(sizeof(CHeapRep)); + if (ptr) + { + CHeapRep*newrep = new(ptr) CHeapRep; + return newrep; + } + return NULL; +} + +// ************************************************************** +OSCL_EXPORT_REF bool CHeapRep::set(uint32 nsz, const char*cp, Oscl_DefAlloc &alloc) +{ + // allocate enough space including terminator + OsclAny* ptr = alloc.ALLOCATE(sizeof(char) * (nsz + 1)); + if (!ptr) + { + refcount = 0; + size = 0; + maxsize = 0; + buffer = NULL; + return false;//can't allocate buffer. + } + refcount = 0; + size = nsz; + maxsize = nsz; + buffer = ptr; + if (cp) + oscl_strncpy((char*)buffer, cp, size); + ((char*)buffer)[size] = '\0'; + return true; +} +OSCL_EXPORT_REF bool CHeapRep::set(uint32 nsz, const oscl_wchar*cp, Oscl_DefAlloc &alloc) +{ + // allocate enough space including terminator + OsclAny* ptr = alloc.ALLOCATE(sizeof(oscl_wchar) * (nsz + 1)); + if (!ptr) + { + refcount = 0; + size = 0; + maxsize = 0; + buffer = NULL; + return false;//can't allocate buffer. + } + refcount = 0; + size = nsz; + maxsize = nsz; + buffer = ptr; + if (cp) + oscl_strncpy((oscl_wchar*)buffer, cp, size); + ((oscl_wchar*)buffer)[size] = '\0'; + return true; +} + +// ************************************************************** +OSCL_EXPORT_REF bool CHeapRep::append(uint32 s1, const char*cp1, + uint32 s2, const char*cp2, + Oscl_DefAlloc &alloc) +{ + maxsize = s1 + s2; + size = maxsize; + // allocate enough space including terminator + OsclAny* ptr = alloc.ALLOCATE(sizeof(char) * (maxsize + 1)); + if (!ptr) + { + refcount = 0; + size = 0; + maxsize = 0; + buffer = NULL; + return false;//can't allocate buffer. + } + refcount = 0; + buffer = ptr; + if (cp1) + oscl_strncpy((char*)buffer, cp1, s1); + ((char*)buffer)[s1] = '\0'; + if (cp2) + oscl_strncat((char*)buffer, cp2, s2); + ((char*)buffer)[size] = '\0'; + return true; +} + +OSCL_EXPORT_REF bool CHeapRep::append(uint32 s1, const oscl_wchar*cp1, + uint32 s2, const oscl_wchar*cp2, + Oscl_DefAlloc &alloc) +{ + maxsize = s1 + s2; + size = maxsize; + // allocate enough space including terminator + OsclAny* ptr = alloc.ALLOCATE(sizeof(oscl_wchar) * (maxsize + 1)); + if (!ptr) + { + refcount = 0; + size = 0; + maxsize = 0; + buffer = NULL; + return false;//can't allocate buffer. + } + refcount = 0; + buffer = ptr; + if (cp1) + oscl_strncpy((oscl_wchar*)buffer, cp1, s1); + ((oscl_wchar*)buffer)[s1] = '\0'; + if (cp2) + oscl_strncat((oscl_wchar*)buffer, cp2, s2); + ((oscl_wchar*)buffer)[size] = '\0'; + return true; +} + +// ************************************************************** +OSCL_EXPORT_REF void CHeapRep::add_ref() +{ + refcount++; +} + +// ************************************************************** +OSCL_EXPORT_REF void CHeapRep::remove_ref(Oscl_DefAlloc &alloc) +{ + --refcount; + if (refcount == 0) + { + alloc.deallocate(buffer); + alloc.deallocate(this); + } +} + +// ************************************************************** +// OSCL_HeapStringA Implementation +// OSCL_wHeapStringA Implementation +// ************************************************************** + +void OSCL_HeapStringA::set_rep(const chartype* cp, uint32 len) +//set heap rep to new string. +{ + CHeapRep::set_rep(iRep, *iAlloc, cp, len); +} + +void OSCL_wHeapStringA::set_rep(const chartype* cp, uint32 len) +//set heap rep to new string. +{ + CHeapRep::set_rep(iRep, *iAlloc, cp, len); +} + +// ************************************************************** +void OSCL_HeapStringA::append_rep(const chartype* cp, uint32 len) +//set heap rep to current string plus new string. +{ + CHeapRep::append_rep(iRep, *iAlloc, cp, len); +} + +void OSCL_wHeapStringA::append_rep(const chartype* cp, uint32 len) +//set heap rep to current string plus new string. +{ + CHeapRep::append_rep(iRep, *iAlloc, cp, len); +} + +// ************************************************************** +void OSCL_HeapStringA::set_rep(const chartype* cp) +{ + uint32 len = (cp) ? oscl_strlen(cp) : 0; + set_rep(cp, len); +} + +void OSCL_wHeapStringA::set_rep(const chartype* cp) +{ + uint32 len = (cp) ? oscl_strlen(cp) : 0; + set_rep(cp, len); +} + + +// ************************************************************** +void OSCL_HeapStringA::append_rep(const chartype* cp) +{ + uint32 len = (cp) ? oscl_strlen(cp) : 0; + append_rep(cp, len); +} + +void OSCL_wHeapStringA::append_rep(const chartype* cp) +{ + uint32 len = (cp) ? oscl_strlen(cp) : 0; + append_rep(cp, len); +} + + +// ************************************************************** +void OSCL_HeapStringA::set_rep(const OSCL_String& src) +{ + set_rep(src.get_cstr(), src.get_size()); +} + +void OSCL_wHeapStringA::set_rep(const OSCL_wString& src) +{ + set_rep(src.get_cstr(), src.get_size()); +} + + +// ************************************************************** +void OSCL_HeapStringA::append_rep(const OSCL_String& src) +{ + append_rep(src.get_cstr(), src.get_size()); +} + +void OSCL_wHeapStringA::append_rep(const OSCL_wString& src) +{ + append_rep(src.get_cstr(), src.get_size()); +} + + +// ************************************************************** +OSCL_EXPORT_REF uint32 OSCL_HeapStringA::get_size() const +{ + if (iRep) + return iRep->size; + return 0; +} + +OSCL_EXPORT_REF uint32 OSCL_wHeapStringA::get_size() const +{ + if (iRep) + return iRep->size; + return 0; +} + +// ************************************************************** +void OSCL_HeapStringA::set_len(uint32 len) +{ + iRep->size = len; +} + +void OSCL_wHeapStringA::set_len(uint32 len) +{ + iRep->size = len; +} + + +// ************************************************************** +OSCL_EXPORT_REF uint32 OSCL_HeapStringA::get_maxsize() const +{ + if (iRep) + return iRep->maxsize; + return 0; +} + +OSCL_EXPORT_REF uint32 OSCL_wHeapStringA::get_maxsize() const +{ + if (iRep) + return iRep->maxsize; + return 0; +} + + +// ************************************************************** +OSCL_EXPORT_REF const OSCL_HeapStringA::chartype* OSCL_HeapStringA::get_cstr() const +{ + if (iRep) + return (chartype*)iRep->buffer; + return NULL; +} + +OSCL_EXPORT_REF const OSCL_wHeapStringA::chartype* OSCL_wHeapStringA::get_cstr() const +{ + if (iRep) + return (chartype*)iRep->buffer; + return NULL; +} + + +// ************************************************************** +OSCL_EXPORT_REF OSCL_HeapStringA::chartype* OSCL_HeapStringA::get_str() const +{ + if (iRep) + return (chartype*)iRep->buffer; + return NULL; +} + +OSCL_EXPORT_REF OSCL_wHeapStringA::chartype* OSCL_wHeapStringA::get_str() const +{ + if (iRep) + return (chartype*)iRep->buffer; + return NULL; +} + + +// ************************************************************** +void OSCL_HeapStringA::create(Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + iRep = NULL; + if (alloc) + {//use an allocator owned by the caller that may also have a ref counter. + iAllocRef = ref; + if (iAllocRef) + iAllocRef->addRef(); + iAlloc = alloc; + } + else + {//use a basic allocator that resides in this object. + iAlloc = &iDefAlloc; + iAllocRef = NULL; + } +} + +void OSCL_wHeapStringA::create(Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + iRep = NULL; + if (alloc) + {//use an allocator owned by the caller that may also have a ref counter. + iAllocRef = ref; + if (iAllocRef) + iAllocRef->addRef(); + iAlloc = alloc; + } + else + {//use a basic allocator that resides in this object. + iAlloc = &iDefAlloc; + iAllocRef = NULL; + } +} + + +// ************************************************************** +OSCL_EXPORT_REF OSCL_HeapStringA::OSCL_HeapStringA() +{ + create(NULL, NULL); + set_rep(NULL); +} +OSCL_EXPORT_REF OSCL_HeapStringA::OSCL_HeapStringA(Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + create(alloc, ref); + set_rep(NULL); +} + +OSCL_EXPORT_REF OSCL_wHeapStringA::OSCL_wHeapStringA() +{ + create(NULL, NULL); + set_rep(NULL); +} +OSCL_EXPORT_REF OSCL_wHeapStringA::OSCL_wHeapStringA(Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + create(alloc, ref); + set_rep(NULL); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_HeapStringA::OSCL_HeapStringA(const chartype* cp, Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + create(alloc, ref); + set_rep(cp); +} + +OSCL_EXPORT_REF OSCL_wHeapStringA::OSCL_wHeapStringA(const chartype* cp, Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + create(alloc, ref); + set_rep(cp); +} + +// ************************************************************** +OSCL_EXPORT_REF void OSCL_HeapStringA::set(const chartype* cp, uint32 length) +{ + set_rep(cp, length); + //just in case input string is shorter than 'length' + iRep->size = oscl_strlen(get_cstr()); +} + +OSCL_EXPORT_REF void OSCL_wHeapStringA::set(const chartype* cp, uint32 length) +{ + set_rep(cp, length); + //just in case input string is shorter than 'length' + iRep->size = oscl_strlen(get_cstr()); +} + +// ************************************************************** + +OSCL_EXPORT_REF void OSCL_HeapStringA::set(const other_chartype* buf, optype op) +{ + iRep->size = setrep_to_char(buf, oscl_strlen(buf), op, iAlloc); +} + +OSCL_EXPORT_REF void OSCL_wHeapStringA::set(const other_chartype* buf, optype op) +{ + iRep->size = setrep_to_wide_char(buf, oscl_strlen(buf), op, iAlloc); +} + +// ************************************************************** + +OSCL_EXPORT_REF void OSCL_HeapStringA::set(const other_chartype* buf, uint32 length, optype op) +{ + iRep->size = setrep_to_char(buf, length, op, iAlloc); +} + +OSCL_EXPORT_REF void OSCL_wHeapStringA::set(const other_chartype* buf, uint32 length, optype op) +{ + iRep->size = setrep_to_wide_char(buf, length, op, iAlloc); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_HeapStringA::OSCL_HeapStringA(const chartype* cp, uint32 length, Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + create(alloc, ref); + set(cp, length); +} + +OSCL_EXPORT_REF OSCL_wHeapStringA::OSCL_wHeapStringA(const chartype* cp, uint32 length, Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + create(alloc, ref); + set(cp, length); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_HeapStringA::OSCL_HeapStringA(const OSCL_HeapStringA& src) : OSCL_String(src) +{ + create(NULL, NULL); + *this = src;//uses heapstring=heapstring overload. +} +OSCL_EXPORT_REF OSCL_HeapStringA::OSCL_HeapStringA(const OSCL_HeapStringA& src, Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + create(alloc, ref); + *this = src;//uses heapstring=heapstring overload. +} + +OSCL_EXPORT_REF OSCL_wHeapStringA::OSCL_wHeapStringA(const OSCL_wHeapStringA& src) : OSCL_wString(src) +{ + create(NULL, NULL); + *this = src;//uses heapstring=heapstring overload. +} +OSCL_EXPORT_REF OSCL_wHeapStringA::OSCL_wHeapStringA(const OSCL_wHeapStringA& src , Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + create(alloc, ref); + *this = src;//uses heapstring=heapstring overload. +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_HeapStringA::OSCL_HeapStringA(const OSCL_String& src, Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + create(alloc, ref); + set_rep(src); +} + +OSCL_EXPORT_REF OSCL_wHeapStringA::OSCL_wHeapStringA(const OSCL_wString& src , Oscl_DefAlloc *alloc, OsclRefCounter *ref) +{ + create(alloc, ref); + set_rep(src); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_HeapStringA::~OSCL_HeapStringA() +{ + //remove ref to string rep + if (iRep) + iRep->remove_ref(*iAlloc); + //remove ref to allocator. + if (iAllocRef) + iAllocRef->removeRef(); +} + +OSCL_EXPORT_REF OSCL_wHeapStringA::~OSCL_wHeapStringA() +{ + //remove ref to string rep + if (iRep) + iRep->remove_ref(*iAlloc); + //remove ref to allocator. + if (iAllocRef) + iAllocRef->removeRef(); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_HeapStringA& OSCL_HeapStringA::operator=(const OSCL_HeapStringA & src) +{ + //the allocators must match in order to re-use + //the heap string representation. + //Allocators match if they're the same object, + //or they're both the default allocators. + if (src.iRep + && ((src.iAlloc == (Oscl_DefAlloc*)&src.iDefAlloc + && iAlloc == &iDefAlloc) + || src.iAlloc == iAlloc)) + { + CHeapRep::assign(iRep, src.iRep, *iAlloc); + } + else + {//otherwise, create a new representation + set_rep(src); + } + return (*this); +} + +OSCL_EXPORT_REF OSCL_wHeapStringA& OSCL_wHeapStringA::operator=(const OSCL_wHeapStringA & src) +{ + //the allocators must match in order to re-use + //the heap string representation. + //Allocators match if they're the same object, + //or they're both the default allocators. + if (src.iRep + && ((src.iAlloc == (Oscl_DefAlloc*)&src.iDefAlloc + && iAlloc == &iDefAlloc) + || src.iAlloc == iAlloc)) + { + CHeapRep::assign(iRep, src.iRep, *iAlloc); + } + else + {//otherwise, create a new representation + set_rep(src); + } + return (*this); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_HeapStringA& OSCL_HeapStringA::operator=(const chartype * cp) +{ + set_rep(cp); + return (*this); +} + +OSCL_EXPORT_REF OSCL_wHeapStringA& OSCL_wHeapStringA::operator=(const chartype * cp) +{ + set_rep(cp); + return (*this); +} + +// ************************************************************** +// CStackRep Implementation +// ************************************************************** + +OSCL_EXPORT_REF void CStackRep::set(const char* cp, uint32 len) +{ + if (len > maxsize) + size = maxsize;//truncate + else + size = len; + if (cp) + oscl_strncpy((char*)buffer, cp, size); + ((char*)buffer)[size] = '\0'; +} +OSCL_EXPORT_REF void CStackRep::set(const oscl_wchar* cp, uint32 len) +{ + if (len > maxsize) + size = maxsize;//truncate + else + size = len; + if (cp) + oscl_strncpy((oscl_wchar*)buffer, cp, size); + ((oscl_wchar*)buffer)[size] = '\0'; +} + +// ************************************************************** +OSCL_EXPORT_REF void CStackRep::append(const char* cp, uint32 alen) +{ + uint32 len = alen; + if (size + len > maxsize) + len = maxsize - size;//truncate + if (len > 0) + { + size = size + len; + oscl_strncat((char*)buffer, cp, len); + ((char*)buffer)[size] = '\0'; + } +} +OSCL_EXPORT_REF void CStackRep::append(const oscl_wchar* cp, uint32 alen) +{ + uint32 len = alen; + if (size + len > maxsize) + len = maxsize - size;//truncate + if (len > 0) + { + size = size + len; + oscl_strncat((oscl_wchar*)buffer, cp, len); + ((oscl_wchar*)buffer)[size] = '\0'; + } +} + +// ************************************************************** +// CFastRep Implementation +// ************************************************************** + +OSCL_EXPORT_REF void CFastRep::set_r(const char* cp, uint32 len) +{ + size = len; + maxsize = len; + buffer = (OsclAny*)cp; + writable = false; +} +OSCL_EXPORT_REF void CFastRep::set_r(const oscl_wchar* cp, uint32 len) +{ + size = len; + maxsize = len; + buffer = (OsclAny*)cp; + writable = false; +} + +// ************************************************************** +OSCL_EXPORT_REF void CFastRep::set_w(char* cp, uint32 len, uint32 maxlen) +{ + size = len; + if (overwrite) + { + oscl_strncpy((char*)buffer, cp, size); + ((char*) buffer)[size] = '\0'; + overwrite = false; + } + else + { + maxsize = maxlen; + buffer = (OsclAny*)cp; + } + writable = true; +} +OSCL_EXPORT_REF void CFastRep::set_w(oscl_wchar* cp, uint32 len, uint32 maxlen) +{ + size = len; + if (overwrite) + { + oscl_strncpy((oscl_wchar*)buffer, cp, size); + ((oscl_wchar*) buffer)[size] = '\0'; + overwrite = false; + } + else + { + maxsize = maxlen; + buffer = (OsclAny*)cp; + } + writable = true; +} + +// ************************************************************** +OSCL_EXPORT_REF void CFastRep::append(const char* cp, uint32 len) +{ + uint32 ncopy = len; + if (size + len > maxsize) + ncopy = maxsize - size;//truncate + if (ncopy > 0) + { + oscl_strncat((char*)buffer, cp, ncopy); + size += ncopy; + if (!writable) + maxsize = size; + } +} +OSCL_EXPORT_REF void CFastRep::append(const oscl_wchar* cp, uint32 len) +{ + uint32 ncopy = len; + if (size + len > maxsize) + ncopy = maxsize - size;//truncate + if (ncopy > 0) + { + oscl_strncat((oscl_wchar*)buffer, cp, ncopy); + size += ncopy; + if (!writable) + maxsize = size; + } +} + +// ************************************************************** +// OSCL_FastString Implementation +// OSCL_wFastString Implementation +// ************************************************************** +void OSCL_FastString::set_rep(const chartype* cp) +{ + uint32 len = (cp) ? oscl_strlen(cp) : 0; + if (rep.overwrite) + rep.set_w((char*)cp, len, rep.maxsize); + else + rep.set_r(cp, len); +} + +void OSCL_wFastString::set_rep(const chartype* cp) +{ + uint32 len = (cp) ? oscl_strlen(cp) : 0; + if (rep.overwrite) + rep.set_w((oscl_wchar*)cp, len, rep.maxsize); + else + rep.set_r(cp, len); +} + +// ************************************************************** +void OSCL_FastString::append_rep(const chartype* cp) +{ + uint32 len = (cp) ? oscl_strlen(cp) : 0; + rep.append(cp, len); +} + +void OSCL_wFastString::append_rep(const chartype* cp) +{ + uint32 len = (cp) ? oscl_strlen(cp) : 0; + rep.append(cp, len); +} + + +// ************************************************************** +void OSCL_FastString::set_rep(const OSCL_String& src) +{ + //inherit the writable-ness of the source string. + if (src.get_str()) + rep.set_w(src.get_str(), src.get_size(), src.get_maxsize()); + else + rep.set_r(src.get_cstr(), src.get_size()); +} + +void OSCL_wFastString::set_rep(const OSCL_wString& src) +{ + //inherit the writable-ness of the source string. + if (src.get_str()) + rep.set_w(src.get_str(), src.get_size(), src.get_maxsize()); + else + rep.set_r(src.get_cstr(), src.get_size()); +} + +// ************************************************************** +void OSCL_FastString::append_rep(const OSCL_String& src) +{ + rep.append(src.get_cstr(), src.get_size()); +} + +void OSCL_wFastString::append_rep(const OSCL_wString& src) +{ + rep.append(src.get_cstr(), src.get_size()); +} + +// ************************************************************** +void OSCL_FastString::set_len(uint32 len) +{ + rep.size = len; +} +void OSCL_wFastString::set_len(uint32 len) +{ + rep.size = len; +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_FastString::OSCL_FastString() +{ + set_rep(NULL); +} + +OSCL_EXPORT_REF OSCL_wFastString::OSCL_wFastString() +{ + set_rep(NULL); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_FastString::OSCL_FastString(const chartype* cp) +{ + set_rep(cp); +} + +OSCL_EXPORT_REF OSCL_wFastString::OSCL_wFastString(const chartype* cp) +{ + set_rep(cp); +} + +// ************************************************************** +OSCL_EXPORT_REF void OSCL_FastString::set(chartype* cp, uint32 maxlen) +{ + //set string to new writable buffer. + //make sure buffer is null-terminated + for (uint32 i = 0; i <= maxlen; i++) + { + if (cp[i] == '\0') + { + rep.set_w(cp, i, maxlen); + return; + } + } + OsclError::Leave(OsclErrGeneral);//not null-terminated +} + +OSCL_EXPORT_REF void OSCL_wFastString::set(chartype* cp, uint32 maxlen) +{ + //set string to new writable buffer. + //make sure buffer is null-terminated + for (uint32 i = 0; i <= maxlen; i++) + { + if (cp[i] == '\0') + { + rep.set_w(cp, i, maxlen); + return; + } + } + OsclError::Leave(OsclErrGeneral);//not null-terminated +} + +// ************************************************************** +OSCL_EXPORT_REF void OSCL_FastString::set(const other_chartype* buf, uint32 numofbyte, optype op) +{ + //copy string to new writable buffer. + //make sure buffer is null-terminated + //validate buf has enough space to continue + for (uint32 i = 0; i <= numofbyte; i++) + { + if (buf[i] == '\0') + { + uint32 byte_needed = i + 1; // i+1: actual chartype length includes '\0' + if (op == EOSCL_StringOp_UTF16ToUTF8) + byte_needed = i * MAX_NUMBER_OF_BYTE_PER_UTF8 + 1; // one byte for '\0' + if (numofbyte >= byte_needed) + { + rep.overwrite = true; + // actual byte space for conversion excludes '\0' + rep.maxsize = numofbyte - 1; + rep.buffer = (char*)buf; + setrep_to_char(buf, i, op, NULL); + return; + } + break; + } + } + OsclError::Leave(OsclErrGeneral);//not null-terminated +} + +OSCL_EXPORT_REF void OSCL_wFastString::set(const other_chartype* buf, uint32 numofbyte, optype op) +{ + //copy string to new writable buffer. + //make sure buffer is null-terminated + //validate buf has enough space to continue + for (uint32 i = 0; i <= numofbyte / sizeof(oscl_wchar); i++) + { + if (buf[i] == '\0') + { + if (numofbyte >= (i + 1)*sizeof(oscl_wchar)) + { + rep.overwrite = true; + rep.maxsize = numofbyte / sizeof(oscl_wchar) - 1; + rep.buffer = (oscl_wchar*)buf; + setrep_to_wide_char(buf, rep.maxsize, op, NULL); + return; + } + break; + } + } + OsclError::Leave(OsclErrGeneral);//not null-terminated +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_FastString::OSCL_FastString(chartype* cp, uint32 maxlen) +{ + set(cp, maxlen); +} + +OSCL_EXPORT_REF OSCL_wFastString::OSCL_wFastString(chartype* cp, uint32 maxlen) +{ + set(cp, maxlen); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_FastString::OSCL_FastString(const OSCL_FastString& src) : OSCL_String(src) +{ + set_rep(src); +} + +OSCL_EXPORT_REF OSCL_wFastString::OSCL_wFastString(const OSCL_wFastString& src) : OSCL_wString(src) +{ + set_rep(src); +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_FastString::~OSCL_FastString() +{ +} + +OSCL_EXPORT_REF OSCL_wFastString::~OSCL_wFastString() +{ +} + +// ************************************************************** +OSCL_EXPORT_REF void OSCL_FastString::set_length() +{ + rep.size = oscl_strlen(get_cstr()); + //for read-only string, the maxsize tracks the size. + if (!rep.writable) + rep.maxsize = rep.size; +} + +OSCL_EXPORT_REF void OSCL_wFastString::set_length() +{ + rep.size = oscl_strlen(get_cstr()); + //for read-only string, the maxsize tracks the size. + if (!rep.writable) + rep.maxsize = rep.size; +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_FastString& OSCL_FastString::operator=(const OSCL_FastString & src) +{ + set_rep(src); + return (*this); +} + +OSCL_EXPORT_REF OSCL_wFastString& OSCL_wFastString::operator=(const OSCL_wFastString & src) +{ + set_rep(src); + return (*this); +} + + +// ************************************************************** +OSCL_EXPORT_REF OSCL_FastString& OSCL_FastString::operator=(const chartype * cp) +{ + set_rep(cp); + return (*this); +} + +OSCL_EXPORT_REF OSCL_wFastString& OSCL_wFastString::operator=(const chartype * cp) +{ + set_rep(cp); + return (*this); +} + + +// ************************************************************** +OSCL_EXPORT_REF uint32 OSCL_FastString::get_size() const +{ + return rep.size; +} + +OSCL_EXPORT_REF uint32 OSCL_wFastString::get_size() const +{ + return rep.size; +} + +// ************************************************************** +OSCL_EXPORT_REF uint32 OSCL_FastString::get_maxsize() const +{ + return rep.maxsize; +} + +OSCL_EXPORT_REF uint32 OSCL_wFastString::get_maxsize() const +{ + return rep.maxsize; +} + +// ************************************************************** +OSCL_EXPORT_REF const OSCL_FastString::chartype* OSCL_FastString::get_cstr() const +{ + return (chartype*)rep.buffer; +} + +OSCL_EXPORT_REF const OSCL_wFastString::chartype* OSCL_wFastString::get_cstr() const +{ + return (chartype*)rep.buffer; +} + +// ************************************************************** +OSCL_EXPORT_REF OSCL_FastString::chartype* OSCL_FastString::get_str() const +{ + if (rep.writable) + return (chartype*)rep.buffer; + return NULL; +} + +OSCL_EXPORT_REF OSCL_wFastString::chartype* OSCL_wFastString::get_str() const +{ + if (rep.writable) + return (chartype*)rep.buffer; + return NULL; +} + + + + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_containers.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_containers.h new file mode 100644 index 0000000..c5b7126 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_containers.h @@ -0,0 +1,1429 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L_ S T R I N G _ C O N T A I N E R S +// +// This file contains a standardized set of string containers that +// can be used in place of character arrays. + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/*! + * \file oscl_string_containers.h + * \brief Provides a standardized set of string containers that + * can be used in place of character arrays. + * + */ + + +#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED +#define OSCL_STRING_CONTAINERS_H_INCLUDED + + +#ifndef OSCL_STRING_H_INCLUDED +#include "oscl_string.h" +#endif + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + +#ifndef OSCL_REFCOUNTER_H_INCLUDED +#include "oscl_refcounter.h" +#endif + +#ifndef OSCL_ERROR_H_INCLUDED +#include "oscl_error.h" +#endif + +#ifndef OSCL_STRING_REP_H_INCLUDED +#include "oscl_string_rep.h" +#endif + +#ifndef OSCL_STDSTRING_H_INCLUDED +#include "oscl_stdstring.h" +#endif + +#ifndef OSCL_MEM_H_INCLUDED +#include "oscl_mem.h" +#endif + +/** + OSCL_HeapString is a simple string class, compatible with + regular character array strings. + + The string array is variable length, is allocated from the heap, + and is modifiable. + A copy-on-write mechanism is used to minimize unnecessary copying when + multiple instances of a string are created for reading. + Allocated memory is automatically freed by the class destructor when + the last string referencing the memory is destroyed. + + The class HAS NO thread synchronization built-in, so it is NOT MT-SAFE. + External locks should be used if the class is to be shared across threads. + + @param Alloc: memory allocator, derived from Oscl_DefAlloc. +*/ +template +class OSCL_HeapString : public OSCL_String +{ + public: + typedef OSCL_String::chartype chartype; + + typedef TOSCL_StringOp optype; + typedef OSCL_wString::chartype other_chartype; + + /** + The default constructor creates an empty string. + */ + OSCL_HeapString(); + + /** + Creates a heap string that contains a copy of the input + string. + @param src: input string. + */ + OSCL_HeapString(const OSCL_HeapString& src); + OSCL_HeapString(const OSCL_String& src); + + /** + Creates a heap string that contains a copy of the input + string. + @param cp: null-terminated string. + */ + OSCL_HeapString(const chartype* cstr); + + /** + Creates a heap string that contains a copy of the input + string or character array. + @param src: character array, not necessarily null-terminated. + @param length: number of characters to copy. + */ + OSCL_HeapString(const chartype* buf, uint32 length); + + ~OSCL_HeapString(); + + /** Pure virtuals from OSCL_String + */ + uint32 get_size() const; + uint32 get_maxsize() const; + const chartype* get_cstr() const; + chartype* get_str() const; + + /** Assignment operators + */ + OSCL_HeapString& operator=(const OSCL_HeapString& src); + OSCL_HeapString& operator=(const OSCL_String& src); + OSCL_HeapString& operator=(const chartype* cstr); + + /** + Set the contents of this string to a new string or + character array. + @param buf: string or character array. + @param length: number of characters to copy. + */ + void set(const chartype* buf, uint32 length); + + /** + Set the contents of this string to a new string, + with conversion operation. + + @param buf: NULL-terminated wide string. + @param op: conversion operation to apply + */ + void set(const other_chartype* buf, optype op); + + /** + Set the contents of this string to a new string or + character array, with conversion operation. + + @param buf: string or character array. + @param length: number of characters to copy. + @param op: conversion operation to apply + */ + void set(const other_chartype* buf, uint32 length, optype op); + + private: + CHeapRep *iRep; + Alloc iAlloc; + void create(); + void set_rep(const chartype*, uint32); + void append_rep(const chartype*, uint32); + + /** Pure virtuals from OSCL_String. + */ + void set_rep(const chartype* cstr); + void append_rep(const chartype* cstr); + void set_rep(const OSCL_String& src); + void append_rep(const OSCL_String& src); + void set_len(uint32 len); + friend class OSCL_String; +}; + +/** + OSCL_wHeapString is identical to OSCL_HeapString + except that it uses wide-character format. + For descriptions, see OSCL_HeapString. +*/ +template +class OSCL_wHeapString : public OSCL_wString +{ + public: + typedef OSCL_wString::chartype chartype; + typedef TOSCL_wStringOp optype; + typedef OSCL_String::chartype other_chartype; + + OSCL_wHeapString(); + + OSCL_wHeapString(const OSCL_wHeapString& src); + OSCL_wHeapString(const OSCL_wString& src); + + OSCL_wHeapString(const chartype* cstr); + OSCL_wHeapString(const chartype* buf, uint32 length); + + ~OSCL_wHeapString(); + + uint32 get_size() const; + uint32 get_maxsize() const; + const chartype* get_cstr() const; + chartype* get_str() const; + + OSCL_wHeapString& operator=(const OSCL_wHeapString& src); + OSCL_wHeapString& operator=(const OSCL_wString& src); + OSCL_wHeapString& operator=(const chartype* cstr); + + void set(const chartype* buf, uint32 length); + + void set(const other_chartype* buf, optype op); + void set(const other_chartype* buf, uint32 length, optype op); + + private: + CHeapRep *iRep; + Alloc iAlloc; + void create(); + void set_rep(const chartype*, uint32); + void append_rep(const chartype*, uint32); + + void set_rep(const chartype* cstr); + void append_rep(const chartype* cstr); + void set_rep(const OSCL_wString& src); + void append_rep(const OSCL_wString& src); + void set_len(uint32 len); + friend class OSCL_wString; +}; + +/** + OSCL_HeapStringA is a simple string class, compatible with + regular character array strings. It is similar to + OSCL_HeapString, except that the allocator is passed at + run-time instead of compile-time. + The allocator pointer is passed in the constructor, and + may be a reference-counted object. + If the allocator is not a reference-counted object then it must + persist over the lifetime of all OSCL_HeapStringA objects that use it. + If no allocator is provided, then an OsclMemAllocator + will be used. + + The string array is variable length, is allocated from the heap, + and is modifiable. + A copy-on-write mechanism is used to minimize unnecessary copying when + multiple instances of a string are created for reading. + Allocated memory is automatically freed by the class destructor when + the last string referencing the memory is destroyed. + + The class HAS NO thread synchronization built-in, so it is NOT MT-SAFE. + External locks should be used if the class is to be shared across threads. + +*/ +class OSCL_HeapStringA : public OSCL_String +{ + public: + typedef OSCL_String::chartype chartype; + typedef TOSCL_StringOp optype; + typedef OSCL_wString::chartype other_chartype; + + /** + The default constructor creates an empty string. + @param: (optional) allocator or reference-counted allocator. + @param: (optional) reference counter associated with allocator object. + If no allocator is provided, this this object will use + an OsclMemAllocator. + */ + OSCL_IMPORT_REF OSCL_HeapStringA(); + OSCL_IMPORT_REF OSCL_HeapStringA(Oscl_DefAlloc *alloc, OsclRefCounter *ref = NULL); + + /** + Creates a heap string that contains a copy of the input + string. + @param src: input string. + @param: (optional) allocator or reference-counted allocator. + @param: (optional) reference counter associated with allocator object. + If no allocator is provided, this this object will use + an OsclMemAllocator. + */ + OSCL_IMPORT_REF OSCL_HeapStringA(const OSCL_HeapStringA& src); + OSCL_IMPORT_REF OSCL_HeapStringA(const OSCL_HeapStringA& src, Oscl_DefAlloc *alloc, OsclRefCounter *ref = NULL); + OSCL_IMPORT_REF OSCL_HeapStringA(const OSCL_String& src, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL); + + /** + Creates a heap string that contains a copy of the input + string. + @param cp: null-terminated string. + @param: (optional) allocator or reference-counted allocator. + @param: (optional) reference counter associated with allocator object. + If no allocator is provided, this this object will use + an OsclMemAllocator. + */ + OSCL_IMPORT_REF OSCL_HeapStringA(const chartype* cstr, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL); + + /** + Creates a heap string that contains a copy of the input + string or character array. + @param src: character array, not necessarily null-terminated. + @param length: number of characters to copy. + @param: (optional) allocator or reference-counted allocator. + @param: (optional) reference counter associated with allocator object. + If no allocator is provided, this this object will use + an OsclMemAllocator. + */ + OSCL_IMPORT_REF OSCL_HeapStringA(const chartype* buf, uint32 length, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL); + + OSCL_IMPORT_REF ~OSCL_HeapStringA(); + + /** Pure virtuals from OSCL_String + */ + OSCL_IMPORT_REF uint32 get_size() const; + OSCL_IMPORT_REF uint32 get_maxsize() const; + OSCL_IMPORT_REF const chartype* get_cstr() const; + OSCL_IMPORT_REF chartype* get_str() const; + + /** Assignment operators + */ + OSCL_IMPORT_REF OSCL_HeapStringA& operator=(const OSCL_HeapStringA& src); + OSCL_IMPORT_REF OSCL_HeapStringA& operator=(const OSCL_String& src); + OSCL_IMPORT_REF OSCL_HeapStringA& operator=(const chartype* cstr); + + /** + Set the contents of this string to a new string or + character array. + @param buf: string or character array. + @param length: number of characters to copy. + */ + OSCL_IMPORT_REF void set(const chartype* buf, uint32 length); + + /** + Set the contents of this string to a new string, + with conversion operation. + + @param buf: NULL-terminated wide string. + @param op: conversion operation to apply + */ + OSCL_IMPORT_REF void set(const other_chartype* buf, optype op); + + /** + Set the contents of this string to a new string or + character array, with conversion operation. + + @param buf: string or character array. + @param length: number of characters to copy. + @param op: conversion operation to apply + */ + OSCL_IMPORT_REF void set(const other_chartype* buf, uint32 length, optype op); + + private: + CHeapRep *iRep; + OsclRefCounter *iAllocRef; + Oscl_DefAlloc *iAlloc; + OsclMemAllocator iDefAlloc; + void create(Oscl_DefAlloc *, OsclRefCounter*); + void set_rep(const chartype*, uint32); + void append_rep(const chartype*, uint32); + + /** Pure virtuals from OSCL_String. + */ + void set_rep(const chartype* cstr); + void append_rep(const chartype* cstr); + void set_rep(const OSCL_String& src); + void append_rep(const OSCL_String& src); + void set_len(uint32 len); + friend class OSCL_String; +}; + +/** + OSCL_wHeapStringA is identical to OSCL_HeapStringA + except that it uses wide-character format. + For descriptions, see OSCL_HeapStringA. +*/ +class OSCL_wHeapStringA : public OSCL_wString +{ + public: + typedef OSCL_wString::chartype chartype; + typedef TOSCL_wStringOp optype; + typedef OSCL_String::chartype other_chartype; + + OSCL_IMPORT_REF OSCL_wHeapStringA(); + OSCL_IMPORT_REF OSCL_wHeapStringA(Oscl_DefAlloc *alloc, OsclRefCounter *ref = NULL); + + OSCL_IMPORT_REF OSCL_wHeapStringA(const OSCL_wHeapStringA& src); + OSCL_IMPORT_REF OSCL_wHeapStringA(const OSCL_wHeapStringA& src, Oscl_DefAlloc *alloc, OsclRefCounter *ref = NULL); + OSCL_IMPORT_REF OSCL_wHeapStringA(const OSCL_wString& src, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL); + + OSCL_IMPORT_REF OSCL_wHeapStringA(const chartype* cstr, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL); + + OSCL_IMPORT_REF OSCL_wHeapStringA(const chartype* buf, uint32 length, Oscl_DefAlloc *alloc = NULL, OsclRefCounter *ref = NULL); + + OSCL_IMPORT_REF ~OSCL_wHeapStringA(); + + OSCL_IMPORT_REF uint32 get_size() const; + OSCL_IMPORT_REF uint32 get_maxsize() const; + OSCL_IMPORT_REF const chartype* get_cstr() const; + OSCL_IMPORT_REF chartype* get_str() const; + + OSCL_IMPORT_REF OSCL_wHeapStringA& operator=(const OSCL_wHeapStringA& src); + OSCL_IMPORT_REF OSCL_wHeapStringA& operator=(const OSCL_wString& src); + OSCL_IMPORT_REF OSCL_wHeapStringA& operator=(const chartype* cstr); + + OSCL_IMPORT_REF void set(const chartype* buf, uint32 length); + + OSCL_IMPORT_REF void set(const other_chartype* buf, optype op); + OSCL_IMPORT_REF void set(const other_chartype* buf, uint32 length, optype op); + + private: + CHeapRep *iRep; + OsclRefCounter *iAllocRef; + Oscl_DefAlloc *iAlloc; + OsclMemAllocator iDefAlloc; + void create(Oscl_DefAlloc *, OsclRefCounter*); + void set_rep(const chartype*, uint32); + void append_rep(const chartype*, uint32); + + void set_rep(const chartype* cstr); + void append_rep(const chartype* cstr); + void set_rep(const OSCL_wString& src); + void append_rep(const OSCL_wString& src); + void set_len(uint32 len); + friend class OSCL_wString; +}; + + +/** + OSCL_StackString is a simple string class, compatible with + regular character array strings. + + The string array is fixed length, is allocated from the stack, + and is modifiable. Operations that update the string will automatically + truncate it to fit the fixed size storage. + This is recommended for use for short strings (<255). + Use OSCL_HeapString for very large strings to avoid stack overflow. + + @param C: type of character. + @param MaxBufSize: maximum string length not including null terminator. +*/ +template +class OSCL_StackString : public OSCL_String +{ + public: + typedef OSCL_String::chartype chartype; + typedef TOSCL_StringOp optype; + typedef OSCL_wString::chartype other_chartype; + + /** Creates an OSCL_StackString initialized with an empty string. + */ + OSCL_StackString(); + + /** Creates an OSCL_StackString with a copy of the input string. + The string may be truncated to fit the available storage. + @param src: input string. + */ + OSCL_StackString(const OSCL_StackString& src); + OSCL_StackString(const OSCL_String& src); + + /** Creates an OSCL_StackString with a copy of the input string. + The string may be truncated to fit the available storage. + @param cp: a null-terminated string. + */ + OSCL_StackString(const chartype* cstr); + + /** Creates an OSCL_StackString with a copy of the input string. + The string may be truncated to fit the available storage. + @param src: a character array, not necessarily null-terminated. + @param length: the number of characters to copy. + */ + OSCL_StackString(const chartype* buf, uint32 length); + + ~OSCL_StackString(); + + /** Pure virtuals from OSCL_String + */ + uint32 get_size() const; + uint32 get_maxsize() const; + const chartype* get_cstr() const; + chartype* get_str() const; + + /** Assignment operators + */ + OSCL_StackString& operator=(const OSCL_StackString& src); + OSCL_StackString& operator=(const OSCL_String& src); + OSCL_StackString& operator=(const chartype* cstr); + + /** + Set the contents of this string to a new string or + character array. + @param buf: string or character array. + @param length: number of characters to copy. + */ + void set(const chartype* buf, uint32 length); + + /** + Set the contents of this string to a new string, + with conversion operation. + + @param buf: NULL-terminated wide string. + @param op: conversion operation to apply + */ + void set(const other_chartype* buf, optype op); + + /** + Set the contents of this string to a new string or + character array, with conversion operation. + + @param buf: string or character array. + @param length: number of characters to copy. + @param op: conversion operation to apply + */ + void set(const other_chartype* buf, uint32 length, optype op); + + private: + CStackRep rep; + char buffer[MaxBufSize+1];//fixed string buffer. + void create(); + + /** Pure virtuals from OSCL_String + */ + void set_rep(const chartype* cstr); + void append_rep(const chartype* cstr); + void set_rep(const OSCL_String& src); + void append_rep(const OSCL_String& src); + void set_len(uint32 len); + friend class OSCL_String; +}; + +/** + OSCL_wStackString is identical to OSCL_StackString + except that it uses wide-character format. + For descriptions, see OSCL_StackString. +*/ +template +class OSCL_wStackString : public OSCL_wString +{ + public: + typedef OSCL_wString::chartype chartype; + typedef TOSCL_wStringOp optype; + typedef OSCL_String::chartype other_chartype; + + OSCL_wStackString(); + + OSCL_wStackString(const OSCL_wStackString& src); + OSCL_wStackString(const OSCL_wString& src); + + OSCL_wStackString(const chartype* cstr); + OSCL_wStackString(const chartype* buf, uint32 length); + + ~OSCL_wStackString(); + + uint32 get_size() const; + uint32 get_maxsize() const; + const chartype* get_cstr() const; + chartype* get_str() const; + + OSCL_wStackString& operator=(const OSCL_wStackString& src); + OSCL_wStackString& operator=(const OSCL_wString& src); + OSCL_wStackString& operator=(const chartype* cstr); + + void set(const chartype* buf, uint32 length); + + void set(const other_chartype* buf, optype op); + void set(const other_chartype* buf, uint32 length, optype op); + + private: + CStackRep rep; + chartype buffer[MaxBufSize+1];//fixed string buffer. + void create(); + + void set_rep(const chartype* cstr); + void append_rep(const chartype* cstr); + void set_rep(const OSCL_wString& src); + void append_rep(const OSCL_wString& src); + void set_len(uint32 len); + friend class OSCL_wString; +}; + +/** + OSCL_FastString is a simple string class, compatible with + regular character array strings. + + This class does not allocate internal memory for the string but acts as + a container for a user-defined buffer. This means no copying of the string + is done and provides a faster way of manipulating strings. + Depending on initialization, this container provides either read-only + or read-write access to the string. + + Implementation assumes the input string is null-terminated. + + @param C: type of character. +*/ +class OSCL_FastString : public OSCL_String +{ + public: + typedef OSCL_String::chartype chartype; + typedef TOSCL_StringOp optype; + typedef OSCL_wString::chartype other_chartype; + + /** + Default constructor. + */ + OSCL_IMPORT_REF OSCL_FastString(); + + /** + Creates a fast string that contains a copy of the input + string. + The string inherits the writable-ness of the source string. + @param src: input string. + */ + OSCL_IMPORT_REF OSCL_FastString(const OSCL_FastString& src); + + /** + Create the string and initialize it to contain the input string. + The string is not writable. + @param: null-terminated string. + */ + OSCL_IMPORT_REF OSCL_FastString(const chartype* cstr); + + /** + Create the string and initialize it to contain the input string. + The string is writable. + @param cp: null-terminated string. + @param maxlen: maximum size of storage at cp, not incl null terminator. + If input string is not null-terminated, the function leaves. + */ + OSCL_IMPORT_REF OSCL_FastString(chartype* buf, uint32 maxlen); + + OSCL_IMPORT_REF ~OSCL_FastString(); + + /** Pure virtuals from OSCL_String + */ + OSCL_IMPORT_REF uint32 get_size() const; + OSCL_IMPORT_REF uint32 get_maxsize() const; + OSCL_IMPORT_REF const chartype* get_cstr() const; + OSCL_IMPORT_REF chartype* get_str() const; + + /** Assignment operators + */ + OSCL_IMPORT_REF OSCL_FastString& operator=(const OSCL_FastString& src); + OSCL_IMPORT_REF OSCL_FastString& operator=(const chartype* cstr); + + /** + This function can be used to reassign the string to a new + writable string. + If input string is not null-terminated, the function leaves. + */ + OSCL_IMPORT_REF void set(chartype* cstr, uint32 maxlen); + + /** + Set the contents of this string to a new string or + character array, with conversion operation. + + @param buf: string or character array. + @param numofbyte: number of bytes available in the buffer. + There must be enough space available for the converted string including its NULL terminator. + The converted string may be smaller or larger than the original string. + @param op: conversion operation to apply + If numofbyte is not large enough for conversion, the function leaves. + If input string is not null-terminated, the function leaves. + */ + OSCL_IMPORT_REF void set(const other_chartype* buf, uint32 numofbyte, optype op); + + /** + This function can be used to refresh the string size in case the + contents of the string buffer have been modified since the + container was created. + */ + OSCL_IMPORT_REF void set_length(); + + private: + CFastRep rep; + + /** Pure virtuals from OSCL_String + */ + void set_rep(const chartype* cstr); + void append_rep(const chartype* cstr); + void set_rep(const OSCL_String& src); + void append_rep(const OSCL_String& src); + void set_len(uint32 len); + friend class OSCL_String; +}; + +/** + OSCL_wFastString is identical to OSCL_FastString + except that it uses wide-character format. + For descriptions, see OSCL_FastString. +*/ +class OSCL_wFastString : public OSCL_wString +{ + public: + typedef OSCL_wString::chartype chartype; + typedef TOSCL_wStringOp optype; + typedef OSCL_String::chartype other_chartype; + + OSCL_IMPORT_REF OSCL_wFastString(); + + OSCL_IMPORT_REF OSCL_wFastString(const OSCL_wFastString& src); + + OSCL_IMPORT_REF OSCL_wFastString(const chartype* cstr); + OSCL_IMPORT_REF OSCL_wFastString(chartype* buf, uint32 maxlen); + + OSCL_IMPORT_REF ~OSCL_wFastString(); + + OSCL_IMPORT_REF uint32 get_size() const; + OSCL_IMPORT_REF uint32 get_maxsize() const; + OSCL_IMPORT_REF const chartype* get_cstr() const; + OSCL_IMPORT_REF chartype* get_str() const; + + OSCL_IMPORT_REF OSCL_wFastString& operator=(const OSCL_wFastString& src); + OSCL_IMPORT_REF OSCL_wFastString& operator=(const chartype* cstr); + + OSCL_IMPORT_REF void set(chartype* cstr, uint32 maxlen); + + OSCL_IMPORT_REF void set(const other_chartype* buf, uint32 numofbyte, optype op); + + OSCL_IMPORT_REF void set_length(); + + private: + CFastRep rep; + + void set_rep(const chartype* cstr); + void append_rep(const chartype* cstr); + void set_rep(const OSCL_wString& src); + void append_rep(const OSCL_wString& src); + void set_len(uint32 len); + friend class OSCL_wString; +}; + + +// ************************************************************** +// OSCL_HeapString Implementation +// OSCL_wHeapString Implementation +// ************************************************************** + +template +void OSCL_HeapString::set_rep(const chartype* cp, uint32 len) +//set heap rep to new string. +{ + CHeapRep::set_rep(iRep, iAlloc, cp, len); +} + +template +void OSCL_wHeapString::set_rep(const chartype* cp, uint32 len) +//set heap rep to new string. +{ + CHeapRep::set_rep(iRep, iAlloc, cp, len); +} + +// ************************************************************** +template +void OSCL_HeapString::append_rep(const chartype* cp, uint32 len) +//set heap rep to current string plus new string. +{ + CHeapRep::append_rep(iRep, iAlloc, cp, len); +} + +template +void OSCL_wHeapString::append_rep(const chartype* cp, uint32 len) +//set heap rep to current string plus new string. +{ + CHeapRep::append_rep(iRep, iAlloc, cp, len); +} + +// ************************************************************** +template +void OSCL_HeapString::set_rep(const chartype* cp) +{ + set_rep(cp, (cp) ? oscl_strlen(cp) : 0); +} + +template +void OSCL_wHeapString::set_rep(const chartype* cp) +{ + set_rep(cp, (cp) ? oscl_strlen(cp) : 0); +} + + +// ************************************************************** +template +void OSCL_HeapString::append_rep(const chartype* cp) +{ + append_rep(cp, (cp) ? oscl_strlen(cp) : 0); +} + +template +void OSCL_wHeapString::append_rep(const chartype* cp) +{ + append_rep(cp, (cp) ? oscl_strlen(cp) : 0); +} + + +// ************************************************************** +template +void OSCL_HeapString::set_rep(const OSCL_String& src) +{ + set_rep(src.get_cstr(), src.get_size()); +} + +template +void OSCL_wHeapString::set_rep(const OSCL_wString& src) +{ + set_rep(src.get_cstr(), src.get_size()); +} + + +// ************************************************************** +template +void OSCL_HeapString::append_rep(const OSCL_String& src) +{ + append_rep(src.get_cstr(), src.get_size()); +} + +template +void OSCL_wHeapString::append_rep(const OSCL_wString& src) +{ + append_rep(src.get_cstr(), src.get_size()); +} + + +// ************************************************************** +template +uint32 OSCL_HeapString::get_size() const +{ + if (iRep) + return iRep->size; + return 0; +} + +template +uint32 OSCL_wHeapString::get_size() const +{ + if (iRep) + return iRep->size; + return 0; +} + +// ************************************************************** +template +void OSCL_HeapString::set_len(uint32 len) +{ + iRep->size = len; +} + +template +void OSCL_wHeapString::set_len(uint32 len) +{ + iRep->size = len; +} + + +// ************************************************************** +template +uint32 OSCL_HeapString::get_maxsize() const +{ + if (iRep) + return iRep->maxsize; + return 0; +} + +template +uint32 OSCL_wHeapString::get_maxsize() const +{ + if (iRep) + return iRep->maxsize; + return 0; +} + + +// ************************************************************** +template +const typename OSCL_HeapString::chartype* OSCL_HeapString::get_cstr() const +{ + if (iRep) + return (chartype*)iRep->buffer; + return NULL; +} + +template +const typename OSCL_wHeapString::chartype* OSCL_wHeapString::get_cstr() const +{ + if (iRep) + return (chartype*)iRep->buffer; + return NULL; +} + + +// ************************************************************** +template +typename OSCL_HeapString::chartype* OSCL_HeapString::get_str() const +{ + if (iRep) + return (chartype*)iRep->buffer; + return NULL; +} + +template +typename OSCL_wHeapString::chartype* OSCL_wHeapString::get_str() const +{ + if (iRep) + return (chartype*)iRep->buffer; + return NULL; +} + + +// ************************************************************** +template +void OSCL_HeapString::create() +{ + iRep = NULL; +} + +template +void OSCL_wHeapString::create() +{ + iRep = NULL; +} + + +// ************************************************************** +template +OSCL_HeapString::OSCL_HeapString() +{ + create(); + set_rep(NULL); +} + +template +OSCL_wHeapString::OSCL_wHeapString() +{ + create(); + set_rep(NULL); +} + + +// ************************************************************** +template +OSCL_HeapString::OSCL_HeapString(const chartype* cp) +{ + create(); + set_rep(cp); +} + +template +OSCL_wHeapString::OSCL_wHeapString(const chartype* cp) +{ + create(); + set_rep(cp); +} + + +// ************************************************************** +template +void OSCL_HeapString::set(const chartype* cp, uint32 length) +{ + set_rep(cp, length); + //just in case input string is shorter than 'length' + iRep->size = oscl_strlen(get_cstr()); +} + +template +void OSCL_wHeapString::set(const chartype* cp, uint32 length) +{ + set_rep(cp, length); + //just in case input string is shorter than 'length' + iRep->size = oscl_strlen(get_cstr()); +} + + +// ************************************************************** +template +void OSCL_HeapString::set(const other_chartype* buf, optype op) +{ + iRep->size = setrep_to_char(buf, oscl_strlen(buf), op, &iAlloc); +} + +template +void OSCL_wHeapString::set(const other_chartype* buf, optype op) +{ + iRep->size = setrep_to_wide_char(buf, oscl_strlen(buf), op, &iAlloc); +} + +// ************************************************************** +template +void OSCL_HeapString::set(const other_chartype* buf, uint32 length, optype op) +{ + iRep->size = setrep_to_char(buf, length, op, &iAlloc); +} + +template +void OSCL_wHeapString::set(const other_chartype* buf, uint32 length, optype op) +{ + iRep->size = setrep_to_wide_char(buf, length, op, &iAlloc); +} + +// ************************************************************** +template +OSCL_HeapString::OSCL_HeapString(const chartype* cp, uint32 length) +{ + create(); + set(cp, length); +} + +template +OSCL_wHeapString::OSCL_wHeapString(const chartype* cp, uint32 length) +{ + create(); + set(cp, length); +} + +// ************************************************************** +template +OSCL_HeapString::OSCL_HeapString(const OSCL_HeapString& src) : OSCL_String(src) +{ + create(); + if (src.iRep) + CHeapRep::assign(iRep, src.iRep, iAlloc); + else + set_rep(src); +} + +template +OSCL_wHeapString::OSCL_wHeapString(const OSCL_wHeapString& src) : OSCL_wString(src) +{ + create(); + if (src.iRep) + CHeapRep::assign(iRep, src.iRep, iAlloc); + else + set_rep(src); +} + +// ************************************************************** +template +OSCL_HeapString::OSCL_HeapString(const OSCL_String& src) +{ + create(); + set_rep(src); +} + +template +OSCL_wHeapString::OSCL_wHeapString(const OSCL_wString& src) +{ + create(); + set_rep(src); +} + +// ************************************************************** +template +OSCL_HeapString::~OSCL_HeapString() +{ + if (iRep) + iRep->remove_ref(iAlloc); +} + +template +OSCL_wHeapString::~OSCL_wHeapString() +{ + if (iRep) + iRep->remove_ref(iAlloc); +} + + +// ************************************************************** +template +OSCL_HeapString& OSCL_HeapString::operator=(const OSCL_HeapString& src) +{ + if (src.iRep) + CHeapRep::assign(iRep, src.iRep, iAlloc); + else + set_rep(src); + return (*this); +} + +template +OSCL_wHeapString& OSCL_wHeapString::operator=(const OSCL_wHeapString& src) +{ + if (src.iRep) + CHeapRep::assign(iRep, src.iRep, iAlloc); + else + set_rep(src); + return (*this); +} + +// ************************************************************** +template +OSCL_HeapString& OSCL_HeapString::operator=(const OSCL_String & src) +{ + set_rep(src); + return (*this); +} + +template +OSCL_wHeapString& OSCL_wHeapString::operator=(const OSCL_wString & src) +{ + set_rep(src); + return (*this); +} + +// ************************************************************** +template +OSCL_HeapString& OSCL_HeapString::operator=(const chartype * cp) +{ + set_rep(cp); + return (*this); +} + +template +OSCL_wHeapString& OSCL_wHeapString::operator=(const chartype * cp) +{ + set_rep(cp); + return (*this); +} + +// ************************************************************** +// OSCL_StackString Implementation +// OSCL_wStackString Implementation +// ************************************************************** +template +void OSCL_StackString::set_rep(const chartype* cp) +{ + rep.set(cp, (cp) ? oscl_strlen(cp) : 0); +} + +template +void OSCL_wStackString::set_rep(const chartype* cp) +{ + rep.set(cp, (cp) ? oscl_strlen(cp) : 0); +} + + +// ************************************************************** +template +void OSCL_StackString::append_rep(const chartype* cp) +{ + rep.append(cp, (cp) ? oscl_strlen(cp) : 0); +} + +template +void OSCL_wStackString::append_rep(const chartype* cp) +{ + rep.append(cp, (cp) ? oscl_strlen(cp) : 0); +} + +// ************************************************************** +template +void OSCL_StackString::set_rep(const OSCL_String& src) +{ + rep.set(src.get_cstr(), src.get_size()); +} + +template +void OSCL_wStackString::set_rep(const OSCL_wString& src) +{ + rep.set(src.get_cstr(), src.get_size()); +} + +// ************************************************************** +template +void OSCL_StackString::append_rep(const OSCL_String& src) +{ + rep.append(src.get_cstr(), src.get_size()); +} + +template +void OSCL_wStackString::append_rep(const OSCL_wString& src) +{ + rep.append(src.get_cstr(), src.get_size()); +} + +// ************************************************************** +template +void OSCL_StackString::set_len(uint32 len) +{ + rep.size = len; +} + +template +void OSCL_wStackString::set_len(uint32 len) +{ + rep.size = len; +} + +// ************************************************************** +template +uint32 OSCL_StackString::get_size() const +{ + return rep.size; +} + +template +uint32 OSCL_wStackString::get_size() const +{ + return rep.size; +} + +// ************************************************************** +template +uint32 OSCL_StackString::get_maxsize() const +{ + return rep.maxsize; +} + +template +uint32 OSCL_wStackString::get_maxsize() const +{ + return rep.maxsize; +} + +// ************************************************************** +template +const typename OSCL_StackString::chartype* OSCL_StackString::get_cstr() const +{ + return (chartype*)rep.buffer; +} + +template +const typename OSCL_wStackString::chartype* OSCL_wStackString::get_cstr() const +{ + return (chartype*)rep.buffer; +} + +// ************************************************************** +template +typename OSCL_StackString::chartype* OSCL_StackString::get_str() const +{ + return (chartype*)rep.buffer; +} + +template +typename OSCL_wStackString::chartype* OSCL_wStackString::get_str() const +{ + return (chartype*)rep.buffer; +} + +// ************************************************************** +template +void OSCL_StackString::create() +{ + rep.buffer = &buffer[0]; + rep.maxsize = MaxBufSize; +} + +template +void OSCL_wStackString::create() +{ + rep.buffer = &buffer[0]; + rep.maxsize = MaxBufSize; +} + +// ************************************************************** +template +OSCL_StackString::OSCL_StackString() +{ + create(); + set_rep(NULL); +} + +template +OSCL_wStackString::OSCL_wStackString() +{ + create(); + set_rep(NULL); +} + +// ************************************************************** +template +OSCL_StackString::OSCL_StackString(const chartype* cp) +{ + create(); + set_rep(cp); +} + +template +OSCL_wStackString::OSCL_wStackString(const chartype* cp) +{ + create(); + set_rep(cp); +} + +// ************************************************************** +template +void OSCL_StackString::set(const chartype* cp, uint32 length) +{ + rep.set(cp, length); + //just in case input string is shorter than 'length'; + rep.size = oscl_strlen(get_cstr()); +} + +template +void OSCL_wStackString::set(const chartype* cp, uint32 length) +{ + rep.set(cp, length); + //just in case input string is shorter than 'length'; + rep.size = oscl_strlen(get_cstr()); +} + +// ************************************************************** +template +void OSCL_StackString::set(const other_chartype* buf, optype op) +{ + rep.size = setrep_to_char(buf, oscl_strlen(buf), op, NULL); +} + +template +void OSCL_wStackString::set(const other_chartype* buf, optype op) +{ + rep.size = setrep_to_wide_char(buf, oscl_strlen(buf), op, NULL); +} + +// ************************************************************** +template +void OSCL_StackString::set(const other_chartype* buf, uint32 length, optype op) +{ + rep.size = setrep_to_char(buf, length, op, NULL); +} + +template +void OSCL_wStackString::set(const other_chartype* buf, uint32 length, optype op) +{ + rep.size = setrep_to_wide_char(buf, length, op, NULL); +} + +// ************************************************************** +template +OSCL_StackString::OSCL_StackString(const chartype* cp, uint32 length) +{ + create(); + set(cp, length); +} + +template +OSCL_wStackString::OSCL_wStackString(const chartype* cp, uint32 length) +{ + create(); + set(cp, length); +} + +// ************************************************************** +template +OSCL_StackString::OSCL_StackString(const OSCL_StackString& src) : OSCL_String(src) +{ + create(); + set_rep(src); +} + +template +OSCL_wStackString::OSCL_wStackString(const OSCL_wStackString& src) +{ + create(); + set_rep(src); +} + +// ************************************************************** +template +OSCL_StackString::OSCL_StackString(const OSCL_String& src) +{ + create(); + set_rep(src); +} + +template +OSCL_wStackString::OSCL_wStackString(const OSCL_wString& src) +{ + create(); + set_rep(src); +} + +// ************************************************************** +template +OSCL_StackString::~OSCL_StackString() +{} + +template +OSCL_wStackString::~OSCL_wStackString() +{} + +// ************************************************************** +template +OSCL_StackString& OSCL_StackString::operator=(const OSCL_StackString& src) +{ + set_rep(src); + return (*this); +} + +template +OSCL_wStackString& OSCL_wStackString::operator=(const OSCL_wStackString& src) +{ + set_rep(src); + return (*this); +} + +// ************************************************************** +template +OSCL_StackString& OSCL_StackString::operator=(const OSCL_String & src) +{ + set_rep(src); + return (*this); +} + +template +OSCL_wStackString& OSCL_wStackString::operator=(const OSCL_wString & src) +{ + set_rep(src); + return (*this); +} + +// ************************************************************** +template +OSCL_StackString& OSCL_StackString::operator=(const chartype * cp) +{ + set_rep(cp); + return (*this); +} + +template +OSCL_wStackString& OSCL_wStackString::operator=(const chartype * cp) +{ + set_rep(cp); + return (*this); +} + +#endif // OSCL_STRING_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_rep.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_rep.h new file mode 100644 index 0000000..1ae7b85 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_rep.h @@ -0,0 +1,132 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L_ S T R I N G _ R E P +// +// This file contains a standardized set of string containers that +// can be used in place of character arrays. + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/*! + * \file oscl_string_rep.h + * \brief Contains some internal implementation for string containers. + * + */ + + +#ifndef OSCL_STRING_REP_H_INCLUDED +#define OSCL_STRING_REP_H_INCLUDED + + +#ifndef OSCL_DEFALLOC_H_INCLUDED +#include "oscl_defalloc.h" +#endif + + + +/** For internal use only-- heap string representation +*/ +class CHeapRep +{ + public: + CHeapRep() + : refcount(0) + , buffer(NULL) + , maxsize(0) + , size(0) + {} + + OSCL_IMPORT_REF static void set_rep(CHeapRep*&, Oscl_DefAlloc&, const char*, uint32); + OSCL_IMPORT_REF static void set_rep(CHeapRep*&, Oscl_DefAlloc&, const oscl_wchar*, uint32); + OSCL_IMPORT_REF static void append_rep(CHeapRep*&, Oscl_DefAlloc&, const char*, uint32); + OSCL_IMPORT_REF static void append_rep(CHeapRep*&, Oscl_DefAlloc&, const oscl_wchar*, uint32); + + uint32 refcount; + OsclAny* buffer; + uint32 maxsize; + uint32 size; + OSCL_IMPORT_REF bool set(uint32, const char*, Oscl_DefAlloc &); + OSCL_IMPORT_REF bool set(uint32, const oscl_wchar*, Oscl_DefAlloc &); + OSCL_IMPORT_REF bool append(uint32, const char*, uint32, const char*, Oscl_DefAlloc &); + OSCL_IMPORT_REF bool append(uint32, const oscl_wchar*, uint32, const oscl_wchar*, Oscl_DefAlloc &); + OSCL_IMPORT_REF void add_ref(); + OSCL_IMPORT_REF void remove_ref(Oscl_DefAlloc &); + + OSCL_IMPORT_REF static void assign(CHeapRep*&, CHeapRep*, Oscl_DefAlloc &); + private: + static CHeapRep *New(Oscl_DefAlloc &); +}; + +/** For internal use only-- stack string representation +*/ +class CStackRep +{ + public: + CStackRep() + : maxsize(0) + , size(0) + , buffer(NULL) + {} + uint32 maxsize; + uint32 size; + OsclAny* buffer; + OSCL_IMPORT_REF void set(const char* cp, uint32 len); + OSCL_IMPORT_REF void set(const oscl_wchar* cp, uint32 len); + OSCL_IMPORT_REF void append(const char* cp, uint32 len); + OSCL_IMPORT_REF void append(const oscl_wchar* cp, uint32 len); +}; + + +/** For internal use only-- fast string representation +*/ +class CFastRep +{ + public: + CFastRep() + : maxsize(0) + , size(0) + , buffer(NULL) + , writable(false) + , overwrite(false) + {} + uint32 maxsize; + uint32 size; + OsclAny* buffer; + bool writable; + bool overwrite; + OSCL_IMPORT_REF void set_w(char* cp, uint32 len, uint32 maxlen); + OSCL_IMPORT_REF void set_w(oscl_wchar* cp, uint32 len, uint32 maxlen); + OSCL_IMPORT_REF void set_r(const char* cp, uint32 len); + OSCL_IMPORT_REF void set_r(const oscl_wchar* cp, uint32 len); + OSCL_IMPORT_REF void append(const char* cp, uint32 len); + OSCL_IMPORT_REF void append(const oscl_wchar* cp, uint32 len); +}; + + +#endif // OSCL_STRING_REP_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_uri.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_uri.cpp new file mode 100644 index 0000000..12eaf39 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_uri.cpp @@ -0,0 +1,182 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L URI S T R I N G FUNCTIONS + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#include "oscl_string_uri.h" +#include "oscl_string_utils.h" +#include "oscl_exception.h" +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +/* ======================================================================== + * Function : oscl_str_unescape_uri + * Date : 11/04/2002 + * Purpose : see oscl_string_uri.h + * Modified : + * ======================================================================== + */ +OSCL_EXPORT_REF bool oscl_str_unescape_uri(const char *str_buf_in, char *str_buf_out, uint32 max_out_buf_bytes, uint32 max_bytes, uint32& out_buf_len) +{ + const char *src = str_buf_in; + char *dest = str_buf_out; + uint32 srcStrLen = max_bytes, destStrLen = max_out_buf_bytes ; + uint32 val = 0; + int32 i = 0; + bool result = false; + + out_buf_len = 0; + if ((srcStrLen <= 0) || (src == NULL)) + return (false); + + while (srcStrLen > 0) + { + if (src[i] == '%') + { + i++; + srcStrLen--; + + if (srcStrLen >= 2) + { + if (PV_atoi(&src[i], 'x', 2, val) == false) + { + if (destStrLen > 0) + *dest = (char)'\0'; + return false; + } + i += 2; + if (destStrLen > 0) + { + *dest++ = (char)val; + destStrLen--; + } + out_buf_len += 1; + srcStrLen -= 2; + } + else + { + if (destStrLen > 0) + *dest = (char)'\0'; + return false; + } + } + else + { + if (src[i] == (char)'\0') + break; + + if (destStrLen > 0) + { + *dest++ = src[i]; + destStrLen--; + } + out_buf_len += 1; + i++; + srcStrLen--; + } + } + + if (destStrLen > 0) + { + *dest = (char)'\0'; + result = true; + } + else + out_buf_len += 1; //needed size + + return result; +} + +/* ======================================================================== + * Function : oscl_str_unescape_uri + * Date : 11/04/2002 + * Purpose : see oscl_string_uri.h + * Modified : + * ======================================================================== + */ +OSCL_EXPORT_REF bool oscl_str_unescape_uri(const OSCL_String& srcString, OSCL_String& destString, uint32& out_buf_len) +{ + const char *src = srcString.get_cstr(); + int srcStrLen = srcString.get_size(); + + destString = ""; + out_buf_len = 0; + + if ((srcStrLen <= 0) || (src == NULL)) + { + return false; + } + + char buf[2]; + buf[1] = '\0'; + + for (int32 i = 0; srcStrLen > 0;) + { + if (src[i] == '%') + { + i++; + srcStrLen--; + + if ((srcStrLen >= 2)) + { + uint32 val; + if (PV_atoi(&src[i], 'x', 2, val) == false) + { + return false; + } + + //check capacity before appending to avoid any leave. + if (destString.get_size() == destString.get_maxsize()) + return false; + buf[0] = (char)val; + destString += buf; + out_buf_len++; + + i += 2; + srcStrLen -= 2; + } + else + { + return false; + } + } + else + { + if (src[i] == (char)'\0') + break; + + //check capacity before appending to avoid any leave. + if (destString.get_size() == destString.get_maxsize()) + return false; + buf[0] = src[i]; + destString += buf; + out_buf_len++; + + i++; + srcStrLen--; + } + } + + return true; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_uri.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_uri.h new file mode 100644 index 0000000..357c323 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_uri.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S T R I N G _ U R I + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/** \file oscl_string_uri.h + \brief Utilities to unescape URIs. +*/ + +/*! + * \par URI String Manipualation + * These routines handle all of the special escape sequences in the URI. + * + */ +#ifndef OSCL_STRING_URI_H +#define OSCL_STRING_URI_H + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif +#ifndef OSCL_STRING_H_INCLUDED +#include "oscl_string.h" +#endif + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Function prototypes +/*! + \brief unescape any of the special escape sequence in the uri string + + The function scans the string and replaces each escape sequence with its corresponding + character. It stops at the first null character, or the max_byte value. + It returns false if the string contains any illegal escape sequence or the output + buffer is not big enough. The out_buf_len value indicates the needed buffer length + or the index of the byte that causes the error respectively. + + \param str_buf_in Ptr to an input string + \param str_buf_out Ptr to an output buffer which stores the modified string + \param max_out_buf_bytes The size of str_buf_out. + \param max_bytes The maximum number of bytes to read. + It is the length of str_buf_in. + \param out_buf_len The length of the result string (not including the null character) + \return It returns true if succeeds, otherwise false. + +*/ +OSCL_IMPORT_REF bool oscl_str_unescape_uri(const char *str_buf_in, char *str_buf_out, uint32 max_out_buf_bytes, uint32 max_bytes, uint32& out_buf_len); +/*! + \brief unescape any of the special escape sequence in the uri string + + The function scans the string and replaces each escape sequence with its corresponding + character. It stops at the first null character, or the max_byte value. + It returns false if the string contains any illegal escape sequence or the output + buffer is not big enough. The out_buf_len value indicates the needed buffer length + or the index of the byte that causes the error respectively. + + \param oscl_str_in Ptr to an input OSCL_String + \param oscl_str_out Ptr to an output OSCL_String which stores the modified string + \param out_buf_len The length of the result string (not including the null character) + \return It returns true if succeeds, otherwise false. +*/ +//Old Definition +//bool oscl_str_unescape_uri(const OSCL_String& oscl_str_in, OSCL_String& oscl_str_out, uint32& out_buf_len); +//New definition +OSCL_IMPORT_REF bool oscl_str_unescape_uri(const OSCL_String& oscl_str_in, OSCL_String& oscl_str_out, uint32& out_buf_len); +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_utf8.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_utf8.cpp new file mode 100644 index 0000000..7001024 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_utf8.cpp @@ -0,0 +1,251 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L UTF-8 S T R I N G FUNCTIONS + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#include "oscl_string_utf8.h" +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#define UTF8_1_BYTE_MASK 0x80 //1000 0000 -> 0xxx xxxx +#define UTF8_1_BYTE_SIG 0x00 //0000 0000 -> 0xxx xxxx + +#define UTF8_2_BYTES_MASK_1 0xE0 //1110 0000 -> 110y yyyy +#define UTF8_2_BYTES_MASK_2 0xC0 //1100 0000 -> 10xx xxxx +#define UTF8_2_BYTES_SIG_1 0xC0 //1100 0000 -> 110y yyyy +#define UTF8_2_BYTES_SIG_2 0x80 //1000 0000 -> 10xx xxxx + + +#define UTF8_3_BYTES_MASK_1 0xF0 //1111 0000 -> 1110 zzzz +#define UTF8_3_BYTES_MASK_2 0xC0 //1100 0000 -> 10yy yyyy +#define UTF8_3_BYTES_MASK_3 0xC0 //1100 0000 -> 10xx xxxx +#define UTF8_3_BYTES_SIG_1 0xE0 //1110 0000 -> 1110 zzzz +#define UTF8_3_BYTES_SIG_2 0x80 //1000 0000 -> 10yy yyyy +#define UTF8_3_BYTES_SIG_3 0x80 //1000 0000 -> 10xx xxxx + + +#define UTF8_4_BYTES_MASK_1 0xF8 //1111 1000 -> 1111 0uuu +#define UTF8_4_BYTES_MASK_2 0xC0 //1100 0000 -> 10uu zzzz +#define UTF8_4_BYTES_MASK_3 0xC0 //1100 0000 -> 10yy yyyy +#define UTF8_4_BYTES_MASK_4 0xC0 //1100 0000 -> 10xx xxxx +#define UTF8_4_BYTES_SIG_1 0xF0 //1111 0000 -> 1111 0uuu +#define UTF8_4_BYTES_SIG_2 0x80 //1000 0000 -> 10uu zzzz +#define UTF8_4_BYTES_SIG_3 0x80 //1000 0000 -> 10yy yyyy +#define UTF8_4_BYTES_SIG_4 0x80 //1000 0000 -> 10xx xxxx + +/* ======================================================================== + * Function : oscl_str_is_valid_and_truncate_utf8 + * Date : 10/25/2002 + * Purpose : + * Modified : + * ======================================================================== + */ +OSCL_EXPORT_REF bool oscl_str_is_valid_and_truncate_utf8(const uint8 *str_buf, uint32& num_valid_characters, uint32 max_bytes, uint32& truncate_pos_index, + uint32 max_char_2_valid = 0) +{ + bool result = true, done = false; + uint32 bytes_left; + uint32 total_num_valid_characters; + const uint8 *ptr; + + ptr = str_buf; + bytes_left = max_bytes; + total_num_valid_characters = 0; + truncate_pos_index = 0; + + while (!done) + { + if ((*ptr & UTF8_1_BYTE_MASK) == UTF8_1_BYTE_SIG) + { + if ((*ptr == 0x0) && (max_bytes == 0)) //if need to be terminated at first null char + { + result = true; + done = true; + continue; + } + if (bytes_left > 0) + bytes_left--; + if (max_bytes && !bytes_left) //done when there is no more data + done = true; + + ptr++; + total_num_valid_characters ++; + truncate_pos_index += 1; + } + else if ((*ptr & UTF8_2_BYTES_MASK_1) == UTF8_2_BYTES_SIG_1) + { + if ((!max_bytes) || (bytes_left >= 2)) + { + if (((*(ptr + 1) & UTF8_2_BYTES_MASK_2) != UTF8_2_BYTES_SIG_2) + || (*ptr < 0xC2) //C0, C1 are illegal + ) + { //invalid char + done = true; + result = false; + continue; + } + if (bytes_left) + bytes_left -= 2; + + if (max_bytes && !bytes_left) //done when there is no more data + done = true; + + ptr += 2; + total_num_valid_characters++; + truncate_pos_index += 2; + } + else + { + done = true; + result = false; + } + } + else if ((*ptr & UTF8_3_BYTES_MASK_1) == UTF8_3_BYTES_SIG_1) + { + if ((!max_bytes) || (bytes_left >= 3)) + { + if (((*(ptr + 1) & UTF8_3_BYTES_MASK_2) != UTF8_3_BYTES_SIG_2) + || ((*(ptr + 2) & UTF8_3_BYTES_MASK_3) != UTF8_3_BYTES_SIG_3) + || ((*ptr == 0xE0) && (*(ptr + 1) < 0xA0)) //if 1st byte =E0, 2n byte has to be greater than 0xA0 + ) + { //invalid char + done = true; + result = false; + continue; + } + if (bytes_left > 0) + bytes_left -= 3; + + if (max_bytes && !bytes_left) //done when there is no more data + done = true; + + ptr += 3; + total_num_valid_characters++; + truncate_pos_index += 3; + } + else + { + done = true; + result = false; + } + } + else if ((*ptr & UTF8_4_BYTES_MASK_1) == UTF8_4_BYTES_SIG_1) + { + if ((!max_bytes) || (bytes_left >= 4)) + { + if (((*(ptr + 1) & UTF8_4_BYTES_MASK_2) != UTF8_4_BYTES_SIG_2) + || ((*(ptr + 2) & UTF8_4_BYTES_MASK_3) != UTF8_4_BYTES_SIG_3) + || ((*(ptr + 3) & UTF8_4_BYTES_MASK_4) != UTF8_4_BYTES_SIG_4) + || (*ptr > 0xF4) + || ((*ptr == 0xF4) && (*(ptr + 1) > 0x8F)) + ) + { //invalid char + done = true; + result = false; + continue; + } + if (bytes_left > 0) + bytes_left -= 4; + + if (max_bytes && !bytes_left) //done when there is no more data + done = true; + + ptr += 4; + total_num_valid_characters++; + truncate_pos_index += 4; + } + else + { + done = true; + result = false; + } + } + else //found invalid char + { + done = true; + result = false; + + if (bytes_left > 0) + bytes_left--; + } + if (num_valid_characters && (total_num_valid_characters == num_valid_characters)) + done = true; + if ((!num_valid_characters) && max_char_2_valid && (total_num_valid_characters == max_char_2_valid)) + done = true; + + } + num_valid_characters = total_num_valid_characters; + + return result; +} + +/* ======================================================================== + * Function : oscl_str_is_valid_utf8 + * Date : 10/25/2002 + * Purpose : see oscl_string_utf8.h + * Modified : + * ======================================================================== + */ +OSCL_EXPORT_REF bool oscl_str_is_valid_utf8(const uint8 *str_buf, uint32& num_valid_characters, uint32 max_bytes, + uint32 max_char_2_valid, uint32 *num_byte_4_char) +{ + uint32 truncate_pos_index = 0; + num_valid_characters = 0; + bool result; + + if (num_byte_4_char) + *num_byte_4_char = 0; + result = oscl_str_is_valid_and_truncate_utf8(str_buf, num_valid_characters, max_bytes, truncate_pos_index, max_char_2_valid); + if (num_byte_4_char) + *num_byte_4_char = truncate_pos_index; + + return result; +} +/* ======================================================================== + * Function : oscl_str_truncate_utf8 + * Date : 10/25/2002 + * Purpose : see oscl_string_utf8.h + * Modified : + * ======================================================================== + */ +OSCL_EXPORT_REF int32 oscl_str_truncate_utf8(uint8 *str_buf, uint32 max_chars, uint32 max_bytes) +{ + uint32 num_valid_characters, truncate_pos_index; + + num_valid_characters = max_chars; + truncate_pos_index = 0; + + oscl_str_is_valid_and_truncate_utf8(str_buf, num_valid_characters, max_bytes, truncate_pos_index); + if (max_bytes) + { + if (truncate_pos_index <= (max_bytes - 1)) + *(str_buf + truncate_pos_index) = 0x00; + } + else + { + *(str_buf + truncate_pos_index) = 0x00; + } + + return num_valid_characters; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_utf8.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_utf8.h new file mode 100644 index 0000000..c6b6a00 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_utf8.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S T R I N G _ U T F 8 + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/** \file oscl_string_utf8.h + \brief Utilities to validate and truncate UTF-8 encoded strings. +*/ + +/*! + * \par UTF-8 String Manipualation + * These routines operate on UTF-8 character string. + * + */ +#ifndef OSCL_STRING_UTF8_H +#define OSCL_STRING_UTF8_H + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Function prototypes +/*! + \brief Check if the input string contains any illegal UTF-8 character. + The function scans the string and validate that each character is a valid utf-8. + It stops at the first NULL character, invalid character or the max_byte value. + The string is valid if and only if every character is a valid utf-8 character and + the scanning stopped on a character boundary. + + \param str_buf Ptr to an input string, which may not terminate with null, to be checked + \param num_valid_chars This is an output parameter which is the number of valid utf-8 characters actually read. + \param max_bytes The maximum number of bytes to read (a zero value means read to the first NULL character). + \param max_char_2_valid This is an input parameter. + Specify the number of utf-8 characters the caller wants to validate. + \param num_byte_4_char This is an output parameter. + The number of bytes used by the max_char characters + \return True if the string is valid and false otherwise. +*/ +OSCL_IMPORT_REF bool oscl_str_is_valid_utf8(const uint8 *str_buf, uint32& num_valid_characters, uint32 max_bytes = 0, + uint32 max_char_2_valid = 0, uint32 * num_byte_4_char = NULL); +/*! + \brief Truncates the UTF-8 string upto the required size. + + The function will modify the str_buf so that it contains AT MOST len valid + utf-8 characters. If a NULL character is found before reading len utf-8 + characters, then the function does not modify the string and simply returns + the number of characters. If an invalid character is found, then it will insert + a NULL character after the last valid character and return the length. Otherwise, + it will insert a NULL character after len valid utf-8 characters and return the length. + \param str_buf Ptr to an input string which may not terminate with null + \param max_char The max number of the UTF-8 CHARACTERS + \param max_bytes The maximum number of bytes to read (a zero value means read to the first NULL character). + \return It returns the length of the truncated string in utf-8 characters. +*/ +OSCL_IMPORT_REF int32 oscl_str_truncate_utf8(uint8 *str_buf, uint32 max_char, uint32 max_bytes = 0); + +#endif + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_xml.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_xml.cpp new file mode 100644 index 0000000..da06c34 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_xml.cpp @@ -0,0 +1,268 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L XML S T R I N G FUNCTIONS + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +#include "oscl_string_xml.h" +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +/* ======================================================================== + * Function : oscl_str_check_and_escape_xml + * Date : 11/04/2002 + * Purpose : + * Modified : + * ======================================================================== + */ +OSCL_EXPORT_REF bool oscl_str_check_and_escape_utf8(const char *str_buf_in, char *str_buf_out, uint32& num_escape_bytes, + uint32 max_out_buf_bytes, uint32 max_bytes = 0, uint32 * num_bytes_written = NULL) +{ + bool result = true, done = false, found = false; + uint32 bytes_left, bytes_left_out; + uint32 total_num_escape_bytes; + const char *ptr; + char *ptr_out; + + ptr = str_buf_in; + ptr_out = str_buf_out; + bytes_left = max_bytes; + bytes_left_out = max_out_buf_bytes; + total_num_escape_bytes = 0; + + if (ptr == NULL) + return false; + + if (num_bytes_written) *num_bytes_written = 0; + while (!done) + { + if ((*ptr == 0x0) && (max_bytes == 0)) //if need to be terminated at first null char + { + result = true; + done = true; + if (ptr_out) + { + if (bytes_left_out >= 1) + { + *ptr_out = *ptr; + if (num_bytes_written) *num_bytes_written += 1; + } + else + { + result = false; + } + } + continue; + } + if (*ptr == '&') + { + found = true; + total_num_escape_bytes += 5; //& -> & + if (ptr_out) + { + if (bytes_left_out >= 5) + { + *ptr_out++ = '&'; + *ptr_out++ = 'a'; + *ptr_out++ = 'm'; + *ptr_out++ = 'p'; + *ptr_out++ = ';'; + bytes_left_out -= 5; + if (num_bytes_written) *num_bytes_written += 5; + } + else + { + result = false; + done = true; + continue; + } + } + } + else if (*ptr == '<') + { + found = true; + total_num_escape_bytes += 4; //< -> < + if (ptr_out) + { + if (bytes_left_out >= 4) + { + *ptr_out++ = '&'; + *ptr_out++ = 'l'; + *ptr_out++ = 't'; + *ptr_out++ = ';'; + bytes_left_out -= 4; + if (num_bytes_written) *num_bytes_written += 4; + } + else + { + result = false; + done = true; + continue; + } + } + } + else if (*ptr == '>') + { + found = true; + total_num_escape_bytes += 4; //> -> > + if (ptr_out) + { + if (bytes_left_out >= 4) + { + *ptr_out++ = '&'; + *ptr_out++ = 'g'; + *ptr_out++ = 't'; + *ptr_out++ = ';'; + bytes_left_out -= 4; + if (num_bytes_written) *num_bytes_written += 4; + } + else + { + result = false; + done = true; + continue; + } + } + } + else if (*ptr == '\'') + { + found = true; + total_num_escape_bytes += 6; //' -> ' + if (ptr_out) + { + if (bytes_left_out >= 6) + { + *ptr_out++ = '&'; + *ptr_out++ = 'a'; + *ptr_out++ = 'p'; + *ptr_out++ = 'o'; + *ptr_out++ = 's'; + *ptr_out++ = ';'; + bytes_left_out -= 6; + if (num_bytes_written) *num_bytes_written += 6; + } + else + { + result = false; + done = true; + continue; + } + } + } + else if (*ptr == '"') + { + found = true; + total_num_escape_bytes += 6; //" -> " + if (ptr_out) + { + if (bytes_left_out >= 6) + { + *ptr_out++ = '&'; + *ptr_out++ = 'q'; + *ptr_out++ = 'u'; + *ptr_out++ = 'o'; + *ptr_out++ = 't'; + *ptr_out++ = ';'; + bytes_left_out -= 6; + if (num_bytes_written) *num_bytes_written += 6; + } + else + { + result = false; + done = true; + continue; + } + } + } + else + { + if (ptr_out) + { + if (bytes_left_out >= 1) + { + *ptr_out++ = *ptr; + bytes_left_out -= 1; + if (num_bytes_written) *num_bytes_written += 1; + } + else + { + result = false; + done = true; + continue; + } + } + + total_num_escape_bytes += 1; + } + + if (bytes_left > 0) + bytes_left--; + if (max_bytes && !bytes_left) //done when there is no more data + done = true; + + ptr++; + } //end while loop + + if (!found && (str_buf_out == 0)) + num_escape_bytes = 0; + else + num_escape_bytes = total_num_escape_bytes; + + return result; +} + +/* ======================================================================== + * Function : oscl_str_need_escape_xml + * Date : 11/04/2002 + * Purpose : see oscl_string_xml.h + * Modified : + * ======================================================================== + */ +OSCL_EXPORT_REF bool oscl_str_need_escape_xml(const char *str_buf, uint32& num_escape_bytes, uint32 max_bytes) +{ + char *str_buf_out; + uint32 max_out_buf_bytes = 0; + + str_buf_out = NULL; + num_escape_bytes = 0; + return oscl_str_check_and_escape_utf8(str_buf, str_buf_out, num_escape_bytes, max_out_buf_bytes, max_bytes); +} + +/* ======================================================================== + * Function : oscl_str_escape_xml + * Date : 11/04/2002 + * Purpose : see oscl_string_xml.h + * Modified : + * ======================================================================== + */ +OSCL_EXPORT_REF int32 oscl_str_escape_xml(const char *str_buf_in, char *str_buf_out, uint32 max_out_buf_bytes, uint32 max_bytes, + uint32 *num_bytes_written) +{ + int32 total_num_bytes = 0; + + if (oscl_str_check_and_escape_utf8(str_buf_in, str_buf_out, (uint32&)total_num_bytes, max_out_buf_bytes, max_bytes, num_bytes_written) == false) + total_num_bytes = -total_num_bytes; + + + return total_num_bytes; +} + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_xml.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_xml.h new file mode 100644 index 0000000..041f00f --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_string_xml.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ S T R I N G _ X M L + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/** \file oscl_string_xml.h + \brief Utilities to escape special characters in XML strings +*/ + + +/*! + * \par XML String Manipualation + * These routines handle the special characters, which needs to be escaped, for xml document. + * + */ +#ifndef OSCL_STRING_XML_H +#define OSCL_STRING_XML_H + +// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Function prototypes +/*! + \brief Check if the input string contains any special ASCII character + like &, <, >, ', ". + The function scans the string and check if each character is a special character. + It stops at the first NULL character (if max_bytes = 0), or the max_byte value. + + \param str_buf Ptr to an input string, which may not terminate with null, to be checked + \param num_escape_bytes This is an output parameter which is the number of bytes needed to hold + the result string. + Value 0 indicates that there is no special character found. + If max_bytes = 0, the return value does not include the null character. + \param max_bytes The maximum number of bytes to read (a zero value means read to the first NULL character). + \return True if the function succeeds, and + num_escape_bytes = 0 means that no special character is found, + num_escape_bytes >0 means the number of bytes of the result string. + False if there is any error occurred. +*/ +OSCL_IMPORT_REF bool oscl_str_need_escape_xml(const char *str_buf, uint32& num_escape_bytes, uint32 max_bytes = 0); +/*! + \brief Escape any of the following special characters in the string + Special ASCII characters: &, <, >, ', ". + + The function scans the string and replaces each special character with its corresponding + escape sequence. It stops at the first NULL character, the max_byte value. + + \param str_buf_in Ptr to an input string + \param str_buf_out Ptr to an output buffer which stores the modified string + \param max_out_buf_bytes The size of str_buf_out. + \param max_bytes The maximum number of bytes to read (a zero value means read to the first NULL character). + It is the length of str_buf_in. + \param num_bytes_written Number of bytes written in the output buffer, str_buf_out + \return It returns the number of bytes in the str_buf_outring if succeeded. + It returns negative number if failed, and its absolute value indicates + the total number bytes written to the output buffer, str_buf_out, + if str_buf_out != null. +*/ +OSCL_IMPORT_REF int32 oscl_str_escape_xml(const char *str_buf_in, char *str_buf_out, uint32 max_out_buf_bytes, uint32 max_bytes = 0, + uint32 * num_bytes_written = NULL); +#endif + + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_tickcount.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_tickcount.cpp new file mode 100644 index 0000000..278ef46 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_tickcount.cpp @@ -0,0 +1,23 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +#include "oscl_tickcount.h" + +#if (OSCL_DISABLE_INLINES) +#include "oscl_tickcount.inl" +#endif + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_tickcount.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_tickcount.h new file mode 100644 index 0000000..3618d3d --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_tickcount.h @@ -0,0 +1,98 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ T I C K C O U N T + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/** \file oscl_tickcount.h + \brief Defines a data structure for string containment/manipulations where the storage for the string is maintained externally. +*/ + +#ifndef OSCL_TICKCOUNT_H_INCLUDED +#define OSCL_TICKCOUNT_H_INCLUDED + +#ifndef OSCL_BASE_H_INCLUDED +#include "oscl_base.h" +#endif + +#define OSCLTICKCOUNT_MAX_TICKS 0xffffffff + +/** + * OsclTickCount class is used to retrieve the system tick + * count and the tick counter's frequency. + * + * The maximum tick count value is equivalent to the maximum + * uint32 value. + */ +class OsclTickCount +{ + public: + /** + * This function returns the current system tick count + * + * @return returns the tick count + */ + static uint32 TickCount(); + + /** + * This function returns the tick frequency in ticks + * per second + * + * @return ticks per second + */ + static uint32 TickCountFrequency(); + + /** + * This function returns the tick period in + * microseconds per tick + * + * @return microseconds per tick + */ + static uint32 TickCountPeriod(); + + /** + * This function converts ticks to milliseconds + * + * @return milliseconds + */ + static uint32 TicksToMsec(uint32 ticks); + + /** + * This function converts milliseconds to ticks + * + * @return ticks + */ + static uint32 MsecToTicks(uint32 msec); +}; + +#if !OSCL_DISABLE_INLINES +#include "oscl_tickcount.inl" +#endif + +#endif // OSCL_TICK_UTILS_H_INCLUDED + +/*! @} */ diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_tickcount.inl b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_tickcount.inl new file mode 100644 index 0000000..d4b2470 --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_tickcount.inl @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCLCONFIG_H_INCLUDED +#include "osclconfig.h" +#endif + +#ifndef OSCL_SINGLETON_H_INCLUDED +#include "oscl_singleton.h" +#endif + + +//See if the gettimeofday implementation is available. +//It relies on timeval and global variables... + +#ifndef OSCLCONFIG_TIME_H_INCLUDED +#include "osclconfig_time.h" +#endif + + +/************************ +* in each the following routines, there must be an valid clause +* in the #if - #elif chain for each platform. If not, a #error +* will be encountered, at compile time. +* +* If, in doing a new port, you do not yet know the appropriate value +* for one of these routines, an "OSCL_ASSERT(false)" could provide +* a temporary expedient. Better, though, not to depend on the runtime +* check .. which may occur at an inopportune time. +*/ + +OSCL_COND_EXPORT_REF OSCL_INLINE uint32 OsclTickCount::TickCount() +{ +#define ROLLBACK_THRESHOLD 0x80000000 + // lock this function against other threads changing the static variables + // ignore return value and error code + int32 errorCode = 0; + OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_TICKCOUNT, errorCode); + + struct timespec tv; + + static struct timespec stv = {0, 0}; + static uint32 prev_val = 0; + + if ((0 == stv.tv_sec) && (0 == stv.tv_nsec)) + clock_gettime(CLOCK_MONOTONIC, &stv); + + clock_gettime(CLOCK_MONOTONIC, &tv); + uint32 clk_val = (tv.tv_sec - stv.tv_sec) * 1000 + (tv.tv_nsec - stv.tv_nsec) / 1000000; + + if ((clk_val - prev_val) > ROLLBACK_THRESHOLD) + { + // assume clock rolled backwards so this update will be + // ignored since we require that the tick counter be monotonic + // non-decreasing. + clk_val = prev_val; + } + prev_val = clk_val; + OsclSingletonRegistry::registerInstanceAndUnlock(0, OSCL_SINGLETON_ID_TICKCOUNT, errorCode); + + return clk_val; + +} + +// how many ticks per second +OSCL_COND_EXPORT_REF OSCL_INLINE uint32 OsclTickCount::TickCountFrequency() +{ + return 1000; +} + +// how many microseconds per tick +OSCL_COND_EXPORT_REF OSCL_INLINE uint32 OsclTickCount::TickCountPeriod() +{ + return 1000; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE uint32 OsclTickCount::TicksToMsec(uint32 ticks) +{ + return ticks; +} + +OSCL_COND_EXPORT_REF OSCL_INLINE uint32 OsclTickCount::MsecToTicks(uint32 msec) +{ + return msec; +} + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_utf8conv.cpp b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_utf8conv.cpp new file mode 100644 index 0000000..c5e834c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_utf8conv.cpp @@ -0,0 +1,233 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/********************************************************************************* + + UTF-8 Bit Distribution + +UTF-16 1st Byte 2nd Byte 3rd Byte 4th Byte +-------- -------- -------- -------- -------- -------- -------- -------- +00000000 0xxxxxxx 0xxxxxxx +00000yyy yyxxxxxx 110yyyyy 10xxxxxx +zzzzyyyy yyxxxxxx 1110zzzz 10yyyyyy 10xxxxxx +110110ww wwzzzzyy 110111yy yyxxxxxx 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx + +NOTE: + uuuuu = wwww+1 (to account for addition of 0x10000 as in Section 3.7, Surrogates) + +**********************************************************************************/ + +#include "oscl_utf8conv.h" + +#define BYTE_1_REP 0x80 /* if <, will be represented in 1 byte */ +#define BYTE_2_REP 0x800 /* if <, will be represented in 2 bytes */ + +/* If the unicode value falls on or between these values, it will be + represented as 4 bytes +*/ +#define SURROGATE_MIN 0xd800 +#define SURROGATE_MAX 0xdfff + +/* Convention for naming of following defines + + SIGMASK_3_1 - Signature mask for 1st byte of 3 byte transformation + CLEARMASK_2_1 - Clearout mask for 1st byte of 2 byte transformation + ROR_3_2 - Rotate right value for 2nd byte of 3 byte transformation + +*/ + +#define SIGMASK_2_1 0xc0 +#define SIGMASK_3_1 0xe0 + + + +/**********************************************************************************/ +/* */ +/* Function: UnicodeToUTF8 */ +/* Description: Convert Unicode string to UTF8 byte sequence */ +/* */ +/* Parameters: szSrc - Unicode string to be converted */ +/* nSrcLen - Length of szSrc */ +/* strDest - char buffer for UTF8 text */ +/* nDestLen - size (in characters) of buffer */ +/* */ +/* Returns: On success, the number of bytes in the destination buffer */ +/* 0 on failure due to insufficient buffer size */ +/* */ +/* History: Created {DATE] {BY} {NAME} {PRODUCT REV} */ +/* Modified {DATE] {BY} {NAME} {PRODUCT REV} */ +/* */ +/**********************************************************************************/ + +OSCL_EXPORT_REF int32 oscl_UnicodeToUTF8(const oscl_wchar *szSrc, int32 nSrcLen, char *strDest, int32 nDestLen) +{ + int32 i = 0; + int32 i_cur_output = 0; + char ch_tmp_byte; + + if (nDestLen <= 0) + { + // We cannot append terminate 0 at this case. + return 0; /* ERROR_INSUFFICIENT_BUFFER */ + } + + for (i = 0; i < nSrcLen; i++) + { + if (BYTE_1_REP > szSrc[i]) /* 1 byte utf8 representation */ + { + if (i_cur_output + 1 < nDestLen) + { + strDest[i_cur_output++] = (char)szSrc[i]; + } + else + { + strDest[i_cur_output] = '\0'; /* Terminate string */ + return 0; /* ERROR_INSUFFICIENT_BUFFER */ + } + } + else if (BYTE_2_REP > szSrc[i]) /* 2 byte utf8 representation */ + { + if (i_cur_output + 2 < nDestLen) + { + strDest[i_cur_output++] = (char)(szSrc[i] >> 6 | 0xc0); + strDest[i_cur_output++] = (char)((szSrc[i] & 0x3f) | 0x80); + } + else + { + strDest[i_cur_output] = '\0'; /* Terminate string */ + return 0; /* ERROR_INSUFFICIENT_BUFFER */ + } + } + else if (SURROGATE_MAX > szSrc[i] && SURROGATE_MIN < szSrc[i]) + { /* 4 byte surrogate pair representation */ + if (i_cur_output + 4 < nDestLen) + { + ch_tmp_byte = (char)(((szSrc[i] & 0x3c0) >> 6) + 1); + strDest[i_cur_output++] = (char)(ch_tmp_byte >> 2 | 0xf0); + strDest[i_cur_output++] = (char)(((ch_tmp_byte & 0x03) | 0x80) | (szSrc[i] & 0x3e) >> 2); + /* @todo Handle surrogate pairs */ + } + else + { + strDest[i_cur_output] = '\0'; /* Terminate string */ + return 0; /* ERROR_INSUFFICIENT_BUFFER */ + } + } + else /* 3 byte utf8 representation */ + { + if (i_cur_output + 3 < nDestLen) + { + strDest[i_cur_output++] = (char)(szSrc[i] >> 12 | 0xe0); + strDest[i_cur_output++] = (char)(((szSrc[i] >> 6) & 0x3f) | 0x80); + strDest[i_cur_output++] = (char)((szSrc[i] & 0x3f) | 0x80); + } + else + { + strDest[i_cur_output] = '\0'; /* Terminate string */ + return 0; /* ERROR_INSUFFICIENT_BUFFER */ + } + } + } + + strDest[i_cur_output] = '\0'; /* Terminate string */ + + return i_cur_output; /* This value is in bytes */ +} + + +/**********************************************************************************/ +/* */ +/* Function: UTF8ToUnicode */ +/* Description: Convert UTF8 byte sequence to Unicode string */ +/* */ +/* Parameters: szSrc - UTF8 byte sequence to be converted */ +/* nSrcLen - Length of szSrc */ +/* strDest - unicode char buffer for */ +/* nDestLen - size (in characters) of buffer */ +/* */ +/* Returns: On success, the number of characters in the destination buffer */ +/* 0 on failure due to insufficient buffer size */ +/* */ +/* History: Created {DATE] {BY} {NAME} {PRODUCT REV} */ +/* Modified {DATE] {BY} {NAME} {PRODUCT REV} */ +/* */ +/**********************************************************************************/ + +OSCL_EXPORT_REF int32 oscl_UTF8ToUnicode(const char *szSrc, int32 nSrcLen, oscl_wchar *strDest, int32 nDestLen) +{ + int32 i = 0; + int32 i_cur_output = 0; + + if (nDestLen <= 0) + { + // We cannot append terminate 0 at this case. + return 0; /* ERROR_INSUFFICIENT_BUFFER */ + } + + unsigned char *pszSrc = (unsigned char *)szSrc; /* cast to avoid signed/unsigned promomtion problems */ + while (i < nSrcLen) + { + /* @todo Handle surrogate pairs */ + if (SIGMASK_3_1 <= pszSrc[i]) /* 1st byte of 3 byte representation */ + { + if (i + 2 < nSrcLen && i_cur_output + 1 < nDestLen) + { + strDest[i_cur_output++] = (((wchar_t)(pszSrc[i] & 0x0f)) << 12) | + (((wchar_t)(pszSrc[i+1] & 0x3f)) << 6) | + ((wchar_t)(pszSrc[i+2] & 0x3f)); + i += 3; + } + else + { + strDest[i_cur_output] = 0; /* Terminate string */ + return 0; /* ERROR_INSUFFICIENT_BUFFER */ + } + } + else if (SIGMASK_2_1 <= pszSrc[i]) /* 1st byte of 2 byte representation */ + { + if (i + 1 < nSrcLen && i_cur_output + 1 < nDestLen) + { + strDest[i_cur_output++] = (wchar_t)(((wchar_t)pszSrc[i] & ~0xc0) << 6 | + ((wchar_t)pszSrc[i+1] & ~0x80)); + i += 2; + } + else + { + strDest[i_cur_output] = 0; /* Terminate string */ + return 0; /* ERROR_INSUFFICIENT_BUFFER */ + } + } + else /* Single byte representation */ + { + if (i < nSrcLen && i_cur_output + 1 < nDestLen) + { + strDest[i_cur_output++] = (wchar_t)pszSrc[i]; + ++i; + } + else + { + strDest[i_cur_output] = 0; /* Terminate string */ + return 0; /* ERROR_INSUFFICIENT_BUFFER */ + } + } + } + + strDest[i_cur_output] = 0; /* Terminate string */ + return i_cur_output; +} + + diff --git a/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_utf8conv.h b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_utf8conv.h new file mode 100644 index 0000000..154fb8c --- /dev/null +++ b/decoder/src/main/jni/android-opencore-20120628-patch-stereo/oscl/oscl/osclutil/src/oscl_utf8conv.h @@ -0,0 +1,120 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2010 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +// -*- c++ -*- +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +// O S C L _ U T F 8 C O N V + +// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + +/*! \addtogroup osclutil OSCL Util + * + * @{ + */ + + +/** \file oscl_utf8conv.h + \brief Utilities to convert unicode to utf8 and vice versa +*/ + + +/******************************************************************************** + UTF-8 Bit Distribution + +UTF-16 1st Byte 2nd Byte 3rd Byte 4th Byte +-------- -------- -------- -------- -------- -------- -------- -------- +00000000 0xxxxxxx 0xxxxxxx +00000yyy yyxxxxxx 110yyyyy 10xxxxxx +zzzzyyyy yyxxxxxx 1110zzzz 10yyyyyy 10xxxxxx +110110ww wwzzzzyy 110111yy yyxxxxxx 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx + +NOTE: + uuuuu = wwww+1 (to account for addition of 0x10000 as in Section 3.7, Surrogates) + +**********************************************************************************/ + + +#ifndef OSCL_UTF8CONV_H +#define OSCL_UTF8CONV_H + +#ifndef OSCL_BASE_INCLUDED_H +#include "oscl_base.h" +#endif + +/*! +** Define the maximum UTF8 representation in bytes. +** @todo Handle 4-byte surrogate pair representation +*/ +#define MAX_NUMBER_OF_BYTE_PER_UTF8 3 + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Function prototypes +/*! + \brief Convert UTF8 byte sequence to Unicode UTF-16 string + + The function converts UTF8 byte sequence (or ASCII sequence) to UTF-16 string. + The length of input UTF8 byte sequence is specified. It stops at two conditions: + (A) Whole input UTF8 byte sequence is successfully converted. + (B) Output buferr is not enough for output, or parse error. + In case of (A), it adds a terminated '\0' at the end of the output Unicode string, + and returns length of the output Unicode string(without counting terminated '\0'). + In case of (B), it converts as much as possible to the output buffer and adds a terminated '\0' + at the end of the output Unicode string"(no '\0' added if outLength is less than or + equal to 0, return 0)", and returns 0. + Please note that Unicode character exceeding U+FFFF are not supported. + + \param input Ptr to an input UTF8 byte sequence. '\0' termanation is not neccesary. + \param inLength The length of the input UTF8 byte sequence, without counting terminated '\0'(if any). + \param output Ptr to an output buffer which output Unicode string is written in. + \param outLength The size of output buffer, also the maximum number of oscl_wchar could be written in. + \return Length of output (excludes '\0') : completely converts all input string and appends '\0' to output; + 0 : insufficient buffer or error in conversion +*/ + +OSCL_IMPORT_REF int32 oscl_UTF8ToUnicode(const char *input, int32 inLength, oscl_wchar *output, int32 outLength); + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Function prototypes +/*! + \brief Convert UTF-16 Unicode string to UTF8 byte sequence + + The function converts Unicode string to UTF8 byte sequence. + The length of input Unicode string is specified. It stops at two conditions: + (A) Whole input Unicode string is successfully converted. + (B) Destination buferr is not enough for output. + In case of (A), it adds a terminated '\0' at the end of the output UTF8 byte sequence. + and returns length of the output UTF8 byte sequence(without counting terminated '\0'). + In case of (B), it converts as much as possible to the output buffer and adds a terminated '\0' + at the end of the output UTF8 byte sequence"(no '\0' added if outLength is less than or + equal to 0, return 0)", and returns 0. + Please note that Unicode character exceeding U+FFFF are not supported. + + \param input Ptr to an input Unicode string. '\0' termanation is not neccesary. + \param inLength The length of the input Unicode string, without counting terminated '\0'(if any). + \param output Ptr to an output buffer which output UTF8 byte sequence is written in. + \param outLength The size of output buffer, also the maximum number of char could be written in. + \return length of output (excludes '\0') : completely converts all input string and appends '\0' to output; + 0 : insufficient buffer or error in conversion +*/ + +OSCL_IMPORT_REF int32 oscl_UnicodeToUTF8(const oscl_wchar *input, int32 inLength, char *output, int32 outLength); + +#endif /* OSCL_UTF8CONV_H */ + +/*! @} */ diff --git a/decoder/jni/opencore-aacdec/Android.mk b/decoder/src/main/jni/opencore-aacdec/Android.mk similarity index 100% rename from decoder/jni/opencore-aacdec/Android.mk rename to decoder/src/main/jni/opencore-aacdec/Android.mk diff --git a/decoder/jni/opencore-aacdec/Apache-LICENSE-2.0.txt b/decoder/src/main/jni/opencore-aacdec/Apache-LICENSE-2.0.txt similarity index 100% rename from decoder/jni/opencore-aacdec/Apache-LICENSE-2.0.txt rename to decoder/src/main/jni/opencore-aacdec/Apache-LICENSE-2.0.txt diff --git a/decoder/jni/opencore-aacdec/oscl/oscl_base.h b/decoder/src/main/jni/opencore-aacdec/oscl/oscl_base.h similarity index 100% rename from decoder/jni/opencore-aacdec/oscl/oscl_base.h rename to decoder/src/main/jni/opencore-aacdec/oscl/oscl_base.h diff --git a/decoder/jni/opencore-mp3dec/Android.mk b/decoder/src/main/jni/opencore-mp3dec/Android.mk similarity index 100% rename from decoder/jni/opencore-mp3dec/Android.mk rename to decoder/src/main/jni/opencore-mp3dec/Android.mk diff --git a/decoder/jni/opencore-mp3dec/Apache-LICENSE-2.0.txt b/decoder/src/main/jni/opencore-mp3dec/Apache-LICENSE-2.0.txt similarity index 100% rename from decoder/jni/opencore-mp3dec/Apache-LICENSE-2.0.txt rename to decoder/src/main/jni/opencore-mp3dec/Apache-LICENSE-2.0.txt diff --git a/decoder/jni/opencore-mp3dec/oscl/oscl_base.h b/decoder/src/main/jni/opencore-mp3dec/oscl/oscl_base.h similarity index 100% rename from decoder/jni/opencore-mp3dec/oscl/oscl_base.h rename to decoder/src/main/jni/opencore-mp3dec/oscl/oscl_base.h diff --git a/default.properties b/default.properties deleted file mode 100644 index 4e60828..0000000 --- a/default.properties +++ /dev/null @@ -1,9 +0,0 @@ -# -# This file is needed by the Android SDK ! -# - -# -# Project target. -# -target=android-3 - diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..db0a467 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Settings specified in this file will override any Gradle settings +# configured through the IDE. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +#org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8c0fb64 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0c71e76 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 10 15:27:10 PDT 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/local.properties b/local.properties new file mode 100644 index 0000000..2562dfa --- /dev/null +++ b/local.properties @@ -0,0 +1,12 @@ +## This file is automatically generated by Android Studio. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Wed Jun 10 13:30:11 EEST 2015 +ndk.dir=/opt/android-ndk-current +sdk.dir=/opt/android-sdk-current diff --git a/player/build.gradle b/player/build.gradle new file mode 100644 index 0000000..12a4281 --- /dev/null +++ b/player/build.gradle @@ -0,0 +1,36 @@ +apply plugin: 'com.android.application' +apply plugin: 'com.getkeepsafe.dexcount' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.1" + + defaultConfig { + applicationId "com.spoledge.aacplay" + minSdkVersion 15 + targetSdkVersion 23 + versionCode 1 + versionName "0.8" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + packagingOptions { + exclude 'META-INF/LICENSE' + exclude 'META-INF/NOTICE' + } + + lintOptions { + abortOnError false + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile project(':decoder') +} diff --git a/player/build.properties b/player/build.properties deleted file mode 100644 index f848a3e..0000000 --- a/player/build.properties +++ /dev/null @@ -1,20 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked in Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - -# The name of your application package as defined in the manifest. -# Used by the 'uninstall' rule. -application.package=com.spoledge.aacplay diff --git a/player/build.xml b/player/build.xml deleted file mode 100644 index 5215697..0000000 --- a/player/build.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - -Please run the main build.xml first. -You should go to the parent directory and run ant again. - - - - - - - - - - - - - - diff --git a/player/pom.xml b/player/pom.xml deleted file mode 100644 index 4f814f4..0000000 --- a/player/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - 4.0.0 - - - com.spoledge.aacdecoder - aacdecoder - 0.8-SNAPSHOT - - - aacdecoder-demo - - apk - - AAC Decoder for Android - Demo - - - - - com.spoledge.aacdecoder - aacdecoder-lib - ${project.version} - apklib - - - - com.google.android - android - provided - - - - - - - src - - - - - - - - - com.jayway.maven.plugins.android.generation2 - android-maven-plugin - true - - - true - - res - true - - - - manifestUpdate - process-resources - - manifest-update - - - - alignApk - package - - zipalign - - - - - - - - - diff --git a/player/AndroidManifest.xml b/player/src/main/AndroidManifest.xml similarity index 100% rename from player/AndroidManifest.xml rename to player/src/main/AndroidManifest.xml diff --git a/player/src/com/spoledge/aacplay/AACPlayerActivity.java b/player/src/main/java/com/spoledge/aacplay/AACPlayerActivity.java similarity index 100% rename from player/src/com/spoledge/aacplay/AACPlayerActivity.java rename to player/src/main/java/com/spoledge/aacplay/AACPlayerActivity.java diff --git a/player/src/com/spoledge/aacplay/History.java b/player/src/main/java/com/spoledge/aacplay/History.java similarity index 100% rename from player/src/com/spoledge/aacplay/History.java rename to player/src/main/java/com/spoledge/aacplay/History.java diff --git a/player/res/layout/main.xml b/player/src/main/res/layout/main.xml similarity index 100% rename from player/res/layout/main.xml rename to player/src/main/res/layout/main.xml diff --git a/player/res/values-cs/strings.xml b/player/src/main/res/values-cs/strings.xml similarity index 100% rename from player/res/values-cs/strings.xml rename to player/src/main/res/values-cs/strings.xml diff --git a/player/res/values/colors.xml b/player/src/main/res/values/colors.xml similarity index 100% rename from player/res/values/colors.xml rename to player/src/main/res/values/colors.xml diff --git a/player/res/values/strings.xml b/player/src/main/res/values/strings.xml similarity index 100% rename from player/res/values/strings.xml rename to player/src/main/res/values/strings.xml diff --git a/player/res/values/styles.xml b/player/src/main/res/values/styles.xml similarity index 100% rename from player/res/values/styles.xml rename to player/src/main/res/values/styles.xml diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 8fbb851..0000000 --- a/pom.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - 4.0.0 - - com.spoledge.aacdecoder - aacdecoder - 0.8-SNAPSHOT - - pom - - AAC Decoder for Android - - - decoder - player - - - - UTF-8 - 1.5_r4 - 3 - - - - - - junit - junit - 4.11 - - - com.google.android - android - ${android-lib} - - - - - - - - - maven-jarsigner-plugin - 1.2 - - - - maven-resources-plugin - 2.5 - - UTF-8 - - - - - maven-clean-plugin - 2.5 - - - - com.jayway.maven.plugins.android.generation2 - android-maven-plugin - 3.8.1 - - - ${android-sdk} - - - true - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.5 - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - com.jayway.maven.plugins.android.generation2 - android-maven-plugin - [3.2.0,) - - manifest-update - - - - - - - - - - - - - - - - - release - - - performRelease - true - - - - - - diff --git a/sample.ant.properties b/sample.ant.properties deleted file mode 100644 index d0fceb6..0000000 --- a/sample.ant.properties +++ /dev/null @@ -1,40 +0,0 @@ -# -# This is a build configuration file. -# - - -# -# The Android SDK home directory: -# -sdk.dir=/usr/local/google/android - - -# -# The Android NDK home directory: -# -ndk.home=/usr/local/google/android-ndk-r9c - - -# -# The directory containing the extracted Android OpenCORE project -# -opencore-top.dir=/usr/local/other-libs/android-opencore-git - - -# -# The debug level of the JNI/C code. -# Allowed values are: trace, debug, info, warn, error -# -jni.loglevel=info - - -# -# Options passed to the Makefile, e.g: -# -d = debug all -# --debug=v = set debug level (a, b, v, i, j, m) -# -qp = print the database of rules (nothing remade) -# -# Or targets: -# dump = dumps all targets -# -make.options= diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..f14e6d9 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +include ':decoder' +include ':player'